Skip to content

fix(lint): os validate and the publish gate refuse a knowledge source whose documentBy is not a single-valued parent link - #38662

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-l8mlq4
Nov 30, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-l8mlq4

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Warren · project thread

Fixes #38537

Clause-②: no
Metadata-protocol: none

Lands after #38594 (merged 2026-11-30T01:10Z; main merged into this branch at d1e1ba3f03). Both PRs are seat 2's. The overlap is two files (packages/lint/src/index.ts, packages/lint/src/rule-explanations.ts), in hunks far apart; overlap-check reads both clean against each other and main.

维护者速读

  • 用户能看到什么变化:知识源的“文档单位”(documentBy)如果填的不是指向父记录的单值查找字段,os validate / os build / os lint 和发布时都会报错并说明怎么改。之前只有在 Studio / 元数据 API 保存时才会拒绝。
  • 为什么做:随包发布或代码注册的知识源不经过保存这道门,填错了没人拦,检索按父记录聚合会悄悄失效。这是 service-knowledge: a knowledge source declares its document unit (source.documentBy); record search groups by it by default #38537 的第二个也是最后一个 PR。
  • 出错会怎样:只影响声明了 documentBy 的知识源;规则误判会让正确的知识源发布失败,删掉 documentBy 即可绕开。
  • 要你做什么:无。

What changes

  • New rule knowledge-source-document-by-not-parent-link (error) in validate-knowledge-source.ts. It refuses a source.documentBy that metadataFields lists and that is not a single-valued parent link of the indexed object. The checks run in the save door's order: declared by the object, neither credential-class nor internal, a lookup / master_detail type, a target referenceTargetOf can read, and not multiple: true. Each reason gets its own message, worded like the save door's documentUnitRefusalText, naming the field and the fix. Path: knowledgeSources[i].source.documentBy.
  • Where it runs. The rule rides the existing validateKnowledgeSource registry entry, so it reaches os validate / build / lint and the runtime publish gate (knowledge_source writes) with no new wiring. This is what judges a source a package ships or code registers; until now only the metadata API's save door did (feat(knowledge): a knowledge source declares its document unit (source.documentBy); record search groups by it by default #38564).
  • Not judged twice. A documentBy that metadataFields does not list is left to the parse, which already names that fix. A member the object does not have is reported once, as knowledge-source-field-unknown. An object with no readable field map is not judged.
  • Published and explained. The rule id is re-exported from the root barrel (index.ts, one line in the knowledge block). rule-explanations.ts gets its os explain entry and table row beside the five sibling rules.
  • Census pin (packages/core/src/security/second-object-read-exposure.pin.test.ts): the new referenceTargetOf import makes validate-knowledge-source.ts a caller of the reference-target arbiter, so it is classified not-a-served-read beside the other lint callers. It only asks whether a target is declared, and reads and serves nothing of the target. Admitted by the seat for this fix after CI's Test Core (8/12) flagged the unclassified caller. Locally: 1 failed / 3 passed before the entry, 4/4 after.
  • Changeset patch for @objectstack/lint.

Route chosen for the parent-link rule (#38564's PR 2 question)

#38564 left PR 2 two ways to reach parentLinkRule / documentUnitOf (service-knowledge's knowledge-search-scope.ts). The seat accepted a third:

  • A: lint imports @objectstack/service-knowledge. Not taken. @objectstack/lint's package description says it "Depends on @objectstack/spec; never on a runtime", and service-knowledge is a runtime service. It would also need a new line on service-knowledge's exports surface.
  • B: move the rule to "a package lint already reads, for example @objectstack/core". Not taken. Lint does not depend on @objectstack/core; its workspace dependencies are formula, metadata-core, sdui-parser and spec. Moving it to spec would put runtime-shaped logic into the protocol package and widen this PR well past its card.
  • C (taken): compose the verdict in lint from the spec predicates parentLinkRule itself asks. Withheld = isMaskedOnReadFieldType(type, managedBy) or internal === true. That is the reading this file already takes for knowledge-source-field-never-indexed, and the one collectCredentialWriteResponseFields / collectInternalWriteResponseFields compute in core. Target = referenceTargetOf (@objectstack/spec/data). The type pair lookup / master_detail is spelled locally, as eight other lint rule files already spell it. Cost: the four-part rule now lives in two places. No test pins their agreement, because no package that depends on both can import documentUnitOf without one more barrel line in service-knowledge. The module header names the save door's function so a change to one points at the other.

Why

ADR-0161 K4: "a packaged item meets the gates that need no principal in os validate and at publish". documentBy is such a gate: it reads only the object definition. #38564 left it judged at save only, and its body says "PR 2's os validate rule covers packaged sources."

Clause-② and Metadata-protocol, measured from the diff

Clause-②: no / Metadata-protocol: none, a judgement call stated here for review. The rule refuses values of source.documentBy, a key #38564 added in this same prerelease line. Its changeset .changeset/38537-knowledge-document-by.md is still pending (not moved to .changeset/pre/), so no published version carries the key and nothing an author could write against a release is refused. The metadata API's save door already refuses the same values. Read against main instead, a packaged source with a non-parent-link documentBy passed os validate before this PR and fails it after. If review prefers that reading, the lines become Clause-②: no (narrowing) / Metadata-protocol: narrowed (level minor and an ADR-0087 disposition).

Verification

Acceptance (the card's os validate half)

Card line Test (validate-knowledge-source.document-by.test.ts)
Refuse a text field, a user field, an internal lookup and a multiple lookup, each naming the fix "refuses a text field / a user field / an internal lookup / a multiple lookup as the document unit, naming the field and the fix"
(the save door's other reasons) "… a credential-class field", "… a lookup with no readable target", "… a system column the platform adds"
Positive controls "CONTROL: a lookup and a master_detail to the parent are admitted", "CONTROL: a source without documentBy is judged as before"
Same verdict at publish "refuses the publish with the words os validate prints", "CONTROL: a single-valued parent link publishes with nothing to report"
Published id + os explain "the root barrel re-exports it", "os explain answers it"

Ablation (scripts/ablation-replace.mjs, each mutation verified on disk, each restore verified blob == HEAD d9f63681062f with an empty git diff HEAD)

Call site disabled (const refusal = documentUnitRefusal(…) → undefined): 9 red

validate-knowledge-source.document-by.test.ts: 9 failed / 8 passed. All seven refusal tests, "a fields array is read like a field map", and "refuses the publish with the words os validate prints". The controls stay green.

multiple arm deleted: 1 red

1 failed / 16 passed: "refuses a multiple lookup as the document unit…".

internal half of the withheld arm removed: 1 red

1 failed / 16 passed: "refuses an internal lookup as the document unit…". (A first attempt was refused by the tool before running anything, because its replacement text already occurred in the file; it was re-run with a distinct replacement.)

Package suite and typecheck

Derived gate families (dispatch-gates.mjs --commands, 70)

  • First pass, captured per the tool's idiom: --ran reports "70 derived famil(ies) accounted for — 66 run, 4 NOT-MEASURED (4 DERIVED from a recorded exit 3)". All 66 that ran exited 0, including check-changeset-no-major --base origin/main, check-adr-0087-registration --base origin/main, check:doc-authoring, check:issue-citations and check:cross-package-test-inputs.
  • The four exit-3 families each had a prerequisite missing. Three were re-run after fixing it, each exit 0: check-plugin-teardown-shape --self-test (needed git fetch --unshallow), check:docs-transcript-drift (needed the built lint) and check:lean-entry-closure (needed the built objectql). These re-runs were by hand, outside the --ran record.
  • check:dual-build-cjs-loads was not measured locally: it reads every package's dist/, which needs a full build. CI's Build Core job runs it on this PR.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic. (spec untouched)
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes (eslint on the changed files).
  • 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: n/a.
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English (the 维护者速读 block is the maintainer's Chinese brief).
  • The Before Submitting list in CONTRIBUTING.md is done.

Read first

  1. packages/lint/src/validate-knowledge-source.ts: documentUnitRefusal and the call site after judgeMembers('metadataFields').
  2. packages/services/service-knowledge/src/knowledge-search-scope.ts: parentLinkRule / documentUnitOf, the save door's rule this one restates.

Two-minute check: pnpm --filter @objectstack/lint exec vitest run src/validate-knowledge-source.document-by.test.ts. Expect 17 passed.

Dogfood: n/a (no ! in the title, no (narrowing) arm).

🤖 Generated with Claude Code

https://claude.ai/code/session_01JQwxbWsSJprjGydwaCH1gD

@github-actions github-actions Bot added documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 30, 2026
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

9 anchor(s) derived from 1 changed package(s); no hand-written page names any of them. ⚠️ 1 changed file(s) yielded no anchor (packages/lint/src/index.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/lint/src/index.ts) — pages documenting those are invisible to this run
  • 1 anchor(s) matched too much of the corpus to be a work list: master_detail (literal, 49 pages)
  • 3 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 — 4 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 74a15cb73b878aa8095aab8472b8ca6f776ccb61 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 089dd061372012b4b8c519ab225f9026ba3691d1 — the merge of head a082c9c5cf8713f24edfa9045554d6d4fa690656 into base 74a15cb73b878aa8095aab8472b8ca6f776ccb61, 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 089dd061372012b4b8c519ab225f9026ba3691d1 && git checkout 089dd061372012b4b8c519ab225f9026ba3691d1
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 74a15cb73b878aa8095aab8472b8ca6f776ccb61 a082c9c5cf8713f24edfa9045554d6d4fa690656 && git checkout -B drift-repro 74a15cb73b878aa8095aab8472b8ca6f776ccb61 && git merge --no-ff a082c9c5cf8713f24edfa9045554d6d4fa690656

node scripts/docs-audit/affected-docs.mjs --json 74a15cb73b878aa8095aab8472b8ca6f776ccb61

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

…rving reference-target caller

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbWsSJprjGydwaCH1gD
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu

2026-11-30T02:11Z · L1 ACCEPT at a082c9c5cf (#38537 PR 2).

  • Face: lint only, no contract face (check-owed-reviews lists none); Clause-②: no / Metadata-protocol: none / @objectstack/lint patch accepted: source.documentBy is unreleased (PR 1's changeset .changeset/38537-knowledge-document-by.md is still pending on main), so the new error narrows no released accept set.
  • Rule matches the save door's documentUnitOf order (declared, not withheld, parent-link type, readable target, single-valued), composed from spec predicates; the message names the fix at each reason.
  • Checks at this head: 60 success, 13 expected skip, 0 failed; the one cancelled PR-body guards run (141576903670) was superseded by its re-run 141577076552, success, on the same head.
  • Census pin: second-object-read-exposure.pin.test.ts classifies the new referenceTargetOf caller as not a served read (red then green, reported); surface widened by that one test file on the seat's word.
  • Serial: lands after fix(lint)!: the publish gate refuses a subflow or map step that calls a flow the deployment does not hold #38594 (merged 01:10Z); main merged at d1e1ba3f03.
  • Changeset read sentence by sentence against the diff: true.
  • Landing: Tier S (not governed). Held as a draft under the release freeze; the seat readies and enqueues it when the freeze lifts. Fixes #38537 closes the card on merge.
  • Follow-up carried by Studio form, docs and skill text for knowledge source documentBy #38538's dispatch: list knowledge-source-document-by-not-parent-link in skills/objectstack-ai/SKILL.md's knowledge-source rule list.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu

维护者速读

  • 用户能看到什么变化:知识源的"文档单位"字段填错类型(不是指向父记录的单值关联)时,os validate、构建和发布都会报错并说明怎么改;以前只有在 Studio 保存时才拦。
  • 风险:只加一条 lint 规则;该字段尚未发布,不影响已有项目。
  • 要你做什么:无;发布冻结解除后席位入队。

席位核对

ACCEPT · L1 · area o2-A · Head-sha a082c9c5cf8713f24edfa9045554d6d4fa690656 · 2026-11-30T02:15Z

  • Face: lint only, no contract face (check-owed-reviews lists none); Clause-②: no / Metadata-protocol: none / @objectstack/lint patch accepted: source.documentBy is unreleased (PR 1's changeset .changeset/38537-knowledge-document-by.md is still pending on main), so the new error narrows no released accept set.
  • Rule matches the save door's documentUnitOf order (declared, not withheld, parent-link type, readable target, single-valued), composed from spec predicates; the message names the fix at each reason.
  • Checks at this head: 60 success, 13 expected skip, 0 failed; the one cancelled PR-body guards run (141576903670) was superseded by its re-run 141577076552, success, on the same head.
  • Census pin: second-object-read-exposure.pin.test.ts classifies the new referenceTargetOf caller as not a served read (red then green, reported); surface widened by that one test file on the seat's word.
  • Serial: lands after fix(lint)!: the publish gate refuses a subflow or map step that calls a flow the deployment does not hold #38594 (merged 01:10Z); main merged at d1e1ba3f03.
  • Changeset read sentence by sentence against the diff: true.
  • Landing: Tier S (not governed). Held as a draft under the release freeze; the seat readies and enqueues it when the freeze lifts. Fixes #38537 closes the card on merge.
  • Follow-up carried by Studio form, docs and skill text for knowledge source documentBy #38538's dispatch: list knowledge-source-document-by-not-parent-link in skills/objectstack-ai/SKILL.md's knowledge-source rule list.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu

2026-11-30T07:08Z · Landing · seat ACCEPT 7266792463 at a082c9c5cf stands (head unchanged). All checks green, mergeable_state clean against main.

  • The release freeze does not apply: Warren (os-warren) answered in os-warren's fleet project timeline at 2026-11-30T07:08Z 「目前已经开发中的不用冻结」, which exempts work already in development.
  • Tier S (not governed): ready for review and auto-merge in this stroke. The queue re-runs every check on the merged tree.
  • Fixes #38537 closes the card on merge.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 30, 2026 07:09
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 30, 2026
Merged via the queue into main with commit c02f972 Nov 30, 2026
74 of 75 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-l8mlq4 branch November 30, 2026 07:36
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 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

Development

Successfully merging this pull request may close these issues.

service-knowledge: a knowledge source declares its document unit (source.documentBy); record search groups by it by default

2 participants