permissions: expose reviewer override grant API

This commit is contained in:
Michael Bolin
2026-06-11 12:09:42 -04:00
parent b4445f2758
commit 7a66421d6a
14 changed files with 139 additions and 20 deletions
@@ -58,6 +58,15 @@
},
"type": "object"
},
"ApprovalsReviewer": {
"description": "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Defaults to `user`. `auto_review` uses a carefully prompted subagent to gather relevant context and apply a risk-based decision framework before approving or denying the request. The legacy value `guardian_subagent` is accepted for compatibility.",
"enum": [
"user",
"auto_review",
"guardian_subagent"
],
"type": "string"
},
"FileSystemAccessMode": {
"enum": [
"read",
@@ -288,6 +297,17 @@
}
},
"properties": {
"approvalsReviewer": {
"anyOf": [
{
"$ref": "#/definitions/ApprovalsReviewer"
},
{
"type": "null"
}
],
"description": "Override who reviews later approval prompts for the rest of the current turn."
},
"permissions": {
"$ref": "#/definitions/GrantedPermissionProfile"
},
@@ -3875,6 +3875,17 @@
"PermissionsRequestApprovalResponse": {
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"approvalsReviewer": {
"anyOf": [
{
"$ref": "#/definitions/v2/ApprovalsReviewer"
},
{
"type": "null"
}
],
"description": "Override who reviews later approval prompts for the rest of the current turn."
},
"permissions": {
"$ref": "#/definitions/GrantedPermissionProfile"
},
@@ -1,6 +1,7 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { ApprovalsReviewer } from "./ApprovalsReviewer";
import type { GrantedPermissionProfile } from "./GrantedPermissionProfile";
import type { PermissionGrantScope } from "./PermissionGrantScope";
@@ -8,4 +9,8 @@ export type PermissionsRequestApprovalResponse = { permissions: GrantedPermissio
/**
* Review every subsequent command in this turn before normal sandboxed execution.
*/
strictAutoReview?: boolean, };
strictAutoReview?: boolean,
/**
* Override who reviews later approval prompts for the rest of the current turn.
*/
approvalsReviewer?: ApprovalsReviewer, };
@@ -1,3 +1,4 @@
use super::shared::ApprovalsReviewer;
use super::shared::v2_enum_from_core;
use codex_protocol::approvals::ExecPolicyAmendment as CoreExecPolicyAmendment;
use codex_protocol::approvals::NetworkApprovalContext as CoreNetworkApprovalContext;
@@ -693,4 +694,8 @@ pub struct PermissionsRequestApprovalResponse {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub strict_auto_review: Option<bool>,
/// Override who reviews later approval prompts for the rest of the current turn.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub approvals_reviewer: Option<ApprovalsReviewer>,
}
@@ -708,6 +708,7 @@ fn permissions_request_approval_response_defaults_scope_to_turn() {
assert_eq!(response.scope, PermissionGrantScope::Turn);
assert_eq!(response.strict_auto_review, None);
assert_eq!(response.approvals_reviewer, None);
}
#[test]
@@ -721,6 +722,20 @@ fn permissions_request_approval_response_accepts_strict_auto_review() {
assert_eq!(response.strict_auto_review, Some(true));
}
#[test]
fn permissions_request_approval_response_accepts_approvals_reviewer() {
let response = serde_json::from_value::<PermissionsRequestApprovalResponse>(json!({
"permissions": {},
"approvalsReviewer": "auto_review",
}))
.expect("response should deserialize");
assert_eq!(
response.approvals_reviewer,
Some(ApprovalsReviewer::AutoReview)
);
}
#[test]
fn permission_profile_selection_uses_id_string() {
let start: ThreadStartParams = serde_json::from_value(json!({