mirror of
https://github.com/openai/codex.git
synced 2026-11-13 06:45:07 +00:00
Require automatic review for high-risk Guardian v2 actions (#38569)
## What changed - Add a thread-scoped extension API for requesting automatic review, resolving multiple contributors to the strongest requirement. - Have Guardian v2 request automatic review when it is enabled and the latest `action_risk` score is at least `0.8`. - Honor extension review requirements across tool approvals, MCP elicitation, and remote execution while preserving host configuration and managed-policy constraints. ## Testing - Cover contributor registration and requirement resolution. - Verify Guardian v2 requests review at the threshold, returns to the default below it, and does not affect threads where the extension is disabled. - Exercise extension-requested strict review with a remote model override. GitOrigin-RevId: 6329fc23585d5cc7173c39bb9952c3109ec3884b
This commit is contained in:
1 parent
d40dfcc3c7
commit
1c4f42863c
11 files changed
+187
-15
No files matched your search
@@ -2512,7 +2512,9 @@ impl Session {
|
||||
});
|
||||
};
|
||||
|
||||
if crate::guardian::routes_approval_to_guardian(turn_context.as_ref()) {
|
||||
if crate::guardian::routes_approval_to_guardian(turn_context.as_ref())
|
||||
|| self.extension_strict_auto_review_enabled().await
|
||||
{
|
||||
let originating_turn_state = {
|
||||
let active = self.active_turn.lock().await;
|
||||
active.as_ref().map(|active| Arc::clone(&active.turn_state))
|
||||
@@ -2851,11 +2853,41 @@ impl Session {
|
||||
pub(crate) async fn active_turn_context_and_strict_auto_review(
|
||||
&self,
|
||||
) -> Option<(Arc<TurnContext>, bool)> {
|
||||
let extension_strict_auto_review = self.extension_strict_auto_review_enabled().await;
|
||||
let active = self.active_turn.lock().await;
|
||||
let active = active.as_ref()?;
|
||||
let turn_context = Arc::clone(&active.task.as_ref()?.turn_context);
|
||||
let ts = active.turn_state.lock().await;
|
||||
Some((turn_context, ts.strict_auto_review_enabled()))
|
||||
Some((
|
||||
turn_context,
|
||||
ts.strict_auto_review_enabled() || extension_strict_auto_review,
|
||||
))
|
||||
}
|
||||
|
||||
pub(crate) async fn extension_strict_auto_review_enabled(&self) -> bool {
|
||||
if self
|
||||
.services
|
||||
.extensions
|
||||
.approval_requirement(&self.services.thread_extension_data)
|
||||
!= codex_extension_api::ApprovalRequirement::RequireAutomaticReview
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
let state = self.state.lock().await;
|
||||
let configuration = &state.session_configuration;
|
||||
!configuration.trusted_guardian_reviewer
|
||||
&& configuration
|
||||
.original_config_do_not_use
|
||||
.features
|
||||
.enabled(Feature::GuardianApproval)
|
||||
&& configuration
|
||||
.original_config_do_not_use
|
||||
.config_layer_stack
|
||||
.requirements()
|
||||
.approvals_reviewer
|
||||
.can_set(&ApprovalsReviewer::AutoReview)
|
||||
.is_ok()
|
||||
}
|
||||
|
||||
pub(crate) async fn granted_session_permissions(
|
||||
|
||||
Reference in new issue
Block a user