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 49cc9210340..89ad164ee90 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 @@ -21,6 +21,7 @@ - **Amended** (2026-11-28, [#38368](https://github.com/objectstack-ai/objectstack/issues/38368)): a third dated note under the table of [K8](#k8--the-contract-additions-decided-item-by-item), read with item 12, records that a knowledge service the runtime mounts is enabled by configuration: a boot enables it when it finds an embedder and the deployment's store, and until then its sources are held and not served. It is written on the maintainer's words of that day, 「平台没有知识服务时,知识源不应该启用啊。」 and 「私有部署判断的是相关参数有没有配置」, as the filing gate of #38368 records them, and on four points he ruled on 2026-11-29 by choosing the decision card's option 「全按推荐(1A 2A 3A 4A)」 (record [`7248214179`](https://github.com/objectstack-ai/objectstack/issues/38368#issuecomment-7248214179) on #38368). It adds no contract member and no settings key. 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-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. --- @@ -138,6 +139,27 @@ Ruling D1, as two lists. The left one is the knowledge service's work, done once > **Cross-reference (2026-11-30, [#38692](https://github.com/objectstack-ai/objectstack/issues/38692)).** The "Hybrid retrieval" row of the adapter's table above is read with the dated note of 2026-11-30 under "Rules for every member" in [K8](#k8--the-contract-additions-decided-item-by-item), and so is "hybrid retrieval" in the title, in the D1 key-words line and in TL;DR item 1: a knowledge source declares which retrieval legs run and the vector leg's share, and the adapter still decides how candidates are found and how the legs are fused. That note also answers two sentences of "◆ Why position" in the note of 2026-11-29 above: "a smaller weight has no unit an author can check", and "a passage only one leg ranks scores at most 0.5", which stops being true of every search. No sentence of K1 or of the note of 2026-11-29 is changed. +> **Note (2026-11-30, [#38760](https://github.com/objectstack-ai/objectstack/issues/38760)) — the "Rerank" row of the adapter's table above, and the second sentence of the list: 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 maintainer's words of 2026-11-30, verbatim and untranslated, as the body of [#38750](https://github.com/objectstack-ai/objectstack/issues/38750), the epic for knowledge retrieval rerank, records them. At 10:13Z: 「有就用」, in answer to the question that body gives as 「是否重排以及模型为什么不是知识源上的开关?」. At 10:37Z: 「所以还是应该按照主流系统的做法,开了开关,一律重排」. In English, the question is why whether to rerank, and the model, are not switches on the knowledge source. The first answer: if there is one, use it. The second: so it should still be done as mainstream systems do it, and with the switch on a search is always reranked. That body states what the two decide under "Rulings", items 1 to 3, and the bullets below quote them. At 10:47Z he answered the six decisions of #38750 with 「全部同意」, all agreed (ruling record [`7276086125`](https://github.com/objectstack-ai/objectstack/issues/38750#issuecomment-7276086125) on #38750). That card numbers its six D1 to D6. Below they are written #38750 D1 to #38750 D6, and none of them is ruling D1, D2 or D5 of this record. #38750 D1, in the ruling record: "The knowledge service reranks, after the permission re-check. Accepting row 1's ADR-0161 note records it; no separate decision card." Row 1 of #38750 is this note. At 11:02:50Z, asked what becomes of #38750, he chose 「照常做,作为平台能力」, carry on as planned, as a platform capability (record [`7276461244`](https://github.com/objectstack-ai/objectstack/issues/38750#issuecomment-7276461244) on #38750). All of these are later than the rulings that the note of 2026-11-30 under [K8](#k8--the-contract-additions-decided-item-by-item) records, which are of 06:00Z to 07:57Z that day. Where the two differ, the later words are the ones this note records. This note marks no ◆. What it states is in those rulings, or in what that body's design says of the placement #38750 D1 confirms: who reranks, and why there. Where it reads an earlier sentence of this record anew, it quotes the sentence. What the rulings leave open, it leaves to the rows of #38750 by name, under "Not in this note". The wording of the amended sentences is this note's. +> +> - **The "Rerank" row.** The adapter's table gives it "Whether a second model reorders candidates, and which." From this note neither is the adapter's. Whether: a knowledge source declares it. Which: the deployment configures the reranker, and no source names a model. And it is the knowledge service that reranks, after the permission re-check and before the cut to `topK`. The adapter contract does not change: `packages/spec/src/contracts/knowledge-adapter.ts#IKnowledgeAdapter` and `AdapterSearchOptions` in the same file gain nothing. What the row keeps is the adapter's own search, which this record gives it in two places this note does not touch: "how candidates are found" (the "Hybrid retrieval" row) and "Changing the adapter changes how candidates are found and ranked" ([Consequences](#consequences)). The table is left as written. +> - **Why the service, and why after the re-check.** K1's test for the platform's side is "facts only the platform has". Which passages the caller may read is such a fact, and no adapter has it: an adapter "does not check permissions" (the list above). So a rerank that stands after the re-check can only be the service's, and because it stands there, only text the caller may read is handed to the reranker. "Why the line is here" is read with this: its "The four on the right need none of those" no longer holds of rerank, and the reranker itself is still an engine the deployment brings and this repository does not write. The record of #38692 had already said whose a platform-wide rerank would be, in words the note of 2026-11-30 under K8 quotes: 「平台以后如果统一做重排,那是知识服务的配置。」 This note records that case. +> - **The sentence of the list, amended again.** As the note of 2026-11-29 left it, the second sentence of the list reads: "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." From the merge of this note it reads: "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`." The service still chooses no model and computes no score: the deployment's configuration names the reranker, and the reranker judges the passages. +> - **One sentence of the note of 2026-11-29.** It says of its own re-order: "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." 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. What changes is the clause between: rerank no longer "stays the adapter's". And of the rerank the second half is not true: to rerank, the service hands the question and passage text to a model. Nothing of `source.affinity` or `source.expand` changes, and the other sentences of that note are left as written. +> - **The title, the D1 key-words line and TL;DR item 1.** Each says that adapters own rerank. From this note the word is read in those three places as the row is read above: it 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. TL;DR item 1 keeps its "Adapters own four", two of them now read as narrowed: hybrid retrieval by the note of 2026-11-30 under K8, rerank by this one. The three texts are left as written; the D1 line is a quotation of the filing gate's record. +> - **The source key.** The body of #38750, under "Rulings", item 1: "A knowledge source may declare `retrieval.rerank` (boolean). The model is never chosen by the source; it comes from the deployment". The key is `source.retrieval.rerank?`, a third optional key of the `source.retrieval` group that the note of 2026-11-30 under K8 declares; `mode` and `vectorWeight` stand as that note states them. A source that does not declare it is searched as before this note. How a deployment states its reranker is under "Not in this note". +> - **No reranker is configured.** Item 2 of that list: "No reranker configured: the search runs normally, the report marks the source not reranked, and saving/publishing the source shows a notice. Never a refusal, never fewer hits." The mark is the reason `no_reranker` in the report's `notReranked`, the two names the ruling record uses (#38750 D2 and #38750 D4). This is not what the note of 2026-11-30 under K8 does with a `mode` the store cannot run, which is refused at four points: a declared rerank is accepted and its search is answered, on 「有就用」. The declaration is not silent (ADR-0078): each such search says that its source was not reranked, and the author is told when the source is saved or published. +> - **A reranker is configured and the source declares it.** Item 3 of that list: "Switch on + reranker configured ⇒ every search is reranked. No skip by candidate count or score gap. Only 0 or 1 candidate makes no call (nothing to order) and sets no marker. At most 50 passages are sent per search; the number of searches is not capped." That is the maintainer's 「开了开关,一律重排」. +> - **A configured reranker fails or times out (#38750 D2).** The ruling record: "adapter order kept, the source marked `failed` in `notReranked`, one attempt (`maxRetries: 0`), 3 s; a configuration failure (4xx: wrong key or model) logged at `error`. Not a coded refusal." So the search is still answered, and its report says that the rerank failed. The reranker is asked once, with no retry, under a limit of 3 s. +> - **One model and one wire format (#38750 D3).** The ruling record: "One reranker model and one wire format for v1, the one the first deployment can reach; no vendor preset list." Which model that is, and the one development tests use, are in ruling records `7276135635` and `7276183954` on #38750. This record names neither. +> - **A hosted deployment (#38750 D4).** The ruling record: "Hosted reranking after row 6 shows a gain (or a hosted customer asks). Until then a hosted source that declares rerank is searched normally and marked `no_reranker`." Row 6 of #38750 measures rerank on against rerank off. #38750 D5, the hosted recipient and its charging, is not decided. #38750 D6 is a rule for one application and is not this record's. +> - **What the reranker is sent.** To rerank, the service hands a model the question and at most 50 passages per search, each one a passage that passed the permission re-check for this caller. A deployment that configures no reranker sends nothing. Configuring one is the deployment's decision to send that text to it, as configuring an embedder is (K5, and the note of 2026-11-28 under K8). +> - **Rule 4 of K8, amended again.** As the note of 2026-11-30 under K8 left it, rule 4 reads: "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." From the merge of this note it reads: "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." The rule's headline is unchanged: the contract carries what an adapter reports, never how it is configured, and it still carries no rerank. An adapter's plugin options stay its own ("What counts as a member"); this note takes none from it and gives it none. +> - **Three sentences of the note of 2026-11-30 under K8.** Under "Rule 4, amended" it quotes the record of #38692: 「K8 第 4 条:「hybrid weights」改划给知识源声明;rerank toggles、parser options 照旧留在驱动。」 It quotes that record's section 六 there too, 「永远不进知识源协议」: 「融合算法及其常数、重排、分数阈值、分词器。平台以后如果统一做重排,那是知识服务的配置。」 And under "Not in this note" it says: "Rerank, a score threshold, a tokenizer and the fusion algorithm with its constant never enter the source (section 六, above)." From this note the three are read so. 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 last sentence of section 六 stands for the reranker itself: which one a deployment uses is configuration the knowledge service reads, and no source's. That note states the record of #38692 as it was ruled and is left as written. +> - **Three rows of K2.** Each names rerank in its "What it becomes" column. The opening of `content/docs/protocol/knowledge.mdx`: "Engines are integrated for embedding, hybrid retrieval, rerank and file parsing." It stays true as a sentence, because a reranker is an engine the deployment brings. What it no longer means is that an adapter integrates it: the knowledge service calls it. The §3.4 row keeps its "no rerank": the adapter contract carries none, before this note and after it. The class note of `KnowledgeService`: "Embedding calls, vector storage, hybrid retrieval and rerank stay the adapter's." From this note the first three stay the adapter's, and reranking the hits of a source that declares it is the service's. This note rewrites none of those texts: each is rewritten by the PR whose code makes the new sentence true (K2). The table is left as written. +> - **Not in this note.** #38750 D5. How a deployment states its reranker, and what the knowledge service calls it through: the contract, the client and the settings are rows 2 and 3 of #38750, each landing with its reader. By "What counts as a member" none of them is a member: a member is what an adapter author must read, and no adapter reads these. 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: each belongs to the row that builds it. A per-search argument on the tool (K9 rule 2). +> +> 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. + **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 @@ -161,6 +183,8 @@ The same position is restated in `content/docs/ai/knowledge-rag.mdx` ("Why we di **The rule for all of them (Prime Directive #10).** A text is rewritten in the PR whose code makes the new sentence true, and not before. This record changes no file outside `docs/adr/`. A reader who meets an old sentence in the meantime finds this record through the ADR index. +> **Cross-reference (2026-11-30, [#38760](https://github.com/objectstack-ai/objectstack/issues/38760)).** Three rows of the table above name rerank in "What it becomes": the opening of `content/docs/protocol/knowledge.mdx`, §3.4 of that file, and the class note of `KnowledgeService`. Each is read with the dated note of 2026-11-30 on #38760 under "What follows from the two lists" in [K1](#k1--the-boundary): a knowledge source may declare that its searches are reranked, the deployment configures the reranker, and the knowledge service reranks. So rerank is no longer among what "stay the adapter's", a reranker is an engine the knowledge service calls and no adapter integrates, and the adapter contract still carries no rerank. The rule above holds for these texts as for every other: each is rewritten by the PR whose code makes the new sentence true, and not before. That note changes no row of the table. + ### K3 — What this record supersedes **1. The three judgements of #4606, and its restart condition.** #4606 (2026-08-02, closed 2026-09-24) recorded the maintainer's positioning in its body: @@ -253,6 +277,8 @@ The package whose README and tests carry the `http` shape, `knowledge-ragflow`, > **Cross-reference (2026-11-29, [#38502](https://github.com/objectstack-ai/objectstack/issues/38502)).** Two source keys are declared by the dated note of 2026-11-29 under "What follows from the two lists" in [K1](#k1--the-boundary): `source.affinity` and `source.expand`, on the object arm. The table above lists the v1 keys as they stood and is left as written. Each of the two lands with its first reader (#38503 for `affinity`; #38504 and #38505 for `expand`), as "A key added later lands with its first reader" asks, and neither is reserved before that. No sentence of K4 is changed. > > **Cross-reference (2026-11-30, [#38692](https://github.com/objectstack-ai/objectstack/issues/38692)).** One group of source keys is declared by the dated note of 2026-11-30 under "Rules for every member" in [K8](#k8--the-contract-additions-decided-item-by-item): `source.retrieval`, with `mode` and `vectorWeight`, beside `source.affinity`. The table above lists the v1 keys as they stood and is left as written. Each key lands with its first reader, as "A key added later lands with its first reader" asks: `mode` in phase 1a of ruling record `7270218011` on #38692, and `vectorWeight` in its phase 1b, after #38671. One text above is read with that note. The reason given for "`adapter` becomes optional" is that "one source written as metadata must build on `os dev`, on a hosted environment and on PostgreSQL". The note records one intended exception: a source that explicitly declares a retrieval mode its store does not support is refused, at the four points the note lists, and its index is still built. A source that omits `mode` is not in the exception. No sentence of K4 is changed. +> +> **Cross-reference (2026-11-30, [#38760](https://github.com/objectstack-ai/objectstack/issues/38760)).** One more source key is declared, by the dated note of 2026-11-30 on #38760 under "What follows from the two lists" in [K1](#k1--the-boundary): `source.retrieval.rerank`, a boolean, in the group the cross-reference above names. The table above lists the v1 keys as they stood and is left as written. The key lands with its first reader, as "A key added later lands with its first reader" asks: row 2 of #38750. It is not reserved before that. One text above is read with that note. "The v1 keys are the keys something enforces": the knowledge service reads this key, and what follows depends on the deployment. Where a reranker is configured, every search of the source is reranked. Where none is, the source is searched normally and is not refused, each such search is marked, and saving or publishing the source shows a notice. That is the opposite of the exception the cross-reference above records for a `mode` the store does not support, and it is the maintainer's ruling: 「有就用」. No sentence of K4 is changed. ### K5 — A source lists its content fields; embedding is egress @@ -439,6 +465,8 @@ Rules for every member: > > This note registers exactly two members, `AdapterCapabilities.retrieval` and `AdapterSearchOptions.retrieval`, and no other: the list stays closed beyond them (rules 3 and 5). It declares, and the phases above build it; the PR that lands it changes no file under `packages/`. Until phase 1a lands, `main` has no `source.retrieval` key, `AdapterCapabilities` holds `chunks` alone, and `knowledge-turso` and `knowledge-pgvector` answer every search by the equal-weight fusion of two legs. The code this note cites was read on `main` at `5a77a7063e`. The title, the tables of K1 and K8, the rules above and every earlier note are left as written; read rule 4 and the "Hybrid retrieval" row with this note. +> **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. + ### 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`).