Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 37 additions & 8 deletions .github/copilot-instructions.md
Comment thread
richiemsft marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,25 @@ build.bat --with-microvm # Include NanVix micro-VM binaries
./build.sh --rust-only # Only Rust binaries, skip SDK/CLI
```

### 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.6.0-dev` 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

# SDK (from sdk/)
npm install && npm run build
Expand Down Expand Up @@ -95,8 +107,10 @@ The Rust workspace (`src/`) implements multiple sandboxing backends behind the `
| BaseContainer (OS sandbox API) | `wxc-exec.exe` | Windows | `base_container_runner.rs` β€” calls `Experimental_CreateProcessInSandbox` via FlatBuffer |
| Windows Sandbox | `wxc-exec.exe` | Windows | `windows_sandbox_runner.rs` |
| MicroVM (NanVix) | `wxc-exec.exe` | Windows | `nanvix_runner.rs` β€” feature-gated behind `microvm` |
| Hyperlight | `wxc-exec.exe` | Windows | `hyperlight_runner.rs` β€” Hyperlight + Unikraft micro-VM backend |
| IsolationSession | `wxc-exec.exe` | Windows | `isolation_session_runner.rs` β€” 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 | `lxc/src/main.rs` + `lxc_common/` |
| Seatbelt | `mxc-exec-mac` | macOS | `mxc_darwin/src/main.rs` + `seatbelt_common/` β€” uses macOS App Sandbox (Seatbelt) profiles for process containment. Requires schema `0.6.0-dev`+. See `docs/macos-support/seatbelt-backend.md`. |

### Config flow

Expand All @@ -106,10 +120,9 @@ The Rust workspace (`src/`) implements multiple sandboxing backends behind the `

### TypeScript layers

- **SDK** (`sdk/`, `@microsoft/mxc-sdk`) β€” the public API. The one-shot surface (`spawnSandbox` / `spawnSandboxFromConfig` / `spawnSandboxAsync`) builds a `ContainerConfig` from a `SandboxPolicy`, serialises to base64, and spawns the correct native binary (`wxc-exec.exe` or `lxc-exec`) via `node-pty`. The state-aware surface (`provisionSandbox` / `startSandbox` / `execInSandbox` / `execInSandboxAsync` / `stopSandbox` / `deprovisionSandbox`, in `sdk/src/state-aware.ts`) drives a sandbox through a multi-call lifecycle against `StateAwareContainmentBackend` backends; per-(backend, phase) typed `*Config` interfaces and a branded `SandboxId<C>` live in `sdk/src/state-aware-types.ts`. Typed wire-format errors live in `sdk/src/errors.ts` (closed `ErrorCode` union plus a single `MxcError` class carrying `code: ErrorCode`, mirroring the Rust `MxcError` shape). Platform detection is in `platform.ts`.
- **CLI** (`cli/`, `mxc-cli`) β€” thin Commander.js wrapper around the SDK. Depends on `@microsoft/mxc-sdk` via `file:../sdk`.
- **SDK** (`sdk/`, `@microsoft/mxc-sdk`) β€” the public API. The one-shot surface (`spawnSandbox` / `spawnSandboxFromConfig` / `spawnSandboxAsync`) builds a `ContainerConfig` from a `SandboxPolicy`, serialises to base64, and spawns the correct native binary (`wxc-exec.exe`, `lxc-exec`, or `mxc-exec-mac`) via `node-pty`. The state-aware surface (`provisionSandbox` / `startSandbox` / `execInSandbox` / `execInSandboxAsync` / `stopSandbox` / `deprovisionSandbox`, in `sdk/src/state-aware.ts`) drives a sandbox through a multi-call lifecycle against `StateAwareContainmentBackend` backends; per-(backend, phase) typed `*Config` interfaces and a branded `SandboxId<C>` live in `sdk/src/state-aware-types.ts`. Typed wire-format errors live in `sdk/src/errors.ts` (closed `ErrorCode` union plus a single `MxcError` class carrying `code: ErrorCode`, mirroring the Rust `MxcError` shape). Platform detection is in `platform.ts`.

The SDK auto-discovers native binaries by checking `sdk/bin/<target-triple>/` (npm-packaged) and `src/target/<target-triple>/{release,debug}/` (local dev). The `build.bat`/`build.sh` scripts copy binaries into the SDK bin directory.
The SDK auto-discovers native binaries by checking `sdk/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.

### Schema system

Expand All @@ -120,16 +133,32 @@ The SDK auto-discovers native binaries by checking `sdk/bin/<target-triple>/` (n

### Key documentation (`docs/`)

Core references:

- `docs/schema.md` β€” full JSON configuration schema reference
- `docs/versioning.md` β€” schema versioning design, experimental feature lifecycle, and promotion process
- `docs/authoring-a-new-feature.md` β€” step-by-step guide for adding experimental features (which files to touch, in what order)
- `docs/lxc-backend.md` β€” LXC container backend details
- `docs/windows-sandbox.md` / `docs/windows-sandbox-reference.md` β€” Windows Sandbox backend
- `docs/examples.md` β€” annotated configuration examples (see also `examples/` and `test_configs/`)
- `docs/diagnostics.md` β€” diagnostic logging knobs (env vars, log file format)
- `docs/sandbox-policy/v1/policy.md` β€” sandbox policy v1 specification

Per-backend guides:

- `docs/base-process-container/guide.md` β€” process container (Windows AppContainer / BaseContainer)
- `docs/base-process-container/UIPolicy_Schema.md` β€” UI policy schema (JOB_OBJECT_UILIMIT_* mappings)
- `docs/lxc-support/lxc-backend.md` β€” LXC container backend (Linux)
- `docs/macos-support/seatbelt-backend.md` β€” macOS Seatbelt backend (experimental)
- `docs/windows-sandbox/windows-sandbox.md` / `docs/windows-sandbox/windows-sandbox-reference.md` β€” Windows Sandbox backend
- `docs/wsl/wsl-container-getting-started.md` / `docs/wsl/wsl-container-support-plan.md` β€” WSL Container (WSLC SDK)
- `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, Rust `StatefulSandboxBackend` trait, and dispatcher contract)
- `docs/state-aware-lifecycle/mxc-state-aware-sandbox-api-overview.md` β€” companion overview to the full state-aware design
- `docs/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 initial plan (per-phase config / metadata, policy honor matrix, idempotence, concurrency, error mapping)
- `docs/examples.md` β€” annotated configuration examples (see also `examples/` and `test_configs/`)
- `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

Expand Down Expand Up @@ -174,7 +203,7 @@ When changing behavior covered by existing documentation, update the relevant do
- **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/README.md` and the JSDoc in `sdk/src/index.ts`
- **CLI command changes** β†’ update `cli/README.md` and `cli/ARCHITECTURE.md`
- **New containment backends or major backend changes** β†’ update the relevant doc in `docs/` (e.g., `lxc-backend.md`, `windows-sandbox.md`)
- **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
Expand Down
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ xperf -merge user.etl kernel.etl merged.etl

MXC also supports Linux via [LXC (Linux Containers)](https://linuxcontainers.org/lxc/). On Linux, the `lxc-exec` binary provides container-based isolation using Linux namespaces, bind mounts for filesystem policy, and iptables/nftables for network policy.

For full details on the LXC backend, see [docs/lxc-backend.md](docs/lxc-backend.md).
For full details on the LXC backend, see [docs/lxc-support/lxc-backend.md](docs/lxc-support/lxc-backend.md).

### Building on Linux

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ mxc/src/
β”œβ”€β”€ wxc_windows_sandbox_guest/ # UNCHANGED
└── wxc_windows_sandbox_daemon/ # UNCHANGED

mxc/docs/
mxc/docs/nanvix-microvm/
└── nanvix-integration-plan.md # NEW β€” this document

mxc/test_configs/
Expand Down
File renamed without changes.
File renamed without changes.
Loading
Loading