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

@@ -18,11 +18,17 @@ pub trait ConversationHistorySnapshot: Send + Sync {
fn items(&self) -> Box<dyn Iterator<Item = &ResponseItem> + Send + '_>;
/// Host-owned retained facts captured atomically with the parent model window.
/// Legacy hosts can withhold these facts to preserve their existing reviewer policy.
/// These facts may be available while review still uses a legacy transcript.
fn retained_context(&self) -> Option<&RetainedContext> {
None
}
/// Whether review uses the parent checkpoint and model window instead of a legacy transcript.
/// Checkpoint compatibility is independent of access to retained user evidence.
fn uses_parent_context_for_review(&self) -> bool {
self.retained_context().is_some()
}
/// Producer compatibility recorded on the latest opaque checkpoint. Missing provenance
/// must not be inferred from the currently selected model, including after resume.
fn latest_compaction_model_hash(&self) -> Option<&str> {