Skip to content

Commit e5f7b16

Browse files
docs(adr): ADR-0161 dated note — a knowledge source declares rerank; the knowledge service reranks after the permission re-check (#38764)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9DAwBxBGNv4CexdUyBYJXSw)_ Fixes #38760 Refs #38750 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:用户无感;知识平台边界那份架构决策记录里追加一条 2026-11-30 的说明,写明知识源可以声明自己的检索结果要重排、用哪个重排模型由部署方配置、由知识服务在权限复核之后统一重排,不改任何代码。 - 为什么做:这是知识检索重排专题的第一步,把你当天说的「有就用」和「开了开关,一律重排」写进决策记录,后面几步的实现才有依据。 - 出错会怎样:说明里若有和你的裁决不一致的句子,后面做实现的人会照着错的文字去做;它只是一处文档追加,可以直接撤回,不影响任何在运行的系统。 - 要你做什么:请你审阅并批准这条说明;它改的是受管的决策记录,你批准它,由知识服务在权限复核之后重排这一条就算正式记下,不再另开决策卡。 ## 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 sixth dated note: 28 lines added, none changed and none removed (614 lines to 642). The note records the maintainer's rulings of 2026-11-30 on the epic for knowledge retrieval rerank. A knowledge source may declare that its searches are reranked. The deployment configures the reranker, and no source names a model. The knowledge service reranks, after the permission re-check and before the cut to `topK`. The adapter contract does not change. Five insertions, in the form the five earlier notes of this record use. Line numbers are at head `6552e290`. | Lines | Where | What is added | |---|---|---| | 24 | Header, after the `**Amended**` line of the fifth note | A sixth `**Amended**` line, dated 2026-11-30. It names what the note amends, the maintainer's words with their times, and ruling record `7276086125`. | | 142 to 161 | K1, under "What follows from the two lists" | The note itself: an opening paragraph, 16 bullets and a last paragraph. | | 186 | K2, under "The rule for all of them" | A cross-reference. Three rows of the table name rerank and are read with the note. | | 281 | K4, in the cross-reference block that is already there | A cross-reference. One more source key is declared, `source.retrieval.rerank`. | | 468 | K8, under the note of 2026-11-30 | A cross-reference. Rule 4 and three sentences of that note are read with the note. | ### Each amended place No existing line is edited. This record's convention is add-only, so the note quotes the old sentence and states how it reads from the merge. The two sentences marked "new sentence" are the note's own wording. Every other entry in the third column is the note's reading of a text it leaves as written. In the last column, "body 1" to "body 3" are items 1 to 3 under "Rulings" in the body of the epic, which record the maintainer's 「有就用」 (10:13Z) and 「所以还是应该按照主流系统的做法,开了开关,一律重排」 (10:37Z). "D1" to "D4" are the first four of the six decisions of the epic that he answered with 「全部同意」 (10:47Z), as ruling record `7276086125` on the epic records them. | Place, with its line on `main` at `acf3b33e` | Old sentence | New sentence or reading | Ruling | |---|---|---|---| | K1, the "Rerank" row of the adapter's table (104) | "Whether a second model reorders candidates, and which." | Reading: neither is the adapter's. Whether: a knowledge source declares it. Which: the deployment configures the reranker, and no source names a model. The knowledge service reranks, after the permission re-check and before the cut to `topK`. The row keeps the adapter's own search. | body 1, D1 | | K1, the second sentence of the list (112), as the note of 2026-11-29 left it (119) | "The service does not choose a model, compute a vector, compute a score for a candidate, rerank or parse a file. It may re-order the hits it is about to answer by the ordering their source declares against a fact about the caller that the platform resolves, by position alone, and it changes the order the adapters answered in no other way." | New sentence: "The service does not choose a model, compute a vector, compute a score for a candidate or parse a file. It may re-order the hits it is about to answer in two ways, and it changes the order the adapters answered in no other way: by the ordering their source declares against a fact about the caller that the platform resolves, by position alone; and by reranking them, where their source declares it and the deployment has configured a reranker, after the permission re-check and before the cut to `topK`." | D1, body 1 and 3 | | The note of 2026-11-29, one sentence (119) | "This is not rerank, which stays the adapter's in the table above: the service reads no passage text and calls no model to do it." | Reading: the re-order by a declared ordering is still not rerank, and the service still reads no passage text and calls no model to do it. Rerank no longer "stays the adapter's". To rerank, the service hands the question and passage text to a model. | D1 | | The title (1), the D1 key-words line (9) and TL;DR item 1 (41) | Each says that adapters own rerank. | Reading: the word "no longer covers whether the hits of a search are reranked, by which model, or by whom, and it covers only what an adapter does inside its own search". | body 1, D1 | | K2, three rows (149, 153, 157) | "Engines are integrated for embedding, hybrid retrieval, rerank and file parsing."; the "no rerank" of the §3.4 row; "Embedding calls, vector storage, hybrid retrieval and rerank stay the adapter's." | Reading: the first stays true as a sentence, because a reranker is an engine the deployment brings, and it is the knowledge service that calls it. The §3.4 row keeps its "no rerank", because the adapter contract carries none. Of the third, the first three stay the adapter's and reranking is the service's. Each text is rewritten by the PR whose code makes the new sentence true. | D1 | | K8, rule 4 (417), as the note of 2026-11-30 left it (422) | "Which provider, which key, how to batch, rerank toggles and parser options stay in the adapter's own plugin options. Hybrid weights are declared by the knowledge source. A parameter of one search request is not configuration." | New sentence: "Which provider, which key, how to batch and parser options stay in the adapter's own plugin options. Hybrid weights are declared by the knowledge source, and so is whether its searches are reranked. The reranker is the deployment's configuration, and no source names a model. A parameter of one search request is not configuration." | body 1 | | The note of 2026-11-30 under K8, three sentences (422, 438) | 「K8 第 4 条:「hybrid weights」改划给知识源声明;rerank toggles、parser options 照旧留在驱动。」; under 「永远不进知识源协议」, 「融合算法及其常数、重排、分数阈值、分词器。平台以后如果统一做重排,那是知识服务的配置。」; "Rerank, a score threshold, a tokenizer and the fusion algorithm with its constant never enter the source (section 六, above)." | Reading: "Of rerank, a switch enters the source and nothing else does: no source names a reranker or a model. That switch is not an adapter's option. The fusion algorithm with its constant, a score threshold and a tokenizer still never enter the source, and parser options stay the adapter's." The sentence 「平台以后如果统一做重排,那是知识服务的配置。」 stands. | body 1; these words are later than the rulings that note records (06:00Z to 07:57Z) | ### What the note states beside the amended readings Each is quoted in the note from the words named here. - **The source key.** `source.retrieval.rerank`, an optional boolean, in the `source.retrieval` group the fifth note declares (body 1). - **No reranker is configured.** The search runs normally, the report marks the source with the reason `no_reranker` in `notReranked`, and saving or publishing the source shows a notice. It is never a refusal and never fewer hits (body 2; the two names are the ruling record's). - **A reranker is configured and the source declares it.** Every search is reranked. Only 0 or 1 candidate makes no call and sets no marker. At most 50 passages are sent per search (body 3). - **A configured reranker fails or times out.** The adapter order is kept, the source is marked `failed`, there is one attempt under a limit of 3 s, and it is not a coded refusal (D2). - **One model and one wire format for v1** (D3). The note names neither. - **A hosted deployment.** Hosted reranking comes after row 6 of the epic shows a gain, or a hosted customer asks. Until then a hosted source that declares rerank is searched normally and marked (D4). Left to the rows of the epic by name, under "Not in this note": the hosted recipient and its charging (D5, which is not decided); how a deployment states its reranker and what the knowledge service calls it through (rows 2 and 3); how many candidates are reranked under the ceiling of 50; how a rerank and a declared `affinity` follow one another; how the hits of several sources stand against each other; what `notReranked` looks like on the report and in the answer of `search_knowledge`; how the notice is shown; a per-search argument on the tool. No file under `packages/`, `content/`, `skills/` or `ui/` changes, and no other ADR does. The note declares; it builds nothing. ## Why The epic puts the record before the code. Its row 1 is this note, and the first decision of ruling record `7276086125` says of it: "Accepting row 1's ADR-0161 note records it; no separate decision card." Until this note merges, the ADR gives rerank to the adapter in every place the table above lists, and rule 4 of K8 keeps "rerank toggles" in the adapter's plugin options. Row 2 of the epic brings the key with its reader, and it needs the record to say so first. ## 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 on the text itself, at head `6552e290`: - **Quotations.** A script compared every quoted span of the 28 added lines with its source, read over REST or from the ADR at the base. The added text holds 16 spans in corner brackets: each is a verbatim substring of the body of the epic, of ruling record `7276086125` or `7276461244`, or of the ADR at the base where it already quotes the record of the fifth note. 0 mismatches. It holds 50 spans in double quotation marks: 48 are verbatim in one of those sources, and 2 are the note's own wording, which are the two "new sentence" entries of the table above. - **Bytes.** The added lines hold no raw control byte, no HTML comment and no model identifier. - **The reading of `main` the last paragraph of the note cites**, taken at `acf3b33e31`. `packages/services/service-knowledge/src/knowledge-service-search.ts#searchByKey` re-checks the hits as the caller (`applyPermissionFilter`), orders them by a declared `affinity` (`affinityOrderFor`) and cuts them to `topK`, with no rerank between. Tests aside, in `packages/services/service-knowledge/src` and the `src` of `knowledge-memory`, `knowledge-pgvector` and `knowledge-turso`, the word `rerank` is on one line, which is the class note K2 lists. The control word `embed` is on 412 lines, so the search reads those directories. - **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 **Against the card's acceptance lines.** 1. "Every amended sentence agrees with the design on #38750 (option B) and with rulings D1 to D4." The table above gives each amended place with the ruling it rests on. 2. "No sentence promises row 2 behaviour that the epic does not rule." The note states no pool size, no widening factor, no order between rerank and `affinity`, no settings key name and no shape for the reranker contract. Each of these is named under "Not in this note" and left to its row. 3. "The `Amended` line is dated." Line 24, dated 2026-11-30. 4. "The note does not change any other ADR. It adds no code." One file changes. **Five things for the approver to weigh.** The note marks no ◆, because each of these rests on a text this record or the epic already has. They are the places where the wording is the note's and not a quotation. - a. **What the "Rerank" row keeps.** The note says the row keeps "the adapter's own search", and rests that on two sentences this record already has: "how candidates are found" (the "Hybrid retrieval" row) and "Changing the adapter changes how candidates are found and ranked" (Consequences). - b. **"The declaration is not silent (ADR-0078)".** A source that declares rerank where no reranker is configured is accepted and its search is answered. The note reads body 2 against ADR-0078: each such search says that its source was not reranked, and the author is told on save and on publish. - c. **Nothing is registered in K8.** The note says that the reranker's contract, client and settings (rows 2 and 3 of the epic) are not members of the adapter contract. It rests that on K8's own definition, under "What counts as a member": a member is what an adapter author must read, and no adapter reads these. - d. **A cross-reference under K4.** The card's list of places does not name K4. This record gives every new source key a cross-reference there, as the fifth note did for `source.retrieval`, so one was added. It changes no sentence of K4. - e. **The K2 rows are read through a cross-reference and are not edited.** Draft #38720 edits the K2 row at line 153 in place, with the code that makes its new sentence true. This note's sentence about that row, that it keeps its "no rerank", holds for the row as it is on `main` and as #38720 leaves it. **The names D1 to D6.** This record already writes "ruling D1", "ruling D2" and "ruling D5" for rulings of its own. The note therefore writes the six decisions of the epic as `#38750 D1` to `#38750 D6`, and says in its opening paragraph that none of them is a ruling of this record. It writes `row N of #38750` for the same reason. **The card's line numbers, read on `main` at `acf3b33e`.** All twelve lines the card names (1, 9, 41, 104, 112, 119, 149, 153, 157, 417, 422, 438) exist and carry the text the card expects. Two labels are exchanged: the card gives 422 for rule 4 of K8 and 417 for the note of 2026-11-30. On `main`, rule 4 is line 417, and line 422 is that note's bullet "Rule 4, amended", which carries 「永远不进知识源协议」. Line 438 is that note's bullet "Not in this note". No line moved. **Overlap with the open drafts on this file.** `node scripts/pm/overlap-check.mjs --repo=objectstack-ai/objectstack`, run at `6552e2905b` before the push, printed `VERDICT clean exit 0`. It read `origin/main` at `acf3b33e31` and the six open heads that change this file (#38745, #38732, #38730, #38722, #38721 and #38720), and each merges cleanly with this branch. The order expected exit 1 against #38720. It is clean because the note is add-only and inserts at none of the lines #38720 changes. It was run again before this pull request opened, with `origin/main` at `8426fa0c89` (one commit later, which does not change this file): the same six heads, each merging cleanly, `VERDICT clean exit 0`. The landing order is the card's: after #38720. **Not done here.** `content/docs/protocol/knowledge.mdx` and the class note of `KnowledgeService` are rewritten by the rows whose code makes their new sentences true. There is no changeset: `docs/adr/` is published by no package, and the PR carries `skip-changeset`. ## Verification **Read first, by risk.** One file changes, so these are its three hunks of most risk. 1. Line 146, the bullet "The sentence of the list, amended again". It is the one sentence that gives the knowledge service a second way to re-order hits. 2. Line 156, the bullet "Rule 4 of K8, amended again". The new rule 4 is composed by this note from body 1. 3. Line 150, the bullet "No reranker is configured". It holds the reading against ADR-0078 (item b above). **Two-minute check.** One click: open the "Files changed" tab. Expected: one file, +28 −0, five hunks, every changed line an addition. **Landing.** `docs/adr/**` is a governed surface. This is opened as a draft. The hand-off to the maintainer 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 one reading taken after it opened. **Gates, run locally on head `6552e290`.** `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: 4574 anchors across 165 records resolve — 1704 symbol (1675 declaration, 29 literal), 2818 file-level, 52 cross-repo, 6 exempt, 128 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 29002 text file(s) -- 29002 tracked, 0 untracked-not-ignored; skipped 101 binary; no raw ASCII control bytes). ✓ doc authoring guard: 24253 customer-facing string(s) across 1963 spec sources clean — no internal issue-id references (message 3603 · strictObject 5655 · tombstone 1510 · describe 12078 · functionBuilt 529 · functionDeclared 878). ``` </details> <details> <summary>One gate first read NOT MEASURED, then green</summary> At the first head, `151609a7`, `pnpm --filter @objectstack/lint run check:doc-formula-expressions` answered exit 3, PREREQUISITE NOT MET: two workspace packages it imports were not built in the fresh worktree. That is a run that measured nothing, not a red gate. The two packages were built under the shared verify lock, and the gate was run again (the lock's verdict line is cut after the wait): ```text VERDICT command-exit 0 · held the lock 23s · waited 167s (2m47s) pnpm --filter @objectstack/lint run check:doc-formula-expressions :: exit 0 ``` At the final head it ran with the other 20 and answered 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 names the note writes are the rulings'. - [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 `acf3b33e31`, one pull request. - [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 maintainer'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 by [Claude Code](https://claude.ai/code/session_01ADHkmPDtfMCw4FJfyFfQ7v)_ <!-- signed: repo:objectstack#3 · os-steve · session_01ADHkmPDtfMCw4FJfyFfQ7v --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 43fe8e4 commit e5f7b16

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

0 commit comments

Comments
 (0)