diff --git a/.changeset/knowledge-id-underscore-exception.md b/.changeset/knowledge-id-underscore-exception.md new file mode 100644 index 00000000000..0d9892fa0fd --- /dev/null +++ b/.changeset/knowledge-id-underscore-exception.md @@ -0,0 +1,8 @@ +--- +'@objectstack/spec': patch +--- + +docs(spec): the `knowledge_source.id` tombstone and the `knowledge-source-registration-governed` upgrade entry name the underscore exception and the `dropSource` cleanup, and say the old index outlives a restart only on a store that persists + +Clause-②: no +Metadata-protocol: none diff --git a/content/docs/protocol/knowledge.mdx b/content/docs/protocol/knowledge.mdx index a4b04b385e7..22169bd532e 100644 --- a/content/docs/protocol/knowledge.mdx +++ b/content/docs/protocol/knowledge.mdx @@ -155,7 +155,7 @@ write instead, and `os migrate meta --from 18` converts the mechanical ones: | Before 19 | Now | |:--|:--| -| `id` | `name` (the value is unchanged, so the index is found again) | +| `id` | `name` (the value is unchanged, so the index is found again). One exception: `name` refuses a leading underscore, so a source whose `id` began with one takes a new name and is built again from nothing under it; the adapter still holds the index under the old id, which nothing searches or drops, so call `dropSource({ source })` on that adapter (`IKnowledgeService.getAdapter`) with the source's `name` set to the old id once the new build completes. An adapter without `dropSource`, or one whose store does not outlive the process (memory), has nothing to drop or keeps it until removed in its own store | | `source.contentFields` | `source.content` (a `'*'` member is replaced by hand with the field names) | | `embedding`, `vectorStore` | removed: the embedder and the store are the deployment's, never a source's | | `adapterConfig` | removed: an adapter takes its settings as options of the plugin that mounts it | diff --git a/content/docs/references/ai/knowledge-source.mdx b/content/docs/references/ai/knowledge-source.mdx index 08cd6efcb41..70b56ddcce5 100644 --- a/content/docs/references/ai/knowledge-source.mdx +++ b/content/docs/references/ai/knowledge-source.mdx @@ -51,7 +51,7 @@ const result = KnowledgeRefreshPolicySchema.parse(data); | Property | Type | Required | Description | | :--- | :--- | :--- | :--- | | **name** | `string` | ✅ | Source machine name (snake_case) — what search_knowledge lists and its sourceIds argument names | -| **id** | `never` | optional | [REMOVED] `knowledge_source.id` was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — a knowledge source is a metadata item, and an item is identified by `name`; use `name`. Rename the key; the value is unchanged, so the source's index is found again and is not rebuilt. A source registered in code (`KnowledgeServicePlugin({ sources })`, `registerSource`) is in no stack collection, so `os migrate meta` lists no edit for it: make this edit in the registration itself. Run `os migrate meta --from 18` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | +| **id** | `never` | optional | [REMOVED] `knowledge_source.id` was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — a knowledge source is a metadata item, and an item is identified by `name`; use `name`. Rename the key; the value is unchanged, so the source's index is found again and is not rebuilt, except for a source whose id began with an underscore: `name` refuses the underscore, so that source takes a new name, is built again under it, and its old index is dropped with `dropSource`; the upgrade entry `knowledge-source-registration-governed` says how, and its notices still apply after the conversion. A source registered in code (`KnowledgeServicePlugin({ sources })`, `registerSource`) is in no stack collection, so `os migrate meta` lists no edit for it: make this edit in the registration itself. Run `os migrate meta --from 18` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **label** | `string` | ✅ | | | **description** | `string` | optional | | | **adapter** | `string` | optional | Adapter id; omitted means the deployment's store (pgvector on PostgreSQL, turso otherwise), else the only adapter registered | diff --git a/packages/spec/src/ai/knowledge-source.zod.ts b/packages/spec/src/ai/knowledge-source.zod.ts index 2cde523e7f3..127f5c8c913 100644 --- a/packages/spec/src/ai/knowledge-source.zod.ts +++ b/packages/spec/src/ai/knowledge-source.zod.ts @@ -252,7 +252,9 @@ export const KnowledgeSourceSchema = lazySchema(() => strictObject( id: retiredKey( '`knowledge_source.id` was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — ' + 'a knowledge source is a metadata item, and an item is identified by `name`; use `name`. ' - + 'Rename the key; the value is unchanged, so the source\'s index is found again and is not rebuilt. ' + + 'Rename the key; the value is unchanged, so the source\'s index is found again and is not rebuilt, except for a source whose id began with an underscore: `name` refuses the underscore, so ' + + 'that source takes a new name, is built again under it, and its old index is dropped with `dropSource`; ' + + 'the upgrade entry `knowledge-source-registration-governed` says how, and its notices still apply after the conversion. ' + CODE_DOOR_18 + MIGRATE_18, ), diff --git a/packages/spec/src/migrations/entries/semantic/19.knowledge-source-registration-governed.ts b/packages/spec/src/migrations/entries/semantic/19.knowledge-source-registration-governed.ts index 7733aa38f82..c66269e1428 100644 --- a/packages/spec/src/migrations/entries/semantic/19.knowledge-source-registration-governed.ts +++ b/packages/spec/src/migrations/entries/semantic/19.knowledge-source-registration-governed.ts @@ -46,8 +46,8 @@ export const entry: SemanticMigration = { + 'began with an underscore. Its name has to change, and an adapter keys everything it holds for a source ' + 'by the source\'s name. So the renamed source is built from nothing under its new name, as a source the ' + 'adapter has never held is: every record it covers is read, and on an adapter that embeds, the content ' - + 'fields of each are sent to the embedding provider again. The adapter also keeps the index it built ' - + 'under the old id. No source ' + + 'fields of each are sent to the embedding provider again. On an adapter whose store outlives the process (Turso, pgvector) the adapter also keeps the index it built ' + + 'under the old id; the memory adapter holds nothing across a restart. No source ' + 'holds that key any more: nothing searches that index or keeps it in step with the records, and nothing ' + 'drops it, because the service drops the index of a `knowledge_source` item it stops serving and never ' + 'that of a registration in code. A source registered in code shares one slot with a source of the same '