Fix turn interrupt reply ordering and shutdown handling (#62066)

## Why

A delayed terminal event from an earlier turn could acknowledge interrupts for a later turn. Interrupts could also remain pending after the thread listener shut down.

## What changed

- Associate pending `turn/interrupt` requests with their target turn and reply only when that turn completes or aborts.
- Track the current Core turn through stop hooks and resolve review delegate IDs to the owning turn when validating interrupts.
- Settle pending interrupts with an error on listener shutdown and reject further interrupts against the retired runtime.

## Testing

Add regression tests for delayed terminal events, queued turn starts, review delegates, and interrupt handling during thread revert and runtime replacement.

GitOrigin-RevId: 9695fc3f718baa6b792a14d54136bb87fc003100
This commit is contained in:
jif
2026-11-17 15:33:21 +00:00
committed by copyberry
parent 0cc88d0c74
commit 58627e6fea
9 changed files with 659 additions and 47 deletions
+1
View File
@@ -367,6 +367,7 @@ impl Session {
}
let turn = active.get_or_insert_with(ActiveTurn::default);
debug_assert!(turn.task.is_none());
turn.turn_id = Some(turn_context.sub_id.clone());
turn.finishing = None;
Arc::clone(&turn.turn_state)
};