@microsoft/mxc
MXC (Microsoft eXecution Container) — Copilot Instructions
Install
agr install @microsoft/mxc --target copilotWrites 1 file into .github/copilot-instructions.md, pinned to git-ce7bfccc.
- .github/copilot-instructions.md
Document
MXC (Microsoft eXecution Container) — Copilot Instructions
Prerequisites
The Rust toolchain version is pinned in src/rust-toolchain.toml to match what CI uses (currently 1.93). The pin is honored automatically by rustup — running any cargo command from src/ (or below) downloads and selects that channel on first use. To opt out for one-off testing on a different toolchain, use cargo +<channel> ... or set RUSTUP_TOOLCHAIN. When bumping the pinned version, bump the matching version: 'ms-prod-1.<N>' lines in the two .azure-pipelines/templates/*.Build.Job.yml files in the same commit.
LSP servers are configured in .github/lsp.json for Rust and TypeScript. Install them before use:
rustup component add rust-analyzer
npm install -g typescript-language-server typescript
Building or testing the C# SDK (sdk/dotnet/) additionally requires the .NET SDK (net8.0 or newer; a net8.0 target is used).
Build Commands
Full build (Windows)
build.bat # Release build for current architecture
build.bat --debug # Debug build
build.bat --all # Release build for both x64 and ARM64
build.bat --with-microvm # Include NanVix micro-VM binaries
Full build (Linux)
./build.sh # Release build
./build.sh --debug # Debug build
./build.sh --rust-only # Only Rust binaries, skip SDK
Full build (macOS)
./build-mac.sh # Release build for native architecture (seatbelt backend)
./build-mac.sh --debug # Debug build
./build-mac.sh --all # Build for both aarch64 and x86_64
./build-mac.sh --rust-only # Only Rust binaries, skip SDK
Requires Xcode Command Line Tools and Rust. Produces an unsigned mxc-exec-mac binary (codesigning + notarization happen at release time). Schema 0.7.0-alpha or later required for macOS/Seatbelt backend.
Individual components
# Rust workspace (from src/)
cargo build --release --target x86_64-pc-windows-msvc
cargo build --release --target aarch64-pc-windows-msvc
cargo build --release -p lxc # Linux only — builds lxc-exec
cargo build --release -p mxc_darwin --target aarch64-apple-darwin # macOS only — builds mxc-exec-mac
cargo build --release -p mxc_ffi # C ABI cdylib (mxc_ffi.dll/.so/.dylib) for the C# SDK
# TypeScript SDK (from sdk/node/)
npm install && npm run build
# C# SDK (from sdk/dotnet/)
dotnet build Microsoft.Mxc.Sdk.slnx
Lint and format
# Rust (from src/)
cargo fmt --all -- --check
cargo clippy --workspace --all-targets -- -D warnings
Tests
# Rust unit tests (from src/)
cargo test --workspace
cargo test -p wxc_common # Single crate
cargo test -p wxc_common -- config_parser # Filter by test name
# SDK (from sdk/node/)
npm test
npm run test:integration
# C# SDK (from sdk/dotnet/)
dotnet test Microsoft.Mxc.Sdk.slnx # requires mxc_ffi built (cargo build -p mxc_ffi); resolver finds it in src/target/{debug,release}
# Local PowerShell helpers — run from repo root, require built binaries
tests\scripts\run_test_configs.ps1 # All test configs via wxc_test_driver
tests\scripts\run_basicprocess_test.ps1 # Single process container test
tests\scripts\run_isolation_session_tests.ps1 # IsolationSession one-shot E2E (requires host with the OS-side IsoSessionOps service)
tests\scripts\run_isolation_session_state_aware_tests.ps1 # IsolationSession state-aware lifecycle E2E (multi-invocation provision/start/exec/stop/deprovision, same host requirements)
tests\scripts\run_windows_sandbox_one_shot_tests.ps1 # Windows Sandbox one-shot E2E (fresh disposable VM per test; requires the Windows Sandbox optional feature)
tests\scripts\run_windows_sandbox_state_aware_tests.ps1 # Windows Sandbox state-aware lifecycle E2E (provision/start/exec*/stop/deprovision; requires the Windows Sandbox optional feature; skips if absent)
tests\scripts\run_lxc_all_tests.sh # All LXC tests (Linux)
tests\scripts\run_bwrap_all_tests.sh # All Bubblewrap tests (Linux, requires bwrap)
# E2E test crate — Rust executor integration tests (from src/)
cargo test -p wxc_e2e_tests # Invokes MXC binaries directly
cargo test -p wxc_e2e_tests -- --ignored # Include stress tests (run_on_repeat)
Architecture
MXC is a sandboxed code execution system with a Rust core and TypeScript SDK layer.
Containment backends
The Rust workspace (src/) implements multiple sandboxing backends behind the ScriptRunner trait (core/wxc_common/src/script_runner.rs):
| Backend | Binary | Platform | Module |
|---|---|---|---|
| AppContainer | wxc-exec.exe | Windows | backends/appcontainer/common/src/appcontainer_runner.rs |
| BaseContainer (OS sandbox API) | wxc-exec.exe | Windows | backends/appcontainer/common/src/base_container_runner.rs — calls Experimental_CreateProcessInSandbox via FlatBuffer |
| Windows Sandbox | wxc-exec.exe | Windows | backends/windows_sandbox/lifecycle/src/ (live transient one-shot WindowsSandboxRunner + state-aware StatefulSandboxBackend). Experimental — requires --experimental. Supports both one-shot (a fresh, disposable VM per invocation with guaranteed teardown, via ScriptRunner) and state-aware (multi-invocation provision/start/exec/stop/deprovision, via StatefulSandboxBackend) modes. State-aware holds a single live VM across separate wxc-exec phase processes behind a persistent detached host-side daemon (backends/windows_sandbox/daemon/); the OS enforces a single running Windows Sandbox VM per host, so the daemon owns it and reclaims an orphaned VM on restart only via positive process-identity proof. The shared boot sequence (write per-launch nonce, launch VM, capture ownership proof, wait rendezvous, connect) lives in backends/windows_sandbox/lifecycle/src/vm.rs::launch_managed_vm; each mode plugs in its own LaunchObserver for the per-caller ownership / proof bookkeeping. Honors readwritePaths/readonlyPaths/deniedPaths (HOST paths) at provision via .wsb <MappedFolder> entries (mapped at the same absolute host path inside the guest; rejects deniedPaths equal-to or nested-within a mapped share since .wsb has no Deny primitive); filesystem policy is immutable post-provision. Network isolation is enforced unconditionally by the in-guest agent; network/ui and the Entra user bundle are not honored. ID prefix wsb (strict wsb:<8-hex> grammar). Per-launch handshake: 32-byte Nonce + 1-byte ChannelRole tag on every TCP connection (boot + reconnect); the guest pairs accepted sockets by declared role, not by accept order. The guest agent binary wxc-windows-sandbox-guest.exe (backends/windows_sandbox/guest/) is injected into the VM. |
| MicroVM (NanVix) | wxc-exec.exe | Windows | backends/nanvix/runner/src/lib.rs — feature-gated behind microvm |
| Hyperlight | wxc-exec.exe | Windows | backends/hyperlight/common/src/lib.rs — Hyperlight + Unikraft micro-VM backend |
| IsolationSession | wxc-exec.exe | Windows | backends/isolation_session/common/src/ — feature-gated behind isolation_session, experimental, uses the in-proc Windows.AI.IsolationSession IsoSessionOps API (loaded from IsoSessionApp.dll). Supports both one-shot (single-invocation lifecycle, via ScriptRunner) and state-aware (multi-invocation provision/start/exec/stop/deprovision, via StatefulSandboxBackend) modes. Honors readwritePaths and readonlyPaths at provision via ShareFolderBatchAsync (rejects deniedPaths since the API has no Deny ACE primitive); filesystem policy is immutable post-provision and rejected at later phases. State-aware additionally accepts an optional user bundle (upn, wamToken) at provision and start to provision Entra cloud-agent sandboxes; one-shot rejects the bundle, and hosts that don't support Entra agents surface backend_unavailable. Streams stdout/stderr, forwards stdin, and switches to ConPTY mode when wxc-exec's stdout is a TTY for spawnSandbox parity. |
| LXC | lxc-exec | Linux | core/lxc/src/main.rs + backends/lxc/common/ |
| Seatbelt | mxc-exec-mac | macOS | core/mxc_darwin/src/main.rs + backends/seatbelt/common/ — uses macOS App Sandbox (Seatbelt) profiles for process containment. Requires schema 0.7.0-alpha+. Supports network.proxy via the same cooperative env-var model as Bubblewrap (injects HTTP_PROXY/HTTPS_PROXY into the sandbox, reusing wxc_common::unix_proxy_coordinator; builtinTestServer spawns the shared unix-test-proxy). See docs/macos-support/seatbelt-backend.md. |
| Bubblewrap | lxc-exec | Linux | backends/bubblewrap/common/src/bwrap_runner.rs — unprivileged sandboxing via Linux user namespaces and bwrap. Experimental — requires --experimental. Uses shared filesystem/network policy fields; per-host network filtering via NetworkIptablesManager from backends/lxc/common. See docs/bwrap-support/bubblewrap-backend.md. |
Config flow
- User provides JSON config (file or base64) →
config_deserialize.rsperforms path-aware typed deserialization into the wire model (wxc_common::wire) →config_parser.rsvalidates and maps it toExecutionRequest(the internal execution model inmodels.rs) ExecutionRequestincludes the containment backend selection, process config, filesystem/network policies, and optional experimental features- The appropriate
ScriptRunnerimplementation executes the process and returnsScriptResponse
TypeScript layers
- SDK (
sdk/node/,@microsoft/mxc-sdk) — the public API. The one-shot surface (spawnSandbox/spawnSandboxFromConfig/spawnSandboxAsync) builds aContainerConfigfrom aSandboxPolicy, serialises to base64, and spawns the correct native binary (wxc-exec.exe,lxc-exec, ormxc-exec-mac) vianode-pty. The state-aware surface (provisionSandbox/startSandbox/execInSandbox/execInSandboxAsync/stopSandbox/deprovisionSandbox, insdk/node/src/state-aware.ts) drives a sandbox through a multi-call lifecycle againstStateAwareContainmentBackendbackends; per-(backend, phase) typed*Configinterfaces and a brandedSandboxId<C>live insdk/node/src/state-aware-types.ts. Typed wire-format errors live insdk/node/src/errors.ts(closedErrorCodeunion plus a singleMxcErrorclass carryingcode: ErrorCode, mirroring the RustMxcErrorshape). Platform detection is inplatform.ts.
The SDK auto-discovers native binaries by checking sdk/node/bin/<target-triple>/ (npm-packaged) and src/target/<target-triple>/{release,debug}/ (local dev). The build.bat/build.sh/build-mac.sh scripts copy binaries into the SDK bin directory.
C# SDK
- C# SDK (
sdk/dotnet/,Microsoft.Mxc.Sdk) — a managed binding that P/Invokes the nativemxc_ffilibrary (which wraps the Rustmxc-sdk→mxc_engine), rather than spawning an executor.MxcSandbox.Run(policy, command)/RunAsyncrun a command to completion and return aRunResult(ExitCode,TimedOut,Stdout,Stderr); policy POCOs (SandboxPolicy,FilesystemPolicy,NetworkPolicy,UiPolicy) serialize to the same camelCase JSON the native layer expects.MxcExceptioncarries a typedErrorCodethat mirrors the nativeMXC_STATUS_*codes (parity-gated byscripts/check-dotnet-errorcode-parity.js).Native/NativeMethods.g.csis generated by csbindgen from the Rust FFI and is not committed (gitignored) — the csproj'sGenerateNativeBindingsMSBuild target regenerates it before each C# compile viacargo build -p mxc_ffi --features dotnetsdk, so adotnet buildneeds the Rust toolchain on PATH.NativeLibraryResolverfindsmxc_ffiviaMXC_FFI_DIR, the assembly dir /runtimes/<rid>/native, orsrc/target/{debug,release}. Projects:Microsoft.Mxc.Sdk(library),Microsoft.Mxc.Sdk.Sample(console),Microsoft.Mxc.Sdk.Tests(xUnit), inMicrosoft.Mxc.Sdk.slnx. Beyond run-to-completion, it also exposes streaming (MxcSandbox.Spawn→MxcSandboxProcess:Stream-based stdio,Wait/WaitAsync/Kill) and the state-aware lifecycle (MxcLifecycle.ProvisionSandbox/StartSandbox/ExecInSandbox/ExecInSandboxAsync/StopSandbox/DeprovisionSandbox, with a typedSandboxId).
Schema system
- Stable schemas: released, immutable schemas live in
schemas/stable/(one file per released version) — never edit them after release. - Dev schema: the in-progress schema lives in
schemas/dev/. It is generated from the Rust wire model (src/core/wxc_common/src/wire.rs) by themxc_schema_gentool — do not hand-edit it. To change the dev schema, edit the wire model and regenerate withcargo run --manifest-path src/Cargo.toml -p mxc_schema_gen -- schemas/dev/mxc-config.schema.<dev>.json.scripts/versioning/check-schema-codegen.jsis a CI gate that regenerates and fails if the committed schema drifts. Seedocs/schema-codegen.md. - Generated SDK wire types:
sdk/node/src/generated/wire.tsis generated from the same wire model by themxc_schema_gen --tsTypeScript emitter (wxc_common::ts_emit, no third-party generator) — do not hand-edit it. It is a drift oracle (not public API); the SDK unit testsdk/node/tests/unit/wire-conformance.test.tsasserts the hand-written public types insdk/node/src/types.tsconform to it, andscripts/versioning/check-sdk-types-codegen.jsis a CI gate that fails if the committed file drifts. Regenerate withcargo run --manifest-path src/Cargo.toml -p mxc_schema_gen -- --ts sdk/node/src/generated/wire.ts. - Canonical schema-version source:
schemas/schema-version.json— the single source of truth for the schema-version constants (min/maxSupported/state-aware/stable/dev).scripts/versioning/check-schema-versions.jsenforces that the Rust parser, SDK, and schema filenames all agree with it; do not hand-edit a schema-version constant without updating the canonical file. Seedocs/versioning.mdfor the full design. - Config files can reference schemas via
"$schema"for editor validation.scripts/versioning/validate-configs.jsvalidates thetests/examples+tests/configscorpus against the dev schema in CI.
Key documentation (docs/)
Core references:
docs/schema.md— full JSON configuration schema referencedocs/versioning.md— schema versioning design, experimental feature lifecycle, and promotion processdocs/authoring-a-new-feature.md— step-by-step guide for adding experimental features (which files to touch, in what order)docs/examples.md— annotated configuration examples (see alsotests/examples/andtests/configs/)docs/diagnostics.md— diagnostic logging knobs (env vars, log file format)docs/host-prep.md—wxc-host-prep.exehost setup binary (prepare-system-drive/unprepare-system-drivefor the AppContainer ACEs on the system-drive root, plusprepare-null-device/verify-null-device/dump-null-devicefor the\Device\Nullsecurity descriptor that AppContainer-based backends require). Owns elevation via embeddedrequireAdministratormanifest —wxc-exec.exeno longer self-elevates.docs/sandbox-policy/v1/policy.md— sandbox policy v1 specification
Per-backend guides:
docs/process-container/guide.md— process container (Windows AppContainer / BaseContainer)docs/process-container/UIPolicy_Schema.md— UI policy schema (JOB_OBJECT_UILIMIT_* mappings)docs/process-container/os-version-support.md— per-Windows-release policy-support matrix (filesystem / network / UI)docs/lxc-support/lxc-backend.md— LXC container backend (Linux)docs/macos-support/seatbelt-backend.md— macOS Seatbelt backenddocs/windows-sandbox/windows-sandbox.md/docs/windows-sandbox/windows-sandbox-reference.md— Windows Sandbox backenddocs/wsl/wsl-container-getting-started.md/docs/wsl/wsl-container-support-plan.md— WSL Container (WSLC SDK)docs/wsl/wslc-sdk-bindings.md— WSLC SDK FFI bindings:src/backends/wslc/common/src/wslcsdk_sys.rsis generated by bindgen fromwslcsdk.h(do NOT hand-edit);wslc_bindings.rsis a thin facade over it. On every WSLC SDK version bump, regenerate viascripts/generate-wslc-bindings.ps1(needs libclang +bindgen-cli, required only on the regen machine — normal/CI builds need neither) and commit the regenerated file with theWSLC_SDK_VERSION+ hash change. See the doc for the full runbook.docs/nanvix-microvm/nanvix.md/docs/nanvix-microvm/nanvix-integration-plan.md— MicroVM via NanVix
State-aware lifecycle:
docs/state-aware-lifecycle/mxc-state-aware-sandbox-api.md— state-aware sandbox lifecycle API (cross-backend wire format, RustStatefulSandboxBackendtrait, and dispatcher contract)docs/state-aware-lifecycle/mxc-state-aware-sandbox-api-overview.md— companion overview to the full state-aware designdocs/isolation-session/initial-bringup-plan.md— IsolationSession backend, one-shot bringup (experimental, isolated user account per execution via the OS-side service)docs/isolation-session/state-aware-rust-initial-plan.md— IsolationSession state-aware lifecycle, Rust-layer plan (per-phase config / metadata, policy honor matrix, idempotence, concurrency, error mapping)docs/isolation-session/state-aware-typescript-initial-plan.md— IsolationSession state-aware lifecycle, TypeScript SDK plan
Key Conventions
Experimental features
New features go under the experimental JSON section and are only active when --experimental is passed. See docs/authoring-a-new-feature.md for the full checklist. The pattern:
- Add the field to the Rust wire model (
src/core/wxc_common/src/wire.rs) under theExperimentalsection, then regenerate the dev schema (cargo run --manifest-path src/Cargo.toml -p mxc_schema_gen -- schemas/dev/mxc-config.schema.<dev>.json) — do not hand-edit the generated schema - Add the matching field to the wire model's
Experimentalstruct (src/core/wxc_common/src/wire.rs) and the domainExperimentalConfiginmodels.rs, then map wire→domain inconfig_parser.rs(useFromimpls beside the domain type for trivial enum/struct conversions) - Guard execution behind
if request.experimental_enabledin the runner - Never modify files in
schemas/stable/— those are immutable release artifacts
Rust workspace structure
The workspace is organized into six top-level directories under src/:
| Directory | Purpose | Examples |
|---|---|---|
core/ | Cross-platform foundation + per-platform aggregator binaries | wxc_common/, wxc/, lxc/, mxc_darwin/, mxc_engine/, mxc-sdk/, mxc_pty/, mxc_build_common/, learning_mode_core/, generated/ |
backends/ | Backend-specific code (one subfolder per containment backend or backend support component) | appcontainer/common, windows_sandbox/{daemon,guest,common,lifecycle}, isolation_session/{bindings,common}, learning_mode/windows, hyperlight/common, nanvix/{common,build_common,binaries,runner}, lxc/common, bubblewrap/common, wslc/common, seatbelt/common |
ffi/ | Foreign-function-interface crates (C ABI for language bindings) | mxc_ffi/ |
host/ | Host-side utilities | wxc_host_prep/, wxc_winhttp_proxy_shim/ |
testing/ | Test infrastructure crates | wxc_e2e_tests/, wxc_test_driver/, wxc_test_proxy/, unix_test_proxy/, wxc_ui_probe/, fuzz/ |
tools/ | Developer/diagnostic tools | mxc_diagnostic_console/ |
wxc_commonis the cross-platform foundation: config parsing, models, errors, logger,ScriptRunner/StatefulSandboxBackendtraits, state-aware dispatch helpers, validators, ids, ui-policy, encoding. Plus a few thin Windows API helpers shared by host tools and backends (process_util,string_util,filesystem_dacl,diagnostic). It must not depend on anybackends/*crate.- Each Windows containment backend lives in its own
backends/*/commoncrate (e.g.appcontainer_common,windows_sandbox_common,isolation_session_common,hyperlight_common,nanvix_runner). Backend crates depend onwxc_common; there are no cross-edges between backend crates. Windows Sandbox additionally haswindows_sandbox_lifecycle, which owns the one-shot and state-aware runners and depends onwindows_sandbox_commonfor the wire protocol, plus separate daemon and guest binaries. learning_mode_coreis the cross-platform learning-mode denial model and output layer. It owns denial types, summaries, analyzer abstractions, plain-JSON document emission, and the serializable output-pointer type, and must not depend on anybackends/*crate.learning_mode_windows(backends/learning_mode/windows) is a Windows-only backend support crate for the AppInfo-brokered Learning Mode APIs inprocessmodel.dll. It runtime-resolves the Learning Mode trace and process security-environment exports, owns their typed handle/lifecycle wrappers, decodes sealed ETL traces throughlearning_mode_core, and depends onwxc_commonpluslearning_mode_core; runner integration consumes it from the AppContainer backend layer.wxc,lxc, andmxc_darwinare thin binary crates (wxc-exec/lxc-exec/mxc-exec-mac) that wire up CLI args (clap), load/validate config, handle maintenance modes (--probe,--delete,--setup-*,--audit), and delegate all backend dispatch tomxc_engine. They contain nomatch request.containmentof their own.wxc-execadditionally owns the Windows Ctrl-C / DACL-cleanup /--auditPLM-trace / telemetry orchestration around the engine call.mxc_engineis the single execution engine — the one home for "given anExecutionRequest, run it". It owns: run-to-completion backend selection (run/resolve_runner, covering all backends, incl. the Windows ProcessContainer BaseContainer/AppContainer BFS/DACL fallback tiers viaappcontainer_common::dispatcher::dispatch_with_fallback, and every experimental backend, feature-gated); streaming (spawn→Box<dyn SandboxProcess>); state-aware lifecycle dispatch (run_state_aware, including Windows Sandbox and IsolationSession); host probing (platform_support/PlatformSupport); and config building (build_request,SandboxPolicy+ sections,available_tools_policy/user_profile_policy/temporary_files_policy). It depends on the backend crates (cfg-split: appcontainer/windows_sandbox lifecycle/isolation_session/wslc/nanvix on Windows, bubblewrap/lxc/nanvix on Linux, seatbelt on macOS) so it can't live inwxc_common. Both the executor binaries andmxc-sdkcall into it.ResolvedRunnercarries the boxed runner plus (Windows only) the optionalDaclManagerguard, sowxc-execcan park the guard for its signal handler.mxc-sdkis the public Rust SDK — a thin facade overmxc_engine. Build aSandboxRequestwithbuild_request, then eitherrun(request)(run-to-completion; returns anOutputwith theWaitOutcome, capturedstdout/stderr, warnings, and optional structured output metadata) orspawn_sandbox(request)(returns aSandboxhandle for live bidirectional stdio —take_stdin/take_stdout/take_stderr,kill(),wait()returning aWaitOutcome(Exited(i32)/TimedOut) asio::Result,output_metadata()after terminal completion, orwait_with_output()). It re-exports the engine's config-building surface (build_request,mxc_sdk::policy::{SandboxPolicy sections}, discovery helpers) andplatform_support;mod sandbox(wrapping the engine'sSandboxProcessinSandbox) is its only local module. No pty is ever allocated. Streaming supports Seatbelt (macOS), Bubblewrap (Linux), and Windows ProcessContainer (AppContainer + BaseContainer); other backends returnErrorCode::UnsupportedContainment.- The lower-level execution surface lives in
wxc_common::sandbox_process: theSandboxBackendtrait (validate+spawn(request, logger, StdioMode) -> Box<dyn SandboxProcess>+ adiagnose_exithook) and the genericRunner<B>adapter that bridges anySandboxBackendto the run-to-completionScriptRunner(viaspawn(StdioMode::Inherit)thenwait()).SandboxProcess::output_metadata()carries backend-produced structured outputs after terminal teardown without writing to process-global stdio.StdioMode::Pipeshands the caller live stdin/stdout/stderr (what themxc-sdkstreaming path uses);StdioMode::Inheritlets the child inherit the host's stdio (what the executor binaries use, preserving the TTY under a pty).SandboxBackendis implemented for Seatbelt, Bubblewrap, and Windows ProcessContainer. mxc_ffi(ffi/mxc_ffi,crate-type = ["cdylib", "staticlib", "lib"]) is a flat, panic-safe C ABI overmxc-sdkfor language bindings.mxc_run(policyJson, command, out)runs a sandbox to completion, filling a#[repr(C)] MxcRunResult(status + exit_code + timed_out + owned stdout/stderr/error/output-metadata C strings); every entry point iscatch_unwind-wrapped so a panic becomes a status code, never an unwind. Itsbuild.rsruns csbindgen to generate the C# P/Invoke (sdk/dotnet/Microsoft.Mxc.Sdk/Native/NativeMethods.g.cs), gated behind the crate'sdotnetsdkfeature (off by default, so the whole-workspace backend build matrix doesn't compile csbindgen). The generated file is not committed (gitignored); the C# csproj regenerates it at build time andscripts/check-dotnet-bindings-codegen.jsruns the codegen in CI and asserts the expected entry points are produced. The C ABI is not a stable external contract (native + binding are co-versioned and generated together; see the crate docs). It exposes three surfaces: run-to-completion (mxc_run), streaming (mxc_spawn→ opaqueMxcSandboxhandle;mxc_stream_read/write/flush,mxc_sandbox_take_stdin/stdout/stderr,mxc_sandbox_id/try_wait/wait/kill/output_metadata_json/free, insrc/streaming.rs), and the state-aware lifecycle (mxc_state_awarefor the envelope phases +mxc_state_aware_execreturning a live streaming handle, insrc/state_aware.rs). All three.rsfiles are csbindgen inputs inbuild.rs; theMXC_STATUS_*space already reserves the state-aware phase codes.mxc_ptyis the shared pty bridge used by the LXC backend (lxc_common::lxc_bindings::attach_run) so the inner shell sees a real TTY and host stdio is streamed live. (Seatbelt and Bubblewrap no longer use it: they spawn directly and let the child inherit the host's stdio — a TTY when the executor binary runs under a pty — viaSandboxBackend::spawn(StdioMode::Inherit).)learning_mode_coreis the cross-platform learning-mode / captureDenials model + output emitter:DeniedResource(+ResourceType/AccessType),DenialSummary, theDenialAnalyzerdecode trait, andemit— which writes the on-disk denials deliverable as a single JSON document{ "denials": [...], "summary": {...} }(write_document/DenialsDocument) and defines the serializableDenialsOutputPointer. It carries no OS-specific code (must not depend on anybackends/*crate); the Windows ETL decoder implementingDenialAnalyzerlives inbackends/learning_mode/windows. WhenprocessContainer.captureDenialsis set, the BaseContainer runner seals a unique internal ETL temp, decodes it via that backend with bounded event/unique-denial processing, writes the JSON file (caller'soutputPathwith a unique per-run identifier stamped into the stem, e.g.denials.<run-id>.json, or a managed temp), deletes the ETL, and returns neutralwxc_commonoutput metadata.wxc-execserializes that metadata as the one-line stderr pointer at the CLI boundary; Rust/C#/FFI callers receive it programmatically. Each denial'sresourcefield holds the file path or the AppContainer capability name; capability denials resolve their capability SID to a friendly name viabackends/learning_mode/windows'scapability_names(well-knownS-1-15-3-…SID → policy name; custom hashed SIDs fall back to the SID string).mxc_build_commonis a build-time helper crate — all Windows binary crates use it in theirbuild.rsto embed VersionInfo (ProductName, FileDescription, copyright, version+commit). When adding a new Windows binary crate, addmxc_build_commonas a build-dependency and callmxc_build_common::embed_version_info()frombuild.rsnanvix_build_commonis a build-only helper crate (never linked into the runtime): it stages NanVix binaries next to the executable and resolves theNANVIX_BINprefetch directory. Thenanvix_binaries,wxc, andlxcbuild scripts consume it as a[build-dependencies]entry. Runtime constants it needs (binary/snapshot filenames) stay innanvix_common. Keep build-only file-staging logic here, not innanvix_common(which is a runtime dependency ofnanvix_runner).- Platform-specific modules use
#[cfg(target_os = "windows")]/#[cfg(target_os = "linux")] - Workspace edition is 2021; shared dependencies are declared in the root
Cargo.toml[workspace.dependencies]
Config parser pattern
The parser deserializes JSON directly into the typed wire model (wxc_common::wire), the single source of truth for the config shape (it also generates the JSON schema). All typed config deserialization goes through config_deserialize.rs, which distinguishes syntax errors from typed policy errors and adds the complete JSON path plus source line/column when available; state-aware backend errors are prefixed with their full experimental.<backend>.<phase> location. config_parser.rs then maps the wire types to the validated domain structs in models.rs. The stable surface uses deny_unknown_fields (closed); the experimental block is permissive.
TypeScript conventions
- Target ES2022, ESM modules (
module/moduleResolution: NodeNext,"type": "module"), strict mode — relative imports use explicit.jsextensions - Tests use Node.js built-in test runner (
node --test)
Binary naming
- Windows:
wxc-exec.exe(AppContainer / Windows Sandbox / MicroVM);wxc-host-prep.exe(host setup — seedocs/host-prep.md) - Linux:
lxc-exec(LXC containers) - macOS:
mxc-exec-mac(Seatbelt) - Target triples:
x86_64-pc-windows-msvc,aarch64-pc-windows-msvc,x86_64-unknown-linux-gnu,aarch64-unknown-linux-gnu,aarch64-apple-darwin
Package versioning
All Rust crates use version.workspace = true to inherit the version from src/Cargo.toml [workspace.package]. The npm SDK version in sdk/node/package.json and the C# SDK version (<Version> in sdk/dotnet/Microsoft.Mxc.Sdk/Microsoft.Mxc.Sdk.csproj) must match. Run node scripts/check-version-sync.js to validate they are in sync. When bumping the version, update src/Cargo.toml (workspace version), sdk/node/package.json, and the C# csproj in the same commit.
Keeping docs up to date
When changing behavior covered by existing documentation, update the relevant docs in the same change:
- Schema changes (adding/removing/renaming config fields) → update
docs/schema.mdand the appropriate JSON schema inschemas/dev/orschemas/stable/ - New experimental features → follow
docs/authoring-a-new-feature.md, which includes schema, Rust, and test config steps - SDK API changes (new exports, changed signatures, new options) → update
sdk/node/README.mdand the JSDoc insdk/node/src/index.ts(TypeScript SDK); the Rustmxc-sdkcrate docs/README.md; andsdk/dotnet/README.md(C# SDK). If themxc_ffiC ABI surface changes, the C# P/Invoke regenerates on the next C# build; keep theErrorCodeparity + bindings-codegen gates green. - New containment backends or major backend changes → update the relevant doc in
docs/(e.g.,lxc-support/lxc-backend.md,windows-sandbox/windows-sandbox.md) - Versioning or promotion changes → update
docs/versioning.md
Policy versioning
The SandboxPolicy.version in the SDK must match a JSON schema version in the supported range (0.6.0-alpha minimum, 0.8.0-alpha maximum). The SDK validates this in sandbox.ts — if the policy version is older than MIN_VERSION or newer than SUPPORTED_VERSION it throws. State-aware lifecycle requests use 0.6.0-alpha. These bounds are mirrored from the canonical schemas/schema-version.json and enforced by scripts/versioning/check-schema-versions.js. See docs/versioning.md for the full design.
Creating Issues
When creating issues in this repository, follow the structure defined by the issue templates in .github/ISSUE_TEMPLATE/. Every issue must match one of the four categories below and include the corresponding labels, issue type, and required fields.
Issue categories, types, and labels
| Category | GitHub Issue Type | Labels | Template |
|---|---|---|---|
| 🐛 Bug Report | Bug | Issue-Bug, Needs-Triage | Bug_Report.yml |
| 🚀 Feature Request / Idea | Feature | Issue-Feature, Needs-Triage | Feature_Request.yml |
| 📚 Documentation Issue | Task | Issue-Docs, Needs-Triage | Documentation_Issue.yml |
| 📋 Task | Task | Issue-Task, Needs-Triage | Task.yml |
- Always apply
Needs-Triagealongside the category-specific label. - Apply exactly the labels listed above — do not invent new labels.
- When creating issues via the API, set labels and issue type explicitly — they are not applied automatically.
Required body structure by category
Issues created via the API or by agents do not inherit the form layout from the YAML templates. Reproduce the structure in the issue body using the markdown skeletons below.
🐛 Bug Report — use when something is broken or behaving unexpectedly:
⚠️ Security notice: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to GitHub issues. Instead, send them to secure@microsoft.com referencing the GitHub issue. For application crashes, include a Feedback Hub link if possible (open with Win+F, choose "Share My Feedback" after submission).
### Relevant area(s)
<!-- One or more of: Linux, macOS, Windows -->
### Brief description of your issue
### Steps to reproduce
1.
2.
3.
### Expected behavior
### Actual behavior
All five sections are required.
🚀 Feature Request / Idea — use for new functionality or improvements:
### Description of the new feature / enhancement
<!-- What problem does it solve? Why and how would a user use it? -->
### Proposed technical implementation details
<!-- Optional: how it could be built -->
"Description of the new feature / enhancement" is required. Omit "Proposed technical implementation details" if there is nothing meaningful to add.
📚 Documentation Issue — use when docs are incorrect, incomplete, or confusing:
### Brief description of your issue
<!-- Which document needs correction and why -->
This section is required.
📋 Task — use for actionable work items:
### Description of the task
<!-- Clear description of the task and expected outcome -->
### Additional context
<!-- Optional: links, references, or background information -->
"Description of the task" is required. Omit "Additional context" if there is nothing meaningful to add.
Choosing the right category
- Something used to work or doesn't work as documented → Bug Report
- Proposing new behavior or capabilities → Feature Request / Idea
- Incorrect, missing, or unclear documentation → Documentation Issue
- A discrete unit of work that doesn't fit the above → Task
Style guidelines
- Use the section headers exactly as shown in the skeletons above
- Be specific and concise — avoid vague descriptions like "it doesn't work"
- For bug reports, always include concrete reproduction steps
- For feature requests, explain the why (user problem) before the how (implementation)
- Reference relevant source files, config fields, or docs when applicable
- If any required field is unknown, ask for the information rather than fabricating content
Creating Pull Requests
Pull requests must follow the template in .github/PULL_REQUEST_TEMPLATE.md. Complete all checklist items and add content below the separator (-----).
Required structure
Every PR body should include:
- Template checklist — check the boxes that apply (CLA, related issue, copilot-instructions update).
- Summary — a brief description of what the PR does and why.
- Issue references — if the PR is intended to close an issue, use GitHub closing keywords (
Closes #NNN,Fixes #NNN, orResolves #NNN). If the PR is related but does not close an issue, use an unordered list under a "Related Issues" heading (- #NNN).
Example
- [x] I have signed the [Contributor License Agreement](https://opensource.microsoft.com/cla/).
- [x] This pull request is related to an issue.
- [ ] If this PR changes build commands, project architecture, or key conventions, I have updated [`.github/copilot-instructions.md`](.github/copilot-instructions.md).
-----
## Summary
Brief description of the change.
Closes #42
Guidelines
- One PR should address one issue or concern. Avoid bundling unrelated changes.
- If the PR updates build commands, project architecture, or key conventions, update
.github/copilot-instructions.mdin the same PR. - Draft PRs are appropriate for work-in-progress that needs early feedback.
Trust
Not scanned yet. Artifacts are graded after they are crawled, so a recently discovered one may have no result for a while.
Versions
git-ce7bfcccf3e92026-08-04