Add an opt-in preference for the local MXC sandbox (#47375)

## What changed

Add the default-off `features.prefer_mxc` flag to select MXC for local Windows execution when native support is available and effective network settings do not explicitly forbid local binding. Otherwise, retain the configured backend and legacy setup behavior.

Resolve the preference during config loading and use the effective local backend for execution, network proxy setup, sandbox diagnostics, and `windowsSandbox/readiness`. Preserve the configured backend for remote executors and `config/read`. Explicit `windows.sandbox = "mxc"` remains strict, and command failures do not trigger backend fallback.

## Testing

Add coverage for preference resolution, startup readiness without rewriting configuration, local and remote backend selection across environment updates and child threads, and workspace-write permission context in an agent turn.

GitOrigin-RevId: b51178f0371d38ebb58e41af54a068fca67fa316
This commit is contained in:
iceweasel-oai
2026-09-22 21:57:52 +00:00
committed by copyberry
parent 78fdcd2311
commit 418199f6ad
28 changed files with 567 additions and 106 deletions
+6 -3
View File
@@ -319,7 +319,8 @@ async fn run_command_under_sandbox(
if let SandboxType::Windows = sandbox_type {
#[cfg(target_os = "windows")]
{
if config.permissions.windows_sandbox_type != codex_sandboxing::SandboxType::WindowsMxc
if config.effective_local_windows_sandbox_type()
!= codex_sandboxing::SandboxType::WindowsMxc
{
let workspace_roots = config
.effective_workspace_roots()
@@ -356,9 +357,11 @@ async fn run_command_under_sandbox(
Some(spec) => Some(
spec.start_proxy(
&permission_profile,
managed_proxy_routing_for_windows_sandbox(config.permissions.windows_sandbox_type),
managed_proxy_routing_for_windows_sandbox(
config.effective_local_windows_sandbox_type(),
),
local_binding_policy_for_sandbox(
config.permissions.windows_sandbox_type,
config.effective_local_windows_sandbox_type(),
Some(std::env::consts::OS),
),
/*policy_decider*/ None,
+1 -1
View File
@@ -123,7 +123,7 @@ pub(super) fn sandbox_check(config: &Config, arg0_paths: &Arg0DispatchPaths) ->
#[cfg(target_os = "windows")]
{
let configured_level = WindowsSandboxLevel::from_config(config);
let mxc = config.permissions.windows_sandbox_type
let mxc = config.effective_local_windows_sandbox_type()
== codex_protocol::sandbox::SandboxType::WindowsMxc;
let elevated = !mxc
&& configured_level != WindowsSandboxLevel::Disabled