Repository navigation
feat(metadata): read and enforce the reference facet in the TypeScript loader - #695
Merged
Merged
Conversation
…t loader The spec reader carries ref on an attr entry; the generic resolver enforces it (target type, subtype list, same system, the facet's codes); the symbol table resolves System.child and pkg::System.child with a kind-typed final segment and looks a bare value up in the referrer's containers first; the registry manifest writes ref only on an attribute that has one. No definition file uses the facet, so no registry or generated output changes.
# Conflicts: # changelog.d/adr-0070-systems-and-reference-facet.md # spec/metamodel-definitions.md
dmealing
added a commit
that referenced
this pull request
Dec 3, 2026
…697) The spec reader in providers.rs validates `ref` on an attr entry (refusing a bad facet, or one on a structural child) and carries it to AttrSchema::reference. The registered walk enforces it through a kind-typed symbol table: System.child and pkg::System.child, bare values found in the referrer's containers first, an untyped lookup only for the wrong-kind code, and sameSystem judged on the walked path. The reference pass writes the walked path and keeps a value as written when its canonical spelling would not look up the same target. The registry manifest writes `ref` only when present. A provider's own code keeps its spelling in MetaError::provider_code. A parent-relative `..::Owner.field` value resolves its owner. A same-document root-level node and a same-named packaged node are no longer merged, which closes yaml-ref-root-escape: yaml-conformance is 19 of 19 with an empty ledger. No definition file uses the facet, so no registry, manifest or generated output changes. Mirrors the TypeScript (#695), C# (#694) and Java (#696) loaders.
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.
What Changed
refon a provider definition's attribute entry, and the loader enforces it. Lookup is typed by target and resolvesSystem.child,pkg::System.child(including inherited children) and bare names from the referrer's containers first. It checks resolution, allowed subtypes and same-system, then rewrites the value to a canonical spelling only if that spelling reloads to the same target. The registry manifest writesrefonly on attributes that have it. No definition file uses the facet yet.TypeDefinition.referencesin code,targetSubTypebecomes the listtargetSubTypes,dottedFieldPathbecomesfieldPath, anderrorCodeis now optional. The symbol table moves toloader/symbol-table.ts, the reference facet types and default codes are exported, and new tests inreference-facet.test.tscover the facet with a test provider.ERR_REF_UNRESOLVEDandERR_REF_WRONG_KINDare added to the shared error-code fixture, its vendored Rust copy, and the TypeScript, Python and Java catalogs. The spec now defines the manifest key order, inherited-child and canonical-spelling rules, and lists TypeScript beside C# as ports that read the facet. Related docs, comments and a changelog fragment are updated.This is the second no-mistakes run on this branch.
Validation
Risk Assessment
✅ Low: The facet is read only, and no definition file uses it yet, so no registry, manifest or generated output changes. Existing core references keep their error codes. The merge with main left no duplicate error codes, the Status line matches the owner's decision, and earlier rounds already reviewed the remaining logic.
Testing
I drove the reference facet through the real
metaCLI and the public library with a disposable test provider, and every scenario behaved as the spec describes. The valid model, including a role and an app both namedapi, verified clean. Each broken variant exited 1 with the expected code. Canonical spellings reloaded to the same targets. A base-versus-target comparison found no differences in 575 conformance fixtures (5 with non-core providers were skipped in this comparison), an unchanged registry manifest with norefkey, and identical codes and messages for the four core reference errors sampled. Broad regression came from the configuredscripts/ci-local.sh --affected --strict-toolchainsrun, which had already passed at this commit. The change has no UI, so the evidence is CLI and library transcripts. The throwaway project was removed and the worktree is clean.refand runsmeta verify: a valid model passes (role and app both namedapi, bare, dotted, qualified and list values), and unresolved, wrong-kind, wrong-subt…Ledger.clerkare kept, and attempts to cross systems or use…Parcels.clerkfrom Ledger raises ERR_RUNSAS_OTHER_SYSTEM; the shared intermediateapii…Evidence: meta verify transcript: adopter provider with the ref facet (valid and broken models)
Evidence: Library load, canonical serialize and reload transcript, with adversarial cases
Evidence: Base versus target comparison: conformance corpus, registry manifest, core reference errors
Evidence: Round-trip driver script
Evidence: Test provider used by the round-trip script
Evidence: Base versus target comparison script
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
refand runsmeta verify: a valid model passes (role and app both namedapi, bare, dotted, qualified and list values), and unresolved, wrong-kind, wrong-subt…Ledger.clerkare kept, and attempts to cross systems or use…Parcels.clerkfrom Ledger raises ERR_RUNSAS_OTHER_SYSTEM; the shared intermediateapii…scripts/ci-local.sh --affected --strict-toolchainsBroad regression came from the configured test commandscripts/ci-local.sh --affected --strict-toolchains, which had already run and passed at target commit c510e09ae1. I did not re-run it, and I changed no source or test files.bun server/typescript/packages/cli/bin/meta.ts verify --templatesagainst a throwaway adopter project whosemetaobjects.config.tsregisters a provider usingref: one valid model, then unresolved, wrong kind, wrong subtype, crosses system and bad list element variantsbun roundtrip.ts: library load, thencanonicalSerialize, then reload, comparing rewritten values and bound targets, with adversarial cases for inherited children and references, an ambiguous intermediate segment, two bad list elements, empty or trailing-dot segments and an over-dropping..::bun .tmp-diff.ts: base 99b6d20919 loader against the target loader overfixtures/conformancewith core providers, the registry manifest againstfixtures/registry-conformance/expected-registry.json, and the four existing core reference errors✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.