Route approvals through the extension decision API (#43432)

## What changed

- Let approval extensions choose between cached approval, synchronous review, and a user prompt for tool and permission requests, while core enforces mandatory Guardian and fresh-review requirements.
- Carry an optional `review_reason` on Guardian assessment events and use it to trigger strict-review notifications, retaining the fallback for older events.
- Require synchronous review when cached evidence has an unusable encrypted parent compaction.

## Testing

Add regression coverage for manual prompts and cached approvals with non-UTF-8 working directories. Update approval contributors in existing tests to use the decision API.

GitOrigin-RevId: a4e66416070bdaa881daa41429c49021629f44c1
This commit is contained in:
jif authored and copyberry committed 2026-09-07 11:07:28 +00:00
1 parent 0df39752cb
commit e1eb98461c
24 files changed
+605 -250

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
//! Supplies action categories to the review extension and enforces host-owned requirements.
use super::GuardianApprovalRequest;
use crate::tools::sandboxing::ApprovalAction;
use codex_protocol::openai_models::GuardianScope;
impl GuardianApprovalRequest {
pub(crate) fn guardian_scope(&self) -> GuardianScope {
match self {
Self::ExecCommand { .. } | Self::WriteStdin { .. } => GuardianScope::Shell,
#[cfg(unix)]
Self::Execve { .. } => GuardianScope::Shell,
Self::ApplyPatch { .. } => GuardianScope::FileChanges,
Self::McpToolCall { server, .. } => GuardianScope::for_mcp_server(server),
Self::NetworkAccess { .. } => GuardianScope::Network,
Self::RequestPermissions { .. } => GuardianScope::Permissions,
}
}
}
impl ApprovalAction {
pub(crate) fn guardian_scope(&self) -> GuardianScope {
match self {
Self::ExecCommand { .. } | Self::WriteStdin { .. } => GuardianScope::Shell,
#[cfg(unix)]
Self::Execve { .. } => GuardianScope::Shell,
Self::ApplyPatch { .. } => GuardianScope::FileChanges,
Self::McpToolCall { server, .. } => GuardianScope::for_mcp_server(server),
Self::NetworkAccess { .. } => GuardianScope::Network,
Self::RequestPermissions { .. } => GuardianScope::Permissions,
}
}
}