Repository navigation
refactor(codex): separate exec session transport - #126859
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 20, 2026, 7:16 PM ET / 23:16 UTC. ClawSweeper reviewWhat this changesThis PR moves one Codex sandbox execution connection’s JSON-RPC dispatch, resource ownership, notifications, and cleanup from the loopback WebSocket adapter into a transport-neutral session object. Merge readinessKeep open for maintainer review: the code inspection found no discrete patch defect, but the removal of the supported-version fallback depends on an upstream Codex contract that could not be directly inspected because the required sibling checkout is absent and network access is unavailable. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 2 Assertions:
How this fits togetherThe Codex plugin registers a local sandbox exec server with the Codex app-server. Its loopback WebSocket receives JSON-RPC requests, while the session owns sandbox processes, file handles, streamed HTTP work, responses, and connection cleanup. flowchart LR
A[Codex app-server] --> B[Loopback WebSocket]
B --> C[Execution session]
C --> D[Sandbox backend and filesystem]
C --> E[Processes and HTTP]
C --> F[JSON-RPC responses and notifications]
Decision needed
Why: The patch intentionally changes startup behavior for a compatibility-supported external runtime, and repository policy requires the acting reviewer to inspect the exact Codex source before a verdict or proof-sufficiency claim. Before merge
Agent review detailsSecurityNone. PR surfaceSource -33, Tests +88. Total +55 across 12 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the single session owner and fail-closed registration behavior after a direct Codex-source check confirms the environment-registration contract for the supported 0.147.0–0.148.0 range. Do we have a high-confidence way to reproduce the issue? Not applicable as an issue reproduction: this is a refactor PR, though its body describes a real pinned-runtime success and registration-failure exercise. Is this the best way to solve the issue? Unclear: the session extraction is the clean owner-boundary shape, but the fail-closed registration change is not yet independently proven against the declared upstream compatibility range. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e78b9d3ce4aa. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
The requested upstream contract and real registration proof is complete on exact head
The sandbox backend/fs bridge in the proof were safe synthetic fixtures; the pinned app-server, stdio transport, environment registration, loopback WebSocket, sandbox child, failure response, and cleanup boundaries were real. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
What Problem This Solves
OpenClaw's Codex plugin previously coupled execution-session ownership to its loopback WebSocket adapter, spread connection-owned process, file-handle, notification, and HTTP cleanup across transport-specific helpers, and silently downgraded failed environment registration even though the supported Codex runtime already defines that operation. This made lifecycle ownership harder to verify and could obscure a real startup failure.
Why This Change Was Made
Move JSON-RPC dispatch, ordered process notifications, connection-owned processes and file handles, streamed HTTP cancellation, and idempotent cleanup into the plugin-private
CodexSandboxExecSession, behind only a generic{ send, isOpen }message transport. The existing loopback WebSocket remains the sole adapter/server owner; connection-local, non-resumable sessions, capability-path authorization, filesystem sandbox policy, subprocess behavior, and local-only transport are preserved. Capture and validate the sandbox backend and filesystem bridge once before publishing the server, then delete the obsolete repeated runtime guards and unsupported-environment/adddowngrade. Registration errors now propagate after releasing the acquired lease because OpenClaw supports Codex app-server 0.147.0+ and ships 0.148.0, where environment registration is an owned upstream contract.This is a maintainer-requested, AI-assisted, plugin-private refactor. It adds no SDK/core/node carrier, transport endpoint, missing RPC, reconnect/resume behavior, changelog entry, or unrelated surface. Production code is +256/-289 (net -33 lines); tests are +137/-49.
User Impact
Existing Codex sandbox execution, loopback WebSocket transport, process/file behavior, notification ordering, and no-resume connection semantics are unchanged. An unsupported or otherwise failed environment registration now reports the actual startup error after deterministic lease cleanup instead of silently degrading. Incomplete sandbox environments fail before exposing a listener.
No visual proof or changelog entry is applicable: this is an internal plugin ownership cleanup with no UI change. The intentional observable difference—registration failure now failing closed—was verified against the real pinned Codex app-server.
Evidence
0268d7915be6bdfb563d6c68a6a6458d64f4a64c.@openai/codex0.148.0 app-server over the production stdio client, with an isolated empty home and no inference/auth request.environment/add, independently reported the registered environmentready, and connected to the real OpenClaw loopback exec-server. A real sandbox child started; lease release terminated it, finalized exactly once, removed the registry entry, closed the listener, and subsequent connection returnedECONNREFUSED.execServerUrl=nonewith JSON-RPC-32600(remote environment cannot use disabled exec-server url). The error propagated, the environment remained unknown, nothread/startor inference occurred, and OpenClaw removed the registry entry and listener.pnpm tsgo:extensions,pnpm tsgo:extensions:test,pnpm lint:extensions, andpnpm build— passed.node scripts/check-changed.mjs -- extensions/codex/src/app-server/attempt-startup.test.ts extensions/codex/src/app-server/sandbox-exec-server.json-rpc.test.ts extensions/codex/src/app-server/sandbox-exec-server.lifecycle.test.ts extensions/codex/src/app-server/sandbox-exec-server.test.ts extensions/codex/src/app-server/sandbox-exec-server.ts extensions/codex/src/app-server/sandbox-exec-server/filesystem.ts extensions/codex/src/app-server/sandbox-exec-server/http.ts extensions/codex/src/app-server/sandbox-exec-server/json-rpc.ts extensions/codex/src/app-server/sandbox-exec-server/processes.ts extensions/codex/src/app-server/sandbox-exec-server/runtime.ts extensions/codex/src/app-server/sandbox-exec-server/types.ts extensions/codex/src/app-server/sandbox-exec-server/session.ts— passed.git diff --check origin/main...HEAD— passed.openai/codex@b5ea64a203ce:app-server-protocol/src/protocol/common.rsdeclaresenvironment/add.app-server-protocol/src/protocol/v2/environment.rsowns the registration contract.app-server/src/request_processors/environment_processor.rsperforms registration and propagates invalid requests.exec-server/src/server/transport.rsseparates transport from connection processing and defines single-connection stdio semantics.exec-server/src/server/processor.rsowns per-connection JSON-RPC state and notification delivery.