Skip to content

fix(codex): close shared app-server clients with the Gateway - #205152

Merged
RomneyDa merged 2 commits into
mainfrom
openclaw/fp-codex-1110
Nov 25, 2026
Merged

RomneyDa merged 2 commits into
mainfrom
openclaw/fp-codex-1110

Conversation

@tideclaw-bot

Copy link
Copy Markdown
Collaborator

What Changed

A prepared model runtime can open a build-scoped Codex app-server client without activating a registered Codex harness. Shutdown previously reached the disposer only through harness retirement, so that path left the transport open.

Why This Change Was Made

Register the same build-scoped disposer with the host singleton lifecycle, keeping the existing harness-retirement callback intact. The host regression opens the shared client through the Codex test facade and asserts its stdio input stays open before the real host drain and is closed afterwards. Removed one cast and lowered its assertion ratchet entry from 2 to 1.

Forward-ports 2026.11.10 release commits fababde406e1 and 56c50d77fc11.

Evidence

  • Against unmodified main (1f3262a9e4dc), the added host test failed at the post-drain assertion: stdin was still open.
  • At the forward-port head, the host regression and all 161 existing shared-client tests passed (two local shards, 104s including cold compilation).
  • Targeted Oxlint, formatting, source-backed host test typecheck, assertion safety and diff checks passed.
  • The regression uses in-memory stdio, not a live Gateway or external Codex process. Pinned Codex 0.169.0's app-server (d32063f96c2d, codex-rs/app-server/src/lib.rs:1217–1240) terminates its single-client loop on stdio disconnect.

Worked on by

tideclaw-bot and others added 2 commits November 25, 2026 06:27
Register the existing build-scoped disposer with the host singleton lifecycle so prepared runtime clients do not outlive Gateway shutdown when no Codex harness was registered. Cover the production drain at the host/plugin boundary.

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: jalehman <[email protected]>
Worked on by:
- @jalehman
- @RomneyDa

Co-authored-by: jalehman <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
OpenClaw-Publication: 1c0cddbe-1e29-4052-8c52-8666c494331a
@clawsweeper

clawsweeper Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@tideclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:other This issue has meaningful maintainer-visible impact outside the owned taxonomy. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 25, 2026
@clawsweeper

clawsweeper Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR registers the existing build-scoped Codex client disposer with the Gateway’s global singleton lifecycle.

Example: Model discovery opens a shared Codex app-server client without registering a Codex harness, then the Gateway stops.

  • Before: Harness retirement never invokes the disposer, leaving the client transport open.
  • After: The Gateway singleton drain invokes the same disposer and closes the transport.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused patch appears correct and has a useful boundary regression, but mocked transport evidence does not satisfy the required real-behavior proof.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Stopping the Gateway can leave a shared Codex app-server transport open when no Codex harness was registered.
Reason: The maintainer-authored direction repairs a concrete resource-lifetime gap using existing owners and preserves prior build-isolation decisions.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it repairs a concrete cleanup gap still present on main, preserves existing lifecycle ownership, and introduces no identified correctness defect.

Reviewed head: 7a800cc676cfb041d10faee4fb7cdb78a1cffcef

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Supply redacted logs or terminal output showing an isolated Gateway opening a real Codex client without harness registration and closing its transport and process on shutdown; redact IPs, credentials, phone numbers, and non-public endpoints.
Agent review details

How this fits together

The Codex plugin owns shared app-server clients; Gateway shutdown drains registered singleton cleanup callbacks, which close transports and join pending startup work.

flowchart TD
  A[Model discovery] --> B[Shared Codex client]
  B --> C[Codex app-server transport]
  D[Gateway shutdown] --> E[Singleton lifecycle drain]
  E --> F[Build-scoped disposer]
  G[Harness retirement] --> F
  F --> B
Loading

Technical review

Best possible solution:

Keep the existing build-scoped disposer as the cleanup owner and register it with the established Gateway lifecycle as this PR does.

Do we have a high-confidence way to reproduce the issue?

Source confirms that main exposes the disposer only through the build-scoped callback consumed by harness retirement; the author reports the new host regression failing before registration and passing afterward, but no reproduction was run during this read-only review.

Is this the best way to solve the issue?

This is the smallest complete production fix: it connects the existing disposer to the existing shutdown owner without adding state, changing public APIs, or replacing transport cleanup policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4e766e6e61ba.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit fc1ec4e adds extensions/codex/src/app-server/shared-client.ts:1562 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: fc1ec4ef492d; files: extensions/codex/src/app-server/shared-client.ts)
  • Srikalyan Swayampakula: Raw commit 3dd0be4 adds extensions/codex/src/build-state.ts:8 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3dd0be4132a5; files: extensions/codex/src/build-state.ts)

PR surface

Source 0, Tests +38, Other 0. Total +38 across 5 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 2 11 11 0
Tests 2 38 0 +38
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 5 50 12 +38

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 25, 2026, 1:38 AM ET / 06:38 UTC.

@RomneyDa
RomneyDa merged commit c985e34 into main Nov 25, 2026
126 checks passed
@RomneyDa
RomneyDa deleted the openclaw/fp-codex-1110 branch November 25, 2026 07:02
tideclaw-bot added a commit that referenced this pull request Nov 25, 2026
* fix(codex): close shared app-server clients with the Gateway

Register the existing build-scoped disposer with the host singleton lifecycle so prepared runtime clients do not outlive Gateway shutdown when no Codex harness was registered. Cover the production drain at the host/plugin boundary.

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: jalehman <[email protected]>

* fix(codex): close shared app-server clients with the Gateway

Worked on by:
- @jalehman
- @RomneyDa

Co-authored-by: jalehman <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
OpenClaw-Publication: 1c0cddbe-1e29-4052-8c52-8666c494331a

---------

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: jalehman <[email protected]>
(cherry picked from commit c985e34)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 26, 2026
…w#205152)

* fix(codex): close shared app-server clients with the Gateway

Register the existing build-scoped disposer with the host singleton lifecycle so prepared runtime clients do not outlive Gateway shutdown when no Codex harness was registered. Cover the production drain at the host/plugin boundary.

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: jalehman <[email protected]>

* fix(codex): close shared app-server clients with the Gateway

Worked on by:
- @jalehman
- @RomneyDa

Co-authored-by: jalehman <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
OpenClaw-Publication: 1c0cddbe-1e29-4052-8c52-8666c494331a

---------

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: jalehman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex impact:other This issue has meaningful maintainer-visible impact outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants