Skip to content

Guard external provider starts across handoffs and verified restores - #9520

Open
hhyykk wants to merge 4 commits into
mainfrom
codex/external-operation-recovery-lint
Open

hhyykk wants to merge 4 commits into
mainfrom
codex/external-operation-recovery-lint

Conversation

@hhyykk

@hhyykk hhyykk commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Goal and delivered outcome

Keep one business delivery from becoming two when a successor starts from a verified backup taken before the original request. The official restore stays inert. If an operator copies the recovered runtime and supplies fresh admission, the governed write path now requires independent service evidence before it can send.

Independent loopback HTTP experiment Before this revision With this revision
Service delivered, dropped its reply, successor blindly retried 2 inbox rows 1 inbox row
Service terminated before delivery, successor blindly retried 1 inbox row 0 inbox rows, held for reconciliation
Service terminated before delivery, successor reconciled and obtained a single-use service grant 1 inbox row 1 inbox row

Both versions used the same synthetic service, backup timing, original provider fixture and business key. The oracle counted persisted SQLite inbox rows outside the LoopX backup. The service committed its terminal observation and then closed the connection without an HTTP reply. The preceding revision was ff82e2693. The first verified-restore revision was 6ca092ab4.

Reservation checkpoint follow-up

Commit bcd6b6f72 addresses the review of the previous head. It leaves the local attempt unarmed while the service is deciding whether to reserve delivery. The validated grant and the dispatch boundary are published in a single durable journal update immediately before provider invocation. Starts sharing the same Todo operation serialize while other Todo operations can obtain their grants independently.

A real child process exited before the reservation lookup, after the service issued its grant but before the caller received it, or after actual delivery but before local result persistence. Both the original Turn and a successor attempted recovery in separate runs. Four of the six cases failed on the previous head. All six passed on the new head. The lost-reply case held until the fixture service reconciled and revoked its unconsumed grant. Each recovered history ended with one recorded delivery. On this head, 145 focused Python tests passed, including an unrelated-Todo progress control. The HTTP lost-acknowledgment and concurrent independent-restore exercises also reproduced their expected delivery counts.

Implementation

  • The backup verifier marks extracted runtime roots, including separate source runtimes. Preview and fresh dispatch inspect the Goal's runtime and the selected journal location. A custom journal directory does not bypass a marked Goal.
  • Original-result readback uses current runnable handoff admission with the original effect and request. On a restored runtime the service must attest the original request digest and target. Validated results use the existing writeback-before-spend path. Restored polling requires a trusted read of the running result.
  • Conditional redelivery requires an atomic service reservation after terminal no-effect. The receipt binds the business operation, material input, current invocation and a fresh challenge. The runtime checkpoints the grant and forwards it to the provider to consume with delivery. A missing, stale or mismatched grant holds dispatch.
  • Pre-dispatch journal checkpoints distinguish a prepared attempt from one that may have reached the provider. A process exit before arming permits recovery. An armed attempt with unknown outcome still requires readback. Legacy uncertain reservations remain held.
  • The original commit also guards direct profiled dispatch and checks the supported raw transport entry points with Ruff and a TypeScript syntax check.

Local verification

  • At 6ca092ab4, 138 focused Python tests passed. They cover real backup publication and verification, original and successor admission, split journal directories, service readback, writeback/spend replay, a stale grant and subprocess exits before dispatch.
  • With two concurrent restored processes waiting at the provider reservation boundary and separate journals, the service granted one request, refused the other and delivered one inbox row. A backup produced by the previous version was also recovered by the new verifier with its data intact and its extracted runtime marked.
  • The broader local development run reported 2,156 passed, one failed and one skipped. The failure was a Lark fixture requiring a non-Git parent. The host temporary directory had a Git boundary. The same case passed under a non-Git temporary root. The skip is Windows-only.
  • Both Ruff boundary scans, the actual JS/TS transport scan, 15 Node tests, TypeScript compilation, repository mypy and the three changed Python modules, and the bilingual RFC diff gate passed locally.

Integration and deployment boundary

The service adapter must retain a business audit independent of the restored host, fence outstanding work and atomically consume its grant. A provider without that primitive remains held for reconciliation. A raw filesystem rollback, an old unmarked extraction, selectively omitted marker or older writer is outside this interlock. Quiesce older writers for rollout. No production system was used in the experiments.

Author declaration

Written by OpenAI Codex. All commits carry DCO sign-offs. No UI change.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-28T03:36:58.433016Z 0075cd1 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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.2-sol · OpenAI · runtime_reported · xhigh

需修订 ff82e269396f356ec65b88805d537bf1eedddd9c。 防重复启动的用例通过,两处恢复缺口经隔离测试确认。

  • [P2] 调用前中断会留下无法恢复的预留。 提供方尚未调用即中断,基线同一轮重试启动一次;候选留下没有原始 journal 的预留记录。原 Turn、新 Turn 和 reconcile 都无法推进,提供方调用数保持 0。 让预留与可恢复的启动意图通过同一个原子记录发布,或在持锁期间按可靠证据恢复明确尚未派发的预留。保留已派发但结果未知时的禁止重发。 预留与原件写入
  • [P2] 接手者有可靠回执时仍无法恢复。 提供方调用一次且保有可读回执时,原身份搭配接手者的当前授权被拒绝;换用接手者的新身份找不到原 journal,普通 reconcile 也拒绝。原 Turn 仍可执行的对照能只读恢复。 为只读恢复绑定原 journal 和受理来源,并独立验证当前接手者对同一操作的恢复权限。结算继续使用原操作身份,无需获得新的启动资格。 读取原回执 现有 reconcile

动机 / Motivation

受影响的是在外部提供方写入后需要重试、恢复或交接同一个 Todo 的集成调用者。
提供方可能已经接受写入,LoopX 却还没保存回执。候选拦住了重复启动,但有两种故障会让同一工作无法接续。
重新进入时应从原操作身份判断能否安全继续,保留有效授权,并在已有可靠回执时恢复观察和结算。
独立验证使用两个固定提交、真实本地子进程、隔离的临时存储和合成提供方。没有调用生产提供方,托管 CI 与 SDK 内部行为未验证。

改动思路 / Approach

复用已有的 profile、Turn 准入、结果校验与写回先于扣额的顺序。跨轮预留有明确目的。原 journal 和预留分别落盘会留下既不可对账、也不能恢复的中间状态。有回执的另一条路径也需要把当前接手权限与原效果身份同时带进只读恢复。

具体改动 / Changes

关键代码讲解

  • _record_start_intent 把原有 per-invocation journal 用目录索引关联到同一操作。在首次写入原件前已经落盘的标记会被后续请求持续视为占用。预留
  • start_governed_external_capability 在有原件时可接收只读回执,但重新检查的仍是原 Turn 的运行权。接手者的当前 Turn 无法沿原身份进入该分支。启动与回执读取
  • reconcile_governed_external_capability 沿已有 journal 轮询和结算,缺少首个结果时直接退出。现有结算入口

基线 0bcdffb9926e46a1024bcdacb18e24de37a1b018 的 docs/reference/extensions.md 定义了从持久 journal 沿原身份恢复。当前头的 External capability journal recovery 在以上两条路径仍未实现。11 个文件 +514/-36,其他改动包括传输入口限制、CI 源扫描、文档和测试。基线恢复契约

对主干的风险 / Risks

基线和候选使用同一故障位置。提供方启动前子进程中断,两边均无 journal 或提供方调用。基线的同轮重试随后启动一次。候选相同轮次和后续轮次均拒绝,原身份 reconcile 报调用不存在。候选在可捕获的预派发 I/O 异常下可以重试,说明受阻的是进程中断后留下的记录。

另一组由合成提供方实际保存回执,本地结果 checkpoint 随后失败。接手者的当前授权无法用于原身份,只沿新身份又找不到已有操作。匹配的原运行准入仍能读取回执,调用次数保持一次。请补接手者沿原操作恢复及一次结算的回归,同时保留不允许的新启动。

语义与 CI 对齐

159 项 Python、14 项 TypeScript 生命周期、1 项 Node lint 夹具通过;两项 Ruff 源扫描、当前树 JS/TS 扫描、TS 类型检查、Git diff check 通过。 现有用例证实跨轮拦截和签名身份一致性。额外的恢复对照指出了首个 journal 与接手权限的缺口。两组都使用本地测试数据,生产服务、托管 CI 和平台升级边界仍未验证。当前未增加新的公开生命周期词汇。

我的整体评价 / Verdict

跨轮防重是可交付方向,当前恢复设计仍会阻断可继续的工作。请让调用前中断可恢复,并给有当前权限的接手者一个沿原身份读回的入口,再用同一回执与结算验证两处故障。

English verdict: REQUEST_CHANGES at ff82e26. A pre-dispatch interruption leaves an unrecoverable reservation, and a current handoff cannot recover a known result under the original invocation identity.

@hhyykk hhyykk changed the title Guard external provider starts across handoffs and lint transport entry points Guard external provider starts across handoffs and verified restores Nov 27, 2026

@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.2-sol · OpenAI · runtime_reported · xhigh

Request changes conclusion

Exact head: 6ca092ab4262356574a5ec05733e4fc42f841ae8

[P2] 恢复态在查询服务预留前中断会卡住所有重试。 本地真实子进程在预留回调第一行退出 73。journal 已标记 dispatch_armed=true,且没有服务预留。原 Turn 与正常准入的接手 Turn 都在查询服务前被拒,查询和派发均为 0。原效果只读查询按预期没有结果。同一服务在独立的干净 journal 对照中签发预留,并成功派发 1 次。 在取得并持久化服务预留以前保留未派发状态。若服务应答丢失,由可信服务先对账未消费的 grant。只有即将进入交付调用时才持久化 armed 边界。 相关代码

动机 / Motivation

从已验证备份恢复的 host adapter 需要在独立服务证明先前尝试无效果后安全启动一次。旧评审头在首次写 journal 之前退出会遗留孤立预留。新头先持久化未派发状态,普通路径成功恢复。恢复态另有取得服务预留的检查点。恢复态若在首次查询预留时退出,原调用和同目录的后续 Turn 都无法到达服务,即使服务可以证明没有派发并重新授权。覆盖隔离的已标记 runtime、本地服务夹具、真实子进程退出和正常交付对照。线上服务、实际主机升级与远端 CI 尚未复核。

改动思路 / Approach

复用现有 start/reconcile、共享 writeback/配额结算和原调用身份。保留现有 journal 和可信服务围栏,在同一生命周期中分别记下服务预留阶段和可能交付的阶段。修复聚焦恢复态的检查点顺序,并保留 provider 原调用只读恢复、服务判定及原工作授权。

具体改动 / Changes

按 6ca092ab4262356574a5ec05733e4fc42f841ae8 的规范核对 恢复后凭服务证明启动一次 与 确定未派发时可恢复。外部派发门在服务查询前已关闭恢复重试,实际子进程和正常对照区分了 journal hold 与服务拒绝。 规格与回退边界

对主干的风险 / Risks

本地真实子进程在预留回调第一行退出 73。journal 已标记 dispatch_armed=true,且没有服务预留。原 Turn 与正常准入的接手 Turn 都在查询服务前被拒,查询和派发均为 0。原效果只读查询按预期没有结果。同一服务在独立的干净 journal 对照中签发预留,并成功派发 1 次。222 项 Python 检查及 1 项 Node transport 检查通过。普通路径的前置写入中断已复验,同一调用重试只派发一次。服务已签发而本地没收到应答时仍要通过服务对账。这个反例更早发生,服务侧没有待处理 grant。

语义与验证对齐

普通进程重启可永久搁置已完成服务端核实的业务写入。该状态没有 provider result 可供原调用的只读恢复消费。在取得并持久化服务预留以前保留未派发状态。若服务应答丢失,由可信服务先对账未消费的 grant。只有即将进入交付调用时才持久化 armed 边界。覆盖服务查询前、服务签发后但本地记录前,以及已 armed 的交付中断三种恢复窗口。

我的整体评价 / Verdict

恢复态若在首次查询预留时退出,原调用和同目录的后续 Turn 都无法到达服务,即使服务可以证明没有派发并重新授权。覆盖隔离的已标记 runtime、本地服务夹具、真实子进程退出和正常交付对照。线上服务、实际主机升级与远端 CI 尚未复核。

English verdict: REQUEST_CHANGES at 6ca092a. A process exit before the restored-start reservation lookup leaves an armed journal with no grant. Both retries fail before querying the service, although a clean control delivers once.

Signed-off-by: Codex <codex@localhost>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bcd6b6f722

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +239 to +241
undispatched = previous.get("dispatch_armed") is False and previous.get("provider_result") is None
if not undispatched and previous.get("status") != "committed":
raise ValueError(f"external write is unsettled; reconcile original invocation {reservation.name}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep new start-admission decisions in the TypeScript lifecycle owner

For cross-Turn retries, this introduces a Python decision owner for whether an external write may start, alongside the existing lifecycle validator in loopx/control_plane/governed_capability.ts. The restored-reservation authorization is also implemented exclusively in Python; the TypeScript owner never interprets dispatch_armed or restored_start_reservation. This splits the lifecycle's safety invariants between two semantic owners, contrary to AGENTS.md's explicit requirement not to create a parallel Python decision owner. Extend the existing typed lifecycle owner to decide retry eligibility and validate reservation facts, while retaining filesystem locking, durable writes and provider calls in the Python IO adapter.

AGENTS.md reference: AGENTS.md:L295-L300

Useful? React with 👍 / 👎.

@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.2-sol · OpenAI · runtime_reported · xhigh

Request changes conclusion

Exact head: bcd6b6f722daef5ae8f150a133d656c90e3549cf

[P2] 恢复派发权限的判定仍分散在 Python 适配器和 TypeScript 生命周期之间。 当前头把未派发、可重试和持证派发条件都写在 Python。TypeScript 的现有 inspect 在没有 provider result 时仍只返回原 journal 状态,不解释 dispatch_armed 与服务预留。原/接手的恢复分支没有共同的类型化派发决定。 扩展现有 TypeScript 生命周期,接收 journal 检查点、服务回执和授权事实并返回类型化的重试或派发决定。Python 保留范围锁、事实采集、落盘和 provider 执行。 相关代码

动机 / Motivation

提供外部写入的 host adapter 与后续维护者需要复用同一份材料写入准入、恢复及派发判定。上一提交在服务预留查询前先标记 armed,退出后两类接手都会被拒。当前提交修复前置恢复,并由 Python 新增状态与服务回执判定。实际复验原中断缺口已修复。当前通用恢复权限仍由 Python 的未派发状态和服务凭证检查单独裁决。覆盖隔离 provider、子进程退出、定向套件和现有 TypeScript reducer 源码。线上服务、真实发布采用与远端 CI 尚未复核。

改动思路 / Approach

用现有 TypeScript 生命周期接收 I/O 事实并裁决,继续复用 Python 的持久写入、provider 调用与恢复流程。派发许可与重试条件具有独立业务含义,应进入现有 TypeScript reducer,执行顺序和锁留在 Python。保留新恢复 interlock 和已经验证的检查点次序,集中通用准入和服务回执校验。

具体改动 / Changes

按 0bcdffb9926e46a1024bcdacb18e24de37a1b018 的规范核对 由现有类型化生命周期决定重新派发 与 服务查询前中断后只派发一次。修好一次具体中断不改变新增准入规则的归属。规范要求新的通用控制面决策在既有 TypeScript owner。 规格与回退边界

对主干的风险 / Risks

当前头把未派发、可重试和持证派发条件都写在 Python。TypeScript 的现有 inspect 在没有 provider result 时仍只返回原 journal 状态,不解释 dispatch_armed 与服务预留。原/接手的恢复分支没有共同的类型化派发决定。229 项定向 Python 通过。真实子进程在查询前退出 73,原 Turn 与接手各用一份独立夹具恢复,均只查询并派发一次。此前 P2 的退出点已修复。另有自动评审提示 owner 边界,本次通过精确源码独立确认。 相关评审

语义与验证对齐

可重试和可能已派发的业务语义属于所有调用方。新增的状态与 service grant 校验无法随既有 TypeScript handler 复用,切换 adapter 时缺少同一权威判定。扩展现有 TypeScript 生命周期,接收 journal 检查点、服务回执和授权事实并返回类型化的重试或派发决定。Python 保留范围锁、事实采集、落盘和 provider 执行。保留原 Turn、接手、未消费 grant、已派发回读及单次结算的实际路径,并验证两类调用使用同一 owner 决定。

我的整体评价 / Verdict

实际复验原中断缺口已修复。当前通用恢复权限仍由 Python 的未派发状态和服务凭证检查单独裁决。覆盖隔离 provider、子进程退出、定向套件和现有 TypeScript reducer 源码。线上服务、真实发布采用与远端 CI 尚未复核。

English verdict: REQUEST_CHANGES at bcd6b6f. The prior crash regression is fixed. The new retry eligibility and provider-grant authorization still live outside the existing typed lifecycle owner. Centralize the decisions there and retain the Python IO adapter.

@mergify

mergify Bot commented Nov 28, 2026

Copy link
Copy Markdown

Hi @hhyykk, the DCO Sign-off check did not pass. Please inspect
its details first: checkout, fetch, timeout or infrastructure errors
need their own recovery, not a rewrite of otherwise signed commits.

If the log confirms a missing Signed-off-by trailer, amend the
affected commit with git commit --amend -s; for multiple commits,
use an interactive rebase against the current base from the correct
base-repository remote and sign off each affected commit. Push the
rewritten PR branch with git push --force-with-lease origin HEAD.

This branch has not been deployed

No deployments
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.

3 participants