Skip to content

Commit bbd9733

Browse files
fix(knowledge-turso)!: Test connection comes with the Turso fields it checks; the group text drops the cloud fallback (#37982)
repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP Fixes #37907 Fixes #37680 Clause-②: yes (narrowing) Metadata-protocol: none Skills-docs: none — no skill under `skills/**` teaches the Knowledge page's test action, `knowledgeTestActionHandler` or the Turso group's text. ## 维护者速读 - 用户能看到什么变化:PostgreSQL 部署的知识设置页上不再有「测试连接」按钮;用 Turso 存储的部署里,按钮跟 Turso 字段放在一起,说明文字不再提云版按组织复用数据库,改为说明留空即用数据目录里的 knowledge.db。 - 为什么做:知识检索设置的复审收尾,让按钮只出现在它检查的字段旁边,并改正一句与实际不符的说明(云版事实已由云席位核实)。 - 出错会怎样:只影响设置页上的按钮和说明文字,不改任何已存数据;可直接撤回本次合并。 - 要你做什么:无。 ## What changes - **N1 (#37907).** The `test` action_button and `knowledgeTestActionHandler` move from `@objectstack/service-settings` (manifest declaration, handler, package export) and `@objectstack/service-knowledge` (registration) into `@objectstack/knowledge-turso`'s settings contribution. The button is now the last entry of the Turso group, right after `turso_auth_token`, and `contributeKnowledgeTursoSettings` registers the handler only where it adds the group. So: - no knowledge-turso, or knowledge-turso given its own `url`/`client`: the page has no Test connection, and `POST /api/settings/knowledge/test` answers `400 SETTINGS_ACTION_FAILED` (no handler registered), the same envelope as an action no page declares; - knowledge-turso reading its URL from settings: the action is on the page and answers the Turso form check with `200`, as before. - The label moved too: out of the eleven service-settings bundles (`settings.knowledge.actions.test`), into `knowledgeTursoSettingsTranslations`, same strings, all 11 locales in step. - `@objectstack/service-settings` no longer exports `knowledgeTestActionHandler`; `@objectstack/knowledge-turso` does (plus `KNOWLEDGE_TURSO_TEST_ACTION` and two structural types). The migration line is in the changeset. - **N2 (#37907).** `KnowledgeTursoPlugin.init()` warns once when `contributeKnowledgeTursoSettings` returns false under `opensFromSettings()`, naming the consequence (nothing can be saved there, the store opens its default file, path given) and the fix. The function now answers whether the page carries BOTH Turso keys, so a host page declaring one group id without the keys also warns. - **N3 (#37907).** `content/docs/ai/knowledge-rag.mdx` (the Settings → Knowledge bullet) now gives the tidy-up for a PostgreSQL deployment that saved the two Turso keys, naming the `sys_secret` row the `turso_auth_token` row's handle points at. The card's else-branch: the 37678 note is no longer pending (see below). - **#37680, folded.** The Turso group description: the English fallback loses "In a cloud deployment with a database per organization, leave blank to reuse that organization's own database connection." (no deployment does that: cloud fact 7217205358 on #37680), and every locale loses the "On PostgreSQL ... these fields are not read" clause (the group is never shown on PostgreSQL). Each now says "Leave blank to use knowledge.db in the data directory." in its language, 11 locales plus the fallback, in step. Written without backticks around `knowledge.db` because the page renders the string as plain text. - `content/docs/ai/knowledge-rag.mdx` says Test connection comes with the two fields. ### No changeset correction The 37678 note (PR #37902) was consumed by main's version pass (#37661): it now lives at `.changeset/pre/37678-knowledge-turso-settings-group.md` and its text is published in the `19.0.0-next.1` CHANGELOG sections of `@objectstack/knowledge-turso` and `@objectstack/service-settings`. Earlier heads of this PR edited its tidy sentence as a DELIBERATE CORRECTION of a pending note; contract record 7224029827 (S2) showed that edit no longer reaches any reader before the stable cut and would keep the whole `19.0.0-next.1` section at that cut. This head leaves the consumed note byte-identical to main and puts the `sys_secret` clause on the docs page instead, as card #37907 routes it for a note that is no longer pending. The two published CHANGELOG entries are release-owned and are not touched here. This PR's own note is `.changeset/37907-knowledge-turso-test-connection.md` (patch on the three packages, one ADR-0087 marker, BREAKING paragraph for three readers). ## Tests See the report on #37907 for the run log at the final head. New and moved pins: - `packages/plugins/knowledge-turso/src/__tests__/settings-contribution.test.ts` (real LiteKernel, real settings service and HTTP door, real knowledge service): no-store page has no action_button and the test door answers the undeclared-action envelope (control: `never_declared`); store-from-settings page carries `turso, turso_url, turso_auth_token, test` in front and the door answers 200 where the control is 400; own-url page has no action; copy carries the action label in 11 locales and the settings bundle no longer does; the description pin (PostgreSQL named once, `knowledge.db` named, no cloud or "not read" clause, in the fallback and 11 locales); the handler unit pins moved from service-settings; the N2 pins (no settings service and a host page with `test` but no keys each warn once; a contributed page and an own-url store say nothing). - service-settings: the manifest declares no action_button; the retired-keys pin now asserts the no-handler envelope against an undeclared control, and its re-registration case keeps a stub handler. - service-knowledge: the mounted page has no `test` and its door answers as an undeclared action. ## Acceptance notes - `knowledgeTestActionHandler` leaving `@objectstack/service-settings`' entry is a removed export of a published package; the dispatch order and the card name the handler's move, and the changeset carries the FROM/TO import line. Flagged for the seat with the narrowing. - The manifest `version` stays 5: an action_button carries no key, and the spec's bump rule is about keys. ## Verification Two-minute check: `pnpm --filter @objectstack/knowledge-turso exec vitest run src/__tests__/settings-contribution.test.ts` — every describe green, including "has no Test connection" and "answers Test connection with the Turso check". Read first: `packages/plugins/knowledge-turso/src/settings-contribution.ts` (`contributeKnowledgeTursoSettings`: registration order and the new both-keys return), `packages/plugins/knowledge-turso/src/plugin.ts` (`init()` warn), `.changeset/37907-knowledge-turso-test-connection.md`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent f9c6f92 commit bbd9733

26 files changed

Lines changed: 507 additions & 303 deletions
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
'@objectstack/knowledge-turso': patch
3+
'@objectstack/service-settings': patch
4+
'@objectstack/service-knowledge': patch
5+
---
6+
7+
fix(knowledge-turso)!: the Knowledge page's "Test connection" comes with the Turso fields it checks — a page without them has no such action
8+
9+
Clause-②: yes (narrowing) — the public surface grows by four exports of `@objectstack/knowledge-turso` (listed below); narrowed: where `@objectstack/knowledge-turso` does not contribute its Turso group (the store is `@objectstack/knowledge-pgvector`, on PostgreSQL, or the store is mounted with a `url` or `client` of its own), the Knowledge page has no "Test connection" action and `POST /api/settings/knowledge/test` answers `400 SETTINGS_ACTION_FAILED` (no handler registered), as every undeclared action does, where it answered the Turso form check with `200`; where the store reads its URL from settings, the action is on the page, beside the two fields, and answers as before. `@objectstack/service-settings` no longer exports `knowledgeTestActionHandler`; `@objectstack/knowledge-turso` does
10+
Metadata-protocol: none
11+
Skills-docs: none — no skill under `skills/**` teaches the Knowledge page's test action or `knowledgeTestActionHandler`.
12+
13+
<!-- 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 and its action handlers are runtime registrations, not authorable metadata, and nothing `objectstack migrate meta` reads names the action. -->
14+
15+
**BREAKING** for three readers:
16+
17+
- A script or client that posts to `POST /api/settings/knowledge/test` on a deployment where the Turso fields are not on the page now gets `400 SETTINGS_ACTION_FAILED`. The check it answered there read fields nothing on that deployment reads, and opened no connection. Stop calling it there.
18+
- Code that imports `knowledgeTestActionHandler` from `@objectstack/service-settings`: import it from `@objectstack/knowledge-turso` instead (`import { knowledgeTestActionHandler } from '@objectstack/knowledge-turso'`). Same check, same answers. `@objectstack/knowledge-turso` depends on the native libSQL client (`@libsql/client`); importing the handler loads nothing native, but installing the package installs that dependency.
19+
- A host that registers its own `knowledge` settings page declaring `turso_url`, `turso_auth_token` and the `test` action: `KnowledgeTursoPlugin` leaves that page as written and registers no handler for it, so its `test` button now answers `400 SETTINGS_ACTION_FAILED`. Register the handler yourself after registering the page: `settings.registerAction('knowledge', 'test', knowledgeTestActionHandler)`, with `knowledgeTestActionHandler` imported from `@objectstack/knowledge-turso`.
20+
21+
The `test` action left `@objectstack/service-settings`' `knowledge` manifest, and `@objectstack/service-knowledge` no longer registers its handler. `KnowledgeTursoPlugin` declares it as the last entry of the Turso group, after `turso_auth_token`, and registers `knowledgeTestActionHandler` with it, only where it contributes the group. The action's label moved with it, in all eleven locales: out of `@objectstack/service-settings`' bundles, into `knowledgeTursoSettingsTranslations`.
22+
23+
New exports of `@objectstack/knowledge-turso`: `knowledgeTestActionHandler`, `KNOWLEDGE_TURSO_TEST_ACTION`, and the types `KnowledgeTursoActionInput` and `KnowledgeTursoActionResult`.
24+
25+
`KnowledgeTursoPlugin` now warns once, at `init()`, when it reads its URL from settings but the Knowledge page cannot carry `turso_url` and `turso_auth_token` (no settings service, no `knowledge` page, or a host page that declares one of the group's ids without both keys): nothing can be saved there, and the store opens its default file, which the line names.
26+
27+
The Turso group's description no longer says that a cloud deployment with a database per organization reuses that organization's database for a blank URL (no deployment does: a blank URL opens `knowledge.db` in the data directory), and no longer says the fields are not read on PostgreSQL (the group is never on the page there). It says instead that a blank URL uses `knowledge.db` in the data directory, in all eleven locales.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Which store is mounted depends on the platform database:
3636
- **The embedder** comes from Settings → AI & Embedder ([below](#configuring-the-embedder-from-settings)).
3737
- **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.
3838
- **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.
39-
- **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.
39+
- **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, with the "Test connection" check of those two fields (on PostgreSQL the page shows none of the three), 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. A PostgreSQL deployment that saved the two Turso keys before the group left the page keeps their rows; the settings service never deletes a stored row. To tidy it up, delete the `knowledge` rows named `turso_url` and `turso_auth_token`, and the `sys_secret` row the `turso_auth_token` row's handle names: without the store no API door clears that key, and the row is a decryptable copy of the token. Nothing requires it.
4040
- **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.
4141
- **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`.
4242
- **Without a source or 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/src/__tests__/plugin.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,17 @@ describe('resolveSettingsStoreUrl', () => {
296296
* A settings service answering saved `knowledge` values as `SettingsService.get`
297297
* resolves them — and, as the real one does, only once its data engine is
298298
* bound: until `bound` is set a saved value reads as the manifest default.
299+
* It serves a `knowledge` page the plugin's init() contributes the Turso group
300+
* to, as the knowledge service's page is on a real boot.
299301
*/
300302
function settingsOf(saved: Record<string, string | undefined>, failure?: Error) {
303+
let page = { namespace: 'knowledge', specifiers: [] as Array<{ key?: string; id?: string }> };
301304
const settings = {
302305
bound: false,
303306
reads: 0,
307+
getManifest: () => page,
308+
registerManifest: (m: typeof page) => { page = m; },
309+
registerAction: () => undefined,
304310
get: async (namespace: string, key: string) => {
305311
settings.reads += 1;
306312
if (failure) throw failure;

0 commit comments

Comments
 (0)