Replay guardian checkpoints into a fresh session in tests (#46514)

## Why

Replaying a checkpoint into the original session can let preserved live state
mask missing checkpoint data.

## What changed

Update `guardian_checkpoint_preserves_live_context_without_storage` to restore
forked history into a fresh session with the matching guardian context mode.
Keep the existing context restoration assertions for both `Legacy` and
`ThreadOwned` modes.

GitOrigin-RevId: 211b567f6b33ffca6dc51110a208aec234004b98
This commit is contained in:
jif
2026-09-18 12:46:05 +00:00
committed by copyberry
parent 7fb599de8c
commit 8933a816eb

View File

@@ -87,10 +87,14 @@ async fn guardian_checkpoint_preserves_live_context_without_storage(mode: Guardi
session
.replace_history(Vec::new(), /*reference_context_item*/ None)
.await;
session
.record_initial_history(InitialHistory::Forked(items))
// Replay into a fresh session so preserved live state cannot mask missing checkpoint data.
let (mut fork, _) = make_session_and_context().await;
fork.guardian_context_mode = mode;
fork.state.lock().await.history =
ContextManager::with_guardian_context_mode(mode, &SessionSource::default());
fork.record_initial_history(InitialHistory::Forked(items))
.await;
let restored = session.clone_history().await;
let restored = fork.clone_history().await;
assert_eq!(restored.annotated_items(), expected.annotated_items());
assert_eq!(restored.retained_context(), expected.retained_context());
assert_eq!(