mirror of
https://github.com/openai/codex.git
synced 2026-12-03 00:41:03 +00:00
Default eligible OpenAI sessions to automatic approval review (#65236)
## What changed When `approvals_reviewer` is unset, default to `auto_review` for sessions using the OpenAI model provider with `guardian_approval` enabled, effective workspace-write permissions, and an effective approval policy of `on-request` or `granular`. Otherwise default to `user`. Explicit reviewer settings still take precedence over the default, subject to configuration requirements. When the TUI starts a replacement session on a remote app server, use the server's configured reviewer if the client has no explicit reviewer setting. Update the configuration and app-server schemas to document the new default. ## Testing Cover reviewer eligibility and managed requirements in configuration tests, manual overrides and empty workspace roots in app-server thread-start tests, and remote reviewer precedence in the TUI replacement-session test. GitOrigin-RevId: fd05687accddb8a3ab99df0486b93f3f595fef65
This commit is contained in:
+1
-1
@@ -86,7 +86,7 @@
|
||||
]
|
||||
},
|
||||
"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.",
|
||||
"description": "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Eligible OpenAI sessions default to `auto_review`. `user` requests manual review. `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",
|
||||
|
||||
@@ -650,7 +650,7 @@
|
||||
"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.",
|
||||
"description": "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Eligible OpenAI sessions default to `auto_review`. `user` requests manual review. `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",
|
||||
|
||||
+1
-1
@@ -8466,7 +8466,7 @@
|
||||
"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.",
|
||||
"description": "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Eligible OpenAI sessions default to `auto_review`. `user` requests manual review. `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",
|
||||
|
||||
+1
-1
@@ -1436,7 +1436,7 @@
|
||||
"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.",
|
||||
"description": "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Eligible OpenAI sessions default to `auto_review`. `user` requests manual review. `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",
|
||||
|
||||
@@ -176,7 +176,7 @@
|
||||
"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.",
|
||||
"description": "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Eligible OpenAI sessions default to `auto_review`. `user` requests manual review. `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",
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@
|
||||
"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.",
|
||||
"description": "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Eligible OpenAI sessions default to `auto_review`. `user` requests manual review. `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",
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"type": "string"
|
||||
},
|
||||
"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.",
|
||||
"description": "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Eligible OpenAI sessions default to `auto_review`. `user` requests manual review. `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",
|
||||
|
||||
@@ -202,7 +202,7 @@
|
||||
]
|
||||
},
|
||||
"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.",
|
||||
"description": "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Eligible OpenAI sessions default to `auto_review`. `user` requests manual review. `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",
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
]
|
||||
},
|
||||
"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.",
|
||||
"description": "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Eligible OpenAI sessions default to `auto_review`. `user` requests manual review. `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",
|
||||
|
||||
@@ -202,7 +202,7 @@
|
||||
]
|
||||
},
|
||||
"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.",
|
||||
"description": "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Eligible OpenAI sessions default to `auto_review`. `user` requests manual review. `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",
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@
|
||||
"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.",
|
||||
"description": "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Eligible OpenAI sessions default to `auto_review`. `user` requests manual review. `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",
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"type": "string"
|
||||
},
|
||||
"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.",
|
||||
"description": "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Eligible OpenAI sessions default to `auto_review`. `user` requests manual review. `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",
|
||||
|
||||
@@ -202,7 +202,7 @@
|
||||
]
|
||||
},
|
||||
"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.",
|
||||
"description": "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Eligible OpenAI sessions default to `auto_review`. `user` requests manual review. `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",
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
"type": "string"
|
||||
},
|
||||
"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.",
|
||||
"description": "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Eligible OpenAI sessions default to `auto_review`. `user` requests manual review. `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",
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -5,8 +5,9 @@
|
||||
/**
|
||||
* 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.
|
||||
* ARC escalations. Eligible OpenAI sessions default to `auto_review`. `user`
|
||||
* requests manual review. `auto_review` uses a carefully prompted subagent
|
||||
* to gather relevant context and apply a risk-based decision framework before
|
||||
* approving or denying the request.
|
||||
*/
|
||||
export type ApprovalsReviewer = "user" | "auto_review" | "guardian_subagent";
|
||||
|
||||
@@ -291,9 +291,10 @@ impl From<CoreAskForApproval> for AskForApproval {
|
||||
)]
|
||||
/// 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.
|
||||
/// ARC escalations. Eligible OpenAI sessions default to `auto_review`. `user`
|
||||
/// requests manual review. `auto_review` uses a carefully prompted subagent
|
||||
/// to gather relevant context and apply a risk-based decision framework before
|
||||
/// approving or denying the request.
|
||||
pub enum ApprovalsReviewer {
|
||||
#[serde(rename = "user")]
|
||||
User,
|
||||
@@ -310,7 +311,7 @@ impl JsonSchema for ApprovalsReviewer {
|
||||
fn json_schema(_generator: &mut SchemaGenerator) -> Schema {
|
||||
string_enum_schema_with_description(
|
||||
&["user", "auto_review", "guardian_subagent"],
|
||||
"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.",
|
||||
"Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Eligible OpenAI sessions default to `auto_review`. `user` requests manual review. `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.",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use app_test_support::TestAppServer;
|
||||
use app_test_support::create_mock_responses_server_repeating_assistant;
|
||||
use app_test_support::to_response;
|
||||
use app_test_support::write_chatgpt_auth;
|
||||
use codex_app_server_protocol::ApprovalsReviewer;
|
||||
use codex_app_server_protocol::AskForApproval;
|
||||
use codex_app_server_protocol::ClientRequest;
|
||||
use codex_app_server_protocol::ConfigWarningNotification;
|
||||
@@ -502,6 +503,64 @@ async fn thread_start_provider_model_fallback_ignores_dynamic_catalog() -> Resul
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn thread_start_defaults_to_auto_review_and_respects_manual_override() -> Result<()> {
|
||||
let mut server = TestAppServer::builder()
|
||||
.without_managed_config()
|
||||
.build_initialized()
|
||||
.await?;
|
||||
let params = ThreadStartParams {
|
||||
permissions: Some(":workspace".to_string()),
|
||||
..Default::default()
|
||||
};
|
||||
let default = server.start_thread(params.clone()).await?;
|
||||
let manual = server
|
||||
.start_thread(ThreadStartParams {
|
||||
approvals_reviewer: Some(ApprovalsReviewer::User),
|
||||
..params
|
||||
})
|
||||
.await?;
|
||||
assert_eq!(
|
||||
(default.approvals_reviewer, manual.approvals_reviewer),
|
||||
(ApprovalsReviewer::AutoReview, ApprovalsReviewer::User)
|
||||
);
|
||||
assert_eq!(default.approval_policy, manual.approval_policy);
|
||||
assert_eq!(default.sandbox, manual.sandbox);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn thread_start_defaults_to_manual_review_without_writable_workspace_roots() -> Result<()> {
|
||||
let mut server = TestAppServer::builder()
|
||||
.without_managed_config()
|
||||
.build_initialized()
|
||||
.await?;
|
||||
let profile = json!({ "filesystem": { ":root": "read", ":workspace_roots": "write" } });
|
||||
// An explicit test environment would supply its own workspace roots.
|
||||
let response: ThreadStartResponse = server
|
||||
.request(|request_id| ClientRequest::ThreadStart {
|
||||
request_id,
|
||||
params: ThreadStartParams {
|
||||
config: Some([("permissions".into(), json!({ "dev": profile }))].into()),
|
||||
permissions: Some("dev".into()),
|
||||
runtime_workspace_roots: Some(Vec::new()),
|
||||
..Default::default()
|
||||
},
|
||||
})
|
||||
.await?;
|
||||
|
||||
assert_eq!(
|
||||
(response.sandbox, response.approvals_reviewer),
|
||||
(
|
||||
codex_app_server_protocol::SandboxPolicy::ReadOnly {
|
||||
network_access: false,
|
||||
},
|
||||
ApprovalsReviewer::User,
|
||||
)
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn thread_start_creates_thread_and_emits_started() -> Result<()> {
|
||||
// Provide a mock server and config so model wiring is valid.
|
||||
|
||||
@@ -260,7 +260,7 @@
|
||||
"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.",
|
||||
"description": "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Eligible OpenAI sessions default to `auto_review`. `user` requests manual review. `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",
|
||||
|
||||
@@ -12807,18 +12807,28 @@ fn retired_feature_requirements_do_not_pin_configured_values(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test_case::test_case("", ApprovalsReviewer::AutoReview; "workspace")]
|
||||
#[test_case::test_case("approval_policy = 'never'", ApprovalsReviewer::User; "never")]
|
||||
#[test_case::test_case("model_provider = 'ollama'", ApprovalsReviewer::User; "other_provider")]
|
||||
#[test_case::test_case("approvals_reviewer = 'user'", ApprovalsReviewer::User; "explicit_manual")]
|
||||
#[test_case::test_case("[features]\nguardian_approval = false", ApprovalsReviewer::User; "disabled")]
|
||||
#[tokio::test]
|
||||
async fn approvals_reviewer_defaults_to_manual_only_without_guardian_feature() -> std::io::Result<()>
|
||||
{
|
||||
async fn approvals_reviewer_workspace_default(
|
||||
contents: &str,
|
||||
expected: ApprovalsReviewer,
|
||||
) -> std::io::Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
|
||||
std::fs::write(
|
||||
codex_home.path().join(CONFIG_TOML_FILE),
|
||||
format!("default_permissions = ':workspace'\n{contents}"),
|
||||
)?;
|
||||
let config = ConfigBuilder::without_managed_config_for_tests()
|
||||
.codex_home(codex_home.path().to_path_buf())
|
||||
.fallback_cwd(Some(codex_home.path().to_path_buf()))
|
||||
.build()
|
||||
.await?;
|
||||
|
||||
assert_eq!(config.approvals_reviewer, ApprovalsReviewer::User);
|
||||
assert_eq!(config.approvals_reviewer, expected);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -12853,16 +12863,16 @@ include_instructions = false
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test_case::test_case("default_permissions = ':read-only'"; "read_only")]
|
||||
#[test_case::test_case("default_permissions = ':danger-full-access'"; "full_access")]
|
||||
#[test_case::test_case("approval_policy = { granular = { sandbox_approval = false, rules = false, request_permissions = true, mcp_elicitations = false } }"; "granular_request_permissions")]
|
||||
#[test_case::test_case("approval_policy = { granular = { sandbox_approval = false, rules = false, request_permissions = false, mcp_elicitations = false } }"; "granular_no_requests")]
|
||||
#[tokio::test]
|
||||
async fn approvals_reviewer_stays_manual_only_when_guardian_feature_is_enabled()
|
||||
-> std::io::Result<()> {
|
||||
async fn approvals_reviewer_stays_manual_outside_workspace_write(
|
||||
contents: &str,
|
||||
) -> std::io::Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
std::fs::write(
|
||||
codex_home.path().join(CONFIG_TOML_FILE),
|
||||
r#"[features]
|
||||
guardian_approval = true
|
||||
"#,
|
||||
)?;
|
||||
std::fs::write(codex_home.path().join(CONFIG_TOML_FILE), contents)?;
|
||||
|
||||
let config = ConfigBuilder::without_managed_config_for_tests()
|
||||
.codex_home(codex_home.path().to_path_buf())
|
||||
@@ -12874,42 +12884,32 @@ guardian_approval = true
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test_case::test_case("default_permissions = ':workspace'", "allowed_approvals_reviewers = ['user']", ApprovalsReviewer::User; "require_manual")]
|
||||
#[test_case::test_case("default_permissions = ':read-only'", "allowed_approvals_reviewers = ['guardian_subagent']", ApprovalsReviewer::AutoReview; "require_auto_review")]
|
||||
#[test_case::test_case("default_permissions = ':workspace'\napproval_policy = 'never'", "allowed_approval_policies = ['on-request']", ApprovalsReviewer::AutoReview; "effective_approval_policy")]
|
||||
#[tokio::test]
|
||||
async fn approvals_reviewer_can_be_set_in_config_without_guardian_approval() -> std::io::Result<()>
|
||||
{
|
||||
async fn approvals_reviewer_defaults_follow_requirements(
|
||||
contents: &str,
|
||||
requirements: &str,
|
||||
expected: ApprovalsReviewer,
|
||||
) -> std::io::Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
std::fs::write(
|
||||
codex_home.path().join(CONFIG_TOML_FILE),
|
||||
r#"approvals_reviewer = "user"
|
||||
"#,
|
||||
)?;
|
||||
|
||||
let config = ConfigBuilder::without_managed_config_for_tests()
|
||||
.codex_home(codex_home.path().to_path_buf())
|
||||
.fallback_cwd(Some(codex_home.path().to_path_buf()))
|
||||
.build()
|
||||
.await?;
|
||||
|
||||
assert_eq!(config.approvals_reviewer, ApprovalsReviewer::User);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn requirements_disallowing_default_approvals_reviewer_falls_back_to_required_default()
|
||||
-> std::io::Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
|
||||
std::fs::write(codex_home.path().join(CONFIG_TOML_FILE), contents)?;
|
||||
let config = ConfigBuilder::without_managed_config_for_tests()
|
||||
.codex_home(codex_home.path().to_path_buf())
|
||||
.cloud_config_bundle(
|
||||
CloudConfigBundleFixture::loader_with_enterprise_requirement(
|
||||
r#"allowed_approvals_reviewers = ["guardian_subagent"]"#,
|
||||
),
|
||||
CloudConfigBundleFixture::loader_with_enterprise_requirement(requirements),
|
||||
)
|
||||
.build()
|
||||
.await?;
|
||||
|
||||
assert_eq!(config.approvals_reviewer, ApprovalsReviewer::AutoReview);
|
||||
assert_eq!(
|
||||
(
|
||||
config.approvals_reviewer,
|
||||
config.requested_approvals_reviewer
|
||||
),
|
||||
(expected, None)
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -4228,21 +4228,6 @@ impl Config {
|
||||
);
|
||||
approval_policy = constrained_approval_policy.value();
|
||||
}
|
||||
let approvals_reviewer_was_explicit =
|
||||
approvals_reviewer_override.is_some() || cfg.approvals_reviewer.is_some();
|
||||
let mut approvals_reviewer = approvals_reviewer_override
|
||||
.or(cfg.approvals_reviewer)
|
||||
.unwrap_or(ApprovalsReviewer::User);
|
||||
let requested_approvals_reviewer = approvals_reviewer;
|
||||
if !approvals_reviewer_was_explicit
|
||||
&& let Err(err) = constrained_approvals_reviewer.can_set(&approvals_reviewer)
|
||||
{
|
||||
tracing::warn!(
|
||||
error = %err,
|
||||
"default approvals reviewer is disallowed by requirements; falling back to required default"
|
||||
);
|
||||
approvals_reviewer = constrained_approvals_reviewer.value();
|
||||
}
|
||||
let web_search_mode = resolve_web_search_mode(&cfg, &features, &constrained_web_search_mode);
|
||||
let web_search_config = resolve_web_search_config(&cfg);
|
||||
let experimental_request_user_input_enabled =
|
||||
@@ -4649,12 +4634,6 @@ impl Config {
|
||||
})
|
||||
.map_err(std::io::Error::from)?;
|
||||
}
|
||||
apply_requirement_constrained_value(
|
||||
"approvals_reviewer",
|
||||
approvals_reviewer,
|
||||
&mut constrained_approvals_reviewer,
|
||||
&mut startup_warnings,
|
||||
)?;
|
||||
let permission_profile_was_constrained = apply_requirement_constrained_value(
|
||||
"permission_profile",
|
||||
permission_profile,
|
||||
@@ -4678,6 +4657,39 @@ impl Config {
|
||||
active_permission_profile = None;
|
||||
profile_workspace_roots.clear();
|
||||
}
|
||||
let requested_approvals_reviewer = approvals_reviewer_override.or(cfg.approvals_reviewer);
|
||||
if let Some(reviewer) = requested_approvals_reviewer {
|
||||
apply_requirement_constrained_value(
|
||||
"approvals_reviewer",
|
||||
reviewer,
|
||||
&mut constrained_approvals_reviewer,
|
||||
&mut startup_warnings,
|
||||
)?;
|
||||
} else {
|
||||
let effective_profile = constrained_permission_profile
|
||||
.get()
|
||||
.clone()
|
||||
.materialize_project_roots_with_workspace_roots(&workspace_roots);
|
||||
let reviewer = if model_provider_id == OPENAI_PROVIDER_ID
|
||||
&& features.enabled(Feature::GuardianApproval)
|
||||
&& sandbox_mode_requirement_for_permission_profile(&effective_profile)
|
||||
== SandboxModeRequirement::WorkspaceWrite
|
||||
&& crate::guardian::routes_approval_policy_to_guardian(
|
||||
constrained_approval_policy.value(),
|
||||
ApprovalsReviewer::AutoReview,
|
||||
)
|
||||
{
|
||||
ApprovalsReviewer::AutoReview
|
||||
} else {
|
||||
ApprovalsReviewer::User
|
||||
};
|
||||
if let Err(err) = constrained_approvals_reviewer.set(reviewer) {
|
||||
tracing::warn!(
|
||||
error = %err,
|
||||
"default approvals reviewer is disallowed by requirements; falling back to required default"
|
||||
);
|
||||
}
|
||||
}
|
||||
apply_requirement_constrained_value(
|
||||
"web_search_mode",
|
||||
web_search_mode,
|
||||
@@ -4851,9 +4863,8 @@ impl Config {
|
||||
explicit_permission_profile_mode,
|
||||
custom_permission_profiles,
|
||||
approvals_reviewer: constrained_approvals_reviewer.value(),
|
||||
requested_approvals_reviewer: (requested_approvals_reviewer
|
||||
!= constrained_approvals_reviewer.value())
|
||||
.then_some(requested_approvals_reviewer),
|
||||
requested_approvals_reviewer: requested_approvals_reviewer
|
||||
.filter(|reviewer| *reviewer != constrained_approvals_reviewer.value()),
|
||||
enforce_residency: enforce_residency.value,
|
||||
notify: cfg.notify,
|
||||
base_instructions,
|
||||
|
||||
@@ -189,9 +189,10 @@ impl fmt::Display for ProfileV2Name {
|
||||
#[ts(type = r#""user" | "auto_review" | "guardian_subagent""#)]
|
||||
/// 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.
|
||||
/// ARC escalations. Eligible OpenAI sessions default to `auto_review`. `user`
|
||||
/// requests manual review. `auto_review` uses a carefully prompted subagent
|
||||
/// to gather relevant context and apply a risk-based decision framework before
|
||||
/// approving or denying the request.
|
||||
pub enum ApprovalsReviewer {
|
||||
#[default]
|
||||
#[serde(rename = "user")]
|
||||
@@ -209,7 +210,7 @@ impl JsonSchema for ApprovalsReviewer {
|
||||
fn json_schema(_generator: &mut SchemaGenerator) -> Schema {
|
||||
string_enum_schema_with_description(
|
||||
&["user", "auto_review", "guardian_subagent"],
|
||||
"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.",
|
||||
"Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Eligible OpenAI sessions default to `auto_review`. `user` requests manual review. `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.",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,6 +218,17 @@ impl App {
|
||||
}
|
||||
};
|
||||
if let Some(defaults) = defaults.as_ref() {
|
||||
// A local fallback must not override a reviewer configured on the remote host.
|
||||
if app_server.thread_params_mode() == crate::ThreadParamsMode::Remote
|
||||
&& let Some(reviewer) = defaults.config.approvals_reviewer
|
||||
&& self.harness_overrides.approvals_reviewer.is_none()
|
||||
&& !config
|
||||
.config_layer_stack
|
||||
.layers_high_to_low()
|
||||
.any(|layer| layer.config.get("approvals_reviewer").is_some())
|
||||
{
|
||||
config.approvals_reviewer = reviewer.to_core();
|
||||
}
|
||||
crate::projectless::apply_defaults(
|
||||
&mut config,
|
||||
&self.harness_overrides,
|
||||
|
||||
@@ -849,11 +849,11 @@ async fn replacement_uses_server_defaults_and_preserves_explicit_launch_settings
|
||||
let client_home = tempdir()?;
|
||||
std::fs::write(
|
||||
server_home.path().join("work.config.toml"),
|
||||
"model = \"server-model\"\nmodel_reasoning_effort = \"high\"\ndeveloper_instructions = 'server instructions'\n",
|
||||
"approvals_reviewer = 'user'\nmodel = \"server-model\"\nmodel_reasoning_effort = \"high\"\ndeveloper_instructions = 'server instructions'\n",
|
||||
)?;
|
||||
std::fs::write(
|
||||
client_home.path().join("config.toml"),
|
||||
"model = \"stale-client-model\"\nmodel_reasoning_effort = \"low\"\nmodel_reasoning_summary = \"detailed\"\nfeatures.concurrent_reasoning_summaries = true\nfeatures.terminal_visualization_instructions = true\ndeveloper_instructions = 'client instructions'\n",
|
||||
"default_permissions = ':workspace'\nmodel = \"stale-client-model\"\nmodel_reasoning_effort = \"low\"\nmodel_reasoning_summary = \"detailed\"\nfeatures.concurrent_reasoning_summaries = true\nfeatures.terminal_visualization_instructions = true\ndeveloper_instructions = 'client instructions'\n",
|
||||
)?;
|
||||
if let Some(effort) = managed_effort {
|
||||
let effort = if effort.is_empty() {
|
||||
@@ -1000,6 +1000,7 @@ async fn replacement_uses_server_defaults_and_preserves_explicit_launch_settings
|
||||
assert!(starts[0]["config"].get("model_reasoning_effort").is_none());
|
||||
}
|
||||
if explicit == "saved" {
|
||||
assert_eq!(starts[0]["approvalsReviewer"], "user");
|
||||
assert_eq!(
|
||||
starts[0]["developerInstructions"],
|
||||
format!(
|
||||
|
||||
Reference in New Issue
Block a user