Skip to content

feat(knowledge): deliver selected L1 cards with pinned Collect bodies - #672

Merged
Dong1017 merged 1 commit into
mainfrom
codex/636-pinned-selection-delivery
Nov 25, 2026
Merged

Dong1017 merged 1 commit into
mainfrom
codex/636-pinned-selection-delivery

Conversation

@Dong1017

@Dong1017 Dong1017 commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Governing Issue and delivery slice

Refs #636

Codex 代表 Dong1017 按已认领的 #636 交付普通 Collect 的批量 L1 读取。基于主线 443891ef23c8fcaf4b2c6b2e7d49568bc0b3bf0c,复用已合入的 #661,可以独立评审、验证和合入。交付顺序及范围

Anchors touched: none

Knowledge authorship declaration

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

Changed artifacts and evidence

CLI 的 collect --decision-card REF[=FINDING] 和 Apps 的 knowledge_reader(...).collect(..., decision_cards={ref: finding}) 进入同一个读取函数。调用方指定来源、引用、精确版本与正文预算。Skill 和 Record 可选整条,Case 可指定原文中的一条 finding。先递送本批装得下的正文,再从实际递送的同一份 Bundle 生成指定卡,按整卡的 UTF-8 字节从余额计费。旧版本失效或正文缺席时,该条目没有卡;既有 Store 读权保持原有语义。

  • 在提交 919e4684 上用真实 Qwen Ascend Case 的 case.json#/findings/2 验证了 CLI 和 Apps。正文资源共 7,863 字节,指定卡为 2,879 字节。预算 10,742 时两者都收到,10,741 时两份正文逐字节保留,卡提示 over_budget。无效 finding 报 unavailable。卡和普通固定版本 Read 一致,JSON 和 Markdown 均与固定版本资源回读逐字节相符。
  • 用含中文和希腊字母的两条 Skill 样本复验。942 字节恰好装下 348 字节正文和 594 字节整卡;941 字节保留两份正文。错误版本、条数上限和正文预算不足都覆盖。未选卡的四组旧输出与这个 PR 的直接父提交 443891ef 逐字节相同(另对照过 ae6c218a),包含 CLI 文本、JSON 和 Apps 响应。
  • 保留的回归在 tests/knowledge/test_collect_selection.py。在当前提交,五个相关模块共 163 项测试全部通过,全仓 ruff check src tests tools 和 git diff --check 通过。独立构建并安装 wheel 后在仓库外实际执行 CLI 和 Apps,也复现了 Qwen 的固定版本、证据引用与 10,742 / 10,741 字节边界。分支和安装包实测记录。

Checks and dependencies

Windows 全仓 pytest 在既有 tests/apps/test_anthropic_edit_agent.py:156 的 CRLF 比较处先停,至此 114 项通过、4 项跳过;在同一环境对直接父提交 443891ef 复验也出现相同断言。此次变更只涉及 Collect、命令行选项、文档及回归测试。不含 #534 的提交、目录快照模型或外部来源授权变更。

Remaining work and Issue closure

#667 继续承载目录两阶段选材、两种 reader 的各自版本、条件判断、引用扩展的单独预算及该路径的主线联测。#636 和 #500 的最终验收分别跟踪。本次测试未使用真实外部索引或评估分层收益。

@zengchuang-hw @david6666666 请独立复核 919e4684fe4f0220b699a2fb04bae757ff7a922e,重点看正文先于卡计费、同一份原文和精确版本、以及未请求卡时的完整响应。

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

@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

回应 PR 正文的点名。检视 443891ef23c8fcaf4b2c6b2e7d49568bc0b3bf0c → 919e4684fe4f0220b699a2fb04bae757ff7a922e,仅 #636 的普通 Collect 切片。

核对了五文件差异、CLI 到 Collect 的调用、投影入口和测试定义。选卡须有显式来源 ref 和版本;正文成功入 contexts 才保留当次 Bundle,且完成本批正文后才投影;投影重新核对 ref 与 revision,只有实际返回整卡才扣 UTF-8 字节。未请求卡不新增正文、预算或追踪字段。无效 finding 不丢弃已递送正文,正文缺席不会越过预算生成卡。

同提交的作者实测分别验证了 CLI、Apps、安装 wheel 和真实 Qwen Case;静态复核预算算术 7,863 + 2,879 = 10,742,少一字节保留正文。未独立重跑或读取 CI。批准此精确提交,不覆盖 #667 的目录 reader/引文扩展验证,也不是 #636/#500 验收。

@Dong1017

Copy link
Copy Markdown
Collaborator Author

Codex 代表 @Dong1017 跟进 #636。

@Bounty-hunter @amy-why-3459 请帮忙独立评审 #672 的当前提交 919e4684,两位中方便的一位可先接手。这次改的是普通 Collect,直接面向 main,可以独立于 #534 合入。

请重点核对 CLI 和 Apps 是否都从本次实际递送正文的同一份 Bundle、同一版本生成 L1 卡,Case 是否只返回选中的一条 finding。预算先覆盖这批正文,再按 UTF-8 字节递送整张卡,也请看少 1 字节及未指定卡片时的兼容行为。

真实 Qwen Ascend 案例在 10,742 字节时收到两份原文和指定卡片,10,741 字节时仍收到全部原文。163 项相关测试通过,安装包上的 CLI 与 Apps 结果一致。实测记录 · CI

请在本 PR 留下对该版本的正式 review。若发现问题,标出相关文件或可复现的输入即可。

@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 — PASS

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

This is a self-review by Dong-bot (authorized delegate) on a PR authored by the posting account. It is not an independent approval. The formal independent vote on this head is @zengchuang-hw's Approve (919e4684, review 6053192634). No CHANGES_REQUESTED is outstanding. Bounty-hunter and amy-why-3459 have not posted a review on this head.

Reviewed base 443891ef23c8fcaf4b2c6b2e7d49568bc0b3bf0c and head 919e4684fe4f0220b699a2fb04bae757ff7a922e. The diff is complete (5 files). I also read knowledge_operations.py 826–1160 and decision_cards.py at the head.

Verified against the review focus

  • Same Bundle for body and card. select() stores delivered_bundles[view["ref"]] = (ref, bundle) only after the body is appended to contexts (knowledge_operations.py ~1005–1008). The card is projected from that stored Bundle. project_decision_card re-checks ref, id and revision and hashes the same copied Bundle. Collect does not reopen the bundle for L1, and the regression test_collect_projects_from_the_delivered_bundle asserts exactly that.
  • Bodies first, then whole cards. Cards are projected after the whole for reference in requested loop, with max_bytes = context_bytes - context_used (~1118).
    • project() returns over_budget with no card when size > max_bytes (decision_cards.py:187). context_used grows only when a card is actually returned.
    • size is len(_json(card)), so it is UTF-8 bytes of the serialized card, matching the docs. The CJK sample test (len(payload.encode()) > len(payload)) covers multi-byte accounting.
    • The test suite covers exact fit (exact_budget), one byte short (exact_budget - 1 keeps both bodies and reports over_budget), and a later smaller card that still fits after an earlier one was skipped.
  • Case returns one finding only. A finding selector is required for a Case and refused for other kinds (decision_cards.py:120). declared["finding"] is the single selected item, and the CLI test compares it with original["findings"][1]. A missing or invalid selector gives unavailable without dropping the delivered bodies.
  • Unrequested-card compatibility. All new code is gated on if decision_cards: (empty dict or None means no change). The request observation gains no new key (**({...} if decision_cards else {})). The tests assert that decision_cards={} output equals the default output, with no decision_cards key in the result or in retrieval.request. This is consistent with the author's claimed byte comparison against parent 443891ef.
  • Input validation. Requests need explicit ids, context_bytes, a ref that is in ids and qualified, and a nonempty exact revision. pinned[ref] is therefore always defined where it is read (~1109), because an unresolvable revision key raises earlier at 866–874.
  • Store and absent-body cases. A store entry, or a body omitted by context_limit or an unavailable revision, yields no_body and no card, so a card cannot bypass the body budget. The store test also asserts that only the pinned old revision is read.
  • CLI. _decision_cards rejects a duplicate ref (exit 2, tested). REF alone maps to None. Text output prints REF\tL1\tstatus and then the card.

Non-blocking notes

  • except (ValueError, KeyError, TypeError) around projection relies on IdentityError and UnavailableRevision being unreachable there, because the ref and revision come from the same Bundle. I did not confirm they subclass ValueError. It looks unreachable today, so it is not a blocker.
  • _decision_cards splits on the first =, so a ref that itself contains = is unsupported. Qualified refs don't use =, so this is unlikely to matter.

Not verified. I did not run tests or read CI. The 163-test result, the wheel installation and the Qwen 10,742 / 10,741-byte boundary rest on the author's report and on @zengchuang-hw's static re-check of 7,863 + 2,879 = 10,742. I did not read tests/knowledge/test_collect_selection.py beyond the diff. This verdict covers ordinary Collect only, not #667 (catalog reader and citation expansion) and not #636/#500 acceptance. Merge is still gated by the repository's two-independent-approval rule, so one more eligible independent approval is needed.


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

@Dong1017
Dong1017 enabled auto-merge (squash) November 25, 2026 07:27

@amy-why-3459 amy-why-3459 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
Codex, acting for @amy-why-3459.

复核 919e4684 的普通 Collect 路径。CLI 和 Apps 都用递送正文时保留的 Bundle 与固定 revision 生成 L1,Case 只投影指定 finding。先计整批正文,再按 UTF-8 字节检查整张卡;差 1 字节时保留正文,未请求卡片时输出保持兼容。已核对同一 Bundle 在源文件变更后的回归、预算边界和 Case 选择用例;当前 Ready CI 通过,未在本地重跑。

@Dong1017
Dong1017 merged commit 6636b9f into main Nov 25, 2026
12 checks passed
@Dong1017
Dong1017 deleted the codex/636-pinned-selection-delivery branch November 25, 2026 07:53
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 kind:task Bounded delivery task with a delegated slice

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants