Skip to content

perf(todos): limit replan reads to consumed views - #8624

Merged
cocolord merged 2 commits into
mainfrom
codex/todo-projection-transport-20261112
Nov 12, 2026
Merged

cocolord merged 2 commits into
mainfrom
codex/todo-projection-transport-20261112

Conversation

@cocolord

@cocolord cocolord commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Summary

Replan writeback needs two role summaries and complete Agent terminal rows. The previous proposal reused a broader quota helper that also built unused displays and prepared wait facts, increasing populated SQLite caller cost. This revision requests only consumed views through the existing TypeScript quota/display owner, keeps ordinary quota defaults and full-source fences, and records the scoped result in both RFC languages.

Validation

  • Source integration: 70 passed. Independently installed ordinary wheel: 69 passed plus the one production-scale fixture test passed after resolving its fixture imports to the installed package.
  • TypeScript projection, quota, replan and transport: 109 passed; control-plane typecheck and Python Ruff passed.
  • Exact-head standard premerge: 19 checks passed, including bilingual RFC and public boundary checks.
  • File and SQLite CLI success/rejection output matches immutable main. Original completed/archived Todo and later acknowledgement settlement tests: 8 passed on main and 8 on this revision. A dropped-recovery-detail mutation fails the independent full CLI oracle.
  • Six alternating pairs per workload on real isolated File/default SQLite, including up to 128 User rows and 0/320/3500 extra mixed-state Agent Todos. At 320/3500, SQLite qualifier medians are 93.2→83.3 ms and 612.3→572.0 ms. Canonical-read plus qualification medians are 139.4→130.0 ms and 900.9→857.0 ms. Strict refresh dry-run medians are 142.4→135.1 ms and 934.4→911.8 ms. The zero-extra refresh median is 28.9→29.3 ms and is retained without a noise/causality claim.

Scope and remaining evidence

The original proposal's 83.0→91.2 ms and 605.9→704.1 ms SQLite failures remain valid at its original head. The new scoped comparison qualifies the consumed replan read, while full CLI wall time, complete model/outcome costs and real user distribution remain unmeasured. Source/wheel provider consumers and original settlement are qualified; complete minimal loading/context closure, R1/M3, independent Standard packaging, workspace/meta publication and other-host adoption remain open. CI completion and merge readiness are separate from the local validation above.

@cocolord cocolord left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

APPROVE (author-owned COMMENTED review): I reviewed exact head 142cae7 for PR #8624.

This is a narrow positive transport change. Semantic replan writeback now consumes the Agent terminal source through the existing quota projection transaction instead of performing a separate planning source projection, while capacity resolution remains disabled for that writeback path. The new regression pins the transport shape and preserves the no-capacity-resolution boundary. Focused planning/quota tests, Ruff, and diff whitespace checks passed locally. No blocking findings from this review.

@cocolord cocolord left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机

复审精确 head 142cae772ef8e64fc02083a7101c358204868687。这个 PR 解决的是 semantic replan writeback 在同一 canonical Agent Todo source 上重复取数的问题:它已经有 quota projection transaction 可以提供 role summaries,却仍额外走一次 terminal planning source projection。继续保留这条重复路径会让 replan 写回的 transport 成本和观测面变宽,也让以后判断 source/lease/replay fence 时多一个不必要的调用边界。

改动思路

改动复用已有 select_quota_todo_contexts 作为唯一 projection transport,让 replan writeback 从同一次 quota projection 里拿 summary rows 和 Agent terminal display view。为了不改变 quota caller 的容量语义,新增的 resolve_capacity 默认保持 True,只有 replan writeback 显式传 False,这样写回路径不会把 available capabilities 解析成 capacity decision,也不会把 transport 收敛误做成行为放宽。

具体改动

相对当前主干,这个 head 只改 3 个文件,新增 56 行、删除 8 行。loopx/control_plane/todos/quota_summary.py 给 select_quota_todo_contexts 增加 resolve_capacity 开关,并保持默认 caller 行为不变。loopx/control_plane/work_items/semantic_replan_writeback.py 删除单独的 quota summaries 与 terminal planning inventory source 读取,改为一次 select_quota_todo_contexts(..., resolve_capacity=False) 后读取 agent_todo_display_views["terminal"]。tests/control_plane/test_canonical_planning_consumers.py 增加 regression,证明 replan writeback 只发起一次 bundled todo.read(kind=quota_projection),不再调用 todo.context.page。

关键代码讲解

  • select_quota_todo_contexts 的默认 resolve_capacity=True 保住现有 quota summary caller 的可用能力解析语义;False 只让非 quota 决策消费者复用同一 projection transport。
  • build_replan_writeback_context 使用 quota projection 的 Agent terminal display rows 作为 source rows,避免在同一写回上下文里重复读取 planning inventory。
  • 新 regression 锁定 transport 形状:Agent source selection 为 terminal display view,resume_options.available_capabilities 保持 [None, None],并确认没有额外 todo.context.page 事务。

对主干的风险

主要风险是把 quota projection 提供给 replan writeback 时误触 capacity 解析,或者把 Agent terminal rows 与旧 terminal planning source 的语义边界混淆。本 PR 用显式 resolve_capacity=False 处理第一类风险,用 regression 的 source flags、available-capabilities 保持值和 no-todo.context.page 断言处理第二类风险。已本地验证 tests/control_plane/test_canonical_planning_consumers.py 全部通过,canonical quota projection 与 legacy asset aliasing 相关测试全部通过,Ruff 针对三个变更文件通过,git diff --check 通过。远端 CI 仍在运行中,当前 merge readiness 还不能把它视为 ready。

我的整体评价

APPROVE。 这是一个窄的正向 transport 收敛:减少 replan 写回路径重复读取 canonical Todo source,同时保留 quota caller 的容量决策默认行为。当前精确 head 没有发现代码层面的阻断项;剩余合并门禁是外部 GitHub review requirement、CI pending 和仓库 readiness 重新读回,不是本地实现质量问题。

English verdict: APPROVE - exact head 142cae772ef8e64fc02083a7101c358204868687 reuses the existing quota projection transaction for replan terminal source rows while preserving quota capacity semantics through an explicit opt-out switch.

@loopx-agent loopx-agent 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.

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · max

本次评审对应提交 142cae772ef8e64fc02083a7101c358204868687。

[P2] 按写回所需字段读取,避免膨胀 quota 响应。 默认 SQLite 的 320 与 3,500 条额外 Agent Todo 夹具各做六次交替配对。资格检查中位耗时分别从 83.0 增至 91.2 ms、从 605.9 增至 704.1 ms。320 条时,观测到的 Effect 响应紧凑 JSON 合计约从 0.55 增至 1.39 MB。 写回入口

动机 / Motivation

长程 Todo 的 Agent 会在 refresh-state 的重规划资格检查中用到这份读取。原资格检查合并读取两个角色的摘要,再单独读取完整的 Agent 终态视图。File、SQLite 与旧格式内联来源都读回相同终态、frontier 和 replan obligation。新版本省去一次 todo.context.page。性能数据来自隔离本机的生产资格函数及真实 SQLite Effect 路径。全 CLI 另验证结算恢复。真实使用分布、整条 CLI 时延及托管 CI 未测量。默认 SQLite 的 320 与 3,500 条额外 Agent Todo 夹具各做六次交替配对。资格检查中位耗时分别从 83.0 增至 91.2 ms、从 605.9 增至 704.1 ms。320 条时,观测到的 Effect 响应紧凑 JSON 合计约从 0.55 增至 1.39 MB。

改动思路 / Approach

沿用现有 Todo owner 合理。写回请求的字段应匹配实际消费。生产改动限于现有重规划写回与共享 Todo 读取,CLI 参数、权限及持久格式沿用原合同。 写回需要两个角色的摘要和 Agent terminal 视图。现有 quota read 可以一次读取权威源。当前写回也取得普通 quota 的 User 显示行、Agent summary/planning 和预建等待数据。320 条时,未使用的 Agent summary/planning 与 User source_summary 合计约 499 kB,另含约 344 kB 的预建 Vision 等待事实。3,500 条时,新 quota 响应解压后是 12.22 MB。gzip 降低跨进程传输字节,本地仍处理完整数据。 共享读取 · TypeScript 投影

具体改动 / Changes

关键代码讲解

  • qualify_replan_writeback 取 display_views["terminal"],使用 resolve_capacity=False。普通 quota 的默认值仍为 True。 写回 caller · 共享 helper
  • select_quota_todo_contexts 为两个角色生成 wire。TypeScript 展开三份 Agent 显示视图,另为 User 生成 source_summary,为 Agent 准备等待和 lineage。 组装位置 · 结果编码
  • 新测试确认 todo.context.page 消失,并检查容量参数。File、SQLite 和旧内联来源的独立验证比较完整终态与实际决策。 回归测试

按本仓库真实入口验证合同,canonical_source 的三种来源和 same_settlement 的两种收口均已验证。caller_total_cost 在两个有额外 Todo 的 SQLite 规模仍有回归。 对应验收

对主干的风险 / Risks

  • PASS。File、SQLite 和旧内联来源在三种规模均得到相同终态、frontier、obligation 和 path delta。三份直接受影响的套件 44 项通过,扩展聚焦验证 53 项通过,标准 premerge 18 项通过。
  • FAIL。相同 SQLite 夹具做六组交替 base/head 配对。0 条额外 Todo 的中位数为 9.7 → 10.2 ms。320 和 3,500 条时分别为 83.0 → 91.2 ms 与 605.9 → 704.1 ms。计时覆盖 qualify_replan_writeback 及真实 Effect 往返。夹具复用已有四项完成链,另填充 open、blocked、deferred、done 和最多 128 条 User 行。 性能验证合同
  • FAIL / 已有。生命周期整组两版各 10 通过、12 失败。失败集中在旧 guard 对 settlement_progress 的同一断言。另以真实 provider readback 续跑 File/SQLite × 同轮/生命周期四种组合。两版均读到原绑定的 spend_required,执行一次扣额后读到 settled,重复执行无新增扣额,原完成证据不变。 UNVERIFIED。真实使用分布、整条 CLI 时延及托管 CI。

语义与 CI 对齐

普通 quota 的容量默认值、兼容输入和原 provider 回执在测试场景保持。补测沿用相同基线夹具及结算测试,计量每组实际生成的视图。 真实入口验证

我的整体评价 / Verdict

请限定现有 quota read 返回的视图,保留等待规则并复测两种出现回归的规模。生产改动限于现有重规划写回与共享 Todo 读取,CLI 参数、权限及持久格式沿用原合同。本次评审覆盖现有宿主与 CLI 行为。性能数据来自隔离本机的生产资格函数及真实 SQLite Effect 路径。全 CLI 另验证结算恢复。真实使用分布、整条 CLI 时延及托管 CI 未测量。

English verdict: REQUEST_CHANGES. 142cae7 preserves terminal evidence and removes one read. The broader projection increases SQLite replan qualification latency on both populated paired fixtures. Return only the views this caller consumes.

cocolord and others added 2 commits November 12, 2026 18:03
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
Signed-off-by: lusendong.6789 <lusendong.6789@bytedance.com>
Co-authored-by: TRAE CLI <traecli@bytedance.com>
@cocolord
cocolord force-pushed the codex/todo-projection-transport-20261112 branch from 142cae7 to e19dda2 Compare November 12, 2026 10:10
@cocolord cocolord changed the title Reuse quota projection for replan terminal source perf(todos): limit replan reads to consumed views Nov 12, 2026

@cocolord cocolord left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Reviewer: model_agent · GPT-6 · OpenAI · self_reported

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机 / Motivation

执行长程 Todo 的 Agent 在 refresh-state 重规划资格检查中消费这些读取。 旧提案把未使用的显示视图和等待事实带入每次检查;修复只返回消费的角色摘要与完整 Agent 行。 默认 SQLite 两种积累规模的真实 replan 检查变快,完整义务、拒绝提示及原结算身份保持一致。 本 PR 不完成最小加载闭包、发布独立 Standard 包,也不宣称模型收益。 完整加载/上下文闭包、workspace/meta 发布、其他宿主采用和端到端模型成本仍未证明。

这里的 replan 是根据当前工作与成果检查是否需要调整后续执行。旧 head 的 320/3,500 条 SQLite 负载曾从 83.0→91.2 ms、605.9→704.1 ms,减少一次 RPC 却增加了实际成本。本次重新评审完整 base-to-head,并保留旧观察;没有从旧 APPROVE 继承结论。

改动思路 / Approach

已有 TypeScript owner 负责选择和派生;Python 只组织一次读取并解码,完整来源与错误仍由原 owner 处理。 本 PR 只修复已存在 replan caller 的消费范围与成本,并记录双语验收结果。 最强的反对理由是:为一次读取再增加专用选择规则,可能引入重复 owner 和兼容负担。当前实现让同一个显示 owner 按已支持的 builder key 选择,保留默认全部三视图;新 Python 函数仅组织两个摘要与 Agent 完整行,因此这个反对理由没有成为当前阻塞。无持久状态、无新权限、无默认 provider 变化,原有 quota 调用继续准备自己实际消费的等待事实。

完整来源是这条路径的前提。省去的内容是 replan 不消费的视图,不是终态、租约、原 Turn 结算或错误恢复信息。公共 CLI 成功与拒绝输出在 File/SQLite 的固定基线和当前 head 一致,原完成证据通过现有 owner 回读和重复结算。

具体改动 / Changes

关键代码讲解

  • qualify_replan_writeback 通过窄读取取得两个摘要及 Agent terminal,继续把完整行交给 frontier;调用方。
  • select_quota_todo_summaries_with_terminal 只对 Agent 请求 terminal,不预建 User 显示或 Vision 等待事实,保留来源解码与完整性校验;读取组合。
  • projectTodoContextPage 延迟运行被明确选择的 builder,省略选择仍返回三视图,空/重复/未知 key 拒绝;projectTodoQuotaPlanning 只在消费显示时接受选择;显示 owner。
  • effect_runtime_result 校验请求的返回视图;未传选择时沿用三视图校验。测试覆盖 terminal 尾部、原错误、失联、源引用与普通显示;共享传输。

验收依据为 docs/development/testing-and-quality.md,固定版本 0abd0dc278bc2f735503e35f2368651ce6e13a21:canonical_source 通过真实来源、完整内联输入及完整诊断对照实现;same_settlement 通过基线/候选各 8 项原身份和重复结算检查实现;caller_total_cost 通过同负载真实默认 SQLite 配对实现。双语 RFC 只记录本次范围,未把 R1/M3 或完整最小闭包改成完成。

对主干的风险 / Risks

PASS:源码 70 项、安装 wheel 69 项加一项定向复跑通过,TypeScript 109 项通过,标准 premerge 19 项及 staged/exact-head 双语检查通过。安装包测试从独立环境解析真实 wheel;初次复制测试目录缺少 examples 与 TS 夹具模块解析,补齐这些测试输入后通过,产品源码没有因该问题改动。原完成/归档来源、失效引用、provider 失联与完整拒绝恢复已覆盖。

六组交替、同一合成状态的默认 SQLite 中位数如下;计时覆盖真实 Effect 往返,测量记录序列化置于计时之外。

额外 Agent Todo replan 资格检查 base→head canonical 读取加资格检查 base→head
0 14.6→12.1 ms 26.1→23.9 ms
320 93.2→83.3 ms 139.4→130.0 ms
3500 612.3→572.0 ms 900.9→857.0 ms

严格 refresh dry-run 在 320/3500 条时为 142.4→135.1 ms、934.4→911.8 ms;零额外行 28.9→29.3 ms 保留为观测,不推断噪声或因果。File 同样覆盖正确性、恢复与对照,并在两种积累规模变快。减少 RPC 或响应字段本身不是验收。刻意清空拒绝提示 next_cli_actions 的隔离 mutation 保留退出码 1,却使真实 CLI 的非空恢复提示 oracle 失败;当前 head 通过同一检查。

语义与 CI 对齐

optional view names 复用既有显示词汇与 owner,不增加 prose 分类或模型义务。普通 quota 默认三视图和等待准备保留;读取不写 provider,权限、scheduler、lease 和扣额规则保持原合同。CI 仍有 pending job,作为诊断与独立 merge-readiness 状态记录;本地必要验证已经覆盖当前变更,未宣称 CI 成功。完整 CLI 墙钟、模型效果、真实用户分布和其他宿主采用为 UNVERIFIED。

我的整体评价 / Verdict

这是有独立价值、可回滚的 justified_increment。long_horizon 的已测调用成本 improved,重复工作与原结算保持;user_experience preserved,没有增加导航、输入或确认轮次。检查 semantic_replan_writeback 到 quota_summary 的路径,未改变渲染页面、CLI 控件或任何首屏内容。 视觉未验证范围为 none。兼容边界保留有明确消费者的默认视图和原回执,应用的简化是去掉未消费计算;没有要求新的跟进流程或把动态 builder 当成新状态词汇。

在 head e19dda2821a7e72a08f86cbcc1421c7494a7d6e4 未变且必要验证通过的前提下给出 APPROVE。原 head 的性能失败保留;旧阻塞评审只能在每项发现已验证解决后通过原生 dismissal 协调,合入授权与 CI/readiness 单独判断。完整加载/上下文闭包、workspace/meta 发布、其他宿主采用和端到端模型成本仍未证明。

English verdict: APPROVE. e19dda2 returns only consumed replan views, preserves complete File/SQLite and supplied-source behavior, and improves the populated default-SQLite caller. Source/wheel, original settlement, TypeScript and premerge checks pass; pending CI and unmeasured whole-kernel/model outcomes remain separate.

@cocolord
cocolord dismissed loopx-agent’s stale review November 12, 2026 10:18

Resolved at e19dda2 and independently re-reviewed in review 5872692581. Replan now requests only two summaries plus Agent terminal; ordinary quota wait preparation remains unchanged. Six alternating populated SQLite pairs improve 320/3500 qualifier medians to 83.3/572.0 ms versus latest-main 93.2/612.3 ms. Full source/wheel provider, terminal-tail, source-fence and original settlement checks pass. Original negative measurements and discussion are retained. Maintainer-authorized reconciliation of this verified P2 finding.

@cocolord
cocolord merged commit 708c68e into main Nov 12, 2026
20 of 21 checks passed
@cocolord
cocolord deleted the codex/todo-projection-transport-20261112 branch November 12, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants