Preserve root authorization context in Guardian reviews (#42832)

## Why

Guardian reviews for delegated workers need the current root instructions and verified answers even after the parent context is compacted. Approvals must also become stale when that root authorization changes.

## What changed

- Build bounded root review evidence from retained context, preserving source order and answer scope while prioritizing user instructions over optional assistant context.
- Recover retained instructions from Guardian history after compaction and mark authorization incomplete when required instructions or answers are unavailable.
- Version root authorization in synchronous and reusable review sessions so an allow result is cancelled when its evidence changes.
- Strip parent-only Guardian approvals when forking worker history in retained-context mode.

## Testing

- Cover retained and legacy context modes, oversized evidence, message limits, parent compaction, and authorization changes during review.

GitOrigin-RevId: 658219b7cee08f2752adcea9966268fd21727976
This commit is contained in:
felixxia-oai
2026-09-04 19:19:04 +00:00
committed by copyberry
parent de7874067f
commit 87628df77a
12 changed files with 588 additions and 103 deletions
+1 -1
View File
@@ -162,7 +162,7 @@ pub struct GuardianAuthorizationVersion {
pub user_message_revision: u64,
/// Successful host answers captured by the temporary legacy path.
pub user_input_response_count: usize,
/// False when required retained answers were lost or do not fit the request budget.
/// False when required retained answers or root instructions are unavailable.
pub retained_context_complete: bool,
}