Skip to content

fix(config-validation): reject bare segment-local names in depends_on (095)#103

Merged
brandon-fryslie merged 1 commit into
mainfrom
brandon-config-validation-095
Jun 12, 2026
Merged

fix(config-validation): reject bare segment-local names in depends_on (095)#103
brandon-fryslie merged 1 commit into
mainfrom
brandon-config-validation-095

Conversation

@brandon-fryslie

Copy link
Copy Markdown
Contributor

Summary

Closes brandon-config-validation-095.

validateCrossReferences (src/config/loader/cross-ref.ts) maintained a second name set — allVarNames, containing both bare and namespaced segment-local names — used only to validate cache.depends_on lists. But the runtime depends_on reaction (src/var-system/sources.ts) calls store.read(name) with each listed name verbatim, and segment locals exist in the store only under segName.varName (declareOne, src/dsl/render.ts). A bare segment-local name in depends_on validated at load but threw at runtime.

[LAW:one-source-of-truth] — the fix deletes the divergent set rather than teaching the runtime to alias. depends_on now validates against the same templateScope that template refs use (the faithful mirror of the store's key set), completing the zk5 NAMESPACED-ONLY rule for the last reference surface. cycles.ts already modeled the graph namespaced-only, so the loader is now uniformly aligned.

Two deliberate semantics in checkDependsOn:

  • Exact .has() membership, not refResolves — template refs may name a dotted prefix and navigate into a value; depends_on entries are literal store keys, so a navigable prefix is still an error (pinned by test).
  • Namespaced-form hint — a bare name that would resolve under the declaring segment's namespace gets (segment-local vars are namespaced — write "seg.name"), same diagnostic shape as the zk5 template hint.

Verification

Ticket criterion: a config with cache.depends_on: ["localName"] where only segName.localName is declared produces a load-time diagnostic — pinned by new tests (bare sibling w/ hint, bare from global w/o hint, namespaced passes, exact-key vs prefix). Repros use shell/git/literal vars per the cje note (time vars are ttl-only and can't declare depends_on).

  • pnpm typecheckpnpm lint
  • Full suite: 68 suites, 1128 tests ✅

… (095)

validateCrossReferences kept a second name set (allVarNames: bare +
namespaced segment locals) solely for depends_on, admitting bare names
the runtime store cannot resolve — the depends_on reaction calls
store.read(name) verbatim and segment locals exist only under
segName.varName. [LAW:one-source-of-truth]: the divergent copy is
deleted; depends_on now validates against the same templateScope as
template refs (globals bare, segment locals namespaced), with exact-key
membership mirroring store.read, and a diagnostic naming the namespaced
form when the bare name would resolve under the declaring segment.
@brandon-fryslie brandon-fryslie merged commit c0d68ed into main Jun 12, 2026
6 of 8 checks passed
@brandon-fryslie brandon-fryslie deleted the brandon-config-validation-095 branch June 12, 2026 03:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants