Fix deterministic Codex auto-resume admission
Closes #13880.
A timed-out ownership scan used to abandon agent restore and type a printf notice into a login shell before it was ready. Restore now retains the saved conversation while gathering evidence, presents recovery status outside the PTY, and admits local launches at one CLI boundary. Codex checks use PID birth identity, the planned account’s writer lock, and a cross-instance kernel lease. An isolated exit watcher holds that lease through exec without passing it to Codex’s child processes.
The latest repairs route both legacy fallback cases through the same lease/admission transaction. Literal legacy Codex commands become structured argv using the saved environment/cwd; unresolvable shell programs fail closed. The parser is adapted from @austinywang’s #12822. The provider-lock inspection also builds on #12822 and @lawrencecchen’s #12815 (which credits #11994).
The managed shell launch plan records whether it actually installs prompt integration. Every supported shell, including zsh/bash, requires that capability before enabling the readiness gate; bootstrap-only and unsupported/custom launchers retain their direct-input fallback. Adding a deferred restore cancels the previous evidence wait and starts a fresh pass without retaining the closed container. Both status keys now have all 20 catalog locales.
Validation (current HEAD: fb9d3977354e13bd1dd150ac79cb999bc6acacc2):
CMUXAgentLaunch: all 414 tests in 59 suites passed locally, compiled with warnings as errors. Fixed the Swift 6 mutable descriptor capture and parallel fork/exec fixture races exposed by the full run.CmuxTerminal: 13 focused readiness/input tests passed, including present and missing Nushell integration files and ambient zsh/bash variables without installed hooks. The ambient-environment test failed before the fix.- Local tagged app build succeeded on current HEAD using
CMUX_GHOSTTYKIT_PREPROVISIONED=1 CMUX_SKIP_ZIG_BUILD=1 ./scripts/reload.sh --tag issue-13880-codex-autoresume-edges --derived-data /Users/austinwang/Library/Developer/Xcode/DerivedData/cmux-issue-13880-codex-autoresume-edges --no-global-cli-links --prod-auth --launch. This checkout has noscripts/dev.sh. The app launched and its tag-bound socket returnedPONGand the expected bundle identity. Open the local build. - The actual compiled CLI passed six probes on current HEAD: command-only and planner-fallback Codex resumes hold the lease and preserve account/cwd/session/model; direct/relaunch retain compatibility; non-Codex unknown-mode legacy records run; unknown Codex modes fail closed.
- Swift file budgets, PBX normalization/test wiring, package resolution/grouping policy, localization validation, app-only warning budget, and whitespace checks passed. Neither Swift budget TSV was changed.
- Hosted app-host run 35830983701 compiled successfully and executed all 15 focused tests successfully. It failed afterward because cleanup rejected the workspace-local DerivedData product. Regression
6e68e6d245reproduces that failure; fixfb9d397735uses the existing exact-product receipt/executable/descriptor checks rather than treating the parent directory as ownership. Cleanup, process-ownership, and home-isolation guards pass, including missing and foreign receipt rejection. - Current-HEAD focused hosted workflow is green: all 15 tests in five suites executed and passed, including the five parameterized legacy-launch cases; app-host cleanup succeeded.
- Current-HEAD CI: macOS compile admission, the unchanged Swift warning budget, Release build, Claude-wrapper regressions, Swift packages (all 414 agent-launch tests), and static/guard checks passed.
- Full CI is not green. App-host shard 2/7 ran 689 tests in 77 suites and failed only
WorkspaceContentViewVisibilityTests/testMinimalModeToggleDoesNotReevaluateChromeHeavyBodies(three assertions). Its 1 / 2 / 1 body counts and dotted@AppStorageinvalidation trace match the existing main failure documented in #13930.ContentView.swift,WorkspaceContentView.swift, and that test file are unchanged in this PR. #13931 explicitly excludes this separate bug, and #13403 still lists it as outstanding. The assertion andfull-cilabel remain intact; the remaining test/CLI lanes are queued. This PR is not at the done bar.
Trade-offs and remaining acceptance gaps: the shared lease covers updated cmux launchers; Codex’s own lock remains authoritative for external writers. A legacy escaped PTY cannot be attached by PID alone, and this change retains a live-owner wait instead of claiming such attachment. Direct-input fallback for shells without prompt reporting remains a limitation of the strict readiness acceptance. Real-app clean/crash/reboot/mid-turn/escaped-owner recordings are not complete, so this PR must not merge yet. The related #13395, #12805 quit cleanup, #12870 stable binding migration, #5802 idle eligibility and #5557 SQLite retry follow-ups remain open. #12920, #4908 and #12834 are unrelated references, as recorded in the issue plan.
No current fleet artifact has been verified: the earlier tagged submission timed out with unknown outcome. It was not resubmitted. The local app/CLI/package validation above uses the user’s subsequent explicit local-build authorization. Launch and socket checks establish that the dev app is usable; they do not establish the complete restore scenario matrix. The tagged app is left running for the user to try.
— Larchsignal · pending
Run: run_13880_28fd5e58340c
Session: codex-13880-6ab0c4daca3848058b2c9db831cf4e5a
Summary by CodeRabbit
- New Features
- Agent-session recovery now displays progress while checking ownership and indicates when another process is using the session.
- Restored startup input is delivered when the shell is ready, helping prevent input from being lost or sent too early.
- Bug Fixes
- Improved agent-session restoration when ownership information is temporarily unavailable, including after a restart.
- Prevented concurrent restore attempts from launching the same local Codex session.
- Improved restoration of existing remote terminal sessions.