feat: globals_build --build merge + generated JSON/MD (Task 2)

build/globals.json is generated (build/ is gitignored, regenerable via
globals_build.py --build); docs/global-reference.md is the tracked human view.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-07-07 08:23:17 -04:00
parent 7306423505
commit 84a8da765f
3 changed files with 16505 additions and 0 deletions

View File

@@ -27,8 +27,22 @@ def test_lint_catches_bad_vocab():
check(any("category" in e for e in errors), "lint flags bad category")
check(any("confidence" in e for e in errors), "lint flags auto-shape claiming high confidence")
def test_merge_precedence():
curated, _ = G.load_toml(paths.VM_MAP / "globals.toml")
auto = G.load_auto(paths.BUILD / "global-var-map.json")
merged = G.merge(curated, auto)
check(merged[0xa57]["name"] == "lily_form_a", "curated 0xa57 name wins over auto label")
check(merged[0xa57]["category"] == "story-flag", "curated 0xa57 category overrides auto string-table")
check(merged[0xa57]["provenance"] == "curated", "0xa57 marked curated")
# an address only in the auto map falls through as provenance=auto
auto_only = next((a for a in auto.get("globals", {})
if int(a, 16) not in curated and auto["globals"][a].get("label")), None)
check(auto_only is not None and merged[int(auto_only, 16)]["provenance"] == "auto",
"auto-only address retained with provenance=auto")
if __name__ == "__main__":
test_load_and_lint()
test_lint_catches_bad_vocab()
test_merge_precedence()
print(f"\n{len(FAILS)} failures")
sys.exit(1 if FAILS else 0)