Repository navigation
feat(service-knowledge)!: a knowledge service the runtime mounts holds its sources without an embedder or its deployment store - #38470
objectstack-fleet[bot] wants to merge 8 commits into
Conversation
…ources without an embedder or its store Claude-Session: https://claude.ai/code/session_01FEkQ5m2rYCwPR3qqhnZDfW Co-authored-by: Claude <noreply@anthropic.com>
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>
Claude-Session: https://claude.ai/code/session_01FEkQ5m2rYCwPR3qqhnZDfW Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 4 package(s): 5 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
What this run could not see
Coarse fallback — 191 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # 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
|
…owledge-held-not-served
…ledge pages Claude-Session: https://claude.ai/code/session_01FEkQ5m2rYCwPR3qqhnZDfW Co-authored-by: Claude <noreply@anthropic.com>
…owledge-held-not-served
Requested by Leehom · project thread
Refs #38369
Clause-②: no (narrowing)
Metadata-protocol: narrowed
维护者速读
search_knowledge;启动日志说一次缺了哪一半、怎么补。以前这种部署照样启动构建和同步,工具也列出来,但每次构建和检索都报错。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
mainafter this merges.packages/services/service-knowledge/src/knowledge-service-plugin.ts). The capability composition (packages/core/src/capability-composition.ts) now passesruntimeComposed: { declared }besidedeploymentAdapter;declaredis true only when the stack listsknowledgeinrequires. WithruntimeComposedset, the plugin reads atkernel:bootstrapped, after every store'sstart()registered its adapter: an embedder is available (another plugin registered one, or the savedai.embedder_*settings build one) and the deployment's store is mounted (an adapter ofdeploymentAdapter's id is registered). Both ⇒ the boot goes on as today. Either missing ⇒ held. A plugin a host mounts (noruntimeComposed) is untouched: it serves from the start, as before.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,rebuildSourceandreindexSourcethrowheldSourcesError: status503, codeSERVICE_UNAVAILABLE, and a message naming the missing half and the fix (build note 2).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.infowhen only a shippedknowledge_sourcemounted the service and nothing was saved;warnwhen the stack declaresrequires: ['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.KnowledgeService.knowledgeTools()answersdefinitions: []). HTTP MCP reads the definitions per request, so it listssearch_knowledgeonly once enabled.packages/mcp/src/plugin.ts, build note 4). The stdio bridge reads the tool in its ownstart(), before the reading, so a runtime-composed service hands out nothing there.MCPServerPluginnow registerssearch_knowledgeatkernel:listening(after everykernel:bootstrappedhandler) 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 sendsnotifications/tools/list_changed; skill prompts read the served tools at each listing. A host-mounted service's tool still registers instart(), once.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 carriesregisteredwith that id.Boot window
Between
kernel:readyandkernel:bootstrappedthe 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'sharness.required-providerscases 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 andmainis merged in; until then this PR carries no docs edit.skills/objectstack-ai/SKILL.mdis 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 onLiteKernelwith a store plugin that counts every call (10 cases): held with no embedder saved (oneinfoline, zero store calls after writes and a delete); nosearch_knowledgedefinition, search answers503 SERVICE_UNAVAILABLEnaming 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 ⇒registerReapGuardnever called and the retention sweep deletesk1,k2on 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 throughMCPServerPluginwith the boot hooks fired by hand: held is never listed and nolist_changedis sent; enabled registers atkernel:listeningwithnotifications/tools/list_changedand the same description; host-mounted registers once instart().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,declaredonly when the stack lists the token.scripts/engine-double-contract.pinned.jsonlearns the stdio double'sfindOnepin (the double routes throughassertEngineFindOnePredicate).Verification
Head
72a9cbfb6a. Shared container; every build and test ran throughscripts/pm/os-verify-lock.sh.Tests and typecheck at 72a9cbf
pnpm --filter '@objectstack/dogfood^...' --filter '@objectstack/cli...' --filter '@objectstack/lint...' build): VERDICT command-exit 0.@objectstack/service-knowledgepnpm test: Test Files 21 passed, Tests 738 passed;typecheckexit 0.@objectstack/mcppnpm test: Test Files 88 passed, Tests 1655 passed;typecheckexit 0.@objectstack/corecapability-composition.test.ts: Tests 26 passed;typecheckexit 0.@objectstack/runtimemcp-knowledge-tools-bridge.test.ts: Tests 7 passed;typecheckexit 0.@objectstack/verifyharness.required-providers.test.ts: Tests 16 passed (point 2 measurement above; file unchanged).@objectstack/cliplan.artifact-item-capabilities.test.ts,boot-preparation-parity.test.ts,migrate-meta-engine-guidance.test.ts: Tests 44 passed.@objectstack/spectypecheckexit 0 (migration registry regenerated with the new entry)..tsfile: exit 0.Ablation
At
2d6c3dfd(plugin unchanged since):scripts/ablation-replace.mjsreplacedconst held = this.settleEnablement(ctx, this.service, embedder);withconst 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 HEADempty.Dogfood battery at 72a9cbf
pnpm --filter @objectstack/dogfood testunder 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
KnowledgeServicePluginitself (host-mounted, unchanged by this PR), so for the control its two knowledge plugins and the source'sadapter: 'memory'were commented out in the worktree only (never committed; restored withgit checkout), which lets the runtime compose the service with the Turso store.objectstack dev --seed-admin --log-level infoon a file database, signed in as the seeded admin: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, asinfoshould be). No build line.index_statuslists the source withbuild: 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/list20 tools,search_knowledgeabsent.PUT /api/settings/aisaved acustomprovider 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". MCPtools/list21 tools withsearch_knowledge; asearch_knowledgecall answered hits fromshowcase-showcase_task_notes; the stub logged one call of 8 inputs (build) and one of 1 (search).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_statusstill reads the adapter while held (here:state: unreadablewith the embedder's reason). Saying "not enabled" there, and inos 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-loadsexits 3 (nodist/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, speccheck: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-testexit 0 after fetching its pinned fixture commit.overlap-checkbefore the push: clean againstmainand against #38439, #38435 and #38268 (#38418 has no PR yet).🤖 Generated with Claude Code
https://claude.ai/code/session_01FEkQ5m2rYCwPR3qqhnZDfW