Skip to content

fix: retain Codex ownership through input failure and recovery - #526

Open
BunsDev wants to merge 5 commits into
mainfrom
codex-pipe-lifecycle
Open

BunsDev wants to merge 5 commits into
mainfrom
codex-pipe-lifecycle

Conversation

@BunsDev

@BunsDev BunsDev commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #525: Codex app-server stdin failure can raise an uncaught EPIPE, and that PR's first failed queue run retained the error with an NSAlert runModal sample during a Settings-click failure. Consume stream failures, settle RPC and initialization write receipts, keep the failed child owned until closure, and preserve an accepted native answer as uncertain when delivery fails.

Bind asynchronous reads, writes, coding setup, terminal cleanup and native replies to their originating server. Validate health ownership at publication and stale-auth ownership at the actual restart/replay decision; detach old cleanup registries before withdrawal callbacks, and prevent an old attempt regaining recovery permission after a replacement starts and closes. Meaningful failing controls precede each repair. The 1,001-receipt confirmation fixture also isolates synthetic selection/scope metadata without changing the production scheduler, deadlines or existing assertions.

Validation on signed 2069430: build and workspace typechecks pass. Frozen local unit groups record 2,891 passes, 36 skips and one cancellation at the unchanged Claude test's six-second bound; that case passes in an isolated diagnostic in 1.43 seconds. Desktop E2E records 546 passes, 17 skips and one window-position failure (40,60 reopened as 1157,1148, retaining 960×620); site passes 8 and web passes 4, without retries. The new actual pipe-failure regression and Jev contrast cases pass. The 18 context/scope cases and identical slow-metadata control pass. Local full qualification remains failed; fresh hosted qualification must validate the candidate.

Scoped agent source review reports no remaining Critical or Important findings and is not human approval. This signed head adds only receipts/status to the tested source. Evidence, first failures and acceptance limits remain explicit. PR #525 has not been requeued; protected merge, installed-release, live-provider, device and human acceptance remain separate gates, and no issue checkbox changes here.

Handle stdin errors and write receipts without an uncaught exception, fence replacement and turn completion until closure, and preserve uncertain answer delivery.
Keep metadata, admission, thread opens, terminal cleanup and response writes on the original server lease. Refuse retired-generation auth recovery, wait for closing servers, and report only that child's native version.
Carry the server lease through health publication and the actual stale-auth restart/replay decision. Detach old cleanup registries before native withdrawal callbacks, and retain latest-issued identity across closure so old attempts cannot regain recovery authority.

Validation: main build, 136 affected cases passed with 13 opt-in native/live skips, and one private Electron regression passed without retries. Full local qualification and protected delivery remain pending.
Supply deterministic missing-file selection and scope readers only for the 1,001-receipt fixture. Preserve the shared scheduler, production deadlines, original assertions and real-filesystem boundary cases. Assert every intended unique selection read and both scope reads.

Main compilation and 18 context/scope tests pass; the identical slow-realpath control passes with zero realpath calls. Retain the original full failure and incomplete scope-only correction separately. Fresh full qualification remains pending.
Record the frozen source, passing coverage, six-second Claude test cancellation, isolated diagnostic and repeated window-position failure. Preserve first failures and explicit native/live acceptance limits; require fresh hosted and protected queue qualification before delivery.
@vercel

vercel Bot commented Nov 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
modex Ready Ready Preview Nov 16, 2026 12:36am UTC
modex-app Ready Ready Preview Nov 16, 2026 12:36am UTC

Request Review

@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: TypeScript

TypeScript / code-coverage-agent

main 538d357 codex-pipe-lifecycle c2d4bcb +/-
66% 67% +1%
View coverage of the 3 most impacted files.
File main 538d357 codex-pipe-lifecycle c2d4bcb +/-
apps/desktop/sr...ckends/codex.ts 98% 98% 0%
apps/desktop/sr...ckends/types.ts 100% 100% 0%
apps/desktop/sr...ngine/runner.ts 98% 98% 0%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

A critical active issue remains in codex.ts where a stale authentication attempt can replay after a replacement server starts and closes, so generation validation must be fixed to prevent unsafe recovery.

1 open issue
What changed in this PR

This PR hardens Codex app-server lifecycle handling so stdin failures are consumed, pending operations settle deterministically, failed server generations remain owned until closure, and native answer delivery is persisted as uncertain when transport confirmation is unavailable.

Changes:

  • Adds server leases, generation checks, transport-failure handling, and guarded recovery across Codex lifecycle operations.
  • Adds regression coverage for pipe failures, ownership races, native request delivery, recovery, task-context selection, and Electron responsiveness.
  • Documents validation evidence and remaining qualification limits.
File Description
docs/​status.md Tracks the Codex lifecycle repair as in flight and records pending hosted and protected qualification.
docs/​reviews/​2026-11-14-codex-input-transport.md Documents the observed transport failure, repair behavior, validation results, and qualification limits.
apps/​desktop/​test/​task-context-checks.test.ts Adds the 1,001-receipt synthetic confirmation fixture and scope-isolation assertions.
apps/​desktop/​test/​human-requests-runner.test.ts Verifies uncertain native-answer persistence and deletion blocking until the failed child closes.
apps/​desktop/​test/​codex-transport.test.ts Covers pipe failures, initialization receipts, stale events, recovery ownership, and replacement-server races.
apps/​desktop/​src/​main/​engine/​backends/​codex.ts Adds transport-failure handling, server leases, closure ownership, and stale-generation protections.
apps/​desktop/​e2e/​codex-transport.spec.ts Exercises a real closed-input Codex peer and confirms Settings remains responsive without uncaught errors.

Review effort: Lite

else {
if (!this.restart("Codex was restarted to pick up a new sign-in.", owner)) return refused();
// A synchronous shutdown subscriber may already have started a different server.
if (this.lease !== null) return refused();

This branch was successfully deployed

1 active deployment
Preview – modex — c2d4bcb4 Deployed Nov 16, 2026 by vercel[bot]
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.

2 participants