Refresh Guardian v3 evidence before retrying an approval review (#63363)

## Why

A user's authorization can change while Guardian is reviewing a tool call.
A retry could reuse the original evidence cutoff and miss a revocation
that arrived during the first attempt.

## What changed

Capture the root thread's history position when the action is bound and
defer evidence routing until Guardian prepares the review. Capture a fresh
position on retries or if authorization changed before the first attempt.
Use bounded history reads to catch up through the selected position and
wait for routing to reach it before submitting the assessment.

## Testing

Extend the app-server test to revoke authorization through a paused user
goal while an MCP tool call's approval is pending. Verify that Guardian
discards the stale allow, sees the revocation on retry, and denies the
tool call. Cover bounded history reads and shared routing progress in
unit tests.

GitOrigin-RevId: d7cf6f03412c4aa5399700427f40710da3123e52
This commit is contained in:
felixxia-oai
2026-11-23 15:57:15 +00:00
committed by copyberry
parent 8b02797a2e
commit 223b61a9a8
9 changed files with 411 additions and 92 deletions
+4 -2
View File
@@ -36,7 +36,8 @@ pub fn reviewer_headers(config: &crate::config::Config) -> crate::CodexResponses
}
}
/// A thread's synchronous reviewer. Bind the evidence catch-up to the action before it waits.
/// A thread's synchronous reviewer. Bind its evidence position before the action waits.
/// Routing may hand the action to a human without ever requesting preparation.
pub trait AttachedReviewer: Send + Sync {
fn bind(self: std::sync::Arc<Self>) -> BoundReviewer;
}
@@ -63,7 +64,8 @@ pub enum ReviewPreparationError {
Cancelled,
}
/// Reserve the actor's reviewer after routing and delivery have covered the bound action.
/// Reserve the actor's reviewer after routing and delivery have covered this attempt.
/// A retry must cover authorization changes since the previous attempt.
pub trait ReviewerPreparation: Send + Sync {
fn prepare<'a>(
&'a self,