Repository navigation
Recover original Turn settlement after task lease generation loss - #9242
Conversation
Adapt the independently verifiable execution-loss closeout slice from #9153. Surface it from prior-Turn recovery without opening the original business execution lane. Co-authored-by: lusendong.6789 <[email protected]> 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.
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · reasoning_effort=xhigh
动机 / Motivation
File 和 SQLite 在基线都把已换代的原准备租约分到 resume_prior_turn,回归在恢复路线断言处失败。 这会耗完当前恢复机会,并持续阻挡下一轮。使用心跳恢复先前任务的注册 Agent,以及需要解除旧轮次卡点的维护者。需要一种能从旧准备回执验证失效、并能安全关闭原轮次的路径。预演保持状态原样,提交后原轮次结算为已阻塞且免扣额度,重试只读回同一份回执,Todo 可以被下一轮正常准入。
File 和 SQLite 在基线都把已换代的原准备租约分到 resume_prior_turn,回归在恢复路线断言处失败。File 和 SQLite 识别到原代际已被替换,给出行政结算预演,仍禁止交付和扣费。预演保持状态原样,提交后原轮次结算为已阻塞且免扣额度,重试只读回同一份回执,Todo 可以被下一轮正常准入。
原业务效果、其他存储提供者和 #9153 的原生 Host 报告改动在本 PR 范围之外。
改动思路 / Approach
先读回权威租约代际,再由同一控制面在写入时独立验真,可以让普通心跳发现故障,也能防止过时的建议变成写入授权。 本次交付覆盖已有 File 和 SQLite 租约写入边界、原轮次的免扣额度收尾和下一轮的正常准入。 这次复用了 #9153 中受约束的结算路径,并把它接到现有的恢复预检与结算读回。租约代际未变时继续原恢复方式。已换代时,先核对当前 writer,再预演免扣额度结算。
| 观察到的状态 | 现有入口给出的处理 |
|---|---|
| 原代际仍有效 | 走原轮次恢复 |
| 代际已换,当前凭据可验证 | 预演并显式结算原轮次 |
| 代际已换,当前凭据不可验证 | 维持等待并给出凭据检查办法 |
具体改动 / Changes
评审依据是 docs/quota-allocation.md 在 43b7e58204bb5410d629f11555b308e7d0fc807b 中的合同。 prepared lease 确定原轮次和原执行权。 typed_blocked_writeback_no_spend 负责在有凭据证明执行权已经丢失时结算原轮次。 receipt progress 用新产生的可信结算回执解除下一轮卡点。File 和 SQLite 识别到原代际已被替换,给出行政结算预演,仍禁止交付和扣费。预演与提交都核对原回执和当前凭据。CLI 真实入口在 File 和 SQLite 上验证两种 Goal 注册归属。存储沿用原 Run、索引和回执,Python 入口只转发参数,TypeScript 完成判定。
关键代码讲解
preflightPriorHostTurnCloseout在原轮次的首笔写回确实缺失时读取当前代际。当前 writer 不可用时,心跳返回需要补齐的凭据。commitExecutionLossCloseout在既有写入边界内校验原回执、当前凭据和作用域,对明确提交持久化只结算一次的 Run 和事件。readQuotaSettlementForAdmittedOwnerFromSnapshot将验证后的阻塞回执投影为已结算、免扣额度,后续心跳可以通过正常准入判断。
对主干的风险 / Risks
最重要的反例是替换租约被借来掩盖已经完成的业务或失败的扣费写入。提交会在写锁内核对原准入、当前租约及注册和账本状态;已有完成或扣款、过期凭据、其他 Agent 和越界输入都不满足条件。125 项相关测试和 19 项标准预检通过,基线两种后端可稳定复现错误恢复路线。旧版读者无法解释新免扣额度回执,运维回退期间需要保持具备该读回能力的版本。按 Goal 配置使用本地预检,远端 CI 未查询。
我的整体评价 / Verdict
当前版本能让正常心跳从可验证的执行权变化得出对应的恢复办法。真实 CLI 验证了原轮次身份、免扣额度、Todo 可续接和提交幂等。这次变更涉及心跳指令和 CLI 结算回执,评审核对了合同载荷,界面渲染没有改动。安装采用和运行时模型后续执行待实机验证。
English verdict: APPROVE - head 4c0245593825d864b919e142f56813b4a55e7bf5 detects fenced prior-Turn recovery and provides an exact-identity no-spend closeout verified against File and SQLite.
Goal And Delivered Outcome
A prior Turn whose prepared task lease was replaced can repeatedly enter a recovery guard that cannot legally resume the original execution. The final recovery contract now distinguishes a fenced generation and routes it to administrative closeout of the exact original Turn. A verified blocked closeout settles without charging quota and leaves the Todo available for a fresh admission.
Author Declaration
model_agent, OpenAI Codex GPT-6 family. The fenced closeout mechanism is adapted from the independently scoped portion of #9153, with attribution in the commit.Scope And Continuation
The new explicit
refresh-state --execution-loss-closeoutpath accepts only blocked, no-spend intent. Preview runs the same identity and provider qualification without creating a Run or effect. Existing ordinary execution, Todo completion, foreign ownership and debit fences still apply. A missing active proof produces actionable recovery guidance while preserving the existing hold. Neither a new execution provider nor migration of historical receipts is required. This PR does not carry over the native Host or reporting changes in #9153.Validation
4c0245593825d864b919e142f56813b4a55e7bf5.Frontend / Visual Evidence
Type of Change
LoopX Area
Boundary Checklist