fix(client): bake the version into the build, so an export can invalidate its cache (T-1241)
current_schema_version() line-scanned res://../project.yaml at runtime. That resolves to the repo root in a dev run and to nothing in an exported build, so a shipped game got the "?.?.?" fallback every time. Since that tag is the Atlas disk cache's ONLY invalidation signal, every exported build stamped and compared the same sentinel: a canvas cached by one build would be served by every later build, forever. T-1239 is what that failure looks like once it happens. loading_screen.gd carried a byte-for-byte copy of the same function, so the version shown to the player was "?.?.?" in exactly the builds where a version string is worth showing. Both call sites now share client/scripts/build_version.gd, which reads application/config/version out of ProjectSettings — a value Godot bakes into the PCK, identical in the editor and in an export by construction rather than by luck. No file IO, no fallback branch. project.yaml stays the source of truth (CLAUDE.md); client/project.godot mirrors it. A mirror nobody checks would be worse than the bug it replaces -- the old code failed loudly everywhere, a stale mirror fails silently -- so tooling/check-client-version compares the two and the pre-push hook runs it unconditionally. Not gated on "were those files in this push": drift persists on main once introduced, and gating would let an existing drift ride along. The test this replaces asserted that current_schema_version() did not return its fallback, and passed -- in the one environment where the code under test worked. Three tests now pin the property that actually matters: a real version, sourced from the baked setting, matching project.yaml. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -96,6 +96,10 @@ extends RefCounted
|
||||
## comment.
|
||||
|
||||
const StepCanvasCache := preload("res://ui/implant/apps/atlas/step_canvas/step_canvas_cache.gd")
|
||||
## preload, not a `class_name` reference: this script is reachable from the
|
||||
## ImplantRegistry autoload's preload graph, and CLAUDE.md's autoload parse-order
|
||||
## rule makes a bare class_name unsafe there.
|
||||
const BuildVersion := preload("res://scripts/build_version.gd")
|
||||
|
||||
## Tier tags, mirroring stig-round2.md's IndexEntry.tier field exactly.
|
||||
const TIER_GEOMETRY: String = "Geometry"
|
||||
@@ -167,21 +171,14 @@ var _root: String = DEFAULT_ROOT
|
||||
var _indexes: Dictionary = {} # body_id String -> (key String -> IndexEntry Dictionary)
|
||||
|
||||
|
||||
## T-1241: this used to line-scan `res://../project.yaml` itself. That path
|
||||
## resolves to the repo root in a dev run and to nothing in an exported build, so
|
||||
## a shipped game got the "?.?.?" fallback — and since this tag is the cache's
|
||||
## only invalidation signal, EVERY exported build stamped and compared the same
|
||||
## sentinel, making the cache permanently un-invalidatable. The version now comes
|
||||
## from ProjectSettings, which Godot bakes into the PCK. See build_version.gd.
|
||||
static func current_schema_version() -> String:
|
||||
var yaml_path := ProjectSettings.globalize_path("res://") + "/../project.yaml"
|
||||
if not FileAccess.file_exists(yaml_path):
|
||||
return "?.?.?"
|
||||
var file := FileAccess.open(yaml_path, FileAccess.READ)
|
||||
if file == null:
|
||||
return "?.?.?"
|
||||
var content := file.get_as_text()
|
||||
file.close()
|
||||
for line: String in content.split("\n"):
|
||||
if line.begins_with("version:"):
|
||||
var parts := line.split(":", false, 1)
|
||||
if parts.size() >= 2:
|
||||
return parts[1].strip_edges()
|
||||
return "?.?.?"
|
||||
return BuildVersion.current()
|
||||
|
||||
|
||||
## `root` is injectable so tests never touch the real
|
||||
|
||||
@@ -2,7 +2,11 @@ extends MetaScreen
|
||||
## #257: Loading screen overlay — blocks input during save/load round-trip.
|
||||
## Shown when LOAD_GAME fires; hidden when save_result arrives (success or failure).
|
||||
## Full-screen, dark overlay with centered status text.
|
||||
## #724: Shows client version (from project.yaml) and protocol version below the status text.
|
||||
## #724: Shows client version and protocol version below the status text. The
|
||||
## version comes from ProjectSettings (mirrored from project.yaml) so it survives
|
||||
## an export — see build_version.gd (T-1241).
|
||||
|
||||
const BuildVersion := preload("res://scripts/build_version.gd")
|
||||
|
||||
const BG_COLOR := Color(0.05, 0.05, 0.08, 1.0)
|
||||
const TEXT_COLOR := Color("#c8d0e0")
|
||||
@@ -55,21 +59,19 @@ func _build_ui() -> void:
|
||||
add_child(_version_label)
|
||||
|
||||
|
||||
## T-1241: was a byte-for-byte copy of the disk cache's own project.yaml scan,
|
||||
## with the same export defect — a shipped build has no res://../project.yaml, so
|
||||
## the version shown to the player read "?.?.?" in exactly the builds where a
|
||||
## version string is worth showing. Both call sites now share build_version.gd.
|
||||
##
|
||||
## The display fallback stays HERE rather than in the accessor: BuildVersion
|
||||
## returns "" for a missing setting and does not invent a value, because its
|
||||
## other caller keys cache invalidation on it and a plausible-looking sentinel
|
||||
## there is what made this bug survive. A label, unlike a cache key, still has to
|
||||
## render something, so it substitutes its own.
|
||||
func _read_client_version() -> String:
|
||||
var yaml_path := ProjectSettings.globalize_path("res://") + "/../project.yaml"
|
||||
if not FileAccess.file_exists(yaml_path):
|
||||
return "?.?.?"
|
||||
var file := FileAccess.open(yaml_path, FileAccess.READ)
|
||||
if file == null:
|
||||
return "?.?.?"
|
||||
var content := file.get_as_text()
|
||||
file.close()
|
||||
for line: String in content.split("\n"):
|
||||
if line.begins_with("version:"):
|
||||
var parts := line.split(":", false, 1)
|
||||
if parts.size() >= 2:
|
||||
return parts[1].strip_edges()
|
||||
return "?.?.?"
|
||||
var v := BuildVersion.current()
|
||||
return v if not v.is_empty() else "?.?.?"
|
||||
|
||||
|
||||
## Update the status text shown while loading. Call before show_loading() or after.
|
||||
|
||||
Reference in New Issue
Block a user