Repository navigation
Commit ff63b02
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
File tree
- .changeset
- content/docs/ai
- packages
- plugins/knowledge-turso
- src
- __tests__
- services
- service-knowledge/src/__tests__
- service-settings/src
- manifests
- translations
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
0 commit comments