code-mode: make session shutdown authoritative (#29287)

## Summary

- Give each session and cell a hierarchical cancellation token.
- Track cell tasks so shutdown waits for admitted actors without polling
the registry.
- Make shutdown authoritative across concurrent admission and
non-cooperative callbacks.

## Why

A best-effort registry scan can miss cells admitted concurrently or
blocked behind the registry lock.

## Impact

Session shutdown reliably stops every admitted cell and rejects new work
once shutdown begins.

## Validation

- Stack-tip validation: `just test -p codex-code-mode -p
codex-code-mode-protocol` (70 passed).
- Parent branch: `cconger/code-mode-runtime-compact-03c-terminal-state`.
This commit is contained in:
Channing Conger
2026-06-21 13:15:38 -07:00
committed by GitHub
Unverified
parent f774455c3a
commit 9c79d87d06
6 changed files with 107 additions and 37 deletions
@@ -289,7 +289,10 @@ async fn observed_natural_completion_wins_over_termination() {
tokio::time::timeout(Duration::from_secs(1), async {
loop {
let response = service
.execute(execute_request(r#"text(String(load("finished")));"#))
.execute(ExecuteRequest {
yield_time_ms: Some(60_000),
..execute_request(r#"text(String(load("finished")));"#)
})
.await
.unwrap()
.initial_response()