Skip to content

feat(metadata): declare core references in metamodel data - #707

Merged
dmealing merged 5 commits into
mainfrom
fm/mo-140-w2-b2
Dec 3, 2026
Merged

dmealing merged 5 commits into
mainfrom
fm/mo-140-w2-b2

Conversation

@dmealing

@dmealing dmealing commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

What Changed

  • Moves core's four reference descriptors into the metamodel definition JSON as the ref facet: relationship.* @objectRef (ERR_INVALID_RELATIONSHIP), identity.reference @references (ERR_INVALID_REFERENCE), and field.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, Rust data/metamodel/).
  • Deletes the hand-coded reference descriptors they replace in the TypeScript core-types.ts, the C# CoreTypes.cs, the Python core_types.py and the Rust providers.rs. Every port now reads these references from data; existing error codes are unchanged. Java adds registry-level reference binding in MetaDataRegistry.java.
  • Extension subtypes that inherit a core reference attribute now get the same reference check. For example, a TypeScript provider subtype inheriting relationship.base's @objectRef raises ERR_INVALID_RELATIONSHIP for a dangling target. Updates fixtures/registry-conformance/expected-registry.json (ref on seven attributes; metamodelVersion unchanged) 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.

  • Live validation: ⚠️ inconclusive - 2 of 3 scenarios driven live against the product
Scenario Result Live Evidence
TS loader: dangling field.object @objectref raises ERR_UNRESOLVED_OBJECT_REF (core ref now from spec data) ✅ pass live pipeline evidence b2-ts-core-ref-loader.txt (kept locally)
TS loader: dangling relationship.aggregation @objectref raises ERR_INVALID_RELATIONSHIP; valid @objectref loads clean ✅ pass live pipeline evidence b2-ts-core-ref-loader.txt (kept locally)
Java: dangling @objectref fails on a createWithCoreProviders() loader (isolated registry path) ⏸️ untested no Only the focused JUnit tests were run; they exercise the real loader but are unit tests, so not live. A live run would need a small java main or jshell against the built metadata jar, which was not bu…
Evidence: TS core-reference loader transcript

objectRefDangling => ERR_UNRESOLVED_OBJECT_REF relationshipDangling => ERR_INVALID_RELATIONSHIP objectRefOk => CLEAN

objectRefDangling => ERR_UNRESOLVED_OBJECT_REF
relationshipDangling => ERR_INVALID_RELATIONSHIP
objectRefOk => CLEAN
  • Outcome: ⚠️ 2 warnings across 1 run (8m18s)

Pipeline

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) and ReferenceFacetTest.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.

⚠️ **Review** - 1 info
  • ℹ️ 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 through def.references on the core relationship, identity and field subtypes. An extension subtype was never checked. It is checked now only because composeWithBase (provider-data.ts) copies relationship.base's @objectRef, which now carries ref. The behavior is new in TypeScript as well. The sentence now says the check is new, names the TypeScript extendsBase route, and keeps the Java scope as it was. Resolved: fixed inline in this run.
⚠️ **Test** - 2 warnings
  • ⚠️ 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 on getInstance(), createWithCoreProviders() and composeLoaderRegistry(extra), with one test each in ReferenceFacetTest and the changelog fragment stating it. Declined at the gate as already fixed.
  • ⚠️ live validation verdict: inconclusive (2 of 3 scenarios were driven live against the product); untested: Java: dangling @objectref fails on a createWithCoreProviders() loader (isolated registry path). Resolved: approved as a test exception; covered by the unit tests ReferenceFacetTest.anIsolatedCoreRegistryStillEnforcesTheCoreReferences and ReferenceFacetTest.anExtensionSubtypeRegisteredOnACoreRegistryInheritsTheCoreReferences.
  • Live validation: ⚠️ inconclusive - 2 of 3 scenarios driven live against the product
Scenario Result Live Evidence
TS loader: dangling field.object @objectref raises ERR_UNRESOLVED_OBJECT_REF (core ref now from spec data) ✅ pass live pipeline evidence b2-ts-core-ref-loader.txt (kept locally)
TS loader: dangling relationship.aggregation @objectref raises ERR_INVALID_RELATIONSHIP; valid @objectref loads clean ✅ pass live pipeline evidence b2-ts-core-ref-loader.txt (kept locally)
Java: dangling @objectref fails on a createWithCoreProviders() loader (isolated registry path) ⏸️ untested no Only the focused JUnit tests were run; they exercise the real loader but are unit tests, so not live. A live run would need a small java main or jshell against the built metadata jar, which was not bu…
  • scripts/ci-local.sh --affected --strict-toolchains
  • bun <scratch>/ts-dangling.ts (real TS MetaDataLoader, strict, coreProviders, synthetic JSON): dangling field.object @objectRef, dangling relationship.aggregation @objectRef, valid field.object @objectRef
  • cd server/java && mvn -o -q -pl metadata -Dtest='ReferenceFacetTest,DownstreamValidationTest' test (37 + 4 tests, 0 failures, 0 errors)
  • Baseline scripts/ci-local.sh --affected --strict-toolchains passed 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.

…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.
@dmealing
dmealing merged commit 0a3b7ea into main Dec 3, 2026
11 checks passed
@dmealing
dmealing deleted the fm/mo-140-w2-b2 branch December 3, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant