Skip to content

Commit 13a0d3f

Browse files
docs(adr): ADR-0161 dated note — an adapter embeds a search's question once, and its refusals stay ahead of the embed (#38812)
<!-- claude-projects-attribution: {"github_login":"os-warren"} --> _Requested by **Warren** · [project thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8WwwNJsfXjR7KkaXqjQxjFx)_ Part of #38676 **Update, head `a28863cef9`.** PR #38809 (card #38438) landed first, at 2026-12-01T03:58Z, and took the seventh and eighth `**Amended**` lines of ADR-0161. This head merges `main` into the branch (merge commit `a28863cef9`, no rebase): main's lines are kept as they are, this PR's header line follows them, and its ordinal reads "a ninth dated note". That one word is the only change to this PR's text (delta report 7300564224 on #38676); the net diff against `main` is still this note alone, +17 / -0. The gate readings and the overlap paragraph further down are of the earlier head `f3cd7dba76`; the 21 derived gates were re-run at `a28863cef9`, all exit 0. This is phase 0 of the card's cause 3 and nothing else: the dated note in ADR-0161. The card stays open for phase 1, the patch round on PR #38798, which waits for this note to merge. Clause-②: yes (widening) — the two optional adapter-contract members the note registers Metadata-protocol: none The two lines above are the claim's (comment `7296290387` on the card) and cover both phases. This pull request changes no contract file: the widening is what the note registers and PR #38798 builds. ## 维护者速读 - 用户能看到什么变化:用户无感;只是在知识平台边界那份架构决策记录里追加一条 2026-12-01 的说明,把你当天选定的「写进约定,一次提问只转一次」和它的附带条件写成文字,不改任何代码。 - 为什么做:这是「知识检索慢」那张卡最后一项(补查时把同一个问题重复转成向量)的前置一步;平台和存储驱动之间的约定是一份封闭清单,要先在决策记录里登记这两项,已经做好的改动才能合并。 - 出错会怎样:说明里若有和你的裁决不一致的句子,接下来改代码的人会照着错的文字去做;它只是一处文档追加,可以直接撤回,不影响任何在运行的系统。 - 要你做什么:请审阅并批准这条说明;其中标了菱形记号的两处是说明自己定的写法,可以一并接受,也可以划掉。 ## What changes One file, add-only. `docs/adr/0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md` gains its ninth dated note: 17 lines added, none changed and none removed (659 lines to 676 on `main` after #38809). Three commits carry it, the third being the merge of `main`, `a28863cef9`: `f00518e716`, the note, and `f3cd7dba76`, a review pass over it (Acceptance notes). **Ruling.** The maintainer chose option A for cause 3 on 2026-12-01T00:22Z: ruling record [`7296268226`](#38676 (comment)) on the card, given on analysis `7290428149`. He ruled by choosing an option of a decision card, and the note quotes the card's words unchanged: the option 「写进约定,一次提问只转一次」 and the condition 「附带条件:存储驱动原本会给出的拒绝提示(比如“需要重建索引”)要保持在前面,不能被转向量的报错盖掉。」 Nothing of the ruling is opened again here. Three insertions, in the form the six earlier notes of this record use. Line numbers are at head `a28863cef9`. | Lines | Where | What is added | |---|---|---| | 27 | Header, after the `**Amended**` line of the eighth note | A ninth `**Amended**` line, dated 2026-12-01: the two members, the texts the note is read with, the ruling record, the chosen option and the condition. | | 166 | K1, under the note of 2026-11-30 on rerank | A cross-reference: the "Embedding calls" row, and "compute a vector" in the second sentence of the list, are read with the new note. | | 483 to 496 | K8, under "Rules for every member" | The note itself: an opening paragraph, nine bullets and a last paragraph. | What the note decides: - **Two optional members, and the list stays closed beyond them** (K8 rules 3 and 5). `IKnowledgeAdapter.embedQuery?(query: string)`, which answers a promise of a `number[]`, and `AdapterSearchOptions.queryVector?`. No capability flag: the method's presence is the signal. - **The type of the second member.** A function of no arguments that answers a promise of a read-only `number[]`. It is not the vector itself. For one search the knowledge service makes one such function for each adapter instance that has `embedQuery`. The first call of the function calls that instance's `embedQuery`; every later call in that search answers the same promise, a rejected one too. An adapter calls it at the point of its `search` where it embeds the query today. This is the per-search memoised provider the analysis recommends, and the one choice the ruling record leaves to the note. - **The three readings that M1 of contract review [`7290045524`](#38798 (comment)) left open.** 1. The adapter still embeds, with its own embedder and query prefix. The service computes no vector: it carries one back to the instance that made it, inside one search. The "Embedding calls" row of K1, the second sentence of the list under it and item 15 of K8 stand as written. 2. One vector serves every source a search binds to that adapter instance. An adapter whose query embedding depends on the source does not implement the method. 3. A handed vector is checked by its width. The model is judged on the index fingerprint, as K7 has it. - **The condition, as an outcome.** An adapter's refusals are answered as on `main`, code, status and remedy, and no question is sent to an embedding provider for a source the adapter refuses. The ruling record's case: a source that needs a rebuild behind a failing embedder answers `KNOWLEDGE_REBUILD_REQUIRED` 409 with 0 embedder calls. The function gives this by construction, because an adapter asks for the vector only after everything it decides first. - **What the members land with.** PR #38798, after this note merges: both members with their first readers in one PR and one case in the contract test suite (rule 1). Each is optional (rule 2), and an adapter without `embedQuery` is searched as before. - **Not in the note.** A vector handed by a caller of the service or by a tool argument, a memo an adapter keeps past one search, a source or context argument on `embedQuery`, and a form that embeds several questions at once. No file under `packages/`, `content/`, `skills/` or `ui/` changes, and no other ADR does. The note declares; it builds nothing. ## Why K8 rule 5 of this record: "The list is closed. A member that is not in the table needs a dated note on this record first." PR #38798 built the two members before the record named them, and its contract review is FAIL on that point (M1). The ruling puts the record before the code: this note first, then the patch round on #38798. ## Tests The diff touches no package, so there is no build closure to make and no package test or type-check owed. What was measured, at head `f3cd7dba76`: - **The premise holds.** Read on `main` at `0fc9eab900`, the commit this branch starts from. A refilled search still embeds the question twice: - `packages/services/service-knowledge/src/knowledge-service-search.ts:232` is the first `searchRound` call and `:245` is the refill's. - `:957`, inside `searchRound`, calls `adapter.search` once for each source. - `packages/plugins/knowledge-turso/src/turso-adapter.ts:741` and `packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts:657` embed the query inside that call. - No line under `packages/`, `content/` or `docs/` names `embedQuery` or `queryVector` (`git grep` exit 1). - `origin/main` has since moved one commit, to `d97aaaea9a` (#38802: one skill file, one ratchet script and a changeset). It changes none of the files read here, so each reading holds there too, and this branch merges with it cleanly. The branch was not merged with it. - **Quotations.** A script compared every quoted span of the added lines with its source, read over REST or from the ADR at the base. 9 spans in corner brackets: each is a verbatim substring of ruling record `7296268226`. 27 spans in double quotation marks: each is verbatim in that record, in analysis `7290428149`, in review `7290045524` or in the ADR at the base. 0 mismatches. (The nested title "What "capabilities" became" counts as two spans.) - **Bytes.** The added lines hold no raw control byte, no HTML comment and no model identifier. - **What an adapter decides ahead of its embed**, the list in the note's bullet on the condition, read in both stores on `main` at `0fc9eab900`: an empty organization set, a scope with no ids and a `topK` of zero answer no hits; the store and the embedder are present and the store is ready; the source has an active generation; that generation holds the searched fingerprint and the embedder's width, or the refusal is `KNOWLEDGE_REBUILD_REQUIRED` (409, with its remedy); the mode is one the adapter runs; and `keyword` never embeds. Each is ahead of the embed in `turso-adapter.ts` (lines 699 to 741) and in `pgvector-adapter.ts` (lines 581 to 657). - **PR #38798 as it stands**, read at head `4561e81d0e`: `queryVector` is the vector itself there, a read-only `number[]`, and `embedQuery` has the signature the note writes. - **Anchors.** Every code citation in the note is a path with a symbol, never a line number, and `check:adr-symbol-anchors` reads all of them (its verdict line is below). No ablation: the diff changes no behaviour a test pins. ## Acceptance notes **The committed note took the function, not a plain array.** A plain array has to exist before `search` is called, so the service would have to embed ahead of every decision the adapter makes. A refused source would then cost an embedding call, and a failing embedder would answer in place of the adapter's own refusal. That is the shape review `7290045524` graded S2, and it cannot meet the condition. The function can, and the note names it as the means it takes. **The review pass, commit `f3cd7dba76`.** Two sentences of the note changed; nothing it decides moved. 1. The opening said that every statement without a diamond is the ruling record's, the analysis's, what follows from the means, or a reading of `main`. Some rest on review `7290045524`, on this record's own rules, on PR #38798 at its head or on the body of the card. The sentence now lists them. 2. The signature of `embedQuery` is the one PR #38798 declares at head `4561e81d0e`. The bullet on the two members now says so. **Two things are marked with a diamond, for the approver to accept with the note or strike.** - a. The means, and with it the member's type. Three points go with it and are the note's wording: the name `queryVector` is kept though the member is now a function; the service hands the function on every `search` call of that search and does not judge whether a call will embed; and a rejected promise is shared like a fulfilled one, so one failed embedding call refuses each source that asked for the vector in that search. - b. One sentence added to the third reading: a caller that reaches an adapter's `search` directly and hands the member answers for the function, and the adapter does not verify it. **Wording that is the note's and not a quotation**, each resting on a text named beside it: - The suite case is the one review `7290045524` asks for under S1, rewritten with the function in the vector's place. - "The condition has its own pin in each of the two stores": the ruling record says "a pin". Each store orders its own decisions ahead of its embed, so the note asks for the case in each. - The English beside the card's Chinese words is a reading aid. The Chinese is quoted unchanged. **Overlap with an open draft on this file.** `node scripts/pm/overlap-check.mjs --repo=objectstack-ai/objectstack`, run at `f3cd7dba76` against `origin/main` at `d97aaaea9a`, printed `VERDICT overlap exit 1`: `origin/main` merges cleanly, and draft #38809 (the weekly ADR revisions, second part, opened 2026-12-01T00:50Z by another seat's thread) conflicts with this branch in this file. Both insert header lines after line 24, and both call their first line "a seventh dated note" (#38809 adds a seventh under K7 and an eighth under Consequences). Its two notes and this one touch no common passage. Whichever lands second merges `main`, keeps both sets of header lines and corrects its ordinals. Which lands first is the seats' to settle; it is put as a question in the report on the card. **What the note asks of PR #38798, none of it done here.** - `queryVector` changes type there, from the vector to the function, and the service stops calling `embedQuery` ahead of `search`. - One case in the contract test suite, and a pin in each of the two stores for the ruling record's case. - The docblocks cite the note and no longer say that the knowledge service embeds. **Text of ADR-0161 that the note is read beside. Listed for the seat, not changed.** - "What "capabilities" became" lists the methods whose absence is the capability signal (listing, dropping, status, the start and end of a build). `embedQuery` joins them by this note; the paragraph is left as written. - The K2 row for §3.4 of the protocol page says what the contract carries. Its last column gives the rewrite to "each card that adds a member", so #38798 rewrites it with its code. **Not done here.** No changeset: `docs/adr/` is published by no package. The two earlier note pull requests on this record, #38714 and #38764, each carry the `skip-changeset` label, hung in the stroke that opened them. This one is opened with no label, as its dispatch order says, so that label is owed by the seat, and `Check Changeset` has no exemption until it is hung. ## Verification **Read first, by risk.** One file changes, so these are its three places of most risk. 1. Line 476, the bullet marked with a diamond, "The means, and with it the member's type". It is the one decision the note makes, and it sets what the patch round on PR #38798 must build. 2. Line 480, the bullet "The condition, as an outcome". It states the maintainer's condition and what holds when the embedding call itself fails. 3. Line 479, the last two sentences of "The third reading": the note's own sentence on a caller that reaches an adapter directly. **Two-minute check.** One click: open the "Files changed" tab. Expected: one file, +17 −0, three hunks, every changed line an addition. **Landing.** `docs/adr/**` is a governed surface. This is opened as a draft. The hand-off is the seat's and the approval is the maintainer's. Nothing here requests a reviewer, marks it ready or arms auto-merge. **CI.** NOT MEASURED: the check-runs of this pull request, reason: it did not exist when this body was written. The report on the card carries the reading taken after it opened. **Gates, run locally on head `f3cd7dba76`.** `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived 21 commands from the diff. All 21 ran in the foreground, each exit code was captured before any pipe, and all 21 are exit 0. The reconciliation: ```text Run reconciliation — 21 derived, 21 run, 0 NOT-MEASURED, 0 UNRUN. ✓ dispatch-gates --ran: 21 derived famil(ies) accounted for — 21 run, 0 NOT-MEASURED (a DERIVED zero — all 21 recorded an exit code and none of them is 3). ``` <details> <summary>The 21 commands and their exit codes</summary> ```text node scripts/check-adr-links.mjs :: exit 0 node scripts/check-adr-links.mjs --self-test :: exit 0 node scripts/check-closing-keyword-parity.mjs :: exit 0 node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0 node scripts/check-comment-mask-corpus.mjs :: exit 0 node scripts/ci/plan-test-core-shards.mjs --self-test :: exit 0 pnpm --filter @objectstack/lint run check:doc-formula-expressions :: exit 0 pnpm check:adr-anchors :: exit 0 pnpm check:adr-index :: exit 0 pnpm check:adr-symbol-anchors :: exit 0 pnpm check:ci-filter-parity :: exit 0 pnpm check:closed-ceremony-text :: exit 0 pnpm check:cross-package-test-inputs :: exit 0 pnpm check:doc-authoring :: exit 0 pnpm check:driver-memory-census :: exit 0 pnpm check:gitlink-declared :: exit 0 pnpm check:nul-bytes :: exit 0 pnpm check:pm-governed-merges :: exit 0 pnpm check:pm-prior-rulings :: exit 0 pnpm check:refd-timer-probe :: exit 0 pnpm check:watch-hint-literal :: exit 0 ``` </details> <details> <summary>Verdict lines of the gates that read the ADR</summary> ```text ✅ check-adr-links: 1284 relative link destination(s) under docs/adr/ resolve ✅ check-adr-symbol-anchors: 4608 anchors across 165 records resolve — 1727 symbol (1698 declaration, 29 literal), 2829 file-level, 52 cross-repo, 6 exempt, 132 continuation. [cut here: the rest of the line is a note on what the count is not] adr-index --report: OK — docs/adr/README.md is current, every record parsed, self-test 60 assertions green. Report-only: this line never reds the step. check-nul-bytes: OK (scanned 29077 text file(s) -- 29077 tracked, 0 untracked-not-ignored; skipped 101 binary; no raw ASCII control bytes). ✓ check-closed-ceremony-text: 6688 shipped file(s) read; none says the ownership ceremony is closed. ✓ comment-mask corpus sweep [scripts/js-comment-mask.mjs]: 24511 files, 0 disagree, 0 unparseable, 211.2s (comparator self-test: 26 cases pass). ``` </details> <details> <summary>One gate first read NOT MEASURED, then green</summary> `pnpm --filter @objectstack/lint run check:doc-formula-expressions` first answered exit 3, PREREQUISITE NOT MET: two workspace packages it imports were not built in this worktree. That is a run that measured nothing, not a red gate. The two packages were built under the shared verify lock, with the command the gate printed, and the gate was run again at the same head: ```text os-verify-lock: VERDICT command-exit 0 · held the lock 100s (1m40s) · waited 0s pnpm --filter @objectstack/lint run check:doc-formula-expressions :: exit 0 ``` </details> **Left to CI, not run locally.** The repo-wide lint, the type-check lanes, the test shards, and the families `dispatch-gates` prints outside the derived list. The commit trailer gate ran in the pre-push hook on the pushed range and is green. ## Human Minimum - [x] 1. No schema and no code changes. - [x] 2. No new name is declared in code. The two member names are the ones PR #38798 and the analysis use. - [x] 3. No formatter ran. `pnpm lint` is NOT MEASURED locally: the repo-wide scan is CI's, and the diff is one Markdown file. - [x] 4. One card, one branch off `main` at `0fc9eab900`, one pull request for this phase. - [x] 5. Nothing publishes, so no changeset; both declaration lines are filled in above. - [x] 6. `packages/spec` is not touched. - [x] 7. No edit to `content/docs/references/`, to a `CHANGELOG.md` or to `content/docs/releases/`. - [x] 8. Title, body and comments are in English. The card's Chinese words are quoted unchanged, and the 维护者速读 section is in Chinese as the fleet's rule asks. - [x] The *Before Submitting* list is done for what a docs-only diff reaches; `pnpm lint` is as item 3 says. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01JQwxbXfgA45f3y5YpDPT5h <!-- signed: repo:objectstack#2 · os-warren · session_01JQwxbXfgA45f3y5YpDPT5h --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4ab7129 commit 13a0d3f

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

0 commit comments

Comments
 (0)