Repository navigation
Recover an interrupted Turn when the original worker lease has been replaced - #9304
Conversation
Signed-off-by: LoopX Agent <[email protected]>
Signed-off-by: LoopX Agent <[email protected]>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
正在恢复一次已准入工作、后来由系统换发执行租约的 CLI 或 Codex App 操作者。 基线的 prior-Turn 检查跳过正在重试的回合。操作者沿原回合重试时仍遇到原 lease identity conflict,无法通过该重试发现可执行的收尾路径。 在原回合重试中发现已存在的无扣额收尾,保留原回执、Todo 状态和 lease 权限。
File 和 SQLite 上同一原回合丢失 prepared lease generation,由同一 Agent 获得新租约。使用原 Turn ID 重试,Todo ID 分别显式给出和从回执推断。 基线返回 heartbeat_receipt_identity_conflict。候选在通用 CLI 与 Codex App 两个 guard 入口均返回原 Turn 的 execution_loss_closeout 预览。已验证提交一次、再次执行给出幂等回执、Todo 保持开放且无扣额。
原 generation 保持,或原回合早已 settled,或替换 lease 属于同 Goal 的另一 Agent。 必须区分普通继续、原回合已结束和需要当前 control writer 的无扣额收尾。 同 generation 两边保留普通继续,已结算回合两边继续 skip。另一 Agent 获得 lease 时,候选进入 control writer 等待,实际 closeout 的外部适用性仍由旧 owner 拒绝。 实际验证的是 File/SQLite 的两种 quota guard 配置和收尾回读。SourceSession 精确根的直接 generic guard 在两边均遇到原有 collection error。已有精确根收尾本身受回归套件覆盖。
改动思路 / Approach
Python 从已绑定的原回执和当前准备信息决定是否附加查询。TypeScript settlement owner 用原事实和 canonical lease 核实,仅在旧路径应收尾时重用 recovery plan。 保留已有 prior debt 扫描与收尾 owner,仅在发现原准备代次可能丢失时把同一回合加入查询。校验和提交继续走已有操作。
具体改动 / Changes
关键代码讲解
评审头 f15d38f,合并基线 3070de3。5 个文件,+83/−3。 依据 Original prepared generation replaced 和 No-debit recovery and current writer proof 核对现有入口。 仓库规范 原有收尾 owner
- _prepared_execution_needs_readback。按原 OPEN 阶段、绑定 Todo 与 lease epoch 判定是否要查询。 代码
- _prior_closeout_preflight。在现有 source admission 内向 typed owner 发只读查询。 代码
- preflightPriorHostTurnCloseoutForOwner。先查旧债,然后只在当前候选通过 lost-generation 证明时提供原回合的恢复计划。 代码
- observeFencedExecution。从 canonical lease 验证原代次已被替换,再判断当前控制写入者。 代码
对主干的风险 / Risks
语义与 CI 对齐
定向 205 个 TS 测试通过。两组真实 provider 各复跑 5 种状态、4 种 guard 参数组合。 另有候选 47 项和基线 45 项 Python 收尾、恢复准入回归通过。Quick premerge 的 6 项直接和 4 项选中检查通过。 这里验证到 CLI 的 Codex App guard 路由。正式安装的桌面执行体验和独立的 SourceSession guard 待另外资格确认。
我的整体评价 / Verdict
同意此提交的代码改动。租约不同代时仍先预览,再由已验证的当前控制写入者收尾。普通工作与消费 continue 仍走自己的前置条件。 依同一原回执重试可读到唯一收尾,新回合仍使用普通工作入口。
English verdict: APPROVE — the original Turn can discover the existing no-debit closeout after lease replacement without widening delivery or writer authority. Exact head f15d38f.
BigDataDZ
left a comment
There was a problem hiding this comment.
独立评审(native Windows 环境)——APPROVE
独立核对 head:f15d38f88(refactor(quota): isolate the prepared lease readback decision)。未沿用既有评审结论;本地真实 Windows 全量执行本 PR 的测试文件:
tests/control_plane/test_execution_loss_closeout_cli.py→ 15 passed, 4 skipped。4 个 skip 均为requires directory symlink privileges的既有环境条件,不涉及本 PR 行为面;新增的test_original_turn_reentry_projects_execution_loss_without_repeating_work在 file/sqlite 双 provider 下均通过。
代码审查结论:
- 自阻塞守卫正确:
currentTurn候选仅在executionLoss成立时进入 closeout 指令(if (currentTurn && !executionLoss) continue),且missingReceipts === null时currentTurn直接跳过——重试者不会因扫描到自己而再次阻塞,也不会为未经证明的丢失发出无谓指令。 - 既有债务优先序保持:
bound.candidates追加在 prior 扫描结果之后,persisted newest-first 顺序未被扰动;turnsValidated合并计数保留了预算语义。 - 触发条件收敛:
_prepared_execution_needs_readback仅在OPEN回放阶段 + prepared lease 存在 + 当前投影与回执 epoch 不一致时才请求 readback,普通重试路径不增加额外 IO。
一个非阻塞观察(性能层面,不要求本 PR 处理):prepared_lease_epoch 与 execution_preparation.lease_epoch 的相等比较依赖两侧字段类型一致;若历史投影一侧为字符串一侧为数值,将恒不相等并使每次 OPEN 阶段重试都请求一次 readback。当前两侧同源产出类型一致,故仅作记录。
文档双语更新与行为一致。
|
补充说明:我那票批准的范围 我的 APPROVED(2026-11-23 13:23 UTC)依据两件事:通读了全量 diff;在 native Windows 上运行了本 PR 的测试文件 但有一点我批准前没有检查,也没有写明:该 head( 合并后我试着确认包含本次改动的完整套件是否在别处跑完:合并提交 就我验证过的范围,行为与 PR 描述一致,我没有发现改动本身有问题。这条说明只是把批准的依据和缺口讲清楚。如果流程上需要,建议在包含 |
Recovery behavior
Retrying a failed writeback with the original Turn ID could return the same receipt identity conflict on every attempt, even though the registered worker could already preview an administrative closeout. The prior-Turn recovery scan excluded the Turn being retried.
The guard now asks the existing settlement owner to inspect the original Turn when its prepared lease may have changed. Earlier debts keep their ordering. The owner checks the original receipt, current canonical lease and absence of settlement effects before offering the existing no-debit preview. The preview and commit retain their existing ownership checks.
Verification
f15d38f8896c, 63 focused tests and all 17 standard premerge checks passed. The first patch exceeded the decision-function complexity limit. This revision isolates the receipt comparison and passes the original limit.