Skip to content

Commit ff63b02

Browse files
fix(knowledge-turso)!: the Knowledge page's Turso fields are contributed by the store that reads them (#37902)
Fixes #37678 Fixes #37679 Clause-②: no (narrowing) — narrowed: where `@objectstack/knowledge-turso` is not mounted (the store is pgvector, on PostgreSQL), or is mounted with a `url` or `client` of its own, `PUT /api/settings/knowledge` refuses a body naming `turso_url` or `turso_auth_token` (`400 UNKNOWN_KEY`, the whole body) where it stored them, and `GET /api/settings/knowledge` no longer serves them; where the store reads its URL from settings both doors answer as before Metadata-protocol: none Skills-docs: none — no skill under `skills/**` teaches `turso_url` or `turso_auth_token`; `content/docs/ai/knowledge-rag.mdx` says where the page shows them. ## 维护者速读 - 用户能看到什么变化:平台库是 PostgreSQL 的部署,管理员打开“知识库”设置页不再看到 Turso 连接字段;用 Turso 存储的部署照旧能看到并保存。 - 为什么做:知识库设置清理的后续——Turso 字段只在真正读取它们的存储装上时出现,同时把“带了已退役键的保存会被整体拒绝”写进迁移说明。 - 出错会怎样:最坏是 PostgreSQL 部署上保存 Turso 字段的旧脚本收到 400;已保存的值不会被删除,可以直接撤回本改动。 - 要你做的:无。 ## What changes **#37678 — the Turso group moves to the store that reads it.** - `@objectstack/service-settings`: the `knowledge` manifest no longer declares the Turso group, `turso_url` or `turso_auth_token` (`version` 4 to 5, with the reason in its header). Its eleven locale bundles drop the group's copy. - `@objectstack/knowledge-turso`: new `src/settings-contribution.ts` declares the group and its two fields (moved verbatim, the cloud per-organization sentence included and untouched) and their copy in the same eleven locales (moved verbatim, checked equal to every `origin/main` bundle value, 11 locales, 0 differences). `KnowledgeTursoPlugin.init()` calls `contributeKnowledgeTursoSettings(ctx)` only under `urlFromSettings` with no `url` or `client`, i.e. only where the plugin reads the two keys. It re-registers the `knowledge` manifest with the group in front (where it always was), and loads the copy into the i18n service at `kernel:ready`. - The mechanism is the existing one, not a new one: the one `@objectstack/service-knowledge` uses for the `ai` page's embedder section (`withAiEmbedderSection` + `SettingsService.registerManifest`, which replaces the manifest and keeps the namespace's action handlers). Ordering is the plugin's existing `optionalDependencies` on the knowledge service, whose `init()` registers the page. - `knowledge-turso` gains `@objectstack/service-settings` as a devDependency (tests only) and a source alias for it in `vitest.config.ts`. - Docs: `content/docs/ai/knowledge-rag.mdx` says the page shows the two keys only where the store reads them. **#37679 — the retired-key refusal is whole-body, and the test door is sent Turso fields only.** - N2: the pending `.changeset/37104-knowledge-settings-readers.md` now says the PUT is refused whole. A new pin posts a retired key beside `chunk_target` and asserts nothing is saved. `knowledge-rag.mdx` does not repeat the refusal sentence, so it needed no N2 edit. - N4: `knowledge-settings-contribution.test.ts:199-201` now posts only `turso_url`. The card's second site, `:225`, is not a test-door post. It is `SECRET_SOURCE.adapter: 'memory'`, a `KnowledgeSource` declaration that the spec requires, so it is left as it is. The one other test-door post that still sent `adapter`, `knowledge-settings-default-absent.pin.test.ts:130`, now sends `turso_url`. That test posts to a namespace that is not registered, so its body changes nothing it asserts. **DELIBERATE CORRECTION — `.changeset/37104-knowledge-settings-readers.md`** (pending, not released; `check-empty-changeset` stays red on this by design). This PR changes what that note describes, so the note is corrected: 1. Clause-② line now reads: "`PUT /api/settings/knowledge` refuses a body naming `adapter`, `over_fetch` or `enforce_rls` (`400 UNKNOWN_KEY`) whole, where it stored them: no other key in that body is saved;" 2. BREAKING paragraph now reads: "the write is now refused as an undeclared key, and refused whole — no other key in that body is saved, so a body that also changes `chunk_target` saves nothing. Drop the retired key from the body." 3. Turso bullet: removed "the Turso group now says so and always shows, since the page no longer has an adapter select to gate it on". This PR makes that clause false. The bullet now ends "On PostgreSQL the store is pgvector, in the platform database, and neither is read." New changeset: `.changeset/37678-knowledge-turso-settings-group.md` (`@objectstack/knowledge-turso` and `@objectstack/service-settings`, both patch), with the two declaration lines, `Skills-docs:` and the ADR-0087 `not-required (no-migration-prescription)` marker in the form the #37104 changeset uses. **Read first** (by risk): 1. `packages/plugins/knowledge-turso/src/settings-contribution.ts`: `contributeKnowledgeTursoSettings`, the re-registration and the i18n load. 2. `packages/plugins/knowledge-turso/src/plugin.ts`: `init()`, the one call and its `opensFromSettings()` gate. 3. `packages/services/service-settings/src/knowledge-settings-retired-keys.pin.test.ts`: the whole-body pin and the stored-value survival pins. **Two-minute check:** `pnpm --filter @objectstack/knowledge-turso exec vitest run src/__tests__/settings-contribution.test.ts`. Expected: 11 passed. The "without knowledge-turso" block shows no Turso field and a `400 UNKNOWN_KEY` PUT. The "reading its URL from settings" block shows the group in front, a `200` PUT, and the boot-saved URL opened by the store. ## Tests - New `knowledge-turso/src/__tests__/settings-contribution.test.ts` boots a real `LiteKernel` with the settings service, its HTTP door and the knowledge service, and covers three mount cases. Without knowledge-turso: no Turso id on the page, nothing served, a PUT of either key answers `400 UNKNOWN_KEY`, no copy loaded. With knowledge-turso under `urlFromSettings`: the group is the first three specifiers, the PUT saves, `turso_auth_token` stays a secret key, and a `turso_url` saved at `kernel:ready` is opened by the store (healthCheck ok, the file exists, the default file does not). With knowledge-turso given its own `url`: no Turso field. It also checks that the copy is complete in all 11 locales and gone from the settings bundle. - `service-settings` `knowledge-settings-retired-keys.pin.test.ts` runs over the real ObjectQL engine and covers the page without the store. A saved `turso_url` stays stored and is not served, and writes of either key are refused. Once a page that declares the group is registered again, the same stored row is served (`source: global`) and saves. The N2 whole-body pin is here too. - `knowledge.manifest.test.ts`: version 5, `chunk_target` the only key, no Turso id. - End to end: `packages/verify/src/harness.required-providers.test.ts` (file-database arm: `settings.set('knowledge','turso_url', …)` during the boot, then the store opens it) passes on the built packages, 15/15. <details><summary>Package runs (head 5c9170a for knowledge-turso; 37106cf for the three-package run, whose later commits touch only docs, changesets and knowledge-turso's vitest alias)</summary> - `pnpm --filter @objectstack/knowledge-turso --filter @objectstack/service-settings --filter @objectstack/service-knowledge test`: service-settings 78 files / 1543 tests passed; service-knowledge 15 / 470 passed; knowledge-turso 4 / 167 passed. VERDICT command-exit 0. - `pnpm --filter @objectstack/knowledge-turso test` at 5c9170a (after the source alias): 4 files / 167 tests passed. - `typecheck` for the three packages: exit 0, test layers included (`check:test-typecheck: OK` for knowledge-turso and service-knowledge). - `pnpm --filter @objectstack/verify exec vitest run src/harness.required-providers.test.ts`: 15 passed. </details> <details><summary>Ablations (each mutation proven on disk by `scripts/ablation-replace.mjs`, restored to the HEAD blob with `git diff HEAD` empty)</summary> - A1: delete the `contributeKnowledgeTursoSettings(ctx)` call in `plugin.ts`. 4 failed / 7 passed: every with-store pin fails (group, PUT 200, boot-saved URL read, copy loaded). - A2: put the Turso group back into the base `knowledge` manifest. This is the `origin/main` shape of that page. service-settings was rebuilt and `ablation-dist-preflight` found the marker in `dist`. Results: service-settings 14 failed (manifest pins, retired-key page pins, and the 10 locale coverage pins, because the bundles no longer carry the copy); knowledge-turso 4 failed (the no-store page shows the fields and the PUT is no longer `400`; the own-`url` case shows them). Restore leg: rebuilt, then `--absent` preflight passed. - A3: make `setMany` drop an unknown key from a multi-key body instead of refusing it. Only the N2 pin fails: "adapter: expected 200 to be 400". The single-key refusal pins stay green. - A4: make the contribution unconditional, ahead of the `opensFromSettings()` gate. The own-`url` case fails, and so does the copy-locales pin (the copy loads twice). - A5 (non-vacuity of survival): remove the seeded `turso_url` row. The three survival pins fail. </details> ## Acceptance notes - Clause-② measured: on this head the no-store page answers `PUT turso_url` with `400 UNKNOWN_KEY` and the store-mounted page answers `200`. Under A2, which is the `origin/main` page shape, the same refusal pin failed because the PUT was accepted. So the narrowing is real, and it is limited to deployments that do not read the keys. - Not changed, per the fence: the Turso group's description, including the cloud per-organization fallback sentence (#37680), which moved verbatim. The sentence "On PostgreSQL ... these fields are not read" is now never shown on PostgreSQL. #37680 edits that text next. - "Test connection" stays on the base page. On a pgvector deployment it now checks Turso fields the page no longer shows. It answers "No Turso URL configured — where the knowledge store is @objectstack/knowledge-turso …", which is conditional and true. Raised for the seat in the report, not changed here. - The local gate subset (114 derived families, all run, `--ran` reconciled) is in Verification. ## Verification <details><summary>Derived gates — `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` at 5c9170a (26 paths, 114 commands), reconciled with `--ran`: 114 derived, 114 run</summary> - 110 exit 0. - `node scripts/check-empty-changeset.mjs --base origin/main`: exit 1, the DELIBERATE CORRECTION class on `.changeset/37104-knowledge-settings-readers.md`. Red by design, declared above. - `pnpm check:test-source-alias`: exit 1 on the first run, which flagged the new `@objectstack/service-settings` test import. Fixed in 5c9170a; re-run exit 0 ("check-test-source-alias OK"). - `pnpm --filter @objectstack/spec run check:skill-examples`: exit 3, PREREQUISITE NOT MET (needs `client-react` built). NOT MEASURED locally; CI's Lint & Repo Gates runs it. - `pnpm check:dual-build-cjs-loads`: exit 3, PREREQUISITE NOT MET (needs a full `pnpm build`). NOT MEASURED locally; CI runs it. </details> Dogfood battery (`!` title, `(narrowing)` arm): see the report comment on #37678 for the final-head reading. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent e50ab8f commit ff63b02

26 files changed

Lines changed: 683 additions & 139 deletions

‎.changeset/37104-knowledge-settings-readers.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44

55
fix(settings)!: the Knowledge settings page keeps only keys something reads — `adapter`, `over_fetch` and `enforce_rls` are retired
66

7-
Clause-②: no (narrowing) — narrowed: `PUT /api/settings/knowledge` refuses `adapter`, `over_fetch` and `enforce_rls` (`400 UNKNOWN_KEY`), where it stored them; `GET /api/settings/knowledge` no longer serves them; `POST /api/settings/knowledge/test` no longer answers from `adapter` (a stored or sent `ragflow` was "Unknown adapter", `memory` an in-memory warning) and answers every call from `turso_url` and `turso_auth_token` alone
7+
Clause-②: no (narrowing) — narrowed: `PUT /api/settings/knowledge` refuses a body naming `adapter`, `over_fetch` or `enforce_rls` (`400 UNKNOWN_KEY`) whole, where it stored them: no other key in that body is saved; `GET /api/settings/knowledge` no longer serves them; `POST /api/settings/knowledge/test` no longer answers from `adapter` (a stored or sent `ragflow` was "Unknown adapter", `memory` an in-memory warning) and answers every call from `turso_url` and `turso_auth_token` alone
88
Metadata-protocol: none
99
Skills-docs: none — no skill under `skills/**` teaches the three retired keys; `skills/objectstack-ai/SKILL.md` teaches `knowledge.chunk_target`, which stays. `content/docs/ai/knowledge-rag.mdx` says what the page holds.
1010

1111
<!-- adr-0087: not-required (no-migration-prescription) No schema key, accepted value or metadata type is added, removed, renamed or re-shaped: a settings manifest is a runtime registration, not authorable metadata. The narrowed answers are doors of one settings namespace, nothing that `objectstack migrate meta` reads names these keys, and stored rows are untouched. -->
1212

13-
**BREAKING** for a script or client that writes `adapter`, `over_fetch` or `enforce_rls` to the `knowledge` settings namespace: the write is now refused as an undeclared key. Nothing in this repository ever read any of the three, so no deployment behaves differently.
13+
**BREAKING** for a script or client that writes `adapter`, `over_fetch` or `enforce_rls` to the `knowledge` settings namespace: the write is now refused as an undeclared key, and refused whole — no other key in that body is saved, so a body that also changes `chunk_target` saves nothing. Drop the retired key from the body. Nothing in this repository ever read any of the three, so no deployment behaves differently.
1414

1515
On the Knowledge settings page (`knowledge` namespace, manifest `version` 4), every key left has a reader:
1616

17-
- `turso_url` and `turso_auth_token` are read by `@objectstack/knowledge-turso` at startup, where the knowledge store is libSQL — a platform database other than PostgreSQL. On PostgreSQL the store is pgvector, in the platform database, and neither is read; the Turso group now says so and always shows, since the page no longer has an adapter select to gate it on.
17+
- `turso_url` and `turso_auth_token` are read by `@objectstack/knowledge-turso` at startup, where the knowledge store is libSQL — a platform database other than PostgreSQL. On PostgreSQL the store is pgvector, in the platform database, and neither is read.
1818
- `chunk_target` is read by the knowledge service's splitter.
1919

2020
What leaves, and why:
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
'@objectstack/knowledge-turso': patch
3+
'@objectstack/service-settings': patch
4+
---
5+
6+
fix(knowledge-turso)!: the Knowledge page's Turso fields are contributed by the store that reads them — a deployment whose store is pgvector shows none
7+
8+
Clause-②: no (narrowing) — narrowed: where `@objectstack/knowledge-turso` is not mounted (the store is `@objectstack/knowledge-pgvector`, on PostgreSQL), or is mounted with a `url` or `client` of its own, `PUT /api/settings/knowledge` refuses a body naming `turso_url` or `turso_auth_token` (`400 UNKNOWN_KEY`, the whole body), where it stored them, and `GET /api/settings/knowledge` no longer serves them; where the store reads its URL from settings (the `requires: ['knowledge']` mount on any other database) both doors answer as before
9+
Metadata-protocol: none
10+
Skills-docs: none — no skill under `skills/**` teaches `turso_url` or `turso_auth_token`. `content/docs/ai/knowledge-rag.mdx` says where the page shows them.
11+
12+
<!-- adr-0087: not-required (no-migration-prescription) No schema key, accepted value or metadata type is added, removed, renamed or re-shaped: a settings manifest is a runtime registration, not authorable metadata. The narrowed answers are doors of one settings namespace on deployments that do not read the two keys, nothing that `objectstack migrate meta` reads names them, and stored rows are untouched. -->
13+
14+
**BREAKING** for a script or client that writes `turso_url` or `turso_auth_token` to the `knowledge` settings namespace of a deployment that does not mount `@objectstack/knowledge-turso` reading its URL from settings: the write is now refused as an undeclared key, and refused whole — no other key in that body is saved. Nothing on such a deployment ever read either key, so no deployment behaves differently. Drop the two keys from the body.
15+
16+
The Turso group (`turso_url`, `turso_auth_token`) left `@objectstack/service-settings`' `knowledge` manifest (now `version` 5), whose remaining keys all have a reader on every deployment that mounts the knowledge service. `KnowledgeTursoPlugin` adds the group to that page in `init()` when it reads the two keys (`urlFromSettings` with no `url` or `client`, as the runtime's `knowledge` capability mount sets it), in front of the page as before, so:
17+
18+
- on PostgreSQL, where the store is pgvector in the platform database, the Knowledge page shows no Turso fields;
19+
- where the store is the libSQL file, the page shows them, and a saved value is read by the store at the end of the boot exactly as before.
20+
21+
New exports of `@objectstack/knowledge-turso`: `knowledgeTursoSettingsSpecifiers`, `withKnowledgeTursoSection`, `contributeKnowledgeTursoSettings`, `knowledgeTursoSettingsTranslations` and `KNOWLEDGE_SETTINGS_NAMESPACE`. A host that declares the two keys in its own `knowledge` manifest keeps that manifest as written.
22+
23+
Stored values: an environment that saved either key keeps its `sys_platform_setting` row (the auth token's `sys_secret` handle included); the settings service never deletes a stored row. Where the store is not mounted the value is not served and changes nothing, as it changed nothing before; mounted again, the store reads it. To tidy up a PostgreSQL deployment, delete the `knowledge` rows named `turso_url` and `turso_auth_token`; nothing requires it.
24+
25+
The group's copy moved with it: `@objectstack/service-settings`' eleven locale bundles no longer carry the Turso group or its two fields, and `KnowledgeTursoPlugin` loads the same strings, in the same eleven locales, into the i18n service at `kernel:ready`.

‎content/docs/ai/knowledge-rag.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Which store is mounted depends on the platform database:
3535
- **The embedder** comes from Settings → AI & Embedder ([below](#configuring-the-embedder-from-settings)).
3636
- **Another libSQL store** for the `turso` case: save its URL as `turso_url` (and `turso_auth_token` for a managed `libsql://` database) in Settings → Knowledge, then restart. A `file:` URL saved there must name a file inside that same data directory, and a URL carrying a NUL byte or another control character, written out or percent-encoded (`%00`), is refused, as is a token carrying one (a pasted line break counts); either way the store answers `SERVICE_UNAVAILABLE` saying why, and the boot goes on.
3737
- **Where the file is**: `os start --home` and `OS_HOME` move it with the default database, so on a container put `OS_HOME` on a volume and the index survives a redeploy. A database named by URL (`OS_DATABASE_URL`) does not move it.
38-
- **Settings → Knowledge** holds only what the service and its store read: `turso_url` and `turso_auth_token` (read where the store is `turso`; on PostgreSQL nothing reads them) and `chunk_target`, the longest passage the splitter cuts. The page names no adapter: a source's store is the one its own `adapter` names, and `os knowledge status` reports it per source. Every search re-checks each hit as the asking user, and no setting turns that off.
38+
- **Settings → Knowledge** holds only what the service and its store read: `turso_url` and `turso_auth_token`, which `@objectstack/knowledge-turso` adds to the page where it is the store and reads them (on PostgreSQL the page shows neither), and `chunk_target`, the longest passage the splitter cuts. The page names no adapter: a source's store is the one its own `adapter` names, and `os knowledge status` reports it per source. Every search re-checks each hit as the asking user, and no setting turns that off.
3939
- **More than one replica** on MySQL, MongoDB or a remote libSQL database: each replica keeps its own local `knowledge.db` and indexes only the record writes that replica itself handles, so replicas answer from indexes that differ. Give them one store: save a shared `libsql://` URL in `turso_url`, or run on PostgreSQL, where the vectors live in the one database.
4040
- **An install without the libSQL client**: `@objectstack/knowledge-turso` is an optional dependency of the CLI, because its client is a native module. Where it could not be installed the server warns at boot that the store was not mounted, and sources naming `turso` answer `SERVICE_UNAVAILABLE`.
4141
- **Without the token** nothing is mounted: no knowledge service, no store and no Knowledge settings page. `knowledge-memory` is never mounted for you.

‎packages/plugins/knowledge-turso/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
},
3434
"devDependencies": {
3535
"@objectstack/service-knowledge": "workspace:*",
36+
"@objectstack/service-settings": "workspace:*",
3637
"@types/node": "^26.6.5",
3738
"tsx": "^4.23.15",
3839
"typescript": "^6.0.3",

0 commit comments

Comments
 (0)