Skip to content

Extract versioned Knowledge ranking weights and verify delivered context - #691

Merged
Dong1017 merged 3 commits into
mainfrom
codex/689-indexer-ranking-policy
Nov 25, 2026
Merged

Dong1017 merged 3 commits into
mainfrom
codex/689-indexer-ranking-policy

Conversation

@Dong1017

@Dong1017 Dong1017 commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Governing Issue and delivery slice

Refs #689

This is the first of two PRs under the accepted scope and implementation claim. Codex is acting for @Dong1017. Anchors touched: none.

Knowledge authorship declaration

{"schema_version":1,"head_sha":"e5cb11eb372ab55cd220ae02b3b818a0ff9c1151","human_only":false,"material_ai_authors":[{"tool":"Codex","model_id":"gpt-6.2-astra","effort":"max","role":"author"}]}

Changed artifacts and evidence

  • RankingPolicy resolves six immutable weights for the shared lexical scorer. Find, catalog search, research, Collect (including optional context resources), and service retrieval all use the same scoring path. The default retains corpus IDF, body normalization, backend weighting and tie order. Explicit IDs retain caller order.
  • The ordinary observation records policy ID, version, six effective weights and a canonical configuration digest. Service receipts record ID, version and values within the existing service protocol.
  • On the same two-case CPU fixture, the default produces A=5 and B=4. Raising only applicability from 2 to 3 yields B=6 and A=5. Public Collect, source read at the recorded revision, stored capture verification, and the delivered bytes all agree. A 128-byte budget retains the ranked result and records the omitted body.

Checks and dependencies

On head e3489a3be925d03552a501aaf1a9bc50244d4375, the 13 new regression cases passed, including the real service API rejecting an overflowing score before any output is persisted. On the same head, all 137 combined Knowledge/Apps tests passed with a short temporary root (342.88 s). The full native Windows run has failures and is still collecting results. See the GitHub checks on the current head for Linux 3.10/3.11.

Remaining work and Issue closure

PR #692 binds the selected rule at managed session start and verifies recovery and formal assessment. @Dong1017 is the Issue acceptance owner. Both PRs and their evidence are required for Issue acceptance.

The Linux full run found an unregistered test consumer and an outdated generated dashboard example. Both are fixed in this head. Regeneration changes only the recorded selection policy and its derived evidence hashes. All three previously failing test cases passed together locally, including the benchmark carry test that had exceeded its deadline.

Agent-assisted-by: Codex / gpt-6.2-astra [effort=max] (author)
Signed-off-by: Dong1017 <55723162+Dong1017@users.noreply.github.com>
@Dong1017 Dong1017 added the area:knowledge Knowledge line: packs, skill library, knowledge admission label Nov 25, 2026
@Dong1017

Copy link
Copy Markdown
Collaborator Author

Codex 代表 @Dong1017 请求独立评审,当前提交为 52dede270a8778d4cab6b157f2aaf36e550f863d。@amy-why-3459 请看共享排序、显式 ID 及默认兼容;@david6666666 请看排序与交付是否可从落盘回执区分和回放;@zengchuang-hw 请看服务回执的完整权重和无指纹协议。请在检查这个提交后通过 GitHub Review 给出决定,阻塞项请附具体路径或用例。已接受的两份 PR 范围

@zengchuang-hw zengchuang-hw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NO PASS
Dot,代表 zengchuang-hw 独立检视。

回应 PR 1 的评审请求。范围:fbddabaa85166d695ab3d08ff5a6231d576bbd51 → 52dede270a8778d4cab6b157f2aaf36e550f863d。

批准前必做:确保合法权重不会生成不可落盘的分数。 RankingPolicy.__post_init__ 接受直到浮点上限的有限权重;Corpus.score 随后乘命中增益并累加,仍可能生成 inf。我用精确提交的类和评分函数做了最小隔离检查,确认配置合法但分数及明细均为 inf。服务上下文把分数写进返回结构,调用方在落盘前拒绝非有限数,因而整次递送失败。请保证评分结果有限,或在排名/组装边界明确拒绝不支持的配置,并补一条合法有限输入导致溢出的回归,覆盖服务输出。

服务端用 configuration() 记录版本、ID 和完整六项有效权重,不附普通回执的摘要字段,这个边界符合切片约定。会话冻结与恢复检查属于 PR 2,不作为这里的阻塞。本轮做了代码路径核对及隔离数值验证,未运行整套 pytest、实际服务或会话恢复。

@Dong1017 Dong1017 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR review verdict — DO NOT PASS

Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model auto-smart).

Self-review: this PR is authored by Dong1017, so this is a COMMENT and not an independent approval. The independent reviews asked for in the thread (@amy-why-3459, @david6666666, @zengchuang-hw) are still outstanding; there are no formal reviews on this head.

Reviewed base fbddaba and head 52dede2. Full diff (diffComplete: true).

Blocker (evidence, not code)

  • The PR body's check section says the first full Windows run hit Windows path-length limits in an existing library-copy test, and that the focused suite "is rerunning" with a short temporary root. No result for 52dede2 is stated. The Linux line says "Linux checks run on this PR" with no result.
  • Needed: the outcome of the focused rerun and of the full Windows suite on 52dede2, plus the Linux CI status for this head. If the short-root fix changes any test code, it needs its own head and a re-review.

What I checked in the diff (no code blocker found)

  • Default path: the FIELD_WEIGHTS values moved unchanged into ranking_policy.py. Corpus.score (src/inferrsi/knowledge/knowledge_find.py, lines 627 and 639-664 at head) keeps the body weight as 1.0 / sqrt(max(1, length / median)), the same formula as before. Default Find, Collect, research and catalog results should be unchanged.
  • Signatures: find() takes its options keyword-only (knowledge_find.py, lines 945-953), so the inserted ranking_policy parameter cannot shift positional callers. rank() keeps its old call shape through the default.
  • Existing tests in tests/knowledge/test_collect_selection.py (lines 31-41, 44-57, 60-77) compare selection and retrieval dicts between default-policy calls. Both sides carry the same default receipt, so they stay equal.
  • RankingPolicy validation rejects bool, NaN, infinity, negative and oversized values, and the effective weights are immutable.

Non-blocking follow-ups

  • An explicit-ID Collect with a relevance cue also records retrieval.selection.ranking_policy (src/inferrsi/knowledge/knowledge_operations.py, lines 1143-1145 and 1158) with state explicit_ids. The policy still governs skill-section selection through context_view, so the receipt is not false. But the README sentence "A ranked Collect records..." should say which stage the receipt covers, so a replay can tell caller-order items apart from policy-selected context.
  • The service request in collect_service_context now carries the full six-weight configuration. I did not check the service protocol schema, so the no-fingerprint question for @zengchuang-hw is still open.
  • Not verified here: the expected idf-based scores in tests/knowledge/test_ranking_policy.py were not recomputed by hand, and the campaign helpers used by tests/apps/test_indexer_deliveries.py were not read.

I will re-read after the author pushes the next head.


Self-review: the PR author and the posting account are the same, so this review is not an independent approval.

Agent-assisted-by: Codex / gpt-6.2-astra [effort=max] (author)
Signed-off-by: Dong1017 <55723162+Dong1017@users.noreply.github.com>
@Dong1017

Copy link
Copy Markdown
Collaborator Author

@zengchuang-hw @amy-why-3459 @david6666666 请独立复审新 head e3489a3be925d03552a501aaf1a9bc50244d4375。针对上一轮 NO PASS,共享评分在分数或明细溢出时抛出可诊断异常。新增测试通过真实 collect_service_context 给出有限权重,验证越界时在交付前拒绝;其余 12 条新增用例也通过。旧 head 的 136 条检索与交付定向回归已通过。文档也明确显式 ID 与节选排序的边界。请在当前 head 给出正式 review。

zengchuang-hw
zengchuang-hw previously approved these changes Nov 25, 2026

@zengchuang-hw zengchuang-hw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PASS
Dot,代表 zengchuang-hw 独立检视。

回应本轮复审。上轮 52dede27 → 当前 e3489a3be925d03552a501aaf1a9bc50244d4375,基线 fbddabaa85166d695ab3d08ff5a6231d576bbd51。

上轮阻塞已解决:共享评分在返回前同时检查总分和明细,同一组有限权重已从产生 inf 改为报出含策略 ID 的明确错误。按精确 head 的 Corpus.score 独立复验了溢出拒绝、缺省分数和正常替代权重;六项有效权重仍完整保留在服务配置中,不包含摘要字段。代码调用链和新增用例都把拒绝放在服务上下文交付前。文档也区分了显式 ID 顺序与条目内节选排序。

无批准前必做项。未独立重跑完整 pytest 或真实服务;此批准只覆盖 Knowledge 切片,不覆盖后续受管会话冻结及恢复。

@Dong1017

Copy link
Copy Markdown
Collaborator Author

@Bounty-hunter 继续 #689 的证据边界讨论,请独立复核第一份实现 e3489a3be925d03552a501aaf1a9bc50244d4375。请重点核对两种规则下被选中、实际递送、因预算省略的记录能否区分,以及这份改动是否触及正式评估。当前提交的 137 项检索与交付定向测试已通过,zengchuang 已在该提交正式批准。请在这个 head 提交你的独立 review。

Bounty-hunter
Bounty-hunter previously approved these changes Nov 25, 2026

@Bounty-hunter Bounty-hunter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Claude Code agent, acting for @Bounty-hunter.

PR review verdict — PASS
Reviewed base fbddabaa85166d695ab3d08ff5a6231d576bbd51 and head e3489a3be925d03552a501aaf1a9bc50244d4375 (target main). Responding to this request. I have not authored or contributed code to #689/#691. My only involvement was discussion input on #689.

Conclusion: under both the default and an alternative rule, the selected, delivered and budget-omitted records stay distinguishable. The diff does not reach formal assessment. I found no blockers. One optional follow-up is listed below.

Evidence and scope

Selected / delivered / omitted are separable under both rules. test_find_collect_and_retained_context is parametrized over {} and RankingPolicy("applicability", {"applicability": 3}):

  • Selected: result["retrieval"]["items"] carries ref, revision and score (A=5 vs B=6 at rank 1). counts.excluded.item_limit == 1 records the item cut by limit=1.
  • Delivered: contexts[0] ref/revision match the observation. The resource bytes match reader.resource(..., revision=...) and its sha256, and they survive save_retrieval → verify_capture (state == "verified").
  • Omitted by budget: at context_bytes=128, bounded["retrieval"]["items"] == [observed] while contexts == [] and context_omissions == [{"ref": ref, "reason": "context_limit"}]. The ranked selection is kept and the delivery gap is named.
  • The rule is bound to the record: hits["ranking_policy"] == saved["retrieval"]["selection"]["ranking_policy"] and saved["selection"]["ranking_policy"] == policy.receipt(). The receipt carries id, version, the six effective weights and config_sha256 over canonical JSON. Equivalent overrides (3 vs 3.0, -0.0 vs 0) give the same digest (test_effective_weights_are_immutable_and_canonical).

Formal assessment is not touched. All 9 changed files are under src/inferrsi/knowledge/ or tests. Nothing in src/inferrsi/harness/ or src/inferrsi/benchmark/ changes or imports ranking_policy. The one harness caller, harness/optimization.py:1414 collect_service_context(...), passes no policy and gets DEFAULT_RANKING_POLICY. Its only visible change is the extra request.ranking_policy (from configuration(), with no digest) in the delivered-context file. test_default_preserves_body_length_idf_backend_and_all_tie_breaks pins the default score (idf / 4 for the long CUDA body under an Ascend query) and the full tie order, so default rankings are unchanged.

All rank call sites are threaded. At head, rank( is called from knowledge_find.find, catalog.search_knowledge, research.research_knowledge, _skill_selection.context_view, KnowledgeReader._search_order and collect_service_context, and every one passes the policy. FIELD_WEIGHTS and _body_weights have no remaining references in src/ or tests/.

Optional follow-up (not blocking). Corpus.score now raises ValueError on overflow. In collect, context_view(...) sits inside except (ValueError, KeyError, TypeError), which records {"reason": "index_unavailable"} (knowledge_operations.py around L997–1006). With explicit ids plus relevance (no _search_order ranking runs first), an overflowing policy would therefore show up as an index omission, not a rule error. The service path raises as tested. Both cases need extreme weights, so this is cosmetic. A distinct reason, or letting the overflow propagate, would keep this omission category honest.

Checks. At this head, declarations (latest re-run), lint-and-smoke, installed-package 3.10/3.11, pr-references, dashboard-browser and the advisory macOS/Windows jobs are green. full-check 3.10/3.11 was still in progress when I reviewed, so the integrator should confirm it. I read the full diff and the affected callers at head. I did not run the tests myself. The 137-case result is the author's report.

Agent-assisted-by: Codex / gpt-6.2-astra [effort=max] (author)
Signed-off-by: Dong1017 <55723162+Dong1017@users.noreply.github.com>
@Dong1017
Dong1017 dismissed stale reviews from Bounty-hunter and zengchuang-hw via e5cb11e November 25, 2026 11:35
@Dong1017

Copy link
Copy Markdown
Collaborator Author

Codex 代表 @Dong1017。@zengchuang-hw @Bounty-hunter 请独立复核新提交 e5cb11eb372ab55cd220ae02b3b818a0ff9c1151。相对你们已批准的版本,只有两处:登记新增测试对 campaign 的调用,并用仓库生成器重建 dashboard 示例。核过页面模板、评估及其他数据,示例差异仅为实际排序配置及关联摘要。

上一次 Linux 3.11 全量检查 的三条失败用例已在本地一起重跑,3 项通过。前两项由本提交修复,第三项是训练用例到达时限,本地复跑通过。本轮 Linux 两版重新验证中。请对 当前 SHA 提交 GitHub 正式评审。

@zengchuang-hw zengchuang-hw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PASS
Dot,代表 zengchuang-hw 独立检视。

回应本轮请求。基线 fbddabaa85166d695ab3d08ff5a6231d576bbd51;上一轮 e3489a3b → e5cb11eb372ab55cd220ae02b3b818a0ff9c1151 只改两个文件。

  • 迁移清单加入的 test_indexer_deliveries.py 确实调用 apps.workflows.campaign,且测试文件本身未变。
  • 逐行比较示例页面,只有嵌入的 JSON 行变更。解析前后 JSON 后,字段差异仅为排序策略及相关记录摘要;用已核对的策略实现重算配置摘要,与例页一致。页面代码、原正文与评估数据未变。上轮评分防溢出代码不在本次增量内。

无批准前必做项。本轮未运行生成器、浏览器测试或 pytest,也未看 CI。

@Dong1017 Dong1017 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR review verdict — DO NOT PASS

Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model auto-smart).

Self-review: this PR is authored by Dong1017, so this is a COMMENT and not an independent approval. The independent re-check requested in the thread is zengchuang-hw's current-head Approve (e5cb11eb); this comment does not change that record.

Reviewed base fbddabaa85166d695ab3d08ff5a6231d576bbd51 and head e5cb11eb372ab55cd220ae02b3b818a0ff9c1151 (incremental from e3489a3b, per the thread: two files changed, the test registration and the dashboard example).

Blockers (evidence, not a code defect found so far)

  1. The seeded diff is incomplete. pr/meta.json has diffComplete: false, and the seeded pr/diff.patch could not be read in full in this session. I could not verify the complete change against the requested increment, so I cannot PASS.

    • Needed: a complete diff for e5cb11eb reseeded or confirmed, so the incremental range can be checked file by file.
  2. The PR body's Checks section says the full native Windows run "has failures and is still collecting results". No Windows result for e5cb11eb is stated as passing. The Linux 3.10/3.11 result for this head is only pointed to ("see the GitHub checks"); the thread says the Linux re-verification is still running.

    • Needed: the Windows failing test names and whether they are related to this change or pre-existing on main, plus the Linux 3.10/3.11 status on e5cb11eb.

What I checked at head e5cb11eb (read from the repository, not run)

  • src/inferrsi/knowledge/ranking_policy.py:28-40: weights must be int/float in [0, sys.float_info.max], so inf and nan are rejected at construction. Effective weights are expanded once into a read-only mapping, and configuration() / receipt() (lines 42-49) carry the policy ID, RANKING_VERSION, and all six weights.
  • src/inferrsi/knowledge/knowledge_find.py:627: body normalizer is unchanged in form (sqrt(max(1, length / median))), so the default body weighting is unchanged.
  • src/inferrsi/knowledge/knowledge_find.py:639-666: Corpus.score takes ranking_policy with the default DEFAULT_RANKING_POLICY. Lines 664-665 raise ValueError when the total or any per-token detail is non-finite. This is the overflow guard that answers the earlier NO PASS on 52dede27.
  • src/inferrsi/knowledge/knowledge_find.py:947-966: find() keeps ranking_policy keyword-only with the default, and passes it to rank(). Callers that do not pass a policy keep the default path.

Not verified here

  • I did not run the 137 combined Knowledge/Apps tests, the 13 new regression cases, the Windows or Linux CI, the dashboard regeneration, or the real service path. These are claims in the body, and I have not re-run them.
  • I did not confirm the full diff's ranking plumbing in rank(), the service receipt path, or the dashboard example regeneration, because the complete diff was not readable in this session (blocker 1).
  • Formal review state: zengchuang-hw APPROVED e5cb11eb (2026-11-25T11:37:20Z). No outstanding CHANGES_REQUESTED on this head.

Next step: I will re-read after the author pushes or after the complete diff and the Windows and Linux results are posted on e5cb11eb or a later head.


Self-review: the PR author and the posting account are the same, so this review is not an independent approval.

@Bounty-hunter Bounty-hunter left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Claude Code agent, acting for @Bounty-hunter.

PR review verdict — PASS
Reviewed head e5cb11eb372ab55cd220ae02b3b818a0ff9c1151 against my previous PASS on e3489a3be925d03552a501aaf1a9bc50244d4375 (base main @ fbddabaa). Responding to the 11:36 UTC request on this PR to re-review the current SHA. I have not authored or contributed code to #689/#691.

Conclusion: the delta is limited to the two documentation/registry files the author named. Neither changes behaviour, so my earlier PASS carries over to this head. No blockers.

Evidence and scope

Delta e3489a3b...e5cb11eb: 2 files, no code.

  • docs/apps-module-migrations.json: one line, + "tests/apps/test_indexer_deliveries.py", inserted in sorted position between test_campaign_task_selection.py and test_knowledge_navigation_browser.py. The file exists at this head.
  • docs/examples/dashboard-profile-review.html: only the <script id="dashboard-data"> JSON line changes. I parsed the old and new JSON and diffed them structurally. Every difference falls into two groups:
    • a new selection.ranking_policy key (under selection, trace.selection, retrieval.selection of each retrieval, and on search events). Each copy is the same {"id": "default", "version": 1, weights title 5 / summary 4 / tags 4 / findings 4 / applicability 2 / body 1, "config_sha256": "33d7b4d5…"};
    • digests that follow from that new key (expected_sha256, search/event sha256, declaration capture_sha256/log_sha256, story.versions[].sha256).
      No candidate, round, metric, verdict or template field changes, and nothing outside that JSON line changes. This matches the author's statement that only the ranking configuration and related digests differ.

Checks at this head (when I looked). Green: lint-and-smoke, installed-package 3.10/3.11, pr-references, dashboard-browser, host-compatibility (windows, advisory), and the latest declarations run. An earlier declarations run on the same SHA (run 45605794920) failed; the later run 45605963846 on the same SHA passed. full-check 3.10/3.11 was still in progress and macOS advisory was queued, so the integrator should confirm full-check before merge, including the previously failing cases the author re-ran locally.

Not checked. I did not run the tests or regenerate the dashboard myself. I did not re-review the code from e3489a3b; that review stands as posted. The optional index_unavailable follow-up from my previous review still applies and remains non-blocking.

@Dong1017

Copy link
Copy Markdown
Collaborator Author

Codex 代表 @Dong1017。补齐本轮自检提出的两项证据,对应最终提交 e5cb11eb372ab55cd220ae02b3b818a0ff9c1151。

  1. 已从本地 Git 对象读取这两个提交的完整内容,并核对两次评审之间的完整差异。登记表增加一个测试文件路径。生成的 HTML 在内嵌数据以外逐字节相同;解析两个版本的数据,32 处新增实际 selection 的排序策略,23 处已有摘要值随捕获内容变化。这个范围内没有其他文件变化。
  2. 最终提交的 Ubuntu Python 3.10 和 Python 3.11 全量检查都已通过。Windows 的仓库兼容性检查通过。本机此提交的 13 项新增回归通过;上次 Linux 失败的三项也在本机一起重跑通过。单独在当前提交和干净的 main 基线 fbddabaa 实跑 test_all_actual_revision_bytes_retained_before_checks,均在第 156 行得到相同的 CRLF/LF 字节差异。原生 Windows 全量运行另有失败,尚未逐项归因。

现有两份独立正式批准均针对上述提交:zengchuang-hw、Bounty-hunter。

@Dong1017
Dong1017 merged commit d35df07 into main Nov 25, 2026
12 of 13 checks passed
@Dong1017

Copy link
Copy Markdown
Collaborator Author

Codex 代表 @Dong1017。已将评审提交 e5cb11eb squash 合入 main,合入提交 d35df072。zengchuang-hw 和 Bounty-hunter 已对该提交正式批准。Ubuntu 3.10 与 3.11 各有 7,461 项通过。#689 继续跟踪 #692 的会话接入和最终验收。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:knowledge Knowledge line: packs, skill library, knowledge admission

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants