Skip to content

feat(knowledge): a knowledge source needs no adapter and no requires entry; it binds to the deployment's store - #38026

Merged
objectstack-fleet[bot] merged 21 commits into
mainfrom
claude/area-o1C-37306
Nov 27, 2026
Merged

objectstack-fleet[bot] merged 21 commits into
mainfrom
claude/area-o1C-37306

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

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

Fixes #37306

Clause-②: yes (widening)
Metadata-protocol: added
Skills-docs: follow-up #37310 — skills/** teaches the optional adapter and the item mount after this lands

维护者速读

  • 用户能看到什么变化:应用作者写知识源时不必再指定存储,也不必在应用里声明需要知识服务;在本机开发(SQLite)、PostgreSQL 和自带存储的部署上,同一个知识源无需修改即可建索引和检索。
  • 为什么做:知识库检索专题(按调用者权限过滤的知识检索)中“知识源可移植”的一行,替写知识源的应用作者和 AI 解决“换个数据库就要改知识源”的问题。
  • 出错会怎样:最坏是同时注册了两个以上存储、且都不是部署自带的那个时,未写存储的知识源在保存时被明确拒绝并列出可选项;改动可直接撤回。
  • 要你做什么:无(“运行中首次保存、部署未装知识服务时怎么办”已拆成单独的待裁决卡)。

What changes

Mechanism (the deployment's-store mark). It is a service option, not a contract member: KnowledgeServicePlugin / KnowledgeService take deploymentAdapter?: string, which the runtime sets to the adapter id of the store it mounted (resolveCapabilityArgument('knowledge', …) answers { deploymentAdapter: resolveKnowledgeStore(input).store.adapterId }, the same resolution resolveCapabilityExtras mounts from). IKnowledgeAdapter and registerAdapter are unchanged, so an adapter that application code registers is never the deployment's by registering.

  1. adapter optional (@objectstack/spec, ADR-0161 K4 / K8 item 11). KnowledgeSourceSchema.adapter is z.string().optional(). Omitted, the source is held by the marked store, else the only adapter registered. Several registered and none the deployment's ⇒ refused at registration on both doors (registerSource, the knowledge_source loader) and at save (admitAuthoredSource), 400 VALIDATION_ERROR, naming the choices. A source registered first and left unplaceable by adapters that came later answers the same refusal at index and search, and reportUnmountedAdapters names it once at boot. No adapter at all ⇒ 503 SERVICE_UNAVAILABLE, naming the marked store.
  2. Placement is resolved where it is used (adapterIdFor / adapterFor / boundAdapterId), so a code-door source registered at init finds a store plugin that registers in start(). Every getAdapter(source.adapter) call site (reindex, index state, record sync, delete, search planning, reap guard, dropMetadataSource) now goes through it. index_status reports the adapter a source is placed on.
  3. An item mounts the service (K8 item 12). PlatformCapabilityProvider gains optional mountedBy: { collection }; the knowledge row of PLATFORM_CAPABILITY_PROVIDERS carries { collection: 'knowledgeSources' }. (Review S1, record 7224273377: the earlier type member had no reader and repeated what the spelling map owns, so it is dropped.) @objectstack/core adds stackItemCapabilities(stack) (top level, then each package body), and resolveServedCapabilities(…, { itemTokens }) serves them as declared tokens, reported in a new byItems set. os serve / os dev / os start and verify's bootStack read it and pass database to the argument resolver. os migrate plan / apply compose the same set: stackItemCapabilities is a composition step of both boots in boot-preparation-parity.test.ts. This answers CI's Test Core red at aba523a and the review's N3.
  4. Item 4 is split to knowledge: what a knowledge_source saved at run time does on a deployment that mounted no knowledge service (split from #37306 item 4) #37983 (seat ruling). The first knowledge_source saved at run time on a deployment with no knowledge service behaves exactly as on main: row 3a's boot line and behaviour are unchanged. The built item-4 code is kept on claude/area-o1C-37306-item4 (fa2b538).
  5. Docs: content/docs/ai/knowledge-rag.mdx, content/docs/protocol/knowledge.mdx; references regenerated (gen:docs).

What a 19.0.0-next.1 stack sees: one that ships a source without requires: ['knowledge'] held an inert item with a boot warning. It is now indexed: the service mounts, the boot pass builds the index, and the content fields are sent to the configured embedder (ADR-0161 K5: embedding is egress). The changeset says the same.

Unchanged: a named adapter that is not mounted answers SERVICE_UNAVAILABLE as before (#37102); a host that mounts KnowledgeServicePlugin itself gets no store and no mark from the runtime; without a source or the token nothing is mounted. Out of scope as fenced: skills/** (#37310), the Studio form (#37309), hosted/EE mounts, #37479's unmounted-adapter reporting.

Deviations (declared)

File surface beyond the claim, declared: packages/runtime/src/domains/mcp-authoring.ts and its test, packages/cli/src/utils/schema-migration-plugins.ts and its test plus boot-preparation-parity.test.ts (above), the knowledgeSources describe in packages/spec/src/stack.zod.ts, service-knowledge plugin options, knowledge-build-actions.ts, knowledge-reap-guard.ts, packages/verify/src/required-providers.ts, packages/core/src/capability-providers.ts (comments only).

Read first (by risk):

  1. packages/services/service-knowledge/src/knowledge-service.ts: adapterIdFor and refuseUnplacedSource, where the refusal and placement rules live.
  2. packages/core/src/capability-composition.ts: stackItemCapabilities and the knowledge branch of resolveCapabilityArgument.
  3. packages/spec/src/kernel/platform-capabilities.ts: the mountedBy row field, the public surface this adds.

Two-minute verification: pnpm --filter @objectstack/verify exec vitest run src/harness.required-providers.test.ts -t "an item, no adapter, no token" should print one passing case: a stack with a knowledge_source that names no adapter and no requires: ['knowledge'] boots KnowledgeServicePlugin + KnowledgeTursoPlugin, places the source on turso beside an app adapter, and finds the Chinese row for 住宿标准 报销.

Tests

Local, under the shared verify lock, at 633041b (the last commit, af27454, adds only module-top imports to one cli test file; that file was re-run, see below).

Suites and typecheck
  • @objectstack/spec (whole package): 909 files / 28749 passed (+1 todo).
  • @objectstack/core capability-composition.test.ts: 25/25.
  • @objectstack/service-knowledge: 18 files / 563 tests.
  • @objectstack/verify harness.required-providers.test.ts: 16/16.
  • @objectstack/cli boot-preparation-parity.test.ts + schema-migration-plugins.test.ts: 2 files / 93 tests, at 633041b and again at af27454 (cli typecheck exit 0 at both).
  • @objectstack/runtime mcp-authoring.test.ts: 73/73, at aba523a; runtime is unchanged since.
  • Typecheck exit 0: spec, core, service-knowledge, verify, cli, runtime.
Ablations (each restored; blob == HEAD, `git diff HEAD` empty)
Pin Mutation Result
A1 the deployment's mark in adapterIdFor 2 failed
A2 the registration refusal 1 failed
A3 the item tokens in resolveServedCapabilities 1 failed
A4 the knowledge capability argument 1 failed
A6 adapter optional, redone as z.string().min(0) (the first try was a no-op) 1 failed
A7b stackItemCapabilities, core dist verify case fails: the knowledge service is not found
A8 the mark argument, core dist verify case fails: source refused, then a TypeError
A9 boot pass reads the named adapter the boot pin fails
A10 reconcile reads the named adapter the reconcile pin fails
A11 MCP door respells non-403 as SERVICE_UNAVAILABLE the pin fails: SERVICE_UNAVAILABLE where VALIDATION_ERROR was expected
A12 the migrate boot passes no item tokens the behaviour pin fails: KnowledgeServicePlugin is not composed

A5 left with item 4.

Acceptance notes

Verification

Container run (os dev, scratch app; at fa2b538, items 1-3 unchanged since)

The scratch app held one knowledge_source, with no adapter and no requires. The embedder was a local bigram fake.

  1. os dev --fresh booted KnowledgeServicePlugin and KnowledgeTursoPlugin.
  2. Three Chinese rows were POSTed (201 ×3).
  3. os knowledge rebuild kbx-kbx_policies ended done: 3 rows read, 3 written.
  4. os knowledge status showed adapter turso, index: current.
  5. MCP search_knowledge '住宿标准 报销' ranked 差旅住宿标准 first (score 0.436).
Gates

🤖 Generated with Claude Code

https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP

…old so; the boot line names the token

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
…unts the service and the deployment's store

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
… no service) to its own card

The save-time warn, the reworded boot line and their tests leave this
change; row 3a's boot line and behaviour are main's again. The full state
is kept on claude/area-o1C-37306-item4 (fa2b538).

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
…pter

main's boot pass (#37951) read the source's named adapter; a source that
names none is now placed through boundAdapterId, and one that cannot be
placed is left to the reading, as an unmounted named one is.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
The reconcile (#37979) read a source's named adapter to tell a store that
lists no documents; it now reads the store the source is placed on, so a
source that names no adapter is walked or left as a named one is.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
…wn code

A 400 VALIDATION_ERROR from admitAuthoredSource arrived over MCP as
SERVICE_UNAVAILABLE with status 400; only a 403 is respelled now.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation protocol:ai tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 6 package(s): @objectstack/cli, @objectstack/core, @objectstack/runtime, @objectstack/service-knowledge, @objectstack/spec, @objectstack/verify, touching 60 documentable anchor(s).

4 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), KnowledgeServicePlugin (symbol, a top-level class), knowledgeSources (symbol, a field of const object STACK_DEFINITION_COLLECTIONS_SHAPE), knowledgeSources (literal, a string literal in knowledge))
  • content/docs/permissions/capabilities.mdx (via PLATFORM_CAPABILITY_TOKENS (symbol, a top-level const object))
  • content/docs/permissions/system-context.mdx (via admitAuthoredSource (symbol, a method of class KnowledgeService), openWriter (symbol, a top-level function))
  • content/docs/protocol/knowledge.mdx (via KnowledgeService (symbol, a top-level class), KnowledgeServicePlugin (symbol, a top-level class), KnowledgeSourceSchema (symbol, a top-level const), PLATFORM_CAPABILITY_PROVIDERS (symbol, a top-level const object), deploymentAdapter (symbol, a field of interface KnowledgeServiceOptions; a field of interface KnowledgeServicePluginOptions), handleRecordDelete (symbol, a method of class KnowledgeService), knowledgeSources (symbol, a field of const object STACK_DEFINITION_COLLECTIONS_SHAPE), mountedBy (symbol, a field of interface PlatformCapabilityProvider), registerSource (symbol, a method of class KnowledgeService), getAdapter (literal, a string literal in KnowledgeReapGuardService), knowledgeSources (literal, a string literal in knowledge), registerSource (literal, a string literal in registerSource))

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

  • content/docs/releases/v16.mdx (via PLATFORM_CAPABILITY_PROVIDERS (symbol, a top-level const object), PLATFORM_CAPABILITY_TOKENS (symbol, a top-level const object))

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
  • 2 anchor(s) matched too much of the corpus to be a work list: VALIDATION_ERROR (literal, 39 pages), os serve (command, 52 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 — 196 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 6e2a8f2bb577b9fff5225a1280bc6cbbea680c7c → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json 6e2a8f2bb577b9fff5225a1280bc6cbbea680c7c

⚠️ 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 6e2a8f2bb577b9fff5225a1280bc6cbbea680c7c → 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_016WV4czzx9dtSEm3jWWL9c3

Contract-review-claim: session_016WV4czzx9dtSEm3jWWL9c3 · head aba523a · 2026-11-27T17:08Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: aba523a3413298d11c6b2d54bf02b716f7581abb
Local-runs: none
Scope: packages/spec/src/ai/knowledge-source.zod.ts, packages/spec/src/kernel/platform-capabilities.ts, packages/spec/src/stack.zod.ts + packages/core/src/capability-composition.ts, packages/core/src/capability-providers.ts, packages/cli/src/commands/serve.ts, packages/verify/src/required-providers.ts, packages/services/service-knowledge/src/knowledge-service.ts, packages/services/service-knowledge/src/knowledge-service-plugin.ts, packages/services/service-knowledge/src/knowledge-build-actions.ts, packages/services/service-knowledge/src/knowledge-reap-guard.ts, packages/runtime/src/domains/mcp-authoring.ts

Inputs read: card #37306 (body and all six comments, dev report 7224020195 last), split card #37983 (body, ruling 7220511579, claim, dev report), PR #38026 body and file list, the net diff from merge base 4af32b99db to the head (23 files, +697/-76), ADR-0161 K4, K6, K8, K10 at the head, and the check-runs on the head (read 2026-11-27T17:16Z). The tests, the two docs pages, the two generated reference pages and the changeset prose are the lane seat's ACCEPT; they were read only to judge the files above.

① Derived judgments

Accept-set and public-surface changes the diff implies, each judged.

  1. KnowledgeSourceSchema.adapter: z.string() to z.string().optional(). RIGHT, a widening. Every value that parsed still parses and reads the same (a named adapter is kept as written); a non-string is still refused. The new accepted spelling is the omitted key. Nothing that parsed on main is refused.
  2. Reader-side type: KnowledgeSource['adapter'] becomes string | undefined. RIGHT, and inherent in item 1. Every reader in the tree was moved or already tolerant: the service's twelve call sites go through adapterIdFor / adapterFor / boundAdapterId; packages/cli/src/commands/knowledge/status.ts already prints ?? '?'; rebuild.ts compares the placed adapter that index_status now answers. No adapter package reads the field. A grep of the head for a remaining direct read found only the two guarded lines in reportUnmountedAdapters.
  3. PlatformCapabilityProvider.mountedBy? (new optional member) and the knowledge row carrying it. RIGHT as an addition; one part of its shape is not (S1 in section ④).
  4. stackItemCapabilities (new export of @objectstack/core), resolveServedCapabilities option itemTokens, ServedCapabilities.byItems, and the knowledge branch of resolveCapabilityArgument. RIGHT. byItems is a new required member of a returned type: additive for every reader.
  5. KnowledgeServicePluginOptions.deploymentAdapter? and KnowledgeServiceOptions.deploymentAdapter?. RIGHT. A service option, as ADR-0161 K8 ("Not members": an option of the service) and the card's item 2 require. IKnowledgeAdapter and registerAdapter are untouched, so application code cannot mark its own adapter by registering.
  6. New methods on KnowledgeService: adapterIdFor, adapterFor, boundAdapterId. RIGHT, additive.
  7. KnowledgeIndexStatusEntry.adapter from string to adapter?: string. RIGHT. It is absent only for a source that names no adapter and cannot be placed, a state that cannot exist on main; every answer main gives keeps the field.
  8. New refusals: 400 VALIDATION_ERROR at registerSource, at the loader door and at admitAuthoredSource, and at index and search for a source left unplaceable later; 503 SERVICE_UNAVAILABLE where no adapter is registered. RIGHT, and none is a hidden narrowing: each fires only for a source with no adapter, which main refuses at parse. The loader catches the throw per item and reports it once, so one refused item does not stop the listing.
  9. A stack that ships a knowledge_source and lists no requires: ['knowledge'] is now served the service and one store, as a declared token. RIGHT against ADR-0161 K8 item 12. Does anything that ran before now refuse? Read for it: @objectstack/service-knowledge is a hard dependency of the CLI and of verify, so the import cannot be missing; the turso store is an optional extra whose import failure is a warning; the pgvector store's start() warns on a failed health check and does not throw. So the boot of such a stack does not fail where it booted before. What does change for it is stated in N1.
  10. MCP draft door, itemSaveRefusal: a verdict that is not a 403 keeps its own code. RIGHT. On main every verdict of the platform's admitter that is not a 403 is 503 SERVICE_UNAVAILABLE (read: every refuse( in admitAuthoredSource is 403, and unavailable is 503), so no answer an MCP client gets today changes; only this PR's new 400 is affected. The three save doors now agree: REST passes refused.code, the dispatcher derives VALIDATION_ERROR from status 400 (packages/spec/src/api/errors.zod.ts), MCP passes the code.

Hidden narrowing: none found in what an author can write or in what a deployment runs. Two TypeScript-only tightenings exist on helper types of @objectstack/service-knowledge, recorded as N5.

② Semver level

  • Clause-②: yes (widening): RIGHT. The published schema accepts one more spelling and refuses none.
  • Metadata-protocol: added: RIGHT. A newly accepted value (the omitted adapter) is added by the AGENTS.md definition. The item mount does not move the meaning or the default of any authorable key: a named adapter and a listed requires read as before, and an item with no reader was a reported fault on main (row 3a's boot line, ADR-0078), which ADR-0161 K8 item 12 decided to end. So neither semantic nor narrowed applies, and the precedence rule changes nothing.
  • Bookkeeping added owes: a level of at least minor on a package the diff moves, and no ADR-0087 disposition (ADR-0161 K4 and K6: "widens what an author may write and takes no disposition"; the registration gate reads added as no signal). Present: @objectstack/spec is minor, and both declaration lines stand in the changeset body and the PR body. Check Changeset, Spec property liveness and the lint gate families that carry the generated-artifact and surface checks concluded success on this head. The two regenerated reference pages are in the diff.
  • Levels, package by package: spec minor (new accepted value, new interface member), core minor (new export, new option, new returned member), service-knowledge minor (new option and methods), cli and verify minor (new mount behaviour) are RIGHT. runtime patch is RIGHT: a corrected error code for a verdict that cannot occur before this PR, no protocol kind of its own.
  • Skills-docs: follow-up #37310 is consistent with the card's fence (skills/** is row 5b's).

③ Boundary flags

  • Declared deviation, the runtime mcp-authoring.ts mapping. In scope of the card, not an adjacent defect: the card's item 1 adds a refusal at the save, and this is that refusal reaching an existing door correctly. Without the edit the PR's own 400 VALIDATION_ERROR would arrive over MCP as SERVICE_UNAVAILABLE with status 400. Read as an adjacent in-place fix it still holds on each count: it is reachable only through this PR's change, it is one expression with no new surface, it is declared in the PR body and carries a runtime patch entry, and it is pinned (the new case in mcp-authoring.test.ts; ablation A11 reported red with SERVICE_UNAVAILABLE where VALIDATION_ERROR was expected). It is right: parity with the REST door, read in packages/rest/src/meta-item-write-routes.ts. See N4 for the cast.
  • The two semantic-conflict fixes with main. Both read in the head. The boot pass (buildIfDue, from 205f667) now skips a source at boot when boundAdapterId answers nothing or names an adapter that is not registered, which is the same set reportUnmountedAdapters names once at error; the comment and the code agree. The reconcile (reconcileExclusion, from merge 635fb18) reads the adapter the source is placed on before it asks for listDocuments; an unplaced source falls through and is walked, so its build fails and names it, as the method's own doc says for an adapter that is not mounted. Both are this card's change meeting a new reader of the field it made optional; fixing them here is correct, and leaving them would not compile. Pins exist for both (A9, A10 reported red).
  • Overlap with fix(service-knowledge)!: retire the knowledge field gate's title arm behind a per-source recipe proof #37963 (open draft). Its patch was read: one textual hunk in the admitted-sources loop of knowledge-service.ts. Its added lines read the adapter from the plan it is handed and add no new direct read of source.adapter. No semantic conflict; whoever lands second keeps both edits.
  • Overlap with docs(adr,spec): ADR-0084's notes catch up with the knowledge_source row; the knowledge_source tombstones name the code door #38015. Its patch was read: it appends one sentence to six tombstone prescriptions in knowledge-source.zod.ts, none on the adapter line, and regenerates content/docs/references/ai/knowledge-source.mdx. The source edits do not meet; only the generated page does, and it is regenerated on the merged tree. Nothing else conflicts semantically.
  • Fixes #37306 with item 4 elsewhere. The card closes rightly. Item 4 and its acceptance line live on knowledge: what a knowledge_source saved at run time does on a deployment that mounted no knowledge service (split from #37306 item 4) #37983, whose body records the seat's split and whose ruling 7220511579 (the maintainer's D) replaces item 4's two options. Once this PR lands nothing of knowledge_source: adapter becomes optional (the deployment's store), and a knowledge_source item mounts the knowledge service #37306 remains to do, so Part of would leave a card open with no work. The PR-body guard concluded success. One record gap: N6.
  • check:type-check-debt, NOT MEASURED locally. Covered: the check-run Type Check · debt ledger concluded success on this head.
  • Check-runs on the head at 17:16Z: 26 success, 10 skipped, 0 failed, 31 in progress (Test Core 1 to 10, Test UI 1 to 16, Type Check · workspace, Type Check · consumer gates, Type Check UI, Build & E2E UI, Live E2E UI). This record judges the contract; those conclusions remain the gate verdicts and the queue reads them.
  • PostgreSQL acceptance, NOT MEASURED locally. The PR body names capability-mount.live-postgres.test.ts as CI's cover. That file, unchanged by this diff, writes adapter: 'pgvector' and requires: ['knowledge'], so it exercises neither the omitted adapter nor the item mount. What pins the card's second acceptance line is the composition of two unit pins: resolveCapabilityArgument('knowledge', postgres) answers { deploymentAdapter: 'pgvector' }, and a source with no adapter binds to the marked store. Handed to the lane seat's ACCEPT as N2.
  • Dev open questions: report 7224020195 carries none. The earlier ones (item 4, the landing order against fix(service-knowledge)!: retire the knowledge field gate's title arm behind a per-source recipe proof #37963, the fix(knowledge-turso)!: Test connection comes with the Turso fields it checks; the group text drops the cloud fallback #37982 bullet, docs(adr,spec): ADR-0084's notes catch up with the knowledge_source row; the knowledge_source tombstones name the code door #38015) are each answered by a ruling the later reports carry out.
  • SQL push-down: no new id materialisation and no in-app join in this diff. Placement is a map lookup over registered adapters.

④ Design judgment

packages/spec/src/ai/knowledge-source.zod.ts. Holds against ADR-0161 K4. The jsdoc and the describe text say: omitted means the store the runtime mounted beside the service, else the only adapter registered, and several with none the deployment's is refused naming them. adapterIdFor does exactly that, in that order. Tried to break it: (a) a source registered in code at init() before any store started is taken and placed at use, so the ADR's "refused at registration" is deferred only where the registry is not yet final; (b) a mark with its store absent and nothing else gives 503 naming the store; (c) two adapters with no mark is refused at both doors and at the save. First consumer: BrightRule mounts the service by hand and names its adapter; serve.ts skips both the provider and the extras when the host holds the service (hasPluginMatching), so it gets no store and no mark and is unchanged.

packages/spec/src/stack.zod.ts. The knowledgeSources description now says the CLI mounts the service where the stack holds a source or lists the token. serve.ts and required-providers.ts do so through one rule.

packages/spec/src/kernel/platform-capabilities.ts.

S1 (should-fix) — mountedBy.type ships with no reader. The new member is { collection, type } and the knowledge row sets type: 'knowledge_source', but stackItemCapabilities reads collection alone; a grep of the head finds type only in the row and in a test that asserts its literal value. The member's own jsdoc describes the collection and never says what type is for. It is also a second statement of a fact the spec already owns: packages/spec/src/meta-spelling/manifest-collection-spelling.ts maps knowledgeSources to knowledge_source, so the two can drift with nothing to notice. ADR-0161 K10 rule 1 (a key lands with its first reader in the same PR) and the K8 note on what is not a member ("they land with their reader") both apply to a required field of a published interface on a governed path. Its reader appears to have left with item 4. Fix before it publishes, since removing it later narrows a published type: drop type and keep mountedBy: { collection }, or land it with a reader and a doc line; a later reader can derive the type from the spelling map.

Implementing files, sentence by sentence.

  • capability-composition.ts, capability-providers.ts: the mark is resolveKnowledgeStore(input).store.adapterId, the same call resolveCapabilityExtras mounts from, on the same database input in both boots, so the mark and the mounted store cannot disagree. Item tokens are appended after the declared ones and counted as declared, as the changeset says.
  • serve.ts, required-providers.ts: both pass itemTokens and the same database to the argument and to the extras. Agree with the contract.
  • knowledge-service.ts, knowledge-service-plugin.ts, knowledge-build-actions.ts, knowledge-reap-guard.ts: agree with the spec text; every former getAdapter(source.adapter) site was moved.
  • mcp-authoring.ts: agrees with its comment and with the REST door.

Nits. None changes correctness or the contract; a fix that moves a reviewed file is left to a follow-up.

N1 — The changeset's "What to do: nothing" omits one case. A stack on 19.0.0-next.1 that ships a source without requires: ['knowledge'] held an inert item with a boot warning; after this change the service mounts and the boot pass builds its index, which sends content to the embedder where one is configured (ADR-0161 K5: embedding is egress). That is the decided behaviour of K8 item 12, on a prerelease line, and the changeset's first paragraph states the mount. One sentence in the changeset and PR body for that reader would close it (prose face).

N2 — The PR body's sentence that CI covers the PostgreSQL acceptance through capability-mount.live-postgres.test.ts overstates: that test names the adapter and the token. Correct the sentence (prose face) and carry a follow-up that drops adapter and requires from the live case, so the card's second acceptance line is exercised end to end.

N3 — packages/cli/src/utils/schema-migration-plugins.ts composes "what os serve mounts" from resolveServedCapabilities(requires) without itemTokens, so os migrate plan on an item-only stack does not compose the knowledge service. No effect today: the service declares no objects. Follow-up, so the two boots stay one rule.

N4 — refused.code as ErrorCode is an unchecked cast of a duck-typed service's string; the code before it clamped every such answer to SERVICE_UNAVAILABLE. The REST door passes the string through the same way, so this is parity, and the platform's admitter answers ledger codes only. A guard against a code outside the vocabulary is a follow-up for both doors.

N5 — Two helper types of @objectstack/service-knowledge ask one more member of a hand-built service object: KnowledgeBuildActionsService (the parameter of the exported knowledgeIndexStatusActionHandler) gains boundAdapterId, and the reap guard's pick swaps getAdapter for adapterFor. A caller that passes the real KnowledgeService, which is every caller in the tree, is unaffected; the compiler carries it for a stub (ADR-0087 D7). Accepted as is.

N6 — #37306's own thread carries no seat line recording the split of item 4; only the dev reports and #37983's body say so, and the card body still lists item 4 and its acceptance line. One seat comment on #37306 naming #37983 and ruling 7220511579 before the merge closes the card (prose face).

N7 — Two message details. noAdapterMountedError advises "requires: ['knowledge'] mounts the deployment's" even in the branch where a mark is set, which means the capability was already requested and the remedy is installing the optional store package. And with a mark set whose store is not registered, a source with no adapter binds to the only other adapter registered; that follows the ADR's words ("or the only adapter registered"), but during startup it can place an early record sync on an application adapter before the runtime's store registers. The boot pass and the reconcile repair it. Follow-up.

N8 — The vectorStore tombstone in knowledge-source.zod.ts still says the store is "named by adapter"; with the key optional that is true only where it is named. Not touched by this diff; a wording follow-up.

Open on this head: S1.

Implemented-by: claude/area-o1C-37306
Reviewed-by: session_016WV4czzx9dtSEm3jWWL9c3 (isolated sub-agent)

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

L1 verdict (L1-a): REWORK at head aba523a3413298d11c6b2d54bf02b716f7581abb (Fixes #37306). Full read · 2026-11-27T17:19Z

席位核对

Contract review. Record 7224273377 at this head: PASS at the contract tier (verify-review-tier PASS), with one graded finding, S1, which the queue guard reads as open. I adopt the record. It rules all six of the area's points the way the PR declares: Clause-②: yes (widening) and Metadata-protocol: added are right, the itemSaveRefusal mapping is in scope and pinned, both semantic-conflict fixes are right, the overlaps with #37963 and #38015 are textual only, Fixes #37306 is right given ruling 7220511579 on #37983, and Type Check · debt ledger is green in CI.

S1, confirmed on the tree. mountedBy.type (platform-capabilities.ts:175, set to 'knowledge_source' at :255) has no reader. stackItemCapabilities reads only .collection (capability-composition.ts:100), and the one other mention is a test asserting the literal. A published spec key that nothing reads goes against ADR-0161 K10 rule 1. It also duplicates the knowledgeSources to knowledge_source mapping that meta-spelling/manifest-collection-spelling.ts already owns. Next head: drop type from the row type and the row, along with the test literal and any generated reference. Or, if item 4 (#37983) needs it, land it there with its reader and a jsdoc line.

Same head, optional prose (record nits):

CI. At 17:16Z, Test Core, Test UI, Type Check (workspace and consumer gates) and the E2E lanes were still running. The next head needs them green.

Next: a new head, a delta L2 on S1, a delta L1, then the seat's Tier H handoff (protocol-added).

The type member had no reader (the spelling map already owns the
collection-to-type mapping). The changeset names the one behaviour a
next.1 stack shipping a source without requires sees.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

Contract-review-claim: session_016WV4czzx9dtSEm3jWWL9c3 · head af27454 · 2026-11-27T19:14Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: af27454a77c7029e50b1a5cb214abf043afb310b
Local-runs: none
Scope: packages/spec/src/ai/knowledge-source.zod.ts, packages/spec/src/kernel/platform-capabilities.ts, packages/spec/src/stack.zod.ts + packages/core/src/capability-composition.ts, packages/core/src/capability-providers.ts, packages/cli/src/commands/serve.ts, packages/cli/src/utils/schema-migration-plugins.ts, packages/verify/src/required-providers.ts, packages/services/service-knowledge/src/knowledge-service.ts, packages/services/service-knowledge/src/knowledge-service-plugin.ts, packages/services/service-knowledge/src/knowledge-build-actions.ts, packages/services/service-knowledge/src/knowledge-reap-guard.ts, packages/runtime/src/domains/mcp-authoring.ts

Delta review of record 7224273377 (head aba523a341). Read for this round: the five commits from aba523a341 to this head (9fb423f, merge 503c913, 3275e95, 633041b, af27454), the PR body as it now stands, card comment 7224355969, and the check-runs on this head (read 2026-11-27T19:15Z). Everything record 7224273377 judged and this round does not name stands as judged there.

S1 (should-fix): closed

No must-fix, no should-fix.

① Derived judgments

  1. PlatformCapabilityProvider.mountedBy is now { collection } (9fb423f). RIGHT. The member has one field and one reader (stackItemCapabilities reads collection); the row carries { collection: 'knowledgeSources' }; the core pin and the changeset line were moved with it. The type of an item is left to the spelling map that owns it. Nothing was published with the two-field shape, so nothing narrows.
  2. The merge of main (503c913). Four of the PR's files were touched by it: content/docs/protocol/knowledge.mdx, knowledge-service-plugin.ts, knowledge-source.test.ts, knowledge-source.zod.ts. For each, the PR-side change before the merge (merge base to first parent) and after it (second parent to the merge) are line for line the same, and the merge's change to each equals main's change to it. So the merge altered the PR's own files by resolution only. A grep of this head for a direct read of a source's adapter finds the same guarded lines as before: main brought no new reader.
  3. The regenerated content/docs/references/ai/knowledge-source.mdx (3275e95). Against main it differs in exactly one row, adapter: required to optional, with the schema's new describe text. That is what the one schema edit predicts on top of main's tombstone sentences. Whether it is byte-equal to the generator's output is the generated-artifact gate's verdict; that lint family is still running (section ③).
  4. The migrate boot (633041b): composeServedPlatform passes itemTokens: stackItemCapabilities(config). RIGHT, judged in section ④.

② Semver level

Unchanged from record 7224273377: Clause-②: yes (widening) and Metadata-protocol: added are right, and no level moves. @objectstack/cli is already minor, which covers the migrate boot's change. Check Changeset concluded success on this head. One prose gap in the changeset: N9.

③ Boundary flags

  • N1 of record 7224273377: answered. The changeset's last paragraph and the PR body now tell a 19.0.0-next.1 reader that a source shipped without requires: ['knowledge'] goes from inert to indexed, with its content fields sent to the configured embedder.
  • N2: answered on the prose face. The PR body now says the PostgreSQL line is not measured end to end, names the two unit pins that compose to it, and names the follow-up. The follow-up has no card number yet (see N10).
  • N3: answered in code, judged in section ④.
  • N6: answered. Comment 7224355969 on knowledge_source: adapter becomes optional (the deployment's store), and a knowledge_source item mounts the knowledge service #37306 records the split, knowledge: what a knowledge_source saved at run time does on a deployment that mounted no knowledge service (split from #37306 item 4) #37983 and ruling 7220511579.
  • N4, N5, N7, N8: stand as accepted or as follow-ups; this delta does not touch them.
  • Known gap named in the PR body: os serve --artifact-fallback synthesizes its stack from the artifact, which surfaces requires and no item collection, so an artifact-only stack's sources do not mount the service on that path. This is not a regression: on main that path mounts by requires alone, and such a source is reported by row 3a's boot line. It does leave the item mount of K8 item 12 short on one boot path, and the built artifact is the shape a hosted runtime reads, so it should not stay a sentence in a PR body. A follow-up card is adequate, provided it is filed before this merges: N10.
  • Check-runs on this head at 19:15Z: 15 success, 11 skipped, 0 failed, 25 in progress. In progress: Test Core 1 to 10, Build Core, Build Docs, Build UI Deps, Live E2E UI, Type Check · workspace, Type Check · source gates, Type Check · consumer gates, Type Check · debt ledger, Lint · ESLint, and the lint families for repo and tooling, docs and code guards, CI and release, query-options erasure, slot lookup. The PR body says Test Core was red at aba523a341 (the boot-preparation parity pin) and that 633041b answers it; that is unconfirmed until Test Core concludes here. The debt-ledger run that was green on the old head is running again on this one. This record judges the contract; those conclusions remain the gate verdicts and the queue reads them.
  • SQL push-down: nothing in the delta materialises ids or joins in the application.

④ Design judgment

packages/spec/src/kernel/platform-capabilities.ts. The finding of record 7224273377 is fixed as asked: the member is as narrow as its reader, and its jsdoc, which always described the collection alone, now describes the whole member.

packages/spec/src/ai/knowledge-source.zod.ts, packages/spec/src/stack.zod.ts. No author edit in the delta; the merge added main's tombstone sentence beside the PR's adapter line without touching it.

packages/cli/src/utils/schema-migration-plugins.ts, the migrate boot. Judged as a behaviour change. What os migrate plan / apply now composes that it did not: KnowledgeServicePlugin, for a stack that ships a knowledge_source and lists no knowledge token. What that does during a migrate run, read in the head:

  • It is composed through composeProviderForDeclarations: init() runs, start() is suppressed, and init() can register no lifecycle hook at all, kernel:ready included. The declaration boot's write guard refuses row writes.
  • KnowledgeServicePlugin.init() builds the service object, registers it under knowledge, and contributes the knowledge settings. It opens no connection and calls no network.
  • Everything with an effect lives in start() and in the kernel:bootstrapped hook start() registers: loading published sources, providing the embedder, the boot build pass, the reconcile job, the record-sync subscription. None of it runs.
  • No store is composed. This loop reads the row's extras, and the knowledge row of CAPABILITY_PROVIDERS has none (serve takes the store from resolveCapabilityExtras). So no libSQL file is created and no PostgreSQL pool is opened.
  • The plugin gets no argument (no posture row), so no mark is set; nothing reads one in a declaration boot.
  • It cannot newly fail: @objectstack/service-knowledge is a hard dependency of the CLI, and this loop does not use the declared set.
  • The path is not new. A stack that lists requires: ['knowledge'] already composed the same plugin the same way on main; the change extends that to the item-only stack.

So nothing is opened, embedded, built, scheduled or sent. The service declares no objects, so a plan is the same as before; the one visible difference is that the "Composed what os serve mounts" note now lists KnowledgeServicePlugin. The change is right for the reason the parity pin exists: both boots compose one set from one rule. Pins: stackItemCapabilities is a named step of boot-preparation-parity.test.ts, and the behaviour case has an item-only stack and an app-only control (A12 reported red without the option). The test-only commit af27454 adds side-effect imports and changes no source.

Nits. None changes correctness or the contract.

N9 — The changeset's @objectstack/cli line names os serve / os dev / os start and bootStack but not os migrate plan / apply, which now compose the knowledge service for an item-only stack. The PR body declares it; the changeset, which ships as the changelog, does not. One clause there closes it (prose face).

N10 — Two follow-ups are named in the PR body and carry no card: the live PostgreSQL case without adapter and requires, and the --artifact-fallback gap. File both before the merge closes #37306, so neither depends on a closed card's PR body.

Implemented-by: claude/area-o1C-37306
Reviewed-by: session_016WV4czzx9dtSEm3jWWL9c3 (isolated sub-agent)

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

Contract-review-claim: session_016WV4czzx9dtSEm3jWWL9c3 · head 6881aa6 · 2026-11-27T19:21Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 6881aa6f0b2d357a81c79e34f8b19f417c334c0b
Local-runs: none
Scope: packages/spec/src/ai/knowledge-source.zod.ts, packages/spec/src/kernel/platform-capabilities.ts, packages/spec/src/stack.zod.ts + packages/core/src/capability-composition.ts, packages/core/src/capability-providers.ts, packages/cli/src/commands/serve.ts, packages/cli/src/utils/schema-migration-plugins.ts, packages/verify/src/required-providers.ts, packages/services/service-knowledge/src/knowledge-service.ts, packages/services/service-knowledge/src/knowledge-service-plugin.ts, packages/services/service-knowledge/src/knowledge-build-actions.ts, packages/services/service-knowledge/src/knowledge-reap-guard.ts, packages/runtime/src/domains/mcp-authoring.ts

Second delta, on record 7226372153 (head af27454a77). Read for this round: the diff from af27454a77 to this head, cards #38039 and #38040, the PR body as it now stands, and the check-runs on this head (read 2026-11-27T19:21Z). Everything records 7224273377 and 7226372153 judged and this round does not name stands as judged there.

① Derived judgments

The diff from af27454a77 to this head is one line of one file, .changeset/37306-knowledge-source-adapter-optional.md. No file in the scope above moved, so no accept set and no public surface changes in this round.

② Semver level

Unchanged: Clause-②: yes (widening), Metadata-protocol: added, and every level as judged before. The changeset's frontmatter and its two declaration lines are untouched. Check Changeset has one run concluded success on this head and one still in progress.

③ Boundary flags

④ Design judgment

No hits file and no implementing file changed since record 7226372153; its judgment of each stands on this head. The one edited sentence describes packages/cli/src/utils/schema-migration-plugins.ts and agrees with it, as section ③ sets out.

Remaining nits, all accepted or carried by a card, none touched here: N4 (the unchecked code cast, parity with REST), N5 (two helper-type tightenings, compiler-carried), N7 (two message and placement details), N8 (the vectorStore tombstone wording).

No must-fix, no should-fix.

Implemented-by: claude/area-o1C-37306
Reviewed-by: session_016WV4czzx9dtSEm3jWWL9c3 (isolated sub-agent)

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

L1 verdict (L1-a): ACCEPT (delta) at head 6881aa6f0b2d357a81c79e34f8b19f417c334c0b (Fixes #37306), after REWORK 7224290286. Delta read · 2026-11-27T19:48Z

席位核对

Gates. Check-runs at 6881aa6: 62 success, 12 expected skip, 0 failed, 0 pending, including Test Core 1 to 10 after the migrate-boot fix. Mergeable state is clean. l1-face is CLEAN on 13 items.

Contract review. The chain is record 7224273377, then delta 7226372153 (af27454, S1 closed, No must-fix, no should-fix), then delta 7226470829 at this head (prose-only, No must-fix, no should-fix). All at the contract tier, with verify-review-tier PASS. I adopt them.

Landing: Metadata-protocol: added with spec minor, so it goes through the seat's Tier H handoff.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

Seat record · 2026-11-27T19:51Z · PR #38026 (Fixes #37306) · head 6881aa6f0b2d357a81c79e34f8b19f417c334c0b · Tier S — seat lands

席位核对 — ACCEPT · repo:objectstack#1 · head 6881aa6f0b

  1. Shape. Draft, base main, 26 files (+728/−78): knowledge_source.adapter becomes optional and a source needs no requires entry — it binds to the deployment's store (packages/spec/src/ai/knowledge-source.zod.ts, kernel/platform-capabilities.ts, stack.zod.ts; core capability composition/providers; service-knowledge service, plugin, build actions, reap guard; cli serve + schema-migration plugins; runtime MCP authoring; verify required providers), with tests and docs. Changeset: minor on spec, core, service-knowledge, cli, verify. Body: Clause-②: yes (widening), Metadata-protocol: added, Skills-docs: follow-up #37310. check-governed-merges.mjs --pr 38026: 0 of 26 paths governed ⇒ Tier S.
  2. Premise measured. Per the records: contract review chain 7224273377 → 7226372153 → 7226470829, PASS at CONTRACT_REVIEW_TIER on this head, "No must-fix, no should-fix"; L1-a delta ACCEPT 7226903678 after REWORK 7224290286. Card acceptance met; item 4 of knowledge_source: adapter becomes optional (the deployment's store), and a knowledge_source item mounts the knowledge service #37306 was split to knowledge: what a knowledge_source saved at run time does on a deployment that mounted no knowledge service (split from #37306 item 4) #37983.
  3. Gates (check-runs at this head). 62 success, 12 skipped, 0 failed; mergeable clean. landing-k.mjs --pr 38026: K = 5 < 15, no new locale pack, no shared book moved under this PR's.
  4. Accepted deviations. None beyond the recorded rulings.
  5. Out of scope → where it went. Artifact-fallback item mount → runtime: os serve --artifact-fallback mounts the knowledge service for an artifact-only stack's knowledge_source items #38039; live PostgreSQL case → knowledge-pgvector: the live PostgreSQL mount case drops adapter and requires, so it exercises the deployment store and the item mount #38040; item 4 → knowledge: what a knowledge_source saved at run time does on a deployment that mounted no knowledge service (split from #37306 item 4) #37983; skills teaching → skills/objectstack-ai and the MCP authoring contract teach knowledge_source as metadata: name, an explicit content list, no wildcard, the retired keys, and a create seed #37310. Security-touching: no on the seat's read: no permission, sharing, credential or auth hunk; the save-admission point is knowledge: what a knowledge_source saved at run time does on a deployment that mounted no knowledge service (split from #37306 item 4) #37983's.
  6. Landing terms. Tier S with a same-head PASS at tier and L1 ACCEPT ⇒ ready + auto-merge in this stroke, under the maintainer's seat-thread line 2026-11-26T13:33Z 「应该使用 pm-dispatch 技能审核和落地pr」. Seat 1 watches the queue.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 27, 2026 19:51
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 27, 2026
Merged via the queue into main with commit dbe0716 Nov 27, 2026
75 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/area-o1C-37306 branch November 27, 2026 20:21
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…eg merged with the vector leg by RRF (objectstack-ai#38037)

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

Clause-②: no
Metadata-protocol: none

## 维护者速读
- 用户能看到什么变化:在知识检索里搜订单号、型号(如
X-200)、人名或「出差」这类短词时,含这些词的段落会排进结果,之前只靠语义向量常被排到前几名之外。
- 为什么做:知识平台总卡下的检索质量子卡,让元数据开发平台上任何知识源(不只制度库)都能按精确词找到内容。
- 出错会怎样:检索结果的排序和分数会变;关键词一路出错时最坏是排序变差或检索报错,权限复核不受影响,撤回本次合并即可恢复原样。
- 要你做什么:无。

## What changes

Both open knowledge stores now search with two legs and merge them by
reciprocal rank fusion (RRF, k = 60, each leg ranks at most `topK`)
inside the adapter, so before the knowledge service re-checks each hit
as the caller.

- **Terms.** The query is split at white space and punctuation; a
hyphen, dot, slash, underscore, `#`, `@` or `+` inside a term keeps it
whole (`X-200`, `v1.2`, `a/b`), at most 16 terms. A passage's keyword
score is the sum, over the terms it holds, of the term's BM25 inverse
document frequency among the rows in scope (binary term frequency), so a
word most passages hold weighs little. Keyword ties are ranked by cosine
distance, and fused ties go to the better vector rank, so the keyword
leg never reorders by chunk id what the vector leg ranks.
- **knowledge-turso.** A term of three characters or more is one quoted
FTS5 phrase (an inner double quote doubled), so `X-200` is never FTS5
syntax. It is matched in a contentless trigram FTS5 table beside each
passage table (`TABLE-fts`), keyed through a map table (`TABLE-kw`, an
INTEGER PRIMARY KEY, so a VACUUM cannot renumber it) and kept in step by
three triggers on the passage table (insert, delete, update of
`chunk_id` or `content`), inside the statement that writes the passage.
A shorter term (「出差」) is matched by `content LIKE` over the rows in
scope. The keyword index is made with the passage table and dropped with
it (generation swap, `completeBuild`, `dropSource`). Its names hold a
hyphen, which no source id, generation table or object name can hold; an
object under one of those names that the store did not make is refused
`SERVICE_UNAVAILABLE`, naming it, and never dropped.
- **knowledge-pgvector.** A word of three characters or more is
`phraseto_tsquery('simple', term)` on `to_tsvector('simple', content)`,
served by a GIN expression index (`knowledge_vec_dWIDTH_content_tsv`):
no column added, no row rewritten. A shorter term, or one holding a Han,
kana or Hangul character, is matched by `content ILIKE`: measured on
PostgreSQL 16, the `simple` parser keeps a run of Han characters as one
word (`'出差住宿标准每晚三百元'`), so a tsvector phrase could never find 「住宿标准」
inside it. Both legs run in one statement (one snapshot), each behind
the existing active-generation guard.
- **One WHERE.** The organization filter, the record scope and the
metadata `filter` are built once and applied in both legs (and in the
inverse-document-frequency counts), before either ranks.
- **An index made before this PR still answers.** turso: the first
search of a passage table without a keyword index builds it from the
table's rows in one write transaction (shape-checked first), then
answers from it. pgvector: the first write or search of a width runs
`CREATE INDEX IF NOT EXISTS`; a concurrent loser re-reads the catalogue
and goes on. Both pinned.
- **Score.** A hit's `score` is now the fused rank normalized to (0, 1]:
1 for first in both legs, 0.5 for first in one alone. It was the cosine
similarity.
- Docs: both READMEs, `content/docs/ai/knowledge-rag.mdx` (retrieval and
both store sections), and the two Search bullets plus the adapter table
of `content/docs/protocol/knowledge.mdx`, which this change made
incomplete (outside the claim's file surface; declared in the report).

**Serial with objectstack-ai#37957.** That card adds a visible-ids pre-filter to the
search options and is not started. Whichever lands second applies its
filter or leg to both legs: here the one `WHERE` (`inScope` in both
adapters) is the single place a new filter goes, and it already feeds
both legs and the counts.

## Read first (by risk)

1. `packages/plugins/knowledge-turso/src/sql.ts` `keywordIndexDdl`: the
triggers and the backfill. A trigger that drifts from the passage table
leaves the contentless index wrong silently (the FTS5 `delete` command
needs the indexed text, which `old.content` holds).
2. `packages/plugins/knowledge-turso/src/turso-adapter.ts`
`searchAttempt`: the shared `inScope` in `vec`, `cand` and `stats`; the
parameter numbering (`?1` is the vector in both legs).
3. `packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts`
`searchAttempt` and `ensureKeywordIndex`: the one statement and the
first-search index build.

## Two-minute check

`cd packages/plugins/knowledge-turso && pnpm exec vitest run
--maxWorkers=2 src/__tests__/acceptance.test.ts -t "hybrid search"`
prints 16 passed (8 cases on `:memory:` and on a `file:` URL).

## Tests

<details><summary>New pins (turso: acceptance.test.ts, top-level
describe; pgvector: acceptance.live-postgres.test.ts, top-level
describe)</summary>

- An exact code in a question: the fixture asserts the vector leg alone
ranks the code's passage 7th of 7; the hybrid search returns it within
topK = 3; the code alone answers it first with score 1 (both legs). Both
stores.
- 「出差」 (2 characters) and 「住宿标准」 (inside an unsplit run) hit: turso by
LIKE and the trigram index, score 1; pgvector by ILIKE, score 0.5 (the
fake embedder holds a Han run as one word, so only the keyword leg ranks
them).
- The organization filter, a record scope and the metadata filter each
exclude an out-of-scope passage that holds the query's code and short
term, while the in-scope keyword match still ranks. Both stores.
- turso: every query string tried as FTS5 syntax (`X-200`, `"A"`,
`NEAR(the`, `OR`, `* pump^2`, `col:umn`, `-x`, `a AND b NOT c`) answers;
the keyword index follows a rewrite, a delete, a generation swap and
`dropSource`; a table without a keyword index gets one at its first
search, 7 map rows from 7 passages, and stays in step after; an object
table under `TABLE-kw` refuses the build, naming it, and keeps its row.
- pgvector: the GIN index dropped, a new adapter's first search rebuilds
it and answers; with sequential scans priced out the plan names the
index.
- turso: the term splitter, the LIKE escape and the FTS5 phrase quoting,
as a unit.
</details>

<details><summary>Readings (head d0340b7 for both suites; ablations
on b2d204a before the merge of main, which touched no knowledge
package)</summary>

- `knowledge-turso` `vitest run --maxWorkers=2`: Test Files 4 passed
(4), Tests 201 passed (201).
- `knowledge-pgvector` `vitest run --maxWorkers=2` against a private
PostgreSQL 16 with pgvector (UTF8 database): Test Files 8 passed, Tests
96 passed; `reconcile-purge` and `reindex-real-driver` did not load
(`@objectstack/metadata-protocol` / `@objectstack/objectql` unbuilt
here) — NOT MEASURED locally; neither file calls `search`.
- Ablations, each a mutation on disk, the pin run, restored from HEAD,
the pins green again (turso 16/16, pgvector 4/4):
- keyword leg off (`terms = []`): exact-code pin red in both stores,
"expected [ …(3) ] to include 'Seal kit for model X-200, part 7731.'".
- LIKE fallback off (terms under 3 characters dropped): 2-character pin
red, turso "expected 0.5 to be 1", pgvector "expected [] to deeply equal
[ [ 'zh_short:1', 0.5 ] ]".
- filter dropped from the keyword leg only: scope pin red in both
stores, "expected [ 'kw_scope:out' ] to deeply equal []".
</details>

## Acceptance notes

- **BrightRule eval set: NOT MEASURED.** The `objectstack-ai/brightrule`
repository is not attached to this session (the API answers 403, access
not enabled), and the eval needs a real embedding provider. RRF reorders
the vector leg's results whenever the keyword leg ranks something, so
this is the reading that would show a regression; it belongs to whoever
runs that eval next.
- **Score semantics changed.** `KnowledgeHit.score` from these two
stores is the normalized fused rank, no longer the cosine similarity.
The knowledge service sorts hits across sources by score, so a
deployment mixing these stores with another adapter now compares a fused
rank with that adapter's score. No threshold on `score` exists in the
service today.
- **Cost.** A LIKE or ILIKE term scans the rows in scope (the vector leg
is already an exact scan). In pgvector a common word makes most rows
candidates, and each candidate's tsvector is computed once for the
per-term counts. No CJK word segmentation: a Chinese question without
spaces or punctuation is one term, so the keyword leg finds a code, a
name or a phrase as written and the vector leg answers the meaning.
- **turso uses `ln()`**, an SQLite math function: present in the libSQL
client build (SQLite 3.45.1, measured); a remote Turso server is not
measured.
- **pgvector's first-search index build** blocks writes to that width's
table while `CREATE INDEX` runs, once.

## Verification

<details><summary>Local gate families (dispatch-gates --commands on
d0340b7; lock saturated, so run outside it as check gates
are)</summary>

- 99 derived commands run once each; exit codes captured before any
pipe: 91 exit 0; 7 exit 3 PREREQUISITE NOT MET
(`check:doc-formula-expressions`, `check:doc-security-posture`, spec
`check:skill-examples`, `check:docs-transcript-drift`,
`check:dual-build-cjs-loads`, `check:lean-entry-closure` — each "run a
build first"); `spec check:docs` exit 1 "packages/spec/json-schema is
missing" (a missing generated tree, also nothing measured). These 8 are
NOT MEASURED locally; CI runs them on a built tree.
- `dispatch-gates --ran`: "99 derived famil(ies) accounted for".
- `overlap-check`: VERDICT clean exit 0 against origin/main and the
three open PRs sharing the docs files (objectstack-ai#38026, objectstack-ai#37982, objectstack-ai#37963).
- Typecheck: the packages' own `typecheck` needs the dependency closure
built, and the build never got the verify lock (queued about an hour
behind a dogfood holder) — NOT MEASURED through the package script.
Narrowed instead: `tsc -p` over each package's test config with `paths`
to the workspace sources: knowledge-turso 0 errors; knowledge-pgvector 2
errors, both "Cannot find module '@objectstack/objectql'" in the two
unloaded test files.
</details>

---

_Generated by [Claude
Code](https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…e — a save does not wait for the embedder, a failed sync is retried, a rolled-back write is never indexed (objectstack-ai#38043)

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

Clause-②: yes (widening) — `KnowledgeServicePluginOptions` gains the
optional `recordSyncRetry`; `KnowledgeService` gains `routeRecordSyncs`,
`recordSyncQueued`, `enqueueRecordSync` and `processRecordSync`; the
package exports `KNOWLEDGE_RECORD_SYNC_QUEUE`,
`RECORD_SYNC_RETRY_DEFAULTS` and the `KnowledgeRecordSync*` types
Metadata-protocol: none

## 维护者速读
-
用户能看到什么变化:保存一条被知识库收录的记录时,不再卡在向量模型上等待,保存立刻返回,几秒后检索才查到新内容;向量模型短暂故障时,同步会自动重试,不再永久丢失。
- 为什么做:知识库检索的可靠性(替接手的旧卡一并解决),保存被向量模型拖慢、同步失败不重试、回滚的写入被收录进索引,这三个问题一次修掉。
-
出错会怎样:最坏是某条记录的检索结果暂时停在旧版本,直到下一次保存、检索发现过期或每日对账把它修好;保存本身不受影响,撤回这次改动即恢复原来的同步方式。
- 要你做什么:无。

## What changes

A record change of an indexed object no longer syncs its document inside
the write. Where the kernel composes a durable `queue` service
(`QueueServicePlugin` over a data engine) and a data engine is bound,
both triggers publish to the `knowledge-record-sync` queue:
- the realtime `knowledge-event-sync` subscription;
- the after-write hooks used on a kernel with no realtime service.

A worker, subscribed in `kernel:ready`, re-reads the row and writes or
removes the document. Everything else keeps the inline path and says so
once at boot at `warn`:
- the kernel's in-memory fallback queue;
- a queue with no `listFailed`;
- no data engine.

`enableEventSync: false` and `refresh.onRecordChange: false` are
unchanged: they publish nothing.

- **The message carries identifiers only:** `{ source, object, recordId,
reason }`, where the reason is `event` or `freshness`. It never carries
a field value. The test reads the stored `sys_job_queue` row.
- **How commit ordering works:** the message is published after the
commit, through ObjectQL's `runAfterOpenUnitsCommit`. It goes out once
the open unit commits (the write's own unit or a caller's
`engine.transaction()`) and is dropped on rollback. With no unit open it
goes out at once. I did not use the other approach (the queue row
joining the write's unit), and no engine change was needed.
- **Rows per save:** one queue row per source per save, with no
`idempotencyKey`. `DbQueueAdapter` suppresses a keyed publish while a
message is pending or running, and for 24 h after it completes. A key
per document would therefore drop a save made while that record's sync
runs, and every save of it for a day after. Each worker run re-reads the
row, so the last committed version wins. `IQueueService` and
`DbQueueAdapter` are unchanged.
- **Retry, then dead letter:** the worker throws on failure, including
when the source's adapter is not mounted. The queue retries on
`recordSyncRetry`: by default 8 attempts, 5 s doubling to a 2 min cap.
The message then becomes a `listFailed` dead letter that names the
source and record, logged once at `error`.
- **Outcomes that are not retried:** a source that is gone, a source no
longer indexing the object, and a malformed message all complete with no
write.
- **The freshness repair goes through the queue:** when a search finds a
document stale, `repairStale` now publishes a `freshness` message
instead of starting an un-awaited inline sync.
- **Who adopts whose seam:** objectstack-ai#37963 touches this freshness path. If this
PR lands first, objectstack-ai#37963 adopts this seam (the queued `freshness` message
in `repairStale`). If objectstack-ai#37963 lands first, this branch merges main and
adopts its seam.
- **Docs:** `content/docs/protocol/knowledge.mdx` gains "Through the
queue" and "Without a durable queue".
`content/docs/ai/knowledge-rag.mdx`, the README and a changeset are
updated too.

## Tests

`src/__tests__/record-sync-queue.test.ts` is new. It boots a real
`ObjectKernel` with `ObjectQLPlugin`, `SqlDriver` (a better-sqlite3
file), `QueueServicePlugin({ adapter: 'db' })` and
`KnowledgeServicePlugin`. Every queue-path case runs once per trigger
(realtime, and the hooks).

The queue-path cases cover:
- a save returns while the embedder is held;
- the queue row holds identifiers only;
- retry, then dead letter;
- nothing is processed inside a caller's `engine.transaction()`;
- a rolled-back insert leaves no document and no row;
- a rolled-back update leaves the committed row indexed;
- a burst of 3 saves gives 3 rows and the last version wins;
- a save after a completed sync is synced;
- a delete, including member and record-granularity searches before the
message is processed;
- a source that is gone.

Further cases:
- nothing is published before the write's own unit commits;
- an `afterInsert` hook that aborts the write's own unit publishes
nothing;
- messages published before a restart are processed after it;
- the freshness message;
- the fallback `warn` and inline sync, plus both switches;
- `destroy()` leaves the message pending.

**Re-land head 5d430ea** (after the merge-queue drop: objectstack-ai#38026 made
`source.adapter` optional, so `processRecordSync` now resolves through
main's `adapterFor(source)`; cause and fix in comment 7229116666). One
locked batch, lock `VERDICT command-exit 0`:
- `turbo build --filter='@objectstack/service-knowledge^...'`: 19 of 19
tasks; `pnpm --filter @objectstack/service-knowledge build`: CJS, ESM
and DTS build success (the build that failed in the queue);
- `pnpm --filter @objectstack/service-knowledge typecheck`:
`check:test-typecheck: OK`;
- `vitest run --maxWorkers=2`: 19 of 19 files, 605 of 605 tests,
including the new pin (a source with no `adapter` syncs through the
queue to the deployment's store, on both triggers);
- NOT MEASURED on this head: an ablation of the new pin (lock saturated
by dogfood holders).

Earlier readings, on head 43dc682 unless noted (all under
`os-verify-lock`):
- `pnpm --filter @objectstack/service-knowledge exec vitest run
--maxWorkers=2`: 19 of 19 files and 593 of 593 tests pass (on merge head
640b356; the one later commit changes only docs and the changeset);
- `pnpm --filter @objectstack/service-knowledge typecheck`:
`check:test-typecheck: OK`.

<details><summary>Ablations (mutated on disk, test file re-run, restored
with git checkout; tests run from source, so no rebuild)</summary>

- enqueue-not-sync (both triggers forced to the inline path): 24 failed.
- rollback-not-indexed (`runAfterOpenUnitsCommit` removed, publish at
once): 4 failed. They are the rolled-back insert (both triggers), the
own-unit test and the own-unit abort. The caller-transaction case stayed
green under this mutation, because on SQLite's single connection the
poller cannot read inside an open transaction. The rollback cases are
the pin for the deferral.
- burst-keeps-last (`idempotencyKey` = source:object:recordId): 9
failed, including the burst, after-completed and delete cases.
- no-field-value-in-message (the row's `title` added to the message on
both triggers): 2 failed (the identifiers-only case for each trigger).
- fallback-inline-warn: two mutations were run.
  - The boot `warn` dropped: 2 failed.
  - A degraded queue or one with no `listFailed` accepted: 2 failed.

</details>

## Acceptance notes

- `MemoryQueueAdapter` (`adapter: 'memory'`) carries no `degraded` label
and has no `listFailed`. It is refused through the `listFailed`
condition, so it takes the inline path with the boot warn.
- **Cross-node race:** in-process serialization (`chainAfter` per
document) orders two runs on one node. Two nodes processing two messages
for one record are not ordered against each other. Each run re-reads the
row, so the last run to finish writes what it read. A save committing
between one node's read and another's write can leave an older version
until the next save, a freshness hit or the reconcile.
- **Distributed realtime adapter:** the realtime trigger relies on the
in-process publish running inside the write (so
`runAfterOpenUnitsCommit` sees the open unit). A realtime adapter that
delivers out of process would publish with no unit open, that is at
once. That is still after the write returned, but not ordered against a
caller's transaction. No such adapter ships today.
- **A system-identity search at chunk granularity** re-reads nothing. It
can answer a deleted record's chunks until the delete's message is
processed. Member searches and `granularity: 'record'` searches do not;
the docs now say so.
- The standard runtime mounts `queue` on every preset except `minimal`.
Under `minimal` the sync takes the inline path with the warn.

## Verification

Two-minute check:

```bash
pnpm --filter @objectstack/service-knowledge exec vitest run --maxWorkers=2 src/__tests__/record-sync-queue.test.ts
```

Expected result: 33 of 33 tests pass.

Read first (by risk):
1. `knowledge-service.ts`: `publishRecordSyncs` (the commit deferral)
and `processRecordSync` (what is retried and what completes).
2. `knowledge-service-plugin.ts`: `startRecordSyncQueue` (the queue
resolution, the fallback warn and the dead-letter line).
3. `knowledge-record-sync-queue.ts`: `recordSyncPublishOptions` (why
there is no idempotency key).

<details><summary>Local gate subset</summary>

`dispatch-gates --commands --repo objectstack-ai/objectstack` derived
119 families. The `--ran` reconciliation reads: 115 run, 3 NOT MEASURED,
1 unrun.

- **Passed:** 113 exit 0.
- **NOT MEASURED, prerequisite** (exit 3, this worktree has no full
build): `check:skill-examples`, `check:dual-build-cjs-loads`,
`check:published-readme-exports`.
- For `check:published-readme-exports`, I confirmed the one new README
import (`QueueServicePlugin` from `@objectstack/service-queue`) by hand
against `service-queue/dist/index.d.ts`.
- **Exit 1 from local build state, not from this diff:**
- `@objectstack/spec check:docs`: `packages/spec/json-schema` is older
than `src`. This branch touches nothing in spec.
- `check:dts-closure`: `packages/rest/dist` has no `.d.ts`. This branch
does not touch rest; the partial dist likely comes from a build I
stopped earlier.
- **Unrun, NOT MEASURED:** `check:type-check-debt`, because it builds
every package under the shared lock.
- **Re-run on 43dc682:** the 39 doc and changeset families, all exit
0.

CI measures the full set.

`overlap-check` on 5d430ea: `VERDICT clean exit 0` against main and
the open PRs, including objectstack-ai#37963, objectstack-ai#38013 and objectstack-ai#37982. Earlier, on
43dc682: `VERDICT clean exit 0` against main and 6 open PRs (objectstack-ai#38038,
objectstack-ai#38037, objectstack-ai#38032, objectstack-ai#38026, objectstack-ai#37982, objectstack-ai#37963).

</details>

---

_Generated by [Claude
Code](https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…ipped vs run-time mount, package-scoped identity) (objectstack-ai#38053)

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

Part of objectstack-ai#37310

Clause-②: no
Metadata-protocol: none

## 维护者速读

- 用户能看到什么变化:用 AI(技能文档或 MCP 搭建)写知识源的作者,现在看到的是新写法:知识源是一份元数据,用
`name`、逐个列出要索引的字段、可以不写存储;MCP
新建知识源暂不提供起始模板(模板里的占位对象和字段会被当成真实值存进去),等设置页表单从作者输入构建 `source` 后再加。
- 为什么做:知识库检索专题(按调用者权限过滤的知识检索)第三阶段的教学一行,替照着技能写知识源的 AI 解决"照文档写出来却被拒绝"的问题。
- 出错会怎样:最坏是技能里某句教法不准,AI 写出的知识源在保存时被明确拒绝并给出修法;不会悄悄索引错的字段;改动可直接撤回。
- 要你做什么:合并(技能文档是受治理面,由你亲手落地);本 PR
只完成卡片的一部分:发布校验的五条规则名要等对应的校验改动(objectstack-ai#37971)合并后再补,新建模板要等设置页表单,所以卡片保持打开。

## What changes

**`skills/objectstack-ai/SKILL.md`, § Knowledge Sources (RAG)**
(ADR-0161 K4, K5, K6 item 6; rows 3a and 3b as merged):

- A source is a `knowledge_source` item: shipped in a package
(`knowledgeSources`, `*.knowledge-source.ts` / `.yml`) or authored in
Studio or over MCP. `KnowledgeServicePlugin({ sources })` and
`registerSource` are a second door for the same schema, and a code
registration and an environment item of one name are one slot, the
second refused. A source's identity is its package and `name`:
`search_knowledge` lists a package's source as `NAMESPACE-NAME` (bare
for a source no package holds). A shipped item (a `knowledgeSources`
entry) mounts the knowledge service and its store with no `requires:
['knowledge']` (objectstack-ai#37306, PR objectstack-ai#38026); an app that ships no source and
authors its sources at run time needs `requires: ['knowledge']`, or its
items are never indexed (as main's `knowledge-rag.mdx` § Turning it on
says).
- The key table is the v1 keys of K4: `name`, `label` / `description`,
`adapter` (optional; omitted ⇒ the deployment's store, else the only one
registered, refused naming them when several and none is the
deployment's), `source.kind`, `source.object`, `source.content` (an
explicit non-empty list; why `'*'` is refused: embedding is egress, K5),
`source.metadataFields`, `source.where`, `source.split`,
`refresh.onRecordChange`, `aiExposed`. The old Hygiene column's advice
(meaningful text only, never ids or system fields; `where` keeps drafts
out) now lives in the `content` and `where` rows, and says `content`.
- Egress and cost (K4): the first build sends every listed field of
every matching record to the embedding provider; a run-time save needs
`manage_knowledge_sources` beside `manage_metadata` and passes save-time
admission.
- The retired keys by name, each with its fix, as the tombstones read:
`id` → `name`, `contentFields` → `content`, `embedding`, `vectorStore`,
`adapterConfig`, `refresh.cron`, and the `file` / `http` arms with their
four keys; `os migrate meta --from 18` for a stack, by hand for a
registration in code.
- The checked example drops `adapter: 'pgvector'` (the deployment's
store) and its comments; it is otherwise row 3a's block.
- `split`: `strategy` is required once `split` is written (`recursive`
only when `split` is omitted); the adapter-list aside is gone.
- The closing note: `topK` is a `search_knowledge` argument; rerank and
hybrid weighting are no source key, and no shipped store has a setting
for either (`knowledge-pgvector` and `knowledge-turso` fuse their legs
by RRF with a fixed `RRF_K = 60`, `pgvector-adapter.ts:124`,
`turso-adapter.ts:95`; no store plugin's options interface has a rerank,
weight or fusion key).
- The routing line in `skills/objectstack-mcp-build/SKILL.md` ("An agent
skill, tool or knowledge source | objectstack-ai") stays true: the
section name is unchanged, so it is not edited.

**Not in this PR, on purpose (amendments 7221575164 and 7224082428):**
the five `os validate` / publish rule ids of PR objectstack-ai#37971
(`knowledge-source-object-unknown`, `knowledge-source-field-unknown`,
`knowledge-source-object-not-searchable`,
`knowledge-source-system-object-not-ai-readable`,
`knowledge-source-field-never-indexed`). objectstack-ai#37971 is still open, so this
PR is `Part of objectstack-ai#37310`: that part follows on this branch after objectstack-ai#37971
lands (the keyword then returns to `Fixes`), or on a later PR if this
one lands first. The create seed is also left open: it waits for the
Studio form (objectstack-ai#37309, row 5).

**`skills/objectstack-ai/evals/skills-tools-knowledge.json`.** Case 3
(kb_article on PostgreSQL) and case 9 (policy_doc, `markdown` split) now
expect `name` and `content`, and forbid a written `contentFields:` key;
case 3 also forbids a written wildcard (`['*'],`, `['*'] }`),
`embedding:` and `vectorStore:`, and its `topK` token becomes `topK:`
(the key written) because the skill now names `topK` as a search
argument. Case 9 also requires `name:` and forbids an `id:` spelling;
case 13 forbids the double-quoted wildcard forms. New case 14 asks for
an app that ships no source and authors one at run time, and requires
the `requires: ['knowledge']` line (either quote style), with no
`contentFields:`. New case 13 asks for a source that indexes "every text
field" and expects an explicit list, the wildcard declined because
embedding is egress, and no written `contentFields:` or wildcard.

**`packages/spec/src/kernel/metadata-create-seeds.ts`: unchanged
(byte-identical to `main`).** A `knowledge_source` create seed was tried
and withdrawn at `4c965f4a5e` (comment 7229668414). Its object binding
and content list sit inside `source`, and the Studio create flow
(`buildCreateModeBody` / `seedPlaceholderKeys` in app-shell's
`createBody.ts`) clears placeholder identity at the top level only, so
it would have saved `example_object` / `example_field` into a new
source: the objectui#12810 defect. No schema-valid seed avoids this,
because `source.object` and a non-empty `content` (K5) are required and
nested. `knowledge_source` stays on `KNOWN_UNSEEDED`, whose comment now
gives the reason: a seed waits until the Studio form (objectstack-ai#37309, row 5)
builds `source` from the author's input. The card allows this ("or the
type stays on `KNOWN_UNSEEDED` with the reason").

**`packages/runtime/src/domains/mcp-authoring.test.ts`.** One case
beside the flow contract case, over the real protocol and the boot type
registry: `list_metadata_items` with `contract: true` for
`knowledge_source` serves no `createSeed`; `contractPath`
`/properties/source/properties/content` serves the content rule
(`minItems: 1`, `minLength: 1`, a pattern that refuses `*` and admits
`body`); the served schema carries no `id` or `contentFields` tombstone;
a hand-written source with one object and one field saves as a draft;
the same item with `content: ['*']`, with an `id`, or with
`contentFields` is refused `422 INVALID_METADATA`, the last two naming
their tombstone's prescription ("use `name`", "use `content`"); nothing
else is written.

**Platform catalog (review round, `6f2e756f58`).** The generator's Boot
cell (`packages/spec/scripts/lib/platform-catalog.ts`) reads ``on
`requires`, or a shipped `knowledgeSources` item`` for a provider that
declares `mountedBy`; `packages/spec/scripts/platform-catalog.test.ts`
pins that cell, with `record-context` as the control that still reads
``on `requires` ``.
`skills/objectstack-project/references/platform-catalog.md` is
regenerated.

**Token ratchet.** The standing ruling, verbatim and untranslated:
「A:先削重复,余额按实测提高」 (ruling record 6513306068, letter B). Paid down first,
in the same file: the wiring paragraph's package list, the old
`source.kind` Hygiene column (folded into two rows), the example's four
comments restating table rows and its `refresh: { onRecordChange: true
}` line restating the default, and the split passage's adapter aside.
The row moves 6609 → 6639, the measured remainder, pinned at the
measurement. Review round (`6f2e756f58`): after paying down the intro's
restating clause, its separate `search_knowledge` sentence, the "one
name is one source" clause and the longer closing note, the row moves
6639 → 6695 (+56, the measured remainder) under the same ruling.
Reproduction: `ceil(($(wc -c < skills/objectstack-ai/SKILL.md) - 27) /
4)` = ceil(26779 / 4) = 6695.

## Tests

**Review round at `6f2e756f58`** (merges `main` at `58be6770ab`; note
7230668192): unlocked, 35 commands, each exit 0, including
`check-skills-token-ratchet` (row 6695), `check:nul-bytes`,
`check-empty-changeset`, `check-adr-0087-registration`,
`check-changeset-no-major`, `check:issue-citations`,
`check:doc-authoring`, `check:skill-links`,
`check:skill-identifier-liveness`, `check:skill-frame-sync`,
`check:published-files`; `gen:skill-refs` exit 0. NOT MEASURED locally
(verify lock never acquired in six tries): `check:skill-docs`,
`check:skill-refs`, `check:yaml-examples`, the platform-catalog test,
`metadata-create-seeds.test.ts`, the MCP contract case, eval case 14. CI
on this head is the reading for them. overlap-check: `VERDICT overlap
exit 1`, the same objectstack-ai#36158-against-main conflict in the ratchet file;
`origin/main`, objectstack-ai#38032 and objectstack-ai#38013 merge cleanly.

The lock was saturated: about 70 minutes of queueing, two dogfood runs
ahead. One locked round ran at `3407f7fe6e`; the second round was not
reached. What was not measured locally is marked below, and CI runs it.

<details><summary>Locked round at 3407f7f (VERDICT command-exit 0,
held 365s)</summary>

- `pnpm turbo run build --filter='@objectstack/runtime^...'
--concurrency=2`: exit 0, `Tasks: 41 successful, 41 total`.
- `metadata-create-seeds.test.ts` (spec): the seed pin run here (`Tests
20 passed (20)`) belonged to the withdrawn seed; the file is back to
`main`'s, so CI `Test Core` is the reading. **Patch round at
`4c965f4a5e`:** the app-shell
`createBody.seedPlaceholders-12810.test.ts` (red at `19f3e118f2`, 2
failures, unedited), the spec create-seeds test and the rewritten MCP
case are NOT MEASURED locally (verify lock saturated); their inputs
equal `main`'s, so CI `Test UI` and `Test Core` on this head are the
evidence. Unlocked gates at `4c965f4a5e`, exit 0 each:
`check-skills-token-ratchet` (6639/6639), `check-empty-changeset`,
`check-adr-0087-registration`, `check-changeset-no-major`,
`check:nul-bytes`, `check:issue-citations`, `check:doc-authoring`. The
changeset no longer lists `@objectstack/spec`.
- `pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2
src/domains/mcp-authoring.test.ts`: exit 1, `Tests 1 failed | 73 passed
(74)`. The failing assertion is the new case's tombstone half: it
expected the served schema to carry `/properties/id`, and the served
schema drops tombstones (see Acceptance notes). Its content-rule and
seed assertions, which run before it, passed. The tombstone half is
rewritten in `01cf7515c2` to assert absence plus the save refusal. **NOT
MEASURED locally after that rewrite** (the second locked round never
acquired); CI `Test Core` runs it.
- `pnpm --filter @objectstack/spec run check:yaml-examples`: exit 0, `19
tagged YAML example(s) across 1 file(s) validate`.
- `pnpm --filter @objectstack/spec run check:skill-docs`: exit 0, `Skill
docs in sync`.
- `pnpm --filter @objectstack/spec run check:skill-refs`: exit 0, `10
generated files in sync with packages/spec`. The generated skill
references needed no regeneration: the section rewrite changes no
reference input.
- `pnpm --filter @objectstack/spec typecheck`: exit 0.
- `pnpm --filter @objectstack/runtime typecheck`: exit 1. `tsc --noEmit`
is clean. `check:test-typecheck` names 3 files this diff does not touch
(`boolean-written-spelling-row-scope.test.ts`,
`meta-object-publish-column-changes.test.ts`,
`organization-ownership-boot-guard.turso-remote.kernel.test.ts`).
`mcp-authoring.test.ts` is not among them. They are read here as the
closure build's gaps (only `runtime^...` was built) and not as this
diff's; CI `TypeScript Type Check` decides.
- `pnpm --filter @objectstack/spec run check:skill-examples`: exit 3,
PREREQUISITE NOT MET (the `@objectstack/client-react` dist is outside
the built closure). **NOT MEASURED**; CI runs it.

</details>

<details><summary>Unlocked gates (35 derived families, each exit 0, at
3407f7f; the ratchet and nul-bytes re-run at 19f3e11)</summary>

- `node scripts/check-skills-token-ratchet.mjs`: exit 0,
`skills/objectstack-ai/SKILL.md is 6639 tokens (ceiling 6639; headroom
0)`; with `--self-test` exit 0.
- Exit 0 each: `check-adr-0087-registration` (both forms),
`check-changeset-no-major`, `check-closing-keyword-parity` (both),
`check-declaration-mirrors` (both), `check-empty-changeset` (both),
`check-issue-citations`, `check-self-test-wired` (both),
`docs-audit/check-affected-docs`, `docs-audit/check-drift-comment`, and
`pnpm check:` `agent-test-spelling`, `changeset-gate-self-tests`,
`closed-ceremony-text`, `corpus-claim-drift`,
`cross-package-test-inputs`, `doc-authoring`, `issue-citations`,
`keyed-text-bounds`, `nul-bytes`, `pm-skill-id-lint`, `published-files`,
`ratchet-remedy-authority`, `role-word`, `skill-compatibility`,
`skill-frame-sync`, `skill-identifier-liveness`, `skill-links`,
`test-source-alias`, `tier-file-adoption`.
- `dispatch-gates --ran`: `116 derived, 38 run, 0 NOT-MEASURED, 78
UNRUN`. That is a declared narrowing: the lock was saturated, and CI
runs the 78.
- Local-only: `check-skill-frame-freshness` exit 0. `check-dev-prereqs`
exit 1 ("69 of 110 workspace packages … not on disk"), which is the
closure-only build and not a finding.

</details>

<details><summary>Eval runner and the ablation (`skill-evals`,
claude-code-cli 2.1.332, oauth login, served claude-opus-5-5)</summary>

Cases 3, 9 and 13 of `objectstack-ai/skills-tools-knowledge`, both arms,
one repeat each:

| skill text | objectstack-ai#3 with-skill | objectstack-ai#9 with-skill | objectstack-ai#13 with-skill | no-skill
(all three) |
|:--|:--|:--|:--|:--|
| this PR | pass | pass | pass | fail |
| `main`'s `SKILL.md` (`8d34c4404f`, hash `88a20cb583`), new cases
(ablation) | fail: `contentFields:` written; `name:`, `content:` missing
| fail: `contentFields:` written; `content:` missing | fail:
`contentFields:`, `['*'],` and `id: 'faq` written; no egress reason |
fail |

The ablation restored `main`'s `SKILL.md` into the working tree only
(`git restore --source=8d34c4404f`, `git hash-object` = `88a20cb583`).
The run ran, and then `HEAD`'s file came back (`fc845724ac` both on disk
and at `HEAD`). An earlier run of case 13 on this text failed with-skill
only on the token `['*']`, which a correct answer quoted while
explaining the refusal. The forbidden token is now the written wildcard
(`['*'],` / `['*'] }`), and the table above is after that change.

</details>

## Acceptance notes

- The acceptance grep (`git grep -n -E "contentFields|'\*'|adapter:
'ragflow'" skills/objectstack-ai`) returns eight lines. In `SKILL.md`,
three: the `content` row ("`'*'` is refused") and two lines of the
retired-keys paragraph. In the eval file, five: the reference answers of
cases 3 and 13, which name both as retired, and the `must_not_contain`
lists of cases 3, 9 and 13, which forbid a written `contentFields:` and
a written wildcard (`['*'],`, `['*'] }`). The card itself asks the eval
to fail on `contentFields` or `'*'`, which puts the forbidden token on
the assertion line. The reviewer decides whether those lines count as
"naming a retired key as retired".
- `adapter: 'ragflow'` has no hit: objectstack-ai#37004 already removed it.
- The new MCP pin is an `it` inside the existing real-protocol
`describe` of `mcp-authoring.test.ts`, beside the flow contract case,
because that describe holds the real-protocol harness (`realProtocol`,
`STUDIO_BASE`). It is in the shared harness file, not a new file.
- **Premise correction (card item 3).** The card asks the served
contract to carry "the tombstones' prescriptions as the describes read".
It does not, by design: the served JSON Schema drops every
`retiredKey()` tombstone (`{ not: {} }`; see the note in
`packages/metadata-protocol/src/protocol-meta-type-schema.ts`: the
served schema publishes what an author MAY write). The prescription
reaches an MCP author through the save refusal instead. The pin asserts
both halves: the tombstone is absent from the served schema, and a save
that writes the retired key is refused naming its replacement.
- The save half of the MCP pin covers row 3a's parse. Row 4's checks
(objectstack-ai#37971) are not on main, so a hand-written draft is not yet judged by
them here. Today the save passes with no knowledge service mounted ("no
knowledge service judges nothing").
- overlap-check before the PR: `VERDICT overlap exit 1`. `origin/main`,
objectstack-ai#38032 and objectstack-ai#38013 merge cleanly. objectstack-ai#36158 (a draft last updated
2026-11-25) conflicts in `scripts/check-skills-token-ratchet.mjs`. That
conflict is objectstack-ai#36158's own against `origin/main`: `git merge-tree
origin/main` with objectstack-ai#36158's head conflicts in the same file, and every
conflict hunk is at line 798 or later, away from this branch's hunk near
line 453. Reported here, not resolved.

## Verification

Files to read first, by risk:
1. `skills/objectstack-ai/SKILL.md` § Knowledge Sources (RAG): the
`adapter` and `content` rows and the retired-keys paragraph.
2. `packages/spec/src/kernel/metadata-create-seeds.test.ts`: the
`KNOWN_UNSEEDED` reason for `knowledge_source` (no seed;
`metadata-create-seeds.ts` is byte-identical to `main`).
3. `packages/runtime/src/domains/mcp-authoring.test.ts`: the new
contract case.

Two-minute check: `node scripts/check-skills-token-ratchet.mjs`. Expect
`skills/objectstack-ai/SKILL.md is 6695 tokens (ceiling 6695; headroom
0)`.

Readings: `skills/objectstack-ai/SKILL.md` 464 → 469 lines, 26462 →
26806 bytes (6609 → 6695 priced tokens, in two moves). Every published
`SKILL.md` summed: 4936 → 4941 lines, 261366 → 261485 bytes (65342 →
65372 tokens). The eval file is 125 → 137 lines and 13611 → 15185 bytes;
eval fixtures are measured, not ratcheted.

---

_Generated by [Claude
Code](https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…t that mounts the knowledge service (objectstack-ai#38013)

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

Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: skills/objectstack-ai/SKILL.md § Knowledge Sources (RAG) —
the run-time clause now says that where an app ships no source, a
run-time save is refused (`503 SERVICE_UNAVAILABLE`, nothing written)
until the stack declares `requires: ['knowledge']` and the server
restarts (it said such items are never indexed); the matching eval case
in `skills/objectstack-ai/evals/skills-tools-knowledge.json` expects the
same; the token-ratchet row moves 6893 → 6906 under ruling record
6513306068, letter B

## 维护者速读

-
作者在没装知识服务的部署上,通过工作台、元数据接口或智能体工具保存知识源时,会当场失败并看到原因和修法(先在应用配置里声明需要知识服务并重启,再保存);以前这种保存显示成功却永远不生效。
- 属于知识库检索这条线,执行您选的方案 D:让作者在保存那一刻就知道,而不是只在看不到的服务器日志里。
-
只影响在这类部署上保存知识源的作者;在这类部署上复制一个含知识源的整个应用包也会被拒、什么都不复制(这是裁决点名的三处之外的第四处,请批准前读下方的待定问题一节);装包、种子数据、迁移照常通过;出问题可整单撤回。
- 要你做的:批准这次收窄(按审批流程)。

## What changes

Ruling D (maintainer, recorded on objectstack-ai#37983, comment 7220511579) is
implemented in the one predicate every save door asks,
`authoredKnowledgeSourceRefusal`
(`packages/metadata-core/src/knowledge-source-save-admission.ts`):

- **No knowledge service registered + a non-system writer ⇒ refused.**
`resolveKnowledgeService()` answering `undefined` (or `null`) used to
admit the save; it now answers `503 SERVICE_UNAVAILABLE` with a message
that names the item, the reason and the remedy in order: add `requires:
['knowledge']` to the stack (or, on a host that composes its own kernel,
`KnowledgeServicePlugin` and a knowledge store), restart, then save the
source again. Nothing is written.
- **Held as ruled:** the engine's own write (`isSystem`: package
install, seed, migration) is never refused (the `isSystem` check still
runs before the service is resolved); a REGISTERED knowledge service
with no `admitAuthoredSource` (not the platform's, for example
host-mounted) keeps today's accept. The module doc (`:33-34` on main)
now says both, and gains a section on the no-service case.
- **Doors.** No door code changed shape: `PUT /meta/:type/:name` in
`packages/rest` passes `refused.code` through for a non-403
(`SERVICE_UNAVAILABLE`), the runtime dispatcher `PUT` derives
`SERVICE_UNAVAILABLE` from `503`, and the MCP `save_metadata_draft`
passes `refused.code` through for a non-403 (on `main` since objectstack-ai#37306).
Only their comments are updated. Each door is pinned.
- **Why `503 SERVICE_UNAVAILABLE`** (ADR-0112 status table,
`STATUS_TO_STANDARD_CODE` in `packages/spec/src/api/errors.zod.ts`): the
save needs a service this deployment does not run. It is the code this
module already answers for a knowledge service that cannot be reached,
and the code the knowledge service answers at index and search for a
source whose store is not mounted (the same kind of composition fact).
It is also the one code all three doors already carry without a door
change. Rejected: `400 VALIDATION_ERROR` (the item is valid; a
validation code sends the author to fix the item), `403` (not a
permission), `501 NOT_IMPLEMENTED` (the meta door's answer for a
protocol with no `saveMetaItem`), `409 RESOURCE_CONFLICT` and `428
PRECONDITION_REQUIRED` (no conflicting resource, no missing request
precondition), and a new ledger code (a contract change the ruling did
not make). The message carries the remedy and does not say "try again".
- **ADR-0087:** `Metadata-protocol: narrowed` owes a registered entry:
`packages/spec/src/migrations/entries/semantic/19.knowledge-source-save-refused-without-knowledge-service.ts`
(notice only, no D2 conversion: the fix is the deployment's composition,
never the item). The changeset carries `registered` with that id.

## Boot line and docs (ruling items 2 and 4), landed after objectstack-ai#37306

Held off this branch until objectstack-ai#37306 merged (PR objectstack-ai#38026, dbe0716); `main`
is now merged in (1ca3a31) and the held commit is re-applied as
33acf12.

- **Boot line** (`packages/objectql/src/knowledge-source-unserved.ts`):
the line for `knowledge_source` items held with no knowledge service now
names the same remedy as the save refusal, from the item-4 patch's
`UNSERVED_REMEDY`: declare `requires: ['knowledge']` and restart (or, on
a host that composes its own kernel, `KnowledgeServicePlugin` and a
knowledge store). Before, it said "add `KnowledgeServicePlugin` and a
knowledge adapter to the composition". Only the boot-line half of that
patch was taken: objectstack-ai#37306 did not touch this file, so `main` still carried
the old text.
- **What objectstack-ai#37306 changed, and what that changes here.** A source the app
ships in `knowledgeSources` now mounts the service by itself, and
`adapter` is optional. So a source saved at run time (Studio, the
metadata API, MCP) is never one that mounts the service, and the remedy
the maintainer ruled (`requires: ['knowledge']`, restart, then save) is
still the one that fixes such a save. The refusal sentence is unchanged.
The docs now also say that a source saved at run time does not mount the
service. The boot-line module doc says that the items it names are ones
the stack does not ship. Main's `knowledge-rag.mdx` already said "the
token is for an app that ships none and authors its sources at run
time", which matches.
- **Docs.** `content/docs/ai/knowledge-rag.mdx`: a bullet beside
"Without a source or the token", plus a clause on the run-time-authoring
bullet. `content/docs/protocol/knowledge.mdx`: the boot-line paragraph
names the remedy (it named the plugin and an adapter), and a paragraph
under "Who may author one" covers the refusal, the duplicate and the
holds. Rewritten against main's merged text, not patched blindly: `git
am --3way` conflicted on `knowledge-rag.mdx`.
- **Changeset:** gains the `@objectstack/objectql` and
`@objectstack/skills` patch lines and their bullets.
- The MCP draft door on `main` now passes `refused.code` through for a
non-403 (objectstack-ai#37306), so this refusal still arrives there as
`SERVICE_UNAVAILABLE`.

## Open question

The package **duplicate** door (`POST /packages/:id/duplicate`) asks the
same predicate for each knowledge source it copies, so on a deployment
with no knowledge service it now refuses a duplicate of a package that
holds one, `503`, naming the remedy (pinned in
`packages-knowledge-source-gate.test.ts`). The ruling names three doors;
this is the fourth door that saves a source as the caller. Keeping it
refused is the predicate's own reading and the ruling's principle (the
copy would be kept and never served); carving it out needs a new input
on an exported function. Recommendation: keep it.

## Tests

- `packages/metadata-core/src/knowledge-source-save-admission.test.ts`:
refusal with code, status, the reason sentence and the ordered remedy,
for both URL spellings and for `undefined`/`null`; an unnamed item;
`isSystem` not refused and the service never resolved; a registered
service without the member still admits.
- REST `PUT`
(`packages/rest/src/meta-write-door-capability-enumeration.test.ts`):
refused on the kernel's branded "never registered" miss and on a server
with no kernel provider; system write saved; host-mounted service saved.
- Runtime dispatcher `PUT`
(`packages/runtime/src/domains/meta-save-capability-gate.test.ts`):
refused on a real `ObjectKernel` with nothing registered; system write
saved; host-mounted service saved.
- MCP `save_metadata_draft`
(`packages/runtime/src/domains/mcp-authoring.test.ts`): refused, nothing
written, another type still saves; host-mounted service saved.
- Package duplicate
(`packages/runtime/src/domains/packages-knowledge-source-gate.test.ts`):
refused, nothing copied; a package with no source and the engine's own
call copy as before.
- Boot line (`packages/objectql/src/knowledge-source-unserved.test.ts`):
names `Declare requires: ['knowledge'] in the stack and restart`.

Head is now `5bc3ee1a00`. Since `33acf12ec4` it adds only: the
test-harness fix `6e4a904ea1` (the MCP `knowledge_source` contract case
from objectstack-ai#38053 mounts an admitting knowledge service; comment 7232197442),
the skills text, eval expectation, ratchet row and changeset line above,
the module-doc wording at index and search, and two clean merges of
`main` (the second carries objectstack-ai#38091). No runtime or rest code moved after
`33acf12ec4`, so the dogfood battery below stands. On `5bc3ee1a00`: the
skills token ratchet exits 0 (6906, headroom 0; self-test 111 cases
pass), `check:skill-docs` and `check:skill-refs` exit 0, and the
changeset, ADR-0087, NUL-byte and issue-citation gates exit 0. After the
harness fix, runtime reads 12315 passed, 0 failed.

Readings at head `33acf12ec4` (main merged in; shared container; every
build and test through `scripts/pm/os-verify-lock.sh`, verdict
`command-exit 0` each round):

<details><summary>Tests and typecheck at 33acf12</summary>

- Full build (`turbo run build`, all but docs) exit 0,
`packages/runtime/.objectstack` cleared, `@objectstack/spec
check:generated` exit 0.
- `@objectstack/metadata-core` `pnpm test`: Tests 1113 passed;
`typecheck` exit 0.
- `@objectstack/objectql` `knowledge-source-unserved.test.ts`: Tests 7
passed; `typecheck` exit 0.
- `@objectstack/rest`, 4 files (door enumeration, type-write capability,
both org-scope suites): Tests 161 passed; `typecheck` exit 0.
- `@objectstack/runtime`, 10 files (dispatcher save gate, MCP authoring,
package knowledge gate, error passthrough, capability parity, org scope,
ensure-customization, publish-drafts x2, package state store): Tests 304
passed; `typecheck` exit 0.
- On the first head, 5 suites that save a `knowledge_source` as a
capable author with no knowledge service went red: that is the ruled
refusal. Their harnesses now mount a knowledge service that admits every
source. Two door-level `isSystem` cases were dropped because inbound
HTTP never carries `isSystem` (`metaTypeWriteRefusal` answers 401
first); that hold is tested at the predicate instead.
- Narrowed locally: the full rest and runtime suites, `test:repo`, and
the derived families not listed under Gates run in CI.

</details>

<details><summary>Ablations (one per tested behaviour)</summary>

- **The save refusal** (at dd50936): `scripts/ablation-replace.mjs`
replaced the one new line (anchor 1 -> 0, marker 0 -> 1).
`@objectstack/metadata-core` was rebuilt, and `ablation-dist-preflight`
found the marker in `dist/index.js` and `dist/index.cjs`. Exactly these
went red: the predicate test (1 of 9), REST `PUT` (1 of 81), and
dispatcher `PUT`, MCP draft save and package duplicate (3 of 162).
Restored with `git checkout HEAD` (blob back to cd26e8f, `git diff
HEAD` empty), rebuilt, and preflight `--absent` was clean.
- **The boot line** (at 33acf12): the remedy was put back to main's
text (anchor 1 -> 0, marker 0 -> 1; the test imports source, so no build
was needed). Red: `names the item, the missing service and both
remedies` (1 of 7). Restored with `git checkout HEAD` (blob aa50e2e,
`git diff HEAD` empty).
- The docs pages are not ablated.

</details>

<details><summary>Live server (REST door, at dd50936)</summary>

After a full build I ran `pnpm dev:crm -- --fresh -p 38937`; the CRM
stack declares `requires: ['ui', 'automation']` and no knowledge. Signed
in as the seeded admin, `PUT /api/v1/meta/knowledge_source/faq` answered
`503`, `error.code` `SERVICE_UNAVAILABLE`, with the remedy sentence. A
`GET` of the item then answered `404`, so nothing was written. The
server was stopped by its recorded pid. A positive control on a stack
with `requires: ['knowledge']` was not run (NOT MEASURED); the unit
tests cover the admitted path.

</details>

<details><summary>Gates at 33acf12</summary>

Local, exit 0 each: `check-adr-0087-registration` (1 declared-breaking
changeset, with its disposition), `check-changeset-no-major`,
`check-empty-changeset`, spec `check:upgrade-guide`,
`check:spec-changes`, `check:api-surface` (unchanged),
`check:nul-bytes`, `check:doc-authoring`, `check-affected-docs`,
`check:issue-citations`, `check:dispatcher-error-vocabulary`,
`check:startup-registry-verdict`, `check:durability-log-level`. At
dd50936 these were also exit 0: `check:authorable-surface`,
`check:route-envelope`, `check:error-status-conformance`,
`check-closing-keyword-parity`, `check:cross-package-test-inputs`,
`check:test-source-alias`, `check:adr-anchors`. `overlap-check` before
the push: clean against `main` and against objectstack-ai#38043, objectstack-ai#37982 and objectstack-ai#37963.

</details>

<details><summary>Dogfood battery at 33acf12</summary>

The full battery, run as CI runs it (no `OS_TEST_SHARD`, no path), under
`scripts/pm/os-verify-lock.sh`. The build was `turbo run build
--filter='@objectstack/dogfood^...'` and exited 0. The test was `pnpm
--filter @objectstack/dogfood test`.

- Verdict: `VERDICT command-exit 0 · held the lock 1727s (28m47s)`, in
shared-box seconds.
- `Test Files  490 passed | 3 skipped (493)`
- `Tests  4144 passed | 68 skipped (4212)`
- Failures: none.

Recorded in comment 7229739676. CI's `Dogfood Regression Gate` on the PR
reads `OS_DOGFOOD_RESULT: skipped` (the shards run in the merge queue),
so it is not evidence for this head.

</details>

## Acceptance notes

- The note on this PR's first head about objectstack-ai#37306's `400 VALIDATION_ERROR`
arriving at the MCP draft door as `SERVICE_UNAVAILABLE` is obsolete:
objectstack-ai#37306 merged with the MCP door passing `refused.code` through.
- Docs Drift Check (comment 7222797378) is receipted here.
`content/docs/ai/knowledge-rag.mdx` and
`content/docs/protocol/knowledge.mdx` are updated on this branch.
`content/docs/permissions/system-context.mdx` row 46 is re-read and
still true: the refusal is not on the `isSystem` path. The other pages
match on the `SERVICE_UNAVAILABLE` literal only and say nothing about
knowledge sources. The release-owned pages are not edited.
- Contract review 7228262724 (PASS) and L1 7228292666 (REWORK: dogfood
battery only) are receipted here. The battery is recorded in comment
7229739676: green, and the head is unchanged. The review's nits N1 to N5
are left for a follow-up card; none of them is changed on this head.

## Verification

Read first (by risk):
`packages/metadata-core/src/knowledge-source-save-admission.ts` (the
`service === undefined || null` branch, before the member check),
`packages/runtime/src/domains/packages-knowledge-source-gate.test.ts`
(the fourth door), `content/docs/protocol/knowledge.mdx` (the two
paragraphs rewritten against objectstack-ai#37306's text).

Two-minute check: `pnpm --filter @objectstack/metadata-core exec vitest
run src/knowledge-source-save-admission.test.ts` — expect the "no
knowledge service registered" cases green; flip line `if (service ===
undefined || service === null) return
noKnowledgeServiceRefusal(input.item);` out and they go red.

Body refreshed 2026-11-28T03:15Z at head `5bc3ee1a00`; the readings in
the three blocks above were taken at `33acf12ec4`.

---

_Generated by [Claude
Code](https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…nd the dropSource cleanup (objectstack-ai#38050)

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

Fixes objectstack-ai#38022

Clause-②: no
Metadata-protocol: none

## 维护者速读

- 升级到 19 的运维读升级表时,会看到「以下划线开头的知识源 id 要改名并清理旧索引」这一例外,不再被告知「索引原样找回」。
- 为 AI 知识库(epic 37000)的 18 到 19 升级文档补上一处与升级条目不一致的说法。
- 只改文档与报错文案,不影响运行行为,可直接撤回。
- 无。

## What changes

- `content/docs/protocol/knowledge.mdx`: the `id` row of the 18 to 19
table names the underscore exception (`name` refuses it, the source is
rebuilt under a new name) and the `dropSource` cleanup, in the words of
the upgrade entry `knowledge-source-registration-governed`. It states
the memory adapter holds nothing across a restart. The row does not
touch `adapter`, which objectstack-ai#38026 made optional (rows and prose near it
re-read on current main; no contradiction).
- N1: the upgrade entry's reason says the adapter keeps the old index
only where its store outlives the process (Turso, pgvector); the memory
adapter holds nothing across a restart.
- N2: the `id` tombstone in `knowledge-source.zod.ts` says the entry's
manual notices still apply after `os migrate meta --from 18`; the
reference page `content/docs/references/ai/knowledge-source.mdx` carries
the same sentence.
- `.changeset/37304-knowledge-source-governed-type.md` is not edited: it
sits in `.changeset/pre/` (consumed by pre mode). A new patch changeset
covers the spec string change.

## Tests

NOT MEASURED: `knowledge-source.test.ts` and
`retired-key-migrate-sentence.test.ts` (the tombstone still ends with
the migrate sentence and still begins with its pinned prefix), because
the verify lock was never acquired in 4 attempts over about 36 minutes
(holder was a dogfood run; VERDICT queue-timeout exit 99).

## Acceptance notes

- NOT MEASURED: `pnpm gen:docs` regeneration (needs the spec build, same
lock). The reference page was edited by one exact-string substitution
mirroring the zod edit; CI `check:generated` is the judge.

<details><summary>Verification</summary>

- check:doc-authoring, check:doc-anchors, check:doc-frontmatter,
check:docs-nav-label, check:docs-image-tag: exit 0.
check:docs-transcript-drift: exit 3, NOT MEASURED (prerequisite).
- overlap-check at d60a6ce: VERDICT clean exit 0 (main, objectstack-ai#38043,
objectstack-ai#38013, objectstack-ai#37963 merge cleanly).
- Two-minute check: open the knowledge protocol page, 18 to 19 table,
`id` row: it names the underscore exception.

</details>

🤖 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 protocol:ai size/l 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: adapter becomes optional (the deployment's store), and a knowledge_source item mounts the knowledge service

2 participants