Skip to content

Commit f52b829

Browse files
shanselmanCopilot
andcommitted
Restrict MXC sandbox support gate
Co-authored-by: Copilot <[email protected]>
1 parent 8af4b70 commit f52b829

3 files changed

Lines changed: 55 additions & 23 deletions

File tree

‎src/OpenClaw.Shared/Mxc/MxcAvailability.cs‎

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace OpenClaw.Shared.Mxc;
88
/// <remarks>
99
/// Backends checked:
1010
/// <list type="bullet">
11-
/// <item><see cref="IsAppContainerAvailable"/> — Windows 11 build &gt;= 26100, UBR &gt;= 7965 (per @microsoft/mxc-sdk README), x64 / arm64.</item>
11+
/// <item><see cref="IsAppContainerAvailable"/> — Windows 11 build 26300 with UBR &gt;= 8289, x64 / arm64.</item>
1212
/// <item><see cref="IsWxcExecResolvable"/> — wxc-exec.exe found in the shipped tray output layout or via override.</item>
1313
/// <item><see cref="IsIsolationSessionAvailable"/> — requires AppContainer plus IsolationProxy.exe in System32.</item>
1414
/// </list>
@@ -22,16 +22,14 @@ public sealed class MxcAvailability
2222
/// </summary>
2323
public const string WxcExecOverrideEnvVar = "OPENCLAW_WXC_EXEC";
2424

25-
private const int MinSupportedBuild = 26100;
25+
private const int SupportedBuild = 26300;
2626

27+
// TODO: This is all temporary and a moment in time; feature gate this correctly ASAP.
2728
/// <summary>
28-
/// Highest base build for which an explicit UBR floor applies. Per the
29-
/// @microsoft/mxc-sdk README, builds in <c>[26100, 26500]</c> require the
30-
/// cumulative update bringing UBR ≥ 7965; builds beyond 26500 (e.g.
31-
/// Canary / Dev channels) ship the feature natively.
29+
/// Temporary MXC support table: only build 26300 with UBR 8289+ is enabled.
30+
/// All other builds are blocked until validated and the table is updated.
3231
/// </summary>
33-
private const int UbrCheckMaxBuild = 26500;
34-
private const int MinSupportedUbrInRange = 7965;
32+
private const int MinSupportedUbr = 8289;
3533

3634
public bool IsAppContainerAvailable { get; }
3735
public bool IsIsolationSessionAvailable { get; }
@@ -81,20 +79,11 @@ public static MxcAvailability Probe(IOpenClawLogger? logger = null)
8179
}
8280

8381
var (build, ubr) = ReadWindowsBuildAndUbr();
84-
var buildOk = build >= MinSupportedBuild;
85-
// UBR floor only applies to builds in the [26100, 26500] window;
86-
// newer Canary / Dev builds ship MXC primitives natively.
87-
var ubrCheckApplies = build <= UbrCheckMaxBuild;
88-
var ubrOk = !ubrCheckApplies || ubr >= MinSupportedUbrInRange;
89-
if (!buildOk)
90-
reasons.Add($"Windows build {build} below MXC minimum {MinSupportedBuild}.");
91-
if (buildOk && !ubrOk)
92-
reasons.Add(
93-
$"Windows UBR {ubr} below MXC minimum {MinSupportedUbrInRange} " +
94-
$"(for builds {MinSupportedBuild}-{UbrCheckMaxBuild}). " +
95-
"Install latest cumulative update.");
96-
97-
var isAppContainerSupported = buildOk && ubrOk;
82+
var windowsSupportReason = GetWindowsBuildUnsupportedReason(build, ubr);
83+
if (windowsSupportReason is not null)
84+
reasons.Add(windowsSupportReason);
85+
86+
var isAppContainerSupported = windowsSupportReason is null;
9887

9988
var (wxcResolvable, wxcPath) = ResolveWxcExec();
10089
if (!wxcResolvable)
@@ -123,6 +112,22 @@ public static MxcAvailability Probe(IOpenClawLogger? logger = null)
123112
reasons);
124113
}
125114

115+
internal static string? GetWindowsBuildUnsupportedReason(int build, int ubr)
116+
{
117+
if (build != SupportedBuild)
118+
return $"Windows build {build} is not MXC supported build {SupportedBuild}.";
119+
120+
if (ubr < MinSupportedUbr)
121+
{
122+
return
123+
$"Windows UBR {ubr} below MXC minimum {MinSupportedUbr} " +
124+
$"(for build {SupportedBuild}). " +
125+
"Install latest cumulative update.";
126+
}
127+
128+
return null;
129+
}
130+
126131
private static (int build, int ubr) ReadWindowsBuildAndUbr()
127132
{
128133
var build = Environment.OSVersion.Version.Build;

‎src/OpenClaw.Shared/Mxc/MxcCommandRunner.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public async Task<CommandResult> RunAsync(CommandRequest request, CancellationTo
5252
var settings = _settingsProvider();
5353

5454
// When MXC sandboxing isn't available on this host (e.g. Windows 10,
55-
// build < 26100, or missing wxc-exec.exe), fall back to the host runner
55+
// build != 26300, UBR < 8289, or missing wxc-exec.exe), fall back to the host runner
5656
// so the agent can still execute commands instead of being completely
5757
// blocked. The Sandbox page is read-only in that state and tells the
5858
// user their commands are running uncontained.

‎tests/OpenClaw.Shared.Tests/Mxc/MxcAvailabilityTests.cs‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,31 @@ public void Constructor_StoresAllFields()
6363
Assert.Single(availability.UnsupportedReasons);
6464
Assert.True(availability.HasAnyBackend);
6565
}
66+
67+
[Theory]
68+
[InlineData(26299, 9999, "is not MXC supported build 26300")]
69+
[InlineData(26300, 8288, "Windows UBR 8288 below MXC minimum 8289")]
70+
[InlineData(26301, 9999, "is not MXC supported build 26300")]
71+
[InlineData(27999, 9999, "is not MXC supported build 26300")]
72+
[InlineData(28000, 9999, "is not MXC supported build 26300")]
73+
public void GetWindowsBuildUnsupportedReason_RejectsUnsupportedBuilds(
74+
int build,
75+
int ubr,
76+
string expectedReason)
77+
{
78+
var reason = MxcAvailability.GetWindowsBuildUnsupportedReason(build, ubr);
79+
80+
Assert.NotNull(reason);
81+
Assert.Contains(expectedReason, reason);
82+
}
83+
84+
[Theory]
85+
[InlineData(26300, 8289)]
86+
[InlineData(26300, 9999)]
87+
public void GetWindowsBuildUnsupportedReason_AllowsSupportedBuilds(int build, int ubr)
88+
{
89+
var reason = MxcAvailability.GetWindowsBuildUnsupportedReason(build, ubr);
90+
91+
Assert.Null(reason);
92+
}
6693
}

0 commit comments

Comments
 (0)