mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50: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:
@@ -2,6 +2,7 @@
|
||||
|
||||
use super::session::Session;
|
||||
use super::session::SessionConfiguration;
|
||||
use super::step_context::StepInputs;
|
||||
use super::step_settings::ResolvedStepSettings;
|
||||
use super::step_settings::StepSettingsConstraints;
|
||||
use super::step_settings::StepSettingsUpdate;
|
||||
@@ -249,7 +250,7 @@ impl Session {
|
||||
(
|
||||
Arc::clone(&task.turn_context),
|
||||
Arc::clone(&task.done),
|
||||
task.turn_context.current_settings.load_full(),
|
||||
task.turn_context.next_step_input.load_full(),
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -277,7 +278,7 @@ impl Session {
|
||||
// settings rules. The task can progress, finish, or be cancelled while
|
||||
// preparation awaits; no publication locks are held here.
|
||||
let prepared = self
|
||||
.prepare_step_settings_activation(&turn_context, ¤t, &update)
|
||||
.prepare_step_settings_activation(&turn_context, ¤t.settings, &update)
|
||||
.await;
|
||||
let active = self.active_turn.lock().await;
|
||||
let Some(task) = active.as_ref().and_then(|active| active.task.as_ref()) else {
|
||||
@@ -288,7 +289,7 @@ impl Session {
|
||||
// A mismatch abandons the update without retrying or retargeting.
|
||||
if !Arc::ptr_eq(&task.done, &task_done)
|
||||
|| !Arc::ptr_eq(&task.turn_context, &turn_context)
|
||||
|| !Arc::ptr_eq(&task.turn_context.current_settings.load_full(), ¤t)
|
||||
|| !Arc::ptr_eq(&task.turn_context.next_step_input.load_full(), ¤t)
|
||||
|| task.cancellation_token.is_cancelled()
|
||||
{
|
||||
return TurnSettingsUpdateOutcome::TargetUnavailable;
|
||||
@@ -316,7 +317,7 @@ impl Session {
|
||||
}
|
||||
check_legacy_turn_safety(
|
||||
&turn_context,
|
||||
¤t,
|
||||
¤t.settings,
|
||||
&destination,
|
||||
&state.session_configuration.original_config_do_not_use,
|
||||
)
|
||||
@@ -327,8 +328,11 @@ impl Session {
|
||||
// Publish the immutable snapshot. Frozen initial settings, existing step
|
||||
// captures, and future thread settings are not changed.
|
||||
task.turn_context
|
||||
.current_settings
|
||||
.store(Arc::new(destination));
|
||||
.next_step_input
|
||||
.store(Arc::new(StepInputs {
|
||||
settings: Arc::new(destination),
|
||||
environments: current.environments.clone(),
|
||||
}));
|
||||
TurnSettingsUpdateOutcome::Applied
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user