Skip to content

Commit be1cc06

Browse files
docs(adr): ADR-0161 dated note, a knowledge source declares how its hits are ordered for the caller and what a hit brings (#38511)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XDXvJPPtrTGfdDYhWWpihq5)_ Fixes #38502 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:用户无感;只在知识检索的架构记录里加一条带日期的注记,定下知识源怎样声明「和提问人相关的内容排前面」(按负责人或所在单位加权,或本单位就近优先),以及「命中一段时带出前后相邻的内容和它所挂记录的名称」。功能本身由随后三张开发卡分别实现。 - 为什么做:属于知识专题;您已裁定平台做「排序加带出」、不做硬筛选、按时间衰减等有应用要再加。注记把这次裁定写进架构记录,并改掉记录里「知识服务不给候选打分」那一句,随后的实现才有据可依。 - 出错会怎样:只改一份文档,运行行为不变;条文若写错,碰到的是随后照它实现的开发者,可以直接撤回。 - 要你做什么:审批并合并这份注记;注记自己定的两处请一并接受或划掉: - 加权怎样和各存储的相关度分数结合:不碰分数,只按名次挪位(知识源写「前移几位」;本单位就近优先则按单位层级分档)。三种存储的分数含义不同,同一个数在不同存储上效果不一样,名次是唯一各处一致的依据。 - 相邻内容怎样取:不给存储适配器加新接口,由平台把命中的那条记录按当前内容重新切段,取前后几段。所有存储不用改就能用,取到的是记录当前的内容;代价是长文档要整篇读一遍。 ## What changes One file, `docs/adr/0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md`, 25 lines added and none removed against `main`, in three places: - **Header.** A fourth `**Amended**` line, dated 2026-11-29, in the shape of the three before it. It quotes the maintainer's choice 「A 精简:排序加带出」 and names ruling record `7251603512` on the decision card #38412. - **K1, under "What follows from the two lists".** The dated note. It amends by name the sentence "The service does not choose a model, compute a vector, score a candidate, rerank or parse a file" and gives its new reading: the service still computes no score, and may re-order the hits it is about to answer by an ordering their source declares against a platform-resolved fact about the caller, by position alone. The sentence itself, both K1 tables, the K8 table and every earlier note are left as written. - **K4.** One cross-reference line in the block that is there, saying the two source keys are declared by the K1 note and land with their readers. What the note fixes, executing the ruling record's conditions as written: no `filter` mode; the caller fact is a closed list the platform resolves and never a value a client or a model supplies; several `affinity` entries add and a source declares at most one `nearest`; the re-order applies to the unit returned (passage, record or group) inside the existing refill bound and reports no count; the tool gains no opt-out argument; `recency` is not in this note. Choices the note makes past the ruling's words, each marked ◆ in the text for the approver to accept or strike: 1. **The keys sit on the object arm**: `source.affinity` (entries `{ field, caller, mode, places? }`) and `source.expand` (`{ window?, follow? }`), with no wrapper key. 2. **The caller facts are a closed list of two**: `user` and `business_unit` (the primary unit and its parents), both read from the one resolver the caller-identity card #38363 builds. 3. **A boost combines by position, never by score** (the first point the ruling left open). Per source, `nearest` parts that source's units into tiers by distance in the caller's unit chain; inside a tier a `boost` moves a matching unit up by `places`. A hit keeps the score its adapter answered. 4. **Neighbouring passages are cut again from the record; no adapter member is added** (the second point the ruling left open). K8's closed list stays closed. - Review finding S1, rule chosen: neighbours are attached only when the passage cut at the hit's id is the hit's own `snippet`, character for character. Chosen over "only when `indexStatus` answers the expected fingerprint" because it judges the text the service holds, not a report from an optional member, so it is one rule for an adapter with `indexStatus` and one without, and it fails closed on an adapter whose snippet is not the passage. - Review nits N1 to N3 are taken in the note: `expand.window` is marked ◆ and names the heading-bounded mode it leaves out; `places` has no bound until #38503 sets one; a `follow` whose target the record tools serve to no caller is among the refusals. 5. **`expand.follow`** brings the related record's object, id and title, one hop, read as the caller. 6. **An expansion rides on the tool's hit** (`neighbours`, `related`) as a result of the service, so the hit an adapter answers gains no key. The note names the slice cards that build it: #38504 (`expand.window`), #38503 (`affinity`, after the caller-identity card #38363, with the ruling's three-arm measurement as its acceptance), #38505 (`expand.follow`). No code, no schema, no contract member, no changeset: the record declares and implements nothing. `skip-changeset` is declared on this pull: `docs/adr/**` publishes from no released package. ### Read first, by risk 1. The bullet "◆ By position, never by score". Two things to weigh: the re-order is per source (a source's units move only among the places that source's units hold, so another source's hit never moves), and `nearest` is a strict tiering inside the candidates the search already read, not a bounded lift. 2. The bullet "◆ Neighbouring passages are cut again from the record; no adapter member is added". It rests on three readings taken at `545a4fa278`: a passage carries no offset and is not a slice of the document's text; the splitter is pure and the fingerprint covers the applied split; the service already makes the same read and hash comparison in two places. 3. The bullet "◆ `expand.follow`". It reads the slice card's "declared fields" as the hop's object, id and title, and sends a list of fields to bring back to a later dated note. ## Tests None. The diff is one Markdown file under `docs/adr/`; no tested behaviour changes, so nothing is ablated. ## Acceptance notes - **Measured facts the two open points rest on**, all read on `main` at `545a4fa278`: - `knowledge-pgvector` and `knowledge-turso` answer a reciprocal rank fusion (`RRF_K` 60 in both) divided by the score of a passage first in both legs: ranks 1 to 10 in both legs score 1 down to 61/70, and a passage only one leg ranks scores at most 0.5. `knowledge-memory` answers the raw cosine similarity. `KnowledgeHitSchema` says the meaning of `score` is each adapter's. - The service orders merged hits by that score and nothing else (`kept.sort((a, b) => b.score - a.score)` in `searchByKey`, and the same comparison in `answerByRecord`). - `KnowledgeChunkSchema` carries `id`, `documentId`, `index`, `content`, `headingPath?`; no offset. Under `markdown` a passage begins with its heading path and a table cut between rows repeats its header row. - `IKnowledgeAdapter` has no method that reads a passage by document and index. All three in-tree adapters declare `capabilities.chunks` and store the passage ids the service sets. - `splitDocument` is pure; the fingerprint covers the resolved split and the split algorithm version; `checkFreshness` and `dropUnverifiedHits` already read a hit's record, assemble it and compare `docHash`. - **The caller-identity card #38363 is a draft, not merged** (branch `claude/issue-38363-mcp-asker-identity` at `0cea24a56c`, no pull request open on it when this was read). Its resolver answers the user, the active organization, and the primary business unit with its parents, each read as the caller. The note names the two facts it takes, not the resolver's code. - Noted, not filed (carrier in brackets): - That resolver lives in `packages/runtime/src/domains/mcp.ts` on its branch, a package `service-knowledge` does not depend on. The note leaves where it lives to the `affinity` slice and the caller-identity card. [carrier: #38503] - The `expand.window` slice card asks for work in "both stores"; under this note no store changes, because neighbours are cut again from the record. [carrier: #38504, the seat's to reword] - The `expand.follow` slice card's acceptance says "declared fields"; the note reads that as object, id and title. [carrier: #38505, the seat's to reword] - The 维护者速读 carries two sub-lines under its fourth line: the order asks for the two open points in one line each, and the agent file caps the section at four lines. ## Verification Two-minute check: `git diff --stat origin/main...HEAD` prints one file, 25 insertions and no deletion; then `pnpm check:adr-symbol-anchors` exits 0 with its ✅ line, which shows every `path#symbol` the note cites resolves. <details> <summary>Local gates at head ec46fbc (21 derived, 21 run, each exit 0)</summary> Derived with `node scripts/pm/dispatch-gates.mjs --commands` (no path passed; 1 changed path, +25 / -0 against merge base `545a4fa27`) and reconciled with `--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)". - `node scripts/check-adr-links.mjs` and its `--self-test` :: exit 0 ("1281 relative link destination(s) under docs/adr/ resolve") - `pnpm check:adr-anchors` :: exit 0 - `pnpm check:adr-index` :: exit 0 ("docs/adr/README.md is current, every record parsed") - `pnpm check:adr-symbol-anchors` :: exit 0 ("4561 anchors across 165 records resolve ... 0 line anchors survive") - `pnpm check:doc-authoring` :: exit 0 - `pnpm --filter @objectstack/lint run check:doc-formula-expressions` :: exit 0 (after building `@objectstack/formula` and `@objectstack/lint` under the verify lock, VERDICT command-exit 0) - `node scripts/check-closing-keyword-parity.mjs` and its `--self-test` :: exit 0 - `node scripts/check-comment-mask-corpus.mjs` :: exit 0 ("24362 files, 0 disagree, 0 unparseable") - `node scripts/ci/plan-test-core-shards.mjs --self-test` :: exit 0 - `pnpm check:ci-filter-parity`, `check:closed-ceremony-text`, `check:cross-package-test-inputs`, `check:driver-memory-census`, `check:gitlink-declared`, `check:nul-bytes`, `check:pm-governed-merges`, `check:pm-prior-rulings`, `check:refd-timer-probe`, `check:watch-hint-literal` :: exit 0 each The whole list was run again at `ec46fbc986`, after the rework commit, with `node scripts/pm/overlap-check.mjs` before the push (VERDICT clean, exit 0). At the first head, seven of these exited 3 on the first pass (PREREQUISITE NOT MET: the worktree had no `node_modules`, then two unbuilt packages); each was run again after `pnpm install` and the build and exited 0. The repo-wide scans and the full check farm are left to CI. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- signed: repo:objectstack#5 · os-project-manager · session_01FEkQ5oQLfL8thb6wtUHnTb --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 0af813f commit be1cc06

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

0 commit comments

Comments
 (0)