From f4a201ea95f478ab2408ba99a4ae4bb72e1a06f9 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 13:25:36 +0000 Subject: [PATCH 1/4] feat(spec,core): a scoped import lookup miss whose value exists under another parent answers reference_out_of_scope FieldErrorCode gains reference_out_of_scope, with its catalog sentence import_reference_out_of_scope in all four platform locales. The importer answers it for a scoped lookup cell whose value matches a record only outside the row's scope, and the cell error carries the scoping columns as `scope: [{ field, value }]` (ValidateDataIssueSchema), so a client keyed on the code can name the column and its cell without parsing the message. A value no record has keeps reference_not_found. A scoped read the field-predicate guard refused is never probed, so it stays reference_not_found too. Claude-Session: https://claude.ai/code/session_01L6bhgWgMUXf5juNBhN6rLX Co-authored-by: Claude --- .changeset/36794-reference-out-of-scope.md | 18 +++++ content/docs/api/error-catalog.mdx | 2 +- .../docs/data-modeling/import-mappings.mdx | 9 ++- content/docs/references/api/errors.mdx | 4 +- content/docs/references/api/export.mdx | 2 + content/docs/references/api/protocol.mdx | 11 +++ .../api.md | 2 +- packages/core/src/utils/import-coerce.ts | 49 +++++++++--- ...port-runner-reference-master-scope.test.ts | 74 +++++++++++++++---- packages/core/src/utils/import-runner.ts | 24 +++++- packages/rest/src/import-integration.test.ts | 74 +++++++++++++++++++ .../src/dispatcher-error-vocabulary.ts | 13 ++++ packages/spec/authorable-surface/api.json | 1 + packages/spec/src/api/errors.zod.ts | 7 ++ packages/spec/src/api/protocol.zod.ts | 13 +++- .../src/system/validation-message.test.ts | 26 +++++++ .../spec/src/system/validation-message.ts | 12 +++ 17 files changed, 308 insertions(+), 33 deletions(-) create mode 100644 .changeset/36794-reference-out-of-scope.md diff --git a/.changeset/36794-reference-out-of-scope.md b/.changeset/36794-reference-out-of-scope.md new file mode 100644 index 00000000000..18c5f1846b2 --- /dev/null +++ b/.changeset/36794-reference-out-of-scope.md @@ -0,0 +1,18 @@ +--- +'@objectstack/spec': patch +'@objectstack/core': patch +'@objectstack/runtime': patch +--- + +feat(spec,core): an import lookup cell that names a record under another parent answers its own reason, `reference_out_of_scope`, with the scoping columns as data + +Clause-②: yes (widening) +Metadata-protocol: none (a wire error code, no author-writable key) + +`FieldErrorCode` (ADR-0114) gains `reference_out_of_scope`. The importer answers it for a SCOPED lookup cell (a `dependsOn` column, or the master the same row sets) whose value matches no record within the row's scope while it does match a record outside it: the row names a record that lives under another parent. Until now that cell answered `reference_not_found`, the same reason as a value no record has, and only the message told the two apart (`Contract: no record matches "CTR-0006" (Account = "Acme")`); a client that keys its text on the reason, such as the Import Wizard's dry run, could only say "no matching record". The message is unchanged in English and has its own catalog key, `import_reference_out_of_scope`, in all four platform locales (a deployment overrides it under `validation.field.import_reference_out_of_scope`). + +The cell error, the element of an import row's `errors` (`ValidateDataIssueSchema`), now carries `scope` on that reason only: the row columns the lookup was resolved within, each `{ field, value }` with the cell as the importer typed it, so a client names the scoping column and its cell without parsing `message`. + +Unchanged: a value that matches no record at all, scoped or not, still answers `reference_not_found` with the plain sentence and no `scope`. The out-of-scope probe is still the importing caller's own read, so a record that caller cannot read is never named and its cell answers `reference_not_found`. + +What to do: a client that switches on `reference_not_found` to tell a user "no such record" keeps receiving it for a value no record has. A client that wants every unresolved lookup cell matches `reference_not_found` and `reference_out_of_scope` both. diff --git a/content/docs/api/error-catalog.mdx b/content/docs/api/error-catalog.mdx index 0e7c33ec480..e1d76c527ca 100644 --- a/content/docs/api/error-catalog.mdx +++ b/content/docs/api/error-catalog.mdx @@ -930,7 +930,7 @@ snake_case, so the code and the schema property are the same word. | Presence and shape | `required`, `invalid_type`, `invalid_shape`, `unknown_field` | | Per-type parse | `invalid_boolean`, `invalid_number`, `invalid_date`, `invalid_time`, `invalid_email`, `invalid_url`, `invalid_phone`, `invalid_json`, `invalid_format` | | Bounded ranges | `min_length`, `max_length`, `min_value`, `max_value`, `max_scale`, `max_precision`, `min_items`, `max_items` | -| Closed sets and references | `invalid_option`, `value_domain` (the written value is not a member of the field's declared `valueDomain` standard), `invalid_value`, `reference_not_found`, `reference_ambiguous` | +| Closed sets and references | `invalid_option`, `value_domain` (the written value is not a member of the field's declared `valueDomain` standard), `invalid_value`, `reference_not_found`, `reference_ambiguous`, `reference_out_of_scope` (an import lookup cell whose value matches a record only under another parent than the row's own; the cell error names that parent's columns in `scope`) | | Declarative rules | `rule_violation`, `json_schema_violation`, `invalid_initial_state`, `invalid_transition` | Branch on `code` to decide *how* to mark an input; show `message` to the user. diff --git a/content/docs/data-modeling/import-mappings.mdx b/content/docs/data-modeling/import-mappings.mdx index e30a93945ae..247e0bdedb3 100644 --- a/content/docs/data-modeling/import-mappings.mdx +++ b/content/docs/data-modeling/import-mappings.mdx @@ -351,8 +351,13 @@ The `master_detail` rule has no counterpart in the picker, which narrows by `dep and `lookupFilters`, never by an inferred master: for a lookup without `dependsOn`, the import is stricter than the form. -Inside that scope a tie is `reference_ambiguous` and a name that only another master -carries is `reference_not_found`; it never resolves to another master's record. A row +Inside that scope a tie is `reference_ambiguous`, and a name or id that only another +master carries is `reference_out_of_scope`: it never resolves to another master's record. +The row's sentence names the scoping columns and the cells the row gave them +(`Contract: no record matches "CTR-0006" (Account = "Acme")`), and the cell error carries +the same columns as data, `scope: [{ field, value }]`, so a client can say so in its own +words. A name that no record carries anywhere stays `reference_not_found`. Only a record +the importing caller can read is ever counted as "under another master". A row that leaves the master blank is resolved across the whole target as before. When two columns of the row point at the master object (a bill-to and a ship-to account), neither is taken as the master; declare `dependsOn` on the lookup to say which one is. A master diff --git a/content/docs/references/api/errors.mdx b/content/docs/references/api/errors.mdx index 1ff601a170b..db1f1ce38b8 100644 --- a/content/docs/references/api/errors.mdx +++ b/content/docs/references/api/errors.mdx @@ -187,7 +187,7 @@ const result = EnhancedApiErrorSchema.parse(data); | Property | Type | Required | Description | | :--- | :--- | :--- | :--- | | **field** | `string` | ✅ | Field path (supports dot notation) | -| **code** | `Enum<'required' \| 'invalid_type' \| 'invalid_shape' \| 'unknown_field' \| 'invalid_boolean' \| 'invalid_number' \| 'invalid_date' \| 'invalid_time' \| 'invalid_email' \| … +22 more>` | ✅ | Which constraint the value violated (field-level catalog, ADR-0114) | +| **code** | `Enum<'required' \| 'invalid_type' \| 'invalid_shape' \| 'unknown_field' \| 'invalid_boolean' \| 'invalid_number' \| 'invalid_date' \| 'invalid_time' \| 'invalid_email' \| … +23 more>` | ✅ | Which constraint the value violated (field-level catalog, ADR-0114) | | **message** | `string` | ✅ | Human-readable error message, rendered in the caller’s locale | | **label** | `string` | optional | Field display label in the caller’s locale | | **hint** | `string` | optional | The full prescription behind a one-line message, when there is more to say | @@ -222,6 +222,7 @@ const result = EnhancedApiErrorSchema.parse(data); * `invalid_value` * `reference_not_found` * `reference_ambiguous` +* `reference_out_of_scope` * `reference_user_banned` * `rule_violation` * `json_schema_violation` @@ -261,6 +262,7 @@ const result = EnhancedApiErrorSchema.parse(data); * `invalid_value` * `reference_not_found` * `reference_ambiguous` +* `reference_out_of_scope` * `reference_user_banned` * `rule_violation` * `json_schema_violation` diff --git a/content/docs/references/api/export.mdx b/content/docs/references/api/export.mdx index bad83c8e727..f6945cc8c9c 100644 --- a/content/docs/references/api/export.mdx +++ b/content/docs/references/api/export.mdx @@ -395,6 +395,7 @@ Type: `{ sourceField: string; targetField: string; targetLabel?: string; transfo | **message** | `string` | ✅ | Human-readable message — a validation rule's author-written text where one exists. | | **rule** | `string` | optional | The `name` of the ADVISORY validation rule this finding reports. Present only on an advisory rule hit. | | **severity** | `Enum<'warning' \| 'info'>` | optional | The advisory rule's declared severity, `warning` or `info`. Present only on an advisory rule hit. | +| **scope** | `{ field: string; value: string }[]` | optional | The row columns a scoped lookup cell was resolved within, each with the cell the row gave it, in the order the refusal names them. Present only on an import cell error whose `code` is `reference_out_of_scope`: the value matches a record, but none within these columns, so a client can name the scoping column and its cell in its own text instead of parsing `message`. | ### Nested Shape: `ImportRowResult.warnings[number]` @@ -405,6 +406,7 @@ Type: `{ sourceField: string; targetField: string; targetLabel?: string; transfo | **message** | `string` | ✅ | Human-readable message — a validation rule's author-written text where one exists. | | **rule** | `string` | optional | The `name` of the ADVISORY validation rule this finding reports. Present only on an advisory rule hit. | | **severity** | `Enum<'warning' \| 'info'>` | optional | The advisory rule's declared severity, `warning` or `info`. Present only on an advisory rule hit. | +| **scope** | `{ field: string; value: string }[]` | optional | The row columns a scoped lookup cell was resolved within, each with the cell the row gave it, in the order the refusal names them. Present only on an import cell error whose `code` is `reference_out_of_scope`: the value matches a record, but none within these columns, so a client can name the scoping column and its cell in its own text instead of parsing `message`. | ### Nested Shape: `ImportRowResult.droppedFields[number]` diff --git a/content/docs/references/api/protocol.mdx b/content/docs/references/api/protocol.mdx index a948d2276a1..2b8e0086e22 100644 --- a/content/docs/references/api/protocol.mdx +++ b/content/docs/references/api/protocol.mdx @@ -570,6 +570,7 @@ A write-path strip event: caller-supplied fields legally dropped from the payloa | **message** | `string` | ✅ | Human-readable message — a validation rule's author-written text where one exists. | | **rule** | `string` | optional | The `name` of the ADVISORY validation rule this finding reports. Present only on an advisory rule hit. | | **severity** | `Enum<'warning' \| 'info'>` | optional | The advisory rule's declared severity, `warning` or `info`. Present only on an advisory rule hit. | +| **scope** | `{ field: string; value: string }[]` | optional | The row columns a scoped lookup cell was resolved within, each with the cell the row gave it, in the order the refusal names them. Present only on an import cell error whose `code` is `reference_out_of_scope`: the value matches a record, but none within these columns, so a client can name the scoping column and its cell in its own text instead of parsing `message`. | --- @@ -632,6 +633,7 @@ A write-path strip event: caller-supplied fields legally dropped from the payloa | **message** | `string` | ✅ | Human-readable message — a validation rule's author-written text where one exists. | | **rule** | `string` | optional | The `name` of the ADVISORY validation rule this finding reports. Present only on an advisory rule hit. | | **severity** | `Enum<'warning' \| 'info'>` | optional | The advisory rule's declared severity, `warning` or `info`. Present only on an advisory rule hit. | +| **scope** | `{ field: string; value: string }[]` | optional | The row columns a scoped lookup cell was resolved within, each with the cell the row gave it, in the order the refusal names them. Present only on an import cell error whose `code` is `reference_out_of_scope`: the value matches a record, but none within these columns, so a client can name the scoping column and its cell in its own text instead of parsing `message`. | --- @@ -3384,6 +3386,7 @@ A write-path strip event: caller-supplied fields legally dropped from the payloa | **message** | `string` | ✅ | Human-readable message — a validation rule's author-written text where one exists. | | **rule** | `string` | optional | The `name` of the ADVISORY validation rule this finding reports. Present only on an advisory rule hit. | | **severity** | `Enum<'warning' \| 'info'>` | optional | The advisory rule's declared severity, `warning` or `info`. Present only on an advisory rule hit. | +| **scope** | `{ field: string; value: string }[]` | optional | The row columns a scoped lookup cell was resolved within, each with the cell the row gave it, in the order the refusal names them. Present only on an import cell error whose `code` is `reference_out_of_scope`: the value matches a record, but none within these columns, so a client can name the scoping column and its cell in its own text instead of parsing `message`. | --- @@ -3522,6 +3525,14 @@ A write-path strip event: caller-supplied fields legally dropped from the payloa | **message** | `string` | ✅ | Human-readable message — a validation rule's author-written text where one exists. | | **rule** | `string` | optional | The `name` of the ADVISORY validation rule this finding reports. Present only on an advisory rule hit. | | **severity** | `Enum<'warning' \| 'info'>` | optional | The advisory rule's declared severity, `warning` or `info`. Present only on an advisory rule hit. | +| **scope** | `{ field: string; value: string }[]` | optional | The row columns a scoped lookup cell was resolved within, each with the cell the row gave it, in the order the refusal names them. Present only on an import cell error whose `code` is `reference_out_of_scope`: the value matches a record, but none within these columns, so a client can name the scoping column and its cell in its own text instead of parsing `message`. | + +### Nested Shape: `ValidateDataIssue.scope[number]` + +| Property | Type | Required | Description | +| :--- | :--- | :--- | :--- | +| **field** | `string` | ✅ | API name of the row column that scoped the lookup. | +| **value** | `string` | ✅ | The cell the row gave that column, as the importer typed it. | --- diff --git a/docs/audits/2026-07-unknown-key-strictness-ledger.counts/api.md b/docs/audits/2026-07-unknown-key-strictness-ledger.counts/api.md index 79e85164e25..ba6340a82b2 100644 --- a/docs/audits/2026-07-unknown-key-strictness-ledger.counts/api.md +++ b/docs/audits/2026-07-unknown-key-strictness-ledger.counts/api.md @@ -19,4 +19,4 @@ hand-patch a number here** — fix the code or the verdict and regenerate. | Dir | Sites | |---|---| -| `api/` | 537 | +| `api/` | 538 | diff --git a/packages/core/src/utils/import-coerce.ts b/packages/core/src/utils/import-coerce.ts index 55535a7675d..c59f943d038 100644 --- a/packages/core/src/utils/import-coerce.ts +++ b/packages/core/src/utils/import-coerce.ts @@ -89,6 +89,13 @@ export interface RefMatch { id?: string; ambiguous?: boolean; matchedField?: string; + /** + * [#36794] The SCOPED read was refused: its scope names a target field the + * caller cannot read. The miss then says nothing about where the value lives, + * so the refusal stays `reference_not_found` and the value is never reported + * as a record under another parent. + */ + scopeDenied?: boolean; } /** @@ -145,12 +152,13 @@ function resolveScoped( } /** - * [#36159] A row column a lookup cell was scoped by: the column's label and its - * cell as the importer typed it. Carried beside the scope (whose keys are the - * TARGET's fields and whose values are coerced ids) so a refusal can name what - * the importer wrote. + * [#36159] A row column a lookup cell was scoped by: the column's API name, its + * label and its cell as the importer typed it. Carried beside the scope (whose + * keys are the TARGET's fields and whose values are coerced ids) so a refusal + * can name what the importer wrote. */ interface ScopedBy { + field: string; label: string; value: string; } @@ -159,10 +167,17 @@ interface ScopedBy { * [#36159] The refusal for a reference cell that matched nothing. A scoped * miss is asked once more WITHOUT the scope, through the same resolver: when * the value matches a record there (one or several), the row's own scope is - * why nothing matched, and the sentence names the scoping columns and the + * why nothing matched. [#36794] That refusal has its own reason, + * `reference_out_of_scope`: its sentence names the scoping columns and the * values the row gave them, e.g. `Contract: no record matches "CTR-0006" - * (Account = "Acme")`. A value that matches nothing at all keeps the plain - * sentence. The reason stays `reference_not_found`. + * (Account = "Acme")`, and the error carries the same columns as `scope`, so a + * client keyed on the code (the Import Wizard) names them in its own text + * without parsing the sentence. A value that matches nothing at all keeps + * `reference_not_found` and the plain sentence. + * + * A scoped read the field-predicate guard refused (`RefMatch.scopeDenied`: the + * scope names a target field the caller cannot read) is never probed: its miss + * says nothing about where the value lives, so it stays `reference_not_found`. * * The probe is the caller's own read: the resolver runs every lookup as the * importing principal, so it can find only a record that principal can already @@ -177,13 +192,20 @@ async function referenceNotFound( ctx: CoerceContext, scope: Readonly> | undefined, scopedBy: readonly ScopedBy[] | undefined, + scopedMatch: RefMatch, ): Promise<{ error: FieldCoerceError }> { const refusal = coerceError(meta, field, 'reference_not_found', 'import_reference_not_found', value, ctx); if (!scope || !scopedBy || scopedBy.length === 0 || !ctx.resolveRef || !meta.reference) return refusal; + // A scope the caller may not filter by was never asked: nothing is known about + // where the value lives, so it is not "under another parent". + if (scopedMatch.scopeDenied) return refusal; const unscoped = normalizeRefMatch(await ctx.resolveRef(meta.reference, value, meta)); if (unscoped.id === undefined && !unscoped.ambiguous) return refusal; const qualifier = scopedBy.map((s) => `${s.label} = "${s.value}"`).join(', '); - return { error: { ...refusal.error, message: `${refusal.error.message} (${qualifier})` } }; + const outOfScope = coerceError( + meta, field, 'reference_out_of_scope', 'import_reference_out_of_scope', value, ctx, { scope: qualifier }, + ); + return { error: { ...outOfScope.error, scope: scopedBy.map((s) => ({ field: s.field, value: s.value })) } }; } /** Normalise a resolver result (legacy string or structured) to a RefMatch. */ @@ -244,6 +266,12 @@ export interface FieldCoerceError { */ code: FieldErrorCode; message: string; + /** + * [#36794] The row columns a `reference_out_of_scope` cell was resolved + * within, each with the cell the row gave it (`ValidateDataIssueSchema.scope`). + * Present on that code only. + */ + scope?: Array<{ field: string; value: string }>; } /** @@ -906,7 +934,7 @@ async function coerceCell( if (m.ambiguous) { return coerceError(meta, field, 'reference_ambiguous', 'import_reference_ambiguous', token, ctx); } - if (m.id === undefined) return referenceNotFound(meta, field, token, ctx, scope, scopedBy); + if (m.id === undefined) return referenceNotFound(meta, field, token, ctx, scope, scopedBy, m); out.push(m.id); } return { value: out }; @@ -920,7 +948,7 @@ async function coerceCell( if (match.ambiguous) { return coerceError(meta, field, 'reference_ambiguous', 'import_reference_ambiguous', display, ctx); } - if (match.id === undefined) return referenceNotFound(meta, field, display, ctx, scope, scopedBy); + if (match.id === undefined) return referenceNotFound(meta, field, display, ctx, scope, scopedBy, match); return { value: match.id }; } @@ -1086,6 +1114,7 @@ export async function coerceRow( (scope ??= {})[s.param] = v; // [#36159] What the importer wrote in the scoping column, by its label. scopedBy.push({ + field: s.field, label: metaMap.get(s.field)?.label?.trim() || s.field, value: String(sourceRow[s.field]).trim(), }); diff --git a/packages/core/src/utils/import-runner-reference-master-scope.test.ts b/packages/core/src/utils/import-runner-reference-master-scope.test.ts index 48e6b7f865a..fa7a782333b 100644 --- a/packages/core/src/utils/import-runner-reference-master-scope.test.ts +++ b/packages/core/src/utils/import-runner-reference-master-scope.test.ts @@ -14,8 +14,9 @@ * column and the target field it filters by. * * A row that sets no master keeps the whole-object lookup, so a tie there is - * still `reference_ambiguous`. A name absent under the row's master is - * `reference_not_found`, never a match under another master. + * still `reference_ambiguous`. A name absent under the row's master is never a + * match under another master: it is `reference_out_of_scope` when another + * master has it (#36794), and `reference_not_found` when no record has it. * * The fake's `findData` answers like the engine: equality over every `where` * key of the stored row, and it records the context each read ran under. @@ -145,7 +146,8 @@ describe('[#33523] an import lookup naming a detail resolves within the row\'s o expect(createData.mock.calls.map(([a]) => a.data.milestone)).toEqual(['m3']); }); - it('a name absent under the row\'s master is reference_not_found, never a match under another master', async () => { + // [#36794] Each name exists under ANOTHER master, so each is refused as reference_out_of_scope. + it('a name absent under the row\'s master is refused (reference_out_of_scope), never a match under another master', async () => { const { p, createData } = protocol(); const summary = await run(p, [ // Contract C has no "Advance 30%"; A and B do. @@ -156,9 +158,9 @@ describe('[#33523] an import lookup naming a detail resolves within the row\'s o { name: 'INV-3', contract: 'Contract B', milestone: 'm1' }, ]); expect(summary.results.map(verdict)).toEqual([ - { ok: false, code: 'reference_not_found', field: 'milestone' }, - { ok: false, code: 'reference_not_found', field: 'milestone' }, - { ok: false, code: 'reference_not_found', field: 'milestone' }, + { ok: false, code: 'reference_out_of_scope', field: 'milestone' }, + { ok: false, code: 'reference_out_of_scope', field: 'milestone' }, + { ok: false, code: 'reference_out_of_scope', field: 'milestone' }, ]); expect(createData).not.toHaveBeenCalled(); }); @@ -213,7 +215,7 @@ describe('[#33523] the match-key pass scopes a key column by the row\'s master t expect(createData.mock.calls.map(([a]) => a.data.milestone)).toEqual(['m1', 'm2']); }); - it('a key naming a detail of another master is not a shared key: that row alone answers reference_not_found', async () => { + it('a key naming a detail of another master is not a shared key: that row alone answers reference_out_of_scope', async () => { const { p, createData } = protocol(); const summary = await runImport({ p, context: CALLER, objectName: 'xm_invoice', metaMap, writeMode: 'upsert', matchFields: ['milestone'], @@ -226,23 +228,29 @@ describe('[#33523] the match-key pass scopes a key column by the row\'s master t { name: 'INV-2', contract: 'Contract B', milestone: 'Final 70%' }, ], }); - expect(summary.results.map(verdict)).toEqual([OK, { ok: false, code: 'reference_not_found', field: 'milestone' }]); + expect(summary.results.map(verdict)).toEqual([OK, { ok: false, code: 'reference_out_of_scope', field: 'milestone' }]); expect(createData.mock.calls.map(([a]) => a.data.milestone)).toEqual(['m3']); }); }); -describe('[#36159] a scoped miss whose value exists outside the row\'s scope names the scoping column', () => { +describe('[#36159] [#36794] a scoped miss whose value exists outside the row\'s scope is reference_out_of_scope, naming the scoping column', () => { const refusal = (r: { ok: boolean; code?: string; field?: string; error?: string }) => ({ ok: r.ok, code: r.code, field: r.field, error: r.error }); + const cellErrors = (r: { errors?: Array<{ field: string; code: string; scope?: unknown }> }) => + (r.errors ?? []).map(({ field, code, scope }) => ({ field, code, scope })); - it('a dependsOn-scoped cell naming another parent\'s record: reference_not_found naming Project and its cell', async () => { + it('a dependsOn-scoped cell naming another parent\'s record: reference_out_of_scope naming Project and its cell', async () => { const { p, createData } = protocol(); // "Design review" exists, under Apollo only. const summary = await run(p, [{ name: 'INV-1', project: 'Gemini', task: 'Design review' }]); expect(summary.results.map(refusal)).toEqual([{ - ok: false, code: 'reference_not_found', field: 'task', + ok: false, code: 'reference_out_of_scope', field: 'task', error: 'task: no record matches "Design review" (Project = "Gemini")', }]); + // The scoping column rides on the cell error as data, so a client never parses the sentence. + expect(summary.results.map(cellErrors)).toEqual([[ + { field: 'task', code: 'reference_out_of_scope', scope: [{ field: 'project', value: 'Gemini' }] }, + ]]); expect(createData).not.toHaveBeenCalled(); }); @@ -254,17 +262,21 @@ describe('[#36159] a scoped miss whose value exists outside the row\'s scope nam ]); expect(summary.results.map(refusal)).toEqual([ { - ok: false, code: 'reference_not_found', field: 'milestone', + ok: false, code: 'reference_out_of_scope', field: 'milestone', error: 'milestone: no record matches "Final 70%" (Contract = "Contract B")', }, { - ok: false, code: 'reference_not_found', field: 'milestone', + ok: false, code: 'reference_out_of_scope', field: 'milestone', error: 'milestone: no record matches "m1" (Contract = "Contract B")', }, ]); + expect(summary.results.map(cellErrors)).toEqual([ + [{ field: 'milestone', code: 'reference_out_of_scope', scope: [{ field: 'contract', value: 'Contract B' }] }], + [{ field: 'milestone', code: 'reference_out_of_scope', scope: [{ field: 'contract', value: 'Contract B' }] }], + ]); }); - it('a value that matches no record at all keeps the plain no-record-matches sentence', async () => { + it('a value that matches no record at all keeps reference_not_found and the plain sentence, with no scope', async () => { const { p } = protocol(); const summary = await run(p, [ { name: 'INV-1', project: 'Gemini', task: 'Retrospective' }, @@ -274,6 +286,11 @@ describe('[#36159] a scoped miss whose value exists outside the row\'s scope nam { ok: false, code: 'reference_not_found', field: 'task', error: 'task: no record matches "Retrospective"' }, { ok: false, code: 'reference_not_found', field: 'milestone', error: 'milestone: no record matches "Holdback 5%"' }, ]); + expect(summary.results.map(cellErrors)).toEqual([ + [{ field: 'task', code: 'reference_not_found', scope: undefined }], + [{ field: 'milestone', code: 'reference_not_found', scope: undefined }], + ]); + for (const r of summary.results) expect(r.errors?.[0]).not.toHaveProperty('scope'); }); it('a multi-value cell: the token outside the scope is refused with the same sentence', async () => { @@ -284,13 +301,40 @@ describe('[#36159] a scoped miss whose value exists outside the row\'s scope nam ]); expect(summary.results.map(refusal)).toEqual([ { - ok: false, code: 'reference_not_found', field: 'tasks', + ok: false, code: 'reference_out_of_scope', field: 'tasks', error: 'tasks: no record matches "Design review" (Project = "Gemini")', }, { ok: false, code: 'reference_not_found', field: 'tasks', error: 'tasks: no record matches "Retrospective"' }, ]); }); + it('a scope the caller may not filter by is refused by the field guard: reference_not_found, never out of scope', async () => { + const { p, findData } = protocol(); + // The caller cannot read xm_task.project: the field-predicate guard refuses + // any read that filters by it, as plugin-security's does. + findData.mockImplementation(async (args: FindArgs) => { + const where = args.query!.where as Record; + if (args.object === 'xm_task' && 'project' in where) { + throw Object.assign(new Error('[Security] Access denied'), { + code: 'PERMISSION_DENIED', status: 403, + details: { object: 'xm_task', fields: ['project'], reason: 'field_predicate_denied' }, + }); + } + return (ROWS[args.object] ?? []).filter((r) => matches(r, where)); + }); + // "Design review" is Apollo's, and the row names Apollo: the guard, not the + // row's parent, is why the scoped read found nothing. + const summary = await run(p, [{ name: 'INV-1', project: 'Apollo', task: 'Design review' }]); + expect(summary.results.map(refusal)).toEqual([ + { ok: false, code: 'reference_not_found', field: 'task', error: 'task: no record matches "Design review"' }, + ]); + expect(summary.results.map(cellErrors)).toEqual([[{ field: 'task', code: 'reference_not_found', scope: undefined }]]); + // No unscoped probe ran: every xm_task read carried the scope. + const taskReads = findData.mock.calls.map(([c]) => c).filter((c) => c.object === 'xm_task'); + expect(taskReads.length).toBeGreaterThan(0); + for (const c of taskReads) expect(c.query!.where).toHaveProperty('project'); + }); + it('the unscoped probe is the importing caller\'s own read, and a record that caller cannot read stays unnamed', async () => { const { p, findData } = protocol(); // The caller's reads see no Apollo task: the fake hides xm_task rows of p1 diff --git a/packages/core/src/utils/import-runner.ts b/packages/core/src/utils/import-runner.ts index db4f26baa55..42267edb120 100644 --- a/packages/core/src/utils/import-runner.ts +++ b/packages/core/src/utils/import-runner.ts @@ -815,6 +815,19 @@ const yieldToEventLoop = (): Promise => else setTimeout(resolve, 0); }); +/** + * [#36794] Whether a scoped lookup read was refused because its scope names a + * target field the caller cannot read: the field-predicate guard's + * `PermissionDeniedError` (`details.reason: 'field_predicate_denied'`, the one + * reason every such guard answers) naming at least one scope field. Read off + * the error's declared `details`, never its message. + */ +function isScopeFieldDenial(e: unknown, scope: Readonly>): boolean { + const details = (e as { details?: { reason?: unknown; fields?: unknown } } | null)?.details; + if (details?.reason !== 'field_predicate_denied' || !Array.isArray(details.fields)) return false; + return details.fields.some((f) => typeof f === 'string' && Object.prototype.hasOwnProperty.call(scope, f)); +} + /** * [#27465] The refusal of a match key naming a field that holds a list or a * structured value, or `undefined` when every named field can be a key. @@ -997,7 +1010,14 @@ export function runImport(opts: RunImportOptions): Promise { if (recs.length === 0) continue; if (recs.length > 1) { match = { ambiguous: true, matchedField: f }; break; } if (recs[0]?.id != null) { match = { id: String(recs[0].id), matchedField: f }; break; } - } catch { /* field absent on target object — try the next candidate */ } + } catch (e) { + // [#36794] A scope naming a target field the caller cannot read is + // refused by the field-predicate guard, so this miss says nothing + // about where the value lives: report it as such, never as a record + // that lives under another parent. + if (scope && isScopeFieldDenial(e, scope)) { match = { scopeDenied: true }; break; } + /* field absent on target object — try the next candidate */ + } } return match; }; @@ -1644,7 +1664,7 @@ export function runImport(opts: RunImportOptions): Promise { errCount++; results[i] = { row: rowNo, ok: false, action: 'failed', field: first.field, code: first.code, error: first.message, - errors: errors.map(({ field, code, message }) => ({ field, code, message })), + errors: errors.map(({ field, code, message, scope }) => ({ field, code, message, ...(scope ? { scope } : {}) })), }; } else if (shared) { // [#26133] Another row of this import carries the same key. diff --git a/packages/rest/src/import-integration.test.ts b/packages/rest/src/import-integration.test.ts index 43689d82807..f85bc2d7c2e 100644 --- a/packages/rest/src/import-integration.test.ts +++ b/packages/rest/src/import-integration.test.ts @@ -1534,3 +1534,77 @@ describe('GET /meta/mapping — items are raw documents, not publish envelopes ( expectRawDocumentShape(await listMapping(rest)); }); }); + +/** + * [#36794] The REST import door's answer for a scoped lookup cell naming a + * record that exists only under ANOTHER parent: `reason` + * `reference_out_of_scope`, with the scoping column and its cell as data on the + * cell error, while a value that matches no record at all keeps + * `reference_not_found`. A real engine and a real `dependsOn` declaration, so + * the scope is the one a deployment resolves, not a fake's. + */ +describe('import route — a scoped lookup miss whose value exists under another parent', () => { + const XP_PROJECT = { + name: 'xp_project', label: 'Project', systemFields: false, + fields: { + id: { name: 'id', type: 'text' as const, primaryKey: true }, + name: { name: 'name', type: 'text' as const, label: 'Name' }, + }, + }; + const XP_TASK = { + name: 'xp_task', label: 'Task', systemFields: false, + fields: { + id: { name: 'id', type: 'text' as const, primaryKey: true }, + name: { name: 'name', type: 'text' as const, label: 'Name' }, + project: { name: 'project', type: 'lookup' as const, label: 'Project', reference: 'xp_project', displayField: 'name' }, + }, + }; + const XP_TIMESHEET = { + name: 'xp_timesheet', label: 'Timesheet', systemFields: false, + fields: { + id: { name: 'id', type: 'text' as const, primaryKey: true }, + project: { name: 'project', type: 'lookup' as const, label: 'Project', reference: 'xp_project', displayField: 'name' }, + task: { + name: 'task', type: 'lookup' as const, label: 'Task', reference: 'xp_task', displayField: 'name', + dependsOn: [{ field: 'project', param: 'project' }], + }, + }, + }; + + it('answers reference_out_of_scope naming Project and its cell, and keeps reference_not_found for a value nobody has', async () => { + const { engine, route } = await boot(); + for (const o of [XP_PROJECT, XP_TASK, XP_TIMESHEET]) engine.registry.registerObject(o as any); + await engine.syncSchemas(); + await engine.insert('xp_project', { id: 'p1', name: 'Apollo' }); + await engine.insert('xp_project', { id: 'p2', name: 'Gemini' }); + await engine.insert('xp_task', { id: 't1', name: 'Design review', project: 'p1' }); + + const res = makeRes(); + await route.handler({ + params: { object: 'xp_timesheet' }, + body: { + format: 'json', + rows: [ + { id: 's1', project: 'Apollo', task: 'Design review' }, // under its own project → resolves + { id: 's2', project: 'Gemini', task: 'Design review' }, // Apollo's task, row says Gemini + { id: 's3', project: 'Gemini', task: 'Retrospective' }, // no task has this name + ], + }, + } as any, res); + + expect(res._json).toMatchObject({ created: 1, errors: 2 }); + const [, outOfScope, missing] = res._json.results; + expect(outOfScope).toMatchObject({ + row: 2, ok: false, field: 'task', code: 'reference_out_of_scope', + error: 'Task: no record matches "Design review" (Project = "Gemini")', + }); + expect(outOfScope.errors).toEqual([{ + field: 'task', code: 'reference_out_of_scope', + message: 'Task: no record matches "Design review" (Project = "Gemini")', + scope: [{ field: 'project', value: 'Gemini' }], + }]); + expect(missing).toMatchObject({ row: 3, ok: false, field: 'task', code: 'reference_not_found' }); + expect(missing.errors[0]).not.toHaveProperty('scope'); + expect(await engine.findOne('xp_timesheet', { where: { id: 's1' } })).toMatchObject({ task: 't1' }); + }); +}); diff --git a/packages/runtime/src/dispatcher-error-vocabulary.ts b/packages/runtime/src/dispatcher-error-vocabulary.ts index 7778536052c..0b99b69201a 100644 --- a/packages/runtime/src/dispatcher-error-vocabulary.ts +++ b/packages/runtime/src/dispatcher-error-vocabulary.ts @@ -1134,6 +1134,19 @@ export const UNREGISTERED_CODE_SITES: readonly UnregisteredCodeSite[] = [ '\'reference_not_found\' is one of them. It reaches `ApiError.details.fields[].code`, never ' + '`error.code`, so no ledger row can be owed for it (ADR-0112 D6).', }, + { + code: 'reference_out_of_scope', + file: 'packages/core/src/utils/import-coerce.ts', + shape: 'objlithelper', + door: 'none', + verdict: 'foreign-vocabulary', + why: + 'import-coerce\'s `coerceError(meta, field, code: FieldErrorCode, …)` builds the per-cell ' + + '`FieldCoerceError` an import row reports. Its `code` parameter is typed `code: FieldErrorCode`, ' + + 'so the value is a member of the closed ADR-0114 D2 catalog by construction; ' + + '\'reference_out_of_scope\' is one of them. It reaches `ApiError.details.fields[].code`, never ' + + '`error.code`, so no ledger row can be owed for it (ADR-0112 D6).', + }, // invalidQueryParam() — query-param.ts { code: 'invalid_boolean', diff --git a/packages/spec/authorable-surface/api.json b/packages/spec/authorable-surface/api.json index 50addb40d4f..7f0627aa9b0 100644 --- a/packages/spec/authorable-surface/api.json +++ b/packages/spec/authorable-surface/api.json @@ -2081,6 +2081,7 @@ "api/ValidateDataIssue:field", "api/ValidateDataIssue:message", "api/ValidateDataIssue:rule", + "api/ValidateDataIssue:scope", "api/ValidateDataIssue:severity", "api/ValidateDataRequest:data", "api/ValidateDataRequest:mode", diff --git a/packages/spec/src/api/errors.zod.ts b/packages/spec/src/api/errors.zod.ts index c59b8fc09d0..5f2903438bb 100644 --- a/packages/spec/src/api/errors.zod.ts +++ b/packages/spec/src/api/errors.zod.ts @@ -285,6 +285,13 @@ export const FieldErrorCode = z.enum([ 'invalid_value', // rejected for a reason no other member names 'reference_not_found', // a lookup target that does not exist 'reference_ambiguous', // a lookup that matched more than one record + // a SCOPED lookup that matched nothing within its scope while the same value + // does match a record outside it: the row names a record that lives under + // another parent (a `dependsOn` column, or the master the row also sets). + // Split from `reference_not_found` so a client keyed on the code can say + // "under another parent" rather than "no such record"; a value matching + // nothing anywhere keeps `reference_not_found`. + 'reference_out_of_scope', // a lookup to `sys_user` that names a user whose ban is in force: the write // ADDS work for someone who cannot sign in, so it is refused (a value the // row already stores is not the write's, as for `reference_not_found`). diff --git a/packages/spec/src/api/protocol.zod.ts b/packages/spec/src/api/protocol.zod.ts index 1c68b3370e1..31d618ee9e3 100644 --- a/packages/spec/src/api/protocol.zod.ts +++ b/packages/spec/src/api/protocol.zod.ts @@ -3481,7 +3481,9 @@ export const CreateDataRequestSchema = lazySchema(() => z.object({ * and `severity` — both members taken from `ValidationAdvisoryEventSchema` * (`data/data-engine.zod.ts`), the event the engine reports the hit through, * so an event IS an issue and the write and its preview answer in one - * vocabulary. Declared before the write answers that reference it: a schema + * vocabulary. An import's `reference_out_of_scope` cell error additionally + * names its `scope`: the row columns the lookup was resolved within (#36794). + * Declared before the write answers that reference it: a schema * built eagerly (`OS_EAGER_SCHEMAS=1`) would otherwise read it before it exists. */ export const ValidateDataIssueSchema = lazySchema(() => z.object({ @@ -3494,6 +3496,15 @@ export const ValidateDataIssueSchema = lazySchema(() => z.object({ severity: ValidationAdvisoryEventSchema.shape.severity.optional().describe( 'The advisory rule\'s declared severity, `warning` or `info`. Present only on an advisory rule hit.', ), + scope: z.array(z.object({ + field: z.string().describe('API name of the row column that scoped the lookup.'), + value: z.string().describe('The cell the row gave that column, as the importer typed it.'), + })).optional().describe( + 'The row columns a scoped lookup cell was resolved within, each with the cell the row gave it, in the ' + + 'order the refusal names them. Present only on an import cell error whose `code` is ' + + '`reference_out_of_scope`: the value matches a record, but none within these columns, so a client can ' + + 'name the scoping column and its cell in its own text instead of parsing `message`.', + ), })); /** diff --git a/packages/spec/src/system/validation-message.test.ts b/packages/spec/src/system/validation-message.test.ts index c95db1df68b..b8419e3941c 100644 --- a/packages/spec/src/system/validation-message.test.ts +++ b/packages/spec/src/system/validation-message.test.ts @@ -280,3 +280,29 @@ describe('invalid_number_currency_object — the shape lesson, with no currency } }); }); + +/** + * #36794 — `reference_out_of_scope`'s sentence: a scoped lookup cell whose + * value matches a record only outside the row's scope. Every locale names the + * value and the scoping columns (`{{scope}}`), so the refusal never reads as + * "no such record" in any language. + */ +describe('import_reference_out_of_scope — names the value and the scope in every locale', () => { + it('every locale interpolates {{value}} and {{scope}}', () => { + for (const [locale, catalog] of Object.entries(BUILTIN_VALIDATION_MESSAGES)) { + const template = catalog.import_reference_out_of_scope; + expect(template, locale).toBeDefined(); + expect(template, locale).toContain('{{value}}'); + expect(template, locale).toContain('{{scope}}'); + } + }); + + it('renders the English sentence the scoped refusal shipped with, and the scope it is handed in zh-CN', () => { + const params = { value: 'CTR-0006', scope: 'Account = "Acme"' }; + expect(renderValidationMessage({ messageKey: 'import_reference_out_of_scope', label: 'Contract', params })) + .toBe('Contract: no record matches "CTR-0006" (Account = "Acme")'); + expect( + renderValidationMessage({ messageKey: 'import_reference_out_of_scope', label: '合同', params }, { locale: 'zh-CN' }), + ).toBe('合同:在 Account = "Acme" 下未找到与“CTR-0006”匹配的记录'); + }); +}); diff --git a/packages/spec/src/system/validation-message.ts b/packages/spec/src/system/validation-message.ts index 367b0016e8d..f2b25edd755 100644 --- a/packages/spec/src/system/validation-message.ts +++ b/packages/spec/src/system/validation-message.ts @@ -60,6 +60,14 @@ * this issue is about; the column and the offending value are what the importer * can act on. * + * `import_reference_out_of_scope` is `reference_out_of_scope`'s sentence: a + * scoped lookup cell whose value matches a record only outside the row's scope. + * `{{scope}}` is the scoping columns as the row gave them, by LABEL and cell + * (`Account = "Acme"`, several joined with `, `), composed by the importer from + * labels, cells and punctuation only. The same columns ride on the cell error + * as structured `scope` entries, so a client renders its own text from them + * instead of parsing this one. + * * `import_duplicate_match_key` is the importer's ROW refusal for rows of one * file that share a match key (`DUPLICATE_MATCH_KEY`, `core/import-runner.ts`): * not a cell's failure, but a sentence in the same row report, so it is read in @@ -187,6 +195,7 @@ export const BUILTIN_VALIDATION_MESSAGES: Record> import_unknown_option: '{{label}}: "{{value}}" is not a known option', import_reference_ambiguous: '{{label}}: "{{value}}" matches more than one record — use a unique value or the record id', import_reference_not_found: '{{label}}: no record matches "{{value}}"', + import_reference_out_of_scope: '{{label}}: no record matches "{{value}}" ({{scope}})', import_duplicate_match_key: 'Rows {{rows}} of this import have the same match key ({{label}}), so none of them was written: keep one row per key and import again', import_blank_match_key: 'The row has no match key: every key set ({{label}}) has a blank field on it', import_multi_value_match_key: 'The match key cannot use {{label}}: a match key compares one value per field, and a field holding a list or a structured value has no one value to compare — match on single-value fields (a code, a name, an email) instead', @@ -241,6 +250,7 @@ export const BUILTIN_VALIDATION_MESSAGES: Record> import_unknown_option: '{{label}}:“{{value}}”不是可选值之一', import_reference_ambiguous: '{{label}}:“{{value}}”匹配到多条记录,请改用唯一值或记录 ID', import_reference_not_found: '{{label}}:未找到与“{{value}}”匹配的记录', + import_reference_out_of_scope: '{{label}}:在 {{scope}} 下未找到与“{{value}}”匹配的记录', import_duplicate_match_key: '本次导入的第 {{rows}} 行匹配键({{label}})相同,因此均未写入:每个匹配键只保留一行后重新导入', import_blank_match_key: '该行没有匹配键:每组匹配键({{label}})在该行都有空白字段', import_multi_value_match_key: '不能用{{label}}作为匹配键:匹配键每个字段只比较一个值,而列表或结构化值没有单一的值可比较,请改用单值字段(如编码、名称、邮箱)匹配', @@ -292,6 +302,7 @@ export const BUILTIN_VALIDATION_MESSAGES: Record> import_unknown_option: '{{label}}:「{{value}}」は選択肢にありません', import_reference_ambiguous: '{{label}}:「{{value}}」に複数のレコードが一致します。一意の値かレコード ID を指定してください', import_reference_not_found: '{{label}}:「{{value}}」に一致するレコードが見つかりません', + import_reference_out_of_scope: '{{label}}:{{scope}} の範囲に「{{value}}」に一致するレコードが見つかりません', import_duplicate_match_key: 'このインポートの {{rows}} 行目は一致キー({{label}})が同じため、いずれも書き込まれませんでした。キーごとに 1 行だけ残して、もう一度インポートしてください', import_blank_match_key: 'この行には一致キーがありません。どの一致キーの組み合わせ({{label}})にも空欄の項目があります', import_multi_value_match_key: '{{label}} は一致キーに使えません。一致キーは項目ごとに 1 つの値を比較しますが、リストや構造化された値を持つ項目には比較できる 1 つの値がありません。単一値の項目(コード、名前、メールアドレスなど)で照合してください', @@ -343,6 +354,7 @@ export const BUILTIN_VALIDATION_MESSAGES: Record> import_unknown_option: '{{label}}: «{{value}}» no es una opción conocida', import_reference_ambiguous: '{{label}}: «{{value}}» coincide con más de un registro; use un valor único o el id del registro', import_reference_not_found: '{{label}}: ningún registro coincide con «{{value}}»', + import_reference_out_of_scope: '{{label}}: ningún registro coincide con «{{value}}» ({{scope}})', import_duplicate_match_key: 'Las filas {{rows}} de esta importación tienen la misma clave de coincidencia ({{label}}), así que no se escribió ninguna: deje una sola fila por clave e importe de nuevo', import_blank_match_key: 'La fila no tiene clave de coincidencia: cada conjunto de claves ({{label}}) tiene un campo vacío en ella', import_multi_value_match_key: 'La clave de coincidencia no puede usar {{label}}: una clave de coincidencia compara un valor por campo, y un campo que contiene una lista o un valor estructurado no tiene un único valor que comparar; use campos de un solo valor (un código, un nombre, un correo) en su lugar', From 2e8b0b964e27fbd2c8b37bdddafb46e2fc397775 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 13:30:46 +0000 Subject: [PATCH 2/4] test(rest): narrow the route before calling it in the out-of-scope pin Claude-Session: https://claude.ai/code/session_01L6bhgWgMUXf5juNBhN6rLX Co-authored-by: Claude --- packages/rest/src/import-integration.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/rest/src/import-integration.test.ts b/packages/rest/src/import-integration.test.ts index f85bc2d7c2e..61b2ac3fb8c 100644 --- a/packages/rest/src/import-integration.test.ts +++ b/packages/rest/src/import-integration.test.ts @@ -1579,8 +1579,9 @@ describe('import route — a scoped lookup miss whose value exists under another await engine.insert('xp_project', { id: 'p2', name: 'Gemini' }); await engine.insert('xp_task', { id: 't1', name: 'Design review', project: 'p1' }); + expect(route).toBeDefined(); const res = makeRes(); - await route.handler({ + await route!.handler({ params: { object: 'xp_timesheet' }, body: { format: 'json', From 15f65b7610c656446cb5e3b20f99528868f6503c Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 13:35:17 +0000 Subject: [PATCH 3/4] chore(changeset): Metadata-protocol added for the new optional scope key; spec minor Claude-Session: https://claude.ai/code/session_01L6bhgWgMUXf5juNBhN6rLX Co-authored-by: Claude --- .changeset/36794-reference-out-of-scope.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.changeset/36794-reference-out-of-scope.md b/.changeset/36794-reference-out-of-scope.md index 18c5f1846b2..2703a2649e3 100644 --- a/.changeset/36794-reference-out-of-scope.md +++ b/.changeset/36794-reference-out-of-scope.md @@ -1,5 +1,5 @@ --- -'@objectstack/spec': patch +'@objectstack/spec': minor '@objectstack/core': patch '@objectstack/runtime': patch --- @@ -7,7 +7,8 @@ feat(spec,core): an import lookup cell that names a record under another parent answers its own reason, `reference_out_of_scope`, with the scoping columns as data Clause-②: yes (widening) -Metadata-protocol: none (a wire error code, no author-writable key) +Metadata-protocol: added (`ValidateDataIssueSchema.scope`, a new optional key on the import cell error; the new `FieldErrorCode` value is a wire code, no author-writable key) +Skills-docs: follow-up owed — skills/objectstack-data/rules/relationships.md `FieldErrorCode` (ADR-0114) gains `reference_out_of_scope`. The importer answers it for a SCOPED lookup cell (a `dependsOn` column, or the master the same row sets) whose value matches no record within the row's scope while it does match a record outside it: the row names a record that lives under another parent. Until now that cell answered `reference_not_found`, the same reason as a value no record has, and only the message told the two apart (`Contract: no record matches "CTR-0006" (Account = "Acme")`); a client that keys its text on the reason, such as the Import Wizard's dry run, could only say "no matching record". The message is unchanged in English and has its own catalog key, `import_reference_out_of_scope`, in all four platform locales (a deployment overrides it under `validation.field.import_reference_out_of_scope`). From 80a79c7732c04fc57b067c26aa74bdabe5b34604 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 14:26:01 +0000 Subject: [PATCH 4/4] chore(changeset): Skills-docs follow-up names its card Claude-Session: https://claude.ai/code/session_01L6bhgWgMUXf5juNBhN6rLX Co-authored-by: Claude --- .changeset/36794-reference-out-of-scope.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/36794-reference-out-of-scope.md b/.changeset/36794-reference-out-of-scope.md index 2703a2649e3..385c6da7724 100644 --- a/.changeset/36794-reference-out-of-scope.md +++ b/.changeset/36794-reference-out-of-scope.md @@ -8,7 +8,7 @@ feat(spec,core): an import lookup cell that names a record under another parent Clause-②: yes (widening) Metadata-protocol: added (`ValidateDataIssueSchema.scope`, a new optional key on the import cell error; the new `FieldErrorCode` value is a wire code, no author-writable key) -Skills-docs: follow-up owed — skills/objectstack-data/rules/relationships.md +Skills-docs: follow-up #37590 `FieldErrorCode` (ADR-0114) gains `reference_out_of_scope`. The importer answers it for a SCOPED lookup cell (a `dependsOn` column, or the master the same row sets) whose value matches no record within the row's scope while it does match a record outside it: the row names a record that lives under another parent. Until now that cell answered `reference_not_found`, the same reason as a value no record has, and only the message told the two apart (`Contract: no record matches "CTR-0006" (Account = "Acme")`); a client that keys its text on the reason, such as the Import Wizard's dry run, could only say "no matching record". The message is unchanged in English and has its own catalog key, `import_reference_out_of_scope`, in all four platform locales (a deployment overrides it under `validation.field.import_reference_out_of_scope`).