Allow root turn suspension with live descendants (#54414)

## Why

Live descendants previously blocked suspension of an unfinished root turn, requiring callers to stop and unload them before recovering the root elsewhere.

## What changed

Allow `suspend_turn_and_shutdown` to suspend the root and initiate shutdown of all sessions sharing its local agent runtime, fencing new starts. Remove `SuspendTurnOutcome::HasLiveDescendants`.

Success confirms that the root has stopped and its history writer is flushed and closed; descendant cleanup completes separately. Callers must finish tree shutdown or fence and terminate the tree's persistence writers before transferring ownership. Interrupted descendants are not automatically recovered.

## Testing

Extend integration coverage to verify child shutdown, recovery under the original root turn ID without restarting children, and separate reporting of child writer failures.

GitOrigin-RevId: 5adc240ae6e34654209154ee9324621a2bd604d5
This commit is contained in:
Michael Zeng
2026-10-15 20:57:39 +00:00
committed by copyberry
parent 97ebf2d94d
commit 341de32c33
4 changed files with 125 additions and 73 deletions
+1 -5
View File
@@ -19,12 +19,8 @@ use ts_rs::TS;
/// Result of stopping an unfinished root turn so another worker can recover it.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum SuspendTurnOutcome {
Suspended {
turn_id: String,
},
Suspended { turn_id: String },
NotActive,
/// A currently loaded descendant would remain running after root handoff.
HasLiveDescendants,
UnsupportedTask,
}