Repository navigation
feat(metadata): declare core references in metamodel data - #707
Merged
Merged
Conversation
…s in every port relationship.* @objectref, identity.reference @references and field.object / field.map @objectref carry the reference facet in spec/metamodel/relationship.json, identity.json and field.json (and their C#, Python and Rust copies, and the TS embedded definitions), each naming its existing code: ERR_INVALID_RELATIONSHIP, ERR_INVALID_REFERENCE (fieldPath), ERR_UNRESOLVED_OBJECT_REF. The hand-coded descriptors are deleted from TS core-types.ts, C# CoreTypes.cs, the Java type registrations, Python core_types.py and Rust providers.rs; every port reads the facets through its wave 1 reference reader. expected-registry.json now writes ref on those seven attributes; metamodelVersion does not move. The B1 tests that asserted no definition file uses the facet now assert exactly these seven.
…registry path A subtype an SPI provider registers during bootstrap took its inherited requirement copy before the facets were applied; applySpecReferences now takes an undeclared subtype's facet from its nearest declared ancestor, and applySpecDescriptions runs it last so composeLoaderRegistry ends the same. One test per path; the isolated-registry test asserts one error per node. Drop the stale 'no definition file uses the facet yet' line from the five reference-facet fragments and say in the B2 fragment that inheriting subtypes now get the check.
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:relationship.*@objectRef(ERR_INVALID_RELATIONSHIP),identity.reference@references(ERR_INVALID_REFERENCE), andfield.object/field.map@objectRef(ERR_UNRESOLVED_OBJECT_REF). Files:spec/metamodel/{relationship,identity,field}.json, mirrored into each port's data copy (C#, Java, Python, Rustdata/metamodel/).core-types.ts, the C#CoreTypes.cs, the Pythoncore_types.pyand the Rustproviders.rs. Every port now reads these references from data; existing error codes are unchanged. Java adds registry-level reference binding inMetaDataRegistry.java.relationship.base's@objectRefraisesERR_INVALID_RELATIONSHIPfor a dangling target. Updatesfixtures/registry-conformance/expected-registry.json(refon seven attributes;metamodelVersionunchanged) and adds reference-facet tests in each port.Validation
Risk Assessment
✅ Low: The change moves four existing reference declarations into data, and the fixtures in every port already pin their error codes. The Java bootstrap pass from the fix rounds applies those facets the same way on every registry path, and the round-2 decision covers extension subtypes; the only issue found was changelog wording, fixed inline.
Testing
Drove the TS loader live on three synthetic documents: both dangling cases raise their original codes (ERR_UNRESOLVED_OBJECT_REF, ERR_INVALID_RELATIONSHIP) and the valid reference loads clean. Transcript saved as evidence. Java focused tests (ReferenceFacetTest, DownstreamValidationTest) pass offline, but they are unit-level, so the Java isolated-registry scenario is untested live. Broad regression came from the configured test command
scripts/ci-local.sh --affected --strict-toolchains, which passed at this commit. Overall: TS behavior good. Java live check not run; the Java isolated-registry case is covered by unit tests and was approved as a test exception (see below). The Java extension-subtype inheritance question was decided (keep inheritance, matching TypeScript) and fixed in 253438065, with one test per registry path.b2-ts-core-ref-loader.txt(kept locally)b2-ts-core-ref-loader.txt(kept locally)Evidence: TS core-reference loader transcript
objectRefDangling => ERR_UNRESOLVED_OBJECT_REF relationshipDangling => ERR_INVALID_RELATIONSHIP objectRefOk => CLEANPipeline
Updates from git push no-mistakes
Test exception (approved)
Live validation drove the two TypeScript scenarios; the third, Java's isolated registry (
createWithCoreProviders()) with a dangling@objectRef, is covered by unit tests rather than a live run:ReferenceFacetTest.anIsolatedCoreRegistryStillEnforcesTheCoreReferences(one error per offending node) andReferenceFacetTest.anExtensionSubtypeRegisteredOnACoreRegistryInheritsTheCoreReferences. Extension subtypes inheriting a core type get the core reference check on every Java registry path, one test each:anExtensionSubtypeRegisteredDuringTheSpiBootstrapInheritsTheCoreReferences,anExtensionSubtypeRegisteredOnACoreRegistryInheritsTheCoreReferences,anExtensionSubtypeComposedIntoALoaderRegistryInheritsTheCoreReferences.No-mistakes runs: 2 (the first was cancelled before push while its review findings were decided; they were fixed on the branch and this second run validated them).
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
changelog.d/core-references-into-data.md:7- The changelog said an extension subtype now gets the core reference check in Java "as the TypeScript reference already did". Before this change, TypeScript set these references only throughdef.referenceson the core relationship, identity and field subtypes. An extension subtype was never checked. It is checked now only becausecomposeWithBase(provider-data.ts) copiesrelationship.base's@objectRef, which now carriesref. The behavior is new in TypeScript as well. The sentence now says the check is new, names the TypeScriptextendsBaseroute, and keeps the Java scope as it was. Resolved: fixed inline in this run.server/java/metadata/src/main/java/com/metaobjects/registry/MetaDataRegistry.java:1636- Java extension-subtype inheritance of core reference facet (review round 2 ask-user): a custom relationship/field/identity subtype now inherits the facet through requirements, changing dangling-ref behavior on some bootstrap paths. Resolved: decided to keep inheritance (custom subtypes inherit the core reference check, matching TypeScript); already fixed in 253438065 ongetInstance(),createWithCoreProviders()andcomposeLoaderRegistry(extra), with one test each inReferenceFacetTestand the changelog fragment stating it. Declined at the gate as already fixed.ReferenceFacetTest.anIsolatedCoreRegistryStillEnforcesTheCoreReferencesandReferenceFacetTest.anExtensionSubtypeRegisteredOnACoreRegistryInheritsTheCoreReferences.b2-ts-core-ref-loader.txt(kept locally)b2-ts-core-ref-loader.txt(kept locally)scripts/ci-local.sh --affected --strict-toolchainsbun <scratch>/ts-dangling.ts (real TS MetaDataLoader, strict, coreProviders, synthetic JSON): dangling field.object @objectRef, dangling relationship.aggregation @objectRef, valid field.object @objectRefcd server/java && mvn -o -q -pl metadata -Dtest='ReferenceFacetTest,DownstreamValidationTest' test (37 + 4 tests, 0 failures, 0 errors)Baselinescripts/ci-local.sh --affected --strict-toolchainspassed at target commit (not re-run; no source changed in this turn)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.