mirror of
https://github.com/openai/codex.git
synced 2026-10-22 17:58:46 +00:00
Keep step settings and approval environments consistent (#46556)
## Why Background processes can outlive their launching turn. Their approval reviews need the originating environment's filesystem restrictions, even when the active turn uses a different environment. Remote restrictions must also be resolved using executor paths rather than the local filesystem. ## What changed - Capture settings and environment selections together in `StepInputs`. Preserve the captured selection during active model updates while allowing environment startup to finish. - Carry environment IDs into Guardian network and `execve` requests, and use the owning process's environment with current review settings. Refresh environment readiness for network requests that fall back to the active turn. - Resolve remote denied paths and globs using the executor's policy context. Decline automatic approval when the request's environment is unavailable or an explicitly denied temporary directory cannot be resolved. ## Testing Add regression coverage for active model updates retaining their environment while the next turn adopts a new selection, background approvals using their owning environment, newly ready network environments, and remote denied paths and globs, including Windows paths and missing temporary-directory metadata. GitOrigin-RevId: b620d4b030c597a4f430fe0500864fa5469db3d4
This commit is contained in:
@@ -253,7 +253,7 @@ async fn request_permissions_routes_to_guardian_when_reviewer_is_enabled() {
|
||||
..RequestPermissionProfile::default()
|
||||
};
|
||||
let environment = turn_context
|
||||
.environments
|
||||
.initial_environments
|
||||
.primary()
|
||||
.expect("primary environment")
|
||||
.selection();
|
||||
@@ -459,7 +459,7 @@ async fn request_permissions_guardian_review_stops_when_cancelled(
|
||||
let cancellation_token = cancellation_token.clone();
|
||||
async move {
|
||||
let environment = turn_context
|
||||
.environments
|
||||
.initial_environments
|
||||
.primary()
|
||||
.expect("primary environment")
|
||||
.selection();
|
||||
@@ -568,7 +568,7 @@ async fn guardian_allows_exec_command_additional_permissions_requests_past_polic
|
||||
.set_permission_profile(codex_protocol::models::PermissionProfile::Disabled)
|
||||
.expect("test setup should allow disabling the permission profile");
|
||||
let TurnEnvironmentState::Ready(environment) =
|
||||
&mut turn_context_raw.environments.environments[0]
|
||||
&mut turn_context_raw.initial_environments.environments[0]
|
||||
else {
|
||||
panic!("primary environment should be ready");
|
||||
};
|
||||
@@ -692,7 +692,7 @@ async fn strict_auto_review_turn_grant_forces_guardian_for_exec_command_policy_s
|
||||
})
|
||||
.expect("test setup should allow external sandbox permissions");
|
||||
let TurnEnvironmentState::Ready(environment) =
|
||||
&mut turn_context_raw.environments.environments[0]
|
||||
&mut turn_context_raw.initial_environments.environments[0]
|
||||
else {
|
||||
panic!("primary environment should be ready");
|
||||
};
|
||||
@@ -798,7 +798,8 @@ async fn network_approval_uses_published_task_authority_within_same_turn(
|
||||
.task
|
||||
.as_ref()
|
||||
.expect("active task");
|
||||
let mut settings = task.turn_context.current_settings.load_full();
|
||||
let current = task.turn_context.next_step_input.load_full();
|
||||
let mut settings = Arc::clone(¤t.settings);
|
||||
update_selected_settings_for_test(Arc::make_mut(&mut settings), |selected| {
|
||||
selected
|
||||
.approval_policy
|
||||
@@ -806,7 +807,12 @@ async fn network_approval_uses_published_task_authority_within_same_turn(
|
||||
.expect("update policy");
|
||||
selected.approvals_reviewer = ApprovalsReviewer::User;
|
||||
});
|
||||
task.turn_context.current_settings.store(settings);
|
||||
task.turn_context
|
||||
.next_step_input
|
||||
.store(Arc::new(StepInputs {
|
||||
settings,
|
||||
environments: current.environments.clone(),
|
||||
}));
|
||||
}
|
||||
let decision = session
|
||||
.services
|
||||
|
||||
Reference in New Issue
Block a user