From f7da2f92058c221df8fdb34aa4b70c359e6ffb5d Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 01:28:59 +0000 Subject: [PATCH 1/8] fix(lint): refuse a lookupFilters $record path to a structured field Claude-Session: https://claude.ai/code/session_017xRBcSAaBEfQpU2yJexSJ8 Co-authored-by: Claude --- .../src/validate-object-field-refs.test.ts | 53 ++++++++++++++++- .../lint/src/validate-object-field-refs.ts | 57 +++++++++++++------ 2 files changed, 93 insertions(+), 17 deletions(-) diff --git a/packages/lint/src/validate-object-field-refs.test.ts b/packages/lint/src/validate-object-field-refs.test.ts index b79377b83d1..92a70aa5ee5 100644 --- a/packages/lint/src/validate-object-field-refs.test.ts +++ b/packages/lint/src/validate-object-field-refs.test.ts @@ -10,7 +10,7 @@ import { import { explainRule } from './rule-explanations.js'; import { runRuntimeAuthoringRules, runtimeAuthoringRulesFor } from './runtime-gate.js'; import { SEMANTIC_ROLE_FIELD_UNKNOWN, validateSemanticRoles } from './validate-semantic-roles.js'; -import { FieldSchema } from '@objectstack/spec/data'; +import { FieldSchema, STRUCTURED_JSON_TYPES } from '@objectstack/spec/data'; const obj = (over: Record = {}) => ({ name: 'proj_task', @@ -929,6 +929,57 @@ describe('validateObjectFieldRefs — lookupFilters[].value.$record (the RECORD ], multi))).toEqual([]); }); }); + + // [#34562] A STRUCTURED field — a member of `STRUCTURED_JSON_TYPES`, taken + // from `@objectstack/spec/data`, never re-listed — holds an OBJECT, so a + // path that names one (the head) or ends at one behind a hop (the leaf) has + // no scalar value either: refused by the same rule with the same hint. + describe('a path to a structured field (#34562)', () => { + const structural = [...STRUCTURED_JSON_TYPES]; + const fieldsOf = Object.fromEntries(structural.map((t) => [`s_${t}`, { type: t }])); + const stack = (filters: unknown[]) => { + const s = quote(filters, fieldsOf); + Object.assign((s.objects[1] as { fields: Record }).fields, fieldsOf); + return s; + }; + const refused = (path: string) => { + const findings = validateObjectFieldRefs(stack([entry(path)])); + expect(findings.map((f) => f.path)).toEqual([at(0)]); + expect(findings[0]).toMatchObject({ severity: 'error', rule: OBJECT_FIELD_REF_UNKNOWN }); + expect(findings[0]!.hint).toBe( + 'Point `$record` at a single-valued field: a multi-valued field holds a list, and no scalar comparison ' + + 'takes one. Copy the value you mean onto a single-valued field and reference that.', + ); + return findings[0]!.message; + }; + + it('covers the five the card names, and the spec set is what is judged', () => { + for (const t of ['json', 'repeater', 'location', 'address', 'vector']) expect(structural).toContain(t); + }); + + it.each(structural)('REFUSES a plain path to a `%s` field (the head)', (t) => { + expect(refused(`s_${t}`)).toBe( + `fields.price_book.lookupFilters[0].value.$record "s_${t}" names "s_${t}", a structured ${t} field on ` + + 'object "sales_quote"; a $record comparand is one value under a scalar operator.', + ); + }); + + it.each(structural)('REFUSES a `%s` leaf behind a single-valued hop, naming the leaf and its object', (t) => { + expect(refused(`account.s_${t}`)).toBe( + `fields.price_book.lookupFilters[0].value.$record "account.s_${t}" ends at "s_${t}", a structured ${t} ` + + 'field on object "crm_account"; a $record comparand is one value under a scalar operator.', + ); + }); + + it('CONTROL: scalar paths beside the structured fields stay clean — head and leaf', () => { + expect(validateObjectFieldRefs(stack([ + { field: 'valid_from', operator: 'lte', value: { $record: 'quote_date' } }, + entry('notes'), + entry('account.cb_market'), + entry('account.name'), + ]))).toEqual([]); + }); + }); }); describe('validateObjectFieldRefs — summaryOperations.filter (addresses the CHILD object, #31224)', () => { diff --git a/packages/lint/src/validate-object-field-refs.ts b/packages/lint/src/validate-object-field-refs.ts index 4ca95947e9c..014a86f8bad 100644 --- a/packages/lint/src/validate-object-field-refs.ts +++ b/packages/lint/src/validate-object-field-refs.ts @@ -119,8 +119,12 @@ * one behind a single-valued hop — is refused too: the comparand is ONE * value under a scalar operator, and a list has no such value. The * predicate is `isMultiValueField` (`@objectstack/spec/data`), the one - * `FieldSchema` reads. A registry-injected column, and a leaf on an object - * outside this stack, stay unjudged. A `{ $record }` nested + * `FieldSchema` reads. A plain path to, or a leaf behind a hop at, a + * STRUCTURED field (#34562) — a member of `STRUCTURED_JSON_TYPES` + * (`@objectstack/spec/data`): json, address, location, … — is refused the + * same way, with the same hint: it holds an object, not one value. A + * registry-injected column, and a leaf on an object outside this stack, + * stay unjudged. A `{ $record }` nested * deeper inside a literal (`value: { any: { $record: 'x' } }`) is an * opaque literal to the parse, and this rule does not name it either: no * reader resolves that shape, nothing first-party writes it, and the @@ -302,7 +306,12 @@ import { type GraphField, type ObjectGraph, } from './object-graph.js'; -import { classifyDottedFilterHead, isMultiValueField, isVirtualSearchField } from '@objectstack/spec/data'; +import { + classifyDottedFilterHead, + isMultiValueField, + isVirtualSearchField, + STRUCTURED_JSON_TYPES, +} from '@objectstack/spec/data'; /** * A field-name list entry — object-level, or on one of the object's fields — @@ -494,7 +503,8 @@ interface FieldNameSlot { ownFinding?: boolean; /** * [#34378] `true` when the path must read ONE value: its first segment and, - * behind a hop, its leaf may not be multi-valued (`isMultiValueField`). A + * behind a hop, its leaf may not be multi-valued (`isMultiValueField`) or + * structured (`STRUCTURED_JSON_TYPES`, #34562). A * path whose head is multi-valued is refused whether it ends there or hops * through it, at the head; a multi-valued leaf behind a single-valued hop is * refused at the leaf. Judged only on a path the family's resolution did @@ -727,23 +737,37 @@ export function validateObjectFieldRefs(stack: AnyRec): ObjectFieldRefFinding[] * [#34378] Where a path that resolved stops reading ONE value: its AUTHORED * first segment on `objectName` when that is multi-valued (a plain path to * it, or a hop through it), else — behind a single-valued hop — its - * authored leaf when that is. `undefined` = single-valued, or not - * judgeable here (a registry-injected column, an object outside the stack). + * authored leaf when that is. A STRUCTURED field (#34562: a member of + * `STRUCTURED_JSON_TYPES`, `@objectstack/spec/data` — json, address, + * location, …) holds an object, so it has no scalar value either and is + * named at the same two positions. `what` is the finding's noun for the + * field. `undefined` = one scalar value, or not judgeable here (a + * registry-injected column, an object outside the stack). */ const multiValuedSegment = ( objectName: string, segments: readonly string[], - ): { how: string; field: string; object: string } | undefined => { - const isMulti = (m: GraphField | undefined): boolean => - typeof m?.type === 'string' && isMultiValueField({ type: m.type, multiple: m.multiple === true }); + ): { how: string; field: string; object: string; what: string } | undefined => { + const nonScalar = (m: GraphField | undefined): string | undefined => { + if (typeof m?.type !== 'string') return undefined; + if (isMultiValueField({ type: m.type, multiple: m.multiple === true })) return 'a multi-valued field'; + return STRUCTURED_JSON_TYPES.has(m.type) ? `a structured ${m.type} field` : undefined; + }; const head = graph.get(objectName)?.fields.get(segments[0]!); - if (isMulti(head)) { - return { how: segments.length > 1 ? 'goes through' : 'names', field: segments[0]!, object: objectName }; + const headWhat = nonScalar(head); + if (headWhat) { + return { + how: segments.length > 1 ? 'goes through' : 'names', + field: segments[0]!, + object: objectName, + what: headWhat, + }; } if (segments.length < 2) return undefined; const verdict = resolveFieldPath(graph, objectName, segments.join('.')); - if (verdict?.kind !== 'ok' || verdict.injected || !isMulti(verdict.meta)) return undefined; - return { how: 'ends at', field: verdict.field, object: verdict.object }; + if (verdict?.kind !== 'ok' || verdict.injected) return undefined; + const leafWhat = nonScalar(verdict.meta); + return leafWhat ? { how: 'ends at', field: verdict.field, object: verdict.object, what: leafWhat } : undefined; }; /** The declared slice of `name` on `objectName` — authored, else registry-injected. */ @@ -1063,14 +1087,15 @@ export function validateObjectFieldRefs(stack: AnyRec): ObjectFieldRefFinding[] } // [#34378] A path that names real fields can still read a LIST: a - // multi-valued head, or a multi-valued leaf behind one hop. The - // comparand is one value under a scalar operator, so it is refused. + // multi-valued head, or a multi-valued leaf behind one hop — or + // (#34562) an OBJECT: a structured head or leaf. The comparand is + // one value under a scalar operator, so it is refused. if (!hit && slot.singleValued) { const multi = multiValuedSegment(against, segments); if (multi) { refuseKey( { where, path }, - `${subject} "${read.name}" ${multi.how} "${multi.field}", a multi-valued field on object ` + `${subject} "${read.name}" ${multi.how} "${multi.field}", ${multi.what} on object ` + `"${multi.object}"; a $record comparand is one value under a scalar operator.`, slot.singleValuedPrescription ?? slot.prescription, ); From 5909b7ea63be6071771a9a4dc4f1b64b29be7dc9 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 01:31:35 +0000 Subject: [PATCH 2/8] test(lint): pin the structured-field $record refusal beside the multi-valued block Claude-Session: https://claude.ai/code/session_017xRBcSAaBEfQpU2yJexSJ8 Co-authored-by: Claude --- .../lint/src/validate-object-field-refs.test.ts | 14 ++++++++++---- packages/lint/src/validate-object-field-refs.ts | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/lint/src/validate-object-field-refs.test.ts b/packages/lint/src/validate-object-field-refs.test.ts index 92a70aa5ee5..443e750ccc5 100644 --- a/packages/lint/src/validate-object-field-refs.test.ts +++ b/packages/lint/src/validate-object-field-refs.test.ts @@ -959,18 +959,24 @@ describe('validateObjectFieldRefs — lookupFilters[].value.$record (the RECORD it.each(structural)('REFUSES a plain path to a `%s` field (the head)', (t) => { expect(refused(`s_${t}`)).toBe( - `fields.price_book.lookupFilters[0].value.$record "s_${t}" names "s_${t}", a structured ${t} field on ` - + 'object "sales_quote"; a $record comparand is one value under a scalar operator.', + `fields.price_book.lookupFilters[0].value.$record "s_${t}" names "s_${t}", a structured field on object ` + + '"sales_quote"; a $record comparand is one value under a scalar operator.', ); }); it.each(structural)('REFUSES a `%s` leaf behind a single-valued hop, naming the leaf and its object', (t) => { expect(refused(`account.s_${t}`)).toBe( - `fields.price_book.lookupFilters[0].value.$record "account.s_${t}" ends at "s_${t}", a structured ${t} ` - + 'field on object "crm_account"; a $record comparand is one value under a scalar operator.', + `fields.price_book.lookupFilters[0].value.$record "account.s_${t}" ends at "s_${t}", a structured field ` + + 'on object "crm_account"; a $record comparand is one value under a scalar operator.', ); }); + it('reports a hop THROUGH a structured head once, as the family\'s not-a-relationship miss', () => { + const findings = validateObjectFieldRefs(stack([entry('s_address.city')])); + expect(findings.map((f) => f.path)).toEqual([at(0)]); + expect(findings[0]!.message).toContain('not a relationship'); + }); + it('CONTROL: scalar paths beside the structured fields stay clean — head and leaf', () => { expect(validateObjectFieldRefs(stack([ { field: 'valid_from', operator: 'lte', value: { $record: 'quote_date' } }, diff --git a/packages/lint/src/validate-object-field-refs.ts b/packages/lint/src/validate-object-field-refs.ts index 014a86f8bad..cd9bbf46252 100644 --- a/packages/lint/src/validate-object-field-refs.ts +++ b/packages/lint/src/validate-object-field-refs.ts @@ -751,7 +751,7 @@ export function validateObjectFieldRefs(stack: AnyRec): ObjectFieldRefFinding[] const nonScalar = (m: GraphField | undefined): string | undefined => { if (typeof m?.type !== 'string') return undefined; if (isMultiValueField({ type: m.type, multiple: m.multiple === true })) return 'a multi-valued field'; - return STRUCTURED_JSON_TYPES.has(m.type) ? `a structured ${m.type} field` : undefined; + return STRUCTURED_JSON_TYPES.has(m.type) ? 'a structured field' : undefined; }; const head = graph.get(objectName)?.fields.get(segments[0]!); const headWhat = nonScalar(head); From cc407df31e03ad9cd334ddc7df8ff2b6cbe3eb11 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 01:35:22 +0000 Subject: [PATCH 3/8] chore(changeset): lint refuses a $record path to a structured field Claude-Session: https://claude.ai/code/session_017xRBcSAaBEfQpU2yJexSJ8 Co-authored-by: Claude --- .changeset/34562-record-structural-lint.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .changeset/34562-record-structural-lint.md diff --git a/.changeset/34562-record-structural-lint.md b/.changeset/34562-record-structural-lint.md new file mode 100644 index 00000000000..14bd651f092 --- /dev/null +++ b/.changeset/34562-record-structural-lint.md @@ -0,0 +1,12 @@ +--- +'@objectstack/lint': minor +--- + +fix(lint): a lookup filter's `$record` path to a structured field is refused where it is written + +Clause-②: no +Metadata-protocol: narrowed + +A lookup field's `lookupFilters[].value.$record` reads one value from the record being edited and compares it under a scalar operator. A path whose first segment, or whose leaf behind one relationship hop, is a structured field — a member of `STRUCTURED_JSON_TYPES` in `@objectstack/spec/data`: `json`, `composite`, `repeater`, `record`, `location`, `address`, `vector` — holds an object, not one value, so the picker's filter never matched and `os lint` said nothing. Rule `object-field-ref-unknown` now refuses such a path, at the same two positions and with the same hint as a path to a multi-valued field: point `$record` at a single-valued field. A hop through a structured field was already refused as "not a relationship" and still is, once. + +To fix a refused path, copy the value you mean onto a single-valued field and reference that field instead. From 9f302d5a64c874eeb37ecbaa1de586bfa2f7bf94 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 01:37:01 +0000 Subject: [PATCH 4/8] chore(changeset): ADR-0087 disposition for the structured-field refusal Claude-Session: https://claude.ai/code/session_017xRBcSAaBEfQpU2yJexSJ8 Co-authored-by: Claude --- .changeset/34562-record-structural-lint.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.changeset/34562-record-structural-lint.md b/.changeset/34562-record-structural-lint.md index 14bd651f092..08ad3d3d6ee 100644 --- a/.changeset/34562-record-structural-lint.md +++ b/.changeset/34562-record-structural-lint.md @@ -10,3 +10,5 @@ Metadata-protocol: narrowed A lookup field's `lookupFilters[].value.$record` reads one value from the record being edited and compares it under a scalar operator. A path whose first segment, or whose leaf behind one relationship hop, is a structured field — a member of `STRUCTURED_JSON_TYPES` in `@objectstack/spec/data`: `json`, `composite`, `repeater`, `record`, `location`, `address`, `vector` — holds an object, not one value, so the picker's filter never matched and `os lint` said nothing. Rule `object-field-ref-unknown` now refuses such a path, at the same two positions and with the same hint as a path to a multi-valued field: point `$record` at a single-valued field. A hop through a structured field was already refused as "not a relationship" and still is, once. To fix a refused path, copy the value you mean onto a single-valued field and reference that field instead. + + From 9c2f41e6e4f686876c7a3d7940ebe9c4cb2e9b62 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 02:10:49 +0000 Subject: [PATCH 5/8] chore(changeset): drop the refused ADR-0087 disposition; the ledger entry is owed in packages/spec Claude-Session: https://claude.ai/code/session_017xRBcSAaBEfQpU2yJexSJ8 Co-authored-by: Claude --- .changeset/34562-record-structural-lint.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/.changeset/34562-record-structural-lint.md b/.changeset/34562-record-structural-lint.md index 08ad3d3d6ee..14bd651f092 100644 --- a/.changeset/34562-record-structural-lint.md +++ b/.changeset/34562-record-structural-lint.md @@ -10,5 +10,3 @@ Metadata-protocol: narrowed A lookup field's `lookupFilters[].value.$record` reads one value from the record being edited and compares it under a scalar operator. A path whose first segment, or whose leaf behind one relationship hop, is a structured field — a member of `STRUCTURED_JSON_TYPES` in `@objectstack/spec/data`: `json`, `composite`, `repeater`, `record`, `location`, `address`, `vector` — holds an object, not one value, so the picker's filter never matched and `os lint` said nothing. Rule `object-field-ref-unknown` now refuses such a path, at the same two positions and with the same hint as a path to a multi-valued field: point `$record` at a single-valued field. A hop through a structured field was already refused as "not a relationship" and still is, once. To fix a refused path, copy the value you mean onto a single-valued field and reference that field instead. - - From fc1672bf1973c905734ccbd393ddf7e2d66a69e4 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 02:16:12 +0000 Subject: [PATCH 6/8] feat(spec): ADR-0087 ledger entry for the structured-field $record refusal Claude-Session: https://claude.ai/code/session_017xRBcSAaBEfQpU2yJexSJ8 Co-authored-by: Claude --- .changeset/34562-record-structural-lint.md | 9 +++- ...p-filter-record-path-structured-refused.ts | 45 +++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 packages/spec/src/migrations/entries/semantic/18.lookup-filter-record-path-structured-refused.ts diff --git a/.changeset/34562-record-structural-lint.md b/.changeset/34562-record-structural-lint.md index 14bd651f092..4ce65a379e8 100644 --- a/.changeset/34562-record-structural-lint.md +++ b/.changeset/34562-record-structural-lint.md @@ -1,12 +1,17 @@ --- '@objectstack/lint': minor +'@objectstack/spec': patch --- fix(lint): a lookup filter's `$record` path to a structured field is refused where it is written -Clause-②: no +Clause-②: no (narrowing) Metadata-protocol: narrowed -A lookup field's `lookupFilters[].value.$record` reads one value from the record being edited and compares it under a scalar operator. A path whose first segment, or whose leaf behind one relationship hop, is a structured field — a member of `STRUCTURED_JSON_TYPES` in `@objectstack/spec/data`: `json`, `composite`, `repeater`, `record`, `location`, `address`, `vector` — holds an object, not one value, so the picker's filter never matched and `os lint` said nothing. Rule `object-field-ref-unknown` now refuses such a path, at the same two positions and with the same hint as a path to a multi-valued field: point `$record` at a single-valued field. A hop through a structured field was already refused as "not a relationship" and still is, once. +A lookup field's `lookupFilters[].value.$record` reads one value from the record being edited and compares it under a scalar operator. A path whose first segment, or whose leaf behind one relationship hop, is a structured field — a member of `STRUCTURED_JSON_TYPES` in `@objectstack/spec/data`: `json`, `composite`, `repeater`, `record`, `location`, `address`, `vector` — holds an object, not one value. Read from code, the picker compares that object as one value under a scalar operator, so the filter does not do what it reads as, and `os lint` said nothing. Rule `object-field-ref-unknown` now refuses such a path, at the same two positions and with the same hint as a path to a multi-valued field: point `$record` at a single-valued field. A hop through a structured field was already refused as "not a relationship" and still is, once. To fix a refused path, copy the value you mean onto a single-valued field and reference that field instead. + +The ADR-0087 ledger gains the semantic entry `lookup-filter-record-path-structured-refused` in `@objectstack/spec`, beside the multi-valued one. + + diff --git a/packages/spec/src/migrations/entries/semantic/18.lookup-filter-record-path-structured-refused.ts b/packages/spec/src/migrations/entries/semantic/18.lookup-filter-record-path-structured-refused.ts new file mode 100644 index 00000000000..5fad1017baf --- /dev/null +++ b/packages/spec/src/migrations/entries/semantic/18.lookup-filter-record-path-structured-refused.ts @@ -0,0 +1,45 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +import type { SemanticMigration } from '../../types.js'; + +// #34562 — a `lookupFilters[].value` `{ $record: 'path' }` path must read ONE +// value of the record being edited: a path whose head, or whose leaf behind a +// single-valued hop, is a structured field (`STRUCTURED_JSON_TYPES`) names an +// object, and is refused as `object-field-ref-unknown`, beside the +// multi-valued refusal of #34378 (`lookup-filter-record-path-multi-valued-refused`). +// Measured first-party exposure at this change: zero — no example app, +// platform object, plugin or skill writes a `$record` path to such a field. +// Not converted: which single value a structured path meant is the author's +// judgement. +export const entry: SemanticMigration = { + id: 'lookup-filter-record-path-structured-refused', + surface: + 'objects[].fields..lookupFilters[].value.$record of a lookup, master_detail or user field, on an object saved ' + + 'or published through the metadata doors (PUT /api/v1/meta/object/NAME, POST /api/v1/packages/PKG/publish-drafts, ' + + 'the per-item publish and the restore doors) or loaded by os validate / os build / os lint: a path whose first ' + + 'segment is a structured field of the object that owns the picker field, or whose leaf behind a single-valued hop ' + + 'is a structured field of the object that hop references — structured being a member of STRUCTURED_JSON_TYPES ' + + '(json, composite, repeater, record, location, address, vector)', + replacement: + 'A { $record } path reads ONE value of the record being edited: a single-valued, scalar field of the object that ' + + 'owns the picker field ("quote_date"), or one single-valued relationship field of it followed by a scalar field ' + + 'of the object it references ("account.cb_market"). To filter by a value a structured field holds, copy the value ' + + 'you mean onto a single-valued field and reference that. Refused at error as `object-field-ref-unknown` ' + + '(422 INVALID_METADATA at the doors).', + reason: + 'The { $record } comparand stands for one value and pairs only with the six scalar comparisons, but a structured ' + + 'field holds an object (an address, a location, a JSON document, a list of rows), and the path check judged ' + + 'existence and multi-valuedness only, so such a path parsed and linted clean. Read from code: the picker would ' + + 'compare that object as one value under a scalar operator, which no declared reading answers, so the filter does ' + + 'not do what it reads as. The set is STRUCTURED_JSON_TYPES from @objectstack/spec/data, which the cross-field ' + + 'comparison classes already place in the list-or-object family with no comparison class. A hop THROUGH a ' + + 'structured field was already refused as not a relationship. No first-party stack (example apps, platform ' + + 'objects, plugins, skills) writes such a path today. A registry-injected column and a leaf on an object outside ' + + 'the stack are not judged. There is no mechanical rewrite: which single value the author meant is a judgement ' + + 'about the data.', + acceptanceCriteria: + 'Load every object (`os validate` or `os build`): no `object-field-ref-unknown` finding at ' + + 'fields.NAME.lookupFilters[N].value.$record that names a structured field. PUT ' + + '/api/v1/meta/object/NAME?mode=draft&package=PKG with each such path pointing at a single-valued scalar field (or ' + + 'one single-valued hop to one) answers 200, and POST /api/v1/packages/PKG/publish-drafts publishes it.', +}; From c0deeb35cc1bf12b674a57d5490dfe1f4a2ee4bc Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 02:22:11 +0000 Subject: [PATCH 7/8] docs(data-modeling): the $record refusal sentence names multi-valued and structured paths Claude-Session: https://claude.ai/code/session_017xRBcSAaBEfQpU2yJexSJ8 Co-authored-by: Claude --- content/docs/data-modeling/relationships.mdx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/content/docs/data-modeling/relationships.mdx b/content/docs/data-modeling/relationships.mdx index 5d1fbcf61a4..c430488c3d9 100644 --- a/content/docs/data-modeling/relationships.mdx +++ b/content/docs/data-modeling/relationships.mdx @@ -63,7 +63,10 @@ price_book: Field.lookup('price_book', { - **The reference.** `{ $record }` is the whole `value`, never a member of an `in` / `notIn` list, and pairs only with `eq`, `ne`, `gt`, `lt`, `gte` or `lte`. `os validate` refuses a - path that names no field of the object the lookup is on, or of the object its hop points at. + path that names no field of the object the lookup is on, or of the object its hop points at, + and a path whose first field, or whose leaf behind the hop, holds a list or an object rather + than one value: a multi-valued field, or a structured one (`json`, `address`, `location`, + `repeater` and the like). - **Where it resolves.** In a record form, whatever its layout. Every other picker host leaves every `{ $record }` entry out: inline edit on a record page, a record page's header or related list, an action's parameter dialog, and a bulk action over selected rows. From 9a9f0e6421d9675916ebe74684004b1d3d8f6a00 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 04:18:37 +0000 Subject: [PATCH 8/8] fix(spec)!: file the structured-field ledger entry under protocol 19; say list or object Claude-Session: https://claude.ai/code/session_017xRBcSAaBEfQpU2yJexSJ8 Co-authored-by: Claude --- .changeset/34562-record-structural-lint.md | 4 +-- .../lint/src/validate-object-field-refs.ts | 6 +++-- ...-filter-record-path-structured-refused.ts} | 27 ++++++++++--------- 3 files changed, 20 insertions(+), 17 deletions(-) rename packages/spec/src/migrations/entries/semantic/{18.lookup-filter-record-path-structured-refused.ts => 19.lookup-filter-record-path-structured-refused.ts} (65%) diff --git a/.changeset/34562-record-structural-lint.md b/.changeset/34562-record-structural-lint.md index 4ce65a379e8..7f3f8e926a5 100644 --- a/.changeset/34562-record-structural-lint.md +++ b/.changeset/34562-record-structural-lint.md @@ -3,12 +3,12 @@ '@objectstack/spec': patch --- -fix(lint): a lookup filter's `$record` path to a structured field is refused where it is written +fix(lint)!: a lookup filter's `$record` path to a structured field is refused where it is written Clause-②: no (narrowing) Metadata-protocol: narrowed -A lookup field's `lookupFilters[].value.$record` reads one value from the record being edited and compares it under a scalar operator. A path whose first segment, or whose leaf behind one relationship hop, is a structured field — a member of `STRUCTURED_JSON_TYPES` in `@objectstack/spec/data`: `json`, `composite`, `repeater`, `record`, `location`, `address`, `vector` — holds an object, not one value. Read from code, the picker compares that object as one value under a scalar operator, so the filter does not do what it reads as, and `os lint` said nothing. Rule `object-field-ref-unknown` now refuses such a path, at the same two positions and with the same hint as a path to a multi-valued field: point `$record` at a single-valued field. A hop through a structured field was already refused as "not a relationship" and still is, once. +A lookup field's `lookupFilters[].value.$record` reads one value from the record being edited and compares it under a scalar operator. A path whose first segment, or whose leaf behind one relationship hop, is a structured field — a member of `STRUCTURED_JSON_TYPES` in `@objectstack/spec/data`: `json`, `composite`, `repeater`, `record`, `location`, `address`, `vector` — holds a list or an object rather than one value. Read from code, the picker compares that list or object as one value under a scalar operator, so the filter does not do what it reads as, and `os lint` said nothing. Rule `object-field-ref-unknown` now refuses such a path, at the same two positions and with the same hint as a path to a multi-valued field: point `$record` at a single-valued field. A hop through a structured field was already refused as "not a relationship" and still is, once. To fix a refused path, copy the value you mean onto a single-valued field and reference that field instead. diff --git a/packages/lint/src/validate-object-field-refs.ts b/packages/lint/src/validate-object-field-refs.ts index cd9bbf46252..307e7d993c7 100644 --- a/packages/lint/src/validate-object-field-refs.ts +++ b/packages/lint/src/validate-object-field-refs.ts @@ -122,7 +122,8 @@ * `FieldSchema` reads. A plain path to, or a leaf behind a hop at, a * STRUCTURED field (#34562) — a member of `STRUCTURED_JSON_TYPES` * (`@objectstack/spec/data`): json, address, location, … — is refused the - * same way, with the same hint: it holds an object, not one value. A + * same way, with the same hint: it holds a list or an object rather than + * one value. A * registry-injected column, and a leaf on an object outside this stack, * stay unjudged. A `{ $record }` nested * deeper inside a literal (`value: { any: { $record: 'x' } }`) is an @@ -739,7 +740,8 @@ export function validateObjectFieldRefs(stack: AnyRec): ObjectFieldRefFinding[] * it, or a hop through it), else — behind a single-valued hop — its * authored leaf when that is. A STRUCTURED field (#34562: a member of * `STRUCTURED_JSON_TYPES`, `@objectstack/spec/data` — json, address, - * location, …) holds an object, so it has no scalar value either and is + * location, …) holds a list or an object rather than one value, so it has + * no scalar value either and is * named at the same two positions. `what` is the finding's noun for the * field. `undefined` = one scalar value, or not judgeable here (a * registry-injected column, an object outside the stack). diff --git a/packages/spec/src/migrations/entries/semantic/18.lookup-filter-record-path-structured-refused.ts b/packages/spec/src/migrations/entries/semantic/19.lookup-filter-record-path-structured-refused.ts similarity index 65% rename from packages/spec/src/migrations/entries/semantic/18.lookup-filter-record-path-structured-refused.ts rename to packages/spec/src/migrations/entries/semantic/19.lookup-filter-record-path-structured-refused.ts index 5fad1017baf..d92c6ba0387 100644 --- a/packages/spec/src/migrations/entries/semantic/18.lookup-filter-record-path-structured-refused.ts +++ b/packages/spec/src/migrations/entries/semantic/19.lookup-filter-record-path-structured-refused.ts @@ -4,9 +4,10 @@ import type { SemanticMigration } from '../../types.js'; // #34562 — a `lookupFilters[].value` `{ $record: 'path' }` path must read ONE // value of the record being edited: a path whose head, or whose leaf behind a -// single-valued hop, is a structured field (`STRUCTURED_JSON_TYPES`) names an -// object, and is refused as `object-field-ref-unknown`, beside the -// multi-valued refusal of #34378 (`lookup-filter-record-path-multi-valued-refused`). +// single-valued hop, is a structured field (`STRUCTURED_JSON_TYPES`) names a +// list or an object rather than one value, and is refused as +// `object-field-ref-unknown`, beside the multi-valued refusal of #34378 +// (`lookup-filter-record-path-multi-valued-refused`). // Measured first-party exposure at this change: zero — no example app, // platform object, plugin or skill writes a `$record` path to such a field. // Not converted: which single value a structured path meant is the author's @@ -27,16 +28,16 @@ export const entry: SemanticMigration = { + 'you mean onto a single-valued field and reference that. Refused at error as `object-field-ref-unknown` ' + '(422 INVALID_METADATA at the doors).', reason: - 'The { $record } comparand stands for one value and pairs only with the six scalar comparisons, but a structured ' - + 'field holds an object (an address, a location, a JSON document, a list of rows), and the path check judged ' - + 'existence and multi-valuedness only, so such a path parsed and linted clean. Read from code: the picker would ' - + 'compare that object as one value under a scalar operator, which no declared reading answers, so the filter does ' - + 'not do what it reads as. The set is STRUCTURED_JSON_TYPES from @objectstack/spec/data, which the cross-field ' - + 'comparison classes already place in the list-or-object family with no comparison class. A hop THROUGH a ' - + 'structured field was already refused as not a relationship. No first-party stack (example apps, platform ' - + 'objects, plugins, skills) writes such a path today. A registry-injected column and a leaf on an object outside ' - + 'the stack are not judged. There is no mechanical rewrite: which single value the author meant is a judgement ' - + 'about the data.', + 'The { $record } comparand stands for one value and pairs only with the six scalar comparisons, but a ' + + 'structured field holds a list or an object rather than one value (an address, a location, a JSON document, a ' + + 'list of rows), and the path check judged existence and multi-valuedness only, so such a path parsed and ' + + 'linted clean. Read from code: the picker would compare that list or object as one value under a scalar ' + + 'operator, which no declared reading answers, so the filter does not do what it reads as. The set is ' + + 'STRUCTURED_JSON_TYPES from @objectstack/spec/data, which the cross-field comparison classes already place in ' + + 'the list-or-object family with no comparison class. A hop THROUGH a structured field was already refused as ' + + 'not a relationship. No first-party stack (example apps, platform objects, plugins, skills) writes such a ' + + 'path today. A registry-injected column and a leaf on an object outside the stack are not judged. There is no ' + + 'mechanical rewrite: which single value the author meant is a judgement about the data.', acceptanceCriteria: 'Load every object (`os validate` or `os build`): no `object-field-ref-unknown` finding at ' + 'fields.NAME.lookupFilters[N].value.$record that names a structured field. PUT '