Skip to content

Commit a726154

Browse files
hotlongclaude
andauthored
test(metadata-protocol): pin the THIRD union-branch policy copy against @objectstack/spec (#8660) (#8782)
* test(metadata-protocol): pin the third union-branch policy copy against spec (#8660) * chore: changeset for the cross-package union-branch parity pin (#8660) * test(metadata-protocol): read spec's export surface without a restricted root namespace import (#8660) --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4ea921c commit a726154

2 files changed

Lines changed: 446 additions & 0 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
"@objectstack/metadata-protocol": patch
3+
---
4+
5+
test(metadata-protocol): pin the THIRD union-branch policy copy against `@objectstack/spec` (#8660)
6+
7+
The union-branch selection policy — kind-mismatch drop, fewest-issues ranking,
8+
`unrecognized_keys` tie-break, declaration-order determinism, depth limit 3,
9+
branch cap 3 — has three implementations. #8318 (PR #8659) consolidated the two
10+
inside `packages/spec` into one package-internal module and pinned them with a
11+
shared-fixture parity test. The third, `zodIssuesToMetadataIssues` in
12+
`protocol.ts` (the walk behind `saveMetaItem`'s `422 INVALID_METADATA` and the
13+
read path's diagnostics), was structurally out of that consolidation's reach:
14+
the shared module is deliberately not a public export (#4001), so a consumer in
15+
another package cannot import it.
16+
17+
That left this copy exactly where the spec pair sat before #8318 — held in step
18+
by a header comment and nothing else. A future tie-break or ranking tweak lands
19+
in `union-branch-policy.ts` for both spec walks at once and silently not for
20+
this one, and then the same authored metadata gets one prescription from the
21+
terminal, another from the data API, and a third from Studio: the forked verdict
22+
#5014 ruled out.
23+
24+
`src/union-branch-policy.cross-package-parity.test.ts` is the enforcement the
25+
header stood in for. One fixture corpus, one `safeParse` per fixture, three
26+
walks reached through PUBLIC surfaces only — `formatZodIssue` from
27+
`@objectstack/spec`, `zodIssuesToFields` from `@objectstack/spec/api`, and this
28+
package's own copy — compared as ordered `(path, message)` pairs. The corpus
29+
covers every element of the policy by name, plus a hand-authored expectation per
30+
fixture so both sides drifting the same way still fails. The two deliberate
31+
asymmetries (the prose-only omission line, and raw zod codes here vs the
32+
ADR-0114 catalog on the wire) are asserted in place rather than normalised away.
33+
34+
**`patch`, deliberately not a skipped changeset.** No production line changes,
35+
no export moves, and every assertion is green on `main` before this lands — but
36+
the bump floor is right rather than absent, for the same reason
37+
`legacy-unique-guard-attribution` took one: what ships is a ratchet on
38+
release-relevant behaviour. The 422 envelope this pins is a published contract
39+
of `@objectstack/metadata-protocol`, and a consumer reading the CHANGELOG should
40+
be able to see when its verdict acquired mechanical protection against drifting
41+
away from the spec's.

0 commit comments

Comments
 (0)