mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Carry sandbox intent to remote exec servers (#29108)
## What changed PR #29099 stopped sending the orchestrator's concrete sandbox wrapper to a remote exec-server. Remote commands now arrive as plain native argv. This PR adds the next piece: Codex also sends portable sandbox intent next to that plain argv. For a remote unified-exec command, the request can now include: - the canonical permission profile before local workspace-root materialization - the sandbox cwd and workspace roots as `PathUri` values - Windows sandbox settings - the legacy Landlock setting - whether managed networking must be enforced The important part is that symbolic entries such as `:workspace_roots` stay symbolic while crossing the boundary. The executor can then bind them to its own workspace-root paths instead of receiving orchestrator-local absolute paths. The data travels through `ExecRequest` into `ExecParams`. Older exec-servers can still deserialize requests because the new fields have defaults. ## Why The orchestrator should not decide how another machine implements sandboxing. For example: - a local macOS Codex would normally build a Seatbelt command - a remote Linux executor needs a Linux sandbox command instead The orchestrator now sends the plain command plus the policy it intended to enforce. A later PR can let the exec-server choose and build the correct sandbox for its own operating system. ## Important detail This keeps the portable intent separate from the local `SandboxType`. `SandboxType::None` is ambiguous: - it can mean the command was explicitly approved to run without a sandbox - it can also mean the orchestrator host has no concrete sandbox implementation available Those cases are different for remote execution. This PR adds `sandbox_requested` so an executor can still receive sandbox intent when the orchestrator cannot build a local wrapper. Explicit unsandboxed retries still send no sandbox context. ## Behavior today This PR only transports the intent. The exec-server accepts the new fields but does not apply them yet. Remote commands therefore remain unsandboxed after this PR, just as they are after PR #29099. ## Follow-up The next PR will make exec-server read this portable intent, bind symbolic workspace permissions to executor-native roots, choose the sandbox for its own operating system, build the wrapper locally, and then spawn the command.
This commit is contained in:
20 files changed
+178
-36
No files matched your search
@@ -4,7 +4,6 @@ use crate::tools::hook_names::HookToolName;
|
||||
use codex_protocol::permissions::FileSystemAccessMode;
|
||||
use codex_protocol::permissions::FileSystemPath;
|
||||
use codex_protocol::permissions::FileSystemSandboxEntry;
|
||||
use codex_protocol::permissions::NetworkSandboxPolicy;
|
||||
use codex_protocol::protocol::GranularApprovalConfig;
|
||||
use codex_sandboxing::SandboxCommand;
|
||||
use codex_sandboxing::SandboxManager;
|
||||
@@ -202,21 +201,23 @@ fn deny_read_blocks_explicit_escalation_and_policy_bypass() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn exec_server_env_keeps_command_native() {
|
||||
fn exec_server_env_keeps_command_native_and_carries_sandbox_context() {
|
||||
let cwd: AbsolutePathBuf = std::env::current_dir()
|
||||
.expect("current dir")
|
||||
.try_into()
|
||||
.expect("absolute cwd");
|
||||
let cwd_uri = PathUri::from_abs_path(&cwd);
|
||||
let permissions = codex_protocol::models::PermissionProfile::from_runtime_permissions(
|
||||
&FileSystemSandboxPolicy::default(),
|
||||
NetworkSandboxPolicy::Restricted,
|
||||
);
|
||||
let exec_server_permissions = codex_protocol::models::PermissionProfile::workspace_write();
|
||||
let permissions = exec_server_permissions
|
||||
.clone()
|
||||
.materialize_project_roots_with_workspace_roots(std::slice::from_ref(&cwd));
|
||||
let manager = SandboxManager::new();
|
||||
let attempt = SandboxAttempt {
|
||||
sandbox: SandboxType::MacosSeatbelt,
|
||||
sandbox: SandboxType::None,
|
||||
sandbox_requested: true,
|
||||
permissions: &permissions,
|
||||
enforce_managed_network: false,
|
||||
exec_server_permissions: &exec_server_permissions,
|
||||
enforce_managed_network: true,
|
||||
manager: &manager,
|
||||
sandbox_cwd: &cwd_uri,
|
||||
workspace_roots: std::slice::from_ref(&cwd),
|
||||
@@ -252,4 +253,16 @@ fn exec_server_env_keeps_command_native() {
|
||||
);
|
||||
assert_eq!(request.arg0, None);
|
||||
assert_eq!(request.sandbox, SandboxType::None);
|
||||
assert_eq!(
|
||||
request.exec_server_sandbox,
|
||||
Some(codex_exec_server::FileSystemSandboxContext {
|
||||
permissions: exec_server_permissions.into(),
|
||||
cwd: Some(cwd_uri),
|
||||
workspace_roots: vec![PathUri::from_abs_path(&cwd)],
|
||||
windows_sandbox_level: codex_protocol::config_types::WindowsSandboxLevel::Disabled,
|
||||
windows_sandbox_private_desktop: false,
|
||||
use_legacy_landlock: false,
|
||||
})
|
||||
);
|
||||
assert!(request.exec_server_enforce_managed_network);
|
||||
}
|
||||
Reference in new issue
Block a user