Repository navigation
Description
Ruled: 7270218011 · letter A(变体) · 2026-11-30T06:16Z
已裁定。第 1、2、7、8 节的写法以裁决评论为准:用
vectorWeight(向量占比)代替keywordWeight;比例排在 #38671 之后;单次覆盖推到第二期且只开放mode;先合 ADR-0161 修订说明。
知识源需要一组「检索方式」声明:可选「只用向量」「只用关键词」「混合」,选「混合」时还能设关键词和向量两路的比例。由应用写在知识源定义里,随应用部署生效。目前 knowledge-turso 和 knowledge-pgvector 上的知识源只有一种检索方式,即两路等权混合;在中文口语问题上它比只用向量更不准、更慢,应用没法绕开。
比例的加权算法建议在现有的按名次合并上加权,不改成 Dify、RAGFlow 那种按分数加权。理由见「混合的比例」一节。
说明:「向量一路」指按语义相似度找段落,「关键词一路」指按字面匹配找段落。两路的结果现在用 RRF(倒数名次融合)合并:一个段落在每一路里排第几名,就得 1 / (60 + 名次) 分,两路相加,再除以两路都排第一时的得分,所以最终分在 0 到 1 之间。
为什么需要
在 BrightRule 的制度条款知识源上实测。知识源共 59,621 段,嵌入模型为 qwen3.7-text-embedding(1024 维),存储为 knowledge-turso。题目是 132 道真实员工问题,其中 118 道有标准制度、70 道有标准条款。员工账号经 MCP(外部 AI 客户端调平台工具的接口)调 search_knowledge,带提问人所属单位的检索范围和 groupBy: "clause_hash"(相同条文只取一条),每次取前 8 条(topK 8):
| 指标 | 混合(现状) | 只用向量¹ |
|---|---|---|
| 第一条属于正确制度 | 76.3% | 78.8% |
| 前 3 条有正确条款 | 72.9% | 88.6% |
| 前 8 条有正确条款 | 91.4% | 94.3% |
| 一次检索耗时(中位) | 562 ms | 396 ms |
¹ 「只用向量」是在本地框架里临时改代码跳过关键词一路测的,不是平台已有的功能。
- 只用向量时,平台返回的结果和离线按余弦相似度排序的结果一致。换用 bge-m3 嵌入模型的索引再测一遍,只用向量时平台结果同样和离线排序完全一致,「前 3 条有正确条款」为 90.0%。
- 混合变差的原因见 知识库混合检索在中文口语问题上比只用向量更差:关键词一路的滑动窗口切词 + 等权 RRF #38671:中文问句被切成滑动窗口片段,再和向量一路等权合并。变慢的原因见 knowledge-turso 检索慢:关键词一路随向量重试重复执行、窄范围下近似检索反而比精确扫描慢、补查轮重复生成问题向量 #38676:关键词一路随向量一路的每次重试重复执行。这两个问题修好以前,以及修好以后对某些知识源仍不合适时,应用需要能选择只用向量。
同类平台都允许选检索方式:
- Dify(官方文档「Setting indexing methods」;源码
api/core/rag/rerank/weight_rerank.py、api/core/rag/datasource/retrieval_service.py):知识库检索方式可选「Vector Search」「Full-Text Search」「Hybrid Search」。 - RAGFlow(源码
internal/service/nlp/retrieval.go,main 92ce638a0a):有VectorOnly开关,只跑向量一路。
为什么放在知识源定义上
不放在适配器的插件选项里,原因有两个:
- 哪种检索方式合适,取决于这个知识源的语料和提问语言。同一部署里的不同知识源可能需要不同的方式。
- 插件选项属于部署,应用包带不走;托管环境里应用也改不了插件选项。
需要先说明一点:spec 19 删掉了 adapterConfig,理由是「没有适配器读每个知识源各自的配置,适配器的设置走挂载它的插件选项」(knowledge-source.zod.ts 里 adapterConfig 的删除说明)。本单提的不是把那个不定形的配置包加回来,而是一个有固定取值、每个适配器都要读或明确拒绝的声明字段,性质上和 source.documentBy 一样,是知识源自己的检索语义。
要做什么
1. spec 加字段
建议在 source 里加一个 retrieval 分组,和 #38606 刚加的 source.affinity(按提问人调整命中先后)放在一起:两者都是这个知识源「检索时怎么排」的声明。检索方式和比例放在同一个分组里。以下写法是建议,字段名、取值拼写和放在哪一层由平台定:
// ObjectKnowledgeSourceSchema 里,与 affinity 并列
retrieval: strictObject({
// 省略:用适配器自己的默认方式,即现在的行为
mode: z.enum(['hybrid', 'vector', 'keyword']).optional(),
// 仅 mode 为混合(或省略且适配器默认混合)时可写;0 到 1,不含两端;省略按 0.5
keywordWeight: z.number().gt(0).lt(1).optional(),
}).optional()和 affinity 的关系:affinity 在知识服务里对已经合并好的命中调整先后,不改分数。retrieval.mode 决定适配器跑哪几路、怎么出分。两者先后作用,互不冲突。
vector(只用向量):只跑向量一路。keyword(只用关键词):只跑关键词一路。问题里抽不出关键词时返回空结果。是否仍生成问题向量、用于关键词同分时按向量距离排先后(现在的同分规则),由平台决定。hybrid(混合):两路都跑,按 RRF 合并,即 knowledge-turso 和 knowledge-pgvector 现在的行为。
省略时不写默认值,含义是「用适配器的默认方式」:knowledge-turso 和 knowledge-pgvector 是混合,knowledge-memory 是只用向量。不建议在 spec 里把默认值写成 hybrid,因为 knowledge-memory 从来只有向量一路,写死默认值会让已有的 memory 知识源变成「声明了一种它做不到的方式」。这样所有已有知识源的行为都不变。
2. 适配器声明自己支持哪些方式,不支持的在保存或注册时拒绝
建议在适配器的能力声明(AdapterCapabilities,现在只有 chunks 一项)里加一项,列出它支持的检索方式:knowledge-turso 和 knowledge-pgvector 三种都支持,knowledge-memory 只支持 vector。没有声明这一项的第三方适配器,只接受省略。
知识源明确写了它所用适配器不支持的方式时拒绝,并在提示里写出该适配器支持哪些方式:
- 经 Studio 或 MCP 保存的知识源,在保存时拒绝(和现在「部署里没挂这个存储就在保存时拒绝」同一处)。
- 写在代码里注册、或随软件包安装的知识源不经过保存,在注册时拒绝(现有先例:没写适配器又无法确定用哪个的知识源,已经是在注册时拒绝)。
不采用「不支持就悄悄按只用向量处理」,因为那样应用声明的方式和实际执行的方式不一致,排查时看不出来。
3. knowledge-turso 和 knowledge-pgvector 按字段决定跑哪几路
知识源定义已经随每次检索传给适配器(AdapterSearchOptions.source),适配器直接读这个字段即可。按次覆盖见第 8 点。
分数规则建议统一成一条:最终分 = 参与的各路 1 / (60 + 名次) 之和,除以「参与的各路都排第一」时的得分。
- 混合时参与的是两路,结果和现在的分数、排序逐位相同。
- 只用向量或只用关键词时参与的只有一路,第 1 名得 1 分,第 n 名得
61 / (60 + n)分。
单路方式下的排序就是那一路自己的排序。只用向量时,向量一路现有的规则不变(余弦相似度不大于 0 的段落不返回,近似索引的重试和回退照旧)。
4. 不重建索引
切换检索方式只影响检索。两路读的是同一批段落,向量随段落入库,关键词索引在建表时建立,或在第一次用到关键词的检索时补建。新字段不计入索引指纹和 recipe hash(决定「要不要重建索引」的两个哈希),和 source.documentBy 的处理一样;这两个哈希只读嵌入模型、切分方式和 source 分组里的几个键,所以新字段不需要特别处理。「只用向量」的知识源是否还维护关键词索引,由平台决定。
5. Studio 表单
知识源表单加上「检索方式」下拉,带「默认」一项(对应省略);选「混合」时显示「关键词比例」输入(0 到 1,不含两端,留空按 0.5)。能否保存仍按现有的知识源编辑规则(例如只读软件包里的知识源不能在页面上改)。
6. 不改变「部署必须配嵌入模型」
三种检索方式下,索引都照常带向量建立,「只用关键词」只是检索时不用向量一路的排名。没配嵌入模型的部署能否只做关键词检索,不在这一单里。
7. 混合的比例(retrieval.keywordWeight)
为什么要能调:在同一知识源上按下面的名次加权公式离线重算,两路等权时「前 3 条有正确条款」71.4%²,关键词权重约 0.33 时 77.1%,只用向量 88.6%。比例对结果影响明显,不同知识源、不同语言合适的比例也不同,应该由应用按知识源声明。#38671 修好关键词一路的切词后,合适的比例还会变,所以写在元数据里、随应用调整比写死在平台里合适。
算法建议在现有 RRF 上加权:retrieval.keywordWeight 取值在 0 和 1 之间(不含两端),向量一路的权重为 1 减去它。只在混合时可写,其他方式下写了就在保存或注册时拒绝。最终分 = (向量权重 / (60 + 向量名次) + 关键词权重 / (60 + 关键词名次)),除以两路都排第一时的得分 1 / 61。省略时按 0.5 算,分数和排序与现在逐位相同(两个权重都是 0.5 时,分子分母同时减半,浮点结果不变)。要完全关掉一路用检索方式,不用把权重设成 0 或 1,所以两端不允许。
不采用 Dify、RAGFlow 那种按分数加权(最终分 = 关键词权重 × 关键词分 + 向量权重 × 向量余弦相似度)。两家的做法如下:
- Dify(
api/core/rag/rerank/weight_rerank.py):混合时两路各取 top_k、去重后重新打分,score = vector_weight × 向量余弦相似度 + keyword_weight × 关键词分。关键词分是用 jieba 抽词、在这批候选段落上算 TF-IDF 后的余弦相似度。没有另做归一化。也可以不用权重,改用重排模型。 - RAGFlow(
internal/service/nlp/retrieval.go、reranker.go,main 92ce638a0a):参数vector_similarity_weight默认 0.3,关键词权重为 1 减去它。最终分sim = 关键词权重 × tsim + 向量权重 × vsim:vsim 是向量余弦相似度;tsim 是问题的加权词(单词权重 × 0.4,相邻两词组合 × 0.6)在段落里命中的权重占问题总权重的比例,在 0 到 1 之间。
不照搬的理由:
- 默认行为做不到不变。 按分数加权等于换掉现在的合并算法,不写权重的知识源排序也会变,所有已上线的知识源都受影响。
- 平台现在没有可用的关键词分。 两个适配器的关键词分是命中词的 BM25 IDF 之和,没有上限,只用来在关键词一路内部排名次。要按分数加权,得先在两个适配器里各定义一个 0 到 1 的关键词分,并为候选段落补算另一路的分数(只被向量一路排到的段落要补关键词分,反之亦然)。这是一个新的打分模型,不是加一个参数。
- 分数会随取多少条而变。 知识服务在带
groupBy或权限过滤时会分两轮向适配器要结果(先要 topK × 5 条,不够再要 topK × 20 条),并把各知识源的结果按分数放在一起排序。按名次算的分数,同一段落在两轮里得分相同;像 Dify 那样在候选集上算的关键词分,候选集一变分数就变。 - 两个分数的分布不一样,权重不好解释。 余弦相似度的取值范围随嵌入模型而变,关键词分是另一种分布,同一个权重换了嵌入模型含义就变了。名次加权没有这个问题。
按分数加权不是永远不做:平台将来若加重排这一步(对候选段落统一重新打分),那时再评估更合适。
² 离线重算是在本地按 turso 适配器的 SQL 和合并逻辑复现的结果,等权时比平台实测的 72.9% 少一题。差异可能来自同文条款的合并处理没有完全复现(平台在 groupBy 下首轮向适配器要 topK × 5 = 40 条,适配器每一路各取 40 条,离线也按 40 条取)。这一题的差异不影响结论。
8. 单次检索可以覆盖
search_knowledge 工具和 IKnowledgeService.search 加一个可选参数 retrieval: { mode?, keywordWeight? },取值规则和知识源上的一样。生效顺序:单次检索的参数 > 知识源的声明 > 适配器的默认方式。用途:同一个知识源,大多数问题按语义找,但模型有时要按原文、编号、专有名词精确找(例如「第十二条」某个发文字号),这时临时用「只用关键词」或调高关键词比例更合适。
- 一次检索查多个知识源时,单次参数对每个知识源都生效。某个知识源的适配器不支持这个方式时,这个知识源按「拒绝检索」报告(和现在适配器不可用时一样列在结果的 refused 里),其他知识源照常返回。
- 工具说明里写清楚各方式适合什么问题,模型才知道什么时候该改。
范围说明
- 这一单包括:知识源上的检索方式和混合比例声明、三个适配器的支持与拒绝、Studio 表单、单次检索覆盖。重排模型、托管环境是否开放给客户在页面上修改,不在这一单里。
- 一次检索同时查多个知识源时,知识服务把各知识源的结果按分数放在一起排序。检索方式不同的知识源,分数不可直接比较:混合下只被一路排到的段落最高 0.5 分,单路方式下第 1 名是 1 分。这个问题现在就存在(knowledge-memory 返回的是余弦相似度,另两个适配器返回的是名次分),本单不解决,只请在文档里写明。
- spec 的知识源定义不接受未声明的键,所以应用一旦写了这个字段,就必须跑在带这个字段的 spec 版本上。新字段是可选的纯新增,不影响已有定义。本地检出的 spec 版本是 19.0.0-next.2,希望能进 19 的下一个发布版本。
完成后
BrightRule 会把制度条款知识源设为「只用向量」,随应用发布,自托管和托管环境都生效,替换掉目前本地的临时改动。
相关:#38671(混合检索准确率)、#38676(检索耗时)、#38675(托管环境检索超时)
Generated by Claude Code
Activity
objectstack-fleet commentedon Nov 30, 2026
triage@os-warren · os-warren · session_01JQwxbZzZ2f5mzcvJbRrRNZ
Triage: route ·
needs-user-decision· area:ai · domain:spec · Feature · p2 · size M (spec field, three adapters, the Studio form, a per-search override).Grade: area:ai · Feature (a new declared retrieval mode and keyword weight on a knowledge source, plus an override on
search_knowledge) · p2, not p1, since a Feature enters p1 only when it blocks a p1 · evidence measured by the filer (132 real questions on a 59,621-clause source: vector-only top-3 88.6% against hybrid 72.9%, and 396 ms against 562 ms median).Rationale: it adds an authorable key to the published knowledge-source schema and a parameter to a tool contract, and it is not a child of a topic the maintainer opened, so it is a non-pre-authorised feature with a contract change, which is on the human floor. It sits next to the open knowledge cards #38671 (hybrid accuracy), #38676 (latency) and #38675 (hosted timeout, p1); whether the bugs are fixed first or the mode is offered as an escape is part of the choice. The decision analysis (速读 and four axes) is owed by a decision thread, per
decision-analysis.md.os-warren commentedon Nov 30, 2026
decision@os-warren · os-warren · session_01JQwxbaXfHXvoJs5bQn4iat
维护者速读
Served-tier: CONTRACT_REVIEW_TIER
Analysed-by: decision-thread isolated analyst sub-agent
Decision analysis · 2026-11-30 · #38692, whether a knowledge source may declare which retrieval legs run for it. Read on
origin/mainat5ac1ee0bc8. ⛔ Not a claim and not a ruling: the maintainer rules.Background
Card #38692 (Feature, p2, area:ai, domain:spec,
needs-user-decision), filed by os-bob for the BrightRule app, asks for four things in one card: (1) an authorablesource.retrieval.mode(hybrid|vector|keyword) onknowledge_source; (2)source.retrieval.keywordWeight, a number in (0,1) that weights the two legs of the rank fusion; (3) a member on the adapter capability report listing the modes a store can run, with a refusal at save or registration when a source asks for one it cannot; (4) a per-searchretrievaloverride on thesearch_knowledgetool and onIKnowledgeService.search. Plus the Studio form.The evidence is the filer's own measurement on one source (59,621 clause passages, 132 real employee questions, 70 of them with a labelled clause): top-3 clause hit 72.9% hybrid against 88.6% vector-only, median 562 ms against 396 ms. Vector-only was measured with a local patch of the store that skips the keyword leg. Triage (comment 7269349608) kept it on the human floor: a new authorable key and a tool-contract parameter outside any topic the maintainer opened.
Three Bug cards sit on the same search path, all open as read: #38675 (p1; hosted scoped search times out on remote Turso; draft PR #38693, +261/−29, up since 05:07Z), #38676 (p2; the keyword leg is recomputed on every vector retry and the question is embedded twice; claimed 05:13Z, to be stacked on #38693), #38671 (p2,
pm:queue; unspaced Chinese questions are cut into sliding 2- and 3-character pieces and merged at equal weight). Claim 7268984126 on #38675 puts all three on one card thread, in that order, because they edit the same files. Claim 7269464921 on #38676 notes that a release freeze is holding #38693 from landing, so the fixes are being stacked.The measured gap is one day old. Until PR #38469 merged (2026-11-29T05:28Z, +276/−21) an unspaced Chinese question was one keyword term that matched nothing, so hybrid search on Chinese was in effect vector-only; that PR's own summary says so (「解决混合检索在中文问题上实际只剩向量一路的问题」). It measured the keyword leg alone (top-5 hit 0.028 → 0.495) and not the fused answer, and it said the worst case was a worse keyword ranking with the vector leg answering as before. With equal-weight fusion that is not what happens: a noisy keyword leg demotes the vector leg's best passage. #38671 is the card for that.
Governing text
keywordWeightis the "hybrid weights" this sentence names. A list of supported modes on the capability report is a report and fits the rule.AdapterCapabilitiesis such a member.adapterConfigrow: its one reader "read four keys of it (datasetId,rerankModel,similarityThreshold,vectorSimilarityWeight)". The spec tombstone: "An adapter takes its settings as options of the plugin that mounts it." A per-source hybrid weight existed on this type and was retired four days ago (PR fix(settings)!: retire @objectstack/knowledge-ragflow and the Knowledge page's RAGFlow adapter option #37477, merged 2026-11-26).IKnowledgeService.search".content/docs/protocol/knowledge.mdx§7.1: "Reranker hooks, hybrid retrieval toggles, MMR — adapter-private."git grep -n -iE 'retrieval|hybrid|keyword|adapterConfig' origin/main -- AGENTS.mdprints nothing.Bug选项」. This is why "let the source choose vector-only", which 知识库混合检索在中文口语问题上比只用向量更差:关键词一路的滑动窗口切词 + 等权 RRF #38671 lists as one possible fix, is this separate card and not part of that Bug.retrievalblock — rank hits by the asker's relation to a declared field, by recency, and expand a hit along declared structure #38412); 2026-11-27, 「但是我们作为元数据开发平台,不能只考虑制度库」 and 「云端不应该让客户配置向量模型」 (comments 7220000671 and 7218695999 on 专题:知识检索平台化(应用写一份知识源配置就有可用的检索:开源、托管、企业版都能用) #37000). His ruling on [Decision] knowledge_source: a declarativeretrievalblock — rank hits by the asker's relation to a declared field, by recency, and expand a hit along declared structure #38412 (record 7251603512) chose 「A 精简:排序加带出」, whose line reads 「不做硬筛选,按时间衰减等有应用要再加」: the part with a consumer was built, the parts without one were left to return with a consumer.Read together: as written, the governing text answers this card with "a plugin option of the store" or "nothing". Options A and B below are requests to amend ADR-0161 by a dated note, the way #38412 did (note PR #38511). No ruling yet says whether a source may declare its retrieval legs.
Greps run:
git grep -n -E 'hybrid weights|The list is closed|\*\*Hybrid retrieval\*\*' origin/main -- 'docs/adr/0161-*.md'(lines 102, 412, 413);git grep -n 'hybrid retrieval toggles' origin/main -- content/docs/protocol/knowledge.mdx(line 1499);git grep -n -iE 'adapterConfig|affinity|documentBy' origin/main -- packages/spec/src/ai/knowledge-source.zod.ts.Protocol statement
knowledge_source.source(Clause-②: yes (widening),Metadata-protocol: added) and one member on the adapter capability report, after a dated note on ADR-0161 that amends by name K1's "Hybrid retrieval" row and K8 rule 4 (Tier H; the maintainer merges it). A also adds an argument to the onesearch_knowledgedefinition and an option toIKnowledgeService.search, and has to strike "hybrid weights" from rule 4.Premises, each with its re-check
git grep -n -E 'const vectorLeg|const terms = keywordTerms' origin/main -- packages/plugins/knowledge-turso/src/turso-adapter.ts packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts(two lines each);git grep -n -E '^ [a-zA-Z]+\?:' origin/main -- packages/plugins/knowledge-turso/src/plugin.ts packages/plugins/knowledge-pgvector/src/plugin.tslists no retrieval option (queryPrefix,vectorIndexThreshold,vectorIndexOverfetchare the nearest).git grep -n -E 'RRF_K = 60|const best = 2 / \(RRF_K \+ 1\)' origin/main -- packages/plugins/knowledge-turso/src/turso-adapter.ts packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts.git grep -n -A2 'export interface AdapterSearchOptions' origin/main -- packages/spec/src/contracts/knowledge-adapter.ts(source: KnowledgeSource).git grep -n -A9 'export interface AdapterCapabilities' origin/main -- packages/spec/src/contracts/knowledge-adapter.ts(chunks?: boolean).git grep -n -E 'sparse token-frequency|embedTokens\(tokenize\(query\)\)' origin/main -- packages/plugins/knowledge-memory/src/index.ts. The card calls it "vector only"; see the notes below.search_knowledgetakes six arguments and refuses any other.git grep -n 'const INPUT_KEYS' origin/main -- packages/services/service-knowledge/src/knowledge-tools.ts.git grep -n -E 'b\.score - a\.score' origin/main -- packages/services/service-knowledge/src/knowledge-service.ts(lines 2599, 2778).git grep -n 'MAX_KEYWORD_TERMS =' origin/main -- packages/plugins/knowledge-turso/src/sql.ts;gh api repos/objectstack-ai/objectstack/pulls/38469 --jq '.merged_at,.title'.for n in 38675 38676 38671; do gh api repos/objectstack-ai/objectstack/issues/$n --jq '[.number,.state,([.labels[].name]|join(","))]|@tsv'; done;gh api repos/objectstack-ai/objectstack/pulls/38693 --jq '.state,.draft'; the serial order is in claim 7268984126 on knowledge-turso:远程 Turso 上带检索范围的 search_knowledge 稳定超时(单条 SQL 超过 10 秒),不带范围也要 25 秒 #38675.sed -n 23,34p src/knowledge/policy-clause.knowledge-source.tsin a checkout of objectstack-ai/brightrule (read at0f618c6).Where the card is off or silent:
adapterConfigtombstone and not K1's "Hybrid retrieval" row, K8 rule 4 ("hybrid weights ... stay in the adapter's own plugin options"), rule 5, or docs §7.1. Those are the texts its request amends.keywordWeight, thekeywordvalue and the per-search override have no named writer.vector": its one leg is a token-frequency cosine, a lexical match. Reporting it asvectornames a semantic leg it does not have. The note has to say what that store reports.The concrete problem
An application whose users ask in colloquial Chinese gets a worse and slower ranking from the platform's default search than from one of its two legs alone, and has no supported way to say "this knowledge base is searched by meaning only". The only route today is a private patch of the store, which works on a self-hosted deployment and does not exist on a hosted one. Separately, the default itself is defective for Chinese since yesterday, and that is being fixed as a Bug.
The six items
1. The problem in one line
A knowledge base cannot say how it should be searched, so when the platform's default suits one kind of question badly, every employee asking that kind of question gets the worse answer and the app's owner can do nothing about it.
2. Options, real cost, effort
documentBy#38564 (+784/−41, 36 files) and #38606 (+1,601/−197, 47 files); a one-leg run in the SQL stores: 无先例 (nearest edit of the same functions: #38469, +276/−21, 12 files)A per-search override on its own, without the source key, was considered and is not a row: it is the part of A with no measurement and with the silent failure described under axis ③, and it would leave the knowledge base unable to state its own default.
3. Business meaning
4. Four axes
git grep -c 'retiredKey(' origin/main -- packages/spec/src/ai/knowledge-source.zod.ts).os-decision-facets
① 项目长远合理性 (long-term fit): B puts "how this knowledge is searched" on the knowledge base as a closed list, the model the reference platforms use, and amends ADR-0161 K1 and K8 rule 4 narrowly; A adds a hand-set weight tied to a keyword leg that is about to change and a model-chosen switch; C keeps a private fork of platform code as the special case; D ties search behaviour to the deployment; none slows the SQL stores for the memory store.
② 实际业务拉动 (real pull): one app, one source, measured by the filer (top-3 72.9% → 88.6%, 562 → 396 ms), hit on every policy question; pull is for meaning-only alone; zero pull for weight, keyword-only and per-search; part of the pull is the one-day-old defect #38671.
③ 防 AI 犯错 (AI error surface): B is a closed list refused loudly at save when the store cannot run it; A's weight and per-search switch fail silently in the employee's answer; C adds no surface and leaves today's silent default; D differs silently between environments.
④ 创业阶段不扩散 (no spread): C adds nothing, D one option per store, B one key with two values plus one report member, A three more surfaces with no consumer.
Self-check: 只看①选 B;②③④ 是否翻转:否
Prior rulings read: retrieval,hybrid,keyword,adapterconfig → 3 hits; ADR-0086 D1, ADR-0106 D3, ADR-0161 K8 rule 4 (listed as Decision §30, status line Proposed, in force since PR #37119 merged); thread: none; repo: objectstack-ai/objectstack
Notes on those two lines. Self-check: ② and ④ trim A to B (no weight, no keyword-only value, no per-search switch) and put B's code behind the three Bug cards; ③ fixes the refusal as loud. ④ argues for C, and that moves timing, not the letter. No new gate is proposed. Prior rulings:
node scripts/pm/check-prior-rulings.mjs --card 38692alone exits 3 ("the card yielded no admissible search term", the title is Chinese), so the line above is from--card 38692 --terms retrieval,hybrid,keyword,adapterConfig: docs/adr 3 hits, AGENTS.md 0, the card's thread 0 rulings of 1 comment. ADR-0086 D1 and ADR-0106 D3 match on a word only (authorization, metadata cache) and do not answer this card. A second run with--terms knowledge,rerank,weights,capabilitiesgives 25 candidates with the same ADR-0161 rule on top. Also read by hand: ADR-0161 K1 with its note of 2026-11-29, K4, K8 rules 1 to 5, K9; epic #37000 and its thread; #38412 with ruling record 7251603512; PR #38606, #38564, #38511, #38469; the three Bug cards.5. Recommendation
B. A knowledge base declares which retrieval legs run for it, from a closed list of two; the store reports what it can run and a mismatch is refused at save and at registration. It is the end-state shape, it is the one part of the card with a measured consumer, and it follows the pattern of the maintainer's own ruling on #38412: build the part with a consumer, let the rest return with one.
Not taken:
Effort note: B is one note and about two PRs against C's none. The ① readings are not close (C keeps the special case outside the platform), so the difference does not move the letter. It does set the order: B's code edits the files the #38675 thread holds, and a key lands with its reader in one PR, so every code PR of B queues behind #38675, #38676 and #38671. B therefore gives BrightRule no relief earlier than the Bug fix does. Its value is the declared shape, not speed.
Confidence gaps (none of them changes the letter):
source.affinity) #38606, where the form was a small part of the diff.6. After the ruling
hybridandvector; omitted means the store's own behaviour, with no default in the spec, so every existing source is answered as today; an unsupported mode is refused at save and at registration and is never run as another mode; the key enters neither the index fingerprint nor the recipe hash; no weight, nokeywordvalue, no argument onsearch_knowledge, no option onIKnowledgeService.search, each to return by a dated note with its first consumer.retrievalwrapper is the level the 2026-11-29 note declined to keep, so a flat key besideaffinityis the likely answer); what the memory store reports; and how a one-leg source's scores stand beside a two-leg source's in a search over several sources.Blocked-by:the note and 知识库混合检索在中文口语问题上比只用向量更差:关键词一路的滑动窗口切词 + 等权 RRF #38671: the key, the report member, both SQL stores and the memory store reading it, the two refusals, a case in the adapter contract suite, the Studio form and its docs, in the shape of feat(knowledge): a knowledge source orders its hits for the person asking (source.affinity) #38606. Premise first, before any code: the 132 questions are re-run on the post-知识库混合检索在中文口语问题上比只用向量更差:关键词一路的滑动窗口切词 + 等权 RRF #38671 build, hybrid against meaning-only (with the filer's scripts), at least three runs each, and both sets of numbers go on the card. If hybrid is then within the run-to-run range of meaning-only on accuracy and on latency, that result goes back to the maintainer and nothing is built; the thread does not build on a premise that failed and does not fall back to another option on its own. Acceptance after the build repeats the two arms through the declared key.keywordvalue and the per-search override in the note. The note then strikes "hybrid weights" from rule 4, adds an argument to the one tool definition (K9 rule 2), and the cloud in-app agent's copy of the definition follows on a cloud card. About two more code cards.Blocked-by: #38671. The seat asks the filer to re-run the 132 questions when 知识库混合检索在中文口语问题上比只用向量更差:关键词一路的滑动窗口切词 + 等权 RRF #38671 lands and to file a new card if a gap remains. BrightRule keeping patched platform code meanwhile is a transition only the maintainer can allow, and it should be said in the ruling.Related cards and PRs
retrievalblock — rank hits by the asker's relation to a declared field, by recency, and expand a hit along declared structure #38412 and ruling record 7251603512; note PR docs(adr): ADR-0161 dated note, a knowledge source declares how its hits are ordered for the caller and what a hit brings #38511 (+25/−0);source.affinityPR feat(knowledge): a knowledge source orders its hits for the person asking (source.affinity) #38606 (+1,601/−197);source.documentByPR feat(knowledge): a knowledge source declares its document unit (source.documentBy); record search groups by it by default #38564 (+784/−41): the precedent for "ruling, dated note, key with its reader".search_knowledge.Generated by Claude Code
os-bob commentedon Nov 30, 2026
Ruling: 知识源可声明检索方式与向量占比,单次覆盖推后 · letter A(变体,见下) · maintainer 「同意,更新决策卡」 2026-11-30T06:00Z;复核修正 「全部采纳,修正裁决」 2026-11-30T06:16Z
维护者裁定(2026-11-30,复核后修订版)
本评论取代原单正文第 1、2、7、8 节的写法。初版发出后,经独立复核(Fable)修正了 5 处,维护者于 06:16Z 选择「全部采纳」。和卡上分析的选项相比,这是 A 的变体:比例的方向改为向量占比;单次覆盖推到第二期,且只开放
mode。维护者速读
一、知识源元数据
vectorWeight的含义是抽象的:混合时向量一路的相对分量。0.5 等于驱动的等权行为;调高不会让向量一路的命中名次变差。具体公式属于驱动的现行实现,不属于字段含义(见第五节)。alpha、RAGFlowvector_similarity_weight一致(向量占比)。不用原单的keywordWeight。mode、或mode为vector/keyword时写了vectorWeight。retrieval: {}允许,等同省略。mode,所以权重不能取 0 或 1。source.affinity并列、先后作用。不计入索引指纹和 recipe hash,切换方式不用重建索引。各方式的语义
vector:只跑向量一路。hybrid:两路都跑,按驱动的融合算法合并。keyword:只跑关键词一路,不调用嵌入器、不生成问题向量;同分按段落 id 排,结果确定;问题里抽不出词就返回空。它适合文号、条款编号这类精确查找。想要「关键词为主、向量定先后」,应写hybrid加低的向量占比。二、驱动契约(报告,不是配置)
hybrid就必须支持vectorWeight,不单独声明。hybrid。mode。检索报告和 Studio 显示「驱动未声明」。AdapterSearchOptions.retrieval: { mode, vectorWeight? },由服务解析后交给驱动。这是逐次请求参数(同topK、scope),不是配置。三、拒绝的四个落点
400 VALIDATION_ERROR,列出驱动支持的方式。start()才注册,按 AGENTS.md 的启动期注册表规则,不在init()下结论)。软件包安装不经过保存门,靠第 3、4 条兜住。reportUnmountedAdapters):记 error 日志,点名知识源和驱动支持的方式。refused(带错误码),不悄悄按默认方式跑。方式不被支持的知识源照常建索引,只拒绝检索。
四、生效顺序与可见性
mode及其来源写进 debug 日志和 Studio 的知识源状态,不进模型可见的工具答案。search_knowledge的工具说明加一句:「分数只表示同一知识源内的先后,不表示相关程度」。单路方式下第一名总是满分。五、驱动的现行实现(turso、pgvector;写进驱动文档和 ADR 修订说明)
(w/(60+v) + (1−w)/(60+k)) / (w/61 + (1−w)/61)。保留「除以最佳分」的写法。改写成「乘以 61」会有大量末位差异(全组合实测 13,369 / 40,400 处)。w = 0.5与现在的fuse()逐位相等。同分规则(先比向量名次,再比段落 id)不动。fuse(),mode改的是 SQL(少拼一路)。61/(60+n)。memory 保持返回余弦相似度不变。契约只要求同一知识源内分数随名次不增。六、永远不进知识源协议
融合算法及其常数、重排、分数阈值、分词器。平台以后如果统一做重排,那是知识服务的配置。
七、默认值与索引
hybrid,不随探测到的档位变化。知识库混合检索在中文口语问题上比只用向量更差:关键词一路的滑动窗口切词 + 等权 RRF #38671 修好后重新实测,再议是否改默认。八、ADR-0161 修订说明(单独 PR,Tier H,由维护者亲手合并)
需要写到的内容:
AdapterCapabilities.retrieval、AdapterSearchOptions.retrieval两个成员的完整形状,以及第 1 条规则要求的契约测试用例。vectorWeight的抽象含义,和现行实现的公式(第五节)。RRF 常数不开放。keyword方式的语义(第一节)。content/docs/protocol/knowledge.mdx§7.1 的修改随代码 PR 走。ui/(Studio 表单)和skills/(AI 作者文档)是受治理路径,各自单独提 PR。分期
mode(三种)、能力声明、四个拒绝落点、Studio 表单、工具说明。vectorWeight。排在 知识库混合检索在中文口语问题上比只用向量更差:关键词一路的滑动窗口切词 + 等权 RRF #38671 修好切词之后,修好后实测,确认权重有可用的区间。search_knowledge单次覆盖,只开放mode。届时还要定两件事:知识源能不能声明「不许覆盖」;覆盖成混合时用哪个权重。cloud 应用内 agent 的工具定义要同步。和其他单的关系
BrightRule 的上线顺序
平台发版 → cloud 托管运行时升级到该版本 → BrightRule 升级
@objectstack/spec,在制度条款知识源上写retrieval: { mode: 'vector' }(不指定 adapter),去掉本地临时改动,重跑 132 题。知识源 schema 是严格对象,顺序反了的话,旧环境安装会被拒。Analysis (for reviewers and agents)
Served-tier: TIER_DEFAULT
Analysed-by: project decision thread (initial analysis and adversarial review by isolated sub-agents; files in the maintainer's project:
决策分析-38692/Fable-检索协议分析.md,Fable-裁决复核.md)vectorWeight(vector share) instead ofkeywordWeight; weight sequenced after 知识库混合检索在中文口语问题上比只用向量更差:关键词一路的滑动窗口切词 + 等权 RRF #38671 (phase 1b); per-call override phase 2,modeonly;fusion/RRF constant/rerank/threshold/tokenizer stay out of the source schema; RRF constant not exposed as plugin option.main: fusion lives infuse()(turso-adapter.ts:1631,pgvector-adapter.ts:1385),best = 2/(RRF_K+1);AdapterCapabilitiesholds onlychunks; adapters register instart()after code-registered sources atinit()(knowledge-service.ts:404-406), hence no init-time verdict; save admission inpackages/metadata-core/src/knowledge-source-save-admission.tsexcludes package installs.w = 0.5holds only with the divide-by-best form (13,369/40,400 last-bit differences when rewritten as multiply-by-61); pin test required.w > 68/129 ≈ 0.53; window varies with topK and the ×5/×20 fetch rounds, so no fixed number is written into the protocol.Ruled:line (added with this revision); the lane seat replaces the state label (suggestedpm:blockedwithBlocked-by:the ADR note PR) onNotify: ruling.Generated by Claude Code
objectstack-fleet commentedon Nov 30, 2026
repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu
2026-11-30T06:22Z · State after the ruling:
needs-user-decision→pm:blocked.The maintainer's ruling is recorded in 7270218011, and the body's 06:16Z revision supersedes body sections 1, 2, 7 and 8. It sets out the phases:
source.retrieval.mode, the adapter capability report, the four refusal points, the Studio form and the tool text.vectorWeight, after 知识库混合检索在中文口语问题上比只用向量更差:关键词一路的滑动窗口切词 + 等权 RRF #38671 and a re-measure.Blocked-by: the maintainer's knowledge pause of 2026-11-30T05:39Z (「暂时不开工新的知识任务」). When he lifts it, phase 0 is claimed first, and this card then waits on that PR (Blocked-by: the phase-0 PR). Phase 1b also waits on #38671, which is back in the queue under the same pause.
objectstack-fleet commentedon Nov 30, 2026
repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu
2026-11-30T06:24Z · Claim · phase 0 and phase 1a of ruling 7270218011, on the maintainer's 「先解决 一期 a」 and 「零期: + 1a」 (2026-11-30T06:23Z). They lift the knowledge pause for this card's phase 0 and 1a only. Phases 1b and 2 stay unstarted.
Claim: PM loop round 1
Session:
session_01JQwxbXyLoBzNYY1U8SNPFuAccount:
os-warrenBranch: new branches, one per PR, named by claim amendments on the threads' first reports. Phase 0 is from
origin/mainat5a77a7063e. Phase 1a PRs stack where the file they change is held: on #38700 (claude/project-thread-e6npb2) forservice-knowledge, and on #38697 (claude/project-thread-slovhl-38676) forknowledge-turso. Everything else is fromorigin/main.Worktree:
objectstack-issue-38692-p0,objectstack-issue-38692-1aDomain:
domain:specSeat:
repo:objectstack#2Area:
o2-A(area:ai)File surface:
docs/adr/0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.mdonly.packages/spec/src/ai/(the knowledge sourceretrieval.modeschema),packages/spec/src/contracts/knowledge-adapter.ts(AdapterCapabilities.retrieval,AdapterSearchOptions.retrieval), and the spec generated baselines and docs.packages/services/service-knowledge/src/**(resolution and the four refusal points).packages/plugins/knowledge-{turso,pgvector}/src/**(mode in SQL, the capability report).ui/packages/(separate PR) and thesearch_knowledgetool text and skill text (separate PR).Container & model:
model: fable(dispatch-gates --tier: "Model tier — MANDATORY: claude-fable-5-2" fordocs/adr/**), effort: xhigh.Clause-②: yes for phase 1a: it widens the published knowledge-source schema and the adapter contract (additive, optional). A CONTRACT_REVIEW_TIER review is owed before the queue. Phase 0: no.
Metadata-protocol: added (phase 1a:
source.retrieval.mode); none (phase 0)Responsibility: n/a (Feature by ruling)
Thread-read: none
Premise: holds at
5a77a7063e.AdapterCapabilitiesis inpackages/spec/src/contracts/knowledge-adapter.ts, and ADR-0161 is atdocs/adr/0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md.knowledge-service.tsis split by refactor(service-knowledge): split KnowledgeService into five concern modules behind a delegating facade #38700 (awaiting approval) andturso-adapter.tsis changed by fix(knowledge-turso): a scoped search reads its passage table once a statement; a request past its bound answers TIMEOUT #38693 and perf(knowledge-turso): compute the keyword leg once a search; send a scope too narrow for the approximate pass straight to the exact scan #38697 (accepted, held by the freeze), so 1a stacks on them.Serial constraints cleared: the ruling orders phase 0 before code. Phase 1a PRs do not land before the phase-0 PR merges (the maintainer merges it).
Pre-claim lane:
packages/spec/**⇒ domain:spec; service-knowledge and the knowledge plugins ⇒ domain:server; area:ai, zone o2-A.Pre-claim deps: refactor(service-knowledge): split KnowledgeService into five concern modules behind a delegating facade #38700, fix(knowledge-turso): a scoped search reads its passage table once a statement; a request past its bound answers TIMEOUT #38693 and perf(knowledge-turso): compute the keyword leg once a search; send a scope too narrow for the approximate pass straight to the exact scan #38697 for the stacked parts.
Prior rulings read: 7270218011 (the body's 06:16Z revision supersedes body sections 1, 2, 7 and 8).
9 remaining items
objectstack-fleet commentedon Nov 30, 2026
repo:objectstack#2 · os-warren · session_01JQwxbaASqBozmmj1n5tbUf
Phase 1a, the pgvector PR is open: #38745 (draft, stacked on #38720), built on
mainafter #38726 (B2) merged as f782a12. It keeps B2'sSET LOCAL statement_timeoutranking statement, its coded refusals (src/errors.ts) and its pool default of 20. Undermode: 'vector'it writes no keyword condition into any statement, pinned inretrieval-modes.test.ts(the same pin is on #38721 for turso). Against live PostgreSQL 16 + pgvector: 17 files, 154 tests passed. Landing order, as agreed: #38720, then #38721, #38722 and #38745, then #38730 and #38732. Read at 2026-11-30T10:01Z.objectstack-fleet commentedon Nov 30, 2026
repo:objectstack#2 · os-warren · session_01JQwxbXyLoBzNYY1U8SNPFu
2026-11-30T17:01Z · Phase 1a landed. This seat releases the card to seat
repo:objectstack#3(os-steve), as a handover, not an abandonment.Phase 1a,
source.retrieval.mode: all six PRs are onmain.AdapterCapabilities.retrieval,AdapterSearchOptions.retrieval, both optional per ruling 7272337479)errorlog, search 503SERVICE_UNAVAILABLEas the maintainer confirmed at 2026-11-30T12:40Z); liveness rowlivesearch_knowledgescore text + AI skill rowRelease. The work held under this seat's takeover of
o2-Aends here. Provenance: who = the maintainer (Warren,os-warren); words, verbatim: 「ai 区也交接给 3号座位了,你不用接新任务。」; where = os-warren's fleet project timeline, 2026-11-30T12:46Z. This seat was told to land only the in-hand 1a PRs, and it has.Card state.
pm:dispatchedis off and the assignee is off.pm:on-holdis on, because phases 1b (vectorWeight, the hybrid ratio) and 2 (the per-search override) are still under the maintainer's knowledge hold (2026-11-30T05:39Z, with phase 0 and 1a released at 2026-11-30T06:23Z).Follow-up for the next owner, not filed: the Studio picker re-sends the
index_statusrequest on each keystroke of the draft'sadapter(#38730 contract record N1).chore(knowledge-pgvector): per-search segment timing and a load bench…
docs(adr): ADR-0161 dated revision note — knowledge source declares r…
fix(knowledge-pgvector): a failed search is a coded refusal, its stat…
feat(spec): a knowledge source declares its retrieval mode; an adapte…
feat(service-knowledge): read a source's retrieval mode and refuse a …
feat(knowledge-turso): run one leg or both, by the source's retrieval…
feat(knowledge-pgvector): run one leg or both by the search's retriev…
docs(adr): ADR revisions, week of 2026-11-29 (seven dated notes acros…
feat(studio): the knowledge source retrieval-mode picker offers the m…
docs(knowledge): search_knowledge says what a score means; the AI ski…