Honor model-provided Guardian review policies (#42744)

## What changed

- Add optional per-model Guardian modes for computer use, shell, code mode,
  file changes, MCP, network, and permission requests.
- Apply disabled, synchronous, or adaptive review by action category while
  preserving legacy configuration when model policy is absent.
- Bind cached risk scores to the active model policy, thread settings, and
  environment selections so outdated scores cannot approve later actions.
- Keep unknown review modes on the synchronous path and ignore unknown policy
  fields for forward compatibility.

## Testing

- Cover policy serialization, legacy fallback, scoped tool classification,
  disabled categories, and score invalidation after policy changes.

GitOrigin-RevId: f334a5f4fffb198da66cde3a400233e0df650516
This commit is contained in:
jif authored and copyberry committed 2026-09-04 11:59:18 +00:00
1 parent 9d253c885c
commit 4e48cd02da
26 files changed
+654 -186

No files matched your search

@@ -11,10 +11,7 @@ use crate::ConversationHistorySnapshot;
use crate::ExtensionData;
/// Thread-local state installed only after Guardian V2's async classifier initializes.
pub struct GuardianV2Enabled {
/// Computer-use classification remains active for models requiring synchronous review.
pub computer_use_only: bool,
}
pub struct GuardianV2Enabled;
/// Classification returned by an approval reviewer.
#[derive(Clone, Debug, Eq, PartialEq)]