Add Guardian internal session support (#39994)

## What changed

- Add an extension API for spawning host-owned internal sessions and a
  `ThreadReadyInput` lifecycle callback that runs after thread registration.
- Add Guardian reviewer session scaffolding that records the parent thread and
  effective model, plus the under-development `guardian_ext` feature flag.
- Start internal sessions with fresh history while preserving parent lineage,
  shared session controls, and internal-thread visibility rules.
- Scope internal-session prompt cache keys to their source and parent thread,
  and expose `guardian` as an internal session source.

## Testing

- Cover internal-session spawning, parent metadata, history isolation, prompt
  cache keys, and extension spawner argument forwarding.

GitOrigin-RevId: 682dae80397d62bb36247796b447042e760ca364
This commit is contained in:
Won Park
2026-08-21 18:59:59 +00:00
committed by copyberry
parent 79b7606803
commit 56012fafb8
22 changed files with 402 additions and 10 deletions

View File

@@ -2650,6 +2650,7 @@ impl FromStr for ThreadSource {
#[ts(rename_all = "snake_case")]
pub enum InternalSessionSource {
MemoryConsolidation,
Guardian,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, TS)]
@@ -2822,6 +2823,7 @@ impl fmt::Display for InternalSessionSource {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
InternalSessionSource::MemoryConsolidation => f.write_str("memory_consolidation"),
InternalSessionSource::Guardian => f.write_str("guardian"),
}
}
}