Skip to content

fix(service-knowledge): the knowledge-source save door names an absent object or field as such - #38465

Queued
objectstack-fleet[bot] wants to merge 4 commits into
mainfrom
claude/issue-38419-knowledge-source-absent-ref
Queued

objectstack-fleet[bot] wants to merge 4 commits into
mainfrom
claude/issue-38419-knowledge-source-absent-ref

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #38419

Clause-②: no
Metadata-protocol: none

维护者速读

  • 在 Studio 或 MCP 保存知识源的搭建者:以前填错对象名或字段名时,会看到"暂时无法判断、请重试"或"无权访问"的提示,现在会直接看到"该对象/字段不存在",并带上与 os validate 相同的规则名。
  • 属于知识库检索(把业务数据建成可搜索的知识源)这条线,替搭建者解决"拼错了却被告知去重试或去找管理员"的误导。
  • 出错时只影响保存知识源这一个入口的提示文字与状态码;对存在但无权访问的对象和字段,拒绝提示一字未变,可以直接撤回。
  • 无。

What changes

KnowledgeService.admitAuthoredSource (the save-time admission every knowledge-source save door asks: PUT /meta/knowledge_source/:name, the runtime /meta door, the MCP draft save, and the package duplicate) gains a "does not exist" arm ahead of every permission arm (ADR-0161 K4, row 4):

  • source.object names no object the registry defines ⇒ 400 VALIDATION_ERROR, naming the object and the rule knowledge-source-object-unknown.
  • a source.content / source.contentFields / source.metadataFields member names neither a declared field nor id or a system column the registry injects (resolveInjectedSystemColumns, the derivation os validate uses) ⇒ 400 VALIDATION_ERROR, naming the object, the field (field on the verdict) and the rule knowledge-source-field-unknown.

Before this PR, with a platform-like security service, the same saves answered 503 SERVICE_UNAVAILABLE "... could not be judged ... try again" (absent object), 403 "is a system object that does not opt into AI reads" (absent sys_ object), and 403 "you may not query field ... hidden from you" (absent field). With no security service they were admitted.

The arm reads the object's registered definition only. It never reads a permission answer. Every door that asks this verdict admits only a manage_metadata holder, and ADR-0106 D4 serves that caller every object definition whole. So the arm tells the author nothing they could not already read. It draws no verdict for an engine with no schema registry, for an object of a disabled package (that gate still answers it), or for an object whose fields cannot be enumerated. A registry that throws keeps the 503, reported once. No new error code: VALIDATION_ERROR is the code this method already answers for an unmounted adapter.

The refusal is worded for the door, as the other arms are: the duplicate's caller is told the source cannot be copied, then to duplicate the package again.

Read first

  1. packages/services/service-knowledge/src/knowledge-service.ts, absentSourceReference: the riskiest hunk is the three early returns (no getSchema, disabled package, no field map). Each one keeps a case that exists from being read as absent.
  2. packages/services/service-knowledge/src/knowledge-service.ts, admitAuthoredSource, the new block after the engine check: its position decides which arm wins.
  3. packages/services/service-knowledge/src/__tests__/knowledge-source-save-absent-reference.test.ts, the no permission answer changes for an object or a field that exists block, which holds the full answers taken on the base.

Two-minute verification

pnpm --filter @objectstack/service-knowledge exec vitest run --maxWorkers=2 src/__tests__/knowledge-source-save-absent-reference.test.ts. Expect 15 passed. Restore knowledge-service.ts from 0c1b2ffe and the same command shows 7 failed and 8 passed: the absent references answer 503 / 403, and every pin for what exists still passes.

Tests

New file: knowledge-source-save-absent-reference.test.ts (15 cases)
  • Absent business object and absent sys_ object, with and without a security service: VALIDATION_ERROR / 400, object set, no field, message carries knowledge-source-object-unknown, never "could not be judged", "try again", "does not opt into AI reads" or "may not query". The engine's own write (isSystem) is admitted.
  • Absent content, metadataFields and retired contentFields member, for a member and a manager, with and without a security service: VALIDATION_ERROR / 400, object + field, message carries knowledge-source-field-unknown.
  • An absent field is named before a hidden one in the same source.
  • CONTROL: id, created_at, owner_id (not declared, injected) are admitted.
  • door: duplicate: same status, code, object and field as the save, worded for the duplicate.
  • Exists, answer unchanged, full verdict with toEqual, sentences taken from the base: hidden field (403), sys_ object without enable.aiReadable (403), security service that answers neither question (503), disabled package with and without a served definition (403), registry that throws (503, logged once), engine with no schema registry (admitted).
Red on the base, green on the head

Base knowledge-service.ts (0c1b2ffe), head test file:

Tests  7 failed | 8 passed (15)
AssertionError: expected { admitted: false, status: 503, ... } to match object { admitted: false, ... }   (absent object)
AssertionError: expected { admitted: false, status: 403, ... } to match object { admitted: false, ... }   (absent sys_ object)
AssertionError: u_member undefined: expected { admitted: false, status: 403, ... }                       (absent field)
os-verify-lock: VERDICT command-exit 1

Head cf125c96, after pnpm turbo run build --filter='@objectstack/service-knowledge...' --concurrency=2 (20/20):

pnpm --filter @objectstack/service-knowledge test
 Test Files  22 passed (22)
      Tests  741 passed (741)
pnpm --filter @objectstack/service-knowledge typecheck
check:test-typecheck: OK — 0 file(s) / 0 error(s)
os-verify-lock: VERDICT command-exit 0

Acceptance notes

  • The fields a where reads are not checked for existence here. os validate does not check them either (validate-knowledge-source.ts checks content and metadataFields only), so no rule name exists for them. Measured on cf125c96: a where naming an absent field answers 403 PERMISSION_DENIED "which you may not query (it is hidden from you ...)" when a security service is mounted, and is admitted when none is. Reported to the seat to file; not changed here.
  • The published objectstack-ai skill says os validate and publish check the two rules. That is still true. It does not mention the save door, and this PR leaves skills/** untouched.
  • Search-time admission (admitSources) is untouched by this PR. Only the save-time verdict changes.

Verification

Local derived gates at cf125c9 (dispatch-gates --commands, 71 commands)

Each derived command ran on head cf125c96 (after merging origin/main at 1afd9c13), exit captured before any pipe:

dispatch-gates --ran: 71 derived famil(ies) accounted for, 70 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3)
NOT MEASURED: node scripts/check-plugin-teardown-shape.mjs --self-test, reason: PREREQUISITE NOT MET, its positive control is pinned to a commit this shallow clone cannot reach (checker health only; CI runs it)
pnpm check:dual-build-cjs-loads: 126 published require entry point(s) across 74 package(s) load; 2593 emitted CommonJS file(s) parse

The other 69 commands exit 0, among them check:nul-bytes, check:doc-authoring, check:issue-citations, check:published-files, check:type-check-coverage, check:type-check-debt, check:undeclared-dep-imports, check:engine-double-contract, check:error-status-conformance, check:adr-0087-registration --base origin/main and check:empty-changeset --base origin/main. Every family CI runs beyond these is read from this PR's check-runs, not re-run locally.


Generated by Claude Code

…wledge-source reference

Claude-Session: https://claude.ai/code/session_016WV4d13AraSmVmgVtCvkWk
Co-authored-by: Claude <noreply@anthropic.com>
…t object or field as such

A knowledge_source naming no object, or a content / metadataFields member
naming no field of its object, is refused 400 VALIDATION_ERROR with the
os validate rule names, ahead of every permission arm, decided from the
object's registered definition alone.

Claude-Session: https://claude.ai/code/session_016WV4d13AraSmVmgVtCvkWk
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m 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 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/service-knowledge, touching 8 documentable anchor(s).

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

  • content/docs/ai/knowledge-rag.mdx (via KnowledgeService (symbol, a top-level class), metadataFields (literal, a string literal in AbsentSourceReference; a string literal in absentSourceReference))
  • content/docs/permissions/system-context.mdx (via admitAuthoredSource (symbol, a method of class KnowledgeService))
  • content/docs/protocol/knowledge.mdx (via KnowledgeService (symbol, a top-level class), metadataFields (literal, a string literal in AbsentSourceReference; a string literal in absentSourceReference))
What this run could not see
  • 1 anchor(s) matched too much of the corpus to be a work list: VALIDATION_ERROR (literal, 40 pages)
  • the SDK route bridge reached 69 of 253 client-bound route-ledger rows — the other 184 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 184: 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; 125 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 f459c863e37c0a31656c6cc471323f92659fff18 → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json f459c863e37c0a31656c6cc471323f92659fff18

⚠️ 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 f459c863e37c0a31656c6cc471323f92659fff18 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-elon-musk · session_016WV4d13AraSmVmgVtCvkWk

席位核对

ACCEPT at head cf125c9 (L1, repo:objectstack#1, read by the dispatching seat; first round, no REWORK).

  • Shape (l1-face.mjs --pr 38465, CLEAN, 13 items): draft, base main, Fixes #38419, one changeset for @objectstack/service-knowledge (patch), Clause-②: no · Metadata-protocol: none; all checks green at this head (39 success, 0 failed, 0 pending), mergeable clean. check-governed-merges.mjs: NOT governed, 372 lines.
  • Diff read by the seat: admitAuthoredSource gains an absentSourceReference() arm ahead of the permission arms. It answers 400 VALIDATION_ERROR with the rule names os validate already reports (knowledge-source-object-unknown, knowledge-source-field-unknown), naming the object and the field, for an absent source.object, content, contentFields or metadataFields.
  • Disclosure: the existence check reads only the registered object definition (id and registry-injected system columns count as fields). Every door that reaches it admits only a manage_metadata holder, who is already served every definition whole, so naming an absent object or field tells that caller nothing new; for anything that exists, every refusal is unchanged.
  • Changeset read sentence by sentence against the diff: the old 503 / 403 answers it names, the new 400 with the rule name, the "no security service: was admitted" line, and the existing-reference sentence each match.
  • Evidence: src/__tests__/knowledge-source-save-absent-reference.test.ts, 15 cases, red on base, green on head.
  • Out of scope, filed: an absent field read by source.where is still answered as a permission refusal; it needs a lint rule first and moves an existing pin, so it is card knowledge-source save door words an absent where field as a permission refusal #38471 (undispatched, for triage), not this PR.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-elon-musk · session_016WV4d13AraSmVmgVtCvkWk

Landing · ACCEPT → PR #38465 comment 7250429083

reading at head cf125c9
pr-state.mjs --pr 38465 39 success · 16 expected skip · 0 unexpected skip · 0 failed · 0 pending · mergeable clean
check-governed-merges.mjs --pr 38465 NOT governed · 372 lines; landing-k.mjs K = 2

State: ready + auto-merge now; on MERGED #38419 closes by Fixes and leaves pm:dispatched.

This branch has not been deployed

No deployments
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.

knowledge-source save door words permanent reference mistakes as temporary or as permission refusals

2 participants