…enceTo` spelling too
`MetadataFieldsPage`'s read door (`toDesignerField`) read the spec spelling
`reference` and nothing else, while `carryOver` strips `referenceTo` from the
stored definition. A field whose target survives only as the pre-objectui#6041
`referenceTo` therefore read as target-less, the strip removed the stored
value, and the field reached the wire as a `lookup` with no target — saving
silently at `@objectstack/spec` 17.2.0 and answering `422 INVALID_METADATA` at
`fields.NAME.reference` against 17.3.0, with nothing naming which field.
The read door now reads `reference` and falls back to `referenceTo`
(`storedRelationshipTarget`). That is a pure rename, not a lenient alias:
`FieldSchema`'s own map renames `referenceTo` onto `reference` and both
spellings carry one object machine name, so no value changes shape on the way
through — unlike `formula` -> `expression`, where objectui#6043 refused the
rename because the two sides carry different value grammars.
objectui#7714's guard is untouched and still refuses a relationship field with
no usable target under either spelling, by name, before the PUT. The carry-over
docblock's "costs nothing" claim is rewritten to say what it is conditional on,
and to name the one path where it is still false.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01611D6ZaRaMmwTNQmSbk8MH
Fixes #8058
What was broken
MetadataFieldsPagehad two halves that did not meet. The read door (toDesignerField) setreferenceTo: raw.reference— the spec spelling and nothing else. The write door'scarryOverstripsreferenceTofrom the carried-over server definition (the objectui#6527 tombstone site), andfromDesignerFieldre-emits the target asreference.For a field whose target survives only as the pre-objectui#6041
referenceTo, the read found nothing, the strip removed the stored value, and the field reached the wire as alookupwith no target at all — saving silently at@objectstack/spec17.2.0, and answering422 INVALID_METADATAatfields.NAME.referenceagainst 17.3.0 with nothing naming which field.The change
storedRelationshipTarget(raw)readsreferenceand falls back toreferenceTo;toDesignerFielduses it. That is all of the behaviour change.P1 — measured before writing a line, because the ruling hung on it
The dispatch made the fix conditional on
referenceToandreferencecarrying the same value shape across the objectui#6041 rename. Measured against the installed artifact (pnpm-lock.yamlresolves@objectstack/specto 17.4.0):Three readings, all pointing the same way:
referenceTois one of five entriesFieldSchema's alias map renames ontoreference(relatedTo,target,targetObject,lookupObjectare the rest), andsrc/ui/view.zod.tssays so in prose: "referenceis the keyFieldSchemaaccepts —referenceTois only a rejected alias it lists so a failed parse can offer a rename hint."reference: z.string().optional()upstream,DesignerFieldDefinition.referenceTo?: stringhere. Every other site in this repo that namesreferenceTo(reports.zod.ts,filter-builder.tsx,designer.ts) holds a single object machine name too — no array form, no{object, field}form anywhere.referenceTothis reads is whatfromDesignerField's pre-objectui#6041 emit line wrote, out of the samedesigned.referenceTothat today'sreference: designed.referenceToreads.⇒ P1 holds. And it is exactly what separates this from objectui#6043: the alias map lists
formula → expressiontoo, but those two sides carry different value grammars (expressionis CEL; the retired textarea accepted arbitrary text), so that rename would have laundered non-CEL text into a formula that parses green. There is no value grammar to violate here.The case:
MetadataFieldsPage.specKeyReference.test.tsx, the lastdescribein the file —objectui#7714 · a lookup whose target survives only as 'referenceTo'›it('is refused by name, and issues no PUT').What it pinned: a stored
{ stale_id: { type: 'lookup', label: 'Stale', referenceTo: 'contact' } }, an author relabelling an unrelated field, and two assertions — that the page's error surface named`stale_id`, and thatputsstayed[].What it pins now: the same document and the same edit, and that the target survives: the designer model receives
referenceTo === 'contact', the PUT happens, the wire carriesreference: 'contact'with noreferenceTokey, andFieldSchemaparses the emitted field.Why the flip is right. That pin recorded the CONSEQUENCE of the read-side gap, not a contract anyone chose. objectui#7714 said so itself when it wrote the case — "After objectui#7714 the failure is at least loud and field-named instead of a silent dropped relationship. That is strictly better and it is not a fix: the author still has to re-pick a target the document already held." — and objectui#8058 was filed at that moment for exactly this. Once the read door finds the target, the guard has nothing to refuse, so the old expectation cannot survive the repair; it is replaced rather than respelled, because the branch it pinned is the branch this card removes.
Order of measurement, as required:
pnpm exec vitest run packages/plugin-designer/src/MetadataFieldsPage.specKeyReference.test.tsx→Test Files 1 passed (1) · Tests 13 passed (13)— the pin is green, pinning the refusalTests 1 failed | 13 passed (14)— the single failure is that case:TestingLibraryElementError: Unable to find an element by: [data-testid="metadata-fields-page-error"], i.e. the save now succeedsTests 15 passed (15)So the pin demonstrably sees this change; it was not edited on a hunch.
⛔ objectui#7714's guard is untouched, and the acceptance criterion is two-sided
Not one line of
assertRelationshipTargetPresent,describeUnusableTargetorRELATIONSHIP_TYPES_REQUIRING_REFERENCEchanged. Both rows are asserted:referenceToobjectui#8058 · … › loads with its target, and PUTs it back under the spec spelling)⛔ CONTROL — a lookup with NO target under EITHER spelling is still refused, by name, with no PUT)A third control pins the precedence that keeps the fallback a rename rather than a second contract:
⛔ CONTROL — when both spellings are stored and DISAGREE, the spec spelling wins. And the pre-existing guard cases are all still green — the half-filled draft, the four unusable-target states plusnull, and themaster_detailpair.⛔ objectui#6041's strip assertion is untouched and green:
a save of an object ALREADY carrying 'referenceTo' puts it back without the key. The shared fixture still carries both keys onlegacy_id, deliberately — that is what gives the strip something to measure, and it now also pins thatreferencewins.The docblock that was false
The
carryOvertombstone docblock asserted, as settled:That was true only when the READ found a target, which for this shape it did not. It is rewritten to say what it is conditional on — the read door reading both spellings — and to record that this PR is what made it true, so the next reader cannot restate the conclusion without the premise. It also now names the one path where it is still false (below).
验收备注 — out of scope, filed, not fixed here
MetadataFieldsPage's carried-through half and metadata-admin'sreadFieldsstill lose a target stored only asreferenceTo— and the tombstone registry still says the strip "loses nothing" #8896 — the same strip still costs the relationship on the paths with no read door. Measured on this branch: a stored{ parent_id: { type: 'master_detail', label: 'Parent', referenceTo: 'invoice' } }goes topartitionStoredFields' preserved half, is re-emitted ascarryOver(keep.raw)with notoDesignerFieldin the path, and is refused —puts=[], error`parent_id` … and this one has none. Worse there than here: a preserved field is read-only on this page, so "Pick the target object" names a control the author cannot reach. metadata-admin'sreadFields(object-fields-io.ts) states the same invariant and is the second candidate site. The card also names the registry sentence "The strip loses nothing" as the claim to fix at the source, which is a decision about the tombstone contract rather than a local patch.@objectstack/specpin is 17.4.0, not 17.3.0 — three version-qualified measurements (one of them a user-visible error message) describe a spec that is not installed #8897 — the installed spec pin is 17.4.0, not the 17.3.0 that three version-qualified measurements in this file, its siblingMetadataService.tsand this test file all name. Measured:reference: ' 'is now refused upstream (customatreference), so the docblock's "Until the pin reaches the fix, this guard is still the only thing refusing' 'here" and the user-visible refusal text "@objectstack/spec17.3.0 ACCEPTS this value" are both false against the installed artifact. ⛔ Not a behaviour bug — the guard is right to keep refusing (objectui#8621 ruled that) — but the refusal message is pinned verbatim by both writers' tests, so correcting it flips existing pins and is not a drive-by edit.referenceTo") is a deployed-tenant data question this repo cannot answer. No time was spent guessing and the deliverable was not reduced for it; the card's own conclusion covers both outcomes.scripts/cross-file-line-citation-census.mjsrun at the branch point (b686ebf7d) and again at the final commit (3a200e94a): population identical (1267), and exactly two rows move —plugin-gantt/src/ObjectGantt.referenceArms-6837.test.tsx:49andplugin-tree/src/ObjectTree.referenceArms-6837.test.tsx:50, both citingMetadataFieldsPage.specKeyReference.test.tsx:75. At the branch point that line was blank ([non-substantive] (cited line reads '')) while the citation claims it names areferenceTofixture — so both were class (B): already not pointing at their subject onorigin/main, not addresses this PR knocked off target. ⛔ Untouched; they belong to objectui#8875.Verification
Run at the final commit
3a200e94a.pnpm exec vitest run packages/plugin-designer/src/MetadataFieldsPage.specKeyReference.test.tsx --reporter=verbose→Test Files 1 passed (1) · Tests 15 passed (15)pnpm exec vitest run packages/plugin-designer/→Test Files 18 passed (18) · Tests 142 passed (142)pnpm --workspace-concurrency=2 --filter '@object-ui/plugin-designer^...' run build→ 15 of 47 projects, allDone(the dependency closure; without ittype-checkanswersTS2307 Cannot find module '@object-ui/types', which is PREREQUISITE NOT MET, not a red gate)pnpm --filter @object-ui/plugin-designer run type-check→ exit 0.*.test.tsx(--listFilescount for the changed test file: 0), so the test file is covered bytsconfig.test.jsoninstead:tsc -p tsconfig.test.json --noEmit --listFiles→ exit 0, changed test file present in the program (count 1), zeroerror TS.node scripts/check-changeset-presence.mjs→✅ 2 source file(s) of 1 released package(s) changed, and this change declares 1 changeset(s)pnpm run check:designer-field-key-parity→designer-field-key-parity: OKpnpm run check:control-bytes→✅ OK (scanned 7086 tracked text file(s)), plus a directgrep -naPover the three changed paths: no matchpnpm run check:vi-mock-specifiers/check:vi-mock-inherit/check:spec-symbols→ all✅ OKnode scripts/check-governed-queue-guard.mjs --testover the three changed paths →✅ NOT GOVERNEDpnpm linthere isturbo run lint— per-packageeslint .— and the diff touches one package, so the affected unit is run whole:pnpm exec eslint . --no-inline-config --format jsoninsidepackages/plugin-designer→ exit 0, 53 files linted (count read from the JSON output), 0 errors, 66 pre-existing warnings, none of them in either changed file. Invariance for the packages not run:eslint.config.jsconfigures noparserOptions.projectand noprojectService, so no rule here is type-aware and no verdict on an untouched file can move with this diff.Clause-②
Clause-②: yes— judged by this seat and appended to the claim comment on #8058 under the dispatch's carrier pre-authorization. No new exported symbol and no new key on a published payload, but the read door now honours a second spelling, so a stored document that previously produced a target-lesslookupnow produces one carryingreference. That is an acceptance-set widening on the surface AGENTS.md #0.1 governs, and the card had to argue against objectui#6043 to reach it. This PR parks in draft awaiting the contract-review tier;needs:contract-reviewis attached.🤖 Generated with Claude Code
https://claude.ai/code/session_01611D6ZaRaMmwTNQmSbk8MH
Generated by Claude Code