Preserve Guardian evidence during checkpoint migration (#45789)

## Why

A checkpoint produced by a previous model may be incompatible with the selected Guardian reviewer. Legacy review must retain user restrictions and verified answers across compaction and restart until a compatible checkpoint is available.

## What changed

- Expose retained user evidence independently of whether Guardian reviews the legacy transcript or parent context.
- Resolve the selected reviewer's compaction compatibility hash during resume and remote compaction. Preserve the legacy transcript when checkpoint compatibility is unknown or mismatched.
- Activate parent-context review immediately after compatible compaction and invalidate pending reviews bound to the previous evidence policy. Ordinary compaction preserves pending reviews.
- Keep strict compatibility checks for previously migrated checkpoints whose complete legacy transcript is no longer available.

## Testing

Add coverage for mismatched checkpoint hashes, retained evidence during legacy review, and pending-review cancellation on migration. Add a request-history scenario covering a model switch, incompatible automatic compaction, restart, and compatible manual compaction with preserved user restrictions and verified answers.

GitOrigin-RevId: b52bfd7c21ce7ebed482174c8d7c327e50b1ada8
This commit is contained in:
felixxia-oai authored and copyberry committed 2026-09-15 20:41:39 +00:00
1 parent 0c3a14bbc2
commit c51cb968e4
22 files changed
+841 -281

No files matched your search

+2
View File
@@ -86,6 +86,7 @@ pub(crate) struct CompactedHistoryMetadata {
pub(crate) window_ids: AutoCompactWindowIds,
pub(crate) compaction_response_id: Option<String>,
pub(crate) compaction_model_hash: Option<String>,
pub(crate) reviewer_compaction_hash: Option<String>,
}
pub(crate) async fn build_compaction_initial_context(
@@ -388,6 +389,7 @@ async fn run_compact_task_inner_impl(
window_ids,
compaction_response_id: Some(compaction_response_id),
compaction_model_hash: turn_context.model_info().comp_hash.clone(),
reviewer_compaction_hash: None,
},
)
.await;