Preserve Guardian review evidence across compaction (#41846)

## Why

Context compaction can replace original conversation items that Guardian still needs to review approval-sensitive actions.

## What changed

- Retain a bounded, chronological review history independently of the model's compacted history.
- Keep separate limits for user messages and other transcript items so tool traffic cannot evict user instructions.
- Use the retained evidence for synchronous and asynchronous Guardian transcripts, while resetting it after rollback or history reconstruction.

## Testing

- Cover retention through compaction and eviction, reset behavior after rollback, independent size limits, and asynchronous transcript construction.

GitOrigin-RevId: c5851e992820504fc18de8cfec7f6f9f1b69f316
This commit is contained in:
jif authored and copyberry committed 2026-08-31 13:57:59 +00:00
1 parent e45226e771
commit 1c1e17782a
15 files changed
+468 -31

No files matched your search

@@ -14,4 +14,15 @@ pub trait ConversationHistorySnapshot: Send + Sync {
/// Returns the snapshot's response items in conversation order.
fn items(&self) -> Box<dyn Iterator<Item = &ResponseItem> + Send + '_>;
/// Original review evidence retained across parent compaction, in conversation order.
/// Hosts without separate retention provide their current history.
fn review_items(&self) -> Box<dyn Iterator<Item = &ResponseItem> + Send + '_> {
self.items()
}
/// Changes whenever offsets into the retained review evidence become invalid.
fn review_history_version(&self) -> u64 {
self.history_version()
}
}