Repository navigation
fix(context): reuse exact Todo rows in native required views - #7610
Conversation
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent; model=gpt-6.1-sol; provider=OpenAI; declaration_source=runtime_reported; reasoning_effort=max.
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
结论:APPROVE。未发现阻塞问题;有一项 P3 回归断言建议。完整评审绑定 head d64ee74c3c15b847a589b30be43f3873d0a383a3,比较基线为 447c35ed646a637d77ce4a27b5b60813cdd71efa。这是代码批准结论;GitHub 的实际 review state 使用 COMMENTED。
动机 / Motivation
使用原生上下文投递的 Agent 在冷读或恢复时,会在多个 Todo 摘要分组中重复收到同一完整记录。相同的长约束、反例和停止条件因此被重复传输和阅读。
例如,同一个任务同时位于首项、backlog 和 claimed 分组时,原来三处都带全文;本次保留第一份完整记录,后续分组通过同一 required view 内的 JSON pointer 引用它。JSON pointer 是定位当前 JSON 中原值的路径。
可验证的改善是减少完全相同内容的传输,同时逐项展开后仍与原记录一致。本 PR 不筛选候选、不缩写任务、不改变原要求、权限或结算,也没有证明模型费用或长程成果收益。
更广的候选分阶段读取、真实宿主采用和完整模型成本仍由原上下文收敛工作继续验收。
改动思路 / Approach
不修改时,冷态重复仍在;仅依赖跨轮 delta 无法解决没有可用基线的首次投递。较小且合适的边界是扩展现有 TypeScript 投影 owner,让它选择完全相同的记录,再由 Python 适配器核对原值并应用路径编辑。没有新增选择器、配置 owner 或持久状态。
决定保留该实现的理由是:它只改变启用原生投递后的展示,复用现有 lane/record vocabulary、原始 capture 和恢复链;完整记录仍在同一必读视图中。当前 PR 边界是同一 required view 内的精确复用,较广的候选分阶段读取和完整模型成本资格仍由原上下文收敛工作承担。
正向路径为 context-project → _capture_required_context → progressiveContextPlan → quotaSummaryReferences → 原 Python 值二次比较 → 包含说明的整视图大小比较 → 已有分页和 native lifecycle。失败、未知或不划算时保留全文;不重新准入,不增加人工确认轮次。
具体改动 / Changes
完整 diff 为六个文件、+177/-6:生产适配与投影 +55/-6,文档 +15,测试 +107。没有增加模块或 CLI 参数。
关键代码讲解
quotaSummaryReferences只遍历注册分组,按完整值比较;同 Todo id、相同标题均不足以合并。第一份记录保持完整,引用不形成链。不同 revision、ownership 和反证保持各自原值,未知字段、未知 lane 和不安全数字不参与复用。progressiveContextPlan把引用计划接入既有 owner,signed/already-projected 等分支保持完整。只有确实推迟 acceptance supporting material 时才更换那段 read guidance;纯 Todo 引用不会改变 pending acceptance 的全文读取义务。_capture_required_context先存原 archive,再在原 Python 数值上比较。整数/浮点类型或负零不同会使整次引用投影退回原文。整视图比较包含新增说明,小记录不会因引用而增加开销。
规范依据为变更前的 required-work-context.md:spec_ref docs/reference/required-work-context.md;spec_revision 447c35ed646a637d77ce4a27b5b60813cdd71efa。此文没有逐条编号,下面用原句映射既有要求,未另造验收标准:
| criterion_id(原句) | 本 head 的处置 |
|---|---|
| Required reads, full/delta preparation and recovery use that same model view. | implemented:冷读、delta、compaction 恢复仍消费同一个 required capture。 |
| Context delivery off remains unchanged. | implemented:关闭态、unsupported surface 和 signed envelope 保持原文。 |
| A full requirement tail must never be replaced by a summary. | implemented:展开逐项相等,末尾停止条件和反证保留。 |
| Distinct projected facts are never merged by Todo id or body text. | implemented:版本、归属、数值和未知分支分别验证。 |
| If the required view and its index are not smaller | implemented:继续原整视图大小回退,包含新增引用说明。 |
对主干的风险 / Risks
最大风险是 JS 数值往返或仅按 id 去重,导致错误地复用另一版本的约束。本次真实 CLI 反例覆盖 1/1.0、正负零、大整数、未知字段/分组、跨角色、pending acceptance、signed 和小记录。展开后用原 JSON 值比较,不把数值类型差异归一化。一个固定合成样本由 10,428 降至 5,763 UTF-8 字节;这只是该样本的传输观察。
| 独立执行 | 结果 |
|---|---|
| 相关 context/lifecycle/reader/diagnostic Python 测试 | PASS:423;70 项 native binary opt-in 用例 SKIP,未执行真实模型。 |
| 四个相关 TypeScript test 文件、control-plane typecheck | PASS:62 项;typecheck 通过。 |
| 固定相同 saved-CLI lifecycle,加“确实生成引用”断言 | 基线 FAIL:原 lifecycle 断言通过,但没有引用;本 head PASS。 |
| 新 wheel 的同一 lifecycle 和十项反例 | PASS:11 项;46 个真实 CLI 子进程均从新安装包加载,三个关键生产文件与该 head 一致。 |
标准 canary premerge --from-git-diff --git-diff-base origin/main |
PASS:6 direct、14 selected,0 manual holds;公开边界通过。 |
[P3] 在 saved-CLI 用例中断言引用确实生成。 test_saved_cli_references_keep_tail_constraints_and_recover_without_detail_reads 的展开检查也接受全部为 literal 的输入;将该冻结用例放到基线时,它的原有断言全部通过。若未来适配器停止应用引用、而 TS plan 仍正确,该集成用例可能漏报。建议在原用例补充至少一个 context_ref,以及包含说明后的 required view 小于原文的断言。本次独立 CLI 对照已验证当前实现确实生成引用,因此此项为非阻塞 test hardening。
语义与 CI 对齐
context_ref 是当前视图的派生展示字段,不是新任务状态或执行凭据。原 must_attempt、完整 required reads、freshness、恢复与一次结算规则保持原 owner;说明不能代替这些强制义务。按当前 wait_for_ci=false 规则未查询、轮询或等待 CI。没有修改预算、跳过规则或冻结阈值来获得通过。
我的整体评价 / Verdict
这是有实际消费者、可独立验证和回滚的 justified_increment:同视图精确复用已贯通保存、分页、冷读、delta 和 compaction;更广的上下文分阶段交付、真实宿主采用与完整费用/净成果仍未资格化。long_horizon 与 user_experience 判为 preserved;没有证据表明它改变后续任务义务,也不据字节减少声称理解或效果改善。
架构与范围相称,复用原 vocabulary、codec 与 capture owner。建议把已验证的引用存在性断言纳入现有集成用例;无需新增框架。visual_review 为 not_applicable:检查的变更路径没有 rendered presentation 变化;unverified_scope 为真实 native/model 采用、持续成本与长程收益。UI 截图不适用于本次投影切片。
English verdict: APPROVE — exact reuse, fallback and recovery are independently verified; the saved-CLI assertion improvement is non-blocking.
Native required context repeats the same complete Todo across several summary lanes, so cold reads and recovery can pay for the same constraints and evidence repeatedly. This change keeps the first exact record inline and represents later copies with a
todo_idand a JSON pointer into the same required view. It preserves lane membership, ordering, revisions, ownership, dependencies, negative evidence and final constraints. No extra detail read is needed for those references.The existing TypeScript quota projection owner builds the edit plan; the Python capture adapter checks equality against original values before applying it. Unknown row fields/schemas/lanes, unsafe numbers, signed envelopes and disabled native delivery retain their existing full behavior. The whole-view size comparison also includes the reference instructions and keeps small records inline when references would cost more. Acceptance-read guidance changes only when acceptance material is actually deferred.
Validation:
This is exact reuse within an already required view, not candidate relevance filtering or complete decision-stage loading. Preferences, Explore history and broader candidate staging remain separate work. Native-host behavior, total model cost, fees and long-horizon outcome gains are not established by these transport and lifecycle tests. CI was not queried under the managed review policy; exact-head independent review remains required before merge.