Skip to content

fix(lint,core)!: refuse a lookup dependsOn filter key naming a formula of its target; an import lookup no scoped read answered is never out of scope - #37910

Merged
os-zhuang merged 3 commits into
mainfrom
claude/project-thread-wv76zu
Nov 27, 2026
Merged

os-zhuang merged 3 commits into
mainfrom
claude/project-thread-wv76zu

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Sales · project thread

Fixes #37717

Clause-②: yes (narrowing)
Metadata-protocol: narrowed
Skills-docs: none — no skills/ page teaches a dependsOn filter key on a formula field; content/docs/data-modeling/import-mappings.mdx names the refusal in this change

维护者速读

  • 应用作者在查找字段的 dependsOn 里,把筛选键指向目标对象上的公式字段时,os validate、构建以及 Studio、REST、MCP 保存都会直接报错,并点出是哪个字段、为什么不行、该改成哪个存储字段。以前这种写法能发布,之后记录选择器查不出候选,导入这一列的每一行都失败。
  • 这是座位复审 PR feat(plugin-grid,core): the Import Wizard names the column a lookup cell was scoped by; a scope no read could filter by says so #37706 时留下的两条小尾巴(导入“值属于另一个父记录”这条提示的后续):一条是作者时提前报错,一条是导入时如果限定范围的查询一次都没得到回答,就不再说“这个值在别的父记录下”,只说找不到记录。
  • 出错会怎样:只有用到这种写法的对象下次保存时会被拒;仓库里的示例应用和打包对象、hotcrm 都没有这种写法;存量数据不改写,开机不拒。整张 PR 可以直接撤回。
  • 要你做的:这是收严(narrowing),走 Tier H,等你审批。

What changes

  • @objectstack/lint, N2: the dependsOn filter key must be filterable. validateObjectFieldRefs (validate-object-field-refs.ts) gains a filtered flag on its field-name slots, set on the REFERENCE half of dependsOn (param, else the bare name or field), the key the record picker's candidate query and the importer's scoped lookup filter the referenced object by. When that name resolves to an authored field of the referenced object that is computed on read (isVirtualSearchField from @objectstack/spec/data, the predicate the engine's filter seam and the import resolver already use), it reports at error, under the existing rule id object-field-ref-unknown, at the entry's path. It runs wherever that rule runs: os validate / lint / compile / build and the runtime publish gate for object writes. Example finding:
    fields.contact.dependsOn[0].param "account_label" is a formula field of "showcase_contact", computed on read: no record-picker query or import lookup can filter on it.
    
    The hint names the fix: point the entry at a stored field of the referenced object that holds the same value, in the { field, param } form, or drop it. A formula on the OWNING side (dependsOn[i].field, the form's gate, read from the record being edited) stays legal. os explain object-field-ref-unknown (rule-explanations.ts) gains one sentence for it; the module note says what is judged and why.
  • @objectstack/core, N4: no unscoped probe when no scoped read answered. The import resolver (import-runner.ts) now marks every scoped lookup none of whose candidate reads answered, and the field guard did not refuse, as RefMatch.scopeUnanswered when the refusals did not name an unfilterable scope field (that case keeps scopeUnqueryable). referenceNotFound (import-coerce.ts) returns the plain reference_not_found refusal for it before the unscoped probe. Before, an all-refused scoped lookup (for example every read refused INVALID_FILTER because the row's master cell is a value the scoping field's type cannot take) was asked again without the scope and could answer reference_out_of_scope, a claim about where the value lives that the import never checked. RefMatch gains the optional member scopeUnanswered.
  • Wording (N4). The validation-message.ts jsdoc on import_reference_scope_unqueryable and the import-mappings.mdx paragraph now say that any other all-refused scoped lookup keeps reference_not_found and the plain sentence and is not tried again without the scope. The docs paragraph also says the formula case is refused at authoring now.
  • Upgrade guide. New ADR-0087 semantic entry lookup-depends-on-param-computed-field-refused (packages/spec/src/migrations/entries/semantic/), notice only: no D2 conversion, since only the author knows which stored field carries the value the formula computes.
  • Changeset .changeset/37717-lookup-depends-on-param-computed-field.md: @objectstack/lint minor (the narrowing), @objectstack/core and @objectstack/spec patch, BREAKING banner, FROM → TO, registered disposition. The pending note .changeset/36794-wizard-reference-out-of-scope.md is left as it is: its sentence "A scoped lookup whose reads are all refused for any other reason (no read access to the target, say) keeps the plain no record matches sentence." was loose on main (review N4) and is exactly true after this change, so it is not rewritten.

Small choices made here (dev's call, per the claim)

  • One rule id, object-field-ref-unknown, not a new one. The roll-up filter position in the same rule already refuses a key computed on read under that id, and the rule already runs at error on every door this needs, so no new registration, explanation entry or door wiring was added.
  • Population: fields computed on read only (SEARCH_VIRTUAL_TYPES, today formula), which is what the card names. A secret / password field, or one flagged internal: true, is also refused as a filter key for a non-system caller, but by a guard that judges the caller, not the field's storage; left out (see Acceptance notes).
  • N4 covers every all-refused scoped lookup, not only INVALID_FILTER: whatever refused every scoped read, the scope was never asked, so a hit without it says nothing about the scope.

Tests

  • packages/lint/src/validate-object-field-refs.test.ts, in the dependsOn describe: a param naming a formula of the referenced object is refused at .param with the field and the reason; a bare name that is a formula on the referenced side is refused at the entry; a stored param, and a formula on the owning side only, pass; the runtime publish gate refuses it too (objects.crm_invoice.fields.contact.dependsOn[0].param). The file's own 200-character cap on every fired verdict still holds.
  • packages/core/src/utils/import-runner-reference-master-scope.test.ts: every scoped read refused INVALID_FILTER while the unscoped read would answer with a record under another project; the cell answers reference_not_found, the plain sentence, no scope, and every read of the target carried the scope (no unscoped probe).
  • Ablations (tree 40007bc2, through scripts/ablation-replace.mjs, each restored to the HEAD blob with git diff HEAD empty):
    • runner: { scopeUnanswered: true } → {}: the N4 pin goes red (reference_out_of_scope received), 1 failed / 19 passed; restored 20 passed.
    • coerce: the scopeUnanswered early return deleted: the same pin red, 1 failed / 19 passed.
    • lint: the filtered branch disabled: 3 failed / 128 passed (the two refusals and the runtime-gate pin); restored 131 passed.

Acceptance notes

  • First-party exposure, measured: objectstack validate passes on all five example apps (app-crm, app-showcase, app-starter, app-todo, app-multi-package) with the new rule built in. Positive control on the same CLI: adding a formula account_label to showcase_contact and pointing showcase_invoice.contact's dependsOn param at it exits 1 with the finding quoted above (both mutations restored). By reading, every other shipped dependsOn is clean: the five in plugin-sharing sit on text / non-picker fields, where the filter half has no reader and is not judged; every one in hotcrm (crm_account, crm_project) names a lookup / master_detail field of its target.
  • Not judged here, for a later card if anyone wants it: a dependsOn filter key naming a secret / password field or an internal: true field. Those are refused as filters for non-system callers by the credential and internal-field guards, a judgment about the caller, not about the field's storage.
  • A stored object that already carries such an entry is not refused at boot. Its import keeps the could-not-look-up sentence from feat(plugin-grid,core): the Import Wizard names the column a lookup cell was scoped by; a scope no read could filter by says so #37706, and its next publish is refused.

Verification

Read first: the filtered branch in validateObjectFieldRefs (validate-object-field-refs.ts), the all-refused branch at the end of the resolver's lookup (import-runner.ts), and the scopeUnanswered return in referenceNotFound (import-coerce.ts).

Two-minute check: pnpm --filter @objectstack/lint exec vitest run src/validate-object-field-refs.test.ts -t "formula" runs 3 tests, all green.

Local readings (tree 40007bc, on main 1e721fd)
  • @objectstack/lint whole package: 242 files / 9801 passed. @objectstack/core whole package: 166 files / 3902 passed.
  • typecheck lint, core and spec: green. eslint --no-inline-config on the eight changed source files: 0 problems.
  • objectstack validate: all five example apps pass; the positive control exits 1 with the new finding.
  • The derived local gate sweep (dispatch-gates.mjs --commands, 119 commands, tree 40007bc): 116 exit 0. Three exit 3, prerequisite not met, NOT measured: check-plugin-teardown-shape --self-test (shallow clone), spec check:skill-examples (client-react not built), check:dual-build-cjs-loads; CI covers these families on this head. check:type-check-debt first queued behind the dogfood hold, then re-run under the lock: exit 0, 0 ledger entries above their number.
  • Dogfood battery on 40007bc under os-verify-lock: VERDICT command-exit 0, Test Files 490 passed / 3 skipped (493), Tests 4144 passed / 68 skipped (4212), no failures.
  • CI on 40007bc: 60 check-runs success, 10 skipped, none failed.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes.
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed.
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.

🤖 Generated with Claude Code

https://claude.ai/code/session_01L6bhgXj9vLmZ3KE2rWhtBH


Generated by Claude Code

…ts target; never probe a scoped lookup unscoped when no scoped read answered

Claude-Session: https://claude.ai/code/session_01L6bhgXj9vLmZ3KE2rWhtBH
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation protocol:system tests labels Nov 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 3 package(s): @objectstack/core, @objectstack/lint, @objectstack/spec, touching 14 documentable anchor(s). ⚠️ 1 changed file(s) yielded no anchor (packages/spec/src/system/validation-message.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

7 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/api/client-sdk.mdx (via /:object/import (route, bridged from symbol runImport — its route source's handler names it))
  • content/docs/api/wire-format.mdx (via /:object/import (route, bridged from symbol runImport — its route source's handler names it))
  • content/docs/data-modeling/currency.mdx (via /:object/import (route, bridged from symbol runImport — its route source's handler names it), /:object/import/jobs (route, bridged from symbol runImport — its route source's handler names it))
  • content/docs/data-modeling/fields.mdx (via /:object/import (route, bridged from symbol runImport — its route source's handler names it))
  • content/docs/data-modeling/import-mappings.mdx (via /:object/import (route, bridged from symbol runImport — its route source's handler names it), /:object/import/jobs (route, bridged from symbol runImport — its route source's handler names it))
  • content/docs/permissions/system-context.mdx (via /:object/import (route, bridged from symbol runImport — its route source's handler names it), /:object/import/jobs (route, bridged from symbol runImport — its route source's handler names it))
  • content/docs/protocol/objectql/state-machine.mdx (via /:object/import (route, bridged from symbol runImport — its route source's handler names it), /:object/import/jobs (route, bridged from symbol runImport — its route source's handler names it))

⛔ 4 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v12.mdx (via /:object/import (route, bridged from symbol runImport — its route source's handler names it))
  • content/docs/releases/v17/17-6.mdx (via runImport (symbol, a top-level function), /:object/import (route, bridged from symbol runImport — its route source's handler names it))
  • content/docs/releases/v18/18-1.mdx (via /:object/import (route, bridged from symbol runImport — its route source's handler names it))
  • content/docs/releases/v18/18-2.mdx (via /:object/import (route, bridged from symbol runImport — its route source's handler names it))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/spec/src/system/validation-message.ts) — pages documenting those are invisible to this run
  • 5 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 184 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 0a3ea67c2c02adbced1c43eda0f252eac3568123 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 8cff535454a2e580ee5f30ca772b96c6e93b104d — the merge of head 40007bc293e47f0e84e2be456b495403899f1c78 into base 0a3ea67c2c02adbced1c43eda0f252eac3568123, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 8cff535454a2e580ee5f30ca772b96c6e93b104d && git checkout 8cff535454a2e580ee5f30ca772b96c6e93b104d
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 0a3ea67c2c02adbced1c43eda0f252eac3568123 40007bc293e47f0e84e2be456b495403899f1c78 && git checkout -B drift-repro 0a3ea67c2c02adbced1c43eda0f252eac3568123 && git merge --no-ff 40007bc293e47f0e84e2be456b495403899f1c78

node scripts/docs-audit/affected-docs.mjs --json 0a3ea67c2c02adbced1c43eda0f252eac3568123

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 0a3ea67c2c02adbced1c43eda0f252eac3568123 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@github-actions github-actions Bot added the tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface label Nov 27, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 40007bc293e47f0e84e2be456b495403899f1c78
Local-runs: none
Scope: packages/core/src/utils/import-coerce.ts, packages/core/src/utils/import-runner.ts, packages/core/src/utils/import-runner-reference-master-scope.test.ts, packages/lint/src/validate-object-field-refs.ts, packages/lint/src/validate-object-field-refs.test.ts, packages/lint/src/rule-explanations.ts, packages/spec/src/migrations/entries/semantic/19.lookup-depends-on-param-computed-field-refused.ts, packages/spec/src/system/validation-message.ts + read in the cited code, not reviewed: packages/objectql/src/filter-comparand-shape.ts (assertFilterIsMaterializable), packages/spec/src/data/search-fields.ts (SEARCH_VIRTUAL_TYPES, isVirtualSearchField), packages/spec/src/data/field.zod.ts (dependsOn), packages/spec/src/data/field-value.zod.ts and packages/spec/src/data/import-coercion.ts (the reference type sets), packages/lint/src/authoring-rules.ts and packages/lint/src/reference-integrity-suite.ts (the runtime door of the rule)

Inputs: card #37717 (body and its four comments: triage 7206273294, claim 7215661638, amendment 7215831279, os-dev-report 7217685430), PR #37910 (body, ten files, net diff against main), and the check-runs on the head: 74 runs, none failed (the rest success or skipped), including Check Changeset, Governed Surface Queue Guard, Spec property liveness, TypeScript Type Check, Lint & Repo Gates, Test Core, Test UI, Build Core, Dogfood Regression Gate.

① Derived judgments

  • Accept-set, authoring (N2): right. object-field-ref-unknown now refuses, at error, a dependsOn filter key (param, else the bare name, else field) on a lookup, master_detail or user field when that name resolves to an AUTHORED field of the referenced object for which isVirtualSearchField is true. That is the predicate the engine's filter seam refuses by (assertFilterIsMaterializable reads the same spec function, and its own note says summary and autonumber are stored and stay filterable), and the predicate the import resolver's scopeUnqueryable verdict comes from (an INVALID_FIELD refusal naming a scope field). So the refused set equals the set the scoped read cannot answer for a storage reason: no stored field is refused, and no computed one is passed where the rule can see the target.
  • No false refusal found. The owning side (dependsOn[i].field) is untouched, so a formula gate on the record being edited stays legal (pinned). The new branch runs only when the name already resolved (!hit), so an unknown name keeps its one existing finding. A bare name that misses on the owner is reported once, there, as before. Fields of non-picker types have no target and are not judged.
  • Accept-set, import (N4): right. The resolver sets scopeUnanswered exactly when a scope was passed, no candidate read answered, and neither the field guard nor a scope-field filter refusal explained it; referenceNotFound returns the plain reference_not_found before the unscoped probe. Every candidate read carries the scope, so asked false means the scope was never asked; a lookup in which any read answered still probes. An unscoped lookup never gets the flag. A legacy resolver that returns a string or sets no flag behaves as before.
  • Public surface: right. One optional exported member, RefMatch.scopeUnanswered; no schema, no wire key, no new rule id, no new message key. The wire change is one code in one case: a cell that could answer reference_out_of_scope after an all-refused scoped lookup now answers reference_not_found.
  • First-party exposure: taken from the head's check-runs (example apps and the dogfood gate green on this head), not re-run.

② Semver level

Clause-②: yes (narrowing) — matches the diff: metadata that publishes on main is refused, and an exported member is added beside it.

Metadata-protocol: narrowed is the right kind (a value refused). @objectstack/lint minor carries the narrowing on the package that refuses; @objectstack/core patch (a fix plus an optional member) and @objectstack/spec patch (the migration entry and a jsdoc line) are right. The changeset has the BREAKING banner, both declaration lines, a FROM → TO with a correct one-line fix in each row, and one ADR-0087 marker, registered lookup-depends-on-param-computed-field-refused, whose entry file is in the diff. Check Changeset is green on the head.

③ Boundary flags

  • open_questions: none in the os-dev-report.
  • Dev flag, out of scope: a filter key naming a credential-typed or internal field is not judged by this lint. Answered: agreed, it is outside the card. The card's population is a field the target cannot be filtered on because it is not stored; those refusals judge the caller, and the import already answers them in its own branch (scopeDenied, or the plain sentence). No carrier is owed by this PR; a follow-up card is the seat's call.
  • Dev choice, one rule id: accepted. The roll-up filter position of the same rule already refuses a computed key under object-field-ref-unknown.
  • Dev choice, N4 covers every all-refused scoped lookup, not only INVALID_FILTER: accepted, and it is what the card asks ("whenever no scoped read answered").
  • SQL push-down: no finding. The diff adds no read, no id materialisation and no in-app join; it removes one read (the unscoped probe) in the all-refused case.

④ Design judgment

The narrowing makes the spec's own refusal real; it takes no declared capability away. FieldSchema.dependsOn on main declares that the entry scopes the picker's candidate query by equality on the referenced object, and the engine refuses every filter on a field computed on read at the one seam every where passes. So an entry whose filter key is a formula of the target never delivered a scoped picker or a scoped import: the form gates the field until the sibling is set, and from then on every candidate query is refused. Nothing that works today stops working; the refusal moves from every query to the publish. The capability the spec declares (scoping by a stored field) is delivered and unchanged, so this is not a capability narrowed at the consumer.

Attempts to break it, all held:

  • A stored field refused: none. The verdict is the type predicate alone, the same one the engine uses, so lint and engine cannot disagree on a field both can see.
  • A formula on the owner refused: no, pinned by test.
  • Two findings for one fix: no. The reported set and the !hit guard keep one finding per name.
  • N4 hiding a real out-of-scope answer: no. When any scoped read answered, the probe still runs; only a lookup that never asked its scope loses it.
  • N4 against the validation-message.ts jsdoc, the changeset and the docs paragraph: the three say what the code does (plain sentence, no second ask, never reference_out_of_scope).
  • The message and hint name the referenced field, its type, the object and the fix, and the prescription is right for both the param form and the bare name.

No must-fix, no should-fix.

  • N1 (nit, prose) — content/docs/data-modeling/import-mappings.mdx says an import meets the could-not-look-up sentence "only on metadata stored before that check". That is wider than the rule. The rule does not see: a target object outside the validated stack on the CLI; a target field changed from stored to formula after the owning object was published (the runtime door judges the object being written, not its referrers); and a reference field of a type outside the picker set (see N2). Soften to "mostly" wording or name the check's reach. Fixable on the prose face.
  • N2 (nit, follow-up) — the importer scopes by dependsOn on every type in IMPORT_REFERENCE_TYPES (which adds tree and the legacy reference), while the rule judges the referenced half only on lookup, master_detail and user. A tree field with such an entry is still found only at import. This is the rule's existing boundary for the whole referenced half (lint: check a lookupFilters { $record } path against the edited object and its hop #34200), and the spec's dependsOn text declares scoping for lookup and master_detail only, so it does not change this PR's contract. Left as an accepted deviation or a follow-up card that settles which side is right.

Implemented-by: claude/project-thread-wv76zu
Reviewed-by: session_01L6bhgV6i8jfWwSXjpWJrjA

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA

席位核对 — ACCEPT · head 40007bc · card #37717 · area s2-data · 2026-11-27T12:06Z

L1 checklist

Tier: H. Landing: hand-off to the maintainer follows this record.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA

Tier H hand-off · 2026-11-27T12:07Z · head 40007bc · approver os-zhuang

维护者速读

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 27, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review November 27, 2026 12:08
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 27, 2026
Merged via the queue into main with commit 709a087 Nov 27, 2026
80 checks passed
@os-zhuang
os-zhuang deleted the claude/project-thread-wv76zu branch November 27, 2026 12:40
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…and the search gates that need no caller, also at publish (objectstack-ai#37971)

repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP
Fixes objectstack-ai#37307

Clause-②: yes (narrowing)
Metadata-protocol: narrowed
Skills-docs: objectstack-ai#37310 (amendment 7221575164: the five rule ids and their
fixes)

Premise corrected: card objectstack-ai#37307 item 3 ("follow the refuse-or-warn
verdict the `ai_context` row took") conflicts with ADR-0161 K4; K4 wins,
so this rule is `gating` at publish (refuses), not advisory. Seat 1
ruling on this PR: keep gating (seat record: objectstack-ai#37307 comment 7221816104).
Ruling-ref:
`docs/adr/0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md`
K4 — "It defines no object, extends none, and is refused when the object
or a named field does not exist (the lint and `os validate` checks are
row 4)." and "An object whose package is disabled, that the API exposure
refuses for search, or that is a system object without
`enable.aiReadable`, and a field the author may not query, each refuse
the save with a coded refusal that names the object or the field. A
packaged item meets the gates that need no principal in `os validate`
and at publish (row 4)."

## 维护者速读
- 用户能看到什么变化:写应用包的作者和用 AI 搭建的作者,在 `os validate`
和发布知识源时,就能看到知识源写错的对象名、字段名,或指向不允许检索的对象(API 不开放检索、系统对象未开放 AI
读取),报错写明是哪个对象、哪个字段。
- 为什么做:属于「知识平台」专题第三阶段第 4 行,让知识源的错误在发布前暴露,而不是等到检索时才发现「怎么搜不到」。
-
出错会怎样:带这几类错误的知识源,发布会被拒(以前能发布,但对象不存在时无内容可索引、字段写错时该字段读不到、对象不开放检索时永远搜不到);已存储的知识源不受影响,可以直接撤回本改动。
- 要你做什么:无。

## What changes

ADR-0161 K4, row 4: a knowledge source is checked against the objects it
names, by `os validate` / `build` / `lint` and by the runtime publish
gate, with one set of rule ids and messages.

- **`packages/lint/src/validate-knowledge-source.ts`** (new):
`validateKnowledgeSource`, five rule ids, exported from
`packages/lint/src/index.ts`.
- `knowledge-source-object-unknown` — **error**. `source.object` names
no object of the stack, of a package of its artifact (`packages[]`), or
at the door of the objects the host serves. Under a stated package
closure it is worded for the closure with `closureDependencyRemedy`; at
the door with no closure (the whole collection the host serves) it is an
error too, and an empty served collection is no universe. On the CLI,
while the manifest declares a dependency the artifact does not carry, it
is a **warning** with the hedge (the build cannot see that package's
objects; the publish judges the source against the closure, which holds
them), the `flow-trigger-unknown-object` split. The ladder
`validateObjectReferences` uses: a known platform object
(`isPlatformProvidedObjectName`) is not judged when the stack does not
carry its definition; a platform-prefixed name no known package
registers is a **warning**.
- `knowledge-source-field-unknown` — **error**. A `source.content` /
`source.metadataFields` member names no field of the object: declared
(the stack's own extensions folded in, `objectsAsServed`) or addressable
without a declaration (`injectedColumnsFor`: `id`, which the driver
provisions, and the injected system columns).
- `knowledge-source-object-not-searchable` — **error**.
`canServeApiOperation(enable, 'search')` is false (the admission
module's gate 2): `enable.apiEnabled: false`, an `enable.apiMethods`
list that does not grant `list` (search derives from it; `search` itself
is a retired list value the parse strips), or one that grants `list`
beside `enable.searchable: false`. With no `apiMethods` list,
`searchable: false` does not refuse it. The fix prescribed: keep
`apiEnabled` true and, where the object declares `apiMethods`, include
`list` with `searchable` not false; or index another object.
- `knowledge-source-system-object-not-ai-readable` — **error**. A `sys_`
object for which `isAiReadExposed` is false (the admission module's gate
3).
- `knowledge-source-field-never-indexed` — **warning**. A member names a
credential-class field (`isMaskedOnReadFieldType`, the spec declaration
the service's withheld set asks) or an `internal: true` field. The index
never carries either (K5). This addition goes past the Execution row,
under ADR-0078.
- **`authoring-rules.ts`**: one entry, `tier: 'gating'`, all three
commands, `surfaces: CLI_AND_RUNTIME`, `runtimeTypes:
['knowledge_source']`, with the package scope passed through, and
`wholeCollection` set at the door when no scope is stated.
- **`runtime-gate.ts`**: `knowledge_source: 'knowledgeSources'`.
- **`rule-explanations.ts`**: one `os explain` entry for each of the
five ids.
-
**`packages/spec/src/migrations/entries/semantic/19.knowledge-source-publish-refuses-missing-references-and-gated-objects.ts`**:
the upgrade-guide entry. `check:adr-0087-registration` requires it:
`Metadata-protocol: narrowed` refuses `no-migration-prescription`
outright. This file is outside the claim's declared file surface.
- **Changeset** `.changeset/37307-knowledge-source-references.md`:
`@objectstack/lint` minor, `@objectstack/spec` patch, BREAKING,
registered disposition.

### The at-publish verdict: refuse, not advise, against the `ai_context`
precedent

The `ai_context` row (`validateAiContext`) is advisory at publish. Its
reason is that a pack still reads what resolves (ADR-0160 D1). This row
departs from it, for three reasons. ADR-0161 K4 says an item "is refused
when the object or a named field does not exist (the lint and `os
validate` checks are row 4)". It also says that "a packaged item meets
the gates that need no principal in `os validate` and at publish". And
each of the four errors defeats retrieval (a missing object leaves
nothing to index, a missing field indexes no text for that member, a
gated object is never searched for a caller the service judges), so the
card's severity section (all four are errors) has the same reading. The
rule is therefore `gating`: its errors refuse the publish (422 with the
rule id, path, message and hint), and its warnings ride the 2xx
`advisories`. The card's sentence "follow the refuse-or-warn verdict the
`ai_context` row took" and its severity section cannot both hold. The
ADR text decides between them, and the departure is stated in the rule
header, the registry entry and the runtime-gate row.

What this narrows at publish, measured on the code paths:
- For a non-system author with the knowledge service mounted, the save
door already refuses the two gates `403`
(`authoredKnowledgeSourceRefusal`), before this gate runs. Where no
author judgement is reached, the publish is now refused `422`: a host
with no knowledge service, or a system-context write.
- A missing object or a missing field is now refused at publish. The
save admission accepted a missing object
(`canServeApiOperation(undefined)` is true, and with no security service
the field gate is masked-only).
- `os validate` / `build` / `lint` exit 1 on the same source.

Declarations: the claim expected `Clause-②: no` / `Metadata-protocol:
none`. The measured reading is `Clause-②: yes (narrowing)`, because five
new exports widen `@objectstack/lint`'s public surface and a new refusal
narrows the accept set, and `Metadata-protocol: narrowed`, because a
requirement is tightened. So the lint bump is `minor` and the title
carries `!`.

## Tests

`packages/lint/src/validate-knowledge-source.test.ts` (44 cases):
- every Acceptance family through `runAuthoringRules('validate')`: a
missing object, content field or metadata field; `apiEnabled: false`; an
`apiMethods` list that does not grant search; `searchable: false`; a
`sys_` object without `aiReadable`. Each prints exactly one finding,
with its rule id, severity, path, and the object or field named. A clean
source prints none.
- the credential-class and `internal` warnings.
- the same families at the door (`runRuntimeAuthoringRules` with `type:
'knowledge_source'`). Errors land in `errors` (refused) and warnings in
`advisories`, and the face (rule, severity, where, message, hint) equals
the `os validate` face.
- closure wording and remedy under `packageScope`, with a non-vacuous
control: declaring the dependency clears it.
- injected columns, stack extensions, artifact `packages[]`, a known
platform object skipped, an unknown platform-prefixed name as a warning,
`list` granting `search`.
- `metadataFields: ['id']` and `content: ['id']` resolve (CLI and door);
`enable.searchable: false` with no `apiMethods` list is clean.
- the object-unknown split: on the CLI a warning while the manifest
declares a dependency `packages[]` does not carry, an error when every
declared dependency is carried or none is declared; against the whole
collection an error beside the same unseen dependency; an empty served
collection at the door judges no object.
- `explainRule` answers all five ids.

<details><summary>Readings (lint suite at 73441db; the head
3ea6b3c adds only the four docs transcript counts)</summary>

- `pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2` (with
spec and lint rebuilt, then lint `typecheck`): lock VERDICT command-exit
0, **Test Files 243 passed (243), Tests 9836 passed (9836)**; typecheck
exit 0 (`check:test-typecheck` included; `tsc -p tsconfig.test.json
--listFiles` lists the new test file, 1 hit).
- `pnpm --filter @objectstack/spec exec vitest run src/migrations` after
the spec build: 5 files, 206 tests passed.
- Ablation, one per new pin, each with the anchor proven on disk by
`scripts/ablation-replace.mjs`, a trap restore, and `git diff HEAD`
empty after restore. Every leg went red: the runtime-gate row removed
(12 red); the object-unknown error made a warning (3); the API gate off
(6); the system-object gate off (2); the withheld warning off (4); the
injected-column merge off (1); the artifact `packages[]` resolution off
(1); the closure branch off (1); the platform-object skip off (1); the
stack extensions not folded (1).
- Public door: `objectstack validate` in `examples/app-showcase` exits 0
with zero `knowledge-source-*` findings, so the shipped corpus is clean.
The same command with `content` mutated to `['title', 'notez',
'secret_note']` exits 1 with two `knowledge-source-field-unknown`
findings at `knowledgeSources[0].source.content[1]` and `[2]`, and the
file is restored. `objectstack explain knowledge-source-object-unknown`
and `objectstack explain knowledge-source-system-object-not-ai-readable`
both answer.
- Full dogfood battery (`pnpm --filter @objectstack/dogfood test`, lock
VERDICT command-exit 1, head 73441db): Test Files 14 failed / 476
passed / 3 skipped (493); Tests 20 failed / 4113 passed / 79 skipped
(4212). The failures were 17 `Test timed out in 5000ms`, 2 hook
timeouts, the cascading `already has a live bootStack kernel` errors,
and 1 assertion inside a timed-out file. None names a
`knowledge-source-*` rule. The 14 failed files re-run alone on the same
head: **14 passed (14), 164 passed (164)**, VERDICT command-exit 0. Read
as shared-box contention, not this diff.

</details>

<details><summary>Rework readings (review 7221784031: M1, S1, S2, N1,
N2; head 8301509)</summary>

- At 15b32e6, under the lock (VERDICT command-exit 0): `turbo run
build --filter='@objectstack/lint...'` 5/5 tasks; the lint suite **Test
Files 244 passed (244), Tests 9856 passed (9856)**; spec
`src/migrations` 5 files, 206 tests passed;
`check:docs-transcript-drift` exit 0 against the built registry (4
declared values, 87).
- At 2677e83 (only the test file changed after 15b32e6), a
declared narrowing run outside the lock after three lock queue-timeouts
behind another seat's dogfood battery: the knowledge-source file 44
passed (44); `pnpm --filter @objectstack/lint typecheck` exit 0
(`check:test-typecheck` included).
- Ablations, each anchor proven by `scripts/ablation-replace.mjs` with a
trap restore and `git diff HEAD` empty after: the `injectedColumnsFor`
existence check off (2 red, `id` among them); the CLI dependency hedge
off (2 red); the whole-collection reading off in the rule (1 red); the
registry's `wholeCollection` pass set false (1 red); the empty-universe
skip off (2 red).
- After merging origin/main (bfc0dd0, no lint or transcript file
touched): `check:docs-transcript-drift` exit 0 (87; objectstack-ai#37986 still open),
`check-adr-0087-registration` exit 0, `check:nul-bytes` exit 0,
`overlap-check` VERDICT clean.

</details>

<details><summary>Derived gates (dispatch-gates --commands, then
--ran)</summary>

- 94 families derived at 73441db, all run locally. 90 exited 0. Of
the rest: `check:docs-transcript-drift` was red (four CLI transcripts
printed 85 author-time rules, and this rule makes 86); the four counts
were fixed in 3ea6b3c, and the gate now exits 0 (4 declared values
equal the derived count). `check:exported-any` returned exit 3 while the
dogfood build was rebuilding `packages/spec/dist`; re-run after that
build, it exits 0. `check:dual-build-cjs-loads` returned exit 3 because
the `studio`, `client-react` and `scenarios` dist are not built here:
NOT MEASURED, CI. `check:type-check-debt` returned exit 3 on a lock
queue-timeout (another seat's hold): NOT MEASURED, CI.
- The docs commit derived 23 more families. 22 exit 0.
`check:skill-examples` returned exit 3 because the `client-react` dist
is not built: NOT MEASURED, CI.
- `check:api-surface` and `check:docs` exit 0 after the spec rebuild.
`overlap-check` VERDICT clean before every push; objectstack-ai#37910 and objectstack-ai#37870 merge
cleanly. objectstack-ai#37870 bumps the same four transcript counts, so whichever
lands second needs 87.

</details>

## Acceptance notes

- The search gate follows the exposure derivation: `apiMethods: ['get',
'list']` **grants** `search` (`list` grants it unless
`enable.searchable` is false). The save-door refusal text in
`service-knowledge` (`admitAuthoredSource`, `object-api-not-served`)
reads "its `enable.apiMethods` list does not include `search`". For
`searchable: false` with `list` granted, that wording names the wrong
cause. Wording only; the PM files it as a card with the S2 wording.
- On the CLI, a platform object the stack does not carry (for example
`sys_user`) is not judged, because its declaration is not in hand. The
publish door judges it against the live definition.
- Fences held: the spec predicates and the admission module are
unchanged, there is no adapter work for objectstack-ai#37306, and there is no
unknown-adapter refusal for objectstack-ai#37479.

## Verification

Read first, by risk:
1. `packages/lint/src/authoring-rules.ts`, the `validateKnowledgeSource`
entry (`tier: 'gating'` on the publish door is the narrowing).
2. `packages/lint/src/validate-knowledge-source.ts`, the object ladder
and the two gates.
3. `.changeset/37307-knowledge-source-references.md`.

Two-minute check: in
`examples/app-showcase/src/ai/task-notes.knowledge-source.ts`, change
`content: ['title', 'notes']` to `['title', 'notez']` and run `pnpm exec
objectstack validate` in `examples/app-showcase`. Expected: exit 1 and
`rule: knowledge-source-field-unknown at
knowledgeSources[0].source.content[1]`. Unchanged, the showcase
validates with zero `knowledge-source-*` findings.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue protocol:system size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

3 participants