Repository navigation
feat(service-knowledge): build a never-built source after boot; os knowledge rebuild and status - #37439
Conversation
…owledge rebuild and status After boot, KnowledgeServicePlugin reads what each object source's adapter holds against the index fingerprint and recipe hash (ADR-0161 K7, "What starts a rebuild") and builds, in the background and one at a time, every source that is unbuilt, under another fingerprint or under another recipe hash. A build runs under the cluster service's lock so one node builds a source. The knowledge settings namespace gains the administrator's rebuild and index_status actions; os knowledge rebuild and os knowledge status call them. Progress and results are logged, and the docs state the cost. Claude-Session: https://claude.ai/code/session_01JQwxbXkQAmjg7Hf74xDKA6 Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 2 package(s): 14 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 4 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 43 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 67bf557f73711286ffb93c60c7019518887a5433 && git checkout 67bf557f73711286ffb93c60c7019518887a5433
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin a46efa8c625f2b43d4aa1aa1044eb702667ba07d 1061045e49d4f7c5ed116c87cfe010d232f78614 && git checkout -B drift-repro a46efa8c625f2b43d4aa1aa1044eb702667ba07d && git merge --no-ff 1061045e49d4f7c5ed116c87cfe010d232f78614
node scripts/docs-audit/affected-docs.mjs --json a46efa8c625f2b43d4aa1aa1044eb702667ba07d
|
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract-review-claim: session_01Utp6CYtTDvfPQDzMbZnN5X · head 3681410 · 2026-11-26T06:22Z The seat runs the at-tier contract review of this head through an isolated sub-agent; L1 is the seat's own. |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract reviewServed-tier: PR #37439 for card #37099 (epic #37000). Face: declaration ( Check-runs on the head: every run concluded ① Derived judgmentsCard acceptance
The build lock's lease against long builds (previous seat's point 1)
Admin-only rebuild and status on every door (previous seat's point 2)
Per-node build records against the card (previous seat's point 3)
The field gate's
Docs
Boot-time build
Settings contribution
CLI
② Semver level
③ Boundary flags
No must-fix. S1 to S6 are should-fix: S4, S5 and S6 are small enough to ride the next push; S1, S2 and S3 can be follow-up rows if the seat prefers. Implemented-by: VERDICT: PASS |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X 席位核对Head-sha:
|
…s; docs and CLI follow-ups - The rebuild and index_status settings actions are refused 403 SETTINGS_FORBIDDEN to a caller without manage_platform_settings, through the real settings action door, naming no source and reaching no handler. - The cost callout says the default memory adapter is empty after every restart (each boot re-embeds the whole source on each node), and that one builder per source needs a shared cluster lock driver. - os knowledge rebuild --no-wait says it reports no outcome. - buildSourcesAtBoot lists the sources inside its try, and its background call carries a catch. - A first build that opened a generation and never completed reads as nothing built, not as another fingerprint. Claude-Session: https://claude.ai/code/session_01Utp6Cb4BAjgQ43tqy1DvVJ Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6Cb4BAjgQ43tqy1DvVJ Co-authored-by: Claude <noreply@anthropic.com>
…ry is answered 401 Claude-Session: https://claude.ai/code/session_01Utp6Cb4BAjgQ43tqy1DvVJ Co-authored-by: Claude <noreply@anthropic.com>
…adapter rebuilds at every boot; --no-wait reports no outcome Claude-Session: https://claude.ai/code/session_01Utp6Cb4BAjgQ43tqy1DvVJ Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract-review-claim: session_01Utp6CYtTDvfPQDzMbZnN5X · head 1061045 · 2026-11-26T07:25Z |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract reviewServed-tier: Delta review of PR #37439 for card #37099 (epic #37000), on top of the record for head Check-runs on the head: 42 ① Derived judgmentsFindings of the previous record
New in the delta
② Semver level
③ Boundary flags
No must-fix and no open should-fix on this head. S1 and S2 are carried by open cards. One landing condition: the newer Implemented-by: VERDICT: PASS |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X 席位核对Head-sha:
|
|
repo:objectstack#5 · os-bill · session_01Utp6Cb4BAjgQ43tqy1DvVJ Landing · 2026-11-26T07:30Z · zone ai-37000
State change: ready for review + auto-merge (merge queue). #37099 closes on merge; close-out follows. knowledge-rag.mdx siblings (#37442, #37004) merge main after this lands. |
…ge page's RAGFlow adapter option (objectstack-ai#37477) <!-- claude-projects-attribution: {"github_login":"os-bill"} --> _Requested by **Bill** · [project thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wgFiXLbrG7d8JVydkmtSf4Bt)_ Fixes objectstack-ai#37004 Clause-②: no (narrowing) — narrowed: `PUT /api/settings/knowledge` refuses `adapter: 'ragflow'` (`400 SETTINGS_VALIDATION`, field code `invalid_option`) and refuses `ragflow_base_url`, `ragflow_api_key` and `ragflow_default_dataset` (`400 UNKNOWN_KEY`), where it stored all four; `POST /api/settings/knowledge/test` answers `adapter = ragflow` as an unknown adapter (`400 SETTINGS_ACTION_FAILED`), where it answered a form check Metadata-protocol: none Skills-docs: updated here — `skills/objectstack-ai/SKILL.md` and its eval case 3 teach the `pgvector` adapter where they taught `ragflow`; `content/docs/protocol/knowledge.mdx`, `content/docs/ai/knowledge-rag.mdx` and `content/docs/ai/index.mdx` name the adapters this repository builds. ## 维护者速读 - 用户能看到什么变化:管理员在「知识库」设置页的后端下拉里不再有 RAGFlow 选项和它的三个配置项;以前选过它的环境,下拉显示为空,重新选一个后端保存即可。 - 为什么做:属于知识库平台边界整理;这个 RAGFlow 对接包发出的请求和对方接口对不上,绑定它的知识源从来搜不到内容,按裁决整包退役而不是修。 - 出错会怎样:还在用这个对接包的部署,升级后知识源搜索为空且只留一条警告日志;撤回这次合并即可恢复,已保存的配置一条都没删。 - 要你做什么:去掉它的版本发布之后,在 npm 上给这个包打弃用标记。 ## What changes Ruling 7134290286 on the decision card (objectstack-ai#36839), R1: the package is retired whole, in one PR, as a patch. - **Package.** `packages/plugins/knowledge-ragflow/` is deleted (9 files), with its `.changeset/config.json` fixed-group entry and its `pnpm-lock.yaml` importer. - **Settings page.** `knowledge.manifest.ts` loses the `ragflow` option, the RAGFlow group, its three keys and the `ragflow` branch of "Test connection". Manifest `version` goes 2 → 3 (the spec's "increment when keys are renamed/removed"). The strings go from all eleven locale bundles. - **Docs.** `content/docs/ai/knowledge-rag.mdx`, `content/docs/ai/index.mdx`, `content/docs/protocol/knowledge.mdx`, `content/docs/plugins/packages.mdx`, `CONTRIBUTING.md`, the `service-knowledge` README and package description, the `embedder-openai` README, `packages/spec/llms.txt` (78 → 77 published packages). - **Spec.** Comments only, in `knowledge-source.zod.ts`, `contracts/knowledge-adapter.ts` and `contracts/knowledge-service.ts`. No schema, no tombstone, no ADR-0087 conversion: `KnowledgeSource.adapter` stays a free string. - **Skill.** `skills/objectstack-ai/SKILL.md` and eval case 3 teach `pgvector` (H3 below). - **Scripts and ledgers.** Six scripts (comments, one self-test fixture URL, one debt row) and a comment in `.github/workflows/lint.yml`. ### Skill size | Reading | Before | After | |---|---|---| | `skills/objectstack-ai/SKILL.md` lines | 487 | 487 | | `skills/objectstack-ai/SKILL.md` tokens (ceiling 6801) | 6798 | 6798 | | All `SKILL.md` lines | 4961 | 4961 | | Ratcheted bundle tokens | 199596 | 199596 | Net lines in `skills/**`: +0. The eval fixture is measured, not ratcheted (3008 tokens after). ### `git grep -i ragflow` after this PR `git grep -i ragflow -- ':!**/CHANGELOG.md' ':!content/docs/releases/v17/**' ':!docs/audits/**'` answers 11 files. Each one: | File | Hits | Why it stays | |---|---|---| | `packages/services/service-settings/src/manifests/knowledge.manifest.ts` | 4 | The retired note beside `version: 3` | | `packages/services/service-settings/src/manifests/knowledge.manifest.test.ts` | 9 | Absence pins for the option, the group and the three keys; the stored-retired-adapter pin | | `content/docs/protocol/knowledge.mdx` | 1 | One "retired" row in the adapter table | | `.changeset/37004-retire-knowledge-ragflow.md` | 13 | This PR's release note | | `.changeset/33933-knowledge-settings-with-service.md` | 1 | A pending release note of another change, kept as written | | `.changeset/37292-skill-knowledge-split.md` | 2 | Same | | `CHANGELOG.md` (root) | 3 | Release history. The acceptance pathspec `**/CHANGELOG.md` does not match the root file | | `docs/adr/0161-…` | 13 | Deliberate history; `docs/adr/**` stays, apart from one anchor fix (Acceptance notes) | | `content/docs/releases/implementation-status.mdx` | 3 | Lines 311, 329, 446. Release-owned path, not edited in a code PR; the docs-only follow-up is filed as objectstack-ai#37481 | | `scripts/test-shard-timings.json` | 3 | Lines 88, 176, 276. Generated, do-not-hand-edit; the timings refresh workflow drops the rows. The partition self-test passes with them in place | | `scripts/partition-test-shards.mjs` | 1 | Line 3456, a frozen fixture of the 2026-11-02 refresh | ### Measurement (a): the settings page for an environment whose stored adapter is `ragflow` Measured on the settings service with the old manifest registered first (rows written through the door), then this PR's manifest registered over it. | Door | Answer | |---|---| | `GET /api/settings/knowledge` | `200`. Manifest `version` 3, adapter options `memory`, `turso`. `values.adapter` is `{"value":"ragflow","source":"global"}`: served as stored. Value keys served: `adapter`, `turso_url`, `turso_auth_token`, `chunk_target`, `over_fetch`, `enforce_rls`. No `ragflow_*` key is served; the three stored rows are still in the store | | `POST /api/settings/knowledge/test` (stored values) | `400 SETTINGS_ACTION_FAILED`, "Unknown adapter: ragflow" | | `PUT` `chunk_target: 900` | `200` | | `PUT` `adapter: 'ragflow'` | `400 SETTINGS_VALIDATION`, "Adapter must be one of: memory, turso. Received 'ragflow'.", field code `invalid_option` | | `PUT` `ragflow_api_key` | `400 UNKNOWN_KEY` | | `PUT` `adapter: 'memory'` | `200`; the next read serves `memory` | In the Console (the real `SettingsField` rendered in jsdom, not a browser): the Adapter select shows **nothing** for the stored `ragflow`, neither a label nor the "Select…" placeholder. `turso` shows its label; an unset value shows the placeholder. The page saves dirty keys only, so editing another field saves; picking an adapter and saving replaces the stored value. Left behind: the encrypted `ragflow_api_key` row and its `sys_secret` row. No settings door clears them once the key is undeclared. The changeset says how to delete them by hand. ### Measurement (b): a knowledge source declaring an unregistered adapter `KnowledgeServicePlugin` booted on a kernel with one object source declaring `adapter: 'ragflow'` and no adapter plugin. | Moment | Answer | |---|---| | Boot | Completes. One `info` line: `[knowledge] source registered: kb (adapter=ragflow, kind=object)`. No warning, no error | | `search` | `[]`, with `warn: [knowledge] source 'kb' references unknown adapter 'ragflow'; skipping.` | | `searchWithRefusals` | `{"hits":[],"refused":[]}`, same warning. The source is not reported as refused | | `indexDocument`, `reindexSource` | Throw a bare `Error` (no code, no status): `[knowledge] unknown adapter 'ragflow'. Registered: []` | | Record upsert / delete events | Resolve; `warn: [knowledge] event-sync failed for source 'kb': …` / `delete failed …` | **(b) is silent** at boot and on search. It is not changed here; the enforcement card is filed as objectstack-ai#37479. ## Tests - `knowledge.manifest.test.ts`: `version` 3 with absence pins for the three keys and the group (non-vacuity: `turso_url` is there); adapter options are exactly `memory`, `turso`; one new pin, "answers a stored retired adapter (ragflow) as a failure, complete old keys or not", with a passing `turso` call beside it. - `settings-visibility-declaration.pin.test.ts`: the predicate count goes 87 → 83 (the four `visible` predicates of the RAGFlow group and its keys). - `knowledge-settings-default-absent.pin.test.ts` and `service-knowledge`'s `knowledge-settings-contribution.test.ts`: the fixture adapter is `turso`. - The package's own test file (`ragflow-adapter.test.ts`) goes with the package. Run under the verify lock on `d3692d0c` (after the merge of `main` at `a46efa8c`): | Command | Result | |---|---| | `pnpm --filter @objectstack/service-settings test` | Test Files 77 passed (77), Tests 1521 passed (1521) | | `pnpm --filter @objectstack/service-knowledge test` | Test Files 13 passed (13), Tests 416 passed (416) | | `pnpm --filter @objectstack/embedder-openai test` | Test Files 1 passed (1), Tests 33 passed (33) | | `typecheck` of `service-settings` and `service-knowledge` | exit 0 | After the second merge of `main` (`cc38a91a`), on `cb640fb2`: `service-knowledge` Test Files 14 passed (14), Tests 448 passed (448); `service-settings` 77 files, 1521 tests, unchanged; `service-knowledge` typecheck exit 0. No ablation run: the change deletes code and edits prose. The one behaviour that moves, a stored `ragflow` reaching "Test connection", has its pin above. ## Acceptance notes - **H1 (hit count).** The tree was taken as the truth: 50 paths changed, 9 of them the package and 41 outside it. All 8 scripts were looked at: 6 edited, the timings JSON and the frozen fixture line left (see the table). - **H2 (`lint.yml` premise).** `DEBT` and `TEST_DEBT` in `scripts/check-type-check-coverage.mjs` are both `{}` on `main`, so the ledgered closure the step's comment describes was already empty before this card. The comment now says so. The step's `run:` line is unchanged; whether the step still earns its place is a workflow question outside this card. - **H3 (skill eval).** Case 3 is rewritten, not dropped: the prompt says the deployment runs PostgreSQL with pgvector and the expected answer writes `adapter: 'pgvector'` with no `split` key. Dropping it would lose the only case covering an object source with `where`, `metadataFields` and `refresh`; the in-memory adapter is already case 9. - **Size.** 50 files changed, 159 insertions, 7041 deletions against `main`, nearly all of it the deleted package and its lockfile entries. That is over the 3000-line threshold for a human merge, on top of the governed paths (`skills/**`, `.github/workflows/lint.yml`). - **ADR-0087 disposition (review round).** The changeset's marker is `not-required (runtime-export-retired @objectstack/knowledge-ragflow#*)`, the disposition ADR-0087 D9 gives a published package deleted at HEAD, with one FROM line naming the package. It was `no-migration-prescription`, which refuses a note that carries a prescription. The settings half's argument sits in the marker's reason. `check-adr-0087-registration` on `78fff74e`: exit 0, "verified: @objectstack/knowledge-ragflow#* (package)". - **ADR-0161, anchor fix, not a revision.** One table cell (the `adapterConfig` row) named a symbol anchor in the deleted package's `src/index.ts`, and `check:adr-symbol-anchors` refuses an anchor with no tracked file. The cell now names the function and the retired package in prose. No decision text is touched. Agreed with the zone. - **Serial.** objectstack-ai#37439 (zone ai-37000) landed first and is merged in (`main` at `cc38a91a`, no conflict). Its first-build callout in `content/docs/ai/knowledge-rag.mdx` listed RAGFlow among the persistent adapters; that one word is removed here. objectstack-ai#37442 (same zone) is still open: `overlap-check` against its head and `main` answers clean at `cb640fb2`. Whichever lands first, the other merges `main` once. objectstack-ai#37310 (same zone) rewrites cases 3 and 9 of `skills/objectstack-ai/evals/skills-tools-knowledge.json`, the file whose case 3 this PR rewrites; it is coordinated with this card and comes after it. - **Not edited, deliberately.** `content/docs/releases/implementation-status.mdx` (release-owned) and `scripts/test-shard-timings.json` (generated). Both agreed with the zone. - **Beyond the single hit.** `content/docs/plugins/packages.mdx`: the Plugins row swaps `knowledge-ragflow` for `knowledge-pgvector` and `knowledge-turso`, which it did not list, so its count goes 17 → 18. `embedder-openai` README: its "no knowledge adapter consumes an `IEmbedder`" paragraph was already untrue (pgvector and turso take one) and is rewritten. `packages/spec/llms.txt`: 78 → 77 published packages (`check:llms-txt` counts the workspace). - **An earlier pending note is now partly untrue.** `.changeset/33933-…` says clearing the key from Setup removes the stored RAGFlow API key. With the key undeclared that door is gone; this PR's changeset says so and gives the manual deletion. The earlier note is not edited. - **Pre-existing, not touched.** The docs describe `file` and `http` source kinds; no adapter in this repository ingests them. - **Seen, not changed here**, and where each went: - (1) Measurement (b), the silent unregistered adapter: filed objectstack-ai#37479. - (2) The Console's blank select for a stored value the manifest no longer offers, and (3) no door clearing a stored secret whose key was removed from a manifest: filed objectstack-ai#37480, one card for both. - (4) The docs-only releases follow-up: filed objectstack-ai#37481. - (5) The `lint.yml` step with an empty premise: filed objectstack-ai#37482. - (6) The three stale rows in the timings JSON: no card; the refresh workflow regenerates the file. - (7) ADR-0161 keeps `adapterConfig` in v1 "only while an adapter reads it", and after this PR no adapter in the tree does: no card; objectstack-ai#37304 already carries that removal. - (8) The earlier pending note about clearing the key from Setup: no card; this PR's changeset corrects it. ## Verification **Read first** (by risk): 1. `packages/services/service-settings/src/manifests/knowledge.manifest.ts`: the removed handler branch. A stored `ragflow` now falls through to the last line, `Unknown adapter`. 2. `skills/objectstack-ai/SKILL.md`: three small hunks in *Knowledge Sources (RAG)*; the published text an agent follows. 3. `.changeset/37004-retire-knowledge-ragflow.md`: the BREAKING paragraph and the "What to do if you used it" list. **Two-minute check:** `git grep -il ragflow -- ':!**/CHANGELOG.md' ':!content/docs/releases/v17/**' ':!docs/audits/**'` on this branch lists exactly the 11 files in the table above. <details> <summary>Local gates</summary> - `node scripts/pm/dispatch-gates.mjs --commands` over the 50 changed paths derives 175 commands. `--ran`: 175 derived, 175 run, 0 NOT-MEASURED, 0 UNRUN, every one exit 0. - After the second merge of `main`, the derivation is the same 175; the 39 that read docs, skills or changesets were run again on `cb640fb2`, all exit 0. The rest were not repeated (CI runs them). - Review round, on `78fff74e`: the 18 derived gates that read changesets, ADR anchors or citations were run again, all exit 0. - Three were red on the way and are repaired in this PR, not waived: `check-skills-token-ratchet` (the first wording put `SKILL.md` 13 tokens over its ceiling; trimmed in the same file to 6798, its count before), `check:llms-txt` (78 → 77 published packages) and `check:adr-symbol-anchors` (the ADR-0161 anchor). - `check-plugin-teardown-shape --self-test` needs a pinned commit a shallow clone lacks; it passed (48 cases) once that commit was fetched. - `pnpm --filter @objectstack/spec check:generated`: exit 0 on the merged tree. - Full workspace build (`turbo run build` over `packages/*` and `packages/*/*`): 83 of 83 tasks, exit 0, on the merged tree. - `check-platform-checklist --changed-from origin/main`: exit 0, no anchored file in the change set. </details> <details> <summary>Dogfood battery (owed by the narrowing arm), on the final head</summary> - Head `d3692d0c919f690def1ec29b4021f69a1b3c8932`. Closure built with `pnpm turbo run build --filter=@objectstack/dogfood` (73 of 73 tasks), then `pnpm --filter @objectstack/dogfood test` under the verify lock, no shard, no path. - `VERDICT command-exit 0`. Test Files 487 passed, 3 skipped (490). Tests 4129 passed, 68 skipped (4197). Duration 2178 s. - That head is before the second merge of `main`, so the battery was run again on `cb640fb2`, same commands: `VERDICT command-exit 0`, same counts. - Current head `78fff74e1e182c3e9432329e06e8a8a3dbf0b4fd` (the review round's changeset commit), same commands: `VERDICT command-exit 0`. Test Files 487 passed, 3 skipped (490). Tests 4129 passed, 68 skipped (4197). Duration 2270 s. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- signed: repo:objectstack#5 · os-bill · session_01Utp6CaUMCSy2q88QhyTB9f --> --------- Co-authored-by: Claude <noreply@anthropic.com>
…ector store (objectstack-ai#37442) <!-- claude-projects-attribution: {"github_login":"os-warren"} --> _Requested by **Warren** · [project thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ84BSz1obpkWFoBogsxn7rAx)_ Fixes objectstack-ai#37102 Clause-②: yes Metadata-protocol: added Skills-docs: follow-up objectstack-ai#37310 ## 维护者速读 - 用户能看到什么变化:应用声明需要“知识检索”后,平台自动装好检索服务和一个向量库(PostgreSQL 项目用同一个数据库,其他数据库用项目本地的一个文件);没有声明的部署前后完全一样。 - 为什么做:属于“知识检索平台化”专题,让本地开发和自建部署不用手工接线就有可用的检索。 - 出错会怎样:只影响声明了该能力的应用;检索源指向没装上的向量库时应用照常启动,检索会明确报错并说明可选的库;回退本改动即可恢复原状。 - 要你做什么:批准一次。本改动在两份对外技能文件里各补了一个能力名(受管的技能文件),需要你批准后才能合并。 ## What changes - **New capability token `knowledge`** in `PLATFORM_CAPABILITY_TOKENS` / `PLATFORM_CAPABILITY_PROVIDERS` (provider `@objectstack/service-knowledge`, edition `open`) and in core `CAPABILITY_PROVIDERS`. - **Store selection, shared by both boots** (`@objectstack/core`): `resolveKnowledgeStore` / `resolveCapabilityExtras` + `KNOWLEDGE_STORE_PROVIDERS`. PostgreSQL (driver `postgres` or a `postgres(ql)://` URL) → `KnowledgePgvectorPlugin` on the same URL; `:memory:` → in-memory turso; anything else → `KnowledgeTursoPlugin` on `knowledge.db` in the data directory (`.objectstack/data/`, or `<OS_HOME>/data/` when `OS_HOME` is set) with `urlFromSettings`. `knowledge-memory` is never mounted. - **`os serve`** reads the primary database it resolved and mounts the one store; an extra that cannot be imported or constructed now warns instead of being skipped silently. A host that mounts the service or a store itself keeps its own (`hasPluginMatching` on the identities). - **`@objectstack/verify`** `constructServedProviders` takes an optional `database` (default in-memory SQLite) and mounts the same store as serve. - **Unmounted adapter** (`service-knowledge`): service mounts, boot does not fail; at `kernel:bootstrapped` one `error` line per such source naming the mounted adapters; index and search of that source answer `SERVICE_UNAVAILABLE` 503 with the same message (existing code, no new error code). A multi-source search keeps the other sources' hits and names the refused one. - **Carry from objectstack-ai#37107 (comment 7181713320)** (`knowledge-turso`): under the token the store URL comes from settings (`knowledge.turso_url` / `turso_auth_token`). `resolveSettingsStoreUrl` holds a saved `file:` URL to the realpath'd `.objectstack/data/` (symlink escape, `..`, the directory itself and the platform DB file are refused) and refuses a NUL or other control character, all before `createClient`. `resolveStoreUrl` refuses control characters too. - **The saved store URL is read at `kernel:bootstrapped`, not in `start()`** (`knowledge-turso`, fix round). The settings service answers a saved value only once its data engine is bound, in its own `kernel:ready` hook; a read in `start()` saw the manifest default while the saved row sat unread, so the store opened the default file whatever the operator had saved (`check:settings-bind-window` named it; reproduced on a real kernel, see Verification). Under `urlFromSettings` the adapter is now registered in `start()` with no database and answers `SERVICE_UNAVAILABLE` 503; the plugin registers its `kernel:bootstrapped` handler in `init()`, so it runs ahead of every handler a plugin registers in `start()`: the knowledge service's embedder, its reading of unmounted adapters, and the first build of objectstack-ai#37099 find the store open. A store given `url` or `client` opens in `start()` as before. The plugin's `optionalDependencies` keep only the knowledge service: no ordering edge moves a `start()` read past the settings bind. - **Rework after contract record 7187791236 (FAIL on M1) and the seat's REWORK note:** - **M1, a percent-encoded control character is refused** (`knowledge-turso`). `resolveStoreUrl` and `resolveSettingsStoreUrl` tested the raw URL only, so a saved `file:…/k%00.db` passed both; libSQL decodes the path it opens and its native library ends the process on the NUL byte, at every boot. Both now read each `%XX` escape as the character it encodes and refuse a control character in either spelling, before anything touches the disk or the client. The check is in `resolveStoreUrl`, so the plugin's own `url` option holds too. - **S3, `@objectstack/knowledge-turso` is an optional dependency** of `@objectstack/cli` and `@objectstack/verify` (it was a hard one in the first round). Its libSQL client is a native module with an `os` / `cpu` list; as a hard dependency it would refuse the whole CLI install outside that list. `KNOWLEDGE_STORE_PROVIDERS.turso` and its `CapabilityExtra` carry `optional: true`. `os serve` already warns when an extra cannot be imported and boots on; `constructServedProviders` now does the same for an optional extra (any other provider it cannot load is still a thrown boot error). - **S4, the store's file follows `OS_HOME`** (`os start --home` sets it): `resolveKnowledgeStore` hands the store `stateDir`, and the data directory is then `<OS_HOME>/data/`, the directory the boot keeps the default platform database in (`resolveDatabaseStateDir`'s order). The settings confinement moves with it, so an operator can keep the file on the volume. Without `OS_HOME` nothing changes. New plugin option `stateDir`; `dataDirectoryOf` and `defaultStoreUrl` take it as a second argument. A database named by URL does not move the store (documented). - Docs (`knowledge-rag.mdx`): where the file is, what more than one replica means on MySQL, MongoDB or remote libSQL (one local file per replica, each indexing only its own writes: use a shared `libsql://` store or PostgreSQL), and an install without the libSQL client. - Changeset: the sentence about a host-mounted service no longer overstates (a host that mounts the service gets no store from the runtime). - **After the delta record 7193770862 (PASS) and the seat's note 7193780591: the auth token is checked too** (`knowledge-turso`, commit 664bd70). `turso_auth_token` is the second settings value handed to the libSQL client. A token with a NUL byte, a line break or another control character is refused in the plugin's one open path (`open()`), for the saved setting and for the `authToken` option alike, before the client is created; the store answers `SERVICE_UNAVAILABLE` with a reason that never quotes the token. It is read as written, with no percent-decoded reading: the client percent-decodes a URL (an `authToken` in a URL's query is already covered by M1's check), never this option, so `%00` in a token is three characters. Probed on the installed `@libsql/client` 0.18.0 before the change, to know what the check prevents: on a `file:` URL a NUL or a line break in the token opens and answers a query (exit 0, no abort: the native open ignores the token without a sync URL); on `http://` every request is rejected with a catchable `TypeError` (invalid header value); on `ws://` the connection was refused before the token was used, so that arm is unmeasured. So no process abort was found; the check turns a failure at every call into one refusal that names the setting. N4: the `knowledge.manifest.ts` jsdoc now names the state directory's data directory and both spellings of a control character. - Settings manifest + 11 locales: the `turso_url` example path is now `file:./.objectstack/data/knowledge.db`. - Docs: `content/docs/ai/knowledge-rag.mdx` gains "Turning it on: `requires: ['knowledge']`"; the old "Wiring" section is now "Wiring by hand". - **Skills enumeration rows only (Tier H)**, under the enumeration-row case (ruling A on objectstack-ai#32584): the token's one `CAPABILITY_ROWS` line in `packages/spec/scripts/lib/platform-catalog.ts` and its regenerated page `skills/objectstack-project/references/platform-catalog.md` (`gen:skill-refs`, no hand edit), and the bare `knowledge` token added to the `@objectstack/service-` + token cell of the `requires:` table in `skills/objectstack-platform/SKILL.md`. No teaching, examples or evals: those ride objectstack-ai#37310. - **Two ceilings, each raised by its row's measured delta and by no more** (nothing else cut, nothing rides along): - `skills/objectstack-platform/SKILL.md` (`scripts/check-skills-token-ratchet.mjs`): priced text 24591 to 24603 bytes (+12), 6148 to 6151 tokens (ceil(24591 / 4) = 6148, ceil(24603 / 4) = 6151). `main`'s row is 6149, with 1 token of headroom since objectstack-ai#37568 took 2 bytes out of the file; that token is absorbed, so the ceiling moves 6149 to 6151 (+2), pinned at the measurement. History of the number: on the first three merges of `main` (4925039, cc38a91, 5dbcc02) the base was 24593 priced bytes and the row read 6152 (24605 bytes); objectstack-ai#37568 then landed, and after the fourth merge (758e145) the row is re-pinned at 6151 (S5 of delta record 7196043543). The delta of the row itself is 12 bytes throughout. - the catalog's hand-written text (`packages/spec/scripts/platform-catalog.test.ts`): 6902 to 6939 bytes (+37), ceiling 1726 to 1735 tokens, pinned at the measurement. The row was first shortened from 50 to 37 bytes ("knowledge search and its vector store"). - **The two rulings the raise path names**, quoted: - Ruling A on objectstack-ai#32584 (record 6819475461; maintainer, verbatim: 「同意 A」): "a product PR that adds an authorable `defineStack()` top-level key, or a live member of a schema symbol bound to a registered exhaustive skills section, carries the matching skills enumeration row in the same PR. Only that row; prose, examples and evals still go to the skills sub-card." - objectstack-ai#32673 letter A (record 6840575378; maintainer, verbatim: 「32843 32673 同意」): "a PR that adds a metadata key and, under ruling A on objectstack-ai#32584, carries the matching enumeration row in a published skill may raise that skill file's token cap by the row's measured delta, and by no more. The PR body cites ruling A and this ruling. Nothing else in the file is cut to make room, and no wider raise rides along." - **Skills readings** on this head against `main` 758e145 (lines; tokens as the ratchet prices them): `skills/objectstack-platform/SKILL.md` 421 to 421 lines, 6148 to 6151 tokens; `skills/objectstack-project/references/platform-catalog.md` (generated) 160 to 161 lines, 2878 to 2898 tokens; all `SKILL.md` files together 4961 to 4961 lines; the whole shipped bundle reads 299348 tokens, of which this PR adds 23 (3 + 20). - **`packages/cli/src/utils/boot-preparation-parity.test.ts`**: `resolveCapabilityExtras` is a `SERVE_ONLY` entry (the declaration boot reads a row's `extras` itself and composes no knowledge store: a store's `init()` declares nothing, its tables are its own). Editing the file put it in `check:test-source-alias`'s changed-file scope, so it now pays six dynamic imports its step modules reach at collection (six module-top side-effect imports, the gate's printed remedy). ## Tests - `packages/verify/src/harness.required-providers.test.ts`: `requires: ['realtime','knowledge']` on SQLite boots the service + turso (not pgvector), a record write is indexed and `search` finds it, a pgvector source is refused 503 while boot succeeds; no token → no service and `settings.getNamespace('knowledge')` rejects `SETTINGS_UNKNOWN_NAMESPACE`; host-mounted service unchanged. - `packages/plugins/knowledge-pgvector/src/__tests__/capability-mount.live-postgres.test.ts` (new, live cell): the token's resolution on PostgreSQL picks pgvector on the same URL; a record write is indexed and `search_knowledge` finds it. **It has not run in CI on any commit of this PR**: the job with a PostgreSQL service, `temporal-conformance`, does not run on `pull_request`, and Test Core collects the file with both cases skipped. Its first CI run is the merge queue (the PR touches `packages/plugins/knowledge-pgvector/**`, which is in the `temporal_live` filter). It did run locally in the rework round, against PostgreSQL 16.15 with pgvector 0.6.0 from the distribution's package (CI pins pgvector 0.8.7): see Verification. - `packages/core/src/capability-composition.test.ts`: store selection arms (pg driver/URL, other DBs, in-memory, env fallback) and extras. - `packages/plugins/knowledge-turso/src/__tests__/plugin.test.ts`: `resolveSettingsStoreUrl` (NUL/control, inside, outside, symlink escape, platform file) and the plugin never reaching a mocked `createClient` with a refused URL. Fix round: the settings double now answers a saved value only once bound, as the real service does, and the cases run a boot in kernel order (`init()`, `start()`, the bind, `kernel:bootstrapped`). New case: nothing is read and no file is made in `init()` or `start()`, the mounted adapter answers `SERVICE_UNAVAILABLE` / 503 until the boot completes, then the saved file opens and the default file is never made. - Rework round, `plugin.test.ts`: `%00`, `%0a`, `%0A`, `%7f`, a `file://` form and a `libsql://` URL are refused by both resolvers, with a control (`%20` and a doubly encoded `%2500` are names, not control characters); a saved `%00` or `%0a` URL never reaches a mocked `createClient`; a state directory moves the default file and the confinement. - Rework round, `harness.required-providers.test.ts`: **a real-kernel case for the file-database arm** (`constructServedProviders` with a `file:` database under a temporary `OS_HOME`, a `turso_url` saved from a `kernel:ready` handler: the store is healthy on the saved file, neither default file is made, a record write is found by search); **an install without the store** (the package made unimportable: the service is constructed, the store is not, one warning); the dependency pin now requires an `optional` store to be an optional dependency and nothing else. - Rework round, `capability-composition.test.ts`: `OS_HOME` is handed to the file arm as `stateDir`, and to no other arm. - Token round, `plugin.test.ts`: a token with a NUL byte, a trailing line break, a CR LF or U+007F never reaches a mocked `createClient`, through the settings door (on a `libsql://` URL and on a file inside the data directory) and through the `authToken` option; no log line quotes the token; controls: a JWT-shaped token and one with `%00` in it reach the client as written. - `packages/services/service-knowledge/src/__tests__/knowledge-service.test.ts`: boot reading, coded index/search refusals, the plugin hook. - `packages/cli/test/serve-capability-identity.test.ts`: identity rows for the service and both stores. ## Acceptance notes - **Governed (Tier H)**: the diff touches `skills/**`, so this PR stays draft until the maintainer's approval. - **File surface**: the claim was widened twice. The take-over claim (7184318627) lists what the first round measured; claim amendment 7184431271 adds the four files this fix round needed (`packages/spec/scripts/platform-catalog.test.ts`, `skills/objectstack-platform/SKILL.md`, `scripts/check-skills-token-ratchet.mjs`, `packages/cli/src/utils/boot-preparation-parity.test.ts`), and the maintainer approved editing them in the card thread. - **Between `kernel:ready` and `kernel:bootstrapped`** a store whose URL is the operator's setting has no database yet: a record written by another plugin's `kernel:ready` handler is not indexed into it (the call answers 503). The knowledge service's own settings-configured embedder is provided at the same phase, so a deployment without a host-registered embedder indexed nothing in that window before either. The first build of objectstack-ai#37099, now on `main` and merged here, builds the source after the store has opened and so covers such rows. - `@objectstack/knowledge-turso` is an **optional** dependency of `@objectstack/cli` and `@objectstack/verify` (S3). On an install without it `requires: ['knowledge']` on a non-PostgreSQL database boots with the service and a warning, and sources naming `turso` answer 503. - **Accepted nits, not changed** (the seat's record): N1, `file::memory:` and an empty `wasm-sqlite:` URL take the file arm; N2, the settings example `file:./.objectstack/data/knowledge.db` is read from the working directory and names the project's directory, so under `OS_HOME`, or from another working directory, it is refused with a message naming the right directory (it fails closed; the example text lives in the manifest and 11 locales). N3, the `ci.yml` step comment still says three `*.live-postgres.test.ts` files where there are now five: `.github/workflows/**` is outside this card's surface, so it is not edited here. - The double boot line for a source whose adapter is not mounted, and the publish-time refusal, are carried by objectstack-ai#37479. - **objectstack-ai#37099 (PR objectstack-ai#37439) landed first; `main` is merged here and the first-build path re-checked.** Its after-boot build starts in the knowledge service's `kernel:bootstrapped` handler and reaches `getAdapter` through `readIndexState`, inside that method's own `try`. Read on a real kernel (see Verification): a store whose URL is a saved setting is open before the build starts (its handler is registered in `init()`, the service's in `start()`), and the build of its source ends `done`; a source naming an unmounted adapter is read as `unreadable`, is not built, and the boot goes on. Such a source is logged twice at boot, once at `error` by this PR's reading of unmounted adapters and once at `warn` by the build pass; one line would do (carried by objectstack-ai#37479, not changed here). - **Merged with `main` four times** (`scripts/pm/os-regen-merge.sh`, no rebase): at 4925039 for a GitHub conflict in the `requires:` table row of `skills/objectstack-platform/SKILL.md` (resolved by keeping `main`'s provider cell whole and adding the bare `knowledge` token after `record-context`), at cc38a91 once objectstack-ai#37439 had landed (no conflict), in the rework round at 5dbcc02 once objectstack-ai#37477 and objectstack-ai#37492 had landed (no conflict), and at 758e145 for S5 once objectstack-ai#37568 had edited `skills/objectstack-platform/SKILL.md` (auto-merged, no conflict). After each, `git diff origin/main` names this PR's 38 files and nothing else; `gen:skill-refs` and `check:generated` leave the tree clean. - **Open PRs that will conflict with this one**: objectstack-ai#37422 in `scripts/check-skills-token-ratchet.mjs`. Whichever lands second re-measures the `skills/objectstack-platform/SKILL.md` row. ## Verification First files to read, by risk: 1. `packages/plugins/knowledge-turso/src/plugin.ts`: `init()` / `start()` / `openFromSettings` (when the store opens, and what it answers before). 2. `packages/core/src/capability-composition.ts`: `resolveKnowledgeStore` (which store, with what argument). 3. `packages/services/service-knowledge/src/knowledge-service.ts`: `getAdapter` / `reportUnmountedAdapters` (the coded refusal). Two-minute check: `pnpm --filter @objectstack/knowledge-turso exec vitest run --maxWorkers=2 src/__tests__/plugin.test.ts`: expect 22/22, including "refuses a percent-encoded control character too" and "reads the settings at kernel:bootstrapped, never in init() or start()". <details><summary>Local runs (under scripts/pm/os-verify-lock.sh): the rework round on 806c55d, the token round on 664bd70, and what ran again on head c25cc1a</summary> - `pnpm install --frozen-lockfile`: exit 0. `pnpm turbo run build --concurrency=2 --filter='./packages/**' --filter='./examples/**'`: exit 0, 85/85 tasks. `gen:skill-refs` then `check:generated`: exit 0, tree clean. - `pnpm --filter @objectstack/knowledge-turso test`: exit 0, 3 files, 155/155. `typecheck`: exit 0. - `pnpm --filter @objectstack/core exec vitest run --maxWorkers=2 src/capability-composition.test.ts`: exit 0, 21/21. `pnpm --filter @objectstack/core typecheck`: exit 0. - `pnpm --filter @objectstack/verify exec vitest run --maxWorkers=2 src/harness.required-providers.test.ts`: exit 0, 15/15 (19.0 s of tests locally; the header's budget is re-derived to 28). `pnpm --filter @objectstack/verify typecheck`: exit 0. - `pnpm --filter @objectstack/cli exec vitest run --project unit --maxWorkers=2 src/utils/boot-preparation-parity.test.ts test/serve-capability-identity.test.ts src/commands/knowledge/knowledge.test.ts`: exit 0, 3 files, 143/143. `pnpm --filter @objectstack/cli typecheck`: exit 0. The rest of the cli suite is left to CI. - `pnpm --filter @objectstack/service-knowledge test`: exit 0, 14 files, 452/452. `pnpm --filter @objectstack/service-settings test`: exit 0, 77 files, 1521/1521 (after objectstack-ai#37477's edits to the same manifest and locales). `scripts/platform-catalog.test.ts` (spec): exit 0, 20/20. - **The pgvector live cell**, as CI's step runs it: `OS_TEST_POSTGRES_URL=postgres://postgres:postgres@127.0.0.1:5432/postgres OS_EXPECT_LIVE_DIALECT_MATRIX=1 pnpm --filter @objectstack/knowledge-pgvector exec vitest run live-postgres`: exit 0, 5 files, 65/65, none skipped (4 files, 59/59 before the merge of `main` brought objectstack-ai#37492's file). Server: PostgreSQL 16.15 with the `vector` extension 0.6.0 (the distribution's `postgresql-16-pgvector`), not CI's pinned pgvector 0.8.7 image. - **Ran again on the token commit 664bd70 (it touches `knowledge-turso`, one comment in the settings manifest, the docs page and the changeset):** `pnpm --filter @objectstack/knowledge-turso test`: exit 0, 3 files, 156/156 (`plugin.test.ts` 22/22); its `typecheck`: exit 0; `turbo run build` of `@objectstack/knowledge-turso` and `@objectstack/service-settings`: exit 0, 20/20 tasks. Everything above this line was run on 806c55d and not again. - **After the fourth merge (c25cc1a):** `pnpm install --frozen-lockfile`: exit 0. `pnpm --filter @objectstack/spec build`, `gen:skill-refs`, then `pnpm --filter @objectstack/spec check:generated`: exit 0, tree clean. `scripts/platform-catalog.test.ts`: exit 0, 20/20 (catalog ceiling 1735 unchanged). `node scripts/check-skills-token-ratchet.mjs`: exit 0, `skills/objectstack-platform/SKILL.md` 6151 / 6151. No package test was run again on this head. </details> <details><summary>Rework round: each new test turns red without its fix</summary> - **M1.** With the decoded read removed from `carriesControlCharacter` (the raw test alone, as on abf337b): `plugin.test.ts` 2 failed / 19 passed, "refuses a percent-encoded control character too" and "a saved URL with a NUL byte, or outside the data directory, never reaches the libSQL client". Restored (byte-identical to the committed file): 21/21. - **S2, S3, S4.** With `stateDir` and `optional: true` removed from core and core rebuilt: `harness.required-providers.test.ts` 3 failed / 12 passed. The file-database case answers `{ ok: false }` (the saved file under `OS_HOME` is outside the app's data directory); the missing-store case throws the "could not load it" boot error; the dependency pin reports `@objectstack/knowledge-turso` as not a dependency. Restored and rebuilt: 15/15. - **The auth token.** With the `acceptsAuthToken` check removed from `open()`: `plugin.test.ts` 1 failed / 21 passed, "an auth token with a control character never reaches the libSQL client, saved or given; the reason never quotes it". Restored with `git checkout` (the committed file): 22/22. </details> <details><summary>Fix round: reverse verification of the settings read (one-off, no file kept)</summary> A throwaway `@objectstack/verify` case booted a real kernel with `KnowledgeServicePlugin`, `KnowledgeTursoPlugin({ urlFromSettings: true })` and a plugin that saves `knowledge.turso_url` from its `kernel:ready` handler (ordered after the settings bind). - This head: the read in `start()` answers `source: 'default'`; after the boot the store is healthy on the saved file and `knowledge.db` was never made. Probe 1/1 green. - `plugin.ts` restored to 969b372 (the pre-fix file), `knowledge-turso` rebuilt (dist marker absent): the probe is red, the saved file was never made and the default `knowledge.db` was opened; `plugin.test.ts` 3 failed / 16 passed (the two saved-URL cases and the new phase case). - Restored from `HEAD` (blob hash equal, `git diff HEAD` empty), rebuilt (dist marker present): probe green again. </details> <details><summary>The first build of objectstack-ai#37099 on a real kernel, after the second merge (one-off, no file kept)</summary> A throwaway `@objectstack/verify` case booted a real kernel with `KnowledgeServicePlugin`, `KnowledgeTursoPlugin({ urlFromSettings: true })` and an app plugin that registers an embedder, a source on `turso`, a source naming the unmounted `pgvector`, and saves `knowledge.turso_url` from its `kernel:ready` handler. 1/1 green; readings after the boot: - the `turso` source: `buildRecord` is `{ trigger: 'boot', status: 'done', result: { ok: true, failed: 0 } }`, then `readIndexState` answers `current` ("same fingerprint, same recipe hash"). The store is healthy on the saved file and the default `knowledge.db` was never made. - the `pgvector` source: no build record; `readIndexState` answers `{ state: 'unreadable', due: false }` with the coded refusal's text ("adapter 'pgvector' is not mounted (mounted: turso)"). Boot log: one `ERROR` line from the reading of unmounted adapters, one `WARN` line "is not built at boot" from the build pass. </details> <details><summary>Derived gates (node scripts/pm/dispatch-gates.mjs --commands, 166 commands)</summary> - On this head (c25cc1a, after the fourth merge and the re-pinned row): the 37 derived commands that read skills, the ratchet, the catalog, generated artifacts, docs or the changeset ran again, 37/37 exit 0 (among them `check-skills-token-ratchet.mjs` and its self-test, `check:skill-docs`, `check:skill-examples`, `check:skill-refs`, `check:skill-identifier-liveness`, `check:skill-links`, `check:skill-top-level-keys`, `check:ratchet-remedy-authority`). The other 129 were not run again locally on this head; CI runs them on the merge. - `overlap-check` before the push: `origin/main` (758e145) merges cleanly; exit 1 only for open PR objectstack-ai#37422 (conflict in `scripts/check-skills-token-ratchet.mjs`). - Earlier rounds, for the record: 166/166 on the token commit 664bd70; 166/166 on 806c55d (the rework round); 166/166 on 63eba5b before the first merges; the 56 commands a merge can reach, 56/56, at 64075a7 and at abf337b. </details> ## Remaining - The ceiling-tier contract review owed by `Clause-②: yes`, then the maintainer's approval (Tier H). - The pgvector live cell has not run in CI on this PR (it cannot: see Tests); the merge queue is its first CI run, and a red there ejects the entry. Locally it passed against pgvector 0.6.0, not CI's 0.8.7. - The seat re-scopes objectstack-ai#37479 before this lands; the re-pinned ratchet row (S5) is re-checked by the same contract reviewer. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- signed: repo:objectstack#5 · os-bill · session_01Utp6CYE8s5v1UX96GEfkcR --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Warren · project thread
Fixes #37099
Clause-②: yes
Metadata-protocol: none
维护者速读
What changes
First build after boot (
@objectstack/service-knowledge)KnowledgeService.readIndexState(source)reads ADR-0161 K7's table for one source: the adapter holds nothing, a different fingerprint, a different recipe hash, no recipe hash, current, or (an adapter withoutindexStatus) whetherlistDocumentslists anything. Each reading says whether a build is due.KnowledgeService.buildSourcesAtBoot()runs from the plugin'skernel:bootstrappedhook, after the embedder is provided, without holding up the boot. It walks the sources one at a time and builds each one a build is due for. A source withrefresh.onRecordChange: false(an external indexer owns it) is skipped. A state it cannot read, or an adapter that cannot say, is logged at warn and left alone; the operator rebuild is the way for those.rebuildSourcetakes the cluster lockknowledge:build:SOURCE(ILock, 60 s lease renewed every 20 s,waitMs: 0). A node that finds the lock held recordsnot-runand builds nothing. A node that gets the lock re-reads the state first, so a node arriving after another finished builds nothing either. If the lock service errors, no build starts and the node warns. Without aclusterservice (single process) the build runs without a lock.wherematches is read, and its content fields are sent to the embedding provider, which bills for them), progress at most every 10 s, and its totals at the end (info) or why it did not finish (warn).buildAtBoot(defaulttrue).falseturns the boot pass off; the operator rebuild still works.Operator rebuild
knowledgesettings namespace, besidetest:rebuild({ source }) starts a build and answers at once;index_status({ source? }) answers each source's index reading and the last build record on this node, with its progress. Both go through the settings action door, so both needmanage_platform_settings. A second rebuild of a source already building on this node is refused.os knowledge rebuild SOURCEstarts one and follows it to its end by pollingindex_status(--no-waitto return at once,--interval). It exits 1 when the build failed or did not run, or when the answer comes from a node that is not running this build.os knowledge status [source]prints each source, its index state and its last build on the node that answered.Docs:
content/docs/ai/knowledge-rag.mdxgains "The first build, and rebuilding a source": the K7 table, what one build costs (a warn callout), how to turn the boot pass off, and the two commands.Rework round (seat L1 REWORK, contract record PASS with should-fix findings)
knowledge-settings-contribution.test.tsgains "the rebuild and index_status actions are administrator-only, at the HTTP door": a realLiteKernelwithKnowledgeServicePluginandSettingsServicePlugin, driven throughregisterSettingsRoutesand the realSettingsService.runAction. A signed-in caller withoutmanage_platform_settings(an organization member holdingsetup.read/setup.write, or one with no capability) gets403 SETTINGS_FORBIDDENforrebuildandindex_status; an unauthenticated one gets401 UNAUTHENTICATED. No refusal names the source (id or label), and no handler method on the service (listSources,getSource,readIndexState,rebuildSource,buildRecord) is called. A control shows the same door lets an administrator through and then names the source, and the in-processrunActionwith an enforced member context rejects withSETTINGS_FORBIDDEN. The gate itself is unchanged; it still lives in theknowledgemanifest'swritePermission, and relaxing it now turns these pins red (ablation below).content/docs/ai/knowledge-rag.mdxnow says the defaultmemoryadapter holds nothing after a restart, so with it every boot is a first build that re-embeds the whole source on every node; and that "only one node builds a source" holds only with a shared cluster lock driver, because the defaultmemorycluster driver's lock is a per-process mutex. The paragraph above the callout now qualifies its "only one builds" sentence the same way and links the cluster page. The changeset says both.content/docs/deployment/cli.mdxgains a### Knowledgesection after### MCP, in the shape of the other command groups (overview table, one####per command with examples, a flag table):os knowledge statusandos knowledge rebuild, their exit codes, the admin-only door, and the per-node build record.os knowledge rebuild --no-waitnow prints that it reports no outcome and points atos knowledge status; the flag help and the CLI reference say so), N3 (buildSourcesAtBootlists the sources inside atryand resolves with a warn when it cannot; the plugin'svoidcall carries a.catch), N5 (an adapter reporting{ building: true }with no active fingerprint, a first build that never completed, now readsnothingwith its own sentence instead ofnew-fingerprint). N1 (the optionalprotocol/knowledge.mdxpointer) stays an accepted deviation.os knowledge rebuildcan exit 1 on a poll that lands elsewhere) is service-knowledge: os knowledge rebuild and status give the right answer behind a load balancer #37466. S5 (retiring the field gate'stitlearm) is service-knowledge: retire the field gate's title arm once a source's index is proven built under the current recipe #37467.Why
A source that was never built had an empty index until each of its rows was written again; search found nothing and nothing said why. After an embedder or recipe change the index stayed stale the same way. ADR-0161 K7 says what starts a rebuild; nothing ran it.
Tests
packages/services/service-knowledge/src/__tests__/knowledge-build.test.ts(20 tests): everyreadIndexStatereading; a fresh source is built at boot and search finds its rows; a built source is not rebuilt; two nodes sharing one lock build once (onedone, onenot-run, lock released); a node arriving late re-reads and builds nothing; a lock error starts nothing and warns;onRecordChange: falseis skipped; a failed build is logged at warn and stays due; therebuildandindex_statusactions (progress, result, an operator rebuild skipping unchanged documents, a running build refused, bad payloads refused); the plugin'skernel:bootstrappedpass andbuildAtBoot: false.packages/cli/src/commands/knowledge/knowledge.test.ts(7 tests): both commands against bodies written bysendOk/sendError: the route and payload, following a build to its end, exit 1 on a failed build, on a server refusal, and on an answer from a node not running this build;--no-wait.lock.acquirewith an always-granted handle fails the two-node and lock-unreachable tests.knowledge-settings-contribution.test.ts+10 tests (the admin-gate pins above);knowledge-build.test.ts+2 (N3: a listing that throws resolves and warns; N5:{ building: true }readsnothing);knowledge.test.ts: the--no-waitcase now also asserts the line namingos knowledge status(N2).scripts/ablation-replace.mjs(landing proved on disk, restore provedgit diff HEADempty):knowledgemanifest'swritePermissionset tosetup.writein@objectstack/service-settings, package rebuilt (the pins read itsdist/): the four member cases, the admin control and the in-process case turn red (6 failed, 4 passed); restored and rebuilt, 10/10 green, and the built manifest readswritePermission: "manage_platform_settings"again.--no-waittest red. All three green again after restore.Acceptance notes
titlearm of the field gate is not retired here. Per the 11-25 14:55Z comment it can go once a rebuild has run, but it is a security gate and retiring it needs proof per source at search time that the index was built under the current recipe. That is its own row, service-knowledge: retire the field gate's title arm once a source's index is proven built under the current recipe #37467; this PR only makes the rebuild happen.index_statusreports the build the answering node ran. Behind a load balancer,os knowledge statusmay reach a node that is not building;os knowledge rebuildsays so and exits 1 rather than guessing. The index state itself is read from the adapter and is the same on every node. Sharing the record, or letting the CLI fall back to the index state, is service-knowledge: os knowledge rebuild and status give the right answer behind a load balancer #37466.content/docs/deployment/cli.mdxnow lists both commands (S6).content/docs/frontend/cli.mdxis not updated: it is outside this card's file surface.Verification
service-knowledge: 14 test files / 436 tests pass;tsc --noEmitandcheck:test-typecheckpass.eslint --no-inline-configon every changed file passes.tsc --noEmit: not measured locally. This container has no builtdist/for the CLI's workspace dependencies (563 TS2307-family errors, none in a knowledge file); CI owns it.LiteKernels sharing oneMemoryLockover a 250-row source. Boot returned in 9 ms without waiting for the build. Node A:done, 250 indexed; node B:not-run("another node holds the build");beginBuildcalled once; search found rowr0007; the state afterwards readcurrent. A non-adminrunAction('knowledge','rebuild')was refused ("requires the 'manage_platform_settings' capability"); an admin rebuild then showeddonewith 250 skipped. The log carried the cost line.check:skill-examples,check:dual-build-cjs-loads,check:i18n,check:i18n-coverage,check:i18n-walk-parity,check-plugin-teardown-shape --self-test; that script's scan alone exits 0). Those six go to CI.knowledge-rag.mdx, Open runtime: requires: ['knowledge'] mounts the knowledge service, and pgvector on PostgreSQL #37102 alsopackages/cli): clean at push time. The second to land merges main.Rework round readings, head 1061045
service-knowledge(dependency closure rebuilt first,turbo run build --filter='@objectstack/service-knowledge^...', 18/18 tasks):pnpm test14 files / 448 tests pass;typecheck(tsc --noEmitandcheck:test-typecheck, 0 files / 0 errors in the debt ledger) passes.src/commands/knowledge/knowledge.test.ts7/7 pass (unit layer). CLItsc --noEmitnot measured locally, for the reason above; CI'sTypeScript Type Checkowns it.eslint --no-inline-configon the seven changed.tsfiles: exit 0.dispatch-gates.mjs --commands, 122 commands, run on a753df9 with the changeset edit in the tree): 114 exit 0. Not measured here, left to CI: six exit 3, PREREQUISITE NOT MET, the same six the first round named (check-plugin-teardown-shape --self-test, whose positive control is pinned to a commit a shallow clone cannot reach, its scan exits 0;spec check:skill-examples,check:dual-build-cjs-loads,check:i18n,check:i18n-coverage,check:i18n-walk-parity, which read built output this container does not have); two whole-repo scans,check:query-options-erasure(its self-test passed) andcheck:type-check-debt, hit the 300 s per-command limit on the shared box. Re-run on 1061045: the changeset family (check-adr-0087-registration,check-changeset-no-major,check-empty-changeset,check:changeset-fixed),check:nul-bytes,check:doc-anchors,check:cli-command-ids,check:cli-examples-parity, all exit 0.overlap-checkbefore each push: clean againstorigin/main, feat(core): requires knowledge mounts the knowledge service and one vector store #37442, feat(spec)!: form is a metadata type of its own, and the form doors read a form over both types #37422 (sharescontent/docs/deployment/cli.mdx) and chore: version packages (next) #35129. Retire @objectstack/knowledge-ragflow: package, settings option, docs and skill mentions #37004 has no PR open yet.Human Minimum
packages/specholds no runtime logic.pnpm lintpasses.main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed. (not touched)content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_01JQwxbXkQAmjg7Hf74xDKA6