Preserve the CLI MXC preference in executor config reads (#51525)

## Why

Executor config reads omitted the startup `features.prefer_mxc` override, so clients could not see the CLI sandbox preference.

## What changed

- Include the explicit CLI `features.prefer_mxc` value in `environmentConfig/read` as a `session-flags` layer, above project config and below legacy managed file and MDM config.
- Retain only this preference from startup overrides.
- Expose `windows_mxc_allowed_by_config` to share MXC eligibility checks after callers resolve the active permission profile.

## Testing

Add CLI and remote executor coverage for preference propagation and filtering, plus a unit test verifying that both legacy managed config sources retain precedence.

GitOrigin-RevId: 5ac6f5257f1e807c2f197dcf5dcb2385cedca0ea
This commit is contained in:
zm-oai
2026-10-07 00:29:04 +00:00
committed by copyberry
parent 19c4793964
commit ed59a6c1cd
13 changed files with 256 additions and 19 deletions
+1
View File
@@ -221,6 +221,7 @@ pub use windows_sandbox_config::PreparedWindowsSandboxConfig;
use windows_sandbox_config::config_allows_mxc;
pub use windows_sandbox_config::prepare_windows_sandbox_config;
use windows_sandbox_config::resolve_windows_sandbox_type;
pub use windows_sandbox_config::windows_mxc_allowed_by_config;
const DEFAULT_IGNORE_LARGE_UNTRACKED_DIRS: i64 = 200;
const DEFAULT_IGNORE_LARGE_UNTRACKED_FILES: i64 = 10 * 1024 * 1024;
@@ -120,6 +120,30 @@ pub(super) fn config_allows_mxc(
} else {
None
};
Ok(windows_mxc_allowed_by_config(
windows_sandbox_mode,
network_requirements,
features,
enable_network_proxy,
profile_local_binding,
))
}
/// Eligibility shared with remote selection after the caller resolves its active profile.
/// Managed network requirements outrank feature and profile binding restrictions.
pub fn windows_mxc_allowed_by_config(
windows_sandbox_mode: &ConstrainedWithSource<Option<WindowsSandboxModeToml>>,
network_requirements: Option<&Sourced<NetworkConstraints>>,
features: Option<&FeaturesToml>,
enable_network_proxy: bool,
profile_local_binding: Option<bool>,
) -> bool {
if windows_sandbox_mode
.can_set(&Some(WindowsSandboxModeToml::Mxc))
.is_err()
{
return false;
}
let allow_local_binding = network_requirements
.and_then(|requirements| requirements.value.allow_local_binding)
.or_else(|| {
@@ -128,7 +152,7 @@ pub(super) fn config_allows_mxc(
.and_then(|config| config.allow_local_binding)
})
.or(profile_local_binding);
Ok(allow_local_binding != Some(false))
allow_local_binding != Some(false)
}
#[cfg(test)]
@@ -106,7 +106,7 @@ async fn thread_projection_preserves_executor_order_and_unavailable_selections()
let selections = requests
.iter()
.cloned()
.map(TurnEnvironmentSelection::new)
.map(|request| TurnEnvironmentSelection::new(request, &[]))
.collect::<Vec<_>>();
recorder
.observed