Repository navigation
feat(rust): read and enforce the reference facet in the Rust loader - #697
Merged
Merged
Conversation
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
server/rust/metaobjects/src/providers.rsaccepts thereffacet on atype: "attr"entry, validates it (string attrs only,targetType,targetSubTypes,fieldPath,sameSystem, error codes) and carries it to a newAttrSchema::reference. A structural child carryingrefis refused.validate/refs.rsenforces the facet through a kind-typed symbol table. It resolvesSystem.childandpkg::System.child, and reports unresolved values (ERR_REF_UNRESOLVED), wrong-kind targets (ERR_REF_WRONG_KIND) and cross-system targets (sameSystem). It also writes a canonical walked path for references.ReferenceDescriptoris now{ attr, facet: ReferenceFacet }, andregistry.rsholds the newReferenceFacettype.manifest.rs) writesrefonly on attributes that carry one. A root-level node and a same-named package node in one document now stay two nodes, which closes theyaml-ref-root-escapefixture (yaml-conformance19 of 19). Rust API users who buildReferenceDescriptororAttrSchemaby struct literal need the changed fields (seechangelog.d/rust-reference-facet.md).Validation
Risk Assessment
Testing
Ran the two proving suites named in the intent (Rust reference resolver unit tests and yaml-conformance; both pass). Drove the real cargo-meta CLI live on two throwaway projects: a valid root-escape model generates and verifies clean, and an unresolved reference fails the load with its error code and writes nothing. The unit-test and conformance results are not live scenarios and are marked untested for live purposes. The configured
scripts/ci-local.sh --affected --strict-toolchainsbaseline passed at this commit and was not re-run. Facet-specific CLI scenarios (wrong kind, wrong subtype, cross-system) are covered only by unit tests because no shipped definition uses the facet yet, so they are not live.Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
scripts/ci-local.sh --affected --strict-toolchainscargo test -p metaobjects --lib refs(36 passed: unresolved, wrong kind, wrong subtype, crosses system, role and app both namedapi, system.child resolution, manifest ref key)cargo test -p metaobjects --test yaml_conformance(yaml_corpus passed, covers yaml-ref-root-escape)Inspectedserver/rust/metaobjects/tests/yaml-conformance-expected-failures.json: ledger notes and fixtures empty, minPassing 19cargo build -p metaobjects-clithen livecargo-meta init+ metadata with root-level::Appleshadow model (from yaml-ref-root-escape input) +cargo-meta gen(exit 0) +cargo-meta verify --codegen(in sync, exit 0)Live adversarial:cargo-meta genon field.object objectRef::Nope-> exit 1, ERR_UNRESOLVED_OBJECT_REF, nothing writtenRemoved throwaway projects under /mnt/scratch; worktree clean✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.