Repository navigation
feat(metadata): read and enforce the reference facet in the Java loader - #696
Merged
Merged
Conversation
The spec reader validates `ref` on an attr entry (refusing a bad facet, or one on a structural child) and carries it onto the attr's ChildRequirement / CommonAttributeDef; the registry-derived walk enforces it through a kind-typed symbol table (System.child, pkg::System.child, bare values found in the referrer's containers first, untyped lookup only for the wrong-kind code, sameSystem judged on the walked path); the reference pass binds facet attributes to the walked path and keeps a value as written when its canonical spelling would not reload to the same target; the registry manifest writes `ref` only when present. A provider's own code keeps its spelling (MetaDataException.getProviderCode / getCodeName). A parent-relative `..::` owner now resolves (the walk no longer cuts at the first dot), and a dotted `extends` whose owner is a non-object top-level node resolves, as in TS and C#. Kotlin runs on it. No definition file uses the facet, so no registry, manifest or generated output changes. Mirrors the C# loader (#694) case for case.
Keep main's single copy of ERR_REF_UNRESOLVED/ERR_REF_WRONG_KIND and list Java and Kotlin on the reference-facet Status line.
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
reffacet on provider-definition attributes. This covers target type and subtypes,fieldPath,sameSystem,System.childandpkg::System.childlookups, bare values found in the referrer's containers first, canonical rewriting, and writingrefto the registry manifest only when present.ReferenceFacetTestis added, and the spec's list of enforcing ports now includes Java and Kotlin. No shipped definition file uses the facet yet.@referencesvalues now resolve, and a dottedextendscan target a non-object top-level owner. An@objectRefor@referencesvalue that climbs above the root package now raisesERR_BAD_ATTR_VALUE, and an inherited reference is checked in its declaring node's package. A provider's custom error code is preserved throughMetaDataException.getProviderCode()andgetCodeName().ReferenceDescriptoris now(attr, ReferenceFacet), andSymbolTableloses its public no-argument constructor (useSymbolTable.build(root)).SymbolTablegains typedresolveandlookupmethods, andSpecMetamodelReader.fromJsonparses provider definitions from JSON text. A changelog fragment includes upgrade notes.Validation
Risk Assessment
✅ Low: The change mirrors the merged TypeScript reference closely. No shipped definition uses the facet, so registry and manifest output do not change. Each behavior change to the four core references is deliberate, matches TypeScript and is recorded in the changelog. New JUnit cases built on the spec cover them.
Testing
The baseline
scripts/ci-local.sh --affected --strict-toolchainshad already passed at this commit and supplies broad regression. I ran the focusedReferenceFacetTestandmetadata-ktxtests, then drove 23 synthetic models with a test provider through the Java loader, the TypeScript loader and the KotlinloadStringfacade. Java and TypeScript reported identical codes on every case and byte-identical canonical output on every clean load. Kotlin matched too, except that its facade throws a single exception, so the two-bad-entries list case surfaced onlyERR_REF_WRONG_KIND. The code sits on that exception's cause, under aMetaDataLoadingExceptionwrapper fromfromString, which this change does not modify. An empty-string reference value loads clean in all three. The change has no UI, so the evidence is CLI transcripts and serialized output. The temporary harness was removed and the worktree is clean.apibind by kind; unresolved, wrong-kind, wrong-subtype and cross-system values are refused w…System.child,pkg::System.child, root-absolute, field-path and parent-relative@referencesvalues canonicalize as in TypeScript; the manifest writesref…metadata-ktxloadStringand gets the same enforcement and canonical output, and the existingmetadata-ktxtests still passEvidence: Java vs TypeScript vs Kotlin parity transcript (codes, canonical output, manifest ref entries)
Evidence: Java loader error messages per refused model
Evidence: TypeScript loader error messages for the same models
Evidence: Kotlin facade exception cause chain per refused model
canonical)cases)harness)Evidence: Focused JUnit log: ReferenceFacetTest and metadata-ktx
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.
apibind by kind; unresolved, wrong-kind, wrong-subtype and cross-system values are refused w…System.child,pkg::System.child, root-absolute, field-path and parent-relative@referencesvalues canonicalize as in TypeScript; the manifest writesref…metadata-ktxloadStringand gets the same enforcement and canonical output, and the existingmetadata-ktxtests still passscripts/ci-local.sh --affected --strict-toolchainsBroad regression came from the configured test commandscripts/ci-local.sh --affected --strict-toolchains, which already passed at target commit e5b4c43f36; it was not re-run, and no source or test files were changed.mvn -o -pl metadata,metadata-ktx -am test -Dtest='ReferenceFacetTest,com.metaobjects.metadata.ktx.**.*':ReferenceFacetTestand themetadata-ktxtests passed.Disposable Java driver (Drive.java) against the builtmetadataclasses, with a test provider read throughSpecMetamodelReader, over 23 synthetic YAML models.The same 23 models and facet definition through the TypeScriptMetaDataLoader(bun drive.ts) as the independent reference; compared error codes, canonical JSON bytes and registry-manifestrefentries.Temporary Kotlin test callingmetadata-ktxloadString(..., providers = listOf(...))over the same 23 models; the test file and its build outputs were removed afterwards.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.