Skip to content

[codex] implement standalone code-mode process host - #30111

Merged
cconger merged 1 commit into
mainfrom
cconger/process-owned-session-runtime-3-host
Jun 26, 2026
Merged

[codex] implement standalone code-mode process host#30111
cconger merged 1 commit into
mainfrom
cconger/process-owned-session-runtime-3-host

Conversation

@cconger

@cconger cconger commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • implement the standalone codex-code-mode-host stdio service
  • route sessions, cells, delegate requests, responses, and cancellation through a bounded host peer
  • supervise request, writer, cell-forwarding, actor, and V8 failure boundaries
  • bound request/session tombstones and fail-stop the connection on invalid protocol state
  • add host-only duplex protocol tests and local Cargo/Bazel run recipes

Why

This stage makes the host process independently runnable and reviewable before exposing any remote client in Codex. Transport or runtime failure closes the connection and relies on process replacement rather than transactional recovery.

Stack

This is 3 of 4 in the process-owned code-mode session stack.

Validation

  • just test -p codex-code-mode-host — 7 host-only tests passed
  • just fix -p codex-code-mode-host
  • just bazel-lock-update
  • just bazel-lock-check
  • just fmt

@cconger
cconger force-pushed the cconger/process-owned-session-runtime-2-runtime branch from 93c2ba5 to 9dcaccb Compare June 25, 2026 20:32
@cconger
cconger force-pushed the cconger/process-owned-session-runtime-3-host branch from 9882678 to ed321a2 Compare June 25, 2026 21:24
@cconger
cconger force-pushed the cconger/process-owned-session-runtime-2-runtime branch from 9dcaccb to b6b8769 Compare June 25, 2026 21:49
@cconger
cconger force-pushed the cconger/process-owned-session-runtime-3-host branch from ed321a2 to 829922a Compare June 25, 2026 21:51
Comment thread codex-rs/code-mode-host/src/lib.rs
Comment thread codex-rs/code-mode-host/src/lib.rs
Comment thread codex-rs/code-mode-host/src/peer.rs
Comment thread codex-rs/code-mode-host/src/lib.rs
Comment thread codex-rs/code-mode-host/src/host_tests.rs
Base automatically changed from cconger/process-owned-session-runtime-2-runtime to main June 25, 2026 22:34
@cconger
cconger force-pushed the cconger/process-owned-session-runtime-3-host branch 2 times, most recently from f5b2e7e to a5d75bf Compare June 25, 2026 23:14

@jif-oai jif-oai 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.

Approving because this has no production impact for now but once this is fully wired we will have to hunt races and any other fancy rough edges. I can help with this

}
match request {
HostRequest::OpenSession { session_id } => {
let result = self

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.

We commit the session before knowing SessionReady fits on the wire.
This is nit but a near-frame-limit session ID can make the request fit but the response overflow, leaving an open session behind after the client receives an error

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agree this is a gap, but certainly pathological.

peer.fail(reason);
}
});
sessions.insert(

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.

We bound requests, cells, and delegate calls, but not active sessions...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sessions does have some memory pressure through saved values, but otherwise pretty lightweight.

I feel like session load matches thread load state pretty closely but can think about what guarantees we would want to enforce here.

self.respond(request_id, result);
}
HostRequest::ShutdownSession { session_id } => {
let session = self

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.

nit race: This releases the session ID before shutdown and cell-route draining finish

@cconger
cconger marked this pull request as ready for review June 26, 2026 00:05

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a5d75bfdc0

ℹ️ 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".

Comment thread codex-rs/code-mode-host/src/lib.rs Outdated
peer.fail("timed out shutting down code-mode host state".to_string());
}
drop(state);
let failure = peer.failure();

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.

P2 Badge Preserve writer failures observed during shutdown

When shutdown begins while the writer task is still inside write_frame, any broken-pipe/error that the writer supervisor records after this snapshot is lost because failure is read before awaiting writer_supervisor. In that transport-failure race, run can return Ok(()) even though the host failed to write a queued frame; read peer.failure() after the supervisor has finished instead of before dropping the last local peer handle.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed.

Comment thread codex-rs/code-mode-host/src/lib.rs
@cconger
cconger force-pushed the cconger/process-owned-session-runtime-3-host branch from a5d75bf to a1c7a73 Compare June 26, 2026 00:47
@cconger
cconger merged commit da78d5f into main Jun 26, 2026
31 checks passed
@cconger
cconger deleted the cconger/process-owned-session-runtime-3-host branch June 26, 2026 01:00
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants