Skip to content

Commit f22f9c7

Browse files
committed
refactor(driver-mxc): embed policy mapper as a module; remove standalone crate
Adopt the proto-based mapper (map_to_mxc) as the single source of truth, embedded in openshell-driver-mxc as a Windows-gated `policy_map` module. Rewire EmbeddedPolicyMapper to call it directly on the typed SandboxPolicy, deleting the serde_yaml proto->YAML bridge. Move the CLI to a windows-gated example and the parity tests into the crate; delete openshell-policy-mapper. - gate policy_map + seam Windows-only (MXC is Windows-only) - drop serde_yaml; add dev-deps openshell-policy, clap, anyhow - normalize mapped paths to Windows form in the seam, in one place - docs: add driver-mxc to AGENTS.md table; correct design doc section 17 test lane Signed-off-by: Giedrius Burachas <[email protected]>
1 parent 04f716b commit f22f9c7

21 files changed

Lines changed: 456 additions & 1770 deletions

File tree

‎AGENTS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ These pipelines connect skills into end-to-end workflows. Individual skill files
4242
| `crates/openshell-driver-kubernetes/` | Kubernetes compute driver | In-process `ComputeDriver` backend for K8s sandbox pods |
4343
| `crates/openshell-driver-docker/` | Docker compute driver | In-process `ComputeDriver` backend for local Docker sandbox containers |
4444
| `crates/openshell-driver-vm/` | VM compute driver | Standalone libkrun-backed `ComputeDriver` subprocess (embeds its own rootfs + runtime) |
45+
| `crates/openshell-driver-mxc/` | MXC compute driver | **Windows-only** in-process `ComputeDriver` backend for Microsoft MXC (`wxc-exec`) isolation sessions; embeds the OpenShell→MXC policy mapper (also Windows-only) |
4546
| `python/openshell/` | Python SDK | Python bindings and CLI packaging |
4647
| `proto/` | Protobuf definitions | gRPC service contracts |
4748
| `deploy/` | Docker, Helm, K8s | Dockerfiles, Helm chart, manifests |

‎Cargo.lock‎

Lines changed: 3 additions & 172 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/openshell-driver-mxc/Cargo.toml‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ futures = { workspace = true }
2121
tokio-stream = { workspace = true }
2222
serde = { workspace = true }
2323
serde_json = { workspace = true }
24-
# serde_yaml is not a workspace dependency, but 0.9.34 is already resolved in
25-
# Cargo.lock (transitive). Used by the embedded `policy_map` module to consume
26-
# the OpenShell policy in the shape Giedrius's mapper expects.
27-
serde_yaml = "0.9"
2824
base64 = { workspace = true }
2925
tracing = { workspace = true }
3026
thiserror = { workspace = true }
@@ -34,6 +30,11 @@ uuid = { workspace = true }
3430
tokio = { workspace = true }
3531
# tempfile is not a workspace dependency; 3.27 is already resolved in Cargo.lock.
3632
tempfile = "3"
33+
# Used only by the Windows-only example + integration test (parse policy YAML
34+
# into the typed proto, and drive the CLI). Inert on non-Windows.
35+
openshell-policy = { path = "../openshell-policy" }
36+
clap = { workspace = true }
37+
anyhow = { workspace = true }
3738

3839
[lints]
3940
workspace = true

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,20 @@ no isolation session needed), set `OPENSHELL_MXC_MOCK_WXC=1`.
6868

6969
Policy translation (`SandboxPolicy` → MXC `ContainerConfig`) is delegated to
7070
a `policy::PolicyMapper` trait. The primary implementation,
71-
`EmbeddedPolicyMapper`, bridges the proto policy into the
72-
[`policy_map`](src/policy_map.rs) module — **vendored** from Giedrius's
73-
`rust_policy_mapper` (team decision: embed as a module, not a separate
74-
crate). The original `StubPolicyMapper` is retained as a documented,
75-
compile-only fallback that only maps `share_dir`.
76-
77-
The vendored-from marker is at the top of `policy_map.rs`; bump it when
78-
re-vendoring from Giedrius's `gburachas/msft-mxc@policy_mapper` branch.
71+
`EmbeddedPolicyMapper`, calls the embedded [`policy_map`](src/policy_map/)
72+
module's `map_to_mxc` directly on the typed proto (no YAML bridge), then
73+
normalizes the resulting filesystem paths to Windows form. `policy_map/` is
74+
the **source of truth** for the OpenShell→MXC mapping — it was the standalone
75+
`openshell-policy-mapper` crate, now embedded as a module here. The original
76+
`StubPolicyMapper` is retained as a documented, compile-only fallback that only
77+
maps `share_dir`.
78+
79+
Everything in this crate — including the mapper, the
80+
[`policy-to-mxc`](examples/policy-to-mxc.rs) example, and the parity tests in
81+
[`tests/policy_mapper_examples.rs`](tests/policy_mapper_examples.rs) — is
82+
Windows-only (`#[cfg(target_os = "windows")]`); the crate is an empty stub on
83+
other platforms. The mapper's parity tests therefore run on the Windows MSVC
84+
test lane (`mise run windows:test:x64`), not the Linux lane.
7985

8086
## Packaging the demo for the demo box
8187

0 commit comments

Comments
 (0)