Enforce automatic review for managed models (#37511)

## What changed

- Add the managed `auto_review.required_on_models` requirement, unioning model slugs across requirement layers and exposing the result through `configRequirements/read`.
- Force listed models to use `on-request` approvals with the `auto_review` reviewer. Downgrade Full Access to workspace-write when starting a protected session, and reject incompatible runtime overrides or use when automatic review is disabled.
- Preserve these protections across thread starts, resumes, forks, model changes, turn overrides, MCP approvals, and TUI session attachment.

## Testing

- Add coverage for layered model requirements and exact provider-alias matching.
- Add app-server tests for protected thread lifecycle operations, unsafe setting overrides, legacy thread upgrades, disabled automatic review, and requirements API output.

GitOrigin-RevId: c4b1d52c3b5b75e86880725412b8f0812e0dfcd9
This commit is contained in:
viyatb-oai authored and copyberry committed 2026-08-07 23:43:14 +00:00
1 parent 8073dbb20b
commit 208f05b233
37 files changed
+944 -36

No files matched your search

+22
View File
@@ -1233,6 +1233,28 @@ impl App {
turns: Vec<Turn>,
presentation: ThreadAttachPresentation,
) -> Result<()> {
if let Err(err) = self
.config
.permissions
.approval_policy
.set(session.approval_policy.to_core())
{
tracing::warn!(%err, "failed to sync app approval policy from thread session");
}
if let Err(err) = self
.config
.permissions
.set_permission_profile_from_session_snapshot(
PermissionProfileSnapshot::from_session_snapshot(
session.permission_profile.clone(),
session.active_permission_profile.clone(),
),
)
{
tracing::warn!(%err, "failed to sync app permissions from thread session");
}
self.config.approvals_reviewer = session.approvals_reviewer;
let thread_id = session.thread_id;
self.primary_thread_id = Some(thread_id);
self.primary_session_configured = Some(session.clone());
+11
View File
@@ -2001,6 +2001,17 @@ fn display_permission_profile_from_thread_response(
thread_params_mode: ThreadParamsMode,
) -> PermissionProfile {
match thread_params_mode {
ThreadParamsMode::Embedded
if matches!(
config.permissions.effective_permission_profile(),
PermissionProfile::Disabled
) && !matches!(
sandbox,
codex_app_server_protocol::SandboxPolicy::DangerFullAccess
) =>
{
PermissionProfile::from_legacy_sandbox_policy_for_cwd(&sandbox.to_core(), cwd)
}
ThreadParamsMode::Embedded => config.permissions.effective_permission_profile(),
ThreadParamsMode::Remote => {
PermissionProfile::from_legacy_sandbox_policy_for_cwd(&sandbox.to_core(), cwd)
@@ -104,12 +104,17 @@ impl ChatWidget {
name: APPROVE_FOR_ME_LABEL.to_string(),
description: Some(AUTO_REVIEW_DESCRIPTION.to_string()),
is_current: current_review_policy == ApprovalsReviewer::AutoReview
&& Self::preset_matches_current(
&& (Self::preset_matches_current(
current_approval,
&current_permission_profile,
self.config.cwd.as_path(),
&preset,
),
) || (current_approval == AskForApproval::OnRequest
&& self
.config
.config_layer_stack
.requirements()
.auto_review_required_for_model(self.current_model()))),
actions: self.permission_mode_actions(
&preset,
APPROVE_FOR_ME_LABEL.to_string(),
@@ -393,8 +398,6 @@ impl ChatWidget {
PermissionProfile::Managed { .. }
) && file_system_policy.can_write_path_with_cwd(cwd, cwd)
&& !file_system_policy.has_full_disk_write_access()
&& current_permission_profile.network_sandbox_policy()
== preset.permission_profile.network_sandbox_policy()
}
_ => current_permission_profile == &preset.permission_profile,
}
+1
View File
@@ -975,6 +975,7 @@ interrupt_message = false
enforce_residency: Some(ResidencyRequirement::Us),
network: None,
permissions: None,
auto_review: None,
models: None,
};