mvm
CLAUDE.md43 starsChanged 3 months agoApache-2.0View on GitHub
Backing: shipped-source Validation: check-claim-catalog Rust CLI for building and running Firecracker microVMs on macOS and Linux. Handles the full dev lifecycle: bootstrapping, Nix-based image builds, single-VM management, and reusable template creation. Multi-tenant fleet orchestration (tenants, pools, instances, agents, coordinators) lives in the separate mvmd repository. Building, verification, signing, and publication of the system-image train (builder VM, workload kernel and rootfs, runtime overlay, SDK sidecars, Stage 0 seeds) live in the separate mvm-images repository. The system-image train (builder VM, default and…
- Installs packages
In this repository3 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/graft.mdcCursor rule
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
13 rules. About 0 are common, 6 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 53
When a release build finds the pinned toolchain missing it does not fail: it prints a cargo:warning= naming just payload::toolchain and …
- Very specific: line 58
Every build restores the payload from the content store at ~/.cache/mvm/embed when the store holds bytes keyed to this tree — the key is …
- Very specific: line 97
After changing the guest-facing C ABI in crates/mvm-host-services, refresh the source sidecar explicitly:
- Very specific: line 117
Do not brew install zig: Homebrew's zig drifts to newer releases that are incompatible with the pinned cargo-zigbuild and fail with a …
- Very specific: line 170
Every builder boot on every backend carries a *builder boot payload*: an initramfs mvmctl assembles per boot from its embedded …
- Distinctive: line 271
Idempotent setup: every step checks if already done before acting.
- Distinctive: line 306
Keep the ADR-001 table in sync when you rename or move a witness.
- Very specific: line 309
Do not name a test here without checking it exists (rg 'fn <name>').
- Distinctive: line 392
Pre-built dev image is hash-verified: No such function exists —
- Distinctive: line 792
No task is done without tests.
- Distinctive: line 830
Every new module, type, or function needs test coverage:
- Distinctive: line 863
Write one when you learn something the diff will not say — and especially when you learn something is _false_.
- Very specific: line 886
Every subcommand is self-documenting via --help.
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
mvm -- Firecracker MicroVM Development Tool
Backing: shipped-source Validation: check-claim-catalog
Project Overview
Rust CLI for building and running Firecracker microVMs on macOS and Linux. Handles the full dev lifecycle: bootstrapping, Nix-based image builds, single-VM management, and reusable template creation.
Multi-tenant fleet orchestration (tenants, pools, instances, agents, coordinators) lives in the separate mvmd repository. Building, verification, signing, and publication of the system-image train (builder VM, workload kernel and rootfs, runtime overlay, SDK sidecars, Stage 0 seeds) live in the separate mvm-images repository.
The system-image train (builder VM, default and rootless workload images, workload kernel, runtime overlay, SDK sidecars) lives in the separate mvm-images repository. A contributor build discovers a sibling mvm-images checkout automatically (override with MVM_IMAGES_DIR).
macOS Host (this CLI) -> libkrun Linux VM -> Firecracker microVM (/dev/kvm)
Linux Host (this CLI) -> Firecracker microVM (/dev/kvm)Lima was the historical macOS host abstraction. It was removed on 2026-05-14 (Plan 72 W0–W6 + Plan 75 W0). libkrun is the default macOS 13-25 backend; HVF (the in-house Hypervisor.framework VMM, vsock-only) is the macOS 26+ Apple Silicon default; Firecracker is the Linux KVM path. There is no --lima flag and no Lima fallback. The Apple Virtualization.framework backend was removed (Plan 226 R1P1) — HVF is the destination macOS workload backend, with libkrun as the fallback, and the removed backend's --hypervisor value is gone. xtask check-no-vz enforces exactly two things: no Virtualization.framework / Containerization API, Swift import, or SwiftPM manifest anywhere under the workspace root, and no bare vz / Vz / VZ word in the Rust we own. What it does not forbid — and explicitly permits — is the apple-container backend, which still exists: BackendKind::AppleContainer, selector --hypervisor apple-container (alias container), is the HVF workload runner booting Apple's prebuilt container kernel, a fetched binary artifact carrying no Swift and no VZ. It is opt-in only; auto-detect never returns it.
Host dependencies (macOS)
The libkrun-backed builder VM (started automatically by mvmctl bootstrap, mvmctl build, or mvmctl machine run) needs two Homebrew packages installed:
brew install slp/krun/libkrun slp/krun/libkrunfwlibkrun— the in-process VMM.mvm-libkrun-supervisorlinks against it.libkrunfw— bundles the TSI-patched Linux kernel libkrun's guests boot. Plan 86 / Plan 72 W5.D bullet 10 —libkrun-sys::extract_bundled_kernel()pulls the kernel out of the dylib's.rodataat runtime.
There is no third package and no gateway binary. Every libkrun lane — builder
VM, Stage 0, and workload — boots with an explicit virtio-vsock device and no
guest NIC, so there is nothing for a userspace network gateway to sit between.
The MVM_NETWORKING and MVM_GATEWAY_BIN knobs that used to select one are
gone, and xtask check-single-network-path fails the build if a gateway,
guest NIC, or second endpoint path comes back.
mvmctl doctor reports the libkrun install state and emits hints when it is missing.
For source-checkout contributors only: a pinned zig + cargo-zigbuild are
needed so crates/mvm-cli/build.rs can cross-compile the embedded host-vm
binaries (mvm-host-vm-init, mvm-builderd) as static
aarch64-unknown-linux-musl (the builder VM rootfs has no dynamic loader).
See Plan 115 / ADR-004.
That cross-compile is the only work build.rs still does, and it runs in
exactly two cases: a release-profile build (cargo build --release, or any
profile inheriting from release), and a build with the embed-host-bins
feature. MVM_EMBED=0 opts a release build out. A debug build — which is what
cargo check, clippy and nextest use — never cross-compiles.
When a release build finds the pinned toolchain missing it does not fail: it
prints a cargo:warning= naming just payload::toolchain and ships the unembedded
table. The explicit feature keeps failing hard, because it was asked for by
name.
Every build restores the payload from the content store at
~/.cache/mvm/embed when the store holds bytes keyed to this tree — the key is
the dependency closure + Cargo.lock + pinned toolchain, and each entry carries
the SHA-256 it was published with, so a changed entry is refused rather than
embedded. That is why a debug cargo build usually carries the payload too.
An mvmctl that still has no payload builds it in-process the first time it
needs a builder VM: from the source checkout it was compiled from, into that
same store, with the same cargo zigbuild the build script runs
(host_binaries::source). It prints one line on stderr first saying what it is
building and roughly how long it takes; -v streams the compiler output. It
never compiles a second mvmctl. The next plain cargo build restores those
bytes and embeds them without compiling. Only mvmctl does this — a test binary
or other consumer of mvm-cli gets the refusal from host_binaries::extract
instead — and only in a source checkout: an official release binary always
carries its payload.
just embed remains for building every host binary in one go:
just embed # build and invoke ./target/debug/mvmctl
just embed --release # build and invoke ./target/release/mvmctlOn macOS the recipe also replaces any globally configured compiler-cache
wrapper with scripts/rustc-macos-loader.sh for this explicit build. Cargo
constructs a new dynamic-library search path before invoking rustc, so the
wrapper restores the pinned Rust sysroot's lib/ directory through
DYLD_FALLBACK_LIBRARY_PATH at the compiler boundary; ordinary builds keep
their configured wrapper. Some nightly distributions give rust-objcopy an
incorrect RPATH; without the repair cargo-zigbuild repeatedly warns that
libLLVM.dylib is missing and embeds larger, unstripped binaries even though
the library exists. Cargo may replay warning text cached by compilation units
built before this repair; a new warning has a new dyld[PID] and indicates the
current strip step still failed.
The tag-push release workflow always turns the feature on, so a downloaded binary is self-sufficient.
After changing the guest-facing C ABI in crates/mvm-host-services, refresh
the source sidecar explicitly:
./target/release/mvmctl build sdk-sidecar buildThe command is complete only after both glibc and musl variants report that they were cached successfully. A builder-egress endpoint exiting on SIGTERM is normal one-shot teardown, not a failed sidecar build.
Provision the toolchain with one command — it installs the exact pinned zig
(from the ziglang PyPI package, read out of
[workspace.metadata.mvm.toolchain]), the musl rust targets, and the pinned
cargo-zigbuild:
just payload::toolchainDo not brew install zig: Homebrew's zig drifts to newer releases that are
incompatible with the pinned cargo-zigbuild and fail with a cryptic
CacheCheckFailed. The build script and mvmctl both auto-detect the
ziglang-installed zig and, if the pinned zig is missing, name the exact fix.
Override the zig binary with MVM_EMBED_ZIG=/path/to/zig if needed.
End-users running a downloaded mvmctl don't need any of this — the binaries are already embedded.
macOS 26+ Apple Silicon users need no Homebrew prerequisites: hvf is the auto-detect default on that tier and now bootstraps its own builder VM (see "Builder backend selection" below).
That last part is recent, and it is the whole reason the Homebrew requirement is gone. Stage 0 — the bootstrap that builds the builder image from nothing — used to have a hand-written body per VMM and none on hvf, so the dispatch lowered every hvf selection onto libkrun. Stage 0 now runs through BuilderRunner<D: VmmDriver> like every other builder job, as a Stage0Vm<D> generic over the driver, and mvmctl registers one per backend at startup. Nothing lowers onto libkrun any more: a backend with no registered Stage 0 refuses and names itself, because a missing registration is our wiring bug and should not present as "install these Homebrew packages".
Its bootstrap kernel is fetched rather than built: it cannot be built, because Stage 0 is what makes local kernel builds possible. mvm_build::stage0_kernel classifies it as a bootstrap seed — the same classification Stage 0 already gives its Nix root tarball — so it is fetched and digest-verified even in a source checkout. This is a deliberate, narrow exception to building images from a selected mvm-images checkout; it covers that one kernel and nothing else, and the builder image and workload kernel still build from the checkout when one is selected.
Builder backend selection (Plan 98)
The builder VM (the Linux guest that runs nix build inside mvmctl machine build / mvmctl machine run --flake) picks between three host VMMs:
- hvf — the HVF builder (Hypervisor.framework, no Homebrew deps). Default on macOS 26+ Apple Silicon. macOS-only.
- firecracker — the Firecracker builder, the same VMM the Linux workload tier runs on, so a Linux host needs no second hypervisor to build with. Default on Linux-with-KVM. Bootstraps (Stage 0) and serves one-shot builds and shell jobs from the image Stage 0 produced, booted as-is; only the persistent builder refuses it by name. Live-proven on x86_64; aarch64 is untested.
- libkrun — third-party in-process VMM via the
slp/krun/*Homebrew trio. Never auto-detected, and never fallen back to; it runs only when named by--builder libkrun/MVM_BUILDER_BACKEND=libkrun. No builder path reaches it otherwise: a backend with no Stage 0 refuses and says so rather than lowering onto libkrun. - qemu — QEMU/microvm_nix builder (Linux dev/test substrate). Opt-in only.
(The Apple Virtualization.framework builder was removed in Plan 226 R1P1.)
Selection priority (highest first):
--builder <libkrun|qemu|hvf>global CLI flag.MVM_BUILDER_BACKEND=libkrun|qemu|hvfenv var (case-insensitive, whitespace-trimmed; unrecognised values — including any retired backend name — log a warning and fall through to auto-detect).Auto-detect (
auto_detect_default_for): Apple Silicon macOS → hvf; Linux-with-KVM → firecracker; every other host → qemu. libkrun appears nowhere in it.Note what that means on macOS 13–25 Apple Silicon: auto-detect still answers hvf, which then reports the macOS 26 floor as unavailable — and there is no fallback (below). That tier has to pass
--builder libkrunexplicitly.
mvmctl doctor reports the resolved choice on the builder backend line with format <backend> — <source> — <availability> so the override path is observable.
Auto-fallback is not wired. builder_attempt_order returns a
single-element vector in every branch, so a builder that cannot create its VM
surfaces that failure rather than retrying another backend. The policy seam
(builder_attempt_order + run_with_builder_fallback) is still the one place
every builder entry point goes through, so restoring a fallback is a change to
one function — but do not describe the hvf → libkrun retry as something that
happens today, because it does not. A genuine build error surfaces unchanged
either way.
The rootfs-backed libkrun builder does boot and build on Linux/KVM (the guest
kernel parses libkrun's virtio-mmio cmdline devices, and a poweroff-fallback
halt defers to the on-disk build result); it is reachable only via an explicit
--builder libkrun.
The backends produce byte-identical BuilderArtifacts (kernel + rootfs from the same mvm-images builder image), so switching backends mid-development is supported.
mvm's builder binaries travel beside the builder image, not inside it.
Every builder boot on every backend carries a builder boot payload: an
initramfs mvmctl assembles per boot from its embedded mvm-host-vm-init and
mvm-builderd, digest-checked by the guest before it pivots into the
read-only image and runs them from /run/mvm/host-bins. The image and the
payload agree on a versioned builder boot ABI (/etc/mvm/builder-boot-abi;
builder_boot_abi in a signed image set): 0 is a legacy image that bakes the
binaries (the payload's copies still win), 1 is an image that carries none.
The contract lives in mvm_build::builder_boot and is recorded in ADR-004;
builder_boot_cmdline is the one kernel command line every backend boots
with, and stage_builder_boot decides each boot. A persistent builder booted
with other builder binaries is stopped rather than reused.
Persistent builder state dirs live under ~/.mvm/cache/builder-vm/vms/, distinguished by name prefix (mvm-persistent-builder-vm-* for libkrun, mvm-persistent-builder-hvf-* for hvf). The Stage 0 reaper (Plan 99 PR-1) is prefix-agnostic so all backends participate in mvmctl cache prune without code changes.
Architecture
Workspace Structure
27-crate Cargo workspace under crates/ (Bar-A consolidation took 32→16; mvm-vmm, mvm-backends, and mvm-http were split back out afterwards, mvm-host-services was split out of mvm-sdk, mvm-hostlib was added at the top of the graph, the five GPU API-remoting crates mvm-gpu and mvm-gpu-*-shim/mvm-gpu-shim-core were added, mvm-setpriv was split out of mvm-agentd as a leaf, and mvm-bundler was split out of mvm-cli), plus the root mvmctl package, xtask, and mvm-conformance — 30 packages by cargo metadata. Root facade (src/lib.rs) re-exports the libraries.
Libraries, low → high:
mvm-contract--#![no_std]+ alloc,forbid(unsafe_code); the wasm/browser-capable foundation. The audit-log verifier (and, incrementally, theWorkloadIR + wire protocol + policy DTOs). Builds onwasm32-unknown-unknown.mvm-core-- std: types, IDs, config/paths (MVM_HOME), crypto, signing, routing. Absorbsplan(typed signedExecutionPlan),policy,crypto(attestation/keystore/secret_store/snapshot + opt-in cosign behindmanifest-verify). Default build has no async deps:tokiois optional, pulled only by the off-by-defaulthostd-transportormanifest-verifyfeatures.xtask check-core-runtime-freeassertscargo tree -p mvm-core -e no-devcarries notokio.mvm-fs-- image → mountable rootfs: OCI distribution client (registry/manifest/layer fetch + allow-listedunpack/) + a pure-Rust, memory-safe, deterministic ext4 writer (nomkfs, no subprocess) +overlay. Absorbs the oldmvm-ext4+mvm-oci.mvm-net--NetworkProvidertrait + provisioning/policy/registry seam (vsock/UDS + egress-tunnel plumbing). Wasmvm-network; the concrete TAP/bridge impl lives inmvm-runtime.mvm-build-- Nix builder pipeline + artifact cache; hosts the builder-VM-only[[bin]]s (mvm-host-vm-initetc., cfg-gated Linux, cross-compiled + embedded bymvm-cli/build.rs).mvm-bundler-- seals built artifacts into a signed.mvmpkg:export_bundle_with_signerreads the kernel, rootfs, optional initrd, dm-verity pair and guest sidecar, builds the manifest, and signs it under a caller-suppliedBundleSigner. It decides what an exported bundle contains; the format itself stays inmvm_core::plan::bundle. Depends onmvm-corealone — verity probing and template resolution stay with the caller, so no backend is in its closure.mvmctl bundle exportreaches it throughmvm_client::bundle, which addsHostBundleSignerover the host key.mvm-vmm-- backend-agnostic VMM device model and hypervisor seam: guest memory, FDT, arm64 kernel loading, virtio-mmio, thehv::HypervisorVm/HypervisorVcputraits, thedriver::VmmDriverseam, and the vsock transport. Low enough thatmvm-backendscan implement a backend without depending onmvm-runtime's orchestration.mvm-backends-- the concrete VMM mechanics behind that seam:driver/{fc,hvf,libkrun,qemu}.rs(theVmmDriverimpls), their*_process.rshost-process siblings,fc/, andmock.rs. There is nolegacymodule — the*_process.rsfiles were briefly named*_legacyduring the backend split and nothing in them is legacy. Orchestration stays inmvm-runtime; this crate owns only how a VM is built and run.mvm-http-- a minimal HTTP/1.1-over-rustls client, deliberately smaller than a general one (no HTTP/2, redirects, pooling, proxy, compression), to keep the hyper/tower stack out of the shippedmvmctlclosure.mvm-runtime-- the big runtime crate (absorbsmvm+mvm-backend+mvm-base): theVmBackendtrait and theAnyBackenddispatch over every backend, VM lifecycle (vm/templates + checkpoints),microvm/(Firecracker driver),base/(shell/ui/linux_env/cow host substrate),storage/(dm-thin),network/(the TAP/gateway impl behind themvm-netseam). Re-exports themvmctl::runtime/::backendcontract.mvm-client-- the local/remote client facade:LocalBackend(default) +GatewayBackend(theremotefeature), the canonical host-wide machine inventory (inventory, which backsmvmctl machine lsand non-CLI consumers), plus a re-export ofmvm-core'sMvmClienttrait and itsstreamreader. It is the one Rust library an embedder depends on: it also re-exports the launch request's parts (RootfsSource,Grants,HostPort), the guest payload types in itsguestmodule, inventory records, plan types, the error codes, and the workload authoring surface asmvm_client::authoring. There is nodyn MvmClientfacade in the CLI —mvm-cliusesAnyBackenddirectly for the backend surface, and the routing-everything-through-the-client refactor has not landed. Say what the code does, not what the plan said.mvm-cli-- Clap CLI (themvmctlsurface), bootstrap/doctor/build/run/machine commands;build.rsembeds the host binaries.mvm-host-services-- the in-guest host-services C ABI: one JSON-in/JSON-out entry point over the vsock broker, built as thelibmvm_host_services.socdylib every language SDKdlopens. The package name is what makes cargo emit that filename directly. Its closure is deliberately tiny (no C, no async runtime) because it is compiled into every guest —check-sdk-transport-freeholds that line, and the SDK sidecar's staleness fingerprint watches this crate and its dependencies rather thanmvm-sdk.mvm-observability-- tracing subscriber assembly for the host-side binaries.mvm-capture-- project-environment capture frontend.mvm-mcp-- bounded stdio MCP adapter over theMvmClientfacade.
Daemons, SDK, and FFI:
mvm-hostd-- host-side daemon roles, one crate with separate[[bin]]s (the process moat): thesupervisor+jailerlibs, thebroker/host_signer/audit_signersubprocess bins, and the per-VM supervisor binsmvm-libkrun-supervisor/mvm-hvf-supervisor. Absorbsmvm-supervisor/mvm-broker/mvm-host-signer/mvm-audit-signer/mvm-jailer-lite/mvm-vm-host.mvm-agentd-- the in-guest daemon: vsock protocol (vsock/), console, integrations, entrypoint runtime, themvm-guest-agent[[bin]], and the addon/egress helper bins (mvm-addon-dns/mvm-addon-vsock-bridge, gated behind the off-by-defaultaddonsfeature so the sealed agent stays tokio-free). Absorbsmvm-guest+mvm-guest-helpers.mvm-setpriv-- the guest's static privilege-drop and exec helper (mvm-setpriv[[bin]]), plus the descriptor hygiene it applies before exec, whichmvm-agentdre-exports asfd_hygiene. A leaf whose only dependency islibc, and it has to stay one: the builder image compiles it from source, so its closure is part of the builder image's cache key, and every crate it reaches is a crate whose edits rebuild that image.mvm-agentddepends on it, never the reverse.mvm-sdk-- SDK: decorator parser → canonicalWorkloadIR → Nix template, and runtime record mode. Language SDK surfaces live undercrates/mvm-sdk/sdks/. The in-guest host-services C-ABI cdylib is not here:libmvm_host_services.sois emitted bymvm-host-services, a separate crate whose package name is what makes cargo produce that filename directly rather thanlibmvm_sdk.soplus a rename. This matters beyond bookkeeping — the SDK sidecar's staleness fingerprint hashesmvm-host-servicesand its dependencies, so an edit undercrates/mvm-sdkdoes not invalidate a cached sidecar.mvm-hostlib-- the host library the language SDKs load in-process instead of runningmvmctl: one versioned C ABI (mvm_hostlib_abi_version,mvm_hostlib_abi_is_compatible,mvm_hostlib_call,mvm_hostlib_free) over theMvmClientsurface, answered byLocalBackend, plus the admitted local launch (machine.run/machine.create, throughLaunchRequest), the DevOnlyguest.*process and file methods, answered bymvm_client::guest(the implementationmvmctl machine proc/fs/cpuse), and handle-and-poll process output streams (guest.proc.stream.*). A call beforemvm_hostlib_abi_is_compatiblesucceeds is refused. The SDKs never runmvmctland have no subprocess fallback;xtask check-no-cli-shelloutfails the build if SDK source reaches for a process API. On first use it declares the process a library embedder, so any path that would spawnmvmctlrefuses, and declares its own directory as the helper-binary directory. Nothing depends on it, so linkingmvm-clientcannot form a cycle.crates/deps/libkrun-sys-- the libkrun C FFI (bindgen +-lkrun, gated by thelibkrun-sysfeature) plus the safe wrapper (KrunContext/SupervisorConfig). Wasmvm-libkrun; lives low somvm-build/mvm-runtimeconsume the wrapper.
xtask -- tooling + claim-gate lints. mvm-conformance -- dev-only cucumber-rs BDD harness running the security-claim scenarios against mvmctl (not a dependency of any shipped crate).
Root package: src/lib.rs (facade: mvmctl::core=mvm-core, mvmctl::runtime/::backend=mvm-runtime, mvmctl::build=mvm-build, mvmctl::guest=mvm-agentd, mvmctl::security=mvm_core::crypto) + src/main.rs (thin entry → mvm_cli::run()).
Binary: mvmctl (from root, delegates to mvm-cli)
Dependency direction (high → low): mvm-cli → {mvm-runtime, mvm-hostd, mvm-client, mvm-sdk} → mvm-client → mvm-runtime → {mvm-fs, mvm-net, mvm-build} → mvm-core → mvm-contract. mvm-bundler sits beside that chain: mvm-client → mvm-bundler → mvm-core. mvm-contract (no_std) is the foundation; mvm-core builds on it. mvm-agentd is a mid-graph guest-protocol and runtime library: ten shipped workspace crates consume it directly, in addition to development-only consumers. Its binaries are top-level processes, but the crate is not a dependency leaf. Per-role binaries stay thin entries over their owning libraries.
Key module locations:
mvm-contract: verify (audit-log verifier), ir/ (Workload IR), wire/policy DTOs.
mvm-core: plan/ (ExecutionPlan, bundle, signing, validity), policy/ (security, audit, network_policy, bundle/resolver), crypto/ (attestation, keystore, secret_store, snapshot_*), protocol.rs, agent.rs, catalog.rs, config.rs (paths/MVM_HOME)
mvm-runtime: backend.rs (AnyBackend dispatch + FirecrackerBackend), driver/ + workload_runner/ (the converged runner seam every claim-bearing workload boots through), backends/hvf/, wasm_backend.rs, apple_container_backend.rs, mock.rs; the libkrun/qemu/hvf VMM impls themselves live in mvm-backends (driver/{libkrun,qemu,hvf}.rs) and are re-exported from lib.rs; the raw HVF substrate (hv_impl.rs, kernel_boot.rs, …) stays in mvm-runtime/src/backends/hvf/. Also microvm/ (Firecracker driver), vm/ (templates + template/lifecycle/, checkpoints), agent_session/ (filesystem store for durable agent sessions, the checkpoint analog), base/ (shell, ui, linux_env, cow), storage/, network/, codesign.rs, artifacts/
mvm-fs: oci/unpack/ (allow-listed unpacker), oci/, the ext4 writer, overlay
mvm-agentd: vsock/, console.rs, integrations.rs, src/bin/mvm-guest-agent/ (the agent bin), runner/
mvm-hostd: supervisor/, broker/, host_signer/, audit_signer/, jailer/, src/bin/{mvm-broker,mvm-host-signer,mvm-audit-signer}.rs, the per-VM supervisor bins
mvm-cli: commands/ (env, build/run, machine, guest RPC, artifacts/trust, local ops); doctor/, commands/vm/up/, commands/image/, bench/ are decomposed module trees. Tenant lifecycle + deploy-to-control-plane commands live in mvmd, not mvmctl.
Trait Architecture
BuildEnvironment is split into two traits in mvm-core/src/build_env.rs:
ShellEnvironment (base)
shell_exec(), shell_exec_stdout(), shell_exec_visible()
log_info(), log_success(), log_warn()
BuildEnvironment : ShellEnvironment (extends)
load_pool_spec(), load_tenant_config()
ensure_bridge(), setup_tap(), teardown_tap()
record_revision()- Dev mode (
mvmctl build,mvmctl machine build): usesdev_build()with&dyn ShellEnvironment - Fleet mode (in mvmd): uses
pool_build()with&dyn BuildEnvironment
The RuntimeBuildEnv in mvm implements only ShellEnvironment. The full BuildEnvironment impl lives in mvmd-runtime.
Key Design Decisions
- Firecracker-only on Linux; libkrun (macOS 13-25) / HVF (macOS 26+) on macOS: no Docker/containers on any auto-detected runtime path. The only container-tier backend is
--hypervisor apple-container(Apple's prebuilt container kernel on the in-house HVF VMM), andauto_selectreturns it only when explicitly selected; it is not a fallback. Builds run Nix inside the selected builder VM: HVF on macOS 26+ Apple Silicon, Firecracker on native Linux, and QEMU on other hosts; libkrun remains explicit-only. A selected builder failure surfaces rather than silently switching VMMs. The QEMU/microvm_nix backend (Plan 166) is amvm-only dev/test backend, never used bymvmd— it carries no untrusted multi-tenant workload. Egress default-deny is enforced at one seam for every workload runner — Firecracker, libkrun, HVF, QEMU, andapple-container, which holds anHvfRunnerand substitutes only the kernel image, so it inherits that seam verbatim: the per-VMmvm-network-endpoint, whose sharedEgressGateis the sole claim-10 decision point.xtask check-single-network-pathpins every runner to that one spawn site and endpoint binary so a backend cannot grow a second gate. Wasm has no guest network and remains outside the microVM funnel. - Workload microVMs have no NIC: every workload microVM backend boots the guest with a virtio-vsock device and no net device at all — Firecracker's config sequence omits
/network-interfaces, libkrun pinsNetworkingMode::VsockDirect(which never calls a net attach), HVF's device model has no net device (andapple-containeris that same device model with a different kernel image), and the QEMU workload driver emits no-netdev. The non-microVM tiers reach the same end differently: the Wasm tier mediates no networking at all. Egress leaves the guest only over theNetworkFlowchannel to the host-side endpoint. This is what makes claim 10 (default-deny), claim 13 (no raw secret to the guest), and the audit chain mechanically enforceable: the host endpoint originates every outbound connection, so it can authorize, substitute, and log it.xtask check-single-network-pathfails closed if a guest NIC, raw-packet stack, alternate spawn implementation, or second workload socket owner appears. The builder VM is also NIC-less on every backend, QEMU included: itsnix buildsubstituter traffic and its dependency installs (uv/pnpm) ride the same vsockNetworkFlowrelay underNetworkPolicy::trusted_build_egress(), through the one proxy environment the guest init hands every builder job. An install on a builder booted without vsock egress is refused rather than dialed direct.check-single-network-pathfails if builder code opens a socket other than the egress client's readiness probe, if a host-binary manifest names the retired guest-sidemvm-egress-proxy, or if the QEMU builder gains a NIC argument. - No SSH in microVMs, ever: microVMs are headless workloads. No sshd, no SSH keys, no SSH users in any rootfs. Guest communication uses Firecracker vsock only. The builder VM (where Nix builds run) is headless too — no interactive shell or console, just a build engine you debug through its logs. See Security model below for the full posture.
- Builder VM is headless: there is no interactive shell into it. The builder VM exists solely to run
nix buildon behalf ofmvmctl build/mvmctl machine run;mvmctl bootstrapoptionally pre-fetches/builds its image ahead of time, but builds auto-bootstrap it on first use if you skip that step. On macOS 26+ Apple Silicon, the automatic choice is a long-lived HVF builder VM with Nix + build tools. On native Linux with KVM, it is Firecracker; other hosts select QEMU. Libkrun remains an explicit-only contributor choice. None of these start or SSH into a workload microVM — the builder VM and workload microVMs are always separate. - Headless microVMs:
mvmctl runandmvmctl machine startboot Firecracker as a daemon. Interactive access viamvmctl machine console(PTY-over-vsock, dev-mode only). - Local-command isolation:
mvmctl start/stopuse a completely separate code path from orchestration. - Shell scripts inside run_in_vm: complex ops are bash scripts handed to the active
LinuxEnvbackend (libkrun / HVF / Firecracker). Deliberate — they run inside the Linux VM, not on the macOS/Linux host. - Idempotent setup: every step checks if already done before acting.
- Templates use dev_build path:
mvmctl buildrunsnix buildlocally inside the builder VM (no ephemeral FC builder VMs). Themvmctl template *mutation namespace was removed;templateis a read-only registry browser (list/search/info). - mvm-core keeps only shared foundation code: dead public modules are deleted, and modules with exactly one in-repository consumer live in that consumer's crate. The remaining core has overlapping consumer sets and stays whole. The pack implementation also stays here:
packsdepends on core architecture, plan-key, digest-shape, and image-verification code, while core image-set and trust/cache modules consume pack types. Extracting it alone would create a dependency cycle; resolving that ownership requires a broadermvm-core/mvm-contractboundary decision, not a third shared-types crate. - No
clippy::too_many_arguments:#[allow(clippy::too_many_arguments)]is banned outright — no exceptions in hand-written code (the only legitimate use is bindgen-generated FFI likecrates/deps/libkrun-sys/src/sys.rs). When a function trips the lint, introduce a dedicated struct with a builder (Rust best practice) carrying those arguments and pass the built value. See AGENTS.md §"Clippy: Zero Warnings, Always". - Reuse first — never reimplement what exists: before writing anything, search the workspace (
rg, the facade re-exports, the owning module) for a helper, type, trait impl, or crate that already does the job, and call it. Duplicated logic drifts and is this repo's most common bug source. If an existing helper is almost right, extend it — don't fork a second copy. Concrete standing rules: all~/.mvmpaths go throughmvm-core::confighelpers (mvm_home,vm_state_dir,mvm_keys_dir,mvm_cache_dir, …) — never build them inline withstd::env::var("HOME")+.join(...)(that ignoresMVM_HOMEand breaks worktree isolation); shell/VM ops go through theShellEnvironment/BuildEnvironmenttraits. - Best-practice construction: prefer many small single-purpose functions (each trivially unit-testable) over large branchy ones; use the builder pattern for types with more than a couple of (especially optional) fields instead of long positional constructors; express behavior that varies by backend/env/mode as a trait with impls (
VmBackend,ShellEnvironment), not amatchscattered across call sites; group related values into named config/params structs rather than threading bare arguments through layers; make illegal states unrepresentable with newtypes/enums over stringly-typed flags; and don't over-abstract (YAGNI) — reach for a trait/builder only when there's a real second case. If you can't write a focused test for a function, it's too big — split it. (See AGENTS.md §"Reuse First; Compose Small, Testable Units".) - Images are built in mvm-images; a contributor build builds them from a checkout of it when one is present: the compiled distribution channel is authoritative. Image construction — the builder image, workload images, kernels, runtime overlay, SDK sidecars, initramfs — lives in the mvm-images repository, and nothing in this tree builds one. A contributor-built
mvmctlthat finds an mvm-images checkout (named byMVM_IMAGES_DIR, or a sibling../mvm-images) builds source-matched images from it against this checkout; without one it fetches and verifies the published image setcrates/mvm-core/images.lockpins. Guest program source — the guest agent and runtime binaries, the SDK host-services library — is still this tree's and still builds from it. An official release binary always downloads verified, version-matched artifacts even when invoked from inside a clone. Filesystem proximity must never turn an official binary into a compiler frontend. A contributor modifying the builder flake in their mvm-images checkout must see their change the next time the builder VM boots — viamvmctl bootstrapor auto-bootstrap on the next build — with no release-pipeline round-trip. ADR-030 §Decision records that resolution rule and ADR-030 §Consequences records the rationale. One contributor opt-out exists:MVM_BOOT_IMAGE=fetchfetches the published boot image even when a checkout is selected, when the image is not what is being worked on and an unconditional image build is pure cost. The fetched image recordssource: fetchedin its sidecar, so a stale prebuilt cannot later be mistaken for a build of the working tree; andmvmctl doctor'sboot imageline reports which arm ran and why. Explicit acquisition overrides remain explicit; the channel governs automatic defaults. - Host Nix is never used by mvmctl, even when present:
mvmctldoes not shell out to a hostnixbinary, does not consultnix-darwin'slinux-builder, and does not honornix-daemonURLs in any code path. Every Nix evaluation goes through a VM we launched; builds run inside that builder VM via HVF, Firecracker, or explicitly selected QEMU/libkrun. The reason is determinism and consistency: the samemvmctlproduces the same artifacts on every host regardless of what the host happens to have installed. A contributor with host Nix installed must not see different behavior from a contributor without it. ADR-004 §Decision and ADR-030 §Decision both record this invariant.
Security model
mvm makes fifteen CI-enforced security claims (numbered 1–15), plus three
Preview claims: 16 (egress-substitution leak-gate, ADR-023), 17
(workload input plane) and 18 (workload resource bounding — admission
ceiling + host-wide budget + spawn-time CPU scope). For all three,
witnesses are machine-checked but
promotion into ADR-001's numbered prose is a pending maintainer
decision, mirroring claim 14's path. Each one is
backed by a test or a workflow gate. ADR-001
(specs/adrs/001-microvm-security-posture.md) is the source of truth
for the claim numbering, threat model, and per-backend tier matrix;
this section is the summary.
The ledger is the claims table inside ADR-001, not a separate
catalog file: xtask check-claim-catalog parses that table (rows 1–19,
witnesses spelled fn:<test_name> / ci:<job_name>) and fails when a
named witness stops existing. model/claims.toml is the parallel
conformance ID register that xtask check-conformance reads. There is
no specs/claims/ directory today; it existed and was deleted by the v1
simplification restructure. Historical plans may still describe that removal,
but live claim authority belongs to ADR-001 and model/claims.toml. Do not
infer ADR existence from a numeric range: ADR-052 and ADR-110 are live, while
some lower or intervening numbers were removed. Resolve every citation against
specs/adrs/; check-adr-coverage enforces that rule.
Keep the ADR-001 table in sync when you rename or move a witness. The
prose below is the narrative and the table is the ledger — and when the
two disagree, the table is right: it is gated and the prose is not.
Do not name a test here without checking it exists (rg 'fn <name>');
several of the names below were fabricated and survived for months
precisely because nothing checks this file. check-witness-citations
checks it now — a backticked symbol in this file must appear in code,
and a comment or a string literal mentioning it does not count.
The opposite direction is checked too. Prose recording that a name was never written goes inside an absence region:
<!-- absent:begin -->
`a_name_that_does_not_exist`
<!-- absent:end -->check-asserted-absence fails if anything in there starts resolving, so
a correction cannot rot into a stale denial, and it fails on a region
that names nothing — a region asserting nothing would pass forever.
Inside a region the citation gate stands down, so the two can never
demand opposite things of the same name.
Claim lineage:
- Claims 1–7 ship with ADR-001's original posture.
- Claim 8 was added by the supervisor-wiring plan — see ADR-014
(
specs/adrs/014-signed-audited-execution-plans.md). - Claim 9 (signed bundles content-addressed) is Sprint 52 W2.
- Claim 10 (default-deny egress) is Sprint 52 W3.
- Claim 11 (app-dep volume sealed) was added by ADR-014 / Plan 73
Followups A + B.1/B.2/B.3 + C + D
(
specs/adrs/014-signed-audited-execution-plans.md). - Claims 12 + 13 (host services broker — binding-gated dispatch and
no raw secret over broker channel) were added by Plan 104 / ADR-020
(
specs/adrs/020-host-services-broker.md) / ADR-023 (specs/adrs/023-secrets-subsystem-egress-substitution.md). - Claim 15 (no interactive access to a sealed production microVM) was
added by Plan 165 WS-C — the same interactive-access threat family as
claim 4 /
do_exec.
OCI image provenance recorded in the chain-signed audit log is row 14 of the ADR-001 table, enforced under the claim 8 admission flow.
Companion doc: the Cardoso minimum-viable-policy mapping lives in ADR-001 §"Appendix: Cardoso minimum-viable-policy checklist".
- No host-fs access from a guest beyond explicit shares. Per-service
uid, seccomp
standarddefault,mvm-setpriv --no-new-privs, and the agent'sPR_CAPBSET_DROPbounding-set narrowing confine each service. - No guest binary can elevate to uid 0.
mvm-setpriv --no-new-privsin the launch path;/etc/{passwd,group,nsswitch.conf}are read-only bind-mounts so a compromised service can't mint a uid 0 entry. - A tampered rootfs ext4 fails to boot. dm-verity sidecar +
kernel-cmdline roothash +
mvm-verity-initinitramfs (shipped 2026-04-30; see plan 27 and the claim-3 row ofspecs/adrs/001-microvm-security-posture.md's "Claims ledger (claim → witness)" table — there is no separate runbook section). CI laneverified-boot-artifactsinsecurity.ymlasserts the artifacts are emitted;verify_and_resume_rejects_tampered_memconfirms a tampered snapshot is rejected before resume, and live-KVM tamper regression confirms the kernel panics before userspace on a flipped data block. - A production-safe run cannot invoke DevOnly guest-agent verbs.
scripts/check-prod-agent-no-exec.sh, run by theguest-agent-runtime-boundaryjob in.github/workflows/security.yml, exercises the universal agent's runtime profile and signed grant boundary. The unit and conformance tests enumerate the complete DevOnly request set. - Vsock framing + supervisor-config JSON are fuzzed.
cargo-fuzztargets atcrates/mvm-agentd/fuzz/coverGuestRequestandAuthenticatedFrame. Plan 88 W6 addscrates/deps/libkrun-sys/fuzz/fuzz_targets/fuzz_supervisor_config.rsagainst the host-sideSupervisorConfigparser themvm-libkrun-supervisorbinary reads on stdin.#[serde(deny_unknown_fields)]on every host↔guest type ensures unexpected fields fail-closed. The third-party virtio-net frame parsers this section used to track as an upstream fuzz gap are no longer reachable from any lane: the userspace network gateways were deleted along with the guest-NIC path, so there is no in-tree caller and no frame for them to parse.specs/adrs/003-hypervisor-egress-policy.mdis written around the vsock-only chokepoint. Pre-built dev image is hash-verified. No such function exists —
<!-- absent:begin -->download_dev_image<!-- absent:end -->defines nothing and never did; the five doc comments that named it were corrected on 2026-09-01, along with a second fabricated name they carried. The real pipeline is
fetch_expected_hashes+verify_artifact_hash(crates/mvm-cli/src/commands/env/artifact_verify.rs), which fetch the per-arch*-checksums-sha256.txtmanifest, stream the artifact through SHA-256, and reject + delete on mismatch. The builder-VM/dev-image orchestration incrates/mvm-cli/src/commands/env/builder_vm/stage0_cache.rs(download_builder_vm_image) and.../builder_vm/default_microvm.rscall them.MVM_SKIP_HASH_VERIFY=1is the documented emergency escape; never set it in CI.- Cargo deps are audited on every PR.
deny.toml+ thedenyandauditjobs in CI. Reproducibility double-build catches non-determinism that could mask injection. - Every workload runs from a signed, audited
ExecutionPlan.mvmctl machine runsynthesizes a typedExecutionPlan, signs it under the host's Ed25519 keypair at~/.mvm/keys/host-signer.ed25519(mode 0600), verifies it throughmvm_core::plan::verify_plan(mvm_planis not a crate —planis a module ofmvm-core), enforces the G4 validity window + nonce replay-store, and only then dispatches the backend. Each admission emitsplan.admitted/plan.launched/plan.failedchain-signed entries to~/.mvm/audit/<tenant>.jsonl; tampering breaksmvm_hostd::supervisor::verify_audit_chain(surfaced viamvmctl trust audit verify, which exits nonzero on detected drift). The chain rotates into sequenced segments once the active file reachesMVM_AUDIT_SEGMENT_BYTES(4 MiB default):<tenant>.seg-NNNNNN.jsonlbeside the live<tenant>.jsonl. Nothing is deleted — rotation only splits. Every segment after the first opens with a signedchain.continuedrecord naming its predecessor and that predecessor's final chain hash, soverify_audit_chainattests "unbroken from genesis or from a signed handoff", andverify_segment_setattests the set is ordered and complete: a removed segment is reported by number rather than passing silently.mvmctl doctorchecks the live segment plus the handoffs and says that is what it checked;mvmctl trust audit verifywalks every retired interior. A session that reaches its end is closed by a chain-signedsession.sealedrecord (entry count, first/last entry, chain head, RFC 6962 root over the session's entries, link to the previous seal), and truncating through a seal turns the sessionUNSEALED, whichtrust audit verify <session>reports field by field. Tail truncation of whole sessions, or of a session that never sealed, stays undetectable without an off-host witnessed root — exactly as it was before rotation (Plan 319). Workspacecargo testexercises rejection paths on every PR (plan 64 W1–W4 —synthesize_plan,host_signer::load_or_init_at,admit_for_run,AuditEmitter;xtask check-no-display-on-secret-typesprotects the host signer's redactedDebug). - Every published bundle is content-addressed, key_id-pinned, and
re-verified at fetch and at admit time. Sprint 52 W2 +
admit-time re-verify follow-on.
mvm_core::plan::bundle::read_and_verify_bundlemvm_core::plan::bundle::verify_plan_bundleexercise the rejection ladder on every PR: unknown-key, tampered manifest, key_id mismatch, tampered artifact, missing artifact, unsafe path, schema bump, pin-archive sha256 drift, pin-signature drift.mvmctl bundle fetchround-trip +admit_for_runtests assert refusal on pin-without-context and pin-archive mismatch.
No untrusted workload reaches the network unless explicitly admitted by policy. Sprint 52 W3.
policy_default_is_deny_allandrun_net_default_is_deny_all(the ADR-001 row's witnesses) assert the default-deny posture. An unrecognised preset name refuses rather than falling through to a permissive default, at the CLI and on the wire alike (crates/mvm-contract/tests/egress_predicate_algebra.rs).This bullet used to claim that "
mvmctl upemits an opt-in warning when the resolved policy isunrestricted", with an escape hatch ofMVM_ACK_UNRESTRICTED_NETWORK=1. None of that exists.upis not a dispatched verb and its leftoverArgsstruct has been deleted. The acknowledgement env var is read nowhere in the workspace; its only occurrence is a doc comment inmvm-contract::stream::edgesaying another mechanism is "shaped after" it:<!-- absent:begin -->MVM_ACK_UNRESTRICTED_NETWORK.<!-- absent:end -->There is no unrestricted acknowledgement, so nothing is being bypassed — but nothing warns either, and
specs/plans/296cites the non-existent hatch as prior art for its E7 redaction opt-out. Building the acknowledgement is Plan 306 WS5. Cardoso-flavoured audit of DNS / vsock control-plane carve-out / Plan 104 broker channels as covert egress is tracked in Plan 111 Workstream A.- Every application-dep volume is CVE-scanned and SBOM-enumerated
when sealed, then hash-locked, attestation-checked, and bound to the
workload's audit chain. ADR-014 / Plan 73 Followups A +
B.1/B.2/B.3 + C + D wire the sealed-volume lifecycle: the builder VM
(
mvm-host-vm-init+LibkrunBuilderVm::run_buildInstall arm) installs deps into a sealed volume at~/.mvm/volumes/deps/<volume_hash>/carryingcontent/,sbom.cdx.json,fetch.log,cve.json, and a hash-chainedmeta.json;mvm-hostd's supervisor admission verifier callsmvm_sdk::compile::deps_audit::verify_sealed_volumebefore launch and refuses tampered volumes. The seal-time security lane appliesmvm_build::app_deps_gate::apply_install_gateand fails closed on high/critical CVE findings or stub SBOM/CVE; production launch does not currently call that severity gate, and the dormant-control manifest pins that limitation.mvmctl deps inspect/mvmctl deps auditsurface the sealed sidecars without a VM spawn. Theapp-deps-auditjob lives in.github/workflows/security.yml(Followup D), notci.yml— it runs on the nightly cron and on release tags, so this lane does not gate every PR. It lived inci-full.ymluntil 2026-08-21, which wasworkflow_dispatch-only and had been triggered zero times since it was written: ADR-001's ledger citedci:app-deps-auditfor claim 11 the whole time, against a lane that had never once run. (ci-full.ymlstill exists, asExtended CI, and now runs nightly — it kept the lanes that are neither security-bearing nor duplicated byci.yml, including the repository's only macOS coverage.) It exercisesmvmctl build compileonexamples/python/hello-app-with-deps/, seals a clean + a high-CVE fixture viamvm-build'smvm-app-deps-fixture-toolexample, assertsmvmctl deps inspect --jsonreports a well-formed report, asserts the prod gate refuses the high-CVE fixture and the dev gate admits it, and asserts a byte-flip oncve.jsonmakes inspect refuse viaverify_sealed_volume. Full builder-VM round-trip (realuv pip install+pip-auditinside the libkrun / cloud-hypervisor builder VM) is still gated on Plan 72 W4/W5 cutover; the CI lane exercises every code path that doesn't require a working microVM backend. Every host-side service the broker exposes is bound to a signed
ExecutionPlan.servicesbinding, enforced before handler dispatch, and audited via the chain-signed log. Plan 104 W2 / ADR-020. Witnesses, per the ADR-001 row:unbound_service_returns_not_boundandservice_call_rejects_unknown_envelope_fields.Earlier revisions of this bullet named four tests, a fuzz target, and three
xtask check-handler-*gates that do not exist and never did on this branch:<!-- absent:begin -->service_call_denied_when_unbound,service_call_denied_outside_profile,audit_chain_contains_service_call_entries,audit_chain_carries_no_payload_bytes, and afuzz_service_call.rstarget.<!-- absent:end -->That list used to be held in quotes rather than backticks, by hand, because backticks assert a real identifier. It is now a gate:
check-asserted-absencefails if any of those names appears in the tree, so the correction cannot decay into a stale denial. The ADR-001 row was always correct, socheck-claim-catalognever went red — only this file was wrong, which is why the ledger and not the narrative is authoritative. Payload-freedom for the stream plane's own audit entries is witnessed bystream_audit_entries_carry_the_binding_and_no_payload_bytes.The managed substitution path hands the guest placeholders, never raw secret values. The host-side substitution endpoint mints the environment delivered to the guest and resolves the real credential only while preparing an admitted outbound request. There is no secret-returning
host.secrets.v1broker handler; that retired name is not part of the SDK host-service surface. Plan 104 W5 / ADR-023. Witnesses, per the ADR-001 row:handed_placeholders_never_contain_the_secret_valueandendpoint_bin_serves_substitution_and_refuses_unbound_destination.encode_secret_env_cmdline_round_trips_pairs_as_single_tokenonly round-trips an encoder nothing calls:mvm.secret_envis built by no backend, so it is not evidence. The six test names this bullet used to list do not exist in the tree:<!-- absent:begin -->host_secrets_v1_denied_outside_allowed_destinations,zeroize_drop_zeros_secret_bytes,handler_inter_call_memory_hygiene,host_secrets_v1_signed_payload_jcs_roundtrip,secrets_subprocess_cannot_reach_supervisor_memory,placeholder_in_outbound_request_dropped_and_audited.<!-- absent:end -->- Every
mvmctl run --image <oci-ref>admission records the OCI image provenance in the chain-signed audit log. Row 14 of the ADR-001 table. Plan 85 Phase E + F wire the user-facing OCI image runner to the same audit chain that backs claim 8.mvmctl image pullmaterializes the layer set inmvm-fs's allow-listed unpacker (mvm_fs::oci::unpack::unpack_layer), materializes an ext4 rootfs — by default in-process on the host via the memory-safe pure-Rust writer (mvm_build::rootfs:: materialize_ext4_pure; ADR-004 supersedes ADR-017's builder-VMmkfsmechanism while preserving its roothash guarantee, and auto-falls-back to the builder VM for trees too large or fragmented for it; the builder VM carries no extended attributes, so a tree carryingsecurity.capabilityor ACL xattrs that falls back is refused rather than emitted without them) — and persists provenance metadata (registry host, repo, supplied reference, resolved manifest digest, layer digest list, trust policy, cosign verdict).mvmctl run --imageadmits anExecutionPlan(claim 8 path) and then emits aplan.oci_provenanceentry viaAuditEmitter::emit_oci_provenance(crates/mvm-cli/src/commands/vm/audit_chain.rs) carrying those labels;mvm_hostd::supervisor::verify_audit_chaincontinues to detect drift, surfaced viamvmctl trust audit verify.--prodrefuses mutable references before any network fetch (crates/mvm-cli/src/commands/image/pull_core.rs:: prod_pull_requires_digest_pin_before_networkandprod_run_image_requires_digest_pin_before_network—imageis a directory of modules, not a singleimage.rsfile), demands an explicit registry policy, and requires cosign verification of the resolved digest before cache admission or boot. The OCIunpack_layerfuzz harness lives in.github/workflows/security.yml'sfuzzjob (release-tag pushes- nightly cron + manual dispatch); the six OCI hardening lanes
(
layer-unpack-adversarial,digest-mismatch-reject,malformed-manifest,mutable-tag-prod-reject,reproducibility,image-runner-smoke) are theoci-hardeningmatrix in.github/workflows/security.yml, notci.yml— so none of the six gate a PR; they run nightly and on release tags. They were six separate dispatch-only jobs inci-full.ymluntil 2026-08-21 and had never been run. Note that ADR-001's ledger does not cite them: claim 14's row names noci:witness, so this paragraph is prose about lanes the gate does not check, and the table is what binds.
- nightly cron + manual dispatch); the six OCI hardening lanes
(
- A sealed production microVM has no shell, no DevOnly guest-agent
verbs, and no PTY. The sole
interactive path into a guest is the agent-served PTY-over-vsock
console (
crates/mvm-agentd/src/console.rs). The universal agent dispatches it only when the runtime profile and signed grant authorize the request. Plan 165 WS-C. Five independent layers: (1) only the dev/initvariant serves a shell; (2) the prod rootfs is dm-verity sealed (claim 3); (3) the backend captures the guest console write-only toconsole.logwith no host input fd (mvm_runtime::libkrun::open_console_capture—mvm_backendis not a crate, this is a function inmvm-runtime— andfollowing_the_console_never_writes_to_it); (4) the hostenforce_accessible_gaterefusesmvmctl machine consoleon a sealed VM (console_refused_on_sealed_image); (5) the agent console and DevOnly handlers are grant-gated. CI: theguest-agent-runtime-boundaryjob in.github/workflows/security.ymlruns the runtime refusal suite. Serial-console passthrough was considered and rejected (fatal on an input-less console); there is exactly one interactive transport and it is dev-only. This claim used to read "no interactive access", holding by absence — a sealed VM had no host→guest byte path at all. The workload input plane built one, so the claim shrank to the part that still holds by absence, which is what its three witnesses check. The input plane's own properties (stdin only, no program selection, no argv or env change, refused without a plan grant) are policy enforced by host code, and are claimed separately asPreviewclaim 17 with their limits.
Preview claim 17 — workload stdin is grant-gated, single-writer,
secret-scanned across frames, and every refusal audited
(crates/mvm-hostd/src/stream/input_gate.rs). Every leg has a production
caller: mvmctl machine run --entrypoint --stdin - opens the route under the
plan that boot was admitted under, the sealed-tier shell-entrypoint refusal
classifies an entrypoint resolved from the image's own mvm-meta.json
sidecar and fails closed when it cannot resolve one, and the secret scan is
populated — the per-VM substitution endpoint (the one process holding a
workload's credentials in the clear) fingerprints each secret it resolves
and StreamPlane::open_input installs that set. Only the fingerprint — a
length, a rolling hash and a category — crosses into the scanning process;
never a value. It stays a preview and not a numbered claim because of what
the enforcement is rather than whether it runs: a fingerprint match is a
length-and-hash match, not an identity, and encoding, derivation and a
window-straddling split defeat the scan permanently. ADR-001's ledger
carries the full limits note, marked closed or open individually; do not
paraphrase this row as enforced without it.
The fleet stream-edge workflow in mvmd is now the input plane's second
production caller; that closes no remaining limit and does not promote the
claim.
Preview claim 18 — a workload's resource consumption is bounded at
admission, and bound at spawn where the host has a mechanism. Admission
is the strong half and holds everywhere: an operator-configured
per-workload ceiling (max_cpu_millicores / max_memory_mib /
max_wall_clock_secs) plus a host-wide budget
(host_budget_memory_mib / host_budget_cpu_millicores) that refuses a
boot whose memory, on top of every live machine's admitted charge, would
exceed the headroom (crates/mvm-hostd/src/admission_budget.rs). The
budget counts only machines carrying a live pid marker — the same probe
the fork path trusts, so a crashed VM cannot lock the host out — and
counts each machine's configured maximum rather than the balloon's
current commitment. CPU is the partial half: a granted share wraps the VMM spawn in a
systemd transient scope on Linux and the achieved tier is read back off
cpu.max. On the in-house HVF VMM on macOS there is no host-level quota
primitive, so the run loop enforces the share in-process using the summed Mach
CPU time of every vCPU thread — the sum, so the bound stays a bound on the
machine rather than on one CPU of an SMP guest; the achieved tier is read back
from the scheduler's measured record and audited. libkrun has no in-process vCPU control, so a CPU
grant there stays declared and --prod refuses it. Memory and tasks are
bounded at spawn on that same scope, for every VMM spawn and not only a granted
one, but only on a Linux host with a systemd user session: the scope carries
MemoryMax= of guest RAM plus a fixed 256 MiB overhead margin (swap excluded)
and TasksMax=1024, memory.max and pids.max are read back with their values
into the same plan.grants_enforced entry, and a scope the OOM killer ended is
recorded as plan.memory_limit_exceeded when a waited run's exit is reported. A
service manager that never creates the scope fails the launch after 10 s instead
of hanging it. macOS, and a Linux host without the mechanism, record both as
declared, and that is not a --prod refusal: nobody asked for these ceilings,
so their absence refuses nothing. The admission budget still charges guest RAM
only, not the margin. Wall clock is enforced
by the per-VM supervisor on libkrun and HVF: the process that owns the guest
for its whole life arms a timer from the admitted plan, and a workload that
outruns its bound is killed with exit 124 and a chain-signed entry. A bound
whose kill could not be audited refuses to boot rather than running unbounded.
Firecracker has no such supervisor process and is not covered. The wasm
backend wires admitted fuel and wall-clock bounds into wasmtime fuel
consumption and epoch interruption. A restored or warm-claimed child is
admission-bounded without its host-side CPU control or its wall-clock
timer being re-armed — a restore deliberately does not inherit the parent's
plan, since auditing a child's kill under its parent's identity would write a
wrong entry rather than a missing one.
ADR-001's ledger carries the "Preview 18 limits" note; do not paraphrase
this row as enforced without it.
- Every dataset, model, prompt, agent, policy, and compute environment
named by a workload carries a content-derived identity in the signed plan,
and a pinned host share that drifts after admission fails closed. Row 19
of the ADR-001 table,
Shipped.--asset KIND:PATHhashes the asset intoAssetIdentityrecords inside the signedExecutionPlan; admission also pins each directory share's content digest and re-verifies it at mount enforcement, so a post-admission edit of the host directory is refused (admitted_share_digest_refuses_directory_changed_after_admission). Synthesis derives the compute-environment identity from the measured image/kernel/verity state (synthesized_plan_records_share_and_caller_asset_identities), and aplan.asset_identitieschain-signed entry carries the kind, locator and digest labels. Note this claim is numbered 19 in the ledger even though it isShippedand rows 16–18 arePreview: the ledger numbers rows in the order claims were added, not by status. Every published release artifact is authenticated under the release workflow's identity, directly or through a signed checksum manifest, and the build, fetch, and self-update paths refuse an artifact whose required signature is missing or invalid. Row 20,
Shipped.release.ymlsigns archives and checksum manifests keyless through GitHub OIDC and publishes bundles carrying the Fulcio certificate and Rekor inclusion proof. Raw kernels, root filesystems, and metadata are covered by the signed manifests rather than individual bundles. Theverify-releasejob re-downloads the published set, verifies the signatures against an identity regexp pinned to this workflow at a tag, and checks the covered blobs against their authenticated digests. The build gate refuses a missing bundle (a_missing_bundle_refuses_and_names_the_asset) and accepts only the versioned release workflow (accepted_identities_are_the_versioned_release_workflow); the fetch gate refuses an unsigned manifest before parsing it (fetch_expected_hashes_refuses_an_unsigned_manifest_before_parsing) and the hash-skip hatch does not waive the signature (skip_hash_verify_does_not_waive_the_manifest_signature).The self-update path used to be the exception:
verify_signatureshelled out tocosignand returnedOkwith a warning when it was absent. It now calls the same in-process verifier with the CLI release train, so it refuses a missing bundle (an_archive_without_a_bundle_is_refused) and verifies a real one only under its own tag (a_real_release_bundle_verifies_under_its_tag). Anmvmctlbuilt withoutmanifest-verifytherefore cannot self-update.install.shverifies an upgrade with the installedmvmctl env verify-release, or withcosign, and is best-effort only on a first install to a host with neither. ADR-001's "Claim 20 limits" note records both; do not paraphrase this row as covering the installer.The release job also attests build provenance for the binary tarballs (
actions/attest-build-provenance, verifiable withgh attestation verify), which witnesses this claim because the attestation is signed under the same workflow identity. It is SLSA Build L2: the attestation is produced by the same workflow that produces the artifact, so a compromised release job forges both. Provenance adds the commit and build inputs in a machine-readable predicate; it is not evidence the build was uncorrupted, andci:reproducibilityunder claim 7 remains the control that speaks to that.
The guest agent itself runs as uid 901 through mvm-setpriv --no-new-privs;
its own PR_CAPBSET_DROP calls narrow the capability bounding set. The
host-side vsock proxy socket is mode 0700 (W1.2), the proxy port
allowlist drops anything outside the agent and forward ranges
(W1.3), and ~/.mvm (and every child, ~/.mvm/cache included) is mode 0700 (W1.5).
Out of scope (named in ADR-001):
- A malicious host. mvmctl trusts the host with the hypervisor and private build keys.
- Multi-tenant guests. One guest = one workload.
- Hardware-backed key attestation.
mvmctl doctor reports the live posture on the running host
(plan 40 folded the standalone security verb into doctor's
unified diagnostics report). Architecture detail, the claims ledger,
and the per-backend tier matrix are all in
specs/adrs/001-microvm-security-posture.md.
Testing
No task is done without tests. Before marking any feature complete:
cargo fmt --all -- --check # workspace-wide fmt; --all matters
cargo nextest run --workspace # all tests must pass (process-parallel)
cargo test --workspace --doc # doctests — nextest does NOT run these
cargo clippy --workspace -- -D warnings # zero warningscargo nextest run --workspace (what just test and CI run) is the named
test gate — it's process-parallel and faster than cargo test on this
~4,350-test suite. The one gap: nextest skips doctests, so the
cargo test --workspace --doc line above (wrapped as just tests::doc, and
folded into just ci) keeps doc-fence coverage gated. cargo test
--workspace still works as a fallback if nextest isn't installed.
--all-targets has two blind spots, and a change to a shared type's shape
(a new struct field, trait method, or enum variant) walks into both. It skips
any target behind required-features — mvm-conformance's cucumber runner
needs --features bdd, and without it the same broken tree reports zero
errors — and on macOS it cannot compile cfg(target_os = "linux") files at
all, including Linux-gated test files, which just check::linux misses too
because that recipe is --lib only. just check::gated covers both. Skipping
it surfaces in CI as check-nextest-groups failing with "cargo nextest list
failed", a message that names neither the file nor the field.
Always pass --all to cargo fmt. Without it, fmt only checks the
manifest crate (whichever one the manifest points at), silently missing
drift in every other workspace member. CI runs cargo fmt --all --
--check; if you only check the local crate, the merge will still fail.
The pre-commit hook at .githooks/pre-commit auto-fixes with cargo
fmt --all and re-stages — just maint::hooks wires
core.hooksPath to .githooks/ so it fires on every commit.
The Justfile recipes wrap this correctly: just lints::fmt-check, just
lints::clippy, just lint (both), just ci (lint + test + doctests). Prefer
those over raw cargo invocations.
Every new module, type, or function needs test coverage:
- Types: serde roundtrip, default values
- Protocol/wire code: mock I/O roundtrip, tampered data rejection, error paths
- CLI: integration tests in
tests/cli.rsfor help text and argument parsing - Security: positive path, negative path (wrong key, tampered, replay), edge cases
Scratch & temporary files
Never write scratch, temporary, or intermediate files anywhere inside the repo working tree — not the root, not a subdirectory, not a hidden dotfile, not a gitignored path. This covers every kind of agent-created scratch (analysis lists, command output, intermediate JSON/TSV, logs, ad-hoc scripts, git merge-file inputs), not just screenshots/binaries. Write them under /tmp/ instead. See AGENTS.md §"Screenshots & Temporary Files" for the full rule.
.agent-memory/notes/ is the one exception, and it is not an exception to the
rule so much as a different thing: scratch is what you produce while working, a
note is what you learned. It is gitignored, so writing one does not put anything
in the repository.
Local findings (.agent-memory/)
These notes are local to your checkout. .agent-memory/ is gitignored and
untracked; it was committed until 2026-09-03 and was deliberately made
local-only again. Nothing here is reviewed, shared, or carried to another clone,
and a note you write is a note only you will read.
One finding per file under .agent-memory/notes/<slug>.md, with title,
date and tags frontmatter. just mem::recall <terms> searches them, just
mem::notes lists them, just mem::remember <slug> scaffolds one. xtask
check-agent-notes holds the shape and refuses a [[link]] to a note that does
not exist — run it yourself; it is not in check-all, because in CI the
directory does not exist and the gate has nothing to check.
Recall before you investigate. A measurement already in there is one you do not have to pay for twice.
Write one when you learn something the diff will not say — and especially when
you learn something is false. The falsifications are the notes that earn
their keep: teardown-scales-with-guest-ram records the obvious fix, the A/B
that refuted it, and why it could not have worked, which is the difference
between a day spent and a paragraph read. Say what not to retry, and say why.
Because the notes are local, anything another contributor needs to know has to
go somewhere tracked — a specs/ doc, an ADR, a comment, or the PR body. A note
is where you keep a measurement for your own next session, not how you tell
anyone else. Machine-specific context — host names, fleet layout, ssh targets,
local paths — is exactly what it is for.
These notes are observations, not authority. specs/adrs/ owns decisions and
the claims ledger owns what is enforced; where a note disagrees with one of
those, the owner wins and the note is stale.
Build and Run
cargo build
cargo run -- --help # full verb surface: build/run/template/image/network/console/init/cache/doctor/…Every subcommand is self-documenting via --help; the complete reference is
public/src/content/docs/reference/cli-commands.md. Build-time verbs
(image/run/template) live under build; console is an interactive PTY,
dev-mode only.
Dev Network Layout
MicroVM (172.16.0.2, eth0)
| TAP interface
Builder VM (172.16.0.1, tap0) -- iptables NAT -- internet
| libkrun (macOS 13-25) / HVF (macOS 26+) / direct (Linux KVM)
macOS / Linux HostDocumentation
public/src/content/docs/contributing/development.md-- contributor guide, testing, CI/CDpublic/src/content/docs/guides/nix-flakes.md-- writing Nix flakes for microVM images (mkGuest API)public/src/content/docs/guides/troubleshooting.md-- common issues and fixespublic/src/content/docs/contributing/adr/001-firecracker-only.md-- ADR: Firecracker-only executionpublic/src/content/docs/reference/cli-commands.md-- complete CLI command referencespecs/plans/-- technical implementation plans for active issues; issues own their status and legacy plans remain only as contextspecs/README.md-- current specs policy and retention rules
Naming a new plan
Name it by slug, not by number: specs/plans/2026-08-15-sdk-binding-fan-out.md.
A date prefix keeps plans sorting chronologically, which is the only thing the
numbers were really giving.
Numbers were a sequential id picked at authoring time, and this repo adds roughly three plans a day across concurrent branches — so two authors routinely picked the same next-free number, and neither could see the other's claim until its PR opened. 18 numbers ended up shared by two plans. Scanning open PRs before picking does not fix it: a branch that has claimed a number and not yet opened its PR is invisible to any scan.
The plans that already carry numbers keep them — renaming them would invalidate
hundreds of Plan NNN references for no benefit. xtask check-plan-names
freezes that set and fails a new number-named plan. Refer to a plan by its
path or title rather than a bare number.
Work tracking and specifications
GitHub issues are the only source of truth for work status, remaining scope,
dependencies, and acceptance criteria. Pull requests record delivery and
validation. Do not maintain a parallel sprint, refactor, delivery, or progress
dashboard under specs/.
specs/ is reserved for durable decisions and contracts plus technical design
material that is still useful while an issue is open. A plan may explain the
implementation, but its checkboxes do not own status and need not be updated as
work lands. Legacy documents may still instruct readers to update retired
dashboards; those instructions are historical and are superseded by this
section and specs/README.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

