Repository navigation
feat(spec,core): a scoped import lookup miss whose value exists under another parent answers reference_out_of_scope - #37567
objectstack-fleet[bot] wants to merge 3 commits into
Conversation
… 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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L6bhgWgMUXf5juNBhN6rLX Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 3 package(s): 12 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 5 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 187 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin cb8f645bde92c54cc6ab4a51a1ce5fb7432fe7f0 && git checkout cb8f645bde92c54cc6ab4a51a1ce5fb7432fe7f0
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 411646562566a1e12b4e0fc3de256192e8302719 15f65b7610c656446cb5e3b20f99528868f6503c && git checkout -B drift-repro 411646562566a1e12b4e0fc3de256192e8302719 && git merge --no-ff 15f65b7610c656446cb5e3b20f99528868f6503c
node scripts/docs-audit/affected-docs.mjs --json 411646562566a1e12b4e0fc3de256192e8302719
|
…key; spec minor Claude-Session: https://claude.ai/code/session_01L6bhgWgMUXf5juNBhN6rLX Co-authored-by: Claude <noreply@anthropic.com>
Requested by Sales · project thread
Part of #36794 (PR-1 of 2: the spec reason and the importer; the Import Wizard text follows in PR-2 on the same branch once this one lands)
Clause-②: yes (widening)
Metadata-protocol: added (
ValidateDataIssueSchema.scope, a new optional key on the import cell error; the newFieldErrorCodevalue is a wire code, no author-writable key)Skills-docs: follow-up owed — skills/objectstack-data/rules/relationships.md
维护者速读
What changes
FieldErrorCodegainsreference_out_of_scope(packages/spec/src/api/errors.zod.ts, ADR-0114 D2 closed catalog), besidereference_not_found. Ruled route A on the card.import_reference_out_of_scopein all four platform locales (packages/spec/src/system/validation-message.ts). The English text is byte-identical to the sentence the scoped refusal already shipped with (Contract: no record matches "CTR-0006" (Account = "Acme")), now with{{scope}}as a parameter, so a deployment can override it undervalidation.field.import_reference_out_of_scopeand the other three locales say it in their own word order.ValidateDataIssueSchemagains an optionalscope: [{ field, value }](packages/spec/src/api/protocol.zod.ts), present only on an import cell error whose code isreference_out_of_scope. This is the thread's route decision, agreed by the seat at claim time: the card asks the Wizard to name the scoping column and its cell while keying on the code and never parsing server prose, and the row result carried no structured column at all. Same{ field, value }naming the importer already uses for the columns; additive, optional, Clause-② widening. The contract review below judges it.packages/core/src/utils/import-coerce.ts,import-runner.ts): the fix(core): a scoped import lookup miss names the scoping column when the value exists outside the scope #36735 unscoped probe now answers the new reason with the new message key and thescopeentries; the runner copiesscopeonto the row'serrorselement. A value nobody has keepsreference_not_found.RefMatch.scopeDenied,isScopeFieldDenial). A caller who cannot read the scope field (a hiddenmaster_detailfield, or theparamadependsOnentry names) has the scoped lookup refused, so its miss says nothing about where the value lives. Before this PR the probe still ran and the fix(core): a scoped import lookup miss names the scoping column when the value exists outside the scope #36735 sentence named the scope; with a code that now claims "under another parent", that answer would be wrong for a record sitting under the row's own parent. It keepsreference_not_foundand the plain sentence, which is whatcontent/docs/data-modeling/import-mappings.mdxalready says for that caller. The guard is read off the error's declareddetails.reason === 'field_predicate_denied'(the reason all four field-predicate guards answer) naming a scope field, never its message.packages/runtime/src/dispatcher-error-vocabulary.ts: the new code'sforeign-vocabularyrow (ADR-0112 D6), same wording as its three siblings.content/docs/api/error-catalog.mdxfield-code table andcontent/docs/data-modeling/import-mappings.mdxscoped-lookup section. Regenerated:content/docs/references/api/{errors,export,protocol}.mdx,packages/spec/authorable-surface/api.json(api/ValidateDataIssue:scope), the strictness-ledger count forapi/(537 → 538, the new nested object).@objectstack/specminor,@objectstack/coreand@objectstack/runtimepatch.Metadata-protocol: added, not the claim'snone:Check Changesetreads the newapi/ValidateDataIssue:scoperow inpackages/spec/authorable-surface/api.jsonas a key entered, and a kind other thannonegrades the package that carries it at leastminor.Tests
packages/core/src/utils/import-runner-reference-master-scope.test.ts: the import: a lookup cell refused by the row's dependent scope says "no record matches", although the record exists under another parent #36159 describe now pinsreference_out_of_scopefor adependsOnscope and a master scope, by name and by pasted id, single and multi-value, witherrors[0].scopeas data; a value nobody has keepsreference_not_foundwith noscopekey; the two import: a lookup cell resolves a name across the whole target object, not within the row's own master reference, so a repeated detail name ("Advance 30%" on two contracts) fails the row with reference_ambiguous #33523 pins whose value lives under another master move to the new code; a new pin: a scope the field guard refuses answersreference_not_foundand no unscoped probe runs.packages/rest/src/import-integration.test.ts: a new top-level describe drives the realPOST /data/:object/importroute on a real engine and sqlite with a realdependsOndeclaration: one row resolves, one answersreference_out_of_scopewithscope: [{ field: 'project', value: 'Gemini' }], one answersreference_not_foundwith noscope.packages/spec/src/system/validation-message.test.ts: every locale interpolates{{value}}and{{scope}}; the English render is the shipped sentence; the zh-CN render.if (scopedMatch.scopeDenied) return refusal;commented out, the guard pin goes red (1 failed / 15 passed), restored green.Local readings (tree f4a201e + 2e8b0b9)
pnpm --filter @objectstack/spec test: Test Files 900 passed (900), Tests 28505 passed, 1 todo.vitest run src/utils/import-runner-reference-master-scope.test.ts(core): 16 passed.src/utils/import-coerce.test.ts: passed.vitest run src/import-integration.test.ts(rest): 62 passed.pnpm --filter @objectstack/spec check:generated: 2 stale before--fix(references docs, strictness ledger), both green after.typecheckspec, core, runtime: green; rest: one TS18048 in the new pin, fixed in 2e8b0b9,check:test-typecheckOK.node scripts/check-dispatcher-error-vocabulary.mjs: exit 0.node scripts/pm/overlap-check.mjs: VERDICT clean exit 0 (main, feat(spec)!: form is a metadata type of its own, and the form doors read a form over both types #37422, feat(security)!: View All and Modify All stop opening fields; viewAllFields is the one every-field bit #37371).dispatch-gates.mjs --commandsderived list (118 commands) is running; its reading goes on the PR when done.Acceptance notes
reason === 'reference_not_found'to mean "the lookup cell did not resolve" stops seeing the out-of-scope case under that value. The schema only widens (a new enum member, a new optional key), so this PR declaresClause-②: yes (widening); whether the move of that case is itself a narrowing for such a client is the L2's call.Skills-docs: follow-up owed):skills/objectstack-data/rules/relationships.md:117says another master's detail answersreference_not_found.skills/**is governed, and this PR'sClause-②: yeskeeps it off the low-risk arm, so the line here would make the whole PR Tier H; the seat files the owed card.casefor, soformatDryRunErrorfalls through to the server's own sentence (already in the caller's locale, naming the scope) on both the dry-run panel and the completion screen. PR-2 gives the code its own Wizard key built fromscope.Verification
Read first:
packages/core/src/utils/import-coerce.tsreferenceNotFound(the new reason and the guard),packages/core/src/utils/import-runner.tsthe resolver'scatch(isScopeFieldDenial),packages/spec/src/api/protocol.zod.tsValidateDataIssueSchema.scope.Two-minute check:
pnpm --filter @objectstack/rest exec vitest run src/import-integration.test.ts -t "under another parent"— one test, green; row 2 answersreference_out_of_scopewith itsscope.Generated by Claude Code