code-mode: move session ownership into runtime (#29285)

## Summary

- Move code-mode cell ownership and shared stored values from
`CodeModeService` into `SessionRuntime`.
- Keep the protocol-facing execute/wait behavior behind the existing
service adapter.
- Add runtime-level ownership and isolation coverage.

## Why

This establishes a transport-neutral session boundary before later
lifecycle and create/observe changes.

## Impact

No intended model-facing behavior change. This is an ownership and
layering refactor.

## Validation

- Stack-tip validation: `just test -p codex-code-mode -p
codex-code-mode-protocol` (70 passed).
- Parent branch: `cconger/code-mode-runtime-compact-03a-runtime-types`.
This commit is contained in:
Channing Conger
2026-06-21 11:18:36 -07:00
committed by GitHub
parent 6d993ca646
commit 63f009e9da
5 changed files with 510 additions and 224 deletions
+2 -9
View File
@@ -1,5 +1,4 @@
use std::sync::Arc;
use std::sync::atomic::Ordering;
use std::time::Duration;
use super::CellId;
@@ -7,7 +6,6 @@ use super::CodeModeNestedToolCall;
use super::CodeModeService;
use super::CodeModeSessionDelegate;
use super::NotificationFuture;
use super::ObserveMode;
use super::RuntimeResponse;
use super::ToolInvocationFuture;
use super::WaitOutcome;
@@ -216,20 +214,15 @@ async fn shutdown_interrupts_cpu_bound_cells() {
#[tokio::test]
async fn start_cell_rejects_new_cell_after_shutdown_begins() {
let service = CodeModeService::new();
service.inner.shutting_down.store(true, Ordering::Release);
service.shutdown().await.unwrap();
let error = service
.start_cell(
cell_id("late-cell"),
execute_request(""),
ObserveMode::YieldAfter(Duration::from_millis(1)),
)
.execute(execute_request("text('late');"))
.await
.err()
.unwrap();
assert_eq!(error, "code mode session is shutting down".to_string());
assert!(service.inner.cells.lock().await.is_empty());
}
#[tokio::test]