Skip to content
necessary-nuPublic

About

Single-use microVMs from OCI images on Linux (Firecracker) and Apple silicon macOS (Crabapple).

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

arsonist

Single-use microVMs from OCI images on Linux (Firecracker) and Apple silicon macOS (Crabapple).

Every run boots a fresh VM with its own kernel, clean copy-on-write root filesystem, and hardware isolation — then throws the VM away on exit. No Docker daemon, sysbox, or privileged containers on the host. One binary acts as both the host controller and the guest bootstrap (/init on Linux, arsonist macos-guest on macOS).

Two ways to use it

Mode Driven by Best for
CI pools (slots) systemd / launchd looping one job per boot Buildkite, GitHub Actions ephemeral runners, GitLab, or custom CI workers
On-demand sandboxes arsonist serve (Unix-socket API) or arsonist run (CLI) Multi-tenant workloads, hosted coding/ACP agents, untrusted code execution

Both modes share the same image pipeline, per-slot /30 subnet & UID isolation, and Linux/macOS backends. Dynamic sandboxes lease non-overlapping slot indices above any configured static pools.

Architecture

flowchart TB
    subgraph Callers
        ci["CI Pools<br/>systemd / launchd"]
        api["On-Demand Callers<br/>CLI / Unix-socket API"]
    end

    ci --> slot["arsonist slot run"]
    api --> serve["arsonist serve"]

    slot --> core["Shared Slot Isolation<br/>/30 subnet · per-slot UID · volumes · bridges · OpenBao SSH"]
    serve --> core

    subgraph Linux["Linux (Firecracker)"]
        fc["Jailer chroot + Firecracker<br/>EROFS rootfs · static /init<br/>TAP + nftables · vsock · ext4"]
    end

    subgraph macOS["macOS (Crabapple)"]
        cb["App Sandbox + Virtualization.framework<br/>Warm VM snapshots · APFS clonefile<br/>smoltcp Link · USB hot-attach APFS volumes"]
    end

    core --> fc
    core --> cb
Loading

Generic CI runners ([runner])

Arsonist is runner-agnostic. Configure a workload once under [runner] and override per pool under [pools.<name>]:

  • command — guest argv for one job (optional on Linux, where the image's OCI ENTRYPOINT, CMD, USER, and WORKDIR are honoured automatically).
  • env & env_files — static environment and host files read fresh and trimmed on every boot (kept in guest memory, never written to guest disks).
  • prepare — optional host pre-boot hook receiving slot/image metadata as JSON on stdin and returning per-boot command/env JSON on stdout (for JIT registration tokens, dynamic labels, etc.).
  • dockerd — if the Linux image ships dockerd, guest init starts it automatically so jobs can build and run containers inside their own VM.

On-demand sandboxes ([sandbox])

Built for services that need one hardware-isolated VM per request without granting the caller root:

  • Streaming stdio: full-duplex stdin/stdout/stderr over vsock (Linux) or the guest Link (macOS) with bounded 64 KiB frames, backpressure, stdin EOF half-close, and exact guest exit-code propagation.
  • Named per-tenant volumes: isolated ext4 (Linux) or APFS (macOS) images under <state_dir>/volumes/, guarded by exclusive advisory flock locks so concurrent runs cannot corrupt a volume and active volumes cannot be deleted.
  • Scoped host-service bridges: expose allowlisted host Unix sockets or loopback TCP ports inside one guest (for example an MCP callback endpoint on 127.0.0.1:4400) without exposing the host or LAN; revoked immediately when the run ends.
  • Per-run network policies:
    • none — no NIC on Linux, no uplink on macOS; all egress dropped while stdio and bridges keep working.
    • egress — internet uplink only; host, other slots, loopback, and broadcast denied.
    • allowlist — default-deny egress except explicitly listed IPv4 CIDRs and host-resolved hostnames.
  • Local Unix-socket daemon (arsonist serve): mode 0660 with SO_PEERCRED / getpeereid peer-UID access control so unprivileged apps can launch VMs safely.

OpenBao SSH signing ([ssh_agent])

With [ssh_agent] configured, guests get SSH_AUTH_SOCK backed by an Ed25519 key in OpenBao's transit engine via bao-ssh-agent. The private key and AppRole credentials never enter any VM, and every signature is logged under the requesting slot.

Quick start

On-demand sandboxes

Configure [sandbox] in /etc/arsonist/config.toml (see config.example.toml or config.macos.example.toml):

[sandbox]
socket = "/run/arsonist/daemon.sock"
max_concurrent = 4
allowed_uids = [1000]
memory = "2G"
timeout_secs = 1800

[sandbox.bridges.mcp]
kind = "tcp"
port = 4400

Start the host daemon and run ephemeral VMs from the CLI or over the Unix socket:

# Pull a standalone image for on-demand sandboxes (no pool required)
sudo arsonist images pull ghcr.io/example/agent:latest

# Host daemon (runs privileged; callers stay unprivileged)
sudo arsonist serve

# Ephemeral run with streaming stdio, per-tenant volume, scoped bridge, and no internet
# (Ctrl-C drains the guest cleanly; a second Ctrl-C powers it off immediately)
arsonist run \
  --image ghcr.io/example/agent:latest \
  --volume tenant_a:/home/agent/profile:512 \
  --bridge mcp:tcp:4400 \
  --network none \
  -- /usr/local/bin/agent-acp

# Inspect or cancel active runs and manage tenant volumes
arsonist sandbox list
arsonist sandbox cancel <run-id>
arsonist volume list
arsonist volume delete tenant_a

Daemon HTTP API (arsonist serve)

Endpoint Behaviour
GET /v1/health Returns daemon readiness, Arsonist version, and active run count
GET /v1/runs Lists active sandbox runs (id, image, slot, started_at_unix)
POST /v1/runs Streams NDJSON events (started, stdout, stderr, exited, error)
POST /v1/runs?stream=framed Upgrades (101) with X-Arsonist-Run-Id to full-duplex framed stdio
POST /v1/runs/{id}/cancel Sends one graceful SIGTERM drain (?force=1 powers off immediately)
GET /v1/volumes Lists named volumes, byte sizes, and lock state
DELETE /v1/volumes/{name} Removes an unlocked volume (409 Conflict if in use, 404 if absent)

CI pools on Linux

Requirements: x86_64 Linux with /dev/kvm, systemd with cgroup v2, and Ubuntu/Debian apt for arsonist setup.

gh release download --repo necessary-nu/arsonist --pattern arsonist-x86_64-linux
sudo install -m 755 arsonist-x86_64-linux /usr/local/bin/arsonist
sudo arsonist setup          # installs e2fsprogs, erofs-utils, iproute2, nftables, pinned Firecracker, example config
sudoedit /etc/arsonist/config.toml
echo -n "$RUNNER_TOKEN" | sudo install -m 600 /dev/stdin /etc/arsonist/agent-token
echo -n "$GHCR_TOKEN"   | sudo arsonist auth login ghcr.io -u <user>   # private registries only
sudo arsonist install        # writes & enables systemd units (slots, network, image timer, and serve if [sandbox] is set)
sudo arsonist status

The Firecracker guest kernel (ghcr.io/necessary-nu/arsonist-kernel:latest, built from Amazon Linux microvm-kernel-* with kernel/arsonist.config) is pulled automatically alongside pool images.

If Docker also runs on the host, Arsonist inserts allowances in DOCKER-USER; other default-drop firewalls (such as ufw) must permit forwarding on arsonist+.

CI pools and sandboxes on macOS

On Apple silicon, download arsonist-aarch64-darwin and Crabapple-aarch64-darwin.app.tar.gz (or build and sign Crabapple with crates/crabapple/package.sh), set backend = "crabapple", and run sudo arsonist setup to write the example config and verify Crabapple's entitlements and slot user accounts. Each slot runs as its own macOS user (uid_base + index) inside Crabapple's App Sandbox container, with slots, image updates, and arsonist serve managed as launchd daemons by arsonist install. On first boot of an image digest + VM shape (or ahead of time via arsonist snapshot warm), Crabapple warms a local VZVirtualMachine snapshot (post-boot, pre-workload) and clones it via APFS clonefile on every subsequent run, hot-attaching cache and tenant APFS volumes over XHCI USB after resume, cutting boot times roughly 3× (~5 s warm vs ~15 s cold). Logs go to Apple Unified Logging (os_log) under subsystem nu.necessary.arsonist. See docs/design/crabapple.md and config.macos.example.toml.

OpenBao SSH agent

Create a transit key and scoped AppRole per bao-ssh-agent's README, then:

echo '{"role_id":"…","secret_id":"…"}' | sudo install -m 600 /dev/stdin /etc/arsonist/openbao-approle.json
sudo arsonist ssh-agent public-key   # register on your git host

Operating

Slots reload configuration between boots, and running VMs keep hard links to the image digest they booted from, so image updates and binary upgrades roll out with zero manual draining. Stopping a slot (systemctl stop arsonist@<slot> on Linux, launchctl bootout system/nu.necessary.arsonist.slot.<slot> on macOS) sends Ctrl-Alt-Del / Drain, delivering one SIGTERM so the current job finishes cleanly before shutdown; a second stop forces power-off.

Host supervisor logs and guest stdout/stderr go to journald on Linux (arsonist@<slot>.service) and Apple Unified Logging (os_log) on macOS (subsystem nu.necessary.arsonist, category slot.<slot> / images / serve).

Task Command
Host, slot, daemon & snapshot status sudo arsonist status
Follow slot logs (Linux & macOS) arsonist slot logs <slot> -f
Recent slot logs (Linux & macOS) arsonist slot logs <slot> --last 30m
Pull one standalone image sudo arsonist images pull <image>
Trigger pool image sync now sudo arsonist images update
List / cancel active sandbox runs arsonist sandbox list / arsonist sandbox cancel <id>
List / pre-warm / prune macOS snapshots arsonist snapshot list / warm [--image <ref>] / prune
Reset a slot's cache disk sudo arsonist slot reset-cache <slot>
Export flattened OCI rootfs arsonist images export <image> -o rootfs.tar
Show full Linux kernel boot Set [kernel] args = "" and restart the slot

Inside both Linux and macOS guests, $ARSONIST_VM_INFO points to a vm.json file (/run/arsonist/vm.json on Linux) recording the slot name, host, image digest, kernel, and Arsonist version.

Developing

Arsonist builds and tests natively on both Linux and Apple silicon macOS. On Linux, arsonist slot run requires a statically linked binary because it is copied directly into each VM's initramfs as /init.

# Format, clippy (all targets + macos-vm-tests), bundle lint, and unit tests
nplan check

# Cross-compile static Linux binary from macOS
cargo zigbuild --workspace --locked --target x86_64-unknown-linux-musl

# Boot a Linux guest under QEMU (no KVM required)
docker buildx build --platform linux/amd64 --output type=local,dest=out kernel/
scripts/qemu-boot.sh out/vmlinux target/x86_64-unknown-linux-musl/debug/arsonist

# Boot real macOS guests end to end on Apple silicon (see src/apple/vm_tests.rs)
cargo build --workspace --bins --examples
sh crates/crabapple/package.sh target/debug/crabapple /private/tmp/Crabapple.app
cargo run --example macos_guest_fixture -- ~/.tart/vms/<vm> /private/tmp/arsonist-fixture admin
CRABAPPLE=/private/tmp/Crabapple.app/Contents/MacOS/crabapple \
  ARSONIST_FIXTURE=/private/tmp/arsonist-fixture GUEST_HOME=/Users/admin \
  cargo test --features macos-vm-tests apple::vm_tests -- --test-threads 1 --nocapture

# OpenBao SSH agent e2e test
crates/bao-ssh-agent/scripts/e2e.sh

Specs & Design

Licence

EUPL-1.2. See LICENSE.

About

Single-use microVMs from OCI images on Linux (Firecracker) and Apple silicon macOS (Crabapple).

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages