Repository navigation
Combine writeback and quota spend for ready native heartbeat Turns - #8396
loopx-agent wants to merge 3 commits into
Conversation
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
…lement-plan-20261109 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, gpt-6.1-sol, OpenAI, runtime_reported, reasoning_effort=max
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
动机 / Motivation
Codex App heartbeat 执行完已准入的 Todo 后,需要按当前计划完成写回和一次扣额。基线在写回后还需执行单独的扣额命令,读到的是同一个 Turn 的回执。当前提交在预先持有租约时能把两个命令合为一个,并保留原回执及中断恢复。评审覆盖原生准入、计划投影和 File/SQLite 的同一轮结算。先准入、再领取、同一轮复查时,候选仍给出两个命令;这条常用路径没有获得承诺的收益。
改动思路 / Approach
用原 TypeScript 结算计划和既有 refresh-state 执行器;投影不写入状态或发放权限。 评审覆盖原生准入、计划投影和 File/SQLite 的同一轮结算。计划在当前原生会话、已就绪的 Todo 和原回执对齐后替换命令,把扣额交给既有执行器。失败后读回原 settlement_owed,身份、租约和已结算回执仍由原 owner 核对。
具体改动 / Changes
评审 4cdb214,PR 基线 c9c0644;实际主干 c44eb15 的图表改动与结算路径不重叠,合并树干净。8 个路径,+286/−26。对照 原回执结算契约:ready-native-composition 尚缺常规领取后的路径;exact-recovery-and-accounting 与 ordinary-and-off-parity 有独立验证;model-and-installed-qualification 另行验收。
关键代码讲解
_prepare_quota_result_context只在原生 Codex App、progressive JSON 捕获和正常交付时调用 TypeScript 投影。拒绝的 guard 保留原诊断;未启用或无原生会话时,仍走已有计划。发布入口composedCliSettlementChannel保留验证、写回、扣额和有条件的终态步骤,把扣额执行交给既有refresh-state --settle-turn --settlement-receipt。首读只隐藏与计划完全重复的后备命令,原 capture 和恢复仍可读。计划 · 首读nativeCliSettlementProjection在核对完整身份前,只接受committed和replayed。现有回执 owner 在同一轮由待领取转为就绪时会写入upgraded;它也带着原 Goal、Agent、Todo、Turn 和已就绪状态。当前分支
对主干的风险 / Risks
P2 · 领取后的正常就绪 Turn 没用上组合命令。 File 和 SQLite 的真实 CLI 对照先读到 claim_required,再领取该 Todo,随后用同一 Turn 复查。复查得到 ready、closeout_required=true 和与计划完全相同的 upgraded 回执,但候选和基线都仍显示 v1、两个命令。候选的预先领取对照则显示 v2,一个命令读回三份回执。所有路径最后均只扣一次,重放不再扣额;显式 off 和无原生会话仍按原两步。请复用原回执资格判定,覆盖已核对的升级回执,继续拒绝身份不一致或不可交付的情况。
我的整体评价 / Verdict
请求修改常规领取后的路径。复用既有执行器的范围合适;同一轮写回、原回执恢复和一次扣额的约束应保留。两版各 8 个独立 provider/入口对照完成;334 个 Python 用例通过、1 项跳过;252 个 TypeScript 用例与类型检查通过,standard premerge 的 6 项直接检查和 19 项自动检查通过。安装后采用、模型输入保留和完整成本仍待另行验证。
English verdict: REQUEST_CHANGES. An ordinarily claimed native Turn is ready with an exact upgraded receipt but still gets the two-command plan on File and SQLite. Include the qualified claim/reentry route while preserving the one-debit guarantee.
| if (!cli || cli.selection_required === true || cli.spend_after_validation !== true | ||
| || preparation?.schema_version !== EXECUTION_PREPARATION_SCHEMA_VERSION || preparation.state !== "ready" | ||
| || preparation.delivery_allowed !== true || receipt?.closeout_required !== true | ||
| || (receipt.status !== "committed" && receipt.status !== "replayed") |
There was a problem hiding this comment.
[P2] 覆盖正常领取后已就绪的回执
先执行原生 guard,得到 claim_required;领取该 Todo,再用同一 Turn 复查。File 和 SQLite 都得到 ready、closeout_required=true,且 upgraded 回执的完整身份与计划相同。这里仅允许 committed/replayed,候选仍投影 v1 并需要另一次扣额命令。预先领取对照在两后端均只需一条命令;两条路径最后均只扣一次。请复用原结算的资格判定,覆盖已核对的 upgraded 回执,并补实际先 guard、再领取、同一 Turn 复查的回归用例。
A ready native Codex App heartbeat now advertises one writeback command that also runs the owed quota spend. It uses the existing
refresh-state --settle-turn --settlement-receiptentry point and binds both receipts to the admitted Todo and original Turn. An interruption after writeback returns the same Turn'ssettlement_owedcommand.The projection requires an active native session with Progressive delivery, a ready Todo and a matching committed or replayed receipt. The initial read omits the duplicate fallback command when the ordered plan already supplies it. Stateless file-based context reads and
--context-delivery offexercised the original two-command route. C1 can reuse the same TypeScript plan function from its existing composition call. Related to #8266.Matched CLI replay
Each variant used three fresh isolated runs per backend. The measured path runs the guard, reads all initial pages and settles one Turn. Every run produced one heartbeat receipt and one quota debit. The supporting receipt snapshot is read on demand.
Generating the combined route reduces required stdout by 30.9% against the default main plan. Most of the savings come from the existing combined receipt. The first-read projection removes a further 277–281 bytes compared with opting in manually. The legacy publisher adds one local projection call, and total framed bytes increase 2.9% against the default plan. Selecting only the optional settlement identity adds one CLI call and about 1.1 KB of stdout. The three-run wall-time medians moved in opposite directions across File and SQLite against the default plan. Model tokens, retention and accepted outcomes require a matched model run.
Validation
4cdb2142b5afac812dc0143f8e8d45875860d21dagainst mainc9c0644be428bbb0ab10726637f5b36602972912.