fix(codex): recover interrupted state DB backfills - #12617
Conversation
📝 WalkthroughWalkthroughThe change adds Codex state-database inspection and backfill recovery. Recovery supports native and WSL execution, polling, retries, cancellation, shutdown, and supervisor locking. Codex PTY spawning, rate-limit fetching, trust grants, and application lifecycle now coordinate with recovery. Renderer PTY connections detect backfill-timeout output and report a recovery notice. Windows host and process identity detection now use registry and PowerShell probes. Configuration includes the new CLI sources. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Managed-home recovery: a stale running backfill with a dead supervisor owner recovered to Actionable failure state: when recovery could not proceed, the Codex pane rendered the background-recovery guidance and retry instructions. |


Fixes #11830. Related: #11828 and upstream openai/codex#37003.
Summary
codex app-serverclaimant behind an exact process-incarnation lock, recovering dead or PID-reused Orca owners while leaving live owners and concurrent Orca instances untouched.This branch was implemented fresh from current
main; it does not reuse or cherry-pick the closed release-lineage PR #11981.Screenshots
Electron QA through CDP, showing the recovery message in a Codex-launched pane:
Testing
pnpm lintpnpm typecheckpnpm testpnpm buildFocused validation after the final rebase:
The full local
src/main/ipc/pty.test.tsfile reached 438 passing tests; nine unrelated MiMo/Pi/WSL harness cases failed in this environment. None exercises a Codex launch or the new recovery mock, and the change-owned Codex integration test is green.AI Review Report
Reviewed the complete delta against
origin/main, including recovery lifecycle, lock stealing, child-process exit races, read-only DB inspection, shutdown, and all short-lived Codex app-server call sites. The review explicitly checked native macOS, Linux, and Windows process identity, WSL distro/PID-namespace scoping and shell quoting, SSH/folder-workspace behavior, path normalization, and Electron renderer behavior; no shortcut or label behavior changed.The central integration risk is that Codex 0.146's
backfill_statedoes not record a verifiable owner. The implementation therefore never guesses from CPU activity or age and never writes Codex schema: Orca arbitrates only its own supervisor with host + PID + process-start identity, while Codex's existing lease/claim transaction arbitrates the actual backfill. The missing upstream owner/repair contract is tracked in openai/codex#37003.Security Audit
fileMustExist; Orca never updates, deletes, or recreates Codex-owned state.Caveats
Notes
Orca keeps the sanctioned app-server claimant alive until Codex marks the backfill complete, but intentionally does not hold pane startup for the full potentially long index. Pane startup waits only for exact Orca supervisor-owner arbitration; Codex remains the sole authority for its backfill claim.
On quit, Orca terminates and joins only recovery children it owns. Crash recovery remains required and covered because no shutdown path can make an abrupt host/process loss impossible.