fix(config-validation): reject bare segment-local names in depends_on (095)#103
Merged
Merged
Conversation
… (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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 validatecache.depends_onlists. But the runtimedepends_onreaction (src/var-system/sources.ts) callsstore.read(name)with each listed name verbatim, and segment locals exist in the store only undersegName.varName(declareOne, src/dsl/render.ts). A bare segment-local name independs_onvalidated 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_onnow validates against the sametemplateScopethat template refs use (the faithful mirror of the store's key set), completing the zk5 NAMESPACED-ONLY rule for the last reference surface.cycles.tsalready modeled the graph namespaced-only, so the loader is now uniformly aligned.Two deliberate semantics in
checkDependsOn:.has()membership, notrefResolves— template refs may name a dotted prefix and navigate into a value;depends_onentries are literal store keys, so a navigable prefix is still an error (pinned by test).(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 onlysegName.localNameis 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 typecheck✅pnpm lint✅