Repository navigation
fix(plugin-detail): compile the related-list parent filter to match the relationship field arity (objectui#7299) - #8886
Conversation
…he field's arity (objectui#7299)
`RelatedList` composed `{ [referenceField]: parentId }` unconditionally. When
the relationship field is declared `multiple: true` — `Field.user({ multiple:
true })` is the platform's own shape — the stored value is an array persisted
as a JSON column, `=` compares that whole serialized value against a single id,
and `driver-sql` refuses with `400 INVALID_FILTER` naming the field and
prescribing `$contains`. The membership spelling was not reachable from the
authoring surface at all: the parent filter is composed from `relationshipField`
alone, so the list could not be written correctly, only not written.
The condition is now compiled from the field's declared arity, read off the
child object's schema the component already fetches. Multi-valued becomes
`{ [referenceField]: { $contains: parentId } }`; everything else keeps `=` byte
for byte. No authoring key added — the author names a relationship, and its
storage form is the renderer's business.
Both composition points are covered. The legacy raw-URL fallback cannot express
membership at all: `filter[<field>]=<value>` carries no operator, and the repo's
one operator contract for that spelling (`drillUrlFilters`' `URL_FILTER_OPS`)
recognises gte/lte/gt/lt and DROPS anything else, so a `[contains]` suffix would
arrive as no condition — an unscoped fetch of the whole child table. That path
now refuses and says so, matching the sibling filter arm and the unscoped-fetch
guard.
The unscoped-fetch guard itself is untouched, and pinned as untouched.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01611D6ZaRaMmwTNQmSbk8MH
✅ Console Performance Budget
The eager closure is every chunk the entry reaches through static imports — what the browser fetches and parses before the app renders. The entry chunk on its own is a small fraction of it. 📦 Bundle Size Report
Size Limits
|
…not a local copy (objectui#7299)
`check:spec-symbols` caught a hand-written `isMultiValueField` under a name
`@objectstack/spec/data` already exports. Renaming it or allow-listing it would
have satisfied the gate and kept the hazard, and on THIS card the hazard is the
card's own defect one layer up: `RelatedList` picks `$contains` vs `=` on the
arity answer while the driver that refuses the query picks on the spec's, so a
local copy is two readers of one question, free to disagree.
The spec's predicate is imported and the local one deleted. What remains local
is finding the field def to hand it — the metadata API serves a CONTAINER in two
shapes and the spec takes a single def, so that part is genuinely this side's.
The swap is NOT inert, and the difference runs in BOTH directions. Measured
against @objectstack/spec 17.4.0:
{ type: 'multiselect' } spec true, hand-rolled false
{ type: 'checkboxes' } spec true, hand-rolled false
{ type: 'tags' } spec true, hand-rolled false
{ type: 'master_detail', multiple:true} spec false, hand-rolled true
{ type: 'text', multiple: true } spec false, hand-rolled true
{ multiple: true } (no type) spec false, hand-rolled true
MULTI_OPTION_TYPES persist an array with no flag at all, and `multiple` is inert
on a type outside MULTI_CAPABLE_TYPES. The hand-rolled rule would have emitted
equality for the first three (this card's defect, unfixed) and `$contains`
against a scalar column for the last three (wrong the other way, and silent —
it fails as "no rows" rather than as a refusal).
Every pre-existing pin agreed with the spec, so none was adjusted. Three new
cases pin the differences instead.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01611D6ZaRaMmwTNQmSbk8MH
✅ Console Performance Budget
The eager closure is every chunk the entry reaches through static imports — what the browser fetches and parses before the app renders. The entry chunk on its own is a small fraction of it. 📦 Bundle Size Report
Size Limits
|
Contract review at
|
|
Handoff provenance — director seat, summon #18 segment 6 ( Generated by Claude Code |
|
Tier notice — the contract-review-tier requirement on this PR is lifted (skills seat, session Maintainer ruling, verbatim: 「现有的卡片如果写了要求fable的,也要让相关的项目经理知道,opus就够了。」 Under the same ruling set (quoted in full on objectstack-ai/objectstack#17285), the contract-review tier is reserved for the skills seat (protocol files + the published For this PR: its Generated by Claude Code |
Fixes #7299
What was wrong
RelatedListcomposed its parent-relationship condition as bare equality regardless of the field's arity. When the relationship field is declaredmultiple: true—Field.user({ multiple: true })is the platform's own shape for "one assignment names N people" — the stored value is an array persisted as a JSON column.=compares that whole serialized value against a single id and can never equal one member, sodriver-sqlrefuses with400 INVALID_FILTER, names the field, explains the storage and prescribes$contains.The membership spelling was not reachable from the authoring surface at all: the parent filter is composed by the component from
relationshipFieldalone. The list could not be written correctly — only not written.The driver is correct and is untouched here. It refuses loudly and teaches the working spelling; this change makes objectui say the thing the driver is already teaching.
The fix
The condition is compiled from the field's declared arity, read off the child object's schema the component already fetches for its own columns:
multiple: truebecomes{ [relationshipField]: { $contains: parentId } }=, byte for byteNo authoring key was added. The author is naming a relationship; its storage form is the renderer's business, and a
relationshipOperatorwould have widened the authoring surface to work around the renderer not reading metadata it already holds. This restores declared = enforced and widens nothing.The arity verdict is the spec's, not a local copy
The first revision hand-wrote the predicate, and
check:spec-symbolswas right to refuse it:@objectstack/spec/dataalready exportsisMultiValueField. On this card in particular a local copy would have rebuilt the defect one layer up — this component picks$containsvs=on the arity answer, and the driver that refuses the query picks on the spec's; two readers of one question, free to drift.The spec's function is now imported and the local one deleted. What stays local is
parentRelationshipFieldDef, which only finds the def to hand it: the spec takes a singleValueShapeFieldDefwhile the metadata API serves a CONTAINER in two shapes (Record keyed by name, and array of defs carrying their ownname), so that part is genuinely this side's.The swap is not inert, and it is wrong in BOTH directions to eyeball it. Measured against
@objectstack/spec17.4.0, calling the real exported function:multiple === true{ type: 'user', multiple: true }(the card's repro){ type: 'lookup', multiple: true }{ type: 'lookup' }/{ multiple: false }/{ multiple: 'yes' }{ type: 'multiselect' }{ type: 'checkboxes' }{ type: 'tags' }{ type: 'master_detail', multiple: true }{ type: 'text', multiple: true }{ multiple: true }(no type)MULTI_OPTION_TYPESpersist an array with no flag at all, andmultipleis inert on a type outsideMULTI_CAPABLE_TYPES. So the hand-rolled rule would have left this card's own defect unfixed for the first three, and sent$containsagainst a scalar column for the last three — wrong the other way and silent, because it fails as "no rows" rather than as a refusal.Every pre-existing pin agreed with the spec, so no pin was adjusted to match. Three new
SPEC PREDICATE/ counter-probe cases pin the differences instead. Renaming the local symbol or adding an ALLOW entry would have turned the gate green while keeping the hazard; neither was taken.Both composition points, and the measured answer for the second
The card named one; there are two.
1. The adapter path (
dataSource.find) — now arity-aware, as above.2. The legacy raw-URL fallback — this one cannot express membership at all, and that is a measurement, not an assumption:
filter[FIELD]=VALUEspelling isdrillUrlFilters'URL_FILTER_OPS(objectui#1752):gte/lte/gt/ltand nothing else. Its parser DROPS an unrecognised suffix rather than downgrading it, so a hopeful[contains]suffix would arrive as no condition whatsoever — an unscoped fetch of the entire child table, which is exactly what the unscoped-fetch guard exists to prevent.filter=param carrying a JSON AST (the wire in the card's own repro).So there is no third spelling to reach for. That path now refuses and says so — the same posture the sibling
listFilterNodearm one branch up already takes ("empty-and-loud beats wider-and-quiet") and the same posture as the unscoped-fetch guard.The guard is intact
The
refusing to fetch all rowsguard at the top of the fetch effect is untouched, and is pinned as untouched by aGUARD INTACTcase. Nothing in this change trades a loud 400 for a silent full-table scan.Comments this diff would have made false
RelatedListProps.parentId's docblock stated$filter: { [referenceField]: parentId }as a present-tense invariant. Rewritten to state both arities and why they are different questions.RelatedListProps.referenceFieldnow points at the arity decision.renderers/record-related-list.tsx's closing docblock saidRelatedListnow ANDs it with{ [referenceField]: parentId }. Rewritten to name the parent-relationship condition and its arity-dependent spelling.related-count-store.tsclaims badge/row parity because "both sides send the same$filter". That claim now has one exception — the badge probe has no field metadata in hand and still sends=. The comment records the exception and names its card, The related-list tab BADGE compiles its parent scope as bare equality too, so a multi-value related list shows rows with no count — and the store's own badge/row parity claim stops holding #8882. The observable effect is an absent badge above a populated list (the probe'scatchreturns withoutsetCount), not a wrong number.RelatedList.tsxline ~162 is deliberately unchanged: it is past tense about the pre-objectstack#7118 state and is still true.Verification
All readings below are on the tree at commit
674c7c5f6.Tests —
pnpm exec vitest runfrom the repo root (the only invocation that is a reading in this repo):New suite
RelatedList.multiValueParentScope-7299.test.tsx— 16 cases, both branches pinned, following the shape ofRecordDetailView.relatedListFilter-4664.test.tsx(a fake backend that evaluates the composed filter and throws on any shape it does not recognise) rather than starting a parallel one. The evaluator reproduces the driver's refusal for=against an array-valued field, so a component that merely stopped fetching cannot pass.Type-check —
@object-ui/plugin-detailand@object-ui/components, both green, after building the dependency closure first (a staledist/*.d.tslies in both directions).Lint — the full repo, not a narrowing:
pnpm exec eslint . --format jsonover 4672 files,errorCounttotal 0 (warning total unchanged at 12555 across the spec-import revision). My new test file's 18 warnings are all@typescript-eslint/no-explicit-any, the same rule and the same order of magnitude as every neighbouringRelatedList.*.test.tsx(headerSort 12, serverpagination 11).check-lint-coveragereports 46/46 packages linted, 0 with outstanding errors.Ablation — from the committed tree, removing the arity decision at its single source (the memo), which ablates both composition points at once:
Predicted direction before running: RED, on the multi-value cases only. The seven failures, by name:
SUBJECT — renders the parent's rows when the relationship field is multiple: trueSUBJECT — the composed predicate is the membership spelling the driver prescribesDECLARED COST — the arity flip refetches; the first attempt is the pre-card querySPEC PREDICATE — an inherently-array option type is multi-valued with no multiple flagreads the ARRAY-shaped field container the metadata API also servesANDs the list's own declared scope with the membership condition, through the shared sinkrefuses, and names the field, rather than sending a predicate it knows is wrong— the second composition point, which is how this run also re-confirms the arity decision still reaches BOTH of them after the spec swapThe control moved correctly: every single-valued case stayed green, and the two pre-existing suites
RelatedList.parentscope.test.tsxandRelatedList.listFilter.test.tsxstayed green in their entirety (2 files passed). A control that reddened whenever the subject broke would not be one.Restore was verified by state — blob hash back to the HEAD blob and
git diff HEADempty — never by an exit code, and the script carried atrap ... EXIT INT TERMwith absolute paths throughout.Gates — derived from the diff and each run individually, all exit 0.
check:spec-symbolswas reproduced red locally first (the CI job is named "Type Check" but the failing step ispnpm check:spec-symbols, nottsc), then fixed by importing, then seen green:check-spec-symbol-derivation,check-phantom-dependencies(the value import needs@objectstack/specdeclared — it already is, as a runtime dependency of this package),check-control-bytes(7075 files),check-changeset-presence,check-changeset-no-major,check-changeset-overwrite,check-changeset-fixed,check-vi-mock-specifiers,check-vi-mock-inherit,check-entry-guard,check-bash32-floor,check-unreferenced-sources,check-lint-coverage,check-lint-rule-coverage. A control-byte self-scan beyond the gate (grep -naPover the changed files) is clean.check-governed-queue-guard.mjs --teston all five changed paths answers NOT GOVERNED.Enumeration, two axes
$filtercomposition (RelatedList.listFilter,RelatedList.parentscope,RecordDetailView.relatedListFilter-4664,deriveRelatedLists.relatedListFilter-4664,related-count-store.declaredScope-4664), all run and green.RelatedList.tsxline ~190 shifted. Four in-repo comments cite line numbers in it (index.tsx:575,recordRelatedListInputs.spec-parity.test.ts:261, and two inapps/consoletests). They were already stale onorigin/mainbefore this change —RelatedList.tsx:724on main isif (cancelled) return;, not thepicker.valueFielddefault it claims — so they are not this diff's debt; the class is objectui#8875. No mechanical gate in this repo validates source line citations.Clause-2
Clause-②: yes— measured on this diff, not inherited. The mechanical floor is clear (0 new exported symbols;isMultiValueFieldis module-local; no new member onRelatedListProps), so this is a judgement call in the conformance class, and it goes toyeson two grounds: the emitted$filteris a published payload whose shape changes for one input class, and the declared contract text of an exported interface member (RelatedListProps.parentId) moved with it. Per the tie-break, unsure resolves toyes.The contract-review tier being unreachable parks this PR; that is the correct outcome and this change was not reshaped, downscoped or self-reviewed to avoid it.
验收备注
Related facts found while doing this card. None is folded in.
record:reference_railcannot bind to a multi-value relationship field either — same bare-equality parent filter as objectui#7299, plus a "View all" link the URL grammar cannot express #8883 —record:reference_railcomposes the same bare-equality parent filter from an author-suppliedrelationshipField(record-reference-rail.tsx:187), plus a "View all" link into the ADR-0055 bare data surface that the URL grammar cannot express membership for either. Positive control for that negative result:$containsat 0 hits in that file withrelationshipFieldat 4 in the same read.LineItemsPanel.tsx:200andMasterDetailForm.tsx:762compose the same bare equality, and the open question about them is now settled:master_detailis in neitherMULTI_OPTION_TYPESnorMULTI_CAPABLE_TYPES, somultiple: trueis inert on it and those two are correct as written. Measured by calling the spec's exported predicate, not read off a docblock. Recorded as a comment onrecord:reference_railcannot bind to a multi-value relationship field either — same bare-equality parent filter as objectui#7299, plus a "View all" link the URL grammar cannot express #8883 so its seat does not re-derive it.has no referenceField/parentIdconsole hint only fires whenparentIdis also empty, so the commonest half of the misconfiguration it names is silent. The guard itself is unaffected (the fetch is refused either way); this is about the hint. Successor: none named — it is a console-only diagnostic with no user-visible effect.ValueDataSourceimplements$containsas case-sensitive string containment on both dialects, perFILTER_TEXT_CASES, so aprovider: 'value'related list on a multi-value field answers zero rows. It answered zero before this change too (=against an array is equally false), so nothing regressed; but the membership spelling this PR emits is honoured by the drivers and not by the in-memory adapter. Successor: The related-list tab BADGE compiles its parent scope as bare equality too, so a multi-value related list shows rows with no count — and the store's own badge/row parity claim stops holding #8882's seat, which is already in that package.record:related_listhas nogroupBy, and its columns cannot cross a lookup — the two things a related list needs to stop being a flat strip of rows #7301 item 2 closes the other workaround (child-side dotted columns). Untouched.Measured absence, before and after, the probe triage ran:
git grep '\$contains'inRelatedList.tsxwas 0 withreferenceFieldat 23 in the same read; it has moved. The control moved.🤖 Generated with Claude Code
https://claude.ai/code/session_01611D6ZaRaMmwTNQmSbk8MH
Generated by Claude Code