Repository navigation
feat(knowledge): deliver selected L1 cards with pinned Collect bodies - #672
Conversation
Agent-assisted-by: Codex / gpt-6.2-astra [effort=xhigh] (author) Signed-off-by: Dong1017 <55723162+Dong1017@users.noreply.github.com>
zengchuang-hw
left a comment
There was a problem hiding this comment.
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 验收。
|
@Bounty-hunter @amy-why-3459 请帮忙独立评审 #672 的当前提交 请重点核对 CLI 和 Apps 是否都从本次实际递送正文的同一份 Bundle、同一版本生成 L1 卡,Case 是否只返回选中的一条 finding。预算先覆盖这批正文,再按 UTF-8 字节递送整张卡,也请看少 1 字节及未指定卡片时的兼容行为。 真实 Qwen Ascend 案例在 10,742 字节时收到两份原文和指定卡片,10,741 字节时仍收到全部原文。163 项相关测试通过,安装包上的 CLI 与 Apps 结果一致。实测记录 · CI 请在本 PR 留下对该版本的正式 review。若发现问题,标出相关文件或可复现的输入即可。 |
Dong1017
left a comment
There was a problem hiding this comment.
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()storesdelivered_bundles[view["ref"]] = (ref, bundle)only after the body is appended tocontexts(knowledge_operations.py ~1005–1008). The card is projected from that stored Bundle.project_decision_cardre-checks ref, id and revision and hashes the same copied Bundle. Collect does not reopen the bundle for L1, and the regressiontest_collect_projects_from_the_delivered_bundleasserts exactly that. - Bodies first, then whole cards. Cards are projected after the whole
for reference in requestedloop, withmax_bytes = context_bytes - context_used(~1118).project()returnsover_budgetwith nocardwhensize > max_bytes(decision_cards.py:187).context_usedgrows only when a card is actually returned.sizeislen(_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 - 1keeps both bodies and reportsover_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 withoriginal["findings"][1]. A missing or invalid selector givesunavailablewithout 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 thatdecision_cards={}output equals the default output, with nodecision_cardskey in the result or inretrieval.request. This is consistent with the author's claimed byte comparison against parent443891ef. - Input validation. Requests need explicit
ids,context_bytes, a ref that is inidsand 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_limitor an unavailable revision, yieldsno_bodyand 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_cardsrejects a duplicate ref (exit 2, tested).REFalone maps toNone. Text output printsREF\tL1\tstatusand then the card.
Non-blocking notes
except (ValueError, KeyError, TypeError)around projection relies onIdentityErrorandUnavailableRevisionbeing unreachable there, because the ref and revision come from the same Bundle. I did not confirm they subclassValueError. It looks unreachable today, so it is not a blocker._decision_cardssplits 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.
amy-why-3459
left a comment
There was a problem hiding this comment.
LGTM
Codex, acting for @amy-why-3459.
复核 919e4684 的普通 Collect 路径。CLI 和 Apps 都用递送正文时保留的 Bundle 与固定 revision 生成 L1,Case 只投影指定 finding。先计整批正文,再按 UTF-8 字节检查整张卡;差 1 字节时保留正文,未请求卡片时输出保持兼容。已核对同一 Bundle 在源文件变更后的回归、预算边界和 Case 选择用例;当前 Ready CI 通过,未在本地重跑。
Governing Issue and delivery slice
Refs #636
Codex 代表 Dong1017 按已认领的 #636 交付普通 Collect 的批量 L1 读取。基于主线
443891ef23c8fcaf4b2c6b2e7d49568bc0b3bf0c,复用已合入的 #661,可以独立评审、验证和合入。交付顺序及范围Anchors touched: none
Knowledge authorship declaration
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 均与固定版本资源回读逐字节相符。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,重点看正文先于卡计费、同一份原文和精确版本、以及未请求卡时的完整响应。