[codex] Remove async_trait from first-party code (#27475)

## Why

First-party async traits should expose their `Send` contracts explicitly
without requiring `async_trait`. This completes the migration pattern
established in #27303 and #27304.

## What changed

- Replaced the remaining first-party `async_trait` traits with native
return-position `impl Future + Send` where statically dispatched and
explicit boxed `Send` futures where object safety is required.
- Kept implementations behavior-preserving, outlining existing async
bodies into inherent methods where that keeps the diff reviewable.
- Removed all direct first-party `async-trait` dependencies and the
workspace dependency declaration.
- Added a cargo-deny policy that permits `async-trait` only through the
remaining transitive wrapper crates.
- Updated `rand` from 0.8.5 to 0.8.6 to resolve RUSTSEC-2026-0097 and
keep the full cargo-deny check passing.

## Validation

- `just test -p codex-exec-server`: 216 passed, 2 skipped.
- `just test -p codex-model-provider`: 39 passed.
- `just test -p codex-core` and `just test`: changed tests passed;
remaining failures are environment-sensitive suites unrelated to this
migration.
- `cargo deny check`
- `just fix`
- `just fmt`
- `cargo shear`
- `just bazel-lock-check`
This commit is contained in:
Adam Perry @ OpenAI authored and GitHub committed 2026-06-11 18:16:39 -07:00
1 parent 1829ed1122
commit 5a56caf18c
98 files changed
+2010 -1050

No files matched your search

+35 -23
View File
@@ -10,10 +10,9 @@ use crate::session::turn_context::TurnContext;
use crate::tools::context::ExecCommandToolOutput;
use crate::unified_exec::WriteStdinRequest;
use crate::unified_exec::process::OutputHandles;
use async_trait::async_trait;
use codex_exec_server::ExecProcess;
use codex_exec_server::ExecProcessEventReceiver;
use codex_exec_server::ExecServerError;
use codex_exec_server::ExecProcessFuture;
use codex_exec_server::ProcessId;
use codex_exec_server::ProcessSignal;
use codex_exec_server::ReadResponse;
@@ -218,7 +217,31 @@ struct BlockingTerminateExecProcess {
wake_tx: watch::Sender<u64>,
}
#[async_trait]
impl BlockingTerminateExecProcess {
async fn read(&self) -> Result<ReadResponse, codex_exec_server::ExecServerError> {
Ok(ReadResponse {
chunks: Vec::new(),
next_seq: 1,
exited: false,
exit_code: None,
closed: false,
failure: None,
})
}
async fn write(&self) -> Result<WriteResponse, codex_exec_server::ExecServerError> {
Ok(WriteResponse {
status: WriteStatus::Accepted,
})
}
async fn terminate(&self) -> Result<(), codex_exec_server::ExecServerError> {
let _ = self.terminate_started.send(true);
self.allow_terminate.notified().await;
Ok(())
}
}
impl ExecProcess for BlockingTerminateExecProcess {
fn process_id(&self) -> &ProcessId {
&self.process_id
@@ -232,36 +255,25 @@ impl ExecProcess for BlockingTerminateExecProcess {
ExecProcessEventReceiver::empty()
}
async fn read(
fn read(
&self,
_after_seq: Option<u64>,
_max_bytes: Option<usize>,
_wait_ms: Option<u64>,
) -> Result<ReadResponse, ExecServerError> {
Ok(ReadResponse {
chunks: Vec::new(),
next_seq: 1,
exited: false,
exit_code: None,
closed: false,
failure: None,
})
) -> ExecProcessFuture<'_, ReadResponse> {
Box::pin(BlockingTerminateExecProcess::read(self))
}
async fn write(&self, _chunk: Vec<u8>) -> Result<WriteResponse, ExecServerError> {
Ok(WriteResponse {
status: WriteStatus::Accepted,
})
fn write(&self, _chunk: Vec<u8>) -> ExecProcessFuture<'_, WriteResponse> {
Box::pin(BlockingTerminateExecProcess::write(self))
}
async fn signal(&self, _signal: ProcessSignal) -> Result<(), ExecServerError> {
Ok(())
fn signal(&self, _signal: ProcessSignal) -> ExecProcessFuture<'_, ()> {
Box::pin(async { Ok(()) })
}
async fn terminate(&self) -> Result<(), ExecServerError> {
let _ = self.terminate_started.send(true);
self.allow_terminate.notified().await;
Ok(())
fn terminate(&self) -> ExecProcessFuture<'_, ()> {
Box::pin(BlockingTerminateExecProcess::terminate(self))
}
}
+38 -29
View File
@@ -1,8 +1,8 @@
use super::process::UnifiedExecProcess;
use crate::unified_exec::UnifiedExecError;
use async_trait::async_trait;
use codex_exec_server::ExecProcess;
use codex_exec_server::ExecProcessEventReceiver;
use codex_exec_server::ExecProcessFuture;
use codex_exec_server::ExecServerError;
use codex_exec_server::ProcessId;
use codex_exec_server::ProcessSignal;
@@ -26,26 +26,8 @@ struct MockExecProcess {
wake_tx: watch::Sender<u64>,
}
#[async_trait]
impl ExecProcess for MockExecProcess {
fn process_id(&self) -> &ProcessId {
&self.process_id
}
fn subscribe_wake(&self) -> watch::Receiver<u64> {
self.wake_tx.subscribe()
}
fn subscribe_events(&self) -> ExecProcessEventReceiver {
ExecProcessEventReceiver::empty()
}
async fn read(
&self,
_after_seq: Option<u64>,
_max_bytes: Option<usize>,
_wait_ms: Option<u64>,
) -> Result<ReadResponse, ExecServerError> {
impl MockExecProcess {
async fn read(&self) -> Result<ReadResponse, ExecServerError> {
Ok(self
.read_responses
.lock()
@@ -61,14 +43,6 @@ impl ExecProcess for MockExecProcess {
}))
}
async fn write(&self, _chunk: Vec<u8>) -> Result<WriteResponse, ExecServerError> {
Ok(self.write_response.clone())
}
async fn signal(&self, _signal: ProcessSignal) -> Result<(), ExecServerError> {
Ok(())
}
async fn terminate(&self) -> Result<(), ExecServerError> {
if let Some(message) = &self.terminate_error {
return Err(ExecServerError::Protocol(message.clone()));
@@ -77,6 +51,41 @@ impl ExecProcess for MockExecProcess {
}
}
impl ExecProcess for MockExecProcess {
fn process_id(&self) -> &ProcessId {
&self.process_id
}
fn subscribe_wake(&self) -> watch::Receiver<u64> {
self.wake_tx.subscribe()
}
fn subscribe_events(&self) -> ExecProcessEventReceiver {
ExecProcessEventReceiver::empty()
}
fn read(
&self,
_after_seq: Option<u64>,
_max_bytes: Option<usize>,
_wait_ms: Option<u64>,
) -> ExecProcessFuture<'_, ReadResponse> {
Box::pin(MockExecProcess::read(self))
}
fn write(&self, _chunk: Vec<u8>) -> ExecProcessFuture<'_, WriteResponse> {
Box::pin(async { Ok(self.write_response.clone()) })
}
fn signal(&self, _signal: ProcessSignal) -> ExecProcessFuture<'_, ()> {
Box::pin(async { Ok(()) })
}
fn terminate(&self) -> ExecProcessFuture<'_, ()> {
Box::pin(MockExecProcess::terminate(self))
}
}
async fn remote_process(
write_status: WriteStatus,
terminate_error: Option<String>,