Skip to content

Commit de2f834

Browse files
committed
feat(policy): add portable UI policy controls
Signed-off-by: Shailendra Singh <[email protected]>
1 parent 2ad86c1 commit de2f834

43 files changed

Lines changed: 1627 additions & 208 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.agents/skills/build-openshell-mxc-windows/SKILL.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ mise run --skip-tools windows:build:x64
154154
mise run --skip-tools windows:build:arm64
155155
mise run --skip-tools windows:test:x64
156156
mise run --skip-tools windows:test:unsupported:x64
157+
mise run --skip-tools windows:test:mxc-real:x64
158+
mise run --skip-tools windows:test:mxc-real:arm64
157159
```
158160

159161
For full validation, detect the Windows host architecture first and choose the
@@ -235,6 +237,8 @@ crypto dependency builds.
235237
| `windows:test:arm64` | Runs native ARM64 workspace tests with `--no-fail-fast` and the same package exclusions. Rejects non-ARM64 hosts. |
236238
| `windows:test:unsupported:x64` | Re-runs focused `openshell-gateway` tests for unsupported Windows driver behavior. |
237239
| `windows:test:unsupported:arm64` | Re-runs the same focused contracts natively on ARM64. Rejects non-ARM64 hosts. |
240+
| `windows:test:mxc-real:x64` | Runs the serial, ignored real-`wxc-exec` integration suite natively on x64 through the MSVC wrapper. Rejects non-x64 hosts. |
241+
| `windows:test:mxc-real:arm64` | Runs the same real-`wxc-exec` suite natively on ARM64. Rejects non-ARM64 hosts. |
238242
| `windows:artifacts` | Reports size and SHA256 for release artifacts that exist. |
239243
| `windows:ci` | Runs the full ordered x64-host Windows CI lane, plus ARM64 check/build when not skipped. |
240244

@@ -292,6 +296,8 @@ Useful log files:
292296
| `test-aarch64-pc-windows-msvc.log` | Full native ARM64 workspace test output. |
293297
| `test-x86_64-pc-windows-msvc-unsupported-*.log` | Focused unsupported-driver contract output. |
294298
| `test-aarch64-pc-windows-msvc-unsupported-*.log` | Focused native ARM64 contract output. |
299+
| `test-x86_64-pc-windows-msvc-mxc-real.log` | Native x64 real-MXC integration output. |
300+
| `test-aarch64-pc-windows-msvc-mxc-real.log` | Native ARM64 real-MXC integration output. |
295301

296302
The first bundled-Z3 check or test can spend several minutes in CMake/MSBuild
297303
without much console output because Cargo output is redirected to the log. Look

‎architecture/compute-runtimes.md‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ launches and monitors the policy-constrained workload itself.
3232

3333
`compute_driver.proto` is the supported gateway/driver extension boundary.
3434
At initialization the gateway snapshots the driver's identity, version,
35-
default image, gateway-lifecycle preference, and
36-
`driver_reports_runtime_readiness` from `GetCapabilities`. The gateway includes
35+
default image, gateway-lifecycle preference, runtime-readiness ownership, and
36+
complete UI-policy enforcement support from `GetCapabilities`. The gateway includes
3737
the canonical `SandboxPolicy` in `DriverSandboxSpec.policy` for validation and
3838
creation. Drivers that enforce policy outside the standard supervisor fetch
3939
later revisions through `GetSandboxConfig` and acknowledge them through
@@ -106,6 +106,15 @@ The capability RPC reports driver identity, version, and the default sandbox
106106
image used by the gateway. GPU availability stays driver-local and is validated
107107
when a sandbox create request asks for GPU resources.
108108

109+
UI policy is capability-negotiated at the configured driver-instance boundary.
110+
`supports_ui_policy = true` means the driver completely enforces every field in
111+
the current portable `SandboxPolicy.ui` contract; partial implementations must
112+
report false. When `ui` is explicitly present, including as `{}`, the gateway
113+
rejects create before the driver validation RPC or provisioning unless this
114+
capability is true. An absent section bypasses this gate and preserves the
115+
runtime's existing behavior. The startup snapshot is also exposed through
116+
gateway info so clients can discover the selected runtime's support.
117+
109118
The gateway records driver identity and version from the startup capability
110119
response. Elevated gateway info reports that initialized driver snapshot instead
111120
of re-querying drivers on each request.

‎architecture/security-policy.md‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,41 @@ per-request egress decisions.
88
For the field-by-field YAML reference, use
99
[Policy Schema Reference](../docs/reference/policy-schema.mdx).
1010

11+
## Windows MXC Static Enforcement
12+
13+
On native Windows, the MXC driver cannot rely on Linux Landlock or setuid. It
14+
maps portable static filesystem and UI controls from `SandboxPolicy` into MXC
15+
configuration. UI controls are available only with the MXC
16+
`process_container` backend; all omitted UI fields retain deny-by-default
17+
values, and other compute runtimes reject an explicit UI policy.
18+
1119
## Policy Areas
1220

1321
| Area | Enforcement |
1422
|---|---|
1523
| Filesystem | Landlock restricts read-only and read-write paths. |
1624
| Process | The supervisor launches the agent as an unprivileged user with reduced capabilities. |
25+
| UI | Within an explicit UI section, omitted display, clipboard, and input-injection fields deny. The MXC driver's OpenShell `process_container` backend (MXC containment `processcontainer`) can selectively enable them. Other configured backends reject the entire explicit section before provisioning. |
1726
| Network | The proxy evaluates destination, port, calling binary, and optional L7 rules. |
1827
| Inference | `inference.local` is configured through gateway inference settings, not OPA network policy. |
1928
| Runtime settings | Typed settings are delivered with policy and can be global or sandbox scoped. |
2029

21-
Filesystem and process policy are startup-time controls. Network policy is
30+
Filesystem, process, and UI policy are startup-time controls. Network policy is
2231
dynamic and can be hot-reloaded when the new policy validates successfully.
2332

33+
The UI schema names portable capabilities rather than Windows primitives:
34+
graphical output, directional clipboard access, and synthetic input. The
35+
configured compute driver advertises whether it completely enforces this
36+
contract. Any explicit section, including `{}`, is rejected before driver
37+
validation or provisioning when that capability is false. The MXC
38+
`process_container` mapper translates the fields to MXC's top-level `ui` object
39+
under its `processcontainer` containment value and treats omitted fields inside
40+
the section as deny. That object is common to MXC's 0.8 stable and 0.9
41+
development schemas. Both schema lines reject it for `isolation_session`, so
42+
that backend advertises no support and the mapper also rejects it in depth.
43+
Linux, macOS, and other non-MXC paths advertise no support: explicit UI policy
44+
fails closed, while an absent section leaves their runtime behavior unchanged.
45+
2446
Before applying Landlock, the supervisor enriches baseline filesystem paths that
2547
the runtime needs. Missing baseline paths are skipped so one absent runtime path
2648
does not weaken the whole ruleset. When GPU devices are present, GPU baseline

‎crates/openshell-cli/src/commands/gateway.rs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ struct ComputeDriverInfoView {
4545
struct ComputeDriverCapabilitiesView {
4646
driver_name: String,
4747
driver_version: String,
48+
supports_ui_policy: bool,
4849
}
4950

5051
/// Show gateway status.
@@ -392,6 +393,7 @@ pub async fn gateway_info(
392393
capabilities: ComputeDriverCapabilitiesView {
393394
driver_name: capabilities.driver_name,
394395
driver_version: capabilities.driver_version,
396+
supports_ui_policy: capabilities.supports_ui_policy,
395397
},
396398
}
397399
})
@@ -446,6 +448,15 @@ fn print_compute_driver_info(drivers: &[ComputeDriverInfoView]) {
446448
"Driver version:".dimmed(),
447449
driver.capabilities.driver_version
448450
);
451+
println!(
452+
" {} {}",
453+
"UI policy:".dimmed(),
454+
if driver.capabilities.supports_ui_policy {
455+
"supported"
456+
} else {
457+
"unsupported"
458+
}
459+
);
449460
}
450461
}
451462

@@ -464,6 +475,7 @@ fn gateway_info_to_json(view: &GatewayInfoView) -> serde_json::Value {
464475
"capabilities": {
465476
"driver_name": &driver.capabilities.driver_name,
466477
"driver_version": &driver.capabilities.driver_version,
478+
"supports_ui_policy": driver.capabilities.supports_ui_policy,
467479
},
468480
}))
469481
.collect::<Vec<_>>(),
@@ -1822,6 +1834,7 @@ mod tests {
18221834
capabilities: ComputeDriverCapabilitiesView {
18231835
driver_name: "podman".to_string(),
18241836
driver_version: "0.0.75".to_string(),
1837+
supports_ui_policy: false,
18251838
},
18261839
}],
18271840
};
@@ -1840,6 +1853,10 @@ mod tests {
18401853
json["compute_drivers"][0]["capabilities"]["driver_version"],
18411854
"0.0.75"
18421855
);
1856+
assert_eq!(
1857+
json["compute_drivers"][0]["capabilities"]["supports_ui_policy"],
1858+
false
1859+
);
18431860
}
18441861

18451862
#[test]

‎crates/openshell-core/src/policy.rs‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ impl TryFrom<ProtoSandboxPolicy> for SandboxPolicy {
100100
type Error = miette::Report;
101101

102102
fn try_from(proto: ProtoSandboxPolicy) -> Result<Self, Self::Error> {
103+
// UI capabilities are intentionally absent from the portable supervisor
104+
// runtime. Non-Windows compute paths do not expose them, so even a
105+
// schema-level UI allowance cannot grant a UI surface there. The MXC
106+
// driver consumes the typed proto directly on Windows.
103107
// In cluster mode we always run with proxy networking so all egress
104108
// can be evaluated by OPA and `inference.local` is always addressable.
105109
let network = NetworkPolicy {
@@ -165,3 +169,31 @@ impl From<ProtoProcessPolicy> for ProcessPolicy {
165169
}
166170
}
167171
}
172+
173+
#[cfg(test)]
174+
mod tests {
175+
use super::*;
176+
use crate::proto::{UiClipboardAccess, UiPolicy};
177+
178+
#[test]
179+
fn portable_runtime_does_not_activate_ui_allowances() {
180+
let converted = SandboxPolicy::try_from(ProtoSandboxPolicy {
181+
version: 1,
182+
ui: Some(UiPolicy {
183+
allow_graphical_ui: true,
184+
clipboard: UiClipboardAccess::All as i32,
185+
allow_input_injection: true,
186+
}),
187+
..Default::default()
188+
})
189+
.expect("portable policy conversion succeeds");
190+
191+
assert_eq!(converted.version, 1);
192+
assert!(matches!(converted.network.mode, NetworkMode::Proxy));
193+
assert!(converted.network.proxy.is_some());
194+
assert!(converted.filesystem.read_only.is_empty());
195+
assert!(converted.filesystem.read_write.is_empty());
196+
assert!(converted.process.run_as_user.is_none());
197+
assert!(converted.process.run_as_group.is_none());
198+
}
199+
}

‎crates/openshell-driver-docker/src/lib.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,7 @@ impl DockerComputeDriver {
603603
count_selection_supported: self.config.gpu.cdi_supported,
604604
}),
605605
}),
606+
supports_ui_policy: false,
606607
}
607608
}
608609

‎crates/openshell-driver-kubernetes/src/driver.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ impl KubernetesComputeDriver {
589589
count_selection_supported: true,
590590
}),
591591
}),
592+
supports_ui_policy: false,
592593
})
593594
}
594595

‎crates/openshell-driver-mxc/README.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ readiness; there is no in-sandbox supervisor or `ConnectSupervisor` relay.
1919
| Capability | MXC driver |
2020
|---|---|
2121
| Filesystem policy | Read-only/read-write grants come only from `SandboxPolicy`. `process_container` enforces default-deny; `isolation_session` is an explicit grant-only compatibility mode. |
22+
| UI policy | `process_container` advertises complete support and maps portable graphical UI, clipboard-direction, and input-injection controls to MXC; omitted fields inside an explicit section deny. `isolation_session` advertises no support, so the gateway rejects any explicit section before provisioning. |
2223
| Network policy | Rejected synchronously during sandbox creation until an enforcing egress path is bound. |
2324
| Process policy | Unsupported; MXC supplies OS isolation only. |
2425
| Interactive exec/connect/forward | Unsupported; the configured workload runs in-driver. |
@@ -75,11 +76,11 @@ invokes `wxc-exec`. Mapping failure therefore returns from `CreateSandbox`
7576
without leaving a partial sandbox. There is no in-process policy side channel
7677
or MXC-specific gateway composition variant.
7778

78-
`EmbeddedPolicyMapper` calls the embedded [`policy_map`](src/policy_map/) module directly and normalizes filesystem paths to Windows form. It does not add gateway-configured host paths. The policy supplied for the sandbox is the only source of filesystem grants.
79+
`EmbeddedPolicyMapper` calls the embedded [`policy_map`](src/policy_map/) module directly and normalizes filesystem paths to Windows form. It does not add gateway-configured host paths. The policy supplied for the sandbox is the only source of filesystem grants. For `process_container`, the driver advertises `supports_ui_policy = true` and the mapper emits the top-level `ui` object shared by MXC's 0.8 stable and 0.9 development schemas, with restrictive defaults or the exact requested clipboard direction, graphical UI setting, and input-injection setting. `isolation_session` advertises false, so the gateway rejects explicit UI policy before the driver RPC; the mapper also rejects it before lifecycle side effects as defense in depth.
7980

8081
The mapper retains an internal policy-splitting seam for future development, but the runtime exposes no governed-egress switch. Any network rule fails closed until an enforcing proxy is implemented and bound to the sandbox lifecycle.
8182

82-
Parity and matrix tests under [`tests/`](tests/) cover the mapper on the Windows MSVC lane. The driver performs this mapping automatically; there is no separate policy-export command or example.
83+
Parity and matrix tests under [`tests/`](tests/) cover the mapper on the Windows MSVC lane. The real-MXC lane also dry-runs every clipboard direction against the installed schema. The driver performs this mapping automatically; there is no separate policy-export command or example.
8384

8485
## Packaging the demo for the demo box
8586

@@ -98,7 +99,8 @@ exits 0 rather than failing.
9899

99100
| Task | What it runs | When to use |
100101
|---|---|---|
101-
| `windows:test:mxc-real:x64` | `tests/wxc_exec_real.rs` — Tier-2 invoker tests with `--ignored --test-threads=1` | Pre-merge on any Windows host that has `wxc-exec`; dry-run tests always pass; enforcement tests probe-gate themselves |
102+
| `windows:test:mxc-real:x64` | Native x64 `tests/wxc_exec_real.rs` — Tier-2 invoker tests with `--ignored --test-threads=1` | Pre-merge on an x64 Windows host with `wxc-exec`; dry-run tests always pass; enforcement tests probe-gate themselves |
103+
| `windows:test:mxc-real:arm64` | Native ARM64 `tests/wxc_exec_real.rs` with the same contract | Pre-merge on an ARM64 Windows host with `wxc-exec` |
102104
| `windows:e2e:mxc` | `examples/run-mxc-e2e.ps1` — Tier-3 scenario runner, real binary, probe-gated | Demo box / nightly; needs the gateway + CLI binaries in the script directory |
103105
| `windows:e2e:mxc:mock` | Same runner with `-Mock` — wiring-only, no real `wxc-exec` needed | Any Windows host (CI, dev machine); validates wiring and the network-reject scenario |
104106

0 commit comments

Comments
 (0)