Resolve Linux sandbox mode once before launching the helper (#62215)

## Why

Managed proxy routes require bubblewrap's network namespace even when
`features.use_legacy_landlock` is enabled. WSL1 compatibility checks and
helper arguments need to agree on the effective mode.

## What changed

Resolve bubblewrap or legacy Landlock once and use that mode for both the
WSL1 check and the `codex-linux-sandbox` arguments. Use Linux sandbox
naming for the shared launcher and CLI code, and preserve the published
analytics category for a missing helper executable.

## Testing

Unit tests exercise the production argument builder, including managed
network context serialization when legacy Landlock is requested. They
also cover which sandbox configurations WSL1 accepts and rejects.

GitOrigin-RevId: 619ab9d3eef965de6bc6cb13ff8a33132018abcf
This commit is contained in:
viyatb-oai
2026-11-18 07:23:25 +00:00
committed by copyberry
parent ba8ab2d050
commit bcff988bd1
26 changed files with 301 additions and 360 deletions
+1 -1
View File
@@ -204,7 +204,7 @@ pub struct EnvironmentConfig {
pub windows_sandbox_level: WindowsSandboxLevel,
/// Concrete Windows sandbox backend selected for this environment attachment.
pub windows_sandbox_type: SandboxType,
/// Whether Linux sandbox processes use the legacy Landlock backend.
/// Whether this environment requests legacy Landlock mode.
pub use_legacy_landlock: bool,
/// Additional managed command restrictions for this environment attachment.
pub exec_policy: Option<RequirementsExecPolicy>,
+6 -3
View File
@@ -237,8 +237,11 @@ pub enum CodexErrorDetails {
/// Sandbox error
#[error("sandbox error: {0}")]
Sandbox(#[from] SandboxErr),
// Keep the published analytics category stable across the Rust variant rename.
#[strum_discriminants(serde(rename = "landlock_sandbox_executable_not_provided"))]
#[strum_discriminants(strum(serialize = "landlock_sandbox_executable_not_provided"))]
#[error("codex-linux-sandbox was required but not provided")]
LandlockSandboxExecutableNotProvided,
LinuxSandboxExecutableNotProvided,
#[error("unsupported operation: {0}")]
UnsupportedOperation(String),
#[error("{0}")]
@@ -407,7 +410,7 @@ impl CodexErr {
UsageNotIncluded,
InternalServerError,
InternalAgentDied,
LandlockSandboxExecutableNotProvided,
LinuxSandboxExecutableNotProvided,
);
codex_err_tuple_constructors!(
@@ -504,7 +507,7 @@ impl CodexErr {
| CodexErrorDetails::GatewayLoginRequired(_)
| CodexErrorDetails::UnsupportedOperation(_)
| CodexErrorDetails::Sandbox(_)
| CodexErrorDetails::LandlockSandboxExecutableNotProvided
| CodexErrorDetails::LinuxSandboxExecutableNotProvided
| CodexErrorDetails::ContextWindowExceeded
| CodexErrorDetails::ThreadNotFound(_)
| CodexErrorDetails::AgentLimitReached { .. }