mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Preserve environment configuration ownership (#38678)
## Why Environment attachments can either inherit configuration from their thread or provide their own. Later thread setting updates must refresh inherited configuration without overwriting attachment-owned permissions and capability roots. ## What changed - Resolve each attachment's configuration when it is selected and retain whether it came from the thread or the attachment owner. - Apply subsequent thread configuration updates only to thread-owned attachments, while preserving ownership across snapshots and child threads. - Keep the resolved configuration with the environment selection so runtime consumers use a single canonical value. ## Testing - Extend remote-environment coverage to verify that thread-owned permissions follow thread updates while owner-provided read-only permissions remain in effect. - Cover configuration inheritance, attachment replacement, and owner-configured capability roots. GitOrigin-RevId: fe70c4be5f151432b69bf4b141e316faa89036ae
This commit is contained in:
1 parent
233739e76a
commit
22bf16a37e
23 files changed
+343
-192
No files matched your search
@@ -1,5 +1,6 @@
|
||||
use super::*;
|
||||
use crate::config::PermissionProfileSnapshot;
|
||||
use crate::environment_selection::EnvironmentConfigOrigin;
|
||||
use crate::tools::sandboxing::SandboxAttempt;
|
||||
use codex_protocol::config_types::WindowsSandboxLevel;
|
||||
use codex_protocol::models::AdditionalPermissionProfile;
|
||||
@@ -24,15 +25,17 @@ fn test_turn_environment(environment_id: &str) -> crate::session::turn_context::
|
||||
environment_id: environment_id.to_string(),
|
||||
cwd: PathUri::from_abs_path(&std::env::temp_dir().abs()),
|
||||
workspace_roots: Vec::new(),
|
||||
config: EnvironmentConfigState::FromThread,
|
||||
config: EnvironmentConfigState::Ready(EnvironmentConfig {
|
||||
allow_login_shell: true,
|
||||
permission_profile: PermissionProfileSnapshot::legacy(
|
||||
PermissionProfile::read_only(),
|
||||
),
|
||||
selected_capability_roots: Vec::new(),
|
||||
}),
|
||||
},
|
||||
EnvironmentConfigOrigin::Thread,
|
||||
std::sync::Arc::new(codex_exec_server::Environment::default_for_tests()),
|
||||
/*shell*/ None,
|
||||
EnvironmentConfig {
|
||||
allow_login_shell: true,
|
||||
permission_profile: PermissionProfileSnapshot::legacy(PermissionProfile::read_only()),
|
||||
selected_capability_roots: Vec::new(),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use super::*;
|
||||
use crate::config::PermissionProfileSnapshot;
|
||||
use crate::environment_selection::EnvironmentConfigOrigin;
|
||||
use crate::tools::approvals::ApprovalCacheKey;
|
||||
use codex_exec_server::Environment;
|
||||
use codex_protocol::models::PermissionProfile;
|
||||
@@ -21,17 +22,17 @@ async fn approval_key_uses_path_uri_and_includes_environment_id() {
|
||||
environment_id: "remote".to_string(),
|
||||
cwd: PathUri::from_abs_path(&cwd),
|
||||
workspace_roots: Vec::new(),
|
||||
config: EnvironmentConfigState::FromThread,
|
||||
config: EnvironmentConfigState::Ready(EnvironmentConfig {
|
||||
allow_login_shell: true,
|
||||
permission_profile: PermissionProfileSnapshot::legacy(
|
||||
PermissionProfile::read_only(),
|
||||
),
|
||||
selected_capability_roots: Vec::new(),
|
||||
}),
|
||||
},
|
||||
EnvironmentConfigOrigin::Thread,
|
||||
Arc::new(Environment::default_for_tests()),
|
||||
/*shell*/ None,
|
||||
EnvironmentConfig {
|
||||
allow_login_shell: true,
|
||||
permission_profile: PermissionProfileSnapshot::legacy(
|
||||
PermissionProfile::read_only(),
|
||||
),
|
||||
selected_capability_roots: Vec::new(),
|
||||
},
|
||||
),
|
||||
shell_type: None,
|
||||
hook_command: "echo hello".to_string(),
|
||||
|
||||
@@ -514,6 +514,7 @@ impl<'a> ToolRuntime<UnifiedExecRequest, UnifiedExecAttempt> for UnifiedExecRunt
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::config::PermissionProfileSnapshot;
|
||||
use crate::environment_selection::EnvironmentConfigOrigin;
|
||||
use crate::exec::DEFAULT_EXEC_COMMAND_TIMEOUT_MS;
|
||||
use crate::tools::sandboxing::ToolRuntime;
|
||||
use codex_exec_server::Environment;
|
||||
@@ -536,17 +537,17 @@ mod tests {
|
||||
environment_id: LOCAL_ENVIRONMENT_ID.to_string(),
|
||||
cwd,
|
||||
workspace_roots: Vec::new(),
|
||||
config: EnvironmentConfigState::FromThread,
|
||||
config: EnvironmentConfigState::Ready(EnvironmentConfig {
|
||||
allow_login_shell: true,
|
||||
permission_profile: PermissionProfileSnapshot::legacy(
|
||||
PermissionProfile::read_only(),
|
||||
),
|
||||
selected_capability_roots: Vec::new(),
|
||||
}),
|
||||
},
|
||||
EnvironmentConfigOrigin::Thread,
|
||||
Arc::new(Environment::default_for_tests()),
|
||||
/*shell*/ None,
|
||||
EnvironmentConfig {
|
||||
allow_login_shell: true,
|
||||
permission_profile: PermissionProfileSnapshot::legacy(
|
||||
PermissionProfile::read_only(),
|
||||
),
|
||||
selected_capability_roots: Vec::new(),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user