Repository navigation
refactor(codex): split app server run attempt - #106773
Conversation
|
Land-ready proof for
Required hosted landing checks remain enforced by |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4a31af44a3
ℹ️ 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".
| const drainNotificationQueue = async () => { | ||
| await resourceState.turnRoute?.drain(); | ||
| }; | ||
| registerNativeSubagentMonitor(resourceState.thread.threadId); |
There was a problem hiding this comment.
Keep monitor registration under route cleanup
When codexNativeSubagentMonitorRuntime.register throws (for example, an existing monitor has the same parent thread bound to a different requester session), this eager registration happens after startCodexAttemptRuntime has acquired the app-server client/route/native hook relay/sandbox resources but before prepareCodexAttemptRoute enters its cleanup try. The previous inlined flow registered inside ensureCurrentThreadRoute's guarded block, so the route, lease, relay, sandbox exec environment, and upstream abort listener were released on this failure; now this path leaks them and leaves the attempt partially attached. Move this registration back under the route cleanup guard or wrap it with equivalent cleanup.
Useful? React with 👍 / 👎.
|
Codex review: needs real behavior proof before merge. Reviewed July 13, 2026, 4:58 PM ET / 20:58 UTC. Summary PR surface: Source +755. Total +755 across 19 files. Reproducibility: no. live failure was reproduced, but the exception path is source-reproducible with high confidence: a throwing monitor registration occurs after resource acquisition and before the route cleanup guard. Review metrics: none identified. Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Keep the lifecycle split, but place native subagent monitor registration inside the route-owned cleanup guard or add equivalent exception cleanup, cover the throwing registration path with a focused regression test, then refresh onto current main and rerun the Codex attempt and architecture checks. Do we have a high-confidence way to reproduce the issue? No live failure was reproduced, but the exception path is source-reproducible with high confidence: a throwing monitor registration occurs after resource acquisition and before the route cleanup guard. Is this the best way to solve the issue? No, not at the current head. The owner-aligned extraction is the right direction, but registration must remain within the cleanup ownership boundary so the refactor preserves prior failure semantics. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 995c75baa00e. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +755. Total +755 across 19 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
4a31af4 to
98650a3
Compare
|
Land-ready proof for exact head
The dead-export check reports only current |
|
Merged via rebase.
|
What Problem This Solves
extensions/codex/src/app-server/run-attempt.tshad grown to 4,137 lines and mixed connection setup, prompt preparation, routing, turn lifecycle, notification handling, finalization, and cleanup in one module. This made ownership and review boundaries hard to follow. Tracks #106503.Why This Change Was Made
Split the runtime by lifecycle phase and owner boundary. The entry point is now an 81-line orchestrator; every extracted production module is 480 lines or fewer. Existing Codex app-server protocol behavior, public surfaces, and runtime policy remain unchanged.
Review found and fixed three failure-path regressions: deferred cancellation snapshot timing, atomic context-projection metadata, and immediate ownership of startup cleanup handles.
User Impact
No intended user-visible behavior change. Maintainers get smaller modules with explicit startup, active-turn, notification, finalization, and cleanup boundaries.
Evidence
98650a37030dd588a80c2d75e563c034b3ae44batbx_01kxerd15gtzxtprmvnmke7ggmoxfmt --checkandoxlintpassed forrun-attempt.tsandrun-attempt-*.ts.corepack pnpm tsgo:extensionsrun-attempt*.test.tsfiles — 301 tests passedcorepack pnpm deadcode:exportsreports only currentmainbaseline drift outside this branch.git diff --checkcodex-rs/app-server-protocol/src/protocol/common.rs,codex-rs/app-server/src/bespoke_event_handling.rs, andcodex-rs/app-server/src/request_processors/turn_processor.rs.