From 44d6af1c77ab4fdd18ff1bba8e0ac0c5bae5060d Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 13:09:43 +0000 Subject: [PATCH 1/4] docs(adr,spec): ADR-0084 notes catch up with the knowledge_source row; knowledge_source tombstones name the code door ADR-0084: a dated note under the type-to-group table reads the registry again (35 entries, 34 rows, AI 5), the fold sentence and the 2026-11-25 amendment-table row are marked for the second AI row, and item 6 is headed for both types it places. No row, order or tier changes. knowledge_source: each prescription that names `os migrate meta` first says what the author of a registration in code does, and the D3 entry knowledge-source-registration-governed states what a source whose 18 id began with an underscore leaves behind and how it is dropped. Text only. Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP Co-authored-by: Claude --- ...cation-builder-information-architecture.md | 10 +++--- packages/spec/src/ai/knowledge-source.test.ts | 25 ++++++++++++++- packages/spec/src/ai/knowledge-source.zod.ts | 19 +++++++++++ ....knowledge-source-registration-governed.ts | 32 ++++++++++++++++--- 4 files changed, 76 insertions(+), 10 deletions(-) diff --git a/docs/adr/0084-application-builder-information-architecture.md b/docs/adr/0084-application-builder-information-architecture.md index f05329a69e1..c875de98e82 100644 --- a/docs/adr/0084-application-builder-information-architecture.md +++ b/docs/adr/0084-application-builder-information-architecture.md @@ -168,7 +168,7 @@ The group's name is decision 11's, not the domain's dictionary word: `system` is ### Type → group {#type-to-group} -Every type the spec registers, enumerated at `origin/main` `151e8123` from `packages/spec/src/kernel/metadata-plugin.zod.ts#DEFAULT_METADATA_TYPE_REGISTRY` — 32 entries, the same 32 names as the enum `packages/spec/src/kernel/metadata-plugin.zod.ts#MetadataTypeSchema` *(33 at the 2026-11-25 reading, in the note under the table)*: +Every type the spec registers, enumerated at `origin/main` `151e8123` from `packages/spec/src/kernel/metadata-plugin.zod.ts#DEFAULT_METADATA_TYPE_REGISTRY` — 32 entries, the same 32 names as the enum `packages/spec/src/kernel/metadata-plugin.zod.ts#MetadataTypeSchema` *(33 at the 2026-11-25 reading and 35 at the 2026-11-27 one, in the notes under the table)*: | Group | `domain` | Order | Registered type | Tier | |---|---|---|---|---| @@ -211,6 +211,8 @@ Every type the spec registers, enumerated at `origin/main` `151e8123` from `pack *(Rewritten 2026-11-26, card [#37564](https://github.com/objectstack-ai/objectstack/issues/37564), which carries out [Amendment (2026-11-26)](#amendment-2026-11-26-moves) for two rows and decides nothing: `dataset` and `position`. `dataset` is registered `data` by the same change, so its row leaves 界面 UI, where it was seventh, for 数据 Data, where it is second, directly after `object`; each 数据 Data type behind it is one place later, and its tier is 常用. `position` keeps its place, and its tier is 常用. The registry holds the same 33 entries, and the rows now count 数据 Data 8 · 界面 UI 6 · 自动化 Automation 2 · 平台 Platform 7 · 访问 Access 6 · AI 4. The `datasource` row is not touched and `form` has no row yet: each is rewritten, or written, by the change that moves it.)* +*(Amended 2026-11-27, card [#37740](https://github.com/objectstack-ai/objectstack/issues/37740), which catches the notes up with a row the table already holds and decides nothing: `knowledge_source`, the table's last row. The row was written by the change that registered the type (card [#37304](https://github.com/objectstack-ai/objectstack/issues/37304); [ADR-0161](./0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md) K4), under [item 6](#amendment-2026-11-25-silent), and that change left the two notes above at their own readings. Read again at `origin/main` `bc173343ea`: 35 entries — the 33 of those readings, each in the domain the 2026-11-26 note leaves it in, and two registered on 2026-11-27: `form`, registered `ui` ([ADR-0159](./0159-forms-are-their-own-metadata-type-public-forms-are-form-items-view-is-lists-only.md) D2; card [#37086](https://github.com/objectstack-ai/objectstack/issues/37086)), and `knowledge_source`, registered `ai`. `form` still has no row: Studio's directory does not list the type yet, and its row is written by the change that lists it ([Amendment (2026-11-26)](#amendment-2026-11-26-moves)). So the table has 34 rows for the 35 entries, and they count 数据 Data 8 · 界面 UI 6 · 自动化 Automation 2 · 平台 Platform 7 · 访问 Access 6 · AI 5. No type changed group since the 2026-11-26 note, and the `datasource` row is still not touched.)* + The rows are in the menu's order: by group, then by **Order**, which counts inside a group. **Tier** is 常用 Common or 高级 Advanced. The Chinese word beside a registered name is the one the ruling or its proposal uses for that type; a type neither names in Chinese has none. `field` carries no order and no tier because it draws no row (the second reading below). The table is the registry read at one commit. **The rule above is what binds**: a type added to the registry, or given another domain there, moves in the menu without this table being edited, and where the two disagree the registry is right. *(Amended 2026-11-25: that sentence is about the Group and `domain` columns. The Order and Tier columns are read from no registry — they are decided in this record, and a type the table has no row for is drawn in 高级 Advanced, at the end of its group: [Amendment (2026-11-25)](#amendment-2026-11-25).)* @@ -287,7 +289,7 @@ The six groups of decision 11 stand, and so does the rule that a type's group is - AI: 智能体 `agent` · 工具 `tool` · 技能 `skill` — the last visible group - **高级 Advanced** — one collapsed fold under the 常用 groups. It holds every other type and every entry that is not a type, each under its group's label, in the order of the [type → group table](#type-to-group). The ruling names three of them: 选项列表 `picklist`, 邮件模板 `email_template`, and 默认共享, the default sharing overview. A 高级 type is drawn by the area's existing rule, when the package holds one. -A group's label is drawn in a tier only where the group has an entry in that tier (§3.3). 平台 Platform holds no 常用 type, so its label is drawn inside the fold alone. AI is the last of the five groups drawn above the fold, and its label is drawn again inside the fold only where a package holds an `ai_context` ([item 6](#amendment-2026-11-25-silent)). +A group's label is drawn in a tier only where the group has an entry in that tier (§3.3). 平台 Platform holds no 常用 type, so its label is drawn inside the fold alone. AI is the last of the five groups drawn above the fold, and its label is drawn again inside the fold only where a package holds an `ai_context` ([item 6](#amendment-2026-11-25-silent)). *(Amended 2026-11-27, card [#37740](https://github.com/objectstack-ai/objectstack/issues/37740): AI holds two 高级 types since `knowledge_source` was registered, so its label is drawn again inside the fold where a package holds an `ai_context` or a `knowledge_source` — the [note under the table](#type-to-group) and [item 6](#amendment-2026-11-25-silent).)* The four [entries that are not a type](#entries-not-a-type) are 高级 on a package. Each is drawn after the types of its group, the default sharing overview before the cross-package directory — where the menu adds them today (§3.4). @@ -314,7 +316,7 @@ The rule sorts the next type; the table records what was ruled. Where the mainta | The 2026-11-24 amendment, at "Audience routing" and in [its own table](#amendment-stands): "the menu draws no audience tier" | Replaced: the menu draws two tiers. The sentence beside it stands — the line between audiences runs between Studio and Setup (ADR-0146 D1). | | The menu's drawing: six groups, flat | Stands as the six groups and their order. On a package they are drawn in two tiers. | | "A type's group is its registered `domain`"; one type, one group; a seventh group is a seventh `domain` value | Stand. A tier is not a group, and no type is listed twice. | -| The type → group table | Redrawn one row per type, with the Order and Tier columns. No type changed group. One row is new: `ai_context`, registered that day ([item 6](#amendment-2026-11-25-silent)). | +| The type → group table | Redrawn one row per type, with the Order and Tier columns. No type changed group. One row is new: `ai_context`, registered that day ([item 6](#amendment-2026-11-25-silent)). *(Amended 2026-11-27, card [#37740](https://github.com/objectstack-ai/objectstack/issues/37740): a second row has been written under that item since — `knowledge_source`, registered `ai` on 2026-11-27.)* | | "Which rows the menu draws stays the area's existing rule" | Narrowed: on a package a 常用 type is always drawn. The area's rule stays for the 高级 types, and `field` still draws no row. | | The 2026-07-01 "Advanced" — the Settings area's technical tier (TL;DR 5 and 6) | Not brought back. It was an area outside the pillars, and the 2026-11-24 amendment replaced it. 高级 is a fold of the one menu, and every type in it keeps its group. | | [ADR-0146](./0146-studio-designs-setup-administers-one-editor-per-item-paired-customize-package.md) D1 | Not edited: it defers the menu to this record. | @@ -328,7 +330,7 @@ Merging accepts them; an objection names the number. 3. **Where the four entries that are not a type sit.** After the types of their group, as §3.4 leaves them. The proposal's per-type table (§2) lists the organization's own flows between `flow` and `job`; this record follows §3.4, so on a package that holds a `job`, that type's entry is drawn above the organization's flows. 4. **The tiers' English names.** The ruling names the tiers in Chinese. This record writes Common and Advanced, after the two values of the proposal's list (§3.4). 5. **The table's shape.** One row per type, so that each type carries its own order and tier. Order counts inside a group, because the order of the groups is the six-group table's. -6. **A type registered after the ruling was written: `ai_context`.** The proposal and the ruling were made on a registry of 32 types. `ai_context`, the context pack of [ADR-0160](./0160-record-scoped-ai-inquiry.md) D1, was registered under `ai` the same day, after both. The maintainer's words on AI are 「AI 应该提到第一层分类,放在最下面」, and the ruling record lists the group's 常用 types as 智能体 · 工具 · 技能: three types, and not this one. Three ruled sentences place it, and they agree: its schema requires one root object, so the first test of the rule sorts it 高级; 高级 holds every type the ruling does not list as 常用; and a type with no row is drawn at the end of its group. The table writes that down as a row — last in AI, 高级 — so that the placement list has a row to mirror. If every AI type is meant to be 常用, the tier of this one row is the word to change. +6. **~~A type registered after the ruling was written: `ai_context`.~~ Types registered after the ruling was written: `ai_context`, and since then `knowledge_source`.** *(Heading reworded 2026-11-27, for the second row that points here; the note that ends this item says what changed.)* The proposal and the ruling were made on a registry of 32 types. `ai_context`, the context pack of [ADR-0160](./0160-record-scoped-ai-inquiry.md) D1, was registered under `ai` the same day, after both. The maintainer's words on AI are 「AI 应该提到第一层分类,放在最下面」, and the ruling record lists the group's 常用 types as 智能体 · 工具 · 技能: three types, and not this one. Three ruled sentences place it, and they agree: its schema requires one root object, so the first test of the rule sorts it 高级; 高级 holds every type the ruling does not list as 常用; and a type with no row is drawn at the end of its group. The table writes that down as a row — last in AI, 高级 — so that the placement list has a row to mirror. If every AI type is meant to be 常用, the tier of this one row is the word to change. *(Amended 2026-11-27, card [#37740](https://github.com/objectstack-ai/objectstack/issues/37740), which decides nothing: a second type has been registered under `ai` since the ruling — `knowledge_source`, on 2026-11-27 ([ADR-0161](./0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md) K4) — and the change that registered it wrote its row under this item: fifth in AI, 高级. So `ai_context`'s row is the fourth, and no longer the last in AI. The ruling record's list of the group's 常用 types, 智能体 · 工具 · 技能, does not name this type either, and the same three sentences place it: its schema requires one object (the `object` key of its `source`, `packages/spec/src/ai/knowledge-source.zod.ts#ObjectKnowledgeSourceSchema`), so the first test of the rule sorts it 高级; 高级 holds every type the ruling does not list as 常用; and a type with no row is drawn at the end of its group. The sentence before this note holds for each of the two rows: if every AI type is meant to be 常用, the tier of that row is the word to change.)* The ruling also carries, as proposed and not restated here: the menu's visual hierarchy (§3.3), the placement list and its two pins (§3.4), how the fold is opened, remembered and searched (§3.5), and that no address changes (§3.9). Those are the work of #37200 and #37201. diff --git a/packages/spec/src/ai/knowledge-source.test.ts b/packages/spec/src/ai/knowledge-source.test.ts index 0acb02d6a0c..56ebce2f5d4 100644 --- a/packages/spec/src/ai/knowledge-source.test.ts +++ b/packages/spec/src/ai/knowledge-source.test.ts @@ -11,6 +11,9 @@ // dropped; // - the six renamed or removed keys are tombstones, each refused with its own // prescription, and the `file` / `http` kinds are refused with theirs; +// - a prescription that names `os migrate meta` first names the door every +// source written against 18 came through, a registration in code, which +// that command does not walk, and says the edit is made there; // - `content` is a non-empty list of field names, and `'*'` is refused; // - `name` takes the router-addressable grammar (ADR-0150 D5). // @@ -44,6 +47,24 @@ function issuesOf(input: unknown): Array<[string, string, string]> { return r.error.issues.map((i) => [i.code, i.path.join('.'), i.message]); } +/** + * The door every source written against 18 came through: a registration in + * code. No stack could hold `knowledgeSources` before the type, and + * `os migrate meta` walks a stack's collections, so it lists no edit for one. + */ +const CODE_DOOR = ['`KnowledgeServicePlugin({ sources })`', '`registerSource`', 'in the registration itself']; + +/** `message` names the code door and where the edit is made, before the sentence that names the command. */ +function expectCodeDoorBeforeCommand(message: string): void { + const command = message.indexOf('Run `os migrate meta --from 18`'); + expect(command, 'the prescription names the command').toBeGreaterThan(-1); + for (const named of CODE_DOOR) { + const at = message.indexOf(named); + expect(at, `${named} is named`).toBeGreaterThan(-1); + expect(at, `${named} is named before the command`).toBeLessThan(command); + } +} + describe('KnowledgeSourceSchema — the one schema of the knowledge_source type', () => { it('positive control: a source parses, with its defaults stated', () => { const parsed: KnowledgeSourceParsed = KnowledgeSourceSchema.parse(SOURCE); @@ -150,13 +171,14 @@ describe('KnowledgeSourceSchema — the renamed and removed keys are tombstones 'refresh.cron', 'call `reindexSource` from a flow or a job', ], - ])('`%s` is refused at its own path with its prescription and the migrate sentence', (key, input, path, fix) => { + ])('`%s` is refused at its own path with its prescription, the code door and the migrate sentence', (key, input, path, fix) => { const issues = issuesOf(input); expect(issues).toHaveLength(1); const [code, at, message] = issues[0]!; expect([code, at]).toEqual(['invalid_type', path]); expect(message).toContain(`\`knowledge_source.${key}\` was removed in @objectstack/spec 19.0.0 (ADR-0161 K6)`); expect(message).toContain(fix); + expectCodeDoorBeforeCommand(message); expect(message.endsWith(MIGRATE)).toBe(true); }); @@ -191,6 +213,7 @@ describe('KnowledgeSourceSchema — `content` lists fields (ADR-0161 K5)', () => expect([code, at]).toEqual(['invalid_format', 'source.content.1']); expect(message).toContain("the `'*'` member was removed in @objectstack/spec 19.0.0 (ADR-0161 K5)"); expect(message).toContain("List the fields whose text should be indexed, for example `content: ['title', 'body']`."); + expectCodeDoorBeforeCommand(message); }); it('refuses an empty list and an absent one', () => { diff --git a/packages/spec/src/ai/knowledge-source.zod.ts b/packages/spec/src/ai/knowledge-source.zod.ts index 52cc3af61ae..0d433e77468 100644 --- a/packages/spec/src/ai/knowledge-source.zod.ts +++ b/packages/spec/src/ai/knowledge-source.zod.ts @@ -27,6 +27,18 @@ const DROPPED_BEFORE_19 = const MIGRATE_18 = '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.'; +/** + * What the author of a registration in code does, said in every prescription + * below that names the command. Every source written against 18 is such a + * registration: no stack could hold `knowledgeSources` before this type, and + * `os migrate meta` replays its conversions over a stack's collections, never + * over a plugin's options or a `registerSource` call. It stands before the + * `os migrate meta` sentence, which stays the last one of its prescription. + */ +const CODE_DOOR_18 = + '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. '; + /** * The prescription for `source.kind: 'file'` and `'http'`, and for the four * keys those two arms carried (ADR-0161 K4, point 1): the arms had no reader. @@ -58,6 +70,7 @@ export const KnowledgeRefreshPolicySchema = lazySchema(() => strictObject( + 'it was parsed and reached no engine: nothing ever scheduled a reindex from it. Delete the key. ' + 'To rebuild on a schedule, call `reindexSource` from a flow or a job; keeping the index correct between ' + 'events is the service\'s reconcile pass. ' + + CODE_DOOR_18 + MIGRATE_18, ), }, @@ -156,6 +169,7 @@ export const ObjectKnowledgeSourceSchema = lazySchema(() => strictObject( + '19.0.0 (ADR-0161 K5) — embedding is egress, and `\'*\'` sent every text field of the record to the ' + 'embedder, including one added to the object later. List the fields whose text should be indexed, ' + 'for example `content: [\'title\', \'body\']`. ' + + CODE_DOOR_18 + 'Run `os migrate meta --from 18` to list the mechanical edits for the renamed-key case; `--write` applies the ones it can prove, and reports a wildcard member for you to replace by hand.', }), ).min(1).describe('Fields whose text is indexed, in order; every name is listed (no wildcard)'), @@ -167,6 +181,7 @@ export const ObjectKnowledgeSourceSchema = lazySchema(() => strictObject( + 'the key is spelled `content` now that a source is a metadata item; use `content`. ' + 'Rename the key; the value (a list of field names) is unchanged, except that a `\'*\'` member is no longer ' + 'accepted and is replaced by the field names it stood for. ' + + CODE_DOOR_18 + MIGRATE_18, ), /** @@ -238,6 +253,7 @@ export const KnowledgeSourceSchema = lazySchema(() => strictObject( '`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. ' + + CODE_DOOR_18 + MIGRATE_18, ), /** Human-readable label. */ @@ -256,6 +272,7 @@ export const KnowledgeSourceSchema = lazySchema(() => strictObject( '`knowledge_source.adapterConfig` was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — ' + 'no adapter read it: its one reader was the retired RAGFlow adapter. Delete the key. ' + 'An adapter takes its settings as options of the plugin that mounts it. ' + + CODE_DOOR_18 + MIGRATE_18, ), /** What gets indexed. */ @@ -267,6 +284,7 @@ export const KnowledgeSourceSchema = lazySchema(() => strictObject( '`knowledge_source.embedding` was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — ' + 'it was never read: no service and no adapter chose a model from it. Delete the key. ' + 'The embedder is configured once for the deployment, and every source is embedded by it. ' + + CODE_DOOR_18 + MIGRATE_18, ), /** @@ -276,6 +294,7 @@ export const KnowledgeSourceSchema = lazySchema(() => strictObject( '`knowledge_source.vectorStore` was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — ' + 'it was never read: no service and no adapter chose a store from it. Delete the key. ' + 'The store is the adapter the deployment installs, named by `adapter`. ' + + 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 6b543824135..2438d1cc8b7 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 @@ -10,6 +10,14 @@ import type { SemanticMigration } from '../../types.js'; // over one stack can repair. The holder of a code registration and the reading // of a name in code are ruling 7192063608 on #37304 (ADR-0150 addendum of // 2026-11-25, points 4 and 6). +// +// One source is outside "nothing is rebuilt": one whose 18 `id` began with an +// underscore. `name` refuses the underscore (`ROUTER_ADDRESSABLE_NAME_PATTERN`), +// an adapter keys what it holds by the source's name +// (`AdapterContext.source.name`), and the service drops an index only for a +// metadata item it stops serving (`KnowledgeService.dropMetadataSource`; +// `unregisterSource` leaves the index with its adapter). So the entry says what +// the rename leaves behind and how it is dropped. export const entry: SemanticMigration = { id: 'knowledge-source-registration-governed', surface: @@ -22,7 +30,11 @@ export const entry: SemanticMigration = { + 'starts with a letter, and no key the type does not declare. Prefer shipping it as metadata, in the ' + 'stack\'s `knowledgeSources`. Give a source registered in code a name no source authored in the ' + 'environment uses. Where a package ships a source of the same name, name the package\'s source by its ' - + 'face `NAMESPACE-NAME` and the one registered in code by its bare name.', + + 'face `NAMESPACE-NAME` and the one registered in code by its bare name. A source whose `id` began with ' + + 'an underscore takes a new name; once it has been built under that name, drop the index its adapter ' + + 'still holds under the old id: call `dropSource({ source })` on that adapter ' + + '(`IKnowledgeService.getAdapter`), where `source` is the source with its `name` set to the old id. An ' + + 'adapter without `dropSource` keeps that index until it is removed in the adapter\'s own store.', reason: 'Before this release the code door stored what it was given: a key the schema did not declare was ' + 'kept and ignored, an id could start with an underscore, and a second registration of an id replaced ' @@ -30,19 +42,29 @@ export const entry: SemanticMigration = { + 'refused when the source is registered, with the parse\'s own prescription; the D2 conversion renames ' + '`id` in a stack, and a TypeScript registration that still writes it does not compile. A source ' + 'registered in code belongs to no package: it is read as the environment\'s own source and keeps its ' - + 'name, its index and its documents, so nothing is rebuilt. It shares one slot with a source of the same ' + + 'name, its index and its documents, so nothing is rebuilt. One source is the exception: one whose `id` ' + + '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, at the next boot or by ' + + '`os knowledge rebuild` where `buildAtBoot` is `false`, which sends its content fields to the embedding ' + + 'provider again for every record; and the adapter keeps the index it built under the old id. 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 ' + 'name authored in the environment, and whichever of the two arrives second is refused (409 ' + 'RESOURCE_CONFLICT, naming both doors) instead of replacing the first; registering the same name again ' + 'through the code door still replaces the earlier registration. A package may ship a source of that ' + 'name too, and both are kept: a bare name then means the one registered in code, and the package\'s is ' + 'named by its face. A hit\'s `sourceId` is that same spelling, so it is no longer always the bare name. ' - + 'Whether a key the door used to ignore stated something the author still wants, and which of two ' - + 'same-named sources a caller meant, only the application\'s author knows.', + + 'Whether a key the door used to ignore stated something the author still wants, which of two ' + + 'same-named sources a caller meant, and when an index left under an old id may be dropped, only the ' + + 'application\'s author knows.', acceptanceCriteria: 'Every source the application registers in code parses with `KnowledgeSourceSchema` and the application ' + 'boots with no refusal from the knowledge service. No source registered in code shares its name with a ' + 'source authored in the environment. Code that compares a hit\'s `sourceId`, or passes a source id to ' + 'the knowledge service, uses the spelling `search_knowledge` lists for that source. A search that ' - + 'answered before the upgrade answers the same records after it, without a rebuild.', + + 'answered before the upgrade answers the same records after it, without a rebuild. For a source whose ' + + '`id` began with an underscore, it answers them once the one build under the new name is complete, and ' + + 'the adapter holds nothing under the old id.', conversionIds: ['knowledge-source-id-to-name'], }; From ad0d77394ca13a2646ad569e79cd9a58f104f0ea Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 13:53:50 +0000 Subject: [PATCH 2/4] docs(spec): regenerate the knowledge_source reference page; changeset for the tombstone text `check:generated` found one artifact stale after the tombstone change, content/docs/references/**, and `--fix` rewrote one page of it: content/docs/references/ai/knowledge-source.mdx. The changeset is a patch on @objectstack/spec: text only, no schema shape. Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP Co-authored-by: Claude --- ...41-knowledge-source-code-door-prescription.md | 13 +++++++++++++ content/docs/references/ai/knowledge-source.mdx | 16 ++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 .changeset/37741-knowledge-source-code-door-prescription.md diff --git a/.changeset/37741-knowledge-source-code-door-prescription.md b/.changeset/37741-knowledge-source-code-door-prescription.md new file mode 100644 index 00000000000..3e7cee55228 --- /dev/null +++ b/.changeset/37741-knowledge-source-code-door-prescription.md @@ -0,0 +1,13 @@ +--- +'@objectstack/spec': patch +--- + +fix(spec): the `knowledge_source` tombstones say what the author of a registration in code does + +Clause-②: no +Metadata-protocol: none + +Text only. No schema shape changes, and nothing that parsed is refused. + +- **The prescriptions.** Each prescription of a renamed or removed `knowledge_source` key that ends with `os migrate meta --from 18` (`id`, `source.contentFields`, `embedding`, `vectorStore`, `adapterConfig`, `refresh.cron`, and the `'*'` member of `source.content`) now first says what to do with a source registered in code (`KnowledgeServicePlugin({ sources })`, `registerSource`): it is in no stack collection, so the command lists no edit for it, and the edit is made in the registration itself. Every source written for 18 is such a registration, because a stack could not hold `knowledgeSources` before 19. +- **The upgrade entry.** `knowledge-source-registration-governed`, which `os migrate meta --from 18` prints, now covers a source whose 18 `id` began with an underscore. A `name` starts with a letter, so that source is renamed, and an adapter keys what it holds by the source's name: the source is built again under the new name, and the adapter keeps the index it built under the old id. Nothing drops that index for you. Call `dropSource({ source })` on the adapter (`IKnowledgeService.getAdapter`) with the old id as the source's `name`; an adapter without `dropSource` keeps it until it is removed in the adapter's own store. diff --git a/content/docs/references/ai/knowledge-source.mdx b/content/docs/references/ai/knowledge-source.mdx index 6307d5b9684..9f00bafbdf2 100644 --- a/content/docs/references/ai/knowledge-source.mdx +++ b/content/docs/references/ai/knowledge-source.mdx @@ -39,7 +39,7 @@ const result = KnowledgeRefreshPolicySchema.parse(data); | Property | Type | Required | Description | | :--- | :--- | :--- | :--- | | **onRecordChange** | `boolean` | optional (default: `true`) | Sync the index from record events (default true); false leaves the index to an external indexer | -| **cron** | `never` | optional | [REMOVED] `knowledge_source.refresh.cron` was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — it was parsed and reached no engine: nothing ever scheduled a reindex from it. Delete the key. To rebuild on a schedule, call `reindexSource` from a flow or a job; keeping the index correct between events is the service's reconcile pass. 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. | +| **cron** | `never` | optional | [REMOVED] `knowledge_source.refresh.cron` was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — it was parsed and reached no engine: nothing ever scheduled a reindex from it. Delete the key. To rebuild on a schedule, call `reindexSource` from a flow or a job; keeping the index correct between events is the service's reconcile pass. 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. | --- @@ -51,14 +51,14 @@ 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. 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. 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` | ✅ | Adapter id | -| **adapterConfig** | `never` | optional | [REMOVED] `knowledge_source.adapterConfig` was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — no adapter read it: its one reader was the retired RAGFlow adapter. Delete the key. An adapter takes its settings as options of the plugin that mounts it. 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. | +| **adapterConfig** | `never` | optional | [REMOVED] `knowledge_source.adapterConfig` was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — no adapter read it: its one reader was the retired RAGFlow adapter. Delete the key. An adapter takes its settings as options of the plugin that mounts it. 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. | | **source** | `{ kind: Enum<'object'>; object: string; content: string[]; metadataFields?: string[]; … }` | ✅ | | -| **embedding** | `never` | optional | [REMOVED] `knowledge_source.embedding` was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — it was never read: no service and no adapter chose a model from it. Delete the key. The embedder is configured once for the deployment, and every source is embedded by it. 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. | -| **vectorStore** | `never` | optional | [REMOVED] `knowledge_source.vectorStore` was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — it was never read: no service and no adapter chose a store from it. Delete the key. The store is the adapter the deployment installs, named by `adapter`. 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. | +| **embedding** | `never` | optional | [REMOVED] `knowledge_source.embedding` was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — it was never read: no service and no adapter chose a model from it. Delete the key. The embedder is configured once for the deployment, and every source is embedded by it. 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. | +| **vectorStore** | `never` | optional | [REMOVED] `knowledge_source.vectorStore` was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — it was never read: no service and no adapter chose a store from it. Delete the key. The store is the adapter the deployment installs, named by `adapter`. 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. | | **refresh** | `{ onRecordChange?: boolean }` | optional (default: `{}`) | Refresh / sync configuration; omitted parses to `{}` | | **aiExposed** | `boolean` | optional (default: `true`) | | | **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). | @@ -76,7 +76,7 @@ const result = KnowledgeRefreshPolicySchema.parse(data); | **kind** | `Enum<'object'>` | ✅ | What the source indexes; `object` is the one kind | | **object** | `string` | ✅ | Short object name to index | | **content** | `string[]` | ✅ | Fields whose text is indexed, in order; every name is listed (no wildcard) | -| **contentFields** | `never` | optional | [REMOVED] `knowledge_source.source.contentFields` was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — the key is spelled `content` now that a source is a metadata item; use `content`. Rename the key; the value (a list of field names) is unchanged, except that a `'*'` member is no longer accepted and is replaced by the field names it stood for. 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. | +| **contentFields** | `never` | optional | [REMOVED] `knowledge_source.source.contentFields` was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — the key is spelled `content` now that a source is a metadata item; use `content`. Rename the key; the value (a list of field names) is unchanged, except that a `'*'` member is no longer accepted and is replaced by the field names it stood for. 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. | | **metadataFields** | `string[]` | optional (default: `[]`) | | | **where** | `Record` | optional | | | **split** | `{ strategy: Enum<'whole' \| 'recursive' \| 'markdown'>; maxChars?: integer; minChars?: integer }` | optional | How the service cuts this object's documents into passages; omitted means recursive | @@ -86,7 +86,7 @@ const result = KnowledgeRefreshPolicySchema.parse(data); | Property | Type | Required | Description | | :--- | :--- | :--- | :--- | | **onRecordChange** | `boolean` | optional (default: `true`) | Sync the index from record events (default true); false leaves the index to an external indexer | -| **cron** | `never` | optional | [REMOVED] `knowledge_source.refresh.cron` was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — it was parsed and reached no engine: nothing ever scheduled a reindex from it. Delete the key. To rebuild on a schedule, call `reindexSource` from a flow or a job; keeping the index correct between events is the service's reconcile pass. 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. | +| **cron** | `never` | optional | [REMOVED] `knowledge_source.refresh.cron` was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — it was parsed and reached no engine: nothing ever scheduled a reindex from it. Delete the key. To rebuild on a schedule, call `reindexSource` from a flow or a job; keeping the index correct between events is the service's reconcile pass. 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. | --- @@ -124,7 +124,7 @@ const result = KnowledgeRefreshPolicySchema.parse(data); | **kind** | `Enum<'object'>` | ✅ | What the source indexes; `object` is the one kind | | **object** | `string` | ✅ | Short object name to index | | **content** | `string[]` | ✅ | Fields whose text is indexed, in order; every name is listed (no wildcard) | -| **contentFields** | `never` | optional | [REMOVED] `knowledge_source.source.contentFields` was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — the key is spelled `content` now that a source is a metadata item; use `content`. Rename the key; the value (a list of field names) is unchanged, except that a `'*'` member is no longer accepted and is replaced by the field names it stood for. 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. | +| **contentFields** | `never` | optional | [REMOVED] `knowledge_source.source.contentFields` was removed in @objectstack/spec 19.0.0 (ADR-0161 K6) — the key is spelled `content` now that a source is a metadata item; use `content`. Rename the key; the value (a list of field names) is unchanged, except that a `'*'` member is no longer accepted and is replaced by the field names it stood for. 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. | | **metadataFields** | `string[]` | optional (default: `[]`) | | | **where** | `Record` | optional | | | **split** | `{ strategy: Enum<'whole' \| 'recursive' \| 'markdown'>; maxChars?: integer; minChars?: integer }` | optional | How the service cuts this object's documents into passages; omitted means recursive | From df045b9f8b690567a440cec78c90723a1e4b5e15 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 14:19:35 +0000 Subject: [PATCH 3/4] docs(spec): the knowledge_source upgrade entry says which adapters embed again on the rebuild The entry said the build under the new name sends the content fields to the embedding provider for every record. That holds for an adapter that embeds (pgvector, turso); the memory adapter reports no embedding and sends nothing. The sentence now says "on an adapter that embeds". Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP Co-authored-by: Claude --- .../semantic/19.knowledge-source-registration-governed.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 2438d1cc8b7..77161c1fc87 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 @@ -45,8 +45,9 @@ export const entry: SemanticMigration = { + 'name, its index and its documents, so nothing is rebuilt. One source is the exception: one whose `id` ' + '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, at the next boot or by ' - + '`os knowledge rebuild` where `buildAtBoot` is `false`, which sends its content fields to the embedding ' - + 'provider again for every record; and the adapter keeps the index it built under the old id. No source ' + + '`os knowledge rebuild` where `buildAtBoot` is `false`; on an adapter that embeds, that build sends its ' + + 'content fields to the embedding provider again for every record. The adapter also keeps the index it ' + + 'built under the old id. 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 ' From 4f6792529c3a86ae2e44e249fa4c8bada27956fe Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 14:58:24 +0000 Subject: [PATCH 4/4] docs(spec): the knowledge_source upgrade entry no longer lists what starts the build The entry said the renamed source is built "at the next boot or by `os knowledge rebuild` where `buildAtBoot` is `false`". main now has a third moment, the scheduled reconcile, which builds a source the adapter holds nothing for exactly as the boot pass does. The entry's point is what the build costs, not what starts it, so the sentence says that: every record the source covers is read, and on an adapter that embeds the content fields of each are sent to the embedding provider again. Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP Co-authored-by: Claude --- .../semantic/19.knowledge-source-registration-governed.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 77161c1fc87..7733aa38f82 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 @@ -44,10 +44,10 @@ export const entry: SemanticMigration = { + 'registered in code belongs to no package: it is read as the environment\'s own source and keeps its ' + 'name, its index and its documents, so nothing is rebuilt. One source is the exception: one whose `id` ' + '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, at the next boot or by ' - + '`os knowledge rebuild` where `buildAtBoot` is `false`; on an adapter that embeds, that build sends its ' - + 'content fields to the embedding provider again for every record. The adapter also keeps the index it ' - + 'built under the old id. No 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 ' + '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 '