Skip to content

feat(service-knowledge)!: a knowledge service the runtime mounts holds its sources without an embedder or its deployment store - #38470

Draft
objectstack-fleet[bot] wants to merge 8 commits into
mainfrom
claude/project-thread-mu3i0t
Draft

objectstack-fleet[bot] wants to merge 8 commits into
mainfrom
claude/project-thread-mu3i0t

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Leehom · project thread

Refs #38369

Clause-②: no (narrowing)
Metadata-protocol: narrowed

维护者速读

  • 自托管部署如果没配嵌入模型(或部署的知识存储没挂上),知识源现在只列出、不构建、不同步、不检索,智能体工具里也不再出现 search_knowledge;启动日志说一次缺了哪一半、怎么补。以前这种部署照样启动构建和同步,工具也列出来,但每次构建和检索都报错。
  • 属于知识库检索这条线,执行您对 ADR-0161 dated note: a mounted knowledge service is enabled by configuration; until then its sources are held and not served #38368 的裁决(四点全按推荐 1A 2A 3A 4A)和 ADR-0161 K8 的日期注记"挂载不等于启用"。这是三单中的第一单:先把"不服务"做实;保存时拒绝(第 2 单)和状态/命令行文字(第 3 单)随后各开一单。
  • 只影响运行时自动挂载知识服务、且缺嵌入模型或知识存储的部署;配齐两半的部署、以及宿主自己挂载知识服务的部署行为不变;从不阻止启动;出问题可整单撤回。
  • 要你做的:批准这次收窄(按审批流程)。

What changes

The authority is the ADR-0161 K8 dated note on item 12 (PR #38401, 0c1b2ff), with ruling 7248214179 (amendment 7248231750, points 1–4) and build notes 7248592159 (points 1–4). This PR is part 1 of the three serial PRs the card names: items 1–2, ruling points 2–3, build notes 1, 2 and 4. Part 2 (the save refusal: item 3, points 1 and 4, build note 3) and part 3 (items 4–5) follow from main after this merges.

  • Enabled by configuration, read once at boot (packages/services/service-knowledge/src/knowledge-service-plugin.ts). The capability composition (packages/core/src/capability-composition.ts) now passes runtimeComposed: { declared } beside deploymentAdapter; declared is true only when the stack lists knowledge in requires. With runtimeComposed set, the plugin reads at kernel:bootstrapped, after every store's start() registered its adapter: an embedder is available (another plugin registered one, or the saved ai.embedder_* settings build one) and the deployment's store is mounted (an adapter of deploymentAdapter's id is registered). Both ⇒ the boot goes on as today. Either missing ⇒ held. A plugin a host mounts (no runtimeComposed) is untouched: it serves from the start, as before.
  • Held (packages/services/service-knowledge/src/knowledge-service.ts, KnowledgeService.settleEnablement). Every source, whichever store it names (point 2: an application-registered store too), is loaded and listed, and never built, synced, reconciled or searched: the boot build, the reload build, the reconcile pass and its job, the record sync (enqueue, upsert, delete and the queued worker), the predicate-write note and the unmounted-adapter report all return. A dropped source keeps its index (a warn line says no store is called). search, rebuildSource and reindexSource throw heldSourcesError: status 503, code SERVICE_UNAVAILABLE, and a message naming the missing half and the fix (build note 2).
  • No reap guard and no store call while not enabled (point 3, build note 1). The lifecycle reap guard used to register at kernel:ready, before the reading; the lifecycle service has no unregister. A runtime-composed plugin now registers it only once the reading says enabled. Held, a retention sweep deletes on time and calls no store.
  • One boot line, never a boot refusal (ADR-0078 §4). info when only a shipped knowledge_source mounted the service and nothing was saved; warn when the stack declares requires: ['knowledge'], when a saved embedder provider builds nothing (a provider saved without its key), or when the store is not mounted. The embedder's own boot line is not also said when held.
  • No tool definition while pending or held (KnowledgeService.knowledgeTools() answers definitions: []). HTTP MCP reads the definitions per request, so it lists search_knowledge only once enabled.
  • stdio (packages/mcp/src/plugin.ts, build note 4). The stdio bridge reads the tool in its own start(), before the reading, so a runtime-composed service hands out nothing there. MCPServerPlugin now registers search_knowledge at kernel:listening (after every kernel:bootstrapped handler) only when the service then hands out its definition. Fail-closed: an unknown state reads as absent, never listed and then withdrawn. The MCP SDK takes a tool after the transport attached and sends notifications/tools/list_changed; skill prompts read the served tools at each listing. A host-mounted service's tool still registers in start(), once.
  • ADR-0087: packages/spec/src/migrations/entries/semantic/19.knowledge-service-held-without-embedder-or-store.ts (notice only, no D2 conversion: the fix is the deployment's configuration, never the item). The changeset carries registered with that id.

Boot window

Between kernel:ready and kernel:bootstrapped the reading is pending. In that window no tool definition is handed out (fail-closed); a record write's sync behaves as today (it embeds through the stand-in embedder, which refuses). Gating starts when the reading settles. No reap guard registers in that window on a runtime-composed plugin.

Point 2 measurement

None of @objectstack/verify's harness.required-providers cases reads as held: every one registers an embedder. The file is unchanged and its 16 cases pass.

Docs

The two docs pages (content/docs/ai/knowledge-rag.mdx, content/docs/protocol/knowledge.mdx) are claimed by sibling card #38351, whose PR #38439 is open. Their lines for this part are added to this PR after #38439 merges and main is merged in; until then this PR carries no docs edit. skills/objectstack-ai/SKILL.md is out of scope (its own governed card after the build).

Tests

  • packages/services/service-knowledge/src/__tests__/knowledge-settings-contribution.test.ts, new describe "a runtime-composed knowledge service is enabled by configuration", booted on LiteKernel with a store plugin that counts every call (10 cases): held with no embedder saved (one info line, zero store calls after writes and a delete); no search_knowledge definition, search answers 503 SERVICE_UNAVAILABLE naming the missing half, rebuild refused; requires: ['knowledge'] ⇒ warn; a provider saved without its key ⇒ warn (build note 3's state, read here; its save refusal is part 2); store not mounted ⇒ warn; both halves missing named together; point 2 (an application-registered store is held too); controls: enabled through a host-registered embedder and through saved settings (built, definition handed out); a host-mounted plugin builds as before.
  • packages/services/service-knowledge/src/__tests__/reap-guard.test.ts (point 3, build note 1): held ⇒ registerReapGuard never called and the retention sweep deletes k1, k2 on time with no store call; control: enabled ⇒ the guard registers for ['task'] after the reading and de-indexes before the delete.
  • packages/mcp/src/mcp-knowledge-tools.test.ts (build note 4): HTTP lists the tool only once enabled (pending, held: absent; host-mounted: listed from the start); stdio through MCPServerPlugin with the boot hooks fired by hand: held is never listed and no list_changed is sent; enabled registers at kernel:listening with notifications/tools/list_changed and the same description; host-mounted registers once in start().
  • packages/runtime/src/mcp-knowledge-tools-bridge.test.ts: the runtime bridge reads the definitions per listing (pending and held [], enabled ['search_knowledge']).
  • packages/core/src/capability-composition.test.ts: runtimeComposed: { declared } is passed, declared only when the stack lists the token.
  • scripts/engine-double-contract.pinned.json learns the stdio double's findOne pin (the double routes through assertEngineFindOnePredicate).

Verification

Head 72a9cbfb6a. Shared container; every build and test ran through scripts/pm/os-verify-lock.sh.

Tests and typecheck at 72a9cbf
  • Closure build (pnpm --filter '@objectstack/dogfood^...' --filter '@objectstack/cli...' --filter '@objectstack/lint...' build): VERDICT command-exit 0.
  • @objectstack/service-knowledge pnpm test: Test Files 21 passed, Tests 738 passed; typecheck exit 0.
  • @objectstack/mcp pnpm test: Test Files 88 passed, Tests 1655 passed; typecheck exit 0.
  • @objectstack/core capability-composition.test.ts: Tests 26 passed; typecheck exit 0.
  • @objectstack/runtime mcp-knowledge-tools-bridge.test.ts: Tests 7 passed; typecheck exit 0.
  • @objectstack/verify harness.required-providers.test.ts: Tests 16 passed (point 2 measurement above; file unchanged).
  • @objectstack/cli plan.artifact-item-capabilities.test.ts, boot-preparation-parity.test.ts, migrate-meta-engine-guidance.test.ts: Tests 44 passed.
  • @objectstack/spec typecheck exit 0 (migration registry regenerated with the new entry).
  • ESLint over every changed .ts file: exit 0.
Ablation

At 2d6c3dfd (plugin unchanged since): scripts/ablation-replace.mjs replaced const held = this.settleEnablement(ctx, this.service, embedder); with const held = false; void this.settleEnablement;. The runtime-composed describe went 9 failed / 1 passed (the host-mounted control stayed green). Restored; blob back to HEAD, git diff HEAD empty.

Dogfood battery at 72a9cbf

pnpm --filter @objectstack/dogfood test under the lock: VERDICT command-exit 0 · Test Files 495 passed, 3 skipped (498) · Tests 4183 passed, 68 skipped (4251) · 0 failed.

Live positive control (os dev, showcase app)

The showcase mounts KnowledgeServicePlugin itself (host-mounted, unchanged by this PR), so for the control its two knowledge plugins and the source's adapter: 'memory' were commented out in the worktree only (never committed; restored with git checkout), which lets the runtime compose the service with the Turso store. objectstack dev --seed-admin --log-level info on a file database, signed in as the seeded admin:

  • No embedder saved. One boot line, INFO KnowledgeServicePlugin: the knowledge service is not enabled on this deployment: no embedder is configured (no embedder provider is saved — …). Its sources are held: none is built, synced or searched. To enable it, save an embedder provider, then restart. 1 source(s) held: showcase-showcase_task_notes. (hidden at the default log level, as info should be). No build line. index_status lists the source with build: null. The Knowledge page's rebuild action answers "was not started: [knowledge] the knowledge service is not enabled on this deployment: …". MCP over HTTP: tools/list 20 tools, search_knowledge absent.
  • Embedder saved, restarted. PUT /api/settings/ai saved a custom provider pointing at a local OpenAI-compatible stub. The boot registered the embedder, registered the reap guard for [showcase_task] after the reading, and built the source: "8 row(s) read, 8 written". MCP tools/list 21 tools with search_knowledge; a search_knowledge call answered hits from showcase-showcase_task_notes; the stub logged one call of 8 inputs (build) and one of 1 (search).
  • The boot also logs ERROR [knowledge] the start of the build … was not recorded (Duplicate record refused on 'Knowledge Sync State' …) whenever a build starts, host-mounted or not. That is service-knowledge: every boot logs a false ERROR because the sync-state upsert reads a by-id update as "no row changed" #38418 (open, seat 1), not this change.
  • index_status still reads the adapter while held (here: state: unreadable with the embedder's reason). Saying "not enabled" there, and in os knowledge status / rebuild, is card item 4, part 3.
Gates at 72a9cbf

dispatch-gates --ran: 106 derived families accounted for, 105 run with exit 0, 1 NOT MEASURED: check:dual-build-cjs-loads exits 3 (no dist/ for @objectstack/studio, client-react, scenarios, outside this closure); CI runs it. Among them: check-adr-0087-registration (1 declared-breaking changeset, registered knowledge-service-held-without-embedder-or-store), check-changeset-no-major, check-empty-changeset, spec check:upgrade-guide, check:spec-changes, check:api-surface, check:liveness, check:engine-double-contract (after the stdio double's fix), check:slot-lookup (after typing the store plugin), check:error-status-conformance, check:type-check-debt, check:nul-bytes. check-plugin-teardown-shape --self-test exit 0 after fetching its pinned fixture commit. overlap-check before the push: clean against main and against #38439, #38435 and #38268 (#38418 has no PR yet).

🤖 Generated with Claude Code

https://claude.ai/code/session_01FEkQ5m2rYCwPR3qqhnZDfW

…ources without an embedder or its store

Claude-Session: https://claude.ai/code/session_01FEkQ5m2rYCwPR3qqhnZDfW
Co-authored-by: Claude <noreply@anthropic.com>
… sources without an embedder or its store

Pins for the reap guard, both MCP transports and the runtime bridge; the
ADR-0087 upgrade-guide entry and the changeset.

Claude-Session: https://claude.ai/code/session_01FEkQ5m2rYCwPR3qqhnZDfW
Co-authored-by: Claude <noreply@anthropic.com>
…h the predicate; type the store plugin

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

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 4 package(s): @objectstack/core, @objectstack/mcp, @objectstack/service-knowledge, @objectstack/spec, touching 36 documentable anchor(s).

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

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

Coarse fallback — 191 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 16f132fbe76686713b709934389113f915c7d647 → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json 16f132fbe76686713b709934389113f915c7d647

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/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.

2 participants