Repository navigation
Commit 3c53b85
docs(adr,spec): ADR-0084's notes catch up with the knowledge_source row; the knowledge_source tombstones name the code door (#38015)
Fixes #37740
Fixes #37741
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
用户能看到什么变化:从旧版升级、在代码里注册知识源的开发者,碰到旧写法的报错时,提示会先说明“直接改代码里那处注册”,再提迁移命令;旧名字以下划线开头的知识源改名后会留下一份旧索引,升级说明现在写明它为什么留下、怎么删。应用搭建菜单的架构决策记录(ADR-0084)里,几处统计和说明补上了表里已有的“知识源”一行,菜单本身不变。
-
为什么做:知识平台专题里“知识源成为受管元数据类型”那次合并,审核留下两条小尾巴:升级提示指向一个对代码注册不起作用的命令,架构记录的说明没跟上表格。这次替升级的开发者和读记录的人补齐。
- 出错会怎样:只改提示文字和文档,不改任何行为、数据和菜单;文字写错最多是提示不准,直接撤回即可。
- 要你做什么:这个 PR 改了受管文档(架构决策记录 ADR-0084 的几处说明),审核通过后请你批准合并。
## What changes
Two cards from one contract record (the review of the change that made
`knowledge_source` a governed type): its nit N2 is #37740, its nit N5 is
#37741. Text only: no schema shape, no behaviour, no menu row.
### #37740 — ADR-0084's notes read true for the table as it stands
(governed, `docs/adr/**`)
The table has held a `knowledge_source` row since that change (AI, order
5, 高级). The prose around the table still described it without that row.
Five places, each amended in the record's own dated form, struck text
kept:
1. **The note under the table** gains one dated paragraph: the registry
read again at `origin/main` `62dd9e1ef5` holds 35 entries — the 33 of
the two earlier readings and two registered on 2026-11-27, `form` (`ui`)
and `knowledge_source` (`ai`); `form` has no row yet, so the table has
34 rows; AI counts 5.
2. **The fold sentence** ("its label is drawn again inside the fold only
where a package holds an `ai_context`") gains a dated note: AI holds two
高级 types, so either one draws the label.
3. **The 2026-11-25 amendment's table row** ("One row is new:
`ai_context`") gains a dated note: a second row has been written under
item 6 since.
4. **Item 6**: the heading names both types (the old heading struck, not
deleted), and the item ends with a dated note that says what changed for
`ai_context`'s row (fourth, no longer last in AI) and how the same three
ruled sentences place `knowledge_source`.
5. **The sentence that introduces the table** ("*(33 at the 2026-11-25
reading, in the note under the table)*") now also points at the
2026-11-27 reading. This fifth place is not in the card's list of four;
it is the same stale count one paragraph up, so it is brought along here
rather than left to contradict the note it points at. The claim's file
surface names four places: it wants this one added.
The card says "33 entries"; the registry holds 35, because `form` was
registered the same day (hidden from Studio's directory, no row). The
note says 35 and says why the table has 34 rows.
Nothing is decided: the row, its order and its tier were written by the
earlier change under item 6, and `studioMenuPlacement.ts` already
mirrors them. No Status line changes.
### #37741 — the `knowledge_source` tombstones say what the author of a
registration in code does (`packages/spec`)
- **The prescriptions.** Each retired-key prescription 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: a source registered in code
(`KnowledgeServicePlugin({ sources })`, `registerSource`) is in no stack
collection, so the command lists no edit for it, and the edit is made in
the registration itself. One constant, `CODE_DOOR_18`, placed before the
migrate sentence, which stays the last sentence of its prescription (the
house pin). The prescription for a retired source kind (`file`, `http`)
is unchanged: it sends nobody to the command.
- **The ADR-0087 D3 entry** `knowledge-source-registration-governed`
(the entry `os migrate meta --from 18` prints) now states the one
exception to "nothing is rebuilt": a source whose 18 `id` began with an
underscore. A `name` must start with a letter, so that source is
renamed; an adapter keys what it holds by the source's name, so the
renamed source is built from nothing under its new name and the adapter
keeps the index it built under the old id; the service never drops that
index (it drops one only for a `knowledge_source` item it stops
serving). The entry says how it is dropped: `dropSource({ source })` on
the adapter (`IKnowledgeService.getAdapter`) with `name` set to the old
id, or in the adapter's own store where the adapter has no `dropSource`.
- **Pins.** `knowledge-source.test.ts`: each of the six tombstones and
the `'*'` message must name both spellings of the code door and "in the
registration itself", each before the sentence that names the command.
- **Generated.** `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`.
- **Changeset.** `@objectstack/spec` patch.
## Tests
All on head `4f6792529c`, in one hold of the shared verify lock
(`VERDICT command-exit 0`), unless a line says otherwise.
- `pnpm --filter @objectstack/spec build` — exit 0.
- `pnpm --filter @objectstack/spec check:generated` — exit 0: "All 14
generated artifacts are up to date".
- `pnpm --filter @objectstack/spec test` — exit 0: `Test Files 909
passed (909)`, `Tests 28748 passed | 1 todo (28749)`.
- `pnpm --filter @objectstack/spec typecheck` — exit 0.
- `pnpm --filter @object-ui/app-shell exec vitest run --root ../..
--maxWorkers=2
packages/app-shell/src/views/studio-design/studioMenuPlacement.test.ts`
— exit 0: `Tests 19 passed (19)`. This is the test that parses the ADR's
table rows; no row changes here.
<details>
<summary>Ablation (one): the new pin goes red when one tombstone loses
the code-door sentence</summary>
Run on `df045b9f8b`. The two files it involves have the same blobs on
the final head: `knowledge-source.zod.ts` `0d433e77468e`,
`knowledge-source.test.ts` `56ebce2f5d4e`.
Through `scripts/ablation-replace.mjs`: the `+ CODE_DOOR_18` line of one
tombstone (`adapterConfig`) replaced by an empty-string term. Direction
set before the run: that row red, every other test green.
- landed: `ok mutation landed: anchor 1 -> 0, blob 0d433e7 ->
8a47142baebf`; `+ CODE_DOOR_18` lines on disk during the run: 6 (7
before).
- result: exit 1, `Tests 1 failed | 31 passed (32)`. The one failure is
the row "`adapterConfig` is refused at its own path with its
prescription, the code door and the migrate sentence": ``AssertionError:
`KnowledgeServicePlugin({ sources })` is named: expected -1 to be
greater than -1``.
- restored: ``ok restored: blob == HEAD (0d433e7) and `git diff
HEAD` is empty``; 7 lines again. The full suite above ran after it.
The first attempt measured nothing and is void: its replacement text was
a prefix of the anchor, so the tool refused it ("the replacement count
moved 1 -> 1, a rise of 0, not the declared 1") and restored without
running the test. The replacement was changed and the ablation run once
more.
</details>
<details>
<summary>Probe (one-off, not committed): an underscore-led id leaves its
index behind, and dropSource removes it</summary>
A test file placed in `packages/plugins/knowledge-memory` for the run
and removed after it (`git status` clean, checked by the same script).
It reads the schema and the memory adapter:
- `KnowledgeSourceSchema.safeParse` of a source named `_kb` is refused,
at path `name` alone; the same source named `kb` parses.
- an index built under `_kb`, then the source built under `kb`: `old key
holds ["article:1"] new key holds ["article:1"]`.
- `dropSource` with the source's `name` set to `_kb`: `old key holds []
new key holds ["article:1"]`.
- exit 0, `Tests 1 passed (1)`.
Two earlier attempts measured nothing and are void: the first imported
the service and stopped on a workspace package that was not built; the
second read a field the listing does not have.
The service's half is pinned by landed tests and was not run again here:
"unregisterSource removes a source registered in code and keeps its
index" (`service-knowledge`, `knowledge-source-registry.test.ts`) and
the adapter contract suite's `dropSource` block.
</details>
## Acceptance notes
- **"The ADR-0087 D3 entry" is a registry entry, not text in ADR-0087.**
The claim's file surface and its `Container & model` line name
`docs/adr/0087-metadata-protocol-upgrade-contract.md`. That file holds
no `knowledge_source` text (`grep -c knowledge`: 0; control `grep -c
D3`: 19). The D3 entry the card means is
`packages/spec/src/migrations/entries/semantic/19.knowledge-source-registration-governed.ts`,
which is what this PR edits. ADR-0087 is not touched; the PR is governed
through ADR-0084 alone.
- **The underscore fact was read in code before it was written**, then
run once (the probe above). The readers: `name` takes
`ROUTER_ADDRESSABLE_NAME_PATTERN` (a letter first) where the 18 `id`
pattern admitted a leading underscore; every adapter keys by
`AdapterContext.source.name`; `KnowledgeService.unregisterSource` leaves
the index with its adapter and `dropMetadataSource` runs only for a
metadata item; the scheduled reconcile that landed on `main` meanwhile
walks registered sources only; the three adapters in the tree (memory,
pgvector, turso) implement `dropSource`, which the contract leaves
optional.
- **The entry does not list what starts the build of the renamed
source.** `main` gained a third moment (the scheduled reconcile) while
this branch was open, so the sentence says what the build costs instead:
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.
- **Not changed, on purpose:** the `id` tombstone still says "the value
is unchanged, so the source's index is found again and is not rebuilt".
That holds for every id that is a legal name; for an underscore-led id
the parse refuses the value next, with the name grammar's own message,
and the D3 entry carries the rest. The card asks for the exception in
the entry, not in the tombstone.
- **Seen, not changed here, no card:** the changeset of the earlier
change (`.changeset/37304-knowledge-source-governed-type.md`) and the
hand-written `content/docs/protocol/knowledge.mdx` say the index is
found again, without the underscore exception. Both are right for an id
that is a legal name. An edit to a landed changeset is a deliberate
correction with its own declaration, so it is left for the seat to
place.
- **Neighbour #37945 (the `datasource` row)** rewrote the same note
block of ADR-0084 and landed first. `main` was merged twice: at
`62dd9e1ef5` (one conflict, in that block: its note kept first, this
PR's note after it, reworded for the table as it then stood) and at
`9a274e6725` (clean). `node scripts/pm/overlap-check.mjs` before each
push; on the final head: `VERDICT clean exit 0`, 0 PR heads.
- **Neighbour #37306** edits `knowledge-source.zod.ts` at the `adapter`
line, about ten lines from this PR's nearest edits on either side. It
has no open PR at this writing.
- **Not measured locally, declared:** `pnpm --filter @objectstack/cli
exec vitest run test/migrate-meta-engine-guidance.test.ts`, which the
derivation names. It spawns the CLI and needs its 71-package dependency
closure built; CI runs it. What it pins for this diff was read directly:
the entry's four printed fields hold no tracker id (`surface` 279 chars,
`replacement` 863, `reason` 2140, `acceptanceCriteria` 648: no match; a
control string matches).
## Verification
**Read first (by risk):**
1. `docs/adr/0084-application-builder-information-architecture.md`, item
6's closing note. The risk hunk is one clause: "its schema requires one
object (the `object` key of its `source`, …), so the first test of the
rule sorts it 高级". It applies the record's own rule ("Its schema does
not require one object") to a type the ruling did not name. The row's
tier does not rest on it: the two sentences that follow place the type
without it. If the seat reads that clause as more than carrying out, it
can be struck and the note still stands.
2.
`packages/spec/src/migrations/entries/semantic/19.knowledge-source-registration-governed.ts`:
`replacement`, `reason` and `acceptanceCriteria` are what an upgrading
author is shown. Check the drop instruction against
`packages/spec/src/contracts/knowledge-adapter.ts` (`dropSource` takes
an `AdapterContext`).
3. `packages/spec/src/ai/knowledge-source.zod.ts`: `CODE_DOOR_18` and
its seven uses.
**Two-minute check:** `pnpm --filter @objectstack/spec exec vitest run
--project local --maxWorkers=2 src/ai/knowledge-source.test.ts` — expect
`Tests 32 passed (32)`; six of them are the rows titled "… with its
prescription, the code door and the migrate sentence".
**Local gates, on head `4f6792529c`.** Derived by `node
scripts/pm/dispatch-gates.mjs --commands` with no paths; each command
run as printed, its exit code recorded before any pipe; reconciled by
`--ran`:
`Run reconciliation — 116 derived, 111 run, 4 NOT-MEASURED, 1 UNRUN.` ·
`✗ dispatch-gates --ran: 1 of 116 derived famil(ies) UNRUN.`
- **111 run: exit 0, every one.** Among them the families this diff
moves: `check:adr-index`, `check:adr-anchors`,
`check:adr-symbol-anchors`, `node scripts/check-adr-links.mjs`,
`check:keyed-text-bounds`, `check:spec-docblock-symbol-anchors`,
`check:issue-citations`, `check:nul-bytes`, `check:role-word`,
`check:closed-ceremony-text`, `node
scripts/check-adr-0087-registration.mjs --base origin/main`, `node
scripts/check-empty-changeset.mjs --base origin/main`, `node
scripts/check-changeset-no-major.mjs --base origin/main`, and the spec's
own `check:generated`, `check:docs`, `check:api-surface`,
`check:authorable-surface`, `check:liveness`, `check:upgrade-guide`,
`check:spec-changes`.
- `node scripts/adr-index.mjs --check`: exit 0, "adr-index: OK —
docs/adr/README.md is current and every record parsed." No index
regeneration was needed.
<details>
<summary>The five not measured here, each with its reason (none is a
finding; CI runs all five)</summary>
- **UNRUN (1), declared to CI:** `pnpm --filter @objectstack/cli exec
vitest run test/migrate-meta-engine-guidance.test.ts` (Acceptance
notes).
- **NOT MEASURED (4), each exit 3, PREREQUISITE NOT MET:**
- `pnpm --filter @objectstack/spec run check:skill-examples`: its
client-SDK surface reads the declarations of
`@objectstack/client-react`, a 48-package build closure that is not
built here. This diff adds or changes no fenced example.
- `pnpm check:dual-build-cjs-loads`: reads every package's `dist` ("Run
`pnpm build` first").
- `pnpm check:lean-entry-closure`: loads the built entries of
`@objectstack/objectql` (a 14-package closure).
- `pnpm check:type-check-debt`: its re-measure builds every package
under the shared verify lock. It got no turn on the first run (`VERDICT
queue-timeout (exit 99)`), and the second was withdrawn while still
queued: a whole-workspace build is out of proportion to a text-only
diff. Its structural half printed "OK — 132/135 workspace packages
type-checked (plus the root), 0 in the DEBT ledger".
- The derivation printed that the tree was 8 commits behind
`origin/main` at that moment, and that none of the commits it could see
touched what the answer derives from.
</details>
**CI:** no check-run existed when this body was written; the PR's own
check-runs are the verdict for every family CI runs.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 8d598aa commit 3c53b85
6 files changed
Lines changed: 98 additions & 18 deletions
File tree
- .changeset
- content/docs/references/ai
- docs/adr
- packages/spec/src
- ai
- migrations/entries/semantic
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | | - | |
61 | | - | |
| 60 | + | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| |||
0 commit comments