Repository navigation
Description
立卡依据:③ 维护者直接要求(专题父卡)。维护者原话(2026-11-30,项目会话 cloud#5250 线程):
- 10:14Z 「用fable 评估重排的开发方案,平台应该有这个能力」
- 10:13Z 「有就用」(回答「是否重排以及模型为什么不是知识源上的开关?」)
- 10:37Z 「所以还是应该按照主流系统的做法,开了开关,一律重排」
- 10:38Z 「立专题卡,交给3号座位」
分级:area:ai · 专题父卡 · p2(席位暂定,维护者可改)· 影响面:所有声明了知识源的 ObjectOS 应用(私有部署与托管云);首个候选是 BrightRule 制度问询 · 依据:读代码(objectstack main f782a120,#38692 第一期 a 分支 b15ac8df,cloud main 7b41356),Fable 只读评估(2026-11-30),cloud#5250 验收环境实测。
维护者速读
- 做什么:平台提供「重排」能力。向量检索先召回候选,重排模型把问题和每条候选放在一起读,重新排序,再把前 topK 条交给 AI。
- 已裁定:知识源只声明
retrieval.rerank: true;模型永远来自部署配置(私有部署用设置项和环境变量,托管云用平台常量);没配重排模型时检索照常、结果标「未重排」、发布时提示,不拒绝;开了开关、配了模型,就每次都重排,不按候选数量或分数差距跳过(候选 0 或 1 条时无可排,不调用、不标记)。 - 推荐方案 B:由知识服务在权限复核之后统一重排(一处实现,只把用户有权看的原文送出去),三个存储适配器不改。
- 已裁定(10:47Z「全部同意」):D1 知识服务统一重排;D2 失败或超时按原顺序返回、标「重排失败」、配置错误按 error 记日志;D3 只接一个模型、一种格式;D4 托管云等评测有收益再做(D5 暂不定);D6 BrightRule 按逐题输赢、p95、失败率三条规则,评测后再定。D3 模型(10:48Z):私有部署接阿里百炼;开发测试用 Cohere rerank-v5-fast(经 Vercel AI Gateway,10:51Z 由 v3.5 改);私有部署由维护者自己配置测试。
- 和 ADR 的冲突:ADR-0161 K1 把重排划给适配器,今早合并的说明写了「永远不进知识源协议」。「有就用」推翻了这两处,要先补一条带日期的 ADR 说明(行 1,受管面)。
- 时机:真实向量评测里只走向量的中文 hit@3 已到 96.6%,BrightRule 上的提升空间小;能力面向更大、更乱、相似条款更多的语料。BrightRule 是否打开,按行 6 的开关对比结果定。
Rulings (verbatim above, English summary)
- A knowledge source may declare
retrieval.rerank(boolean). The model is never chosen by the source; it comes from the deployment (private:ai.reranker_*settings withOS_AI_RERANKER_*overrides; hosted: a platform constant). - 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.
- 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.
Design (recommended option B)
- Who reranks: the knowledge service, after the permission re-check and before the cut to
topK. One call per search (not one per refill round), and only text the caller may read leaves the service. Adapters (IKnowledgeAdapter,AdapterSearchOptions) are unchanged. - Contract: new
packages/spec/src/contracts/reranker.ts:IReranker { id; rerank(query, documents, opts?: { signal }) → Array of { index, score } }andRERANKER_SERVICE = 'reranker', mirroringembedder.ts. Resolved per search, as adapters resolve the embedder. - Source key:
rerank: z.boolean().optional()inside the strictKnowledgeRetrievalSchemathat 知识源加「检索方式」和混合比例:只用向量 / 只用关键词 / 混合(可设比例),由应用元数据指定,单次检索可覆盖 #38692 phase 1a adds. Not in the fingerprint or recipe hash. - Why the service, after the re-check: ADR-0161 K1's test for the platform side is "facts only the platform has"; which passages the caller may read is such a fact, and an adapter cannot know it. The ADR already says a platform-wide rerank is the service's (「平台以后如果统一做重排,那是知识服务的配置」). The text sent is the same passage text the embedder received, so egress adds a recipient, not new text.
- Pipeline (
knowledge-service-search.ts#searchByKey): widen the first round per declaring source (widened = byRecord || filtered || reranked, givingtopK × 5; real callers are alreadyfiltered, so only system-context searches grow). Pool = the firsttopK × 5answerable units (25 at the tool defaulttopK5, 40 at BrightRule's 8), capped at 50 per search. Text sent = the unit's representativehit.snippet. - One call, before the cut. The
orderhook is synchronous and runs up to four times inside the freshness loop (:461-470), so the model is called once beforehand and the hook applies the stored ranking; rerank first, affinity second (affinity, the caller-specific order, has the last word). Under record granularity (groupBy, BrightRule's path) the pool is the first N group leads; a group whose lead is replaced after the call keeps its group's place; a unit outside the pool follows the pool in adapter order. - Per source, by position. One call covers the declaring sources' pooled units; each source's units are re-ordered among that source's own places, as affinity does (
knowledge-affinity.ts:140-186), so a declaring source never jumps over a non-declaring one. The hit keeps its adapter score. - Marker:
notReranked?: Array of { sourceId, reason }on the report besiderefused;IKnowledgeService.searchkeeps its signature.no_rerankeris set whenever a searched source declares rerank and none is configured, independent of the candidate count. With a reranker and 0 or 1 unit: no call, no marker. - Failure of a configured reranker: open, see D2 (recommended: keep adapter order, marker
failed, a configuration failure such as 4xx logged aterror;rerank()needsmaxRetries: 0for one attempt; 3 s viaAbortSignal). - Asymmetry, written down: in the same
retrievalobject amodethe store cannot run is refused, whilererankwith no reranker is accepted (the ruling). It stays honest only through the marker, the bootwarnand the publish notice; the key's docblock states this. - Config, private:
ai.reranker_*keys contributed by service-knowledge with the embedder section (aiEmbedderSettingsSpecifierspath,knowledge-settings-contribution.ts),OS_AI_RERANKER_*overrides, default none. One client for one wire format, the one the first deployment uses (D3); no vendor preset list. - Config, hosted (cloud): a platform constant beside
PLATFORM_EMBEDDING_MODEL, built inservice-ailikebuildPlatformEmbedder;reranker_*joins the cloud-managed key list (service-settings/src/cloud-managed-settings.ts, objectstack).ai@7.0.118exportsrerank(); gateway typings listcohere/rerank-v3.5,cohere/rerank-v4-*,voyage/rerank-2.5*(no live call made). Timing: D4. - Egress: the question plus up to 50 passages per search go to the reranker. Private: nothing leaves unless configured. Hosted: a new recipient beside OpenAI (decision 2).
- Latency: a 3 s limit sits on a path whose scoped p95 was 4.24 s at 10 callers (before knowledge-pgvector:带范围检索先按范围取行再算距离(metadata GIN 索引 + 包含式范围条件,专题 #38703) #38747); row 6 must report the added p50/p95 and the
failedrate. - Not in v1: cross-source ordering by reranker score, a per-search tool argument, caching, tunable pool/time limit (constants:
topK × 5capped at 50; 3 s), adapter-native rerank,IReranker.model, a vendor preset list.
Rows
| # | Repo | Row | After |
|---|---|---|---|
| 1 | objectstack | ADR-0161 dated note: a source declares rerank; the service reranks after the re-check (accepting the note confirms D1). Amends: K1 table row and list (:104, :112, :119, incl. the 2026-11-29 sentence "the service reads no passage text and calls no model"), K2 rows (:149, :153, :157), K8 rule 4 (:422), the 2026-11-30 note (:417, :438, 「永远不进知识源协议」), TL;DR/title/D1 key words read narrowed (:1, :9, :41), an "Amended" line. Governed. |
D1; serial with open draft #38720 (same file, :153) |
| 2 | objectstack | retrieval.rerank and its reader: IReranker, the service step, the notReranked marker, the Studio form field (knowledge-source.metadata-form.ts + 11 locale files, as 1a shipped mode), generated spec artifacts (api-surface, authorable-surface, declaration-map, export-origins, json-schema manifest, liveness knowledge_source.json), docs (content/docs/references/ai/knowledge-source.mdx, content/docs/protocol/knowledge.mdx), SearchKnowledgeOutput + tool description sentence, changeset; tests with a fake reranker |
1; D2; all of #38692 phase 1a merged (#38720, #38721, #38722 which edits knowledge-service-search.ts, #38745) |
| 3 | objectstack | Reranker client for the D3 format, ai.reranker_* settings via the service-knowledge contribution (+ translations, cloud-managed keys), boot warn naming declaring sources with no reranker, publish notice via DraftReviewVerdictSchema.advisories (spec/src/ai/draft-review.zod.ts:101) |
2; D3 |
| 4 | objectstack | skills/objectstack-ai text for the key (governed) |
2 |
| 5 | cloud | Hosted platform reranker (maxRetries: 0), per-environment cost line, operator off switch; filed in cloud for the cloud lane |
2 + pin bump; only if D4 = with v1 or row 6 shows a gain |
| 6 | brightrule | Eval rerank on vs off on the 58.5k set with the D3 reranker: paired per-question wins/losses at hit@1/hit@3 and MRR (retrieval is deterministic, so repeats only measure latency), added p50/p95 at 10 concurrent callers, failed rate |
3 |
Former row 0 (decision card: who reranks) is folded into row 1: ADR-0161 already places a platform-wide rerank in the service (:422).
Serial note: row 2 touches knowledge-service-search.ts lines the refill/over-fetch work also touches; the scope-first GIN card #38747 touches adapters only and does not collide.
Decisions (Fable review 2026-11-30; all recommendations ruled by the maintainer 2026-11-30T10:47Z 「全部同意」, see the ruling comment)
D3 model ruled 10:48Z: Alibaba Bailian (百炼) reranker for the first private deployment, flat /compatible-api/v1/reranks format (qwen3-rerank / qwen3.7-text-rerank); development tests use cohere/rerank-v5-fast via the AI Gateway (changed from v3.5 at 10:51Z); the maintainer configures and tests Bailian on the private deployment himself. Details in the D3 ruling comment. D5 is not needed now (D4 = after row 6).
| # | Decision | Recommendation | Blocks |
|---|---|---|---|
| D1 | Who reranks | [knowledge service after the re-check; confirmed by accepting row 1] | Row 1 |
| D2 | A configured reranker fails or times out (the 10:13Z ruling covers "none configured" only) | [keep adapter order, mark failed, configuration failures logged at error; not a coded refusal] |
Row 2 |
| D3 | First private reranker and its wire format | [name one model for the first deployment; build that one format] | Row 3, row 6 |
| D4 | Hosted reranking with v1, or after row 6 | [after row 6; until then hosted searches normally and is marked, as ruled] | Row 5 |
| D5 | Hosted recipient (Cohere/Voyage via gateway) and charging | [only if D4 = with v1: cohere/rerank-v3.5 stated in hosted data docs; free and logged, with a review date] |
Row 5 |
| D6 | Does BrightRule declare it | [rule now: on only if paired wins clearly exceed losses at hit@3, added p95 stays inside #38703's limit, failed ≈ 0; answer after row 6] |
Nothing |
Settled, not put to the maintainer: the result is marked (10:13Z ruling); order by position, never by reranker score (affinity precedent, ADR-0161 2026-11-29 note); pool size and time limit are constants; no skipping (10:37Z ruling).
Related: epic #38703 (PG knowledge search), #38692 (retrieval mode), ADR-0161.
Generated by Claude Code
Activity
os-warren commentedon Nov 30, 2026
Ruled: 2026-11-30T10:47Z · maintainer (Warren) · in the project thread for cloud#5250 · 「全部同意」, answering the six decisions as put to him in Chinese (Fable review of this card, recommendations as in the body's Decisions table).
failedinnotReranked, one attempt (maxRetries: 0), 3 s; a configuration failure (4xx: wrong key or model) logged aterror. Not a coded refusal.no_reranker. Row 5 is not filed now.retrieval.rerankonly if row 6 shows, on the same questions, clearly more wins than losses at hit@3, added p95 at 10 callers inside 专题:私有部署企业版(PostgreSQL + pgvector)知识检索 10 人同时提问不超时;Turso 只保基本能力 #38703's limit, and afailedrate near zero.Earlier rulings carried on the body: 10:13Z 「有就用」, 10:37Z 「所以还是应该按照主流系统的做法,开了开关,一律重排」.
Recorded by repo:cloud#1 · os-warren · session_01JQwxbW3iAHptQS29fg3bHR.
Generated by Claude Code
os-warren commentedon Nov 30, 2026
Ruled: 2026-11-30T10:48–10:49Z · maintainer (Warren) · project thread for cloud#5250.
cohere/rerank-v3.5through the Vercel AI Gateway.What this means for the rows:
POST {base_url}/reranks,Authorization: Bearer KEY, request{ model, query, documents: string[], top_n, instruct? }, responseresults[]of{ index, relevance_score }(plusid,object,model,usage). Base URL per region:https://WORKSPACE.cn-beijing.maas.aliyuncs.com/compatible-api/v1(Beijing) or…ap-southeast-1…(Singapore). Models on that endpoint:qwen3-rerank,qwen3.7-text-rerank;gte-rerank-v2is refused there (model_not_supported), so it is out. Limits: 500 documents and about 120,000 tokens per request (query tokens × documents + document tokens), over-limit is HTTP 400, not truncated. Cohere's/v2/rerankuses the same field names (model, query, documents, top_n→results[].index, relevance_score); full compatibility is not verified. Source: Alibaba Cloud Model Studio "Text Rerank API" and "Reranking API" pages (updated 2026-10/11). Price per token: not found on the official pages read; to be read in the Bailian console.cohere/rerank-v3.5via the AI Gateway (ai@7.0.118rerank(),maxRetries: 0). No live Bailian call is made by the seat.cohere/rerank-v3.5via the gateway on the 58.5k set; the Bailian result on the private deployment is the maintainer's own run.cohere/rerank-v3.5for development testing only, never chat models. A seat in another project needs its own gateway key.Recorded by repo:cloud#1 · os-warren · session_01JQwxbW3iAHptQS29fg3bHR.
Generated by Claude Code
os-warren commentedon Nov 30, 2026
Ruled: 2026-11-30T10:51:35Z · maintainer (Warren) · project thread for cloud#5250 · 「ok」, answering: switch development testing from
cohere/rerank-v3.5tocohere/rerank-v5-fast?Development tests and the row 6 eval use
cohere/rerank-v5-fastvia the AI Gateway (listed at $0.02 per million input tokens on the gateway model list, 2026-11-30; v3.5 has no listed price). The Gateway has no Alibaba rerank model, so Bailianqwen3-rerank/qwen3.7-text-rerankis reached only directly (the maintainer's private-deployment test). Supersedes the model named in comment 7276135635; the gateway-key note there now coverscohere/rerank-v5-fast.Generated by Claude Code
os-warren commentedon Nov 30, 2026
Ruled: 2026-11-30T11:02:50Z · maintainer (Warren) · decision card in the project thread for cloud#5250 · question 「重排专题 #38750 现在怎么处理?」 · chose 「照常做,作为平台能力」 (over pause / close).
Context: measured on the real-embedding run, BrightRule gains little (top-8 recall 99.0%; its policy-inquiry skill already checks unit and rank per hit), and the maintainer agreed BrightRule does not need it (11:02Z 「所以就是不需要重排」). The epic proceeds as a platform capability for apps without such a skill; BrightRule stays off (D6 unchanged). Seat 3: start with row 1.
Generated by Claude Code
objectstack-fleet commentedon Nov 30, 2026
triage@os-warren · os-warren · session_01JQwxbZzZ2f5mzcvJbRrRNZ
Triage: first-touch · topic · no issue type (topics take none) · grade p2 kept ·
area:ai·pm:epic.needs-user-decision.objectstack-fleet commentedon Nov 30, 2026
repo:objectstack#3 · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z
Epic taken by seat
repo:objectstack#3at 2026-11-30T11:08Z, on the maintainer's order quoted above (handoff on mailbox #38600, comment 7275900669). The hold is lifted per 7276461620: 「照常做,作为平台能力」.Plan:
Each row card is filed as a sub-issue of this epic when its gate opens, and nothing is claimed early.
docs(adr): ADR-0161 dated note — a knowledge source declares rerank; …