Skip to content

Recover original Turn settlement after task lease generation loss - #9242

Merged
loopx-agent merged 2 commits into
mainfrom
codex/execution-loss-closeout-repair
Nov 22, 2026
Merged

loopx-agent merged 2 commits into
mainfrom
codex/execution-loss-closeout-repair

Conversation

@loopx-agent

@loopx-agent loopx-agent commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • Written by: 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.
  • Implemented against quota settlement and recovery.
Criterion Disposition Implementation and evidence
Recover against the original prepared receipt and source authority implemented The canonical provider fence verifies original preparation and the newer current control writer in File and SQLite.
A typed blocked writeback settles once without debit or delivery implemented Preview, durable Run and event, exact readback and replay under the original identity.
Keep future work eligible through its own guard implemented The regression checks next-Turn admission with the original Todo still open.

Scope And Continuation

The new explicit refresh-state --execution-loss-closeout path 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

  • Tested revision: 4c0245593825d864b919e142f56813b4a55e7bf5.
  • Run state: completed for the targeted suite and standard premerge.
  • Input classes: synthetic and public fixture only.
Check kind Result Public-safe evidence
real_entrypoint / real_backend passed Real CLI and canonical File/SQLite production paths, including legacy aliases and exact-source Goals. The recovery, prepared-lease and closeout suite passed 125 cases.
regression_parity passed The new test drives an original prepared lease through a later generation, checks that the hold identifies the correct closeout route, and verifies that valid replacement proof can close only the original attempt. Valid same-generation recovery remains available. Stale or foreign proof and extra-effect inputs are refused. On the base revision, both provider regression cases incorrectly selected ordinary retry.
static passed TypeScript control-plane typecheck, Ruff, maintainability, public boundary, and staged RFC gate.
integration passed Repository-native standard premerge, including semantic drift, heartbeat quota flow, and public-boundary checks.

Frontend / Visual Evidence

  • UI impact: none. The existing App heartbeat and CLI render the typed recovery route and command. No visual surface or settings editor changes.

Type of Change

  • Bug fix
  • Documentation update
  • Test update

LoopX Area

  • Control plane

Boundary Checklist

  • Public-safe diff and validation.
  • No paired RFC changed.
  • Signed-off-by trailer present.

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]>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator 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)

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 完成判定。

关键代码讲解

对主干的风险 / 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.

@loopx-agent
loopx-agent merged commit 2ab0d1a into main Nov 22, 2026
10 of 14 checks passed
@loopx-agent
loopx-agent deleted the codex/execution-loss-closeout-repair branch November 22, 2026 05:04
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.

1 participant