Commit 7c3fec7
fr5c(java): merge-phase contributors + ERR_MERGE_CONFLICT envelope + WARN_DUPLICATE_DECLARATION
Java port of the FR5c TS reference (`329ba34`) per ADR-0009:
- Overlay-merge phase in `CanonicalJsonParser.processNode` snapshots a
node's pre-merge canonical shape + own-attrs map BEFORE re-applying
the new contribution. When two or more files contribute to the same
logical node AND the merge produces a semantic change (via FR5a
`SemanticDiff`), the merged node's `source` is upgraded to
`format: "merged"` with an alphabetically-ordered `files[]` and a
`contributors[]` whose first entry is role `overlay-base` and all
subsequent entries are `overlay-extension`. Single-file nodes keep
their FR5a parse-time `JsonSource`/`YamlSource` unchanged.
- `ERR_MERGE_CONFLICT` (new ErrorCode) raised when two contributors
set the same `@attr` to different non-empty values on the same node.
Envelope is `format: "merged"` with both contributors listed and
`jsonPath` pointing at the conflicting attr. Last-writer-wins remains
the merge default for non-conflicting cases (one side unset, same
value); the recorded error surfaces the divergence so a consumer can
fix it. Array-shaped JSON values (e.g. `["a","b"]`) are normalized to
the same comma-delimited form `MetaAttribute.getValueAsString()`
emits, so identical-array contributions are not flagged spuriously.
- `WARN_DUPLICATE_DECLARATION` emitted at the merge boundary when a
second contribution declares the same node with no semantic change
(`SemanticDiff` returns false on pre/post canonical-serialize). The
node's `source` is NOT upgraded to merged in this case — only the
new envelope-warning channel surfaces it.
- `MetaDataLoader` gains a parallel `envelopeWarnings: List<LoaderWarning>`
channel (cross-port aligned with TS `ParseResult.envelopeWarnings`).
`addEnvelopeWarning` also pushes the warning's message into the
legacy `warnings: List<String>` channel so the existing conformance
harness — which reads warnings as a flat string list — picks up
FR5c warnings without needing a new contract. Both `addError` and
`addEnvelopeWarning` are now `public` to support the cross-subpackage
parser call sites (matching the precedent set by `addPendingExtends`).
- `tagNodeWithJsonSource` now preserves `MergedSource` in addition to
`JsonSource`/`YamlSource`, so a third contributor cannot revert an
already-upgraded source envelope back to a single-file shape.
- Conformance runner relaxes a too-strict guard that aborted tree-
dependent checks when any error was recorded. FR5c records errors
non-fatally via `addError`, and existing fixtures (e.g.
`overlay-attr-last-writer-wins`) now legitimately produce a recorded
`ERR_MERGE_CONFLICT` alongside a valid tree. TS conformance behaves
the same way — only `expected-errors.json` fixtures check the error
set. Only a thrown exception now aborts tree checks.
- `EntityHasPrimaryIdentityValidationTest.warningsResetAcrossLoadCalls`
reuses the same source id across two `load()` calls so the merge-
attribution code does not see a NEW contributor on the second load
and emit a `WARN_DUPLICATE_DECLARATION` orthogonal to the test's
intent (which is verifying the per-batch warning accumulator reset).
Three shared conformance fixtures all green:
- `error-merge-conflict-attr` — `ERR_MERGE_CONFLICT` envelope with
both contributors listed alphabetically.
- `warning-duplicate-declaration` — three duplicate-declaration
warning strings (one per merged sub-node).
- `merge-three-way-no-conflict` — three-file overlay produces a
`MergedSource` with all three files in alphabetical order.
Tests: 717 → 727 metadata module (+10 unit tests in `Fr5cMergeAttributionTest`,
+1 conformance lint pair via the two new fixtures); full Java suite 21/21
modules green. Cross-port aligned with the TS reference behaviour.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 243b2ac commit 7c3fec7
6 files changed
Lines changed: 757 additions & 11 deletions
File tree
- server/java/metadata/src
- main/java/com/metaobjects
- loader
- parser/json
- test/java/com/metaobjects
- conformance
- loader
- source
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
136 | 143 | | |
137 | 144 | | |
138 | 145 | | |
Lines changed: 74 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
149 | 166 | | |
150 | 167 | | |
151 | 168 | | |
| |||
548 | 565 | | |
549 | 566 | | |
550 | 567 | | |
551 | | - | |
552 | | - | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
553 | 574 | | |
554 | 575 | | |
555 | 576 | | |
556 | | - | |
| 577 | + | |
557 | 578 | | |
558 | 579 | | |
559 | 580 | | |
| |||
567 | 588 | | |
568 | 589 | | |
569 | 590 | | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
570 | 640 | | |
571 | 641 | | |
572 | 642 | | |
| |||
1131 | 1201 | | |
1132 | 1202 | | |
1133 | 1203 | | |
| 1204 | + | |
1134 | 1205 | | |
1135 | 1206 | | |
1136 | 1207 | | |
| |||
0 commit comments