From f00518e71686cb172d227df00f9324fc0c271b76 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 00:40:06 +0000 Subject: [PATCH 1/2] =?UTF-8?q?docs(adr):=20ADR-0161=20dated=20note=20?= =?UTF-8?q?=E2=80=94=20an=20adapter=20embeds=20a=20search's=20question=20o?= =?UTF-8?q?nce,=20and=20its=20refusals=20stay=20ahead=20of=20the=20embed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A seventh dated note under K8 ("Rules for every member"), its line in the header's amendment list, and one cross-reference under K1. Add-only: 17 lines added, none changed and none removed. The note registers exactly two optional adapter-contract members, IKnowledgeAdapter.embedQuery and AdapterSearchOptions.queryVector, and the list stays closed beyond them. It records the maintainer's ruling of 2026-12-01 (ruling record 7296268226 on the card) and settles the three readings contract review 7290045524 left open: the adapter still embeds, with its own embedder and query prefix, and the service computes no vector; one vector serves every source a search binds to an adapter instance; a handed vector is checked by its width. It states the ruling's condition as an outcome: an adapter's refusals are answered as on main, and no question is sent to an embedding provider for a source the adapter refuses. The means it names: the second member is a function that answers a promise of the vector, and the adapter calls it at the point where it embeds today. It declares and builds nothing: no file under packages/ changes. Claude-Session: https://claude.ai/code/session_01JQwxbXfgA45f3y5YpDPT5h Co-authored-by: Claude --- ...eturn-knowledge-source-is-a-governed-type.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/adr/0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md b/docs/adr/0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md index 9dd5e0fe74e..12d76550300 100644 --- a/docs/adr/0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md +++ b/docs/adr/0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md @@ -22,6 +22,7 @@ - **Amended** (2026-11-29, [#38502](https://github.com/objectstack-ai/objectstack/issues/38502)): a fourth dated note, under "What follows from the two lists" in [K1](#k1--the-boundary), amends that list's sentence "The service does not choose a model, compute a vector, score a candidate, rerank or parse a file": the service may re-order the hits it is about to answer by an ordering their source declares against a fact about the caller, by position and never by score, and a source may declare what a hit brings with it (`source.affinity`, `source.expand`). It is written on the maintainer's ruling of that day, his choice of the decision card's option 「A 精简:排序加带出」 (record [`7251603512`](https://github.com/objectstack-ai/objectstack/issues/38412#issuecomment-7251603512) on #38412). It adds no contract member. A cross-reference stands under [K4](#k4--knowledge_source-is-admitted-as-a-metadata-type). The status line above is left as it is. - **Amended** (2026-11-30, [#38692](https://github.com/objectstack-ai/objectstack/issues/38692)): a fifth dated note, under "Rules for every member" in [K8](#k8--the-contract-additions-decided-item-by-item), amends rule 4 of that list and the reading of the "Hybrid retrieval" row of [K1](#k1--the-boundary), and with it of "hybrid retrieval" in the title, in the D1 key-words line above and in TL;DR item 1: a knowledge source declares which retrieval legs run and the vector leg's share (`source.retrieval`), the adapter reports the modes it supports and still decides how candidates are found and how the legs are fused, and a parameter of one search request is not configuration. Decided by the maintainer on 2026-11-30: ruling record [`7270218011`](https://github.com/objectstack-ai/objectstack/issues/38692#issuecomment-7270218011) on #38692, given on his words 「同意,更新决策卡」 (2026-11-30T06:00Z) and revised after an independent review on his words 「全部采纳,修正裁决」 (2026-11-30T06:16Z); the note records the revised text. It registers two contract members, `AdapterCapabilities.retrieval` and `AdapterSearchOptions.retrieval`; that the second is optional, like the first, is his choice of the decision card's option 「可选(推荐)」 at 2026-11-30T07:57Z (record [`7272337479`](https://github.com/objectstack-ai/objectstack/issues/38692#issuecomment-7272337479) on #38692). It is in force from the maintainer's merge of the PR that carries it, which the record keeps for him: 「单独 PR,Tier H,由维护者亲手合并」. Cross-references stand under [K1](#k1--the-boundary) and [K4](#k4--knowledge_source-is-admitted-as-a-metadata-type). The status line above is left as it is. - **Amended** (2026-11-30, [#38760](https://github.com/objectstack-ai/objectstack/issues/38760)): a sixth dated note, under "What follows from the two lists" in [K1](#k1--the-boundary), amends the reading of the "Rerank" row of that section, and with it of "rerank" in the title, in the D1 key-words line above and in TL;DR item 1. It amends again the sentence of that list which the fourth note amended, and rule 4 of [K8](#k8--the-contract-additions-decided-item-by-item) as the fifth note left it: a knowledge source may declare that its searches are reranked (`source.retrieval.rerank`), the reranker is the deployment's configuration and no source names a model, and the knowledge service reranks, after the permission re-check and before the cut to `topK`. The adapter contract does not change. Decided by the maintainer on 2026-11-30, after the rulings the fifth note records: on his words 「有就用」 (10:13Z) and 「所以还是应该按照主流系统的做法,开了开关,一律重排」 (10:37Z), as the body of [#38750](https://github.com/objectstack-ai/objectstack/issues/38750), the epic for knowledge retrieval rerank, records them, and on his 「全部同意」 (10:47Z) to the six decisions of that card (ruling record [`7276086125`](https://github.com/objectstack-ai/objectstack/issues/38750#issuecomment-7276086125) on #38750). The first of the six, which is not ruling D1 of the key-words line above, says of this note: "Accepting row 1's ADR-0161 note records it; no separate decision card." It adds no contract member, no tool argument and no settings key. Cross-references stand under [K2](#k2--the-texts-this-record-revises), [K4](#k4--knowledge_source-is-admitted-as-a-metadata-type) and [K8](#k8--the-contract-additions-decided-item-by-item). The status line above is left as it is. +- **Amended** (2026-12-01, [#38676](https://github.com/objectstack-ai/objectstack/issues/38676)): a seventh dated note, under "Rules for every member" in [K8](#k8--the-contract-additions-decided-item-by-item), registers two contract members, both optional: `IKnowledgeAdapter.embedQuery`, by which an adapter embeds the question of a search as its own `search` embeds it, and `AdapterSearchOptions.queryVector`, by which the knowledge service carries that vector back to the adapter instance that made it, for every `search` call of that search, the refill round included. It is read with the "Embedding calls" row of [K1](#k1--the-boundary), with the second sentence of the list under that section and with item 15 of K8, and it amends none of them: the adapter still embeds, with its own embedder and query prefix, at the point where it embeds today, and the service computes no vector. Decided by the maintainer on 2026-12-01, by his choice of the decision card's option 「写进约定,一次提问只转一次」 at 00:22Z (ruling record [`7296268226`](https://github.com/objectstack-ai/objectstack/issues/38676#issuecomment-7296268226) on #38676), which carries one condition: 「附带条件:存储驱动原本会给出的拒绝提示(比如“需要重建索引”)要保持在前面,不能被转向量的报错盖掉。」 The note states that condition as an outcome and names the means it takes, a function the adapter calls where it embeds today, which fixes the second member's type. A cross-reference stands under [K1](#k1--the-boundary). The status line above is left as it is. --- @@ -160,6 +161,8 @@ Ruling D1, as two lists. The left one is the knowledge service's work, done once > > This note adds no contract member, no tool argument and no settings key: the list stays closed (rules 3 and 5 of K8). It declares, and the rows of #38750 build it. Its row 2 brings the key with its reader in one PR (K10 rule 1), and each row rewrites the docs sentences its code makes untrue, never ahead of it (K2). Until then `main` has no such key and reranks nothing. Read on `main` 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; and, 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, the class note that K2 lists (the control `embed` is on 412). The title, the two tables of K1, the tables of K2 and K8, the rules of K8 and every earlier note are left as written; read the "Rerank" row, the second sentence of the list and rule 4 with this note. +> **Cross-reference (2026-12-01, [#38676](https://github.com/objectstack-ai/objectstack/issues/38676)).** The "Embedding calls" row of the adapter's table above, and "compute a vector" in the second sentence of the list, are read with the dated note of 2026-12-01 under "Rules for every member" in [K8](#k8--the-contract-additions-decided-item-by-item). That note registers two optional contract members, `IKnowledgeAdapter.embedQuery` and `AdapterSearchOptions.queryVector`, so that the question of a search is embedded at most once for each adapter instance and no longer once for each `search` call. The adapter still embeds, with its own embedder and query prefix, and "When to call, how to batch, and whether to call at all" stay the adapter's: the knowledge service hands it a function, and the adapter calls it at the point where it embeds today. The service computes no vector. It carries one back to the adapter instance that made it, inside one search. No sentence of K1 or of its notes is changed. + **The push door.** `indexDocument(sourceId, doc)` and `deleteDocument(sourceId, documentId)` hand a caller-built document to the adapter. On an object source that contradicts the first row above and K5: a pushed document is not built by assembly, so neither the content list nor the egress rule binds it, and the purge of #37096 removes it at the next complete rebuild, because no record answers for it. So **both calls are refused on an object source**, with a coded refusal (ADR-0112), from row 3 at the latest; an earlier card that touches the door may land the refusal sooner. They remain the write door of a source that is not an object source. Whether v1 has such a source is point 1 (K4): if that point stands, the two methods leave `IKnowledgeService` with the `file` and `http` arms. ### K2 — The texts this record revises @@ -467,6 +470,20 @@ Rules for every member: > **Cross-reference (2026-11-30, [#38760](https://github.com/objectstack-ai/objectstack/issues/38760)).** Rule 4 above, and the three sentences of the note of 2026-11-30 above that speak of rerank, are read with the dated note of 2026-11-30 on #38760 under "What follows from the two lists" in [K1](#k1--the-boundary), which is written on the maintainer's later words of that day. Whether a source's searches are reranked is declared by the knowledge source, so "rerank toggles" leaves the adapter's plugin options in rule 4. Of rerank, a switch enters the source and no model does. The sentence 「平台以后如果统一做重排,那是知识服务的配置。」 of the record of #38692 stands: the knowledge service reranks, with the reranker the deployment configures. That note adds no member: `IKnowledgeAdapter` and `AdapterSearchOptions` are unchanged, and the list stays closed (rules 3 and 5). No sentence of K8 or of the note above is changed. +> **Note (2026-12-01, [#38676](https://github.com/objectstack-ai/objectstack/issues/38676)) — two members, `IKnowledgeAdapter.embedQuery` and `AdapterSearchOptions.queryVector`: the question of a search is embedded at most once for each adapter instance, by the adapter, and the knowledge service carries the vector back to it for every call of that search; the adapter asks for it where it embeds today, so its refusals are answered as before.** Decided by the maintainer on 2026-12-01: ruling record [`7296268226`](https://github.com/objectstack-ai/objectstack/issues/38676#issuecomment-7296268226) on #38676. He ruled by choosing an option of a decision card, and the record carries the card's words, verbatim and untranslated. The card's question: 「选定知识搜索补查时重复生成问题向量的处理路线」. The option he chose, at 2026-12-01T00:22:00Z: 「写进约定,一次提问只转一次」, which the card explains as 「需要补查的搜索快约0.2秒,多知识源的应用也只转一次;先补一条架构记录再合已做好的改动,共2个PR。」 The condition that the brief he read beside the card attaches to that option: 「附带条件:存储驱动原本会给出的拒绝提示(比如“需要重建索引”)要保持在前面,不能被转向量的报错盖掉。」 In English, the question is which route to take for the question's vector being made again when a knowledge search looks a second time. The option: write it into the contract, and a question is embedded once. The card's line on it: a search that looks a second time answers about 0.2 s sooner, and an application with several knowledge sources embeds once too; an architecture record is amended first and the change already built is merged after it, two PRs in all. The condition: the refusal a store would have given by itself, such as that its index needs a rebuild, stays in front and is not covered by an error from embedding the question. The record's 「存储驱动」 is this record's adapter, its 「转」 is to embed, and its 「补查」 is the refill round of a search: the second look a search takes when its first round leaves fewer than `topK` after the permission re-check. The architecture record is this one, and this note is the amendment. The analysis he ruled on is comment `7290428149` on #38676. Its section "After the ruling" sets out what this note writes, and the ruling record repeats it. The finding this note answers is M1 of contract review [`7290045524`](https://github.com/objectstack-ai/objectstack/pull/38798#issuecomment-7290045524) on PR [#38798](https://github.com/objectstack-ai/objectstack/pull/38798): that PR built the two members on 2026-11-30, before this record named them, and rule 5 above holds it until it does. The ruling record leaves one choice to this note: "The note names the means it takes, and the member's type follows from that choice." A ◆ marks what this note decides there, and one sentence it adds to the third reading, for the approver to accept with it or strike. The other statements are the ruling record's or the analysis's, quoted where they are given, what follows from the means, or a reading of `main`. +> +> - **The two members.** `IKnowledgeAdapter.embedQuery?(query: string): Promise`, on `packages/spec/src/contracts/knowledge-adapter.ts#IKnowledgeAdapter`. It embeds a question as that adapter's own `search` embeds it: through the adapter's embedder and with its query-side options, a query prefix among them (item 15). It takes no source and no context. And `AdapterSearchOptions.queryVector?`, on `#AdapterSearchOptions` in the same file, whose type the next bullet fixes: what the knowledge service hands an adapter that has `embedQuery`, for the adapter to take the question's vector from. Each is optional (rule 2). An adapter without `embedQuery` is handed nothing and is searched as before: it embeds the question on every `search` call, its answer is the same, and nothing is skipped. No capability flag is added. The method's presence is the signal, as "What "capabilities" became" above says of the other optional methods: "the service asks whether the method is there". `queryVector` is a parameter of one search request, as `topK`, `scope` and `retrieval` are, and neither member carries configuration (rule 4). +> - **◆ The means, and with it the member's type.** `AdapterSearchOptions.queryVector?: () => Promise`. The member is a function that answers the question's vector, and not the vector. One search is one call of the knowledge service's search, with every round it runs. For one search the service makes at most one `embedQuery` call for each adapter instance that has the method, and it makes that call only through the function. The first time the function is called in a search, it calls that instance's `embedQuery` with the search's query. Every later call in that search, on whichever `search` call it was handed, answers the same promise, a rejected one too: a second source the search binds to that instance, the refill round and an adapter's own retry all read the one embedding call. The service hands the function on every `search` call it makes to that instance in that search, and it does not judge whether a call will embed. An adapter that is handed the member calls it at the point of its `search` where it embeds the query today, in place of that embedding call and inside the `search` call that carried it. It does not change the array it is answered, which serves the search's other calls. This is the means the analysis recommends: "the service hands the adapter a per-search memoised provider and the adapter calls it at the line where it embeds today, so every gate stays ahead of the embed". The name is the one PR #38798 gave the member and the analysis uses; the type is new. As #38798 stands (head `4561e81d0e`), the member is the vector itself, `readonly number[]`, and the service calls `embedQuery` ahead of `search`. That is the shape review `7290045524` read against K1, and it is not taken. Nor is the lesser means the analysis names: "on a failed service-side embed, call `search` without the vector; that restores the refusal but still spends an embed on a refused source." The analysis: "The member's type differs between the two, so the note names the one taken." +> - **The first reading of M1: who embeds, and who decides when.** The "Embedding calls" row of [K1](#k1--the-boundary) gives the adapter "Turning passages and queries into vectors, through the embedder the deployment configures", and says: "When to call, how to batch, and whether to call at all (an engine that embeds inside itself makes no call) are the adapter's." The second sentence of the list under that section, as the note of 2026-11-30 on #38760 left it, begins: "The service does not choose a model, compute a vector, compute a score for a candidate or parse a file." Item 15 says: "The adapter embeds, so it knows a query from a passage and applies a prefix itself". The three stand as written, and this note amends none of them. The analysis settles the reading: "the adapter still embeds, with its own embedder and prefix, and the service computes no vector, it carries one back to the instance that made it inside one search". By the means above the row holds word for word. When: the vector is made when an adapter first asks for it, at the point where that adapter embeds today. Whether: an adapter that does not reach that point never asks, so nothing is embedded for a search under `keyword`, for a search that ranks nothing, or for a source the adapter refuses. The service chooses no model and no prefix, and it does not read the vector: it holds the promise for the length of one search and answers it to the instance that made it, and to no other. +> - **The second reading: one vector for every source of an adapter instance.** The analysis: "one vector serves every source the search binds to that adapter instance, and an adapter whose query embedding depends on the source does not implement the method". `embedQuery` takes no source, so the one vector serves each source the search binds to the instance, in the first round and in the refill. An adapter that embeds a query by a model, a width or a prefix that differs from source to source does not implement the method: it keeps embedding inside `search`, where it knows the source, and is handed nothing. Two adapter instances are two functions and two embedding calls, and a vector never reaches an instance other than the one that made it. In `knowledge-turso` and `knowledge-pgvector` the embedder and the query prefix belong to the adapter instance and no source changes either, so both can implement it. +> - **The third reading: a handed vector is checked by its width.** The analysis: "a handed vector is checked by its width". An adapter checks what the function answers as it checks what its own embedder answers today: against the width of the index it is about to rank. A vector of another width refuses the source and is never ranked. Nothing else of the vector is checked. The model is judged where K7 judges it, on the fingerprint the service expects of the index (item 8 a, `AdapterSearchOptions.index`), and the adapter compares that before it reaches the embed. The member is the knowledge service's to hand: `IKnowledgeService.search` takes no vector from its caller, and no tool argument carries one. ◆ A caller that reaches an adapter's `search` directly and hands the member answers for the function: that it answers this instance's own `embedQuery` for this query. The adapter does not verify it. +> - **The condition, as an outcome.** The ruling record: "an adapter's refusals are answered as on `main`, and no question goes to a provider for a source the adapter refuses." The provider is the embedding provider. So the refusal an adapter gives ahead of its embed is the one that is answered, code, status and remedy as on `main`, whatever the embedder would have answered, and a source refused there costs no embedding call. 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 means above gives this by construction: an adapter asks for the vector only after everything it decides first. Read on `main` at `0fc9eab900`, in the `search` of `packages/plugins/knowledge-turso/src/turso-adapter.ts#TursoKnowledgeAdapter` and of `packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts#PgvectorKnowledgeAdapter`, what an adapter decides ahead of the query's embedding call: whether anything is ranked at all, which an empty organization set, a scope with no ids and a `topK` of zero each answer with no hits; whether its store and its embedder are present and the store is ready; whether the source has an active generation; whether that generation holds the fingerprint the search expects and the embedder's width, whose refusal is `KNOWLEDGE_REBUILD_REQUIRED` (409); whether it runs the mode it is asked for; and whether that mode embeds, which `keyword` never does. The outcome is stated for whatever an adapter decides ahead of its embed, and not for that list. When the embedding call itself fails, it fails inside the adapter's `search`, where it fails today, and each source that asked for the vector in that search is refused with the code and the wording it has on `main`. +> - **What a search costs, on `main` and after.** Read on `main` at `0fc9eab900`: `packages/services/service-knowledge/src/knowledge-service-search.ts#searchByKey` runs a first round and, when that round leaves fewer than `topK` after the permission re-check, a refill round for the sources that may hold more. Each round is one `#searchRound`, which calls `search` once for each source, and each of the two stores embeds the query inside every `search` call that reaches its vector leg. So a search embeds the question twice for each source it refills, and a search over several sources of one adapter instance embeds it once for each of them in a round. From #38798 a search embeds it at most once for each adapter instance, and not at all where no source asks. The note of 2026-11-29 under K1 holds a member whose reason is cost to a measurement: it returns "when that cost is measured on a real source". The body of #38676 records this one: on a policy source of 59,621 passages, 27 of 31 searches made without a scope refilled, none of the 30 made with a unit scope did, and one embedding call took 202 ms at the median. +> - **What the members land with (rules 1 and 2).** PR #38798 lands both members after this note merges, with their first readers, in one PR (rule 1). The knowledge service's search reads `embedQuery` and hands `queryVector` (`packages/services/service-knowledge/src/knowledge-service-search.ts#searchRound`). `knowledge-turso` and `knowledge-pgvector` implement the first and read the second. `knowledge-memory` implements neither and is searched as before (rule 2). The case in the contract test suite (`packages/services/service-knowledge/src/testing.ts#runKnowledgeAdapterContract`) is the one review `7290045524` asks for under S1, with the function in the vector's place: an adapter that has `embedQuery`, handed a function that answers its own `embedQuery` for the query, answers what it answers without the member and makes no embedding call of its own for the query; handed a function that answers a vector of another width, it refuses the search. An adapter without the method is not held to the case. The condition has its own pin in each of the two stores, the ruling record's case above. The docblocks of #38798 cite this note and no longer say that the knowledge service embeds. +> - **Not in this note.** A vector handed by a caller of `IKnowledgeService.search` or by an argument of `search_knowledge`. A memo of the question's vector that an adapter keeps past one search, which is the analysis's option B, and leaving the second call in place, its option C: the ruling takes neither, and its record says "There is no fall-back to B or C." A source or a context argument on `embedQuery`, and a form that embeds several questions at once: each returns by a dated note here, with its reader. An `inputType` argument on `IEmbedder.embed` stays where item 15 leaves it. How passages are embedded is unchanged. The texts that list the contract's members (§3.4 of `content/docs/protocol/knowledge.mdx`) are rewritten by #38798, whose code makes the new sentences true, never ahead of it (K2). +> +> This note registers exactly two members, `IKnowledgeAdapter.embedQuery` and `AdapterSearchOptions.queryVector`, and no other: the list stays closed beyond them (rules 3 and 5). It declares, and PR #38798 builds it; the PR that lands this note changes no file under `packages/`. A reader that finds one of the two shapes cannot be built as written stops and says so on its card (rule 3). Until #38798 lands, `main` has neither member: at `0fc9eab900` no line under `packages/` or `content/` names `embedQuery` or `queryVector`, and every `search` call of `knowledge-turso` and `knowledge-pgvector` that reaches its vector leg embeds the query itself. The code this note cites was read on `main` at `0fc9eab900`, and PR #38798 at head `4561e81d0e`. The two tables of K1, the table of K8, the rules above and every earlier note are left as written; read the "Embedding calls" row, the second sentence of the list under K1 and item 15 with this note. + ### K9 — One `search_knowledge` definition, and every knowledge tool goes through the tool registry and the MCP seams **What landed** (PR #36823, merged as `8aecf6d770`, read in the tree at `254e396a29`). The tool has one definition, `packages/services/service-knowledge/src/knowledge-tools.ts#getKnowledgeToolDefinitions`, and one executor, bound by `packages/services/service-knowledge/src/knowledge-tools.ts#createKnowledgeTools`. The knowledge service hands both out through `knowledgeTools()`. Both MCP transports register that definition and call that executor as the principal they bind, where the grant admits `data:read` (`packages/mcp/src/mcp-http-tools.ts#registerKnowledgeTools`; the HTTP bridge in `packages/runtime/src/domains/mcp.ts`, the stdio bridge in `packages/mcp/src/stdio-data-bridge.ts`). From f3cd7dba76c65ba209c5fea2f2d9a1857bbcddfa Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 00:55:09 +0000 Subject: [PATCH 2/2] =?UTF-8?q?docs(adr):=20ADR-0161=20note=20of=202026-12?= =?UTF-8?q?-01=20=E2=80=94=20name=20every=20source=20the=20unmarked=20stat?= =?UTF-8?q?ements=20rest=20on?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Review pass on the seventh dated note. Two sentences change; the diff against main stays add-only (17 lines added, none changed and none removed). - The note's opening says what is not marked with a diamond rests on the ruling record, the analysis, or a reading of main. It also rests on contract review 7290045524 (the suite case, the reading that the method takes no source), on this record's own rules, on PR #38798 at its head and on the body of the card. The sentence now lists them. - The signature of IKnowledgeAdapter.embedQuery is the one PR #38798 declares at head 4561e81d0e. The members bullet now says so, so that an approver does not read an unmarked shape with no source. Nothing the note decides moves: the two members, the type of the second, the three readings, the condition and the means are as committed. Claude-Session: https://claude.ai/code/session_01JQwxbXfgA45f3y5YpDPT5h Co-authored-by: Claude --- ...split-record-return-knowledge-source-is-a-governed-type.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/adr/0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md b/docs/adr/0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md index 12d76550300..74a77183add 100644 --- a/docs/adr/0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md +++ b/docs/adr/0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md @@ -470,9 +470,9 @@ Rules for every member: > **Cross-reference (2026-11-30, [#38760](https://github.com/objectstack-ai/objectstack/issues/38760)).** Rule 4 above, and the three sentences of the note of 2026-11-30 above that speak of rerank, are read with the dated note of 2026-11-30 on #38760 under "What follows from the two lists" in [K1](#k1--the-boundary), which is written on the maintainer's later words of that day. Whether a source's searches are reranked is declared by the knowledge source, so "rerank toggles" leaves the adapter's plugin options in rule 4. Of rerank, a switch enters the source and no model does. The sentence 「平台以后如果统一做重排,那是知识服务的配置。」 of the record of #38692 stands: the knowledge service reranks, with the reranker the deployment configures. That note adds no member: `IKnowledgeAdapter` and `AdapterSearchOptions` are unchanged, and the list stays closed (rules 3 and 5). No sentence of K8 or of the note above is changed. -> **Note (2026-12-01, [#38676](https://github.com/objectstack-ai/objectstack/issues/38676)) — two members, `IKnowledgeAdapter.embedQuery` and `AdapterSearchOptions.queryVector`: the question of a search is embedded at most once for each adapter instance, by the adapter, and the knowledge service carries the vector back to it for every call of that search; the adapter asks for it where it embeds today, so its refusals are answered as before.** Decided by the maintainer on 2026-12-01: ruling record [`7296268226`](https://github.com/objectstack-ai/objectstack/issues/38676#issuecomment-7296268226) on #38676. He ruled by choosing an option of a decision card, and the record carries the card's words, verbatim and untranslated. The card's question: 「选定知识搜索补查时重复生成问题向量的处理路线」. The option he chose, at 2026-12-01T00:22:00Z: 「写进约定,一次提问只转一次」, which the card explains as 「需要补查的搜索快约0.2秒,多知识源的应用也只转一次;先补一条架构记录再合已做好的改动,共2个PR。」 The condition that the brief he read beside the card attaches to that option: 「附带条件:存储驱动原本会给出的拒绝提示(比如“需要重建索引”)要保持在前面,不能被转向量的报错盖掉。」 In English, the question is which route to take for the question's vector being made again when a knowledge search looks a second time. The option: write it into the contract, and a question is embedded once. The card's line on it: a search that looks a second time answers about 0.2 s sooner, and an application with several knowledge sources embeds once too; an architecture record is amended first and the change already built is merged after it, two PRs in all. The condition: the refusal a store would have given by itself, such as that its index needs a rebuild, stays in front and is not covered by an error from embedding the question. The record's 「存储驱动」 is this record's adapter, its 「转」 is to embed, and its 「补查」 is the refill round of a search: the second look a search takes when its first round leaves fewer than `topK` after the permission re-check. The architecture record is this one, and this note is the amendment. The analysis he ruled on is comment `7290428149` on #38676. Its section "After the ruling" sets out what this note writes, and the ruling record repeats it. The finding this note answers is M1 of contract review [`7290045524`](https://github.com/objectstack-ai/objectstack/pull/38798#issuecomment-7290045524) on PR [#38798](https://github.com/objectstack-ai/objectstack/pull/38798): that PR built the two members on 2026-11-30, before this record named them, and rule 5 above holds it until it does. The ruling record leaves one choice to this note: "The note names the means it takes, and the member's type follows from that choice." A ◆ marks what this note decides there, and one sentence it adds to the third reading, for the approver to accept with it or strike. The other statements are the ruling record's or the analysis's, quoted where they are given, what follows from the means, or a reading of `main`. +> **Note (2026-12-01, [#38676](https://github.com/objectstack-ai/objectstack/issues/38676)) — two members, `IKnowledgeAdapter.embedQuery` and `AdapterSearchOptions.queryVector`: the question of a search is embedded at most once for each adapter instance, by the adapter, and the knowledge service carries the vector back to it for every call of that search; the adapter asks for it where it embeds today, so its refusals are answered as before.** Decided by the maintainer on 2026-12-01: ruling record [`7296268226`](https://github.com/objectstack-ai/objectstack/issues/38676#issuecomment-7296268226) on #38676. He ruled by choosing an option of a decision card, and the record carries the card's words, verbatim and untranslated. The card's question: 「选定知识搜索补查时重复生成问题向量的处理路线」. The option he chose, at 2026-12-01T00:22:00Z: 「写进约定,一次提问只转一次」, which the card explains as 「需要补查的搜索快约0.2秒,多知识源的应用也只转一次;先补一条架构记录再合已做好的改动,共2个PR。」 The condition that the brief he read beside the card attaches to that option: 「附带条件:存储驱动原本会给出的拒绝提示(比如“需要重建索引”)要保持在前面,不能被转向量的报错盖掉。」 In English, the question is which route to take for the question's vector being made again when a knowledge search looks a second time. The option: write it into the contract, and a question is embedded once. The card's line on it: a search that looks a second time answers about 0.2 s sooner, and an application with several knowledge sources embeds once too; an architecture record is amended first and the change already built is merged after it, two PRs in all. The condition: the refusal a store would have given by itself, such as that its index needs a rebuild, stays in front and is not covered by an error from embedding the question. The record's 「存储驱动」 is this record's adapter, its 「转」 is to embed, and its 「补查」 is the refill round of a search: the second look a search takes when its first round leaves fewer than `topK` after the permission re-check. The architecture record is this one, and this note is the amendment. The analysis he ruled on is comment `7290428149` on #38676. Its section "After the ruling" sets out what this note writes, and the ruling record repeats it. The finding this note answers is M1 of contract review [`7290045524`](https://github.com/objectstack-ai/objectstack/pull/38798#issuecomment-7290045524) on PR [#38798](https://github.com/objectstack-ai/objectstack/pull/38798): that PR built the two members on 2026-11-30, before this record named them, and rule 5 above holds it until it does. The ruling record leaves one choice to this note: "The note names the means it takes, and the member's type follows from that choice." A ◆ marks what this note decides there, and one sentence it adds to the third reading, for the approver to accept with it or strike. The other statements are the ruling record's, the analysis's or review `7290045524`'s, quoted or named where they are given; or what follows from the means or from the rules above; or a reading of `main`, of PR #38798 or of the body of #38676. > -> - **The two members.** `IKnowledgeAdapter.embedQuery?(query: string): Promise`, on `packages/spec/src/contracts/knowledge-adapter.ts#IKnowledgeAdapter`. It embeds a question as that adapter's own `search` embeds it: through the adapter's embedder and with its query-side options, a query prefix among them (item 15). It takes no source and no context. And `AdapterSearchOptions.queryVector?`, on `#AdapterSearchOptions` in the same file, whose type the next bullet fixes: what the knowledge service hands an adapter that has `embedQuery`, for the adapter to take the question's vector from. Each is optional (rule 2). An adapter without `embedQuery` is handed nothing and is searched as before: it embeds the question on every `search` call, its answer is the same, and nothing is skipped. No capability flag is added. The method's presence is the signal, as "What "capabilities" became" above says of the other optional methods: "the service asks whether the method is there". `queryVector` is a parameter of one search request, as `topK`, `scope` and `retrieval` are, and neither member carries configuration (rule 4). +> - **The two members.** `IKnowledgeAdapter.embedQuery?(query: string): Promise`, on `packages/spec/src/contracts/knowledge-adapter.ts#IKnowledgeAdapter`, with the signature PR #38798 gives it at head `4561e81d0e`. It embeds a question as that adapter's own `search` embeds it: through the adapter's embedder and with its query-side options, a query prefix among them (item 15). It takes no source and no context. And `AdapterSearchOptions.queryVector?`, on `#AdapterSearchOptions` in the same file, whose type the next bullet fixes: what the knowledge service hands an adapter that has `embedQuery`, for the adapter to take the question's vector from. Each is optional (rule 2). An adapter without `embedQuery` is handed nothing and is searched as before: it embeds the question on every `search` call, its answer is the same, and nothing is skipped. No capability flag is added. The method's presence is the signal, as "What "capabilities" became" above says of the other optional methods: "the service asks whether the method is there". `queryVector` is a parameter of one search request, as `topK`, `scope` and `retrieval` are, and neither member carries configuration (rule 4). > - **◆ The means, and with it the member's type.** `AdapterSearchOptions.queryVector?: () => Promise`. The member is a function that answers the question's vector, and not the vector. One search is one call of the knowledge service's search, with every round it runs. For one search the service makes at most one `embedQuery` call for each adapter instance that has the method, and it makes that call only through the function. The first time the function is called in a search, it calls that instance's `embedQuery` with the search's query. Every later call in that search, on whichever `search` call it was handed, answers the same promise, a rejected one too: a second source the search binds to that instance, the refill round and an adapter's own retry all read the one embedding call. The service hands the function on every `search` call it makes to that instance in that search, and it does not judge whether a call will embed. An adapter that is handed the member calls it at the point of its `search` where it embeds the query today, in place of that embedding call and inside the `search` call that carried it. It does not change the array it is answered, which serves the search's other calls. This is the means the analysis recommends: "the service hands the adapter a per-search memoised provider and the adapter calls it at the line where it embeds today, so every gate stays ahead of the embed". The name is the one PR #38798 gave the member and the analysis uses; the type is new. As #38798 stands (head `4561e81d0e`), the member is the vector itself, `readonly number[]`, and the service calls `embedQuery` ahead of `search`. That is the shape review `7290045524` read against K1, and it is not taken. Nor is the lesser means the analysis names: "on a failed service-side embed, call `search` without the vector; that restores the refusal but still spends an embed on a refused source." The analysis: "The member's type differs between the two, so the note names the one taken." > - **The first reading of M1: who embeds, and who decides when.** The "Embedding calls" row of [K1](#k1--the-boundary) gives the adapter "Turning passages and queries into vectors, through the embedder the deployment configures", and says: "When to call, how to batch, and whether to call at all (an engine that embeds inside itself makes no call) are the adapter's." The second sentence of the list under that section, as the note of 2026-11-30 on #38760 left it, begins: "The service does not choose a model, compute a vector, compute a score for a candidate or parse a file." Item 15 says: "The adapter embeds, so it knows a query from a passage and applies a prefix itself". The three stand as written, and this note amends none of them. The analysis settles the reading: "the adapter still embeds, with its own embedder and prefix, and the service computes no vector, it carries one back to the instance that made it inside one search". By the means above the row holds word for word. When: the vector is made when an adapter first asks for it, at the point where that adapter embeds today. Whether: an adapter that does not reach that point never asks, so nothing is embedded for a search under `keyword`, for a search that ranks nothing, or for a source the adapter refuses. The service chooses no model and no prefix, and it does not read the vector: it holds the promise for the length of one search and answers it to the instance that made it, and to no other. > - **The second reading: one vector for every source of an adapter instance.** The analysis: "one vector serves every source the search binds to that adapter instance, and an adapter whose query embedding depends on the source does not implement the method". `embedQuery` takes no source, so the one vector serves each source the search binds to the instance, in the first round and in the refill. An adapter that embeds a query by a model, a width or a prefix that differs from source to source does not implement the method: it keeps embedding inside `search`, where it knows the source, and is handed nothing. Two adapter instances are two functions and two embedding calls, and a vector never reaches an instance other than the one that made it. In `knowledge-turso` and `knowledge-pgvector` the embedder and the query prefix belong to the adapter instance and no source changes either, so both can implement it.