Repository navigation
fix(codex): forward-port 2026.10.10 thread ownership and cleanup fixes - #191830
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Dependency graph guard clearedThis PR no longer has dependency changes awaiting review. A future dependency graph change from an external contributor requires a maintainer's
|
|
Codex review: needs maintainer review before merge. What this changesThis PR repairs Codex thread handoffs, native follow-up targeting, and graceful cleanup budgets. Example: A later parent turn sends followup_task to worker, previously registered as /root/worker.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it contains useful Codex repairs still missing from main, with no definite introduced defect found. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Codex plugin translates Gateway turns and collaboration requests into native app-server operations while owning shared clients, thread subscriptions, and cleanup. flowchart LR
A[Gateway turn] --> B[Codex plugin]
B --> C[Shared client lifecycle]
B --> D[Native child admission]
C --> E[Codex app server]
D --> E
E --> F[Thread writer and cleanup]
Technical reviewBest possible solution: Land the focused repairs through the existing Codex lifecycle owners once the failed checks are resolved or supported by an accepted failure attribution. Do we have a high-confidence way to reproduce the issue? Current-main source and the independently inspected native writer contract establish the failure paths; the PR supplies discriminating regressions, but this read-only review ran no reproduction. Is this the best way to solve the issue? The change repairs the existing fork, admission, and shared-client owners without adding a parallel execution path; the simplification pass found no definite unnecessary machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 44eaed3d95d7. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +160, Tests +295, Other +2. Total +457 across 20 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 4, 2026, 5:13 PM ET / 22:13 UTC (Revision 2). |
3c7cde0 to
a70729a
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
A clean Codex shutdown can spend several seconds flushing its state database after stdin closes under load. Give one-shot and caller-owned isolated clients a bounded 5s graceful window (6s exit budget) instead of force-killing after 250ms, so a normal exit is not converted into a forced, uncertain cleanup receipt. Includes the shared close-options constant introduced by 2eaf9aa on the release branch, which main lacked. Forward-port of 46db9eb from release/2026.10.10.
Codex holds a per-home writer lock while a thread is loaded and keeps it after unsubscribe until the idle unload delay. Canonical forks ran on the catalog connection while child turns resume on the supervision turn connection, so the first child turn failed with 'already has an active writer'. Fork with a zero unload delay, release the catalog subscription and wait for thread/closed before readiness. Model the writer lock in the native fixture and prove the handoff on a separate turn connection. Also covers a3778c8 and 5c47f59, whose retained-subscription approach caa7ea6 reverted on the release branch. Forward-port of caa7ea6 from release/2026.10.10.
Codex followup_task accepts a canonical task name. Each Gateway turn owns a fresh parent registration, and pruning the previous registration dropped its children's agent paths, so a later follow-up by name failed with 'native target lineage is not currently identified'. Treat a registered non-child parent as /root and keep retired children's canonical paths per native parent so the name resolves to the same child. The retired-path index lives beside target resolution so the monitor does not grow. Forward-port of b435b6f from release/2026.10.10.
gpt-5.6-luna runs Codex multi-agent v1, whose follow-up tools address children only by agent ID (Codex agent/control/target.rs resolves IDs and registered task paths). When a later turn names a child by nickname, the refusal now lists this thread's known and earlier-registered child IDs so the model can retry with the exact ID. Forward-port of bbc4e29 from release/2026.10.10.
When a binding's thread is owned by another live app-server connection (for example after /codex resume attached it on the command connection), the handoff unsubscribed the old owner but only waited for closure when that owner was retiring. Codex holds the per-home writer lock until the thread unloads (rollout/src/writer_lock.rs), so the turn connection's resume failed with 'already has an active writer' or rotated to a new thread. Wait for the old owner's thread/closed, bounded, before resuming. Forward-port of f9b8534 from release/2026.10.10.
…load Codex emits thread/closed only after the unloaded thread's shutdown_and_wait completes and reports shutdown as slow only after 10s (app-server thread_lifecycle.rs, unload_thread_without_subscribers). Live teardown of a thread with MCP servers measured about 1.98s, right at OpenClaw's 2s confirmation budget, so reconfiguring resumes intermittently failed with 'Codex did not confirm unloading its previous configuration'. Use Codex's 10s window, kept module-private. The Gateway physical-exit recovery cases retain the previous native thread so it never confirms its unload; they now wait out the 10s window before the exit gate (release test companion 8c275c6). Forward-port of d19bd1d and 35fb02f from release/2026.10.10.
d46c932 to
888fb2b
Compare
Carry the final reviewed changes from #191830, #192378, #192379, #192380, #192383, #192385, and #192386. Preserve #191838's existing file-transfer import fix. Adapt Gateway readiness to the release owner and include the narrow SQLite cold-admission prerequisite from #192586. Do not carry #192387: its Goal expectation depends on main-only Stop-to-paused behavior absent from this release. Retain regression allocations without changing the shared baseline.
openclaw#191830) * fix(codex): preserve loaded one-shot cleanup A clean Codex shutdown can spend several seconds flushing its state database after stdin closes under load. Give one-shot and caller-owned isolated clients a bounded 5s graceful window (6s exit budget) instead of force-killing after 250ms, so a normal exit is not converted into a forced, uncertain cleanup receipt. Includes the shared close-options constant introduced by 2eaf9aa on the release branch, which main lacked. Forward-port of 46db9eb from release/2026.10.10. * fix(codex): unload canonical forks before child turns resume them Codex holds a per-home writer lock while a thread is loaded and keeps it after unsubscribe until the idle unload delay. Canonical forks ran on the catalog connection while child turns resume on the supervision turn connection, so the first child turn failed with 'already has an active writer'. Fork with a zero unload delay, release the catalog subscription and wait for thread/closed before readiness. Model the writer lock in the native fixture and prove the handoff on a separate turn connection. Also covers a3778c8 and 5c47f59, whose retained-subscription approach caa7ea6 reverted on the release branch. Forward-port of caa7ea6 from release/2026.10.10. * fix(codex): resolve native follow-ups by task name across parent turns Codex followup_task accepts a canonical task name. Each Gateway turn owns a fresh parent registration, and pruning the previous registration dropped its children's agent paths, so a later follow-up by name failed with 'native target lineage is not currently identified'. Treat a registered non-child parent as /root and keep retired children's canonical paths per native parent so the name resolves to the same child. The retired-path index lives beside target resolution so the monitor does not grow. Forward-port of b435b6f from release/2026.10.10. * fix(codex): name usable agent IDs when a native target is unidentified gpt-5.6-luna runs Codex multi-agent v1, whose follow-up tools address children only by agent ID (Codex agent/control/target.rs resolves IDs and registered task paths). When a later turn names a child by nickname, the refusal now lists this thread's known and earlier-registered child IDs so the model can retry with the exact ID. Forward-port of bbc4e29 from release/2026.10.10. * fix(codex): wait for a live previous owner to unload before resuming When a binding's thread is owned by another live app-server connection (for example after /codex resume attached it on the command connection), the handoff unsubscribed the old owner but only waited for closure when that owner was retiring. Codex holds the per-home writer lock until the thread unloads (rollout/src/writer_lock.rs), so the turn connection's resume failed with 'already has an active writer' or rotated to a new thread. Wait for the old owner's thread/closed, bounded, before resuming. Forward-port of f9b8534 from release/2026.10.10. * fix(codex): allow Codex's shutdown window when confirming a thread unload Codex emits thread/closed only after the unloaded thread's shutdown_and_wait completes and reports shutdown as slow only after 10s (app-server thread_lifecycle.rs, unload_thread_without_subscribers). Live teardown of a thread with MCP servers measured about 1.98s, right at OpenClaw's 2s confirmation budget, so reconfiguring resumes intermittently failed with 'Codex did not confirm unloading its previous configuration'. Use Codex's 10s window, kept module-private. The Gateway physical-exit recovery cases retain the previous native thread so it never confirms its unload; they now wait out the 10s window before the exit gate (release test companion 8c275c6). Forward-port of d19bd1d and 35fb02f from release/2026.10.10. * test(ci): allocate Codex forward-port regression coverage * fix(codex): apply one-shot grace at initial shared shutdown * test(codex): use valid process inspection failure reason
Problem
The 2026.10.10 stable release fixed Codex thread ownership and native follow-up failures that were missing from main. A freshly forked child could fail its first turn with an active-writer error; a resumed thread could race its previous owner; a later parent turn could no longer resolve a native child by task name. Short shutdown budgets also converted healthy loaded cleanup into failure.
Solution
Keep this existing PR for the Codex portion of the original forward-port batch. All sibling splits target main independently; this is not a stack.
Preserves the six original Codex forward-port commits and release references. Fresh local review also caught a defect in the inherited one-shot change: shared retirement started shutdown before its longer grace options were applied. The repair now applies those options at the first close; the operation lives with the existing shared-client lifecycle owner. A deterministic fake-clock regression fails before this repair because containment starts before the delayed clean exit. The exact scoped test-line allocation is 295 lines for fork handoff, native targeting, previous-owner handoff, and shutdown-budget regressions. Simplification review kept these ownership fixes together; unrelated Matrix, process, storage, cron, config, startup, and file-transfer changes moved out.
Evidence
git diff --checkand targeted oxfmt checks passed.node scripts/run-vitest.mjs extensions/codex/src/app-server/client-shutdown.test.ts --maxWorkers=1— the new grace regression failed as expected; 3 existing tests passed.src/agents/mcp-metadata.ts:5importsMcpCatalogToolfrom a module that does not export it, with consequent optional-property errors inagent-bundle-mcp-materialize.ts. All three source files are byte-identical to base 3400782.34007820fa2c..f00f4d2e7b58: no actionable correctness or security findings; prior shutdown-grace finding resolved.Prior combined-PR evidence: canonical-descendant 65/65; native-subagent 141; binding 100/100; codex-failure-recovery 7/7; handoff.native 2/2. The original regressions were confirmed failing without the corresponding changes, except the one-shot cleanup budget (the delayed-exit fixture was flaky and nondiscriminating, so no such test is claimed).
Codex shutdown contract checked against sibling source commit 092d3acd6bec3e3a14bdc7e7a2810ab628ab759d; the per-thread unload-delay override was also verified against pinned rust-v0.164.0 (6aaac694803004a63c6f393d153c96d22521a6b9):
codex-rs/app-server/src/request_processors/thread_lifecycle.rswaits for shutdown and only emitsthread/closedafter cleanup, reporting shutdown as slow after 10 seconds.Known limitation retained from the original PR: the retired native child-path index is not pruned. Broad CI and live authenticated Codex/MCP qualification are not claimed by local fixture tests.
Independent forward-port PRs
All eight target
maindirectly, not one another.Matrix retains its existing dependency-patch approval requirement before landing.
Original release audit: changes intentionally not ported
Not ported
runtimeHasSourceLoader()core-load.ts:8); no string changes, so no catalog regeneration neededtoolsmodels.listreread after superseded generation)models-list-result.plugin-runtime,models-list-result.configured-static,model-account-catalog-authority.integrationunlink-during-auth/dns) require a request superseded by an account unlink not to reread. A blind reread breaks that, so a main-owned fix must distinguish publication supersession from authority loss. Follow-up.Additionally omitted during this split: file-transfer
d562323353, already repaired on main by #174252 (515b3c409583). Both existing cold and legacy-cache concurrent-import regressions passed on unchanged main sources. Redundant draft #192382 was closed.Exact-head CI attribution and repair
The failed
check-test-typesjob onf00f4d2e7b58included a related error atclient-shutdown.test.ts:68:unexpected containmentis not a validProcessInspectionErrorreason. Commitd46c932c2f16corrects it tounavailable, without weakening the assertion that containment must not run. Fresh shutdown tests passed 4/4. The repository extension-test typecheck no longer reports this error; remaining errors are the inherited MCP failures below. Targeted formatting and diff checks passed.All failed job logs were individually inspected. The three MCP files (
mcp-metadata.ts,agent-bundle-mcp-types.ts,agent-bundle-mcp-materialize.ts) are byte-identical to base34007820fa2c. MissingMcpCatalogToolexport/optional UI metadata errors therefore predate this split. The test-budget job exceeds its adjusted ceiling by the same inherited 47 lines: 6,445,222 versus 6,445,175, with the exact +295 regression allocation.New-head CI is pending, not claimed green. No merge conflicts were reported against current main.
Rebase onto current main
Rebased onto
a1f99240c8367a0e012b401bed71831a3cc65026, including merged Goal-test correction #192387. New candidate:888fb2bcb77fc9912135f274cb970e14526c5fe4. This PR still targets main independently.Verified the complete rebased tree equals the previous PR patch integrated with that main snapshot. No new behavior was added during rebase. Prior test and CI attribution sections remain evidence for their named old revisions; fresh CI on this head is pending, not claimed green.