BuildWarden
BuildWarden produces a cryptographically-signed, tamper-evident ledger of every input to a software build. It answers the question: what exactly went into this binary?
The Problem
When you run docker build, hundreds of network requests happen silently — base images pulled, packages downloaded, dependencies fetched. If any of those sources are compromised, your build is compromised. Traditional approaches (pinning versions, using lockfiles) help but don't prove what actually happened at build time.
The Solution
BuildWarden interposes a relay between your build and the network. Every byte that enters (or leaves) the build flows through this relay and is recorded into a cryptographic ledger:
- Source files — individually hashed as they enter via the relay
- Network fetches — every HTTP/HTTPS request and response recorded
- Container images — registry pulls captured at the layer level
- Build artifacts — outputs posted back to the ledger for verification
The ledger uses chained Ed25519 signatures — altering, reordering, or removing any entry invalidates all subsequent signatures.
Who Is This For?
- Build infrastructure providers (CI/CD platforms, cloud build services) who want to offer verified builds
- Security teams auditing supply chain integrity
- Open source maintainers proving their releases match their source
- Anyone who wants to answer "what went into this build?" with cryptographic proof
Installation
Prerequisites
Prerequisites vary by driver:
Container driver (any platform)
A container runtime is required. Any of the following will work:
- Finch (preferred on macOS; a build starts its VM when it is stopped, see finch's VM)
- Podman
- Docker
warden runs the runtime by its name (finch, podman or docker), which
it looks up on PATH. If yours is installed outside PATH, as it often is
for a CI job or a service, add its directory to PATH: the runtime setting
takes one of the three names, not a path.
QEMU driver
Requires qemu-system-{arch} and qemu-img:
# macOS
brew install qemu
# Linux (Debian/Ubuntu)
apt install qemu-system
Firecracker driver
Requires an x86_64 Linux host with KVM (/dev/kvm), your user in the kvm
group, and the firecracker binary (v1.17.0 or later) on PATH:
sudo usermod -aG kvm "$USER" # then log in again
v=v1.17.0
curl -fsSLO https://github.com/firecracker-microvm/firecracker/releases/download/$v/firecracker-$v-x86_64.tgz
curl -fsSLO https://github.com/firecracker-microvm/firecracker/releases/download/$v/firecracker-$v-x86_64.tgz.sha256.txt
sha256sum -c firecracker-$v-x86_64.tgz.sha256.txt
tar -xzf firecracker-$v-x86_64.tgz
sudo install -m 0755 release-$v-x86_64/firecracker-$v-x86_64 /usr/local/bin/firecracker
# Host networking and disk-image tools (Debian/Ubuntu)
sudo apt install iproute2 nftables iptables qemu-utils genisoimage
Hyper-V driver
Requires Windows with Hyper-V and its management stack enabled, and membership in Hyper-V Administrators (or an elevated terminal). Building the relay boot disk from a source tree also needs Git Bash and WSL.
VZ driver
Requires macOS on Apple Silicon. Virtualization.framework is built into macOS,
but the vz driver is only in a warden you build from source
on the Mac: a released warden has none, and --driver vz says so (see the
drivers guide). The build also needs the
Xcode Command Line Tools (xcode-select --install).
One-liner Install
curl -sSfL https://raw.githubusercontent.com/buildwarden/buildwarden/main/install.sh | sh
This detects your OS and architecture, downloads the latest release, and installs warden, the container driver warden-driver-container and warden-io to /usr/local/bin/. The container driver is a program of its own, which warden finds beside itself; with it, the release is ready for the container driver out of the box. It is built without cgo, so it has no vz driver: for vz, build warden from source on the Mac and follow the first-time VZ setup.
From Releases
Download the appropriate binary from GitHub Releases:
# macOS (Apple Silicon)
tar xzf buildwarden_*_darwin_arm64.tar.gz
mv warden warden-driver-container warden-io /usr/local/bin/
# Linux (x86_64)
tar xzf buildwarden_*_linux_amd64.tar.gz
mv warden warden-driver-container warden-io /usr/local/bin/
Keep warden-driver-container in the same directory as warden: warden
looks for its drivers on PATH, then beside itself (Drivers).
These are the same binaries the one-liner installs, so the macOS one has no vz driver either.
From Source
git clone https://github.com/buildwarden/buildwarden.git
cd buildwarden
make build
Requires Go 1.26+ (managed via mise if present). On
a Mac it also needs the Xcode Command Line Tools: make build compiles the vz
driver with cgo, which a release does not.
The build produces the following binaries in dist/:
| Binary | Description |
|---|---|
dist/warden | Host binary (codesigned on macOS for VZ entitlement) |
dist/warden-driver-container | The container driver, which warden runs from beside itself (warden-driver-container.exe on Windows) |
dist/warden-relay-linux-arm64 | Relay binary for VM/container use |
dist/warden-io-linux-arm64 | Agent binary for Linux build environments |
dist/warden-io-darwin-arm64 | Agent binary for macOS VZ builds |
First-time VZ Setup
After building from source on macOS Apple Silicon:
make build # Builds + codesigns with virtualization entitlement
sudo warden image prepare --driver vz # Downloads macOS IPSW, restores VM, installs warden-io
The first image prepare downloads the latest supported macOS restore image
(about 25 GB), creates a VM disk, boots it, and installs the warden-io agent;
it runs under sudo because it writes root-owned files into the image. The
image it prepares becomes the active image, which builds use.
Later, the same command refreshes the active image's warden boot agent in place, with no download, and warns when Apple has published a newer macOS. Moving to that macOS is a separate step you choose:
sudo warden image prepare --driver vz # refresh the active image in place
sudo warden image prepare --driver vz --update # restore the latest supported macOS and make it active
warden image list # every prepared image, the active one first
You can also prepare from a .ipsw file you already have; it is read where it
is and not copied. The drivers guide
covers sources, disk use and what to do when a build refuses an out-of-date
image, and the CLI reference lists
every option.
First-time QEMU Setup
brew install qemu # macOS (or apt install qemu-system on Linux)
make build # dist/warden and the guest binaries
tools/relay-vm/build-initramfs.sh # Build relay VM kernel + initramfs
tools/build-vm/build-initramfs.sh # Build test VM initramfs (includes warden-io)
dist/warden doctor --driver qemu
Run the VM drivers as dist/warden from this tree: warden finds the relay
VM assets and the source it builds guest binaries from only in the tree its
executable is in.
First-time Firecracker Setup
make build
tools/firecracker-vm/build-kernel.sh # pinned guest kernel
ARCH=x86_64 NO_MODULES=1 tools/relay-vm/build-initramfs.sh # x86_64 relay initramfs
tools/firecracker-vm/build-initramfs.sh # direct-boot initramfs
sudo dist/warden setup --driver firecracker # network slots (each boot)
dist/warden doctor --driver firecracker
The kernel build needs make, gcc, flex, bison, bc, libelf-dev and
libssl-dev. The slots do not survive a reboot; the
drivers guide shows a systemd unit
that re-creates them at boot. Setup refuses, with the fix, when the host's
FORWARD policy is ACCEPT or firewalld is running, and while any slot is in
use by a build or by VMs a --keep-vms build left running.
Optionally cache the default disk image before the first build, so that build does not pay for the download and conversion:
dist/warden image prepare --driver firecracker # ubuntu:24.04
The relay needs a DNS server that is not on the host itself. A host whose only
resolver is local (a resolver-less systemd-resolved stub, a local dnsmasq, or
WSL's 10.255.255.254) gets an error that says how to fix it: give the host
an off-host resolver, or name one in [vm] dns; see
Upstream DNS.
WSL2 is experimental: it needs nested virtualization and a custom WSL kernel
built with NF_TABLES_BRIDGE, which the stock kernel leaves out, and WSL
loses the slots and its iptables state whenever its VM shuts down, so re-run
setup after each restart.
First-time Hyper-V Setup
From a source tree, in Git Bash, then an elevated terminal for setup:
tools/relay-vm/hyperv/refresh-cache.sh # relay boot disk (needs WSL)
warden setup --driver hyperv # elevated, once: NAT and 4 build switches
warden image prepare --driver hyperv # Windows Server base image (about 11 GB)
warden doctor --driver hyperv
warden setup --driver hyperv makes the durable network that builds run on
without elevation: an Internal NAT switch with its host IP and NAT rule, and
one Private build switch per build that can run at once, warden-dev-0 to
warden-dev-3 by default. Pass --slots N (1 to 64) for more or fewer
concurrent builds; re-running setup with a smaller number removes the
switches above it that nothing is attached to. When the default NAT prefix, 192.168.240.0/20, is
already used on your network, pick another with --nat-prefix and
--host-ip; every build then gives its relay an address in that prefix (see
Corporate Networks).
Each build's relay resolves names through the IPv4 DNS servers of the host's
default-route interface, or only through [vm] dns when you set it. A host
whose only resolver is on the host itself is refused before any VM boots,
naming the interface and both fixes.
warden doctor --driver hyperv ends with a Build network block: the NAT it
read back (warden-dev-nat (192.168.240.0/20, host 192.168.240.1)), the
relay's resolvers and where they came from (10.9.0.53 (from interface Ethernet)), and each build switch free or in use by the VMs on it. A
BLOCKED line there names its fix. An address other than the host IP on the
NAT's vNIC, vEthernet (warden-dev-nat), is a warning naming the
Remove-NetIPAddress that clears it; setup leaves only the host IP there when
it makes the NAT.
Upgrading an Existing VM Driver Install
The VM drivers' relay-to-build link is now configurable ([vm] build_link),
and the launchers that read it changed. If you set up a VM driver before this
change, replace its launcher asset once: the Hyper-V relay boot VHDX
(tools/relay-vm/hyperv/refresh-cache.sh), the vz prepared image
(sudo warden image prepare --driver vz, in place), or the qemu and
Firecracker direct-boot initramfs (their build-initramfs.sh). Until you do,
a build refuses to start and names the command, and warden doctor reports
the asset's link-channel stamp as missing or stale. The full table is in
Upgrading to the configurable build link.
Hyper-V's per-build relay channel changed the relay boot disk and the durable
network once more. On a host set up before it, run two commands once:
tools/relay-vm/hyperv/refresh-cache.sh, since a build refuses a relay boot
disk from before the change and names that command; and, elevated,
warden setup --driver hyperv, which makes the per-build switches and retires
the single warden-dev build switch of earlier setups. Until you do, durable
(non-elevated) builds refuse to start and name warden setup; elevated and
service builds make their own switch and need only the relay disk. The qemu
and Firecracker relay initramfs need no rebuild.
Upgrading: the Container Runtime Setting
Earlier releases ran whatever program --runtime, WARDEN_CTR_CLI or
[runtime] cli named. The setting now takes finch, podman or docker
and nothing else, wherever it is set. If yours names one of the three or is
unset, nothing changes. Any other value is refused by the first command that
uses the container runtime (build, shell and doctor with the container
driver; clean with the container driver, qemu or vz), before anything
is run, and the error says where the value is set and what to change.
Two kinds of value have a replacement:
- A path to a supported runtime (
/opt/homebrew/bin/docker), or its name in another form (Docker,docker.exe): write the name,docker, and add the runtime's directory toPATHif it is not there. - A wrapper script that only set variables for a supported runtime
(
DOCKER_HOST,DOCKER_CONTEXT,CONTAINER_HOST): name the runtime and set those variables in the environmentwardenruns in.
nerdctl, and a wrapper that added sudo or arguments, have none.
A path, or another runtime
lists every value that stopped working and the message each one gets.
Upgrading: Driver Binaries and Renamed Keys
The container driver is now a binary of its own, warden-driver-container,
which warden runs from beside itself. The one-liner and the release archives
install it; if you copy warden by hand, copy warden-driver-container into
the same directory. warden driver list shows which file each driver name
runs and where it was found, and a build records the same in its output's
driver.json.
A driver's settings moved into [driver] and [driver.<name>]. An existing
warden.toml keeps working: the old names are read until BuildWarden 1.0,
and each one prints a warning naming its new key:
[warden] warning: /src/repo/warden.toml: [runtime] cli is deprecated; use [driver.container] cli
Rename them when you next edit the file. [runtime] cli = "podman" becomes:
[driver.container]
cli = "podman"
Renamed keys lists all seven. A file
that sets both names of one key is refused. A driver's keys are now
case-sensitive: [Runtime] CLI is refused with the spelling to write, see
Keys are case-sensitive.
[runtime] driver is warden's own key and does not change.
Verify Installation
warden --version
warden --help
warden driver list # the drivers warden finds, and the file each one runs
BuildWarden auto-detects your container runtime for the container driver (trying finch, podman, docker in order, so podman rather than docker when both are running; on macOS and Windows a finch whose VM is stopped is passed over for one that is up, and its VM is started only when none is, see finch's VM). Override with --runtime or the WARDEN_CTR_CLI environment variable; see The container runtime.
Your First Build
Run a warden build
The basic flow is the same regardless of driver:
warden build . # Container driver (default)
warden build --driver qemu . # QEMU driver
warden build --driver vz --script ./build.sh . # VZ driver
warden build --driver hyperv . # Hyper-V driver
warden build --driver firecracker . # Firecracker driver
The VM drivers need a one-time setup first; see
Installation and the drivers guide.
For vz that starts with building warden from source on the Mac: a released
warden has no vz driver.
For the container driver you can also point at a specific Dockerfile:
warden build ./my-project/Dockerfile.prod
The container driver uses the first of finch, podman and docker that
answers, so with both docker and podman running it uses podman. On
macOS and Windows a finch whose VM is stopped is passed over for a runtime
that is up, and used, its VM started, only when none is. To choose one,
name it (--runtime docker for docker):
warden build --runtime podman .
Those three names are the only values the runtime takes, on the command
line, in WARDEN_CTR_CLI and in a warden.toml. A build whose runtime
setting holds anything else (a path, a wrapper script, another runtime)
stops before it runs anything, and the error says where the value is set and
what to change. When it is set in the warden.toml of a repository you
cloned, --runtime with one of the three builds it without editing the
file. A runtime you name must also be installed and running: one that is
not on PATH stops the build before it makes an output directory, and one
whose VM or daemon is stopped fails the build at its first call to the
runtime, which leaves the output directory as any failed build does.
warden does not pick another in its place. Start it, or name another;
warden doctor checks that the runtime answers.
The container runtime
has the rules and the errors.
finch on macOS and Windows is the exception: a build starts its stopped VM itself, at that first call, and says so before finch's own output:
[warden] finch's VM is stopped; starting it (finch vm start), as [driver.container] start_finch_vm is true (the default)
INFO[0000] Starting existing Finch virtual machine...
The VM stays running after the build. To have finch's VM started only by
hand, set start_finch_vm = false under [driver.container]; a build then
fails with the fix to run finch vm start. finch's
VM has the details.
Built from its own directory, a repository's warden.toml is the config
file, and it chooses more than the runtime: the driver, the relay image and
its trust roots. It must be a regular file of at most 1 MiB. To build a
repository you do not control, name your own file with --config or
WARDEN_CONFIG; Building a repository you do not
control
has the list.
What you'll see
The output is consistent across all drivers:
[warden] Build ID: abc12345
[warden] ... (driver-specific startup messages) ...
warden-io: configuring network
warden-io: waiting for relay
warden-io: installing CA
warden-io: fetching build script
warden-io: running build.sh
... (build output) ...
[warden] Build complete
[warden] Output: warden-output
If the build environment exits before the build completes (the script
powers off a VM, or the container's init fails), warden waits 10 seconds
for the completion, then fails with the build environment exited before the build completed and a To fix: line naming the build's
build-output.log, which holds the last thing the build printed.
Output directory
After the build completes (same structure for all drivers):
warden-output/
├── ledger.zst # Cryptographic ledger (ledger if --no-compress)
├── ca.cert.pem.zst # Ephemeral CA cert (ca.cert.pem if --no-compress)
├── driver.json # Which driver ran the build, and where it was found
├── build-output.log # Captured build console output
├── artifacts/ # Build outputs posted via warden-io post
│ └── myapp.whl
├── captures/ # Captured payloads (only with --capture)
├── payloads/ # Content-addressed payload storage
├── relay.log # Relay event log (container and vz drivers)
├── inputs/ # Only for a build from a Dockerfile (ORCH-02)
│ ├── Containerfile # the Dockerfile you submitted, unchanged
│ └── build.sh # the script it was translated to: what ran
└── console.log # Build container console (container driver only)
Posting artifacts
To record a build output in the ledger, use warden-io post from within your build script or Dockerfile RUN step:
warden-io post /path/to/output.whl myapp-1.0.0.whl
The artifact is hashed, signed into the ledger, and saved in the output directory. This works identically in all drivers.
Fetching context files
To pull files from the host into your build environment:
# Fetch a single file:
warden-io fetch config.json -o /tmp/config.json
# Fetch entire context:
warden-io fetch . -o /workspace
This works in all drivers — the relay serves context files over HTTP regardless of whether the build environment is a container or VM.
A first Firecracker build
On an x86_64 Linux host with KVM, after the Firecracker setup:
warden doctor --driver firecracker # every check should pass
warden image prepare --driver firecracker # optional: caches ubuntu:24.04
warden build --driver firecracker . # a Dockerfile FROM ubuntu:24.04
Doctor's output includes the build link and its source, for example
build link 100.127.255.252/30 (default), then
build link: no host interface overlaps it and
firecracker direct-boot launcher initramfs: link-channel stamp current. A
BLOCKED line names its fix; an initramfs built before the configurable
build link is missing or stale until tools/firecracker-vm/build-initramfs.sh
rebuilds it once.
A Dockerfile whose FROM is ubuntu:24.04, debian:bookworm or
alpine:3.21 (or a build given --image <path>) boots that disk image, and
the first build converts it once if you skipped image prepare. A
--script build with no image boots straight from a small initramfs instead,
which is faster but has only what your script brings:
warden build --driver firecracker --script build.sh ./src
If a build stops before booting with a DNS error, the host has no resolver
the relay can use: only local ones (systemd-resolved's stub with no upstream,
a local dnsmasq, or WSL's 10.255.255.254), or only ones inside the build
link. The error says what to change: an off-host resolver on the host, or
[vm] dns naming one. Upstream DNS
covers it; moving the link is in
Corporate Networks.
To look at the VMs after a build, add --keep-vms: both VMs keep running and
warden prints their pids. Stop them, and any left by an interrupted build,
with:
warden clean --driver firecracker
A first Hyper-V build
On Windows, after the Hyper-V setup, from a terminal in Hyper-V Administrators (no elevation needed):
warden doctor --driver hyperv # every check should pass
warden build --driver hyperv --guest-os windows ./win-project
Each build gets its own relay address on the NAT, its own claim token and one
of the build switches warden setup made, so you can start several builds at
once, up to the --slots you set up (4 by default). One more is refused
before any VM boots, naming the VMs on each switch and --slots. A
--keep-vms build keeps its switch until you remove its VMs with
warden clean --driver hyperv; until then doctor lists the switch as
in use by them. Clean never removes the build switches themselves.
The Windows build VM takes its address from the relay's DHCP lease. A guest
that gets no lease waits for the relay, fails, and powers off; its
warden-run.log and COM1 console record the address its NIC ended on and
where it came from (WellKnown, no DHCP lease from the relay).
Interactive debugging (container driver)
warden shell .
# Drops into isolated container — all traffic still audited
warden clean leaves an open shell session alone, as it does a running
build, while its warden-driver-container runs; see
warden clean.
Custom output location
warden build -o ./my-custom-output .
Disabling compression
warden build --no-compress .
Inspecting Results
Basic inspection
After a build, inspect the ledger:
warden inspect warden-output
You can also point directly at a ledger file:
warden inspect warden-output/ledger.zst
Compressed (.zst) and uncompressed ledgers are handled transparently.
Reading the output
════════════════════════════════════════════════════════════════════════════════
LEDGER scheme=ed25519-sha512 hashes=[blake2b_256 sha256 sha1 md5] ✅
════════════════════════════════════════════════════════════════════════════════
✅ HEAD https://registry-1.docker.io/v2/library/python/manifests/3.12-slim (0 bytes)
✅ GET https://registry-1.docker.io/v2/library/python/blobs/sha256:... (64167785 bytes)
✅ GET http://deb.debian.org/debian/dists/bookworm/main/... (8690780 bytes)
✅ GET http://cwd/requirements.txt (42 bytes)
✅ GET https://files.pythonhosted.org/.../requests-2.32.3.tar.gz (131218 bytes)
✅ ARTIFACT POST http://artifacts/requests-2.32.3-py3-none-any.whl (65027 bytes)
════════════════════════════════════════════════════════════════════════════════
SUMMARY: 255 records, 64 requests, 59.8 MB audited, 1 artifact(s)
SIGNATURES: ✅ All 256 signatures valid
COMPLETENESS: ✅ All channels closed
════════════════════════════════════════════════════════════════════════════════
Each line represents a complete request lifecycle (open → data transfer → close) with a valid signature chain.
Record types
- Container registry requests — base image pulls from Docker Hub or other registries
- Package manager fetches — apt, pip, npm, cargo dependencies
http://cwd/requests — source files from your build context (COPY provenance)- ARTIFACT — build outputs posted back via
http://artifacts/
Signature verification
The ✅ indicates all signatures in the chain are valid. If any record were altered, reordered, or removed, the chain would break and show ❌.
Verbosity levels
# Compact (default) — one line per request
warden inspect warden-output
# Tree — shows checkpoints within each request
warden inspect --verbosity 1 warden-output
# Full — all record details
warden inspect --verbosity 2 warden-output
JSON output
For scripting and CI integration:
warden inspect --json warden-output
Returns a structured JSON document with header info, all records, and a summary object.
Exit codes
0— ledger is valid1— verification failed (signature errors or parse failure)
How It Works
This page describes each core component as pseudocode: what it does, in what
order, and what it talks to. It is kept in step with the code (FLOW-15 in
docs/development/process.md), so you can read how a build runs without reading
the source. Architecture has the topology diagrams and the
endpoint tables.
The shape of a build
HOST BUILD ENVIRONMENT
warden (orchestrator) (container or VM)
|-- collector <==== tunnel ==== relay <==== warden-io initialize
| serves inputs, the only fetches every input,
| lands outputs network path runs the build script
'-- driver: isolate, deliver warden-io, start (then only watches)
Three rules hold for every driver (the full model is
docs/development/bootstrap.md):
- The build environment is isolated before any of its code runs.
- The host delivers exactly one thing into it: the
warden-ioexecutable. - After starting it, the host does nothing inside it. Everything else (the CA, the build script, your files) comes through the relay, which records it.
warden build (orchestrator, cmd/warden)
warden build <context>:
load warden's own configuration from the one config file (--config,
found by a scan of the raw arguments, else WARDEN_CONFIG, else
./warden.toml if it exists, else none; a named file that cannot
be read is an error, and so is a ./warden.toml that is not a
regular file or that gives more than 1 MiB)
# the driver may be named in it
driver := the driver named by --driver (found by the same scan),
WARDEN_DRIVER or [runtime] driver (in the config file a
name, never a path), else container: a path as
given, else warden-driver-<name> on PATH in PATH's order,
else beside warden, else a linked driver; not found is an
error
d := driver.describe # what it is; the flags it takes
parse the command line: warden's flags, and the driver's declared
flags, whose values are passed on unread; a flag neither declares
is refused, and so is a line whose parsed --driver or --config
is not the scanned one
req := resolve warden's flags and config (output dir, capture, ...)
req.UpstreamCACerts := the valid PEM certificates under each
upstream CA path (WARDEN_UPSTREAM_CA_CERTS, else [relay]
upstream_ca_certs), read once, before any driver work; each
skip and each path's count logged; a path that is missing,
unreadable or gives none is an error
VM drivers (capabilities.vm): req.BuildLink := --build-link, else
[vm] build_link (checked as the file loads), else
100.127.255.252/30, disjoint from BuildWarden's own ranges;
req.DNS := [vm] dns (checked as the file loads), else none
probe `driver run` # the driver reads and checks its
# own flags and keys, then makes
# its preflight
lock build-<driver>-<id>; write the build record beside the lock
write <output>/driver.json
script := translate(Containerfile, context) # see Translator; not when
# the driver ignores one
if script was translated: keep both under <output>/inputs/ # ORCH-02
start `driver run`; send start{id, claim token, script, base image,
state file, the config file's path, the driver's flags, ...}
<- relay-started{claim address, environment, build link, resolvers}
session := StartSession(output dir, context, script, guest OS)
session.ClaimRelay(claim address, claim token, the driver's values)
-> claimed
<- environment-started
session.Wait() # completion, a failure, SIGINT or SIGTERM, or the
# driver's `exited` (a relay exit at once, a build
# exit after 10 s)
-> stop; <- stopped # the driver tears down
a driver that died or would not stop within [build] teardown_timeout:
kill it, `driver reap <id>` with the record's values
remove the stage directory, the record and the lock
finalize output (optional zstd); print the result; exit with the build
script's exit code
Each driver's run follows the same skeleton, in a process of its own for a
driver binary (the container driver, warden-driver-container) and as a Go
call for a driver linked into warden (qemu, vz, hyperv, firecracker). Only
the marked steps differ per driver.
run (one process per build, or a linked driver's Run):
<- start
read its own configuration: its flags from start, the two existing
variables, its keys from the config file start names (its own
table, then [driver] for a common key), with warden's
precedence # the kit
write the state file, if reap will need more than the ID # per driver
resolve the relay and the environment's image # per driver
VM drivers: refuse a build link a host interface holds, and a launcher
asset whose link-channel stamp is missing or old
relay := start the relay, unconfigured, with the claim token # per driver
-> relay-started; wait for claimed
isolate the build environment # per driver
deliver warden-io into it # per driver
start it # per driver
-> environment-started; wait for stop or the end of input
write relay.log and console.log; teardown, even with stdout and
stderr closed
-> stopped
The other commands run the driver once each and exit: doctor, setup,
image prepare, image list and image verify (the bundled drivers'
binaries; a linked driver's code stays in warden until it is a binary),
clean, which probes the driver's clean, then runs reap for every
dead build from its record and the driver's clean with the live builds'
IDs as keep_ids, shell, which runs a build in mode shell and then the
driver's attach, and warden <name> ..., a driver's own commands. Each
finds the driver by the same lookup: a path as given, else PATH, else
beside warden, else a linked driver (warden driver list shows it).
Session and collector (driver/session.go, collector/)
The host side of one build, the same for every driver.
StartSession(cfg):
collector := new collector(
output dir,
build script -> GET /v1/build-script
bootstrap config -> GET /v1/bootstrap ({"version":1,"trust":{"mode":...}})
build context -> GET /v1/context/<path>
)
ClaimRelay(addr, token, link, oldRelayFix):
tunnel := POST addr/v1/tunnel # host dials the relay, never the reverse
serve collector over tunnel (HTTP/2)
identity := POST addr/v1/claim {collector URL = the tunnel, token, capture mode,
the upstream CA certificates of the request,
environment record,
build_link {prefix, relay, guest} when given,
upstream_dns = req.DNS when given}
a relay that refuses any field as unknown (it predates build_link or
upstream_dns): a fix naming oldRelayFix
# the relay answers only once its build segment is configured
wait for the relay's POST /v1/ready
write identity.CACert to <output>/ca.cert.pem
collector, for the life of the build:
PUT /v1/ledger, /v1/artifacts/*, /v1/captures/*, /v1/environment -> land on disk
POST /v1/output -> append to build-output.log (and tee to your terminal)
POST /v1/heartbeat -> note the guest is alive
POST /v1/complete -> record the exit code; Wait returns
Wait():
return when /v1/complete arrives (exit code 0 => success)
fail if the guest stops heartbeating, or the tunnel drops
Translator (driver/script)
Your Containerfile becomes a shell script on the host, because translating needs the build context.
translate(containerfile, context):
for each instruction:
FROM x -> the base image (one stage only)
RUN cmd -> cmd
ENV k=v -> export k="v" ($VAR expands, as in Docker)
ARG k=v -> : ${k:=v}; export k
WORKDIR d -> mkdir -p d; cd d
COPY src dst -> expand src against the context ON THE HOST
(files, directories, globs; .git skipped), then for each
file: warden-io fetch <context path> -o <destination>
USER, SHELL, ADD, a second FROM -> error before anything boots
EXPOSE, CMD, ENTRYPOINT, LABEL, ... -> ignored
Each warden-io fetch in the script pulls one file through the relay, which
records its bytes.
Container driver (driver/container, cmd/warden-driver-container)
resolve the runtime (--runtime, WARDEN_CTR_CLI, [driver.container] cli, else
the first of finch, podman, docker that is up; any other value is
refused before anything is run) and write it to the state file
the check: docker/podman `version --format {{.Server.Version}}`; finch
on macOS and Windows `finch vm status` (Running is up; Stopped,
Nonexistent, a failure, another word or no answer is not; it never
starts the VM), on Linux (no VM) `finch version`; by runtime.GOOS,
never a fallback
detection asks each candidate its check, 3 s each, for every command,
doctor included; none up and finch's VM Stopped: run and its probe take
finch, its start pending, when [driver.container] start_finch_vm is
true (unset = true); false -> detection's error naming the state and
the setting, in the probe. clean, reap and attach never take it
probe: a named runtime not on PATH -> fixable error naming where it was
named, before any output directory exists; no engine call (a named
finch is asked nothing, whatever start_finch_vm says); detection is
not tried in its place
build: a named runtime's first engine call is its check (10 s); it
fails -> fixable "installed but not running", start hint, warden doctor
build, finch with a VM (named, or detected with its start pending):
state := finch vm status (10 s)
Running -> go on
Stopped, start_finch_vm true -> print "finch's VM is stopped;
starting it (finch vm start), as [driver.container]
start_finch_vm is true (<the default | in <file>>)"; run
`finch vm start`, output on the driver's stderr, no deadline
but the build's context; it fails, or state is not Running
after it -> fixable "did not start", fix: finch vm start by
hand. The VM is left running
Stopped, start_finch_vm false -> fixable "its VM is not running
(`finch vm status`: Stopped)", fix names the setting and file
Nonexistent -> fixable, fix: finch vm init; anything else ->
fixable quoting what finch printed; never started
(the output directory is left after any of these, as after any
failed build)
doctor: a named runtime: its check (10 s); not on PATH, failing or not
answering -> blocked with the fix. None named: detection, as above, and
the runtime it chooses is not asked again; none up -> each installed
candidate asked again, in detection's order, 10 s each: the first that
answers -> blocked, "running but answered after more than 3 s", fix:
name it; none -> detection's error and start hint. At most 45 s:
3 x 3 s + 3 x 10 s = 39 s, plus up to 1 s per query (WaitDelay)
doctor, finch with a VM: never starts it. Stopped and start_finch_vm
true -> "container runtime: finch" and the line "finch's VM is
stopped; a build starts it (...); to start it now: finch vm start",
not blocked (detected: before any re-ask, as the build would take it);
Stopped and false -> blocked with the build's error; Nonexistent or
unknown -> blocked. Detected finch is re-asked only when its 3 s query
timed out; the re-ask says Running -> the slow hint above; Stopped and
start_finch_vm true -> blocked, "answered `finch vm status` (Stopped)
after more than 3 s", fix: name it (builds naming nothing skip it)
resolve the relay image (driver/relaysource) and verify it
allocate the per-build network (host lock "network", one HOME's builds):
for each /29 of 100.64.87.0/24, once: network create warden-<id> on it
(refused -> next block); read every network the runtime has (network
ls, then one network inspect with the runtime's template); another
network on an overlapping subnet -> remove ours, "[warden] network
<cidr> was also created by <other> at the same time; trying the next
/29", pause 0-100 ms, next block; none -> keep it. A failed reading
is read again, whole, after the pause, up to 5 readings, each retry
reported; the fifth failed -> remove ours, fail; none left -> fail,
fix: warden clean
start the relay container on that network; report relay-started
isolate:
holder := run warden-holder # does nothing; owns the network
--network <build net> --cap-drop ALL --read-only
run --privileged warden-netns # joins the holder's namespace,
--network container:<holder> # applies iptables, exits:
# 80/443/53 -> relay, all else DROP
deliver:
build := create <your FROM image> # created, NOT started
--network container:<holder> # inside the isolated namespace
--user 0
--entrypoint /.warden/warden-io initialize --gateway=<relay> --workdir=/work
cp - build:/ < tar{ /.warden/warden-io, mode 0755 }
start:
start build # warden-io initialize runs as PID 1
watch:
<runtime> container wait warden-build-<id> # by name, a child of the driver
wait for the session's completion, or the container exiting without one
clean keeps a build whose lock is held, or whose waiter, <runtime> container wait warden-build-<id> in one ps -A -ww -o pid=,ppid=,args= listing, runs
under a live warden-driver-container. A waiter whose driver was killed is
orphaned and keeps nothing; no other process that names the build counts. With
no ps (Windows), only the locks keep a build.
The image's own ENTRYPOINT never runs, and nothing from the image exists
until the network is already isolated. The holder and sidecar images are
published with each release and run by digest.
warden shell does the same with initialize --hold, starts the same waiter,
whose exit it does not report, and opens a shell in the held environment once
setup is done; the session ends when warden stops it.
VM drivers (driver/qemu, driver/hyperv, driver/vz, driver/firecracker)
before anything boots:
vz base image: --image, else the image cache's active image (the one
`image prepare` made active last; with no pointer, the newest prepared)
refuse a build link that holds a host interface address
check the launcher's link-channel stamp: the qemu or firecracker direct-boot
initramfs, the hyperv relay boot VHDX, the vz prepared image; missing or old
-> a fix naming its one-time rebuild (vz: the active image -> `image
prepare` with no source; another cache image -> `image prepare <dir>`, or
omit --image; an --image disk outside the image cache, which cannot be
re-prepared in place -> omit --image)
the relay's resolvers (driver/resolvers), before any VM:
[vm] dns set -> Check: every entry passes the driver's rule, in order,
used exclusively; the first that fails refuses the build
unset -> Select(the host's list, the driver's rule): the ones that
pass, in order; none -> a fix naming each excluded server,
an off-host DNS server and [vm] dns
req.DNS := that list; the claim carries it as upstream_dns
driver host source excluded
hyperv the IPv4 DNS servers of the loopback, link-local, host
lowest-metric default route's addresses, the NAT prefix,
interface the build link
firecracker /etc/resolv.conf, or resolved's loopback, link-local, host
upstreams behind its stub addresses, the build link
qemu /etc/resolv.conf (macOS or loopback, link-local,
Linux) 10.0.2.0/24, the build link
vz the Mac's /etc/resolv.conf the build link
start the relay VM (or, on VZ, a host relay process); claim it with the build
link and the resolvers
firecracker: first take a free network slot made by `warden setup` (a host
lock), kill VMMs a dead warden left on it, and claim the relay
at the slot's upstream address
hyperv setup: refuse a --nat-prefix that overlaps the build link; make or
adopt <network>-nat on --nat-prefix, refusing another NAT that
owns the prefix or <network>-nat on another (making it leaves
--host-ip the only IPv4 address on vEthernet (<network>-nat));
make the
durable strategy's slot switches <network>-0..N-1 (--slots,
default 4), trim unattached extras, retire an unattached old
<network> switch
hyperv build (Run):
hold the host lock "hyperv-build-<id>" from the build ID's creation
to Run's return
the network strategy: elevated -> a per-build network; else the
privileged service at this protocol -> a per-build network through
it; a service at another protocol (or failing its ping) -> a fix
naming its reinstall, never the durable network; else durable
(doctor reads the service manager when the pipe does not open:
installed but stopped -> Start-Service WardenHyperV, never
"not installed"; a read refused or failed -> "state could not
be read", naming Get-Service WardenHyperV; only "does not exist"
is not installed)
the relay boot VHDX's stamp must be 2, else a fix naming refresh-cache.sh
the NAT read back from the host: name, prefix, host IP (two host
addresses in the prefix -> refused as ambiguous)
durable: <network>-nat and its slot switches; none -> warden setup
ephemeral: a per-build Private switch; the dev switch's NAT if
present, else the one owning the default prefix, else new
a NAT prefix that overlaps the build link -> a fix naming that NAT
(config load checks no Hyper-V range; this is the one check),
run first on the NAT read back before the seed ISO and any
standup (none yet -> the default prefix, named), then on the NAT
the build took
the resolvers, as above; token := a fresh random claim token
under a host lock ("hyperv-network"):
relay address := the lowest free host in the NAT prefix (not the
network, broadcast or host IP, nor any warden-relay-*
VM's Notes); none free -> a fix naming the holders
durable: the lowest slot switch with no VM adapter attached;
none -> a fix naming the holders and --slots
seed ISO (WARDENRELAY) := warden-relay.conf with warden.seed=1,
warden.net=static, warden.nat_ip, warden.nat_prefix,
warden.nat_gw, warden.claim_token (pre-claim values only)
create the relay VM, off: the seed DVD, the build NIC on the slot,
Notes "warden-relay-ip=<ip> warden-relay-switch=<switch>"
start the relay VM; claim it at <relay address>:8301 with the token
(Bearer on the claim and the tunnel)
every seed ISO (the build's, the relay's, a prepare's) is made under
a host lock ("hyperv-iso"), held only around IMAPI2
the build VM joins the relay's switch; before it starts, the slot's
adapters must be exactly the relay's build NIC and the build VM's,
else refuse; removing the relay VM frees its address and slot
hyperv clean (`warden clean --driver hyperv`): for each 8-character build
ID among warden-build-*, warden-relay-* VMs and warden-hyperv-* work
dirs whose "hyperv-build-<id>" lock it gets (not running): remove its
VMs, then its ephemeral warden-<id> switch, then its work dirs; the
NAT, the slot switches (<network>-<i>) and prepare VMs stay, so this
frees a slot a --keep-vms build or a killed warden held
hyperv host locks (driver.HostLock / TryHostLock, all "hyperv-<what>"):
"hyperv-build-<id>" one build's whole run; clean skips a held one
"hyperv-network" relay address and slot, through the relay VM's
creation
"hyperv-iso" IMAPI2 seed ISO creation
"hyperv-prepare" image prepare; a build tries it to see whether a
background refresh is already running; a
refresh that does not start is reported, the
build goes on
hyperv PowerShell (runPS): a failed script's error is its stderr, else
the exit status with the last 10 lines of stdout (psError); every
script that changes the host (setup's slots, EnsureNetwork,
TeardownNetwork, CreateVM, CreateRelayVM, RemoveVM, CreateDiffDisk,
the seed ISO) prints DONE last and runs through runPSDone, which
refuses output without it, naming that tail (psDoneCheck), since
powershell -Command exits with the success of the last statement,
which a suppressed lookup that finds nothing fails
the build VM boots only after the claim returns
isolate: the build VM's only network interface leads to the relay
(QEMU socket pair, Hyper-V private switch, VZ socketpair,
Firecracker: a TAP on the slot's host bridge, whose only other
port is the relay and which drops every frame bound for the host)
deliver: Linux guest -> cloud-init CIDATA disk carrying warden-io
(Firecracker: a read-only drive beside a per-build
raw rootfs copy, or, with no image, warden-io
appended to a launcher-only initramfs)
Windows guest -> WARDEN seed disk carrying warden-io.exe and warden-run.ps1
macOS (VZ) -> warden-io baked into the prepared image (a known deviation)
address: the guest takes the build link per build, nothing baked:
Linux seeded guests (cloud-init network-config)
-> rendered from the link
Windows -> the relay's DHCP lease alone: warden-run.ps1 runs
initialize --gateway=<relay> with no --ip; no lease ->
the relay wait fails naming the NIC's address and origin
direct boot (qemu, firecracker) -> udhcpc takes the relay's lease;
it must agree with warden.link_ip / warden.link_gw on the
kernel command line (else stop); no lease -> the keys;
neither -> stop
macOS (VZ) -> warden-boot takes the host relay's DHCP lease
start: boot the VM. Its launcher runs warden-io initialize:
Linux -> cloud-init runcmd (Firecracker: ending in reboot -f), or
the direct-boot launcher's exec of initialize
Windows -> the warden-run startup task in the prepared image
macOS -> a launchd daemon
watch: wait for the session's completion
firecracker: the build VM's process exiting allows a 10 s grace for
the completion; the relay VM's exiting fails at once
warden-io initialize (cmd/warden-io)
The only program the host puts in the build environment. It sets the environment up from the relay, then runs your build.
initialize --gateway=<relay> [--ip=<static>] [--workdir=<dir>] [--hold]:
point DNS (and on VMs, the address and route) at the relay
wait for GET http://<relay>:8300/health
ca := GET http://artifacts/ca.pem
cfg := GET http://artifacts/bootstrap # 404 => empty config
reject cfg if it has an unknown version, field or value
install the CA as a system root:
exclusive (Linux default) -> the warden CA becomes the ONLY root, and a
ca-certificates update hook keeps it so
append -> add it to the existing roots
baseline, always (derived from the CA alone):
/etc/warden/certs.jks Java truststore (JKS, matches keytool)
/etc/bazel.bazelrc points Bazel's JVM at it
MAVEN_OPTS, GRADLE_OPTS point Maven and Gradle at it
SSL_CERT_FILE, REQUESTS_CA_BUNDLE, NODE_EXTRA_CA_CERTS, PIP_CERT,
CURL_CA_BUNDLE, CARGO_HTTP_CAINFO, NIX_SSL_CERT_FILE, HEX_CACERTS_PATH
the system CA bundle
UV_NATIVE_TLS=1, SOURCE_DATE_EPOCH=0
mkdir and cd into the workdir
if --hold: write the environment to /etc/warden/shell.env and wait forever
script := GET http://artifacts/build-script
run script, with warden-io on PATH:
stdout/stderr -> your console, and POST :8300/v1/output in chunks
every 2s -> GET http://artifacts/heartbeat
POST http://artifacts/exit?code=<script's exit code>
exit with that code
Your script's own ENV lines override any baseline variable. The other
subcommands are what the script calls: warden-io fetch <path> -o <dest> (a
context file from http://cwd/<path>) and warden-io post <file> (an artifact
to http://artifacts/<name>).
Relay (relay/, cmd/relay)
relay --mode=container|vm|host:
bind DNS (:53), HTTP (:80), HTTPS (:443), control plane (:8300)
accept ONE claim on :8301:
open the tunnel; take the config; invalid build_link -> 400, still
claimable
configure the build segment (the mode's start step):
vm: build_link -> refuse (400, still claimable) if another
interface holds an address or route in it;
flush the build interface's IPv4, add
relay/len (netlink); serve DHCP bound to
that interface: one fixed lease (guest,
mask, relay as router and DNS, infinite)
none -> keep the interface's address; none there ->
400 "build_link is required"
host: netstack, ARP, DHCP and listeners from build_link, else
--subnet
container: build_link -> 400
resolvers (every mode), fixed for the build:
upstream_dns in the claim -> checked (non-empty IPv4, not
unspecified, multicast or broadcast, not in build_link; else
400, still claimable) and used exclusively
absent -> the usable nameservers of its own /etc/resolv.conf (not
its own address, 127.0.0.1 or the build link); none -> 400
naming upstream_dns
log "upstream resolvers: <list> (claim | resolv.conf)"
generate the per-build MITM CA and the ledger key; return both; sign the environment record as the first ledger
record; POST /v1/ready to the collector
stop listening for claims
for each guest request:
DNS: artifacts, cwd -> the relay itself; anything else -> the resolvers,
asked in order (the next when one does not answer), recorded
http://artifacts/
/ca.pem, /bootstrap, /build-script -> serve (pulled from the collector;
bootstrap and script recorded)
/ca.crl -> the CA's empty CRL, which every leaf names (not recorded)
/heartbeat -> forward to the collector
/exit -> flush the ledger, POST /v1/complete
POST /<name> -> stream the artifact to the collector, recorded
http://cwd/<path> -> the context file from the collector, recorded
anything else -> proxy upstream (HTTPS through the MITM CA), recorded;
captures streamed to the collector; a dial into the
build link is refused (vm and host), as are host mode's
SSRF blocks; its own lookups (upstream dials, a collector
host name) go through the same in-order forwarder
the ledger is streamed to the collector as it is written, so even a relay
that dies mid-build leaves a verifiable (truncated) ledger
Relay VM init (tools/relay-vm/init)
The init of every vm-mode relay VM (qemu, Hyper-V, Firecracker). It carries only the relay's pre-claim values; the build link and the resolvers come in the claim.
read_keys(words): # one reader for both sources; never evaluated
warden.net=dhcp|static, warden.nat_ip=<quad>, warden.nat_prefix=1..30,
warden.nat_gw=<quad>, warden.claim_token=<64 hex>, warden.seed=1
a malformed value, or warden.dns (retired for upstream_dns) -> stop
qemu, Firecracker: read_keys(/proc/cmdline)
Hyper-V: the seed alone: any warden.* word on /proc/cmdline -> stop, naming it
load the storage, CD-ROM and ISO 9660 modules; wait <= 10 s for the
WARDENRELAY CD; copy warden-relay.conf; unmount; read_keys(it)
no CD, no file or no warden.seed=1 -> stop
bring the build link's interface up (the relay addresses it from the claim)
upstream: static -> nat_ip/nat_prefix via nat_gw, all three required, else stop
dhcp -> udhcpc (its script writes the lease's resolv.conf); no
lease -> stop
iptables: redirect 80/443/53 from the build link; masquerade upstream; drop
forwarding
resolv.conf: not written by the init itself
WARDEN_CLAIM_TOKEN=<token> relay --mode=vm --build-if=<build link interface>
stop: a console line (COM1 on Hyper-V), no relay; the claim times out
Namespace holder (cmd/warden-pause)
warden-pause:
wait for SIGTERM or SIGINT
exit 0
It runs before the container driver's network is isolated, so it has no network code, no shell, and no capabilities.
Architecture
BuildWarden executes builds inside isolated environments while recording a tamper-evident ledger of all network activity. Five drivers implement the same lifecycle on different platforms:
| Driver | Flag | Platform | Isolation mechanism |
|---|---|---|---|
| Container | --driver container (default) | Any Docker/Podman host | iptables sidecar |
| QEMU | --driver qemu | macOS, Linux, Windows | Topological (separate VM) |
| VZ | --driver vz | macOS/arm64 only | Topological (socketpair, no vmnet) |
| Hyper-V | --driver hyperv | Windows | Topological (separate VM, host-only NAT) |
| Firecracker | --driver firecracker | x86_64 Linux with KVM | Topological (microVM on a per-slot host bridge) |
All four share a single runtime model: warden (the orchestrator) boots an
unconfigured relay, claims it with the build's configuration, then boots the
build guest.
relay boots unconfigured --> warden claims it (tunnel + config) --> build guest boots --> warden-io initialize --> fetch build script --> run with heartbeats --> report exit
The relay keeps no build state on disk and mounts nothing. It streams every
output (artifacts, captures, the ledger, build console) to, and pulls every
input (the build script, the bootstrap config, context files) from, a collector that warden
runs on the host. The relay never dials the host and warden never listens on
any network: the collector is served to the relay over a tunnel warden opens
on the relay's claim port.
Every driver bootstraps the build environment the same way: isolate it, deliver
the executor, start it, and let warden-io initialize pull everything else from
the relay. The model, its invariants and the one remaining deviation are in
docs/development/bootstrap.md;
How It Works walks through each component as pseudocode.
High-level topology
Container driver
~~~~~~~~~~~~~~~~
+-----------+ isolated Docker network (100.64.x.0/29) +-----------------+
| Relay |<-------- only allowed connection -------------->| Build Container |
| container | | (FROM image) |
+-----+-----+ +-----------------+
| in the holder's
v external netns, isolated
before it starts
[ Internet ]
QEMU driver
~~~~~~~~~~~
+------------+ Unix socket pair +------------+
| Relay VM |<------------------------>| Build VM |
| (Alpine) | sole network path | (cloud img)|
+-----+------+ +------------+
|
v external
[ Internet ]
VZ driver
~~~~~~~~~
+------------------+ socketpair (raw Ethernet) +-------------+
| Relay (host proc)|<--------------------------------->| macOS VM |
| gvisor netstack | sole network path | (IPSW img) |
+--------+---------+ +-------------+
|
v external
[ Internet ]
Hyper-V driver
~~~~~~~~~~~~~~
+------------+ Private build switch +-------------+
| Relay VM |<---------------------------->| Build VM |
| (Alpine) | sole network path | (Windows) |
+-----+------+ +-------------+
| Internal NAT switch
v external
[ Internet ]
In every case the build environment has exactly one network path: through the relay. The relay proxies allowed traffic to the internet and records it in the ledger.
Components
Orchestrator (cmd/warden/)
Runs on the host. Responsibilities:
- Resolve the build script (translate a Dockerfile on the host, or stage build.sh / build.ps1)
- Start a collector that serves the build script, the bootstrap config and the context, and receives all outputs
- Prepare and start the relay, unconfigured (build container image, cross-compile binary, or launch host process / boot relay VM)
- Claim the relay: open the collector tunnel, push the build config, receive the relay identity (MITM CA cert + ledger public key)
- Isolate the build environment (holder + iptables sidecar, or topological)
- Deliver
warden-iointo it and start it; from then on, only watch - Wait for build completion (heartbeats, exit code) or failure (hung guest, dropped tunnel)
- Finalize output (optional zstd compression)
- Teardown
The host-side build logic (driver.Session) is shared by every driver;
drivers differ only in how they start the relay and the build guest, and in
the claim address they hand the session.
Collector (collector/ library, cmd/collector/ binary)
The protocol between the relay and the collector is specified in two documents, the outputs a collector stores and the inputs and signals it serves; the specifications are the contract, and the seams page links them at the version this repository implements. This section explains it.
The collector is the relay's single output path and the source of its build inputs, so the relay needs no shared filesystem. The relay authenticates every request with a bearer token. Its endpoints, what each takes and what each answers, are listed in the two specifications.
The ledger is streamed throughout the build, so even a relay that dies mid-build
leaves a truncated-but-verifiable ledger. cmd/collector is the standalone host
side for third-party orchestrators: it claims an already-running relay, serves
inputs, lands outputs, and exits with the build result.
Claim protocol (relaycfg/)
The claim is specified in its own document; the specification is the contract, and the seams page links it at the version this repository implements. This section explains it.
A relay boots unconfigured and listens for a single claim on port 8301. The orchestrator:
- Opens a tunnel (
POST /v1/tunnelon the claim port, upgraded to a raw connection) and serves the collector to the relay over it as HTTP/2. - Pushes the build config (
POST /v1/claim): collector URL (the tunnel), collector bearer token, capture mode, upstream CA PEMs, system-CA flag, and an optional environment record: a typed descriptor of what the build runs on (the container image manifest, or for VM drivers avm-disk-chain/v1descriptor of the boot disks and per-build seed files; see the ledger spec's Environment Record). The relay signs it as the ledger's first record and lands the payload as<output>/environment.json. The VM drivers also send the build link (below). - Receives the relay identity: the ephemeral MITM CA certificate (written to
<output>/ca.cert.pem) and the ledger's Ed25519 public key.
The claim listener closes after one claim, before the build guest boots.
Pushing the config (rather than having the relay fetch it) keeps the relay
ignorant of host topology: any setup where the host can reach the claim port
works, with no host listener or firewall rule, relays can be started warm and
claimed later, and concurrent relays never race for a fixed config endpoint. An
optional per-instance claim token (WARDEN_CLAIM_TOKEN) stops another local
process from claiming a warm relay first.
The build link. A claim may carry build_link, the private segment
between the relay and the build environment:
"build_link": {"prefix": "100.127.255.252/30",
"relay": "100.127.255.253",
"guest": "100.127.255.254"}
How a relay validates build_link, and what each mode does with it or
without it, are the claim specification's requirements, linked from the
seams page. warden itself is stricter than a relay
requires: it sends only a /30 link, disjoint from its own ranges.
A relay refuses a claim it cannot apply (a link another interface already
uses, a field its mode does not take) with 400 and stays claimable: its start
step returns an error wrapping relaycfg.ErrRefused. A relay that predates
the field refuses a claim carrying it (unknown field "build_link"), which
warden turns into a fix naming the driver's rebuild.
Ordering rule. A relay replies to a claim only after its build segment is configured: the reply is written after the mode's start step returns, and the step addresses the segment and starts its DHCP responder. Every VM driver boots the build guest only after the claim returns.
Relay (relay/ library, cmd/relay/ binary)
The relay is the network gateway for the build environment. Core services:
- MITM HTTPS proxy — intercepts TLS using an ephemeral CA
- DNS server — resolves
cwdandartifactsto itself, forwards all else to its upstream resolvers in order: the claim'supstream_dns(every VM driver sends[vm] dnsor the host's), else the relay's ownresolv.conf - Build-input serving — serves the build script and context to the guest, pulling them from the collector
- Artifact store — accepts uploads via
http://artifacts/<name>, streamed to the collector - Ledger writer — records requests with chained Ed25519 signatures, streamed to the collector
- Control plane — health check, CA distribution, heartbeat, exit reporting
- Fairness scheduler — prevents single-origin starvation of concurrent requests
cmd/relay/ is a thin main that selects a mode:
| Mode | Flag | Used by | Behavior |
|---|---|---|---|
| container | --mode=container | Container driver | Binds ports directly on container interface |
| vm | --mode=vm [-build-if NAME] | QEMU, Firecracker, Hyper-V drivers | Binds ports directly inside the relay VM; addresses the build interface from the claim and serves the build VM's DHCP lease on it |
| host | --mode=host --fd=N | VZ driver | Reads raw Ethernet from FD via gvisor netstack, built from the claim's build link (--subnet without one); SSRF filtering active |
warden-io (cmd/warden-io/)
The sole agent inside the build environment. Subcommands:
initialize— configure DNS, wait for relay, install the CA per the bootstrap config, apply the baseline (Java truststore, bazelrc, CA and default env), fetch the build script, run it, report exitfetch— download a file from the relay context endpointpost— upload an artifact to the relaytrust— install the ephemeral CA into system trust stores
Platform-specific initialization handles network configuration differences between Linux (containers, VMs) and macOS (VZ).
Ledger (ledger/)
Binary format with chained Ed25519-SHA512 signatures. Magic BLDL, version
0x01. CBOR metadata. Record types: open, checkpoint, close, artifact. The
library provides write (single-writer via channel), read, and verification.
Driver interface (driver/)
Each driver implements a common interface covering:
- Environment preparation (image pull, VM boot)
- Relay startup (mode-specific)
- Build environment startup
- Network isolation application
- Teardown
Driver details
Container driver
warden build .
|-- Translate the Dockerfile to build.sh (COPY expanded against the context)
|-- Start a collector serving the build script, bootstrap config + context
|-- Create isolated Docker network (100.64.x.0/29); check it against the runtime's
| networks and take the next /29 if another network overlaps it
|-- Start relay container, unconfigured, with its claim port published on 127.0.0.1
|-- Claim the relay (tunnel + build config); write ca.cert.pem
|-- Start the namespace holder on the network (no capabilities)
|-- Run the iptables sidecar in the holder's netns (applies rules, exits)
|-- Create the build container from the FROM image in the holder's netns,
| entrypoint warden-io initialize --gateway=<relay_ip> (not started)
|-- Copy warden-io in (tar stream, mode 0755)
|-- Start it: warden-io initialize runs as PID 1
|-- Wait for the completion report (or the container exiting without one)
'-- Teardown containers + network
Network isolation: the build's network namespace belongs to a holder container
that runs nothing. A privileged one-shot sidecar applies iptables rules to it
that allow traffic only to the relay IP, then exits, all before the build
container exists. The build container has no CAP_NET_ADMIN.
QEMU driver
warden build .
|-- Cross-compile relay + warden-io for linux
|-- Start a collector serving the build script + context
|-- Prepare relay VM (Alpine direct-boot; the current relay binary is appended to the prebuilt initramfs as a second cpio at /sbin/relay)
|-- Prepare build VM (cloud image QCOW2 + cloud-init seed ISO with warden-io)
|-- Boot relay VM, unconfigured, with its claim port forwarded to a free 127.0.0.1 port (user-net hostfwd)
|-- Claim the relay (tunnel + build config); write ca.cert.pem
|-- Boot build VM (sole network path is the relay VM)
|-- warden-io initialize runs via cloud-init
|-- Wait for exit
'-- Teardown VMs
The prebuilt initramfs (tools/relay-vm/build-initramfs.sh) only needs
rebuilding when the init script or the base image changes; the relay binary is
appended fresh each build.
Network isolation is topological: the build VM's only NIC connects to the socket pair whose other end is the relay VM. No host networking, no bridge. Accelerator selection: HVF (macOS), KVM (Linux), WHPX (Windows), TCG (fallback).
VZ driver
warden build .
|-- Prepare macOS disk image (warden image prepare: personalize, inject warden-io)
|-- Start a collector serving the build script + context
|-- Start relay as host process on 127.0.0.1:<free port>, unconfigured
| '-- gvisor netstack processes raw Ethernet frames from socketpair
|-- Claim the relay (tunnel + build config); write ca.cert.pem
|-- Boot macOS VM via Virtualization.framework
| '-- Single NIC: VZFileHandleNetworkDeviceAttachment on socketpair
|-- warden-io initialize runs on first boot (system daemon)
|-- Wait for exit
'-- Teardown VM + relay process
Network isolation is topological: the VM has one network interface backed by a socketpair. The other end is the relay process using gvisor netstack to parse Ethernet frames in userspace. No vmnet, no iptables.
Image preparation (warden image prepare --driver vz) is a separate step:
- Restore IPSW to disk image
- Personalize with Apple signing server
- Install warden-io binary and system daemon plist
- Result is a reusable prepared image
Hyper-V driver
warden build --driver hyperv .
|-- Preflight: the relay boot VHDX's stamp, the NAT read back from the host
| (prefix, host IP; one overlapping the build link refused), the relay's
| resolvers ([vm] dns, or the host's default route interface's)
|-- Start a collector serving the build script + context
|-- Under a host lock: allocate the relay's NAT address (and, durable, a free
| slot switch); write its seed ISO (address, prefix, gateway, claim token)
|-- Boot relay VM (its /sbin/relay is baked into a UKI boot disk), unconfigured
| '-- Reachable on its per-build NAT address, port 8301, with the token
|-- Claim the relay (tunnel + build config + resolvers); write ca.cert.pem
|-- Boot build VM on the relay's switch (sole network path is the relay VM)
|-- warden-io initialize runs on first boot, on the relay's DHCP lease
|-- Wait for exit
'-- Teardown VMs
Network isolation is topological, like QEMU. The relay VM and build VM sit on
a Private build switch; the relay reaches upstream through an Internal NAT
switch. The claim endpoint is only on the host-only NAT switch, so the build
VM cannot reach it, and it takes only the per-build token. One-time host
setup (warden setup --driver hyperv) creates the durable NAT switch and its
slot switches (--slots, default 4), so durable builds run concurrently, one
per slot; the relay VM's /sbin/relay is baked into its UKI boot disk by
tools/relay-vm/hyperv/build.sh, and its per-build values arrive on a
WARDENRELAY seed ISO (see tools/relay-vm/README.md).
Firecracker driver
warden build --driver firecracker .
|-- Preflight: /dev/kvm, firecracker >= v1.17.0, boot assets, a slot, an off-host resolver
|-- Stage the build script; record inputs
|-- Prepare build VM: raw rootfs (converted once, reflink-copied per build) + CIDATA
| seed on a read-only drive, or the direct-boot initramfs with warden-io appended
|-- Start a collector serving the build script + context
|-- Take a free network slot (host lock); kill VMMs a dead warden left on it
|-- Boot relay VM (firecracker --no-api; relay appended to the x86_64 initramfs),
| unconfigured, on the slot's bridge and upstream TAP
|-- Claim the relay at the slot's upstream address, port 8301; write ca.cert.pem
|-- Boot build VM (its only NIC on the slot's bridge)
|-- warden-io initialize runs via cloud-init, or the direct-boot launcher
|-- Wait for exit (a completion may land up to 10 s after the build VM exits)
'-- Teardown VMs, the rootfs copy and the slot's pid file; release the slot
Network isolation is topological, like QEMU, but the link is a host bridge per
slot whose only other port is the relay; the bridge has no address, and a
bridge-family nft table and the WARDEN-FC iptables chains keep build
segments, other slots and other local users apart (see
Network Isolation). sudo warden setup --driver firecracker makes the slots once per boot, so builds run unprivileged.
Lifecycle (common)
warden build .
|-- Resolve the build script (translate Dockerfile, or stage build.sh / build.ps1)
|-- Start a collector serving the build script + context
|-- Start relay (unconfigured)
|-- Claim the relay (open tunnel, push config, receive CA + ledger key)
|-- Isolate the build environment
|-- Deliver warden-io and start the environment
|-- warden-io initialize:
| |-- Configure network (point DNS at relay)
| |-- Wait for relay health check (http://<relay>:8300/health)
| |-- Fetch the CA and the bootstrap config; install the CA
| |-- Apply the baseline (Java truststore, bazelrc, CA and default env)
| |-- Fetch the build script (http://artifacts/build-script)
| |-- Run build script with periodic heartbeats
| '-- Report exit code to the relay control plane
|-- Outputs (ledger, artifacts, console) stream to the collector throughout
'-- Teardown
Communication paths
The build environment talks only to the relay. The endpoints it sees, the relay's guest API, are specified in their own document, linked from the seams page.
The relay's control plane binds :8300; artifacts and cwd are reserved
hostnames that resolve to the relay. The relay in turn serves build inputs
from, and streams outputs to, the host collector over the /v1/* API (a
separate plane the build environment never sees).
External HTTPS traffic is transparently proxied (MITM) and recorded in the ledger. External HTTP traffic is proxied and recorded without interception.
Network isolation
See Network Isolation for iptables rule details (container driver). For the QEMU, VZ, and Hyper-V drivers, isolation is topological: the build environment physically cannot reach anything except the relay.
The Ledger
The ledger is a binary file containing a cryptographic record of everything that happened during a build.
Properties
- Tamper-evident — Each record signs over the previous record's signature, forming a chain. Altering any record invalidates all subsequent signatures.
- Append-only — Records can only be added, never modified or reordered.
- Self-describing — The header contains the signature scheme, hash algorithms, and the public key needed for verification.
- Redactable metadata — CBOR-encoded metadata is not part of signatures and can be stripped without affecting integrity.
Structure
┌────────────────────────────────────┐
│ Magic bytes: BLDL │
│ Version: 0x01 │
│ Header (signed, contains pubkey) │
├────────────────────────────────────┤
│ Record 1: OPEN (request start) │
│ Record 2: CHECKPOINT (headers) │
│ Record 3: CLOSE (response body) │
│ Record 4: OPEN ... │
│ ... │
│ Record N: ARTIFACT (build output) │
└────────────────────────────────────┘
Record Types
| Type | Byte | Meaning |
|---|---|---|
| Open | 0x01 | Start of a request lifecycle (HTTP open) |
| Checkpoint | 0x02 | Intermediate data (headers, partial body) |
| Close | 0x03 | End of a request lifecycle (response complete) |
| Artifact | 0x04 | Build output posted to the ledger |
Hash Block
Every record includes a hash block with multiple algorithms computed over the payload:
- blake2b_256 (32 bytes)
- sha256 (32 bytes)
- sha1 (20 bytes)
- md5 (16 bytes)
This multi-hash approach ensures compatibility with various verification systems and provides defense-in-depth against hash collisions.
Signature Chain
Header.sig = Ed25519(SHA512(header_prefix))
Record[0].sig = Ed25519(SHA512(Header.sig || Record[0].body))
Record[1].sig = Ed25519(SHA512(Record[0].sig || Record[1].body))
...
Breaking any link in the chain invalidates all subsequent records, making tampering detectable.
Compression
By default, the ledger is compressed with zstd when written to the output directory. warden inspect handles both compressed (.zst) and uncompressed ledgers transparently.
Full Specification
See the Ledger Specification for the complete binary format, and the Specifications index for each metadata schema.
COPY Provenance
Docker COPY directives introduce build inputs that traditionally bypass network auditing — files go directly from the host into the image layer. BuildWarden rewrites these directives so that every source file flows through the relay and gets recorded in the ledger.
How It Works
- The orchestrator mounts the build context into the relay container (read-only)
- The relay serves these files at
http://cwd/<path> COPYdirectives in the Dockerfile are rewritten toRUN warden-io fetchcommands that fetch each file from the relay- Each file transfer creates a ledger entry with full hash verification
Example Transformation
Original Dockerfile:
COPY requirements.txt /app/
COPY src/ /app/src/
What actually runs:
RUN mkdir -p /app/ && warden-io fetch requirements.txt -o /app/requirements.txt
RUN mkdir -p /app/src/ && \
printf '%s\n' 'src/main.py' 'src/lib.py' 'src/utils.py' | \
xargs -P8 -I{} sh -c 'mkdir -p "/app/src/$(dirname "{}")" && warden-io fetch "{}" -o "/app/src/{}"'
What Gets Excluded
.git/— not part of the build context- Files matching
.dockerignorepatterns
BuildWarden's own staging (/.warden in the build container) lives in a
per-build temp directory, never in the context.
Concurrency
For directories with many files, downloads run with xargs -P8 (8 parallel fetches). Since transfers are over localhost to the relay, this adds negligible overhead.
Large Contexts and Tarballs
If your build context has thousands of files and you don't need per-file provenance, create a tarball first:
# In your build script, before warden build:
tar czf context.tar.gz src/
# In Dockerfile:
COPY context.tar.gz /tmp/
RUN tar xzf /tmp/context.tar.gz -C /app && rm /tmp/context.tar.gz
This produces a single ledger entry for the tarball rather than thousands of individual file entries.
Multi-stage Builds
COPY --from=<stage> directives (copies between build stages) are left unchanged — they don't reference the build context and don't need provenance tracking.
Supported Flags
| Flag | Handling |
|---|---|
--chown=user:group | Appended as && chown -R user:group <dest> |
--chmod=755 | Appended as && chmod -R 755 <dest> |
--from=stage | Left as-is (multi-stage copy) |
In the Ledger
Source file entries appear as:
✅ CONTEXT GET /src/main.py (1523 bytes)
✅ CONTEXT GET /src/lib.py (4201 bytes)
✅ CONTEXT GET /requirements.txt (42 bytes)
Each with full blake2b_256, sha256, sha1, and md5 hashes in the hash block.
Network Isolation
BuildWarden enforces strict network isolation on the build environment so that every byte entering or leaving passes through the relay and is recorded in the ledger. The mechanism differs per driver, but the guarantee is identical.
The Trust Boundary
All drivers enforce the same invariant: every byte entering or leaving the build environment passes through the relay and is recorded in the ledger.
The relay is the single point of network egress. It terminates TLS (via an injected CA), logs DNS queries, and writes network events to the signed ledger. Whether the build environment is a container or a virtual machine, isolation ensures no traffic can bypass this path.
Container Driver — iptables Isolation
The build's network namespace is isolated before the build container exists, in the Kubernetes pod pattern:
- A namespace holder (
warden-holder, a single static binary that does nothing) starts on the per-build bridge network and owns the namespace. It runs with no capabilities, a read-only root and no shell. - A privileged sidecar (
warden-netns) joins the holder's namespace, applies the iptables rules below, and exits. - The build container is created from your
FROMimage inside that namespace (--network container:<holder>), withwarden-io initializeas its entrypoint, and only then started.
Nothing from your image runs before the rules are in place, including the
image's own ENTRYPOINT, which is replaced. The build container has no
CAP_NET_ADMIN and cannot modify the rules. Release builds run the holder and
sidecar images by digest, so a different image carrying the same name is never
run privileged.
The relay IP is on the same bridge network as the holder.
NAT rules (DNAT)
All outgoing HTTP, HTTPS, and DNS traffic is redirected to the relay:
iptables -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to-destination <relay>:53
iptables -t nat -A OUTPUT -p tcp --dport 53 -j DNAT --to-destination <relay>:53
iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination <relay>:80
iptables -t nat -A OUTPUT -p tcp --dport 443 -j DNAT --to-destination <relay>:443
Filter rules (DROP)
After DNAT, only relay and loopback traffic is permitted:
iptables -A OUTPUT -d <relay> -j ACCEPT
iptables -A OUTPUT -d 127.0.0.0/8 -j ACCEPT
iptables -A OUTPUT -j DROP
Why the build container cannot escape
- Isolation precedes execution — no code from the image runs on an open network
- No
CAP_NET_ADMIN— cannot flush or modify iptables rules - No route to any host other than relay and loopback
- The sidecar exits after applying rules — no persistent privileged process
- The holder runs no code that could use the namespace before it is isolated
QEMU Driver — Topological Isolation
Two VMs are connected by a Unix domain socket pair (QEMU -netdev stream).
There is physically no network path from the build VM to the internet that does
not pass through the relay VM.
Network topology
- Relay VM has two interfaces:
eth0: socket to the build VMeth1: user-net (QEMU SLIRP) to the internet
- Build VM has ONE interface: the socket to the relay VM
No iptables are needed on the build VM — there is no other path. The hypervisor enforces the topology; the build VM cannot create new interfaces.
Relay VM iptables
The relay VM uses iptables to ensure build traffic is processed by the relay process before reaching the internet:
PREROUTING: redirects inbound build traffic to the local relay processFORWARD DROP: prevents any unproxied egress from the build VMPOSTROUTING MASQUERADE: NAT for the relay's own upstream connectionsINPUT: the build VM may reach the relay control plane (:8300) but is dropped from the claim port (:8301), so it cannot claim or re-claim the relay
VZ Driver — Topological Isolation
The macOS build VM has a single VZFileHandleNetworkDeviceAttachment backed by
a socketpair. There is no vmnet.framework, no bridging — the socketpair IS the
entire network.
How it works
- The relay runs on the host and reads raw Ethernet frames from its end of the socketpair via gvisor netstack
- The VM sees one network interface connected to the relay — nothing else
- SSRF filtering is active in host-mode relay (blocks connections to loopback/link-local/metadata IPs)
- The VM cannot create additional network interfaces (Virtualization.framework constraint)
Why this is stronger than iptables
There is no software firewall to misconfigure or bypass. The isolation is structural: the only network device the VM possesses connects exclusively to the relay process. No amount of privilege inside the VM can change this.
Hyper-V Driver — Topological Isolation
Like QEMU, the Hyper-V driver uses two VMs and the hypervisor enforces the
topology. The relay VM and build VM share a Private build switch (one per
build: a slot switch warden setup --driver hyperv made for the durable
strategy, or a per-build switch); the relay reaches upstream through an
Internal NAT switch. Each relay takes its own address in the NAT prefix, read
back from the host and allocated per build under a host lock, and gets it,
with the gateway and a fresh claim token, from a per-build WARDENRELAY seed
ISO. The build VM has one interface, on the relay's Private switch, so its
only path is the relay; before it starts, the driver refuses a slot that holds
any adapter but the relay's build NIC and its own.
The same relay-VM iptables rules apply (the init script is shared with QEMU):
PREROUTING redirect, FORWARD DROP, POSTROUTING MASQUERADE, and an INPUT
rule that lets the build VM reach the control plane but drops it from the claim
port. The claim endpoint lives only on the host-only NAT switch, so the build
VM cannot reach it even before iptables, and it accepts only the build's
token.
Firecracker Driver — Topological Isolation
The Firecracker driver uses the same two VMs and the same relay init as QEMU,
but the link between them is on the host: a network slot that sudo warden setup --driver firecracker makes once per boot, so builds need no privilege.
Network slots
| Interface | Role | Address |
|---|---|---|
wfc<i>b | Bridge joining the two TAPs below; IPv6 off, rp_filter=1, arp_ignore=8 | none |
wfc<i>r | Relay VM's build NIC (eth0, the build link's relay address inside) | none |
wfc<i>g | Build VM's only NIC (eth0, the build link's guest address inside) | none |
wfc<i>u | Relay VM's upstream NIC (eth1); IPv6 off, rp_filter=1 | host 100.64.88.0 + 4i + 1/30, relay + 2 |
Every slot reuses the build link's two addresses (default 100.127.255.253
and 100.127.255.254): each bridge is its own segment with no host route. The TAPs belong to the user builds run as.
Bridge table and WARDEN-FC rules
nftbridge tablewarden_fc: its input hook drops every frame arriving on awfc*port, so nothing from a build segment reaches the host stack; its forward hook passes frames only between a slot's ownwfc<i>randwfc<i>g.WARDEN-FC-IN(first in INPUT): dropwfc<i>b; fromwfc<i>uaccept only ESTABLISHED from the slot's relay address; drop the rest ofwfc+.WARDEN-FC-FWD(first in FORWARD): fromwfc<i>uwith the relay's address to the uplink accept, and its replies (ESTABLISHED, RELATED for ICMP errors) back; TCP MSS clamped both ways to the uplink's MTU; anything else fromwfc<i>udropped (anti-spoof: un-NATed build traffic never leaves even if the relay's own rules are missing); within one bridge accept; every otherwfc+forward dropped.WARDEN-FC-OUT(first in OUTPUT): to the relays accept ESTABLISHED and ICMP RELATED, NEWtcp/8301only from the slot owner's uid, and drop the rest, so no other local user reaches a relay's:80,:443,:53or:8300, and the owner reaches only the claim port.WARDEN-FC6: ip6tables drops all INPUT, FORWARD and OUTPUT onwfc+.WARDEN-FC-RAW(raw PREROUTING): conntrack zonei+1per bridge, so identical flows in two slots never share conntrack entries whenbr_netfilteris loaded.WARDEN-FC-NAT: MASQUERADE from100.64.88.0/22out of the uplink.
Inside the relay VM the same iptables rules as QEMU's apply. Setup refuses to run on a host whose filter FORWARD policy is ACCEPT, or whose firewalld or nftables ruleset would drop the relays' traffic, because a DROP in WARDEN-FC is final but an ACCEPT there cannot override another table's drop.
The Build Link
Every VM driver joins the build VM to the relay over one private /30, the
build link: [vm] build_link, default 100.127.255.252/30 (relay
.253, build VM .254; see
Configuration).
Each build segment is its own L2 network (a socket netdev, a per-slot
bridge, a private switch, a socketpair), so the same two addresses repeat
across builds without clashing, and no host interface holds one. The link
reaches every component per build:
- the relay, in its claim (
build_link): in vm mode the relay addresses its build interface over netlink before it answers the claim, refusing a link another of its interfaces already uses; in host mode (vz) it builds its netstack from it; - the build VM, from its seed (cloud-init
network-config), or by DHCP from the relay (Windows guests, whosewarden-run.ps1passesinitializeno--ip; the direct-boot inits, with the kernel command line'swarden.link_ipandwarden.link_gwas the cross-check and fallback; vz'swarden-boot).
The relay's DHCP responder. In vm and host modes the relay answers DHCP
on the build link only: in vm mode on a UDP socket bound to the build
interface (SO_BINDTODEVICE), so a request on the relay VM's upstream
network never reaches it; in host mode inside its netstack. It makes one
fixed offer per build, from the claim: the guest address, the link's mask,
the relay as router, DNS server and server identifier, and an infinite
lease. It keeps no per-client state, so a flood of requests exhausts
nothing, and it never answers a BOOTREPLY, so a forged server message from
the guest is ignored.
The link block. Inside the relay the link is a connected route, so an
upstream address inside it would be sent to the build VM. In vm and host
modes the relay's upstream dialer refuses every address inside the link
(whether or not host mode's SSRF filter is on), it refuses a claim whose
upstream_dns names a resolver there, and its resolv.conf default skips a
nameserver there. warden refuses a link that holds a host interface address,
every VM driver leaves out host resolvers inside it (and refuses a [vm] dns
entry there), and Hyper-V refuses a NAT prefix that overlaps it, at setup and
at every build.
Common DNS Behavior
All drivers configure the build environment to use the relay as its DNS server:
artifactsandcwdresolve to the relay itself (reserved hostnames for context transfer and artifact upload)- All other queries are forwarded to the relay's upstream resolvers, asked in
order, and logged in the ledger. The list is fixed at the claim: its
upstream_dns, which every VM driver sends ([vm] dnswhen set, used exclusively, else the host's resolvers the driver can reach), or, when the claim has none (the container driver), the usable nameservers of the relay's ownresolv.conf. No public resolver stands in, and the relay's own upstream lookups use the same list. - IPv6 is disabled in VM drivers to prevent bypass via link-local addresses
What Isolation Prevents
| Threat | How it is blocked |
|---|---|
| Direct internet access bypassing the relay | All traffic forced through relay by topology or iptables |
| DNS tunneling to external servers | All DNS queries go through the relay |
| Metadata service access (169.254.169.254) | Blocked by SSRF filter in host mode; unreachable in VM modes |
| Build environment modifying its own network | No CAP_NET_ADMIN (container); no additional interfaces (VM) |
What Isolation Does NOT Prevent
These are availability concerns, not integrity violations — the ledger still records everything:
- Build environment sending excessive traffic through the relay
- Build environment attempting to DoS the relay with many connections
- Build environment consuming all available bandwidth
The relay applies fairness scheduling to mitigate resource exhaustion, but these are not considered security violations because the invariant (all traffic is recorded) is preserved.
Trust and the Build Baseline
Every HTTPS connection from the build goes through the relay, which intercepts
it with a certificate authority (CA) generated for that build. Tools in the
build have to trust that CA. warden-io initialize sets this up itself, inside
the build environment, before your build script runs. The only input it needs
from the host is the CA, which it fetches from the relay. See
How It Works for where this sits in a build.
System trust
initialize installs the CA as a system root, in one of two modes. The
orchestrator chooses the mode and sends it in the build's bootstrap config
(GET http://artifacts/bootstrap), which the relay records in the ledger:
| Mode | Guests | Effect |
|---|---|---|
exclusive | Linux (every driver) | The warden CA becomes the only trusted root: /etc/ssl/certs holds just it, and other known system bundles (/etc/pki/..., /etc/ssl/cert.pem) are replaced. A ca-certificates update hook restores this if the build reinstalls ca-certificates. |
append | Windows, macOS | The warden CA is added to the existing roots (the Windows Root store, the macOS System keychain and bundle). |
Exclusive trust loses nothing. Every TLS connection the build makes is intercepted by the relay, so no other root could ever validate a real connection. It also makes it obvious when a tool ignores the system store: that tool fails loudly instead of quietly trusting something else.
The baseline
initialize applies the baseline to every build, on every driver. It is not
configurable. Each part is a small file or an environment variable, harmless
when the tool it serves is absent.
| What | Where | For |
|---|---|---|
| Java truststore (JKS) with the warden CA | /etc/warden/certs.jks (%ProgramData%\warden\certs.jks on Windows) | JVM tools |
MAVEN_OPTS, GRADLE_OPTS | -Djavax.net.ssl.trustStore=<that file> | Maven, Gradle |
| Bazel system rc | /etc/bazel.bazelrc | Bazel's host JVM |
SSL_CERT_FILE, CURL_CA_BUNDLE | the system CA bundle | OpenSSL consumers, Ruby, Erlang, PHP composer, libcurl |
REQUESTS_CA_BUNDLE, PIP_CERT | the system CA bundle | pip, poetry, conda, conan |
NODE_EXTRA_CA_CERTS | the system CA bundle | npm, yarn, pnpm, bun |
CARGO_HTTP_CAINFO | the system CA bundle | cargo |
NIX_SSL_CERT_FILE, HEX_CACERTS_PATH | the system CA bundle | nix, hex |
UV_NATIVE_TLS=1 | uv | |
SOURCE_DATE_EPOCH=0 | reproducible timestamps |
The baseline variables are set on the build script's process, so an ENV line
in your Containerfile (or an export in your script) overrides them. If you set
MAVEN_OPTS yourself, include the truststore flags or Maven will not trust the
relay.
The JKS file is written by warden-io directly; no keytool is needed in the
image. Its bytes match what keytool -importcert -storetype JKS writes, and the
same CA always produces the same file.
Package manager compatibility
| Manager | Trusts the relay through |
|---|---|
| apt, apk, dnf, go modules, nuget/.NET | system trust |
| gem/bundler, composer | SSL_CERT_FILE, CURL_CA_BUNDLE |
| npm, yarn, pnpm | NODE_EXTRA_CA_CERTS |
| pip, poetry, conda, conan | PIP_CERT, REQUESTS_CA_BUNDLE |
| uv | UV_NATIVE_TLS |
| cargo | system trust, CARGO_HTTP_CAINFO |
| nix, hex/mix | NIX_SSL_CERT_FILE, HEX_CACERTS_PATH |
| maven, gradle | MAVEN_OPTS/GRADLE_OPTS and the JKS |
| bazel | /etc/bazel.bazelrc and the JKS |
Adding support for another tool
Support for a tool is added to the baseline in warden-io
(cmd/warden-io/baseline.go), so it ships with the executor and reaches every
driver. Anything specific to one build belongs in that build's Containerfile.
There is no plugin mechanism for setup scripts: the build environment runs no
setup code that warden-io did not ship with (BOOT-05 in
docs/development/bootstrap.md).
Build Drivers
BuildWarden supports five build drivers, each providing the same hermetic build guarantee with different isolation technologies. The driver determines what runs your build code and how network isolation is enforced.
Driver Selection
By default, BuildWarden uses the container driver. Override with the
--driver flag, WARDEN_DRIVER, or a config file entry. There is no
auto-detection: a driver that is not found is an error that says where warden
looked.
Flag:
warden build --driver qemu .
warden build --driver vz --script ./build.sh .
warden build --driver container .
Config file (warden.toml):
[runtime]
driver = "qemu"
Where a driver comes from
A driver is a program named warden-driver-<name> (warden-driver-<name>.exe
on Windows) that warden runs through the driver contract
(specs/driver-contract/v1.md), or a driver linked into warden itself. In
this release container is a binary, warden-driver-container, installed
beside warden, and qemu, vz, hyperv and firecracker are linked. A
name is looked up once
per command, and the first match wins:
PATH, in order;- the directory warden itself is installed in (symbolic links resolved),
when
PATHgave nothing; - a driver linked into warden.
So a warden-driver-<name> in a PATH directory that comes before warden's
own runs in place of the one warden ships, for every command. A file of that
name that is a directory or cannot be executed is passed over; one reached
through a relative PATH entry (or an empty one, the current directory) is an
error that names the entry, and is not run. A batch file (.bat, .cmd) is
never taken for a driver.
--driver and WARDEN_DRIVER also take the path of a driver's file
(anything with a /, or on Windows a \): the file is used as given. A
config file may select a driver by name only; [runtime] driver holding a
path is refused, whichever file it is in.
warden driver list shows, for each name, the file that would run and where
it was found, and every other copy beneath it: the ones it shadows and the
ones it skips. Each build records the same in its output's driver.json
(Output). A driver binary is given
[build] teardown_timeout (60 s unless set) to tear a build down after it is
asked to stop; after that, or on a second Ctrl-C, warden kills it and runs its
reap for the build, bounded by the same wait.
To write a driver, implement the commands of the driver contract
(specs/driver-contract/v1.md) in a program named warden-driver-<name>,
and check it from a source tree with make driver-conformance DRIVER=<path>, which runs the contract's suite against it, real builds
included (CONTRIBUTING.md
lists its options). Put the program on PATH and --driver <name> runs it;
[driver.<name>] in warden.toml holds its settings.
Container Driver
--driver container (default)
The container driver runs builds in an unprivileged OCI container on an isolated Docker network. The relay runs as a sidecar container, and iptables rules are applied by an init-container that shares the build container's network namespace.
Requirements
- Finch, Podman, or Docker
- Works on: macOS, Linux, Windows — any platform with a container runtime
No additional setup is needed beyond installing a container runtime.
Heavy builds (PyTorch, for example) need a larger runtime VM on macOS. For Finch,
in ~/.finch/finch.yaml:
cpus: 6
memory: 16GiB
datadisk: 150GiB
Choosing the runtime
With no runtime named, warden uses the first of finch, podman and
docker that answers within 3 seconds. When both docker and podman are
installed and running, podman is chosen; earlier releases chose docker.
To use another runtime, such as docker, name it with --runtime,
WARDEN_CTR_CLI or [driver.container] cli (old name [runtime] cli,
read until 1.0):
warden build --runtime podman .
[driver.container]
cli = "podman"
The value is one of those three names and nothing else: not a path, and not
another program. warden runs the runtime by that name, looked up on
PATH, with its own arguments, so whatever a runtime needs beyond its name
is set up outside warden:
- A runtime installed outside
PATH: add its directory toPATH. - A remote daemon or a context other than the default: set the runtime's
own variables (
DOCKER_HOST,DOCKER_CONTEXT,CONTAINER_HOST) in the environmentwardenruns in. The runtime inherits them.
Any other value in effect stops build, shell, doctor and clean
before anything is run, with an error that says where the value is set and
what to change. A project's warden.toml can choose among the three, and
--runtime or WARDEN_CTR_CLI replaces its choice with yours.
A runtime you name is used, or the command stops: one that is not on
PATH stops build and shell before any output directory exists. One
whose VM or daemon is stopped fails build and shell at their first call
to the runtime, its version query, with an error that says to start it and
to check with warden doctor; the output directory is left, as after any
failed build. doctor asks the runtime for its engine's version, waiting
up to 10 seconds, and is blocked by either. warden does not fall back to
detection, so start the runtime or name another.
With no runtime named, doctor detects it as a build does and reports the
runtime a build would use. When none answers within 3 seconds, it asks each
installed runtime again with up to 10 seconds; one that answers then is
running but too slow for detection, and doctor is blocked with the fix to
name it.
finch on macOS and Windows runs in a VM, and is checked with finch vm status, which never starts it (finch version would). A build whose
runtime is finch starts its stopped VM itself, at its first call to finch,
printing a line that says so and finch's own output, unless
[driver.container] start_finch_vm = false; then the build fails there
with the fix to start it, naming the setting:
[driver.container]
start_finch_vm = false # never start finch's VM; the default is true
With no runtime named, a runtime that is already up is chosen over starting
finch: a stopped finch is the runtime only when podman and docker are not
up. doctor reports a stopped VM without starting it: with the setting
true it names finch, prints the line that says a build starts it, and is
not blocked; with the setting false it is blocked. finch on Linux has no
VM, keeps its version query, and ignores the key. finch's
VM has the messages.
The setting belongs to the container driver. A build with a VM driver does
not read it, so one warden.toml can hold cli beside the VM drivers'
settings. warden clean is the exception: under qemu and vz it also
removes leftover containers, and checks the setting there.
The container runtime has the
precedence, the commands that check the value and the error.
How It Works
- Uses your Dockerfile/Containerfile as the build specification
- The relay container intercepts all network traffic (MITM proxy + DNS)
- The build container has no
CAP_NET_ADMIN— it cannot modify its own network rules - Network isolation is enforced via iptables in a one-shot init container
Concurrent builds on one runtime
Each build gets its own network on the runtime, a /29 block of
100.64.87.0/24 (32 blocks in all). Builds of one HOME take blocks in turn.
Builds that share a runtime from different HOMEs or users (another HOME or
user on the same finch VM, Docker daemon or rootful podman) can create a
network on the same block at the same moment. Each build checks the runtime's
networks after creating its own. If it finds another build on its block, it
gives that block up and tries the next:
[warden] network 100.64.87.0/29 was also created by warden-abc12345 at the same time; trying the next /29
If that check cannot read the runtime's networks at first, the build reads them again, up to 5 times in all:
[warden] reading the runtime's networks failed (<error>); reading them again (2 of 5)
Neither line needs any action: the build goes on. If all 32 blocks are taken,
the build fails with no available /29 subnet in 100.64.87.0/24 and the fix:
run warden clean to remove leftover networks of builds that are no longer
running.
Examples
Build the current directory (auto-detects Dockerfile):
warden build .
Specify a project path:
warden build --driver container ./my-project
Build with a specific Containerfile:
warden build ./examples/Dockerfile.pip
QEMU Driver
--driver qemu
The QEMU driver runs builds inside a full virtual machine using QEMU's system emulation. It uses a two-VM topology: a relay VM (Alpine Linux) provides the network bridge, and a build VM (your target OS) connects only through the relay. Network isolation is topological — the build VM's sole network path passes through the relay.
Requirements
qemu-system-aarch64andqemu-img- Works on arm64 hosts: macOS (HVF acceleration), Linux (KVM), or any host
with TCG emulation (slow). x86_64 guests are not supported yet: the VMs use
the arm64
virtmachine type.
Installation
macOS:
brew install qemu
Linux (Debian/Ubuntu):
apt install qemu-system-arm qemu-utils
Linux (Fedora/RHEL):
dnf install qemu-system-aarch64 qemu-img
Setup
Build the relay VM assets (kernel + initramfs):
tools/relay-vm/build-initramfs.sh
Build the build VM assets (for direct-boot mode):
tools/build-vm/build-initramfs.sh
The relay's DNS resolvers go in its claim: [vm] dns when set, else the
host's /etc/resolv.conf (the primary resolvers macOS writes there, or a
Linux host's), leaving out loopback and link-local servers (they would be the
relay VM's own), QEMU user-mode NAT's 10.0.2.0/24 and the build link. With
none left the build is refused before any VM boots, naming each server, with
the fix (an off-host DNS server, or [vm] dns). The relay initramfs needs no
rebuild for this.
Cloud Images
The QEMU driver uses QCOW2 cloud images as the build environment. Supported FROM image names that auto-resolve to cloud images:
| FROM value | Image |
|---|---|
alpine | Alpine latest |
alpine:3.21 | Alpine 3.21 |
ubuntu | Ubuntu latest LTS |
ubuntu:24.04 | Ubuntu 24.04 |
debian | Debian stable |
debian:bookworm | Debian Bookworm |
Images are cached in ~/.cache/warden/images/ after first download.
Examples
Build with an explicit image path:
warden build --driver qemu --image ~/.cache/warden/images/alpine.qcow2 .
Build using a Dockerfile with FROM auto-resolution:
warden build --driver qemu examples/Dockerfile.apk
The Dockerfile's FROM alpine:3.21 line resolves to the cached Alpine QCOW2
image automatically.
Windows guests
warden image prepare --driver qemu --os windows --source Win11_Arm64.iso
Windows images are made in two stages. The install stage runs an unattended
install from the ISO with no network and ends in sysprep /generalize, leaving
a generalized base like Microsoft's evaluation VHDs; it is redone only with
--force or a new ISO. The prepare stage then boots an overlay of that base
once with no network through OOBE and the same tuning as Hyper-V, registers
the warden-run startup task, and powers off; builds boot a throwaway child of
that layer as SYSTEM. With no --source, image prepare only re-prepares,
and builds start that in the background once the layer is
[driver] image_refresh_after old, or [driver.qemu] image_refresh_after
for this driver alone (see the Hyper-V section for the evaluation grace
rules, which are the same, and the same report of a re-prepare that cannot
start).
VZ Driver
--driver vz (macOS Apple Silicon only)
The VZ driver runs builds inside a macOS virtual machine using Apple's Virtualization.framework. The relay runs as a host process using gvisor netstack, reading Ethernet frames from a socketpair. The build VM boots macOS with a single network interface that connects exclusively to the relay — no vmnet entitlement is needed.
Requirements
- macOS on Apple Silicon (arm64)
- A
wardenbuilt from source with cgo (make build, which needs the Xcode Command Line Tools). A released binary is built without cgo and has no vz driver:--driver vzstops withERROR: this warden was built without cgo, so it has no vz driver (released binaries are built this way)and aTo fix:line naming the build from source, and exits 1 - The
wardenbinary must be codesigned with thecom.apple.security.virtualizationentitlement make buildhandles codesigning automatically if you have a Developer ID certificate
First-Time Setup
On first use, prepare the macOS build image. This downloads the latest
supported IPSW from Apple, restores a macOS VM image, and installs warden-io
and the LaunchDaemon into it. It writes root-owned files into the image, so it
runs under sudo:
sudo warden image prepare --driver vz
Builds clone the prepared image (copy-on-write) for each build, so startup is
fast. The images live in ~/.cache/warden/images, one macos-<key>
directory per IPSW, and warden image list lists them all.
Which image builds use. The image you prepared last is the active
image, and a build without --image uses it; --image <dir>/disk.img picks
another. A cache prepared before the active image was recorded uses the image
whose preparation finished last.
warden image list shows the active image first, then the older ones, each
with the IPSW it was restored from when that was recorded:
$ warden image list
vz macos /Users/me/.cache/warden/images/macos-a139c218a2010753 active UniversalMac_27.2_26B123_Restore.ipsw
vz macos /Users/me/.cache/warden/images/macos-90a1b1f94f64b00a older UniversalMac_27.0.1_26A100_Restore.ipsw
To switch builds back to an older image, prepare it by its directory (see Other sources below); it is refreshed in place and becomes active.
Refreshing. Re-running sudo warden image prepare --driver vz with no
source refreshes the active image's warden boot agent in place: no IPSW
download and no restore. When Apple has since published a newer macOS, it
ends with a warning naming both versions and the command to move to it:
warning: the active macOS image is macOS 27.0.1 (26A100); macOS 27.2 (26B123) is available. To update (about 25 GB, 15 minutes): sudo warden image prepare --driver vz --update
When the newer image is already prepared, the warning says so instead ("is already prepared. To use it (no download)"). The check is best effort: offline, the refresh completes and prints nothing.
Moving to a newer macOS. sudo warden image prepare --driver vz --update
restores the latest supported IPSW, or refreshes its image in place when it is
already prepared, and makes it active. A newer macOS is a different build OS,
so a refresh never moves to one by itself.
Other sources. A source names what to prepare, and the result becomes the active image:
sudo warden image prepare --driver vz ~/.cache/warden/images/macos-90a1b1f94f64b00a # refresh that image in place
sudo warden image prepare --driver vz ~/Downloads/UniversalMac_27.2_26B123_Restore.ipsw # restore from a local IPSW
sudo warden image prepare --driver vz https://updates.cdn-apple.com/.../UniversalMac_27.2_26B123_Restore.ipsw
A local .ipsw file is read where it is: it is not copied into the cache and
never deleted. An IPSW whose image is already prepared is refreshed in place,
not restored again.
Disk use. Each image is about 25 GB on disk and older images are kept
(they are your rollback); delete a macos-<key> directory you no longer
want. An IPSW downloaded into the cache (ipsw-<key>.ipsw, about 25 GB) is
deleted once its image is prepared, since a later prepare of the same IPSW
refreshes the image in place. Restoring that image from scratch (after
deleting its directory) downloads the IPSW again.
When a build refuses the image. A build refuses a prepared image whose
warden boot agent is out of date (its link-channel stamp is missing or
stale) and names the command that fixes it; warden doctor --driver vz
reports the same as BLOCKED. Run the command it names:
- building from the active image (no
--image):sudo warden image prepare --driver vz, which refreshes it in place in a few minutes, with no download; - building with
--imagenaming another image in the cache: either prepare that directory (sudo warden image prepare --driver vz <dir>, which refreshes it and makes it active) or drop--imageto build from the active image; - building with
--imagenaming a disk outside the cache: drop--imageand build from the cache's image, since prepare re-prepares only images it owns.
The build-link upgrade notes explain why existing images need this once, and the CLI reference lists every source and flag.
Examples
Run a build script inside a macOS VM:
warden build --driver vz --script ./build.sh .
Network Architecture
- Uses
VZFileHandleNetworkDeviceAttachment(no vmnet entitlement required) - The host relay process creates a socketpair and attaches one end to the VM
- gvisor netstack processes raw Ethernet frames on the host side
- The build VM sees a single network interface whose only path is the relay
- The image's
warden-boottakes its address by DHCP from the host relay, which answers from the build link in its claim, so the image bakes no address - The relay's DNS resolvers go in its claim:
[vm] dnswhen set, else the Mac's/etc/resolv.conf, leaving out only servers inside the build link (the relay runs on the Mac, so a loopback resolver is reachable). That file lists only the primary resolvers, not macOS's scoped or split-DNS ones (a VPN's per-domain resolvers): a build that needs those sets[vm] dns
Hyper-V Driver
--driver hyperv (Windows only)
The Hyper-V driver runs builds inside a Hyper-V virtual machine. Like QEMU it uses a two-VM topology: an Alpine relay VM provides the network bridge, and a Windows build VM connects only through it (Linux build guests are not yet supported on Hyper-V; use the QEMU driver). The relay VM reaches upstream through an Internal NAT switch; the build VM sits on a Private build switch with no other path.
Requirements
- Windows with Hyper-V and its management stack enabled
- Membership in Hyper-V Administrators (or an elevated terminal)
Setup
Create the durable network builds reuse (one time, from an elevated terminal):
warden setup --driver hyperv # 4 build switches: 4 builds at once
warden setup --driver hyperv --slots 8
It makes one Private build switch per concurrent build (--slots, default 4),
the Internal NAT switch and its NAT rule. A durable build takes the lowest
switch with nothing attached; with all in use it is refused, naming the VMs on
each, warden clean --driver hyperv (for VMs a --keep-vms build or a
killed warden left) and --slots. Upgrading from a warden whose setup made one build switch
needs this one elevated run again: it makes the slots and retires the old
switch.
Prepare a Windows Server base image. By default warden downloads Microsoft's
current Windows Server 2025 evaluation VHDX (about 11 GB) from the Evaluation
Center link; --source or [driver.hyperv] windows_image names another URL, or a file
you already have (registered in place, not copied):
warden image prepare --driver hyperv
warden image prepare --driver hyperv --source D:\images\server2025.vhdx
Nothing is pinned in advance: the download comes over HTTPS (the default link
must resolve to a Microsoft host), and the resolved URL, ETag and the sha256
computed while downloading are recorded in the image manifest and in every
build's ledger. --sha256 adds an expected-digest check. When Microsoft
publishes new media behind the link, the next refresh downloads it beside the
current base and prepares from it; [driver.hyperv] windows_image_update = "reuse"
keeps the current base instead. A base you supplied as a local file is never
replaced automatically.
Prepare boots the image once with no network adapter. OOBE runs, a tuning
script turns off background work builds never need (Windows Update,
telemetry, maintenance tasks, automatic activation, Defender), registers the
warden-run startup task, and powers off. The result is a read-only
differencing layer over Microsoft's image, which is never modified. Every
build boots a throwaway child of that layer and runs as SYSTEM, with no OOBE.
Prepare takes about three minutes; the ledger records the chain (the
evaluation image, then the prepared layer with the hashes of its inputs).
The evaluation edition is never activated (prepare has no network), so a
prepared base has the 10-day initial grace period, counted in wall time from
the prepare. Builds keep it fresh: once the base is 7 days old, the next build
starts a background re-prepare (warden image prepare --driver hyperv with no
source does the same by hand), and a build refuses to start with less than a
day of grace left. A re-prepare that cannot start is reported on the build's
output with its error and that command to run by hand, and the build goes on
on the current base. Both ages are set in [driver] (image_refresh_after,
image_min_grace), or in [driver.hyperv] for this driver alone; their old
names in [vm] are read until 1.0. Only one prepare runs at a time; superseded layers are
deleted by a later prepare once no VM uses them.
Optionally install the privileged helper service so builds run without elevation and stand up a fresh isolated network per build:
warden hyperv service install # run once, elevated
A service installed by an older warden speaks an older protocol: doctor
reports it as stale, and a non-elevated build is refused until it is
reinstalled (elevated: warden hyperv service uninstall, then warden hyperv service install). One that is installed but stopped is reported as
stopped, with Start-Service WardenHyperV (elevated) as the fix. When warden
cannot read the service's state (access denied, say, in an SSH or scheduled
session), doctor says so rather than "not installed", and names Get-Service WardenHyperV (elevated) to check it.
How It Works
- The relay VM boots from a UKI boot disk with
/sbin/relaybaked in. From a source tree,tools/relay-vm/hyperv/refresh-cache.sh(Git Bash, needs WSL) builds it into the cache below, and rebuilds it only when the relay source has changed since;--checkreports whether it is current - Each build's relay gets its own address on the NAT, the lowest free one in
the NAT prefix read back from the host (
--nat-prefix,--host-ip), so builds run concurrently. Its address, prefix, gateway and a fresh claim token reach it on a small per-build seed ISO (WARDENRELAY); nothing per build is baked into the boot disk. The claim needs that token, and the build VM cannot reach the claim port - The relay's DNS resolvers go in the claim:
[vm] dnswhen set, else the IPv4 DNS servers of the host's default route interface, leaving out loopback, link-local, the host's own addresses, the NAT prefix and the build link. With none left the build is refused, naming the interface, with the fixes (an off-host DNS server, or[vm] dns) - The Windows build VM joins its relay's switch and takes its address from
the relay's DHCP lease; a guest that got none logs, in
warden-run.logand on COM1, its address and origin (WellKnown, no DHCP lease from the relay) - Network isolation is topological, enforced by the switch layout
Examples
warden build --driver hyperv --guest-os windows ./win-project
--image <disk> overrides the prepared base with a disk that already carries
the warden-run startup task; a stock, unprepared image would wait at OOBE.
--keep-vms leaves the build and relay VMs, the build's ephemeral switch and
its work dir in place. warden clean --driver hyperv removes them, and what a
killed warden left behind, for every build that is no longer running.
Where the image cache lives
Prepared images and the relay boot disk are cached in
%LOCALAPPDATA%\warden\hyperv, or in WARDEN_HYPERV_CACHE_DIR when set.
Hyper-V's own service opens these files, so they must be where it can see
them. When warden runs from a terminal started by a packaged (MSIX) app, such
as some desktop apps' built-in terminals, Windows can silently redirect new
files under %LOCALAPPDATA% into that app's private folder
(%LOCALAPPDATA%\Packages\<app>\...), which Hyper-V cannot see.
warden doctor --driver hyperv shows the cache as REDIRECTED, and
warden image prepare stops before any download with the fix: set
WARDEN_HYPERV_CACHE_DIR to a folder outside AppData, or run warden from an
ordinary terminal. The OS temp directory, where each build's work files go by
default, is not redirected.
Firecracker Driver
--driver firecracker (x86_64 Linux with KVM)
The Firecracker driver runs each build in a Firecracker microVM, for Linux
hosts running many builds at once. It uses the QEMU driver's two-VM
topology: an Alpine relay VM, booted from the same relay initramfs and init,
and a Linux build VM whose only network interface is on a per-slot host
bridge whose only other port is the relay. Each VM is one firecracker
process with no API socket, no vsock, no MMDS and stdin /dev/null.
Requirements
- An x86_64 Linux host with
/dev/kvm, and your user in thekvmgroup - Firecracker v1.17.0 or later on
PATH nft,iptablesandip6tables(legacy or nft), andip(iproute2)- For disk-image builds:
qemu-img(qemu-utils) andgenisoimageormkisofs - An upstream DNS server that is not on the host itself (see below)
arm64 hosts are not supported yet.
Boot assets
Both VMs boot one pinned guest kernel (Linux 6.1 LTS with every feature built in), and the driver needs two initramfs images. Build them once from the source tree:
tools/firecracker-vm/build-kernel.sh # output/vmlinux
ARCH=x86_64 NO_MODULES=1 tools/relay-vm/build-initramfs.sh
tools/firecracker-vm/build-initramfs.sh # direct-boot initramfs
warden finds them beside its binary (firecracker-vmlinux,
firecracker-relay-initramfs.cpio.gz, firecracker-build-initramfs.cpio.gz)
or in those scripts' output directories.
Setup
Builds run unprivileged. A root setup step, once per boot, creates the network slots they take:
sudo warden setup --driver firecracker # 16 slots
sudo warden setup --driver firecracker --slots 64 # up to 256
Each slot i is a bridge wfc<i>b with no address joining two TAPs (the
relay's build NIC wfc<i>r and the build VM's wfc<i>g), plus the relay's
upstream TAP wfc<i>u on a /30 in 100.64.88.0/22. The TAPs belong to the
user who ran sudo. Setup also loads the warden_fc bridge table and the
WARDEN-FC iptables chains that isolate the slots (see
Network Isolation),
and sets net.ipv4.ip_forward=1 last. It is idempotent: existing
interfaces are verified, an upstream TAP that already has its address keeps
it, and warden's own table and chains are reloaded; no other rule is touched.
Because the reload briefly removes the slots' rules, setup refuses while any
slot is in use: a VM has one of its TAPs open (a running build, VMs left by
--keep-vms, or ones a killed warden left behind), or a build holds the
slot. Wait for the builds to finish, or stop leftover VMs with warden clean --driver firecracker run as the build user, then re-run setup. While setup
runs it holds every slot's lock, so a build starting then finds them all in
use. It creates any lock file a build has not made yet, as the build user, in
~/.cache/buildwarden/locks. It uses XDG_CACHE_HOME instead only when sudo
keeps it along with your HOME; if your builds keep their cache elsewhere
and sudo drops it, setup holds the wrong locks, so start no build while it
runs.
Setup refuses, printing the fix, when the host's firewall would make it unsafe or ineffective:
- the filter
FORWARDpolicy isACCEPT(enabling forwarding would route between your other interfaces):iptables -P FORWARD DROP && ip6tables -P FORWARD DROP, kept across reboots; - firewalld is running: put the upstream TAPs in its trusted zone,
firewall-cmd --permanent --zone=trusted --add-interface=wfc+u; - an nftables forward chain drops by default: setup prints the
nft insert rulelines that letwfc*utraffic through.
The slots are runtime state and vanish at reboot. Run setup at boot with a
systemd unit (builder is the user builds run as):
# /etc/systemd/system/warden-firecracker.service
[Unit]
Description=BuildWarden Firecracker network slots
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
Environment=SUDO_USER=builder
ExecStart=/usr/local/bin/warden setup --driver firecracker --slots 16
[Install]
WantedBy=multi-user.target
To remove the slots, delete the interfaces (ip link del wfc<i>b, and the
same for each TAP), nft delete table bridge warden_fc, and remove the
WARDEN-FC-* chains and the jumps into them. warden has no command for it.
warden doctor --driver firecracker checks all of the above; run it with
sudo to include the rules and the FORWARD policy, which only root can read.
Under sudo the other checks are of the user who ran sudo (their slots, kvm
group and leftover VMMs), and the reflink probe is skipped: run doctor
without sudo for it.
Upstream DNS
The relay resolves names for the build through [vm] dns when it is set
(used exclusively; see
Configuration), and
otherwise through the host's resolvers: those in /etc/resolv.conf, or
systemd-resolved's upstream list when its 127.0.0.53 stub fronts them. They
reach the relay in its claim, not on its kernel command line. A loopback or
link-local resolver, or one on the host's own address (a local dnsmasq,
unbound or libvirt) is left out, since the slot
rules do not let the relay open connections to the host. So is one inside
the build link ([vm] build_link, default 100.127.255.252/30), the relay's
link to the build VM: the relay would send its queries to the build VM. The
default is a range no VPC or LAN resolver uses, so an AWS VPC's own
resolver is used as is. With none left the build stops before booting and
says how to fix it: a resolver outside the link, [vm] dns, or another [vm] build_link. Under WSL, whose only
resolver is its DNS-tunnelling address 10.255.255.254, set
generateResolvConf=false under [network] in /etc/wsl.conf and list the
Windows host's DNS servers in /etc/resolv.conf.
Images
A build boots one of two ways:
- Disk image. With a
FROMthe qemu catalog resolves (ubuntu:24.04,debian:bookworm,alpine:3.21) or--image <path>(qcow2 or raw), the image is converted to raw once into~/.cache/warden/firecracker/imagesand copied per build into~/.cache/warden/firecracker/work/<id>withcp --reflink=auto(instant on btrfs or XFS, a full copy elsewhere). warden deliverswarden-ioon a cloud-initCIDATAseed on a read-only drive; the image's own kernel is not used. An image with a backing file or an external data file is refused. - Direct boot. With no resolvable image, the build VM boots a small
initramfs that holds only a launcher, with
warden-ioappended per build.
Prepare an image ahead of the first build:
warden image prepare --driver firecracker # ubuntu:24.04
warden image prepare --driver firecracker ./custom.qcow2
Examples
warden build --driver firecracker . # Dockerfile FROM ubuntu:24.04
warden build --driver firecracker --script build.sh ./src # direct boot
warden build --driver firecracker --cpus 8 --memory 8192 .
--keep-vms leaves both VMs running and the slot held, and prints their
pids; warden clean --driver firecracker stops them. It also kills any VMM
left by a warden that was killed, and removes stale work dirs; the next
build on a slot kills such leftovers too.
Upgrading to the configurable build link
The VM drivers' relay-to-build link moved from a fixed RFC 1918 /30 to the
configurable [vm] build_link (default 100.127.255.252/30; see
Configuration).
The link now reaches every component per build, so a launcher built before
the change, which bakes 10.0.0.x, is replaced once. Each such asset carries
a link-channel stamp; a build refuses an asset without a current one, naming
the command, and warden doctor reports each stamp's state. After this one
step, changing [vm] build_link needs nothing on any driver.
| Driver | Replace once | With |
|---|---|---|
| qemu (direct boot only) | the direct-boot initramfs | tools/build-vm/build-initramfs.sh |
| firecracker | the direct-boot launcher initramfs | tools/firecracker-vm/build-initramfs.sh |
| hyperv | the relay boot VHDX (it bakes the relay binary) | tools/relay-vm/hyperv/refresh-cache.sh |
| vz | the prepared macOS image's warden-boot | sudo warden image prepare --driver vz (refreshes the active image in place, no IPSW restore) |
The qemu and Firecracker relay initramfs need nothing: the relay addresses its build interface from the claim and replaces an old init's address. Disk image builds on qemu and Firecracker take the link from their per-build seed, and Windows guests from the relay's DHCP lease, and need nothing either.
Hyper-V's relay boot VHDX is stamped once more by the per-build relay seed:
a disk stamped before it (channel 1) is refused by a build and BLOCKED in
doctor, naming tools/relay-vm/hyperv/refresh-cache.sh, the same one
rebuild; and an older warden refuses the new disk the same way.
On vz, warden image prepare refreshes only images in the cache
(~/.cache/warden/images), and with no source only the active image. A build
with --image naming another cache image whose warden-boot predates the
change is refused with the fix sudo warden image prepare --driver vz <dir>
(which refreshes that image and makes it active) or to omit --image and
build from the active image. A build with --image naming a disk outside the
cache is refused with the fix to omit --image and build from the cache's
prepared image.
Common Patterns
Regardless of which driver you use, the build environment works the same way from the perspective of your build script.
warden-io Commands
Inside every build environment, warden-io is available for interacting with
the relay:
Fetch a context file into the build environment:
warden-io fetch myfile.tar.gz -o /tmp/myfile.tar.gz
Post a build artifact (recorded in the ledger):
warden-io post ./dist/package.whl
Post with a custom name:
warden-io post ./output/binary my-tool-v1.0
Establish TLS trust (install relay CA):
warden-io trust
Inspecting Build Output
The ledger output is identical across all drivers:
warden inspect warden-output/
This verifies the Ed25519 signature chain and displays all recorded network activity, context fetches, and artifact posts — regardless of whether the build ran in a container, a QEMU or Firecracker VM, or a macOS VZ VM.
Choosing a Driver
| Container | QEMU | VZ | Hyper-V | Firecracker | |
|---|---|---|---|---|---|
| Platforms | macOS, Linux, Windows | macOS, Linux, Windows | macOS (Apple Silicon) | Windows | Linux x86_64 with KVM |
| Isolation | Network namespace + iptables | Topological (separate VM) | Topological (separate VM) | Topological (separate VM) | Topological (microVM, per-slot bridge) |
| Performance | Native speed | Near-native (HVF/KVM) | Near-native (Hypervisor.framework) | Near-native (Hyper-V) | Near-native (KVM), fast boot |
| Build OS | Linux (container image) | Linux or Windows | macOS | Windows or Linux | Linux |
| Setup effort | Minimal | Moderate (relay VM assets) | Moderate (image prepare) | Moderate (host setup + image prepare) | Moderate (boot assets + root setup each boot) |
| Best for | Linux builds, CI/CD | Linux/Windows builds needing stronger isolation | macOS-native builds (Xcode, Swift) | Windows-native builds | Many concurrent Linux builds on one host |
Configuration
BuildWarden reads one config file, chosen by whoever runs warden. Every
setting can come from a flag, an environment variable, that file or its
default, in that order: a flag replaces the variable, the variable replaces
the file, and the file replaces the default.
The config file
A command that reads configuration reads exactly one file, the first of:
- the file
--config <path>names; - else the file
WARDEN_CONFIGnames (an emptyWARDEN_CONFIGis not set); - else
warden.tomlin the working directory, when it exists; - else none, and every setting is its default.
No other file is read and nothing is merged. A source that a higher one
replaces is not looked at: with --config given, neither the variable's file
nor ./warden.toml is opened.
- The default is the working directory's
warden.toml, whatever[path]is:warden build /src/repo, run from elsewhere, does not read/src/repo/warden.toml. - A file named with
--configorWARDEN_CONFIGthat does not exist, is a directory or cannot be read is an error, and no other file is tried in its place.--config ""is an error too. A./warden.tomlthat exists but cannot be read is an error, not "no file". ./warden.toml, which nobody named, must be a regular file once links are followed: a link to a device or a pipe (/dev/zero, a terminal) is an error,not a regular file. It is read up to 1 MiB: one that gives more is the errorlarger than 1 MiB, whatever size it appears to have on disk (a link to/proc/self/pagemapappears empty). A file named with--configorWARDEN_CONFIGis read whole, whatever kind of file it is and whatever its size.- An empty file is a file: every setting is its default.
- A relative
--configorWARDEN_CONFIGis relative to the working directory, like any path argument, so a relativeWARDEN_CONFIGnames a different file in each directory. AWARDEN_CONFIGset once for a machine should be absolute. A relative path inside the file (a CA path,tmpdir,output_dir) is relative to the working directory too. - A file that is not valid TOML is an error for every command that reads it.
Every command that reads configuration says which file it read, without
--verbose. build, shell, clean, setup and image prepare print it
first on stderr; warden doctor prints it as the first line of its report.
The path is absolute, and a control character in it (a newline, an escape
sequence from a directory's name) is printed escaped (\n, \x1b), here and
in every message that names the file:
[warden] config: /etc/warden/ci.toml (--config)
[warden] config: /home/ci/warden.toml (WARDEN_CONFIG)
[warden] config: /src/repo/warden.toml (found in the working directory)
[warden] config: none (no --config, no WARDEN_CONFIG, no ./warden.toml): defaults apply
warden inspect, image list, image verify, hyperv service,
--version and help read no configuration: they accept --config and open
nothing.
A message or a fix that says "in warden.toml" means the config file in use,
whatever its name; the config: line gives its path.
Building a repository you do not control
With no file named, cd repo && warden build reads the repository's
warden.toml, and that file decides how the repository is measured: the
driver, the container runtime among finch, podman and docker, the relay
image, the relay's extra trust roots, whether payloads are captured, where
the output and work directories go, and, with --driver hyperv, a base image
that later builds of every project boot. The config: line says the file was
read; it does not stop it. On a machine that builds repositories it does not
control:
- name the file:
--config /etc/warden/ci.toml, or an absoluteWARDEN_CONFIGin the machine's environment. An empty file gives the defaults.WARDEN_DRIVER,WARDEN_CTR_CLI,WARDEN_IMAGEandWARDEN_UPSTREAM_CA_CERTSpin those settings whatever file is read; - under
sudo, pass--config:sudoresets the environment by default, so aWARDEN_CONFIGyou set is dropped and the repository's./warden.tomlis read.sudo --preserve-env=WARDEN_CONFIG, or a sudoersenv_keep, keeps the variable; - keep
wardenoutside the repository it builds. Awardenwhose executable is inside a source tree that declares thegithub.com/buildwarden/buildwardenmodule builds its relay and executor from that tree with a VM driver or withrelay_image = "dev", and a repository can declare that module; - a repository's file can name any host directory as an upstream CA path and
turn on
verbose. The build's log then names that directory's entries and what was skipped there (see Upstream CA paths). Where others can read the log, name the file, or pin the paths withWARDEN_UPSTREAM_CA_CERTS. - the repository's
warden.tomlis the one file warden reads that nobody named, so it is read with two limits: it must be a regular file once links are followed, and it is read up to 1 MiB. A repository whosewarden.tomlis, or links to, a device, a pipe or a file that gives more than 1 MiB stops withnot a regular fileorlarger than 1 MiBrather than hang the build. A file you name has neither limit, so name a file you control.
Moving from ~/.config/warden/config.toml
Earlier releases also read ~/.config/warden/config.toml
(%USERPROFILE%\.config\warden\config.toml on Windows) and merged it under
./warden.toml. It is no longer read. While it exists, build, shell,
clean, doctor, setup and image prepare stop with an error that names
it, before any setting of the config file is applied, rather than drop its
settings without a word:
[warden] ERROR: /home/you/.config/warden/config.toml is no longer read: warden reads one config file, ./warden.toml or the one --config or WARDEN_CONFIG names
To fix: move its settings into the warden.toml you build with, or into the environment (WARDEN_DRIVER, WARDEN_CTR_CLI, WARDEN_IMAGE, WARDEN_UPSTREAM_CA_CERTS), and delete it; or name it as the config file with --config or WARDEN_CONFIG (it is then the only one read: ./warden.toml is not)
The file is not opened. Naming it with --config or WARDEN_CONFIG keeps
your settings as they were, and it is then the only file read. Under sudo
the variable is dropped (see above), so the error comes back there; the fix
then adds: pass --config, or run sudo --preserve-env=WARDEN_CONFIG.
WARDEN_UPSTREAM_CA_CERTS used to add its paths to [relay] upstream_ca_certs; it now replaces them. While both are set, build,
shell and doctor stop with an error that says so: put every path in one
of the two.
Full Reference
[runtime]
driver = "" # Build driver: container, qemu, vz, hyperv, firecracker,
# or the name of another driver binary
# (default: the container driver)
[build]
dockerfile = "" # Override Dockerfile discovery
context = "" # Override context directory
output_dir = "warden-output" # Where build results are written
compress = true # Compress ledger and payloads with zstd
capture = "" # Payload capture mode:
# "" or "none" = no capture
# "headers" = save request/response headers
# "bodies" = save request/response bodies
# "all" = save both
tmpdir = "" # Where each build's private work dir is created
# ("" = the OS temp dir; --tmpdir wins)
teardown_timeout = "60s" # How long a driver binary is given to tear a build
# down when asked to stop, and then its reap;
# a Go duration from "1s" to "1h". A value that
# does not parse or is out of range is refused as
# the file loads. No flag, no variable
[relay]
upstream_ca_certs = [] # Files or directories of PEM certificates the relay
# also trusts upstream (see Upstream CA paths)
system_ca_bundle = true # With upstream_ca_certs: keep the relay's own system
# roots beside them (false: only the listed ones)
[vm] # Defaults for the VM-driver flags; a flag always wins
cpus = 0 # Build VM vCPUs (0 = per-driver default; vz, qemu,
# hyperv and firecracker)
memory_mb = 0 # Build VM memory in MiB (0 = per-driver default)
build_link = "100.127.255.252/30" # advanced: the relay-to-build link, a /30 (every VM
# driver; see Advanced options; --build-link wins)
dns = ["10.20.0.53"] # the relay's upstream DNS servers, in order, used exclusively
# (every VM driver; unset: the host's; see Advanced options)
[output]
color = "auto" # Color mode: auto, always, never
verbose = false # Verbose output (shows container runtime commands)
# The drivers' own keys, read by the selected driver only (see Driver settings)
[driver] # Common keys, for every driver that honours them
image_refresh_after = "7d" # qemu, hyperv: re-prepare the base in the background at this age
image_min_grace = "1d" # qemu, hyperv: refuse builds with less evaluation grace left
[driver.container]
cli = "finch" # Container runtime: finch, podman or docker, and nothing
# else (unset = detected; see The container runtime)
relay_image = "" # Relay image override
# "" = pull ghcr.io/buildwarden/relay:latest (release builds)
# or build from source (dev builds)
# "dev" = always build from source
# "ghcr.io/buildwarden/relay:v0.2.0" = specific version
start_finch_vm = true # finch on macOS and Windows: a build starts its stopped VM
# (finch vm start) and says so; false = never, the build
# fails at its first call to finch (see finch's VM)
[driver.hyperv]
network = "" # durable network name (switches <name>-0.., NAT <name>-nat)
windows_image = "" # base image URL or local path (default: Microsoft's
# current Server 2025 evaluation download)
windows_image_update = "auto" # "auto" picks up new media at refresh; "reuse" keeps it
image_refresh_after = "7d" # overrides [driver] image_refresh_after for hyperv only
Driver settings
warden reads its own keys: [runtime] driver, [build], [relay], [vm] cpus, memory_mb, build_link and dns, and [output]. Every other key is
a driver's, and only the selected driver reads it, in its own process for a
driver binary, from the config file warden read (warden passes the file's
path on). A driver's key that the run does not use is not read, so one file
can hold the settings of several drivers.
[driver]holds the common keys, which the driver contract names for every driver:image_refresh_afterandimage_min_grace(each an age: a Go duration such as"36h", or days such as"7d"). A driver reads the ones it honours (qemu and hyperv honour both) and ignores the rest.[driver.<name>]holds the keys of the driver<name>and its overrides of the common keys. It is read before[driver]: with[driver] image_refresh_after = "3d"and[driver.hyperv] image_refresh_after = "30d", hyperv uses 30 days and qemu 3.
For one setting the order is: the driver's flag, then its environment
variable (WARDEN_CTR_CLI, WARDEN_IMAGE), then [driver.<name>], then
[driver] for a common key, then the driver's default. A value found at
one place that the driver cannot use is an error naming that place; the
next place is not tried.
Renamed keys
Seven keys moved into these tables. Each old name is still read, as the key itself, until BuildWarden 1.0, and only by the driver it belongs to; a file that sets one prints one warning line that names the new key. A file that sets both names of one key is refused, with both named.
| Old name | New name | Driver |
|---|---|---|
[runtime] cli | [driver.container] cli | container |
[runtime] relay_image | [driver.container] relay_image | container |
[vm] image_refresh_after | [driver] image_refresh_after | qemu, hyperv |
[vm] image_min_grace | [driver] image_min_grace | qemu, hyperv |
[vm] network | [driver.hyperv] network | hyperv |
[vm] windows_image | [driver.hyperv] windows_image | hyperv |
[vm] windows_image_update | [driver.hyperv] windows_image_update | hyperv |
An old name stands where its new name stands: [vm] image_refresh_after is
read below [driver.hyperv], like [driver] image_refresh_after.
Keys are case-sensitive
A driver's keys are read exactly as written above. A driver's key in another letter case, in its table or in its own table's name, is refused by the driver that owns it, naming the file, the spelling and the key to write, before its value is looked at:
[warden] ERROR: /src/repo/warden.toml: [Runtime] CLI: keys are case-sensitive, and the container driver reads [driver.container] cli (old name [runtime] cli)
To fix: write it as [driver.container] cli
Two spellings of one key in one table are refused the same way. A key that is no driver's key in any letter case is ignored, as is another driver's key while that driver is not selected. warden's own keys are still read in any letter case.
Upstream CA paths
[relay] upstream_ca_certs, or WARDEN_UPSTREAM_CA_CERTS, which replaces
it, lists extra roots the relay trusts for its upstream TLS connections,
beside its own system roots (which system_ca_bundle = false drops). They
are read once, by build, shell and doctor, before anything is created;
clean, setup and image prepare do not read them.
Each path is a file or a directory; a relative one is relative to the working directory.
- A file named directly is read whatever kind of file it is, a pipe
included (
WARDEN_UPSTREAM_CA_CERTS=<(cat a.pem b.pem)works). A path that never ends, or a pipe nobody writes to, makeswardenwait. - A directory means its files whose names end in
.pem,.crtor.cer, in any letter case, one level deep and in name order; links are followed. A subdirectory, a link to one and an entry with another ending are not read, and an entry that is not a regular file (a pipe, a socket, a device) is not opened.
Every valid PEM certificate found is sent to the relay, and nothing else: no private key, no other block, no text between blocks. What is not sent is skipped, with a line that says why, and the build goes on with the certificates the path does give:
- a private key (a block whose type ends in
PRIVATE KEY), which gets awarning:line because a key does not belong in a file of trust roots; - another kind of block (a
CERTIFICATE REQUEST, anX509 CRL), or aCERTIFICATEblock with PEM headers; - a damaged block (its BEGIN line is not complete, it has no END line, its END line is for another type, or its body is not base64);
- a certificate Go's X.509 parser refuses, with the parser's reason;
- in a directory, a DER-encoded file (convert it with
openssl x509 -inform der -in <file> -out <file>.pem), a file with no PEM block, one whose blocks hold no certificate to send, one that cannot be read, and a link to a file that does not exist.
The lines go to stderr with build and shell (after the config: line;
--quiet does not remove them) and into the report with doctor. Every skip
and one line per path are printed on every run; --verbose adds one line per
file of a directory that gives a certificate and one per entry that was not
read:
[warden] warning: upstream CA /etc/warden/site.pem: block 2 is an RSA PRIVATE KEY and is not sent to the relay; a private key does not belong in a file of trust roots
[warden] upstream CA /etc/warden/site.pem ([relay] upstream_ca_certs): 1 certificate to send; 1 block skipped
[warden] upstream CA /etc/warden/roots/corp.cer: skipped: DER-encoded, and only PEM is read (to convert: openssl x509 -inform der -in <file> -out <file>.pem)
[warden] upstream CA /etc/warden/roots (WARDEN_UPSTREAM_CA_CERTS): 3 certificates to send from 2 files; 1 file skipped; 4 other entries not read
A path that does not exist, cannot be read or gives no certificate at all is
an error, before anything is created; doctor reports it as BLOCKED and
exits 1. An empty entry (a doubled or trailing separator, "" in the list)
is an error too, never read as the working directory.
The lines describe the host: for each path whether it exists, the counts, the
name of each file skipped and why, and with --verbose the name of every
entry of a named directory. A repository's warden.toml can name any host
directory and turn verbose on; see Building a repository you do not
control. Names and other strings
that do not come from warden are printed with control characters escaped.
Environment Variables
A variable replaces the config file's key, and a flag replaces the variable: flag, variable, file, default.
| Variable | Overrides | Description |
|---|---|---|
WARDEN_DRIVER | runtime.driver | Override driver selection |
WARDEN_IMAGE | driver.container.relay_image | Relay image override (container driver) |
WARDEN_CTR_CLI | driver.container.cli | Container runtime: finch, podman or docker (see The container runtime) |
WARDEN_CONFIG | the config file | The config file to read when --config is not given (see The config file); set it absolute |
WARDEN_UPSTREAM_CA_CERTS | relay.upstream_ca_certs | Replaces relay.upstream_ca_certs; paths separated by : (; on Windows) |
NO_COLOR | output.color | Disable colored output (any value) |
WARDEN_VERBOSE | output.verbose | Enable verbose mode (any value) |
CLI Flags
A driver's flags are the selected driver's: they are accepted only when it
is selected, and --help lists them in a section of their own (Flags of driver "container":). A flag that neither warden nor the selected driver
takes is refused as an unknown flag for that driver.
| Flag | Scope | Description |
|---|---|---|
--config | Global | The config file to read, the only one that is (see The config file) |
--driver | Global | Driver to run: container, qemu, vz, hyperv, firecracker, or the name or path of a driver binary |
--runtime | container driver: build/shell/doctor/clean | Container runtime: finch, podman or docker (see The container runtime) |
--color | Global | Color mode |
-v, --verbose | Global | Verbose output |
-o, --output | build/shell | Output directory |
--capture | build/shell | Payload capture mode |
--no-compress | build/shell | Disable compression |
--timeout | build/shell | Maximum build duration (all drivers) |
--image | build/shell | Base disk image for the build VM (VM drivers) |
--script | build/shell | Build script (VM drivers) |
--guest-os | build/shell | Guest OS: linux (default) or windows (qemu, hyperv) |
--cpus | build/shell | Build VM vCPUs (VM drivers) |
--memory | build/shell | Build VM memory in MiB (VM drivers) |
--network | hyperv driver: build/shell/doctor/setup | Durable switch to reuse |
--keep-vms | build/shell | Leave VMs and work dir for inspection (VM drivers) |
--tmpdir | build/shell | Directory for each build's private work dir (default: OS temp dir) |
--build-link | build/shell/doctor | Advanced: the VM drivers' relay-to-build link, a /30 (see Advanced options) |
-q, --quiet | build | Do not echo the guest build console |
Advanced options
The build link ([vm] build_link, --build-link)
Every VM driver joins the build VM to the relay over one private link, a
/30: the relay is its first host and the build VM its second. The default
is 100.127.255.252/30 (relay 100.127.255.253, build VM
100.127.255.254), the last /30 of RFC 6598 shared address space, which no
common LAN, VPC or resolver plan uses. The container driver has its own
per-build network and ignores a valid setting. A malformed [vm] build_link
is refused when the config file loads, by every command and with every
driver (container included), as any config error is.
Inside the relay the link is a connected route, so an upstream address inside it (a resolver, a private mirror, a collector) is sent to the build VM instead of upstream. Move the link only when your network uses the default anyway:
[vm]
build_link = "100.126.255.252/30"
or, for one command, --build-link 100.126.255.252/30 on build, shell
or doctor. Precedence: the flag, then the config file, then the default.
warden doctor prints the link and where it came from.
The value must be an IPv4 network address with prefix exactly /30
(100.126.0.1/30 is refused with "did you mean 100.126.0.0/30"), outside
0.0.0.0/8, loopback, link-local, multicast and class E, and disjoint from
the ranges BuildWarden uses itself: the container driver's 100.64.87.0/24,
Firecracker's upstream 100.64.88.0/22 and qemu's user-mode 10.0.2.0/24. A
key is checked when the file loads and the flag when it is read, before any
work. Hyper-V's NAT is not a fixed range: it is read back from the host, so
the hyperv driver checks the link against the host's NAT at build start,
before the seed ISO or any per-build network, and in doctor, naming it (or the default 192.168.240.0/20 when the host has no NAT
yet, which is where a build would make one). Every VM build
also refuses a link that holds an address of one of the host's interfaces;
a host network that merely contains the link (a /10 CGNAT WAN, say) is
only a doctor warning.
The link reaches the relay in its claim and the build VM in its seed, its kernel command line or the relay's DHCP lease, per build: changing it needs no rebuild, refresh or re-prepare. The one-time upgrade to this scheme is in Drivers.
The relay's resolvers ([vm] dns)
The relay answers the build's DNS and resolves its own upstream connections through one list of upstream DNS servers, fixed when the build starts and sent to the relay in its claim. Every VM driver sends one:
-
Unset (the default): the host's resolvers. Each driver reads the host's DNS servers and keeps those its relay can reach: hyperv the IPv4 servers of the default route's interface, firecracker
/etc/resolv.conf(or systemd-resolved's upstreams), qemu the host's/etc/resolv.conf, vz the Mac's/etc/resolv.conf. A loopback or link-local server, one inside the build link and, per driver, one on the host itself or inside its NAT are left out; when none is left the build is refused, naming each server and why, with the fix (an off-host DNS server on the host, or[vm] dns). No public resolver stands in. -
Set: used exclusively. The listed servers, in order, are the relay's only resolvers: the host's are not read, added or tried when the listed ones fail.
[vm] dns = ["10.20.0.53", "10.20.0.54"]The relay asks the first server and the next when one does not answer in time, as
resolv.conf'snameserverlines are asked; that is the one fallback, and it stays inside your list.
The key has no flag or environment variable: the config file's value is the
one used. Each entry must be an IPv4 address, not
unspecified, multicast or broadcast, and the list must not be empty
(dns = [] is refused: remove the key to use the host's resolvers); this is
checked when the file loads, by every command. At build start and in
warden doctor, the driver refuses an entry its relay cannot reach (a
loopback server for the VM drivers whose relay is a VM, one inside the build
link, and so on), naming it, rather than drop it. The container driver
ignores [vm] and its relay uses its container's resolvers. warden doctor
prints the resolvers and where they came from.
The container runtime
The container driver runs one of three runtimes: finch, docker or
podman. The runtime setting takes one of those three names, written as
they are here (lower case, no directory, no .exe), or is left unset. The
values are the same wherever the runtime is named. The highest of these
levels that names a runtime is the one in effect:
--runtimeWARDEN_CTR_CLI[driver.container] cliin the config file, or its old name[runtime] cli(read until 1.0; see Renamed keys)
An empty --runtime or WARDEN_CTR_CLI is not set, and the next level is
read. cli = "" in the file is not set either, and the runtime is detected.
The container driver (warden-driver-container) runs the runtime by its
name, which is looked up on PATH. A
runtime installed outside PATH needs its directory added to PATH.
Detection
When no level names a runtime, BuildWarden probes finch, then podman,
then docker. The first one that is up, its check answering within 3
seconds, is used, by every command, warden doctor included. For docker
the check is docker version --format '{{.Server.Version}}', and the same
for podman (on Linux, where podman has no server, it answers with its own
version): a query that fails or prints no version means the runtime is not
running. For finch on macOS and Windows it is finch vm status, which
prints the state of finch's VM: Running is up, and anything else is not.
finch version is not used there: it starts a stopped VM before it
answers. On Linux, finch runs without a VM, and its check is finch version.
A runtime that is up is chosen over starting finch's VM: with finch's VM
stopped and podman or docker running, detection uses that one. Only when
none is up, finch is installed and its VM is stopped is finch the runtime,
and the build starts its VM, unless start_finch_vm = false (see finch's
VM).
When both docker and podman are installed and running, and finch is not,
podman is chosen: detection prefers it, as the open-source, free runtime.
Earlier releases probed docker before podman and chose docker there.
To use docker, name it: --runtime docker, WARDEN_CTR_CLI=docker, or
cli = "docker" under [driver.container].
Which commands check the value
Only a command that runs the container runtime checks the setting, and it checks the value in effect:
| Command | The runtime setting |
|---|---|
warden build, warden shell, warden doctor and warden clean with the container driver | checked |
Every command with a VM driver (clean with qemu or vz no longer removes containers); setup; image prepare | not read |
So one warden.toml can hold the settings of several drivers:
warden build --driver qemu does not fail on a cli it does not use.
--runtime is the container driver's flag: with another driver, or on a
command that selects no driver, it is an unknown flag. A value that a higher
level replaces is not checked either. With an unsupported cli in
./warden.toml, warden build --runtime docker builds with Docker, which is
also the way to build someone else's repository without editing its file.
A value that is not supported
A value in effect that is not finch, podman or docker is an error. The
command stops before it looks up or runs anything and before it makes an
output directory, a container or a network, and warden exits 1. The message
says where the value was set and what to change:
[warden] ERROR: [runtime] cli in /src/repo/warden.toml is "dokcer"; the container driver supports finch, podman and docker
To fix: set it to finch, podman or docker, or remove it; --runtime with one of those replaces it for one command
No other value is tried in its place: neither a lower level's nor a detected runtime.
A runtime that is not installed or not running
warden build and warden shell also refuse a runtime that a level names
but that is not on PATH. The container driver refuses it before the build
starts: no output directory, container or network is made, and warden
exits 1. The message names where the runtime was named, and the fix is to
install it, or to name another:
[warden] ERROR: WARDEN_CTR_CLI names the container runtime podman, which is not installed (not found on PATH)
To fix: install Podman, or set WARDEN_CTR_CLI to another runtime, or unset it
A named runtime that is on PATH but not running (its VM or daemon is
stopped) is not checked before the build: the build's first call to it, the
engine-version query above with up to 10 seconds, fails, and warden exits
1 with the fix to start it. The output directory is left, as after any
failed build:
[warden] ERROR: container runtime podman is installed but not running (`podman version --format '{{.Server.Version}}'` failed)
To fix: start its machine: podman machine start (or podman machine init the first time); warden doctor checks it
warden doctor asks a named runtime the same query and waits up to 10
seconds. A runtime that is not installed or not running blocks it with the
errors above: it exits 1 and prints no ok. Detection is not tried in its
place. finch's VM is the exception: see the next section.
When no level names a runtime, warden doctor detects it as a build does,
3 seconds per candidate, so it reports the runtime a build would use. When
detection finds none running, doctor asks each installed one again, in the
same order, waiting up to 10 seconds. The first that answers is running but
too slow for detection, and doctor is blocked with the fix to name it:
[warden] ERROR: container runtime podman is running but answered after more than 3 s, so builds skip it
To fix: name it: --runtime podman, WARDEN_CTR_CLI=podman or [driver.container] cli = "podman"
When none answers, detection's own error says that none is running, with
the fix to start it. At most, doctor waits 45 seconds: 3 seconds for each
of the three runtimes and then 10 seconds for each again, 39 seconds, plus
up to 1 second per query for the runtime's CLI to release its output.
finch is asked again only when its finch vm status did not answer in
time: a VM whose state finch gave is not slow.
finch's VM
On macOS and Windows, finch runs its containers in a VM. A build whose runtime is finch starts its stopped VM, says so, and shows finch's output:
[warden] finch's VM is stopped; starting it (finch vm start), as [driver.container] start_finch_vm is true (the default)
INFO[0000] Starting existing Finch virtual machine...
The start is the build's first call to finch, after the output directory is
made, whether finch was named or detected (detected only when no other
runtime is up). It has no time limit of warden's own: finch vm start ends
when the VM is up or finch gives up, and Ctrl-C stops it. The VM is left
running after the build, as finch vm start by hand leaves it.
start_finch_vm = false under [driver.container] turns that off. The VM
is never started: a named finch fails at the build's first call to it, as
for any runtime that is down, leaving the output directory; a detected one
is refused before the build starts. The message names the setting and the
file:
[warden] ERROR: container runtime finch is installed but its VM is not running (`finch vm status`: Stopped)
To fix: start its VM: finch vm start; a build starts it itself when [driver.container] start_finch_vm is true, and it is false in /src/repo/warden.toml
The key has no flag and no environment variable. To avoid finch altogether, name another runtime. A VM that is not stopped is never started, whatever the setting says:
[warden] ERROR: container runtime finch is installed but has no VM (`finch vm status`: Nonexistent)
To fix: create it: finch vm init
[warden] ERROR: container runtime finch's VM did not start (`finch vm start` exit status 1)
To fix: start it by hand and see finch's error: finch vm start
A finch vm status that fails, or prints a state other than Running,
Stopped or Nonexistent, is an error that quotes what it printed, with
the fix check finch: finch vm status.
warden doctor never starts the VM. With the VM stopped and the setting
true (or unset), finch is the runtime a build would start, so doctor reports
it and is not blocked:
container runtime: finch
finch's VM is stopped; a build starts it ([driver.container] start_finch_vm is true, the default); to start it now: finch vm start
ok
With the setting false it is blocked with the error above, as the build
would fail. A stopped VM whose finch vm status answered only doctor's
second, 10-second ask is one a build that names no runtime skips, as for
any runtime too slow for detection, so doctor is blocked with the fix to
name it:
[warden] ERROR: container runtime finch answered `finch vm status` (Stopped) after more than 3 s, so builds skip it
To fix: name it: --runtime finch, WARDEN_CTR_CLI=finch or [driver.container] cli = "finch"; a build that names it starts its VM
Docker, podman and finch on Linux, which has no VM, ignore the key.
A path, or another runtime
Earlier releases ran whatever program the setting named, from every level.
A repository's warden.toml could therefore make warden run a program of
the repository's own on the host. The setting is now limited to the three
runtimes the container driver supports, and these values stopped working:
| Before | Now |
|---|---|
--runtime /path/to/docker, WARDEN_CTR_CLI=/usr/local/bin/podman, or cli = "/opt/homebrew/bin/finch" in a config file | Refused. Name the runtime, and put its directory on PATH |
--runtime docker.exe, Docker | Refused. Write docker |
WARDEN_CTR_CLI=nerdctl, or another runtime's program | Refused. There is no supported way to use another runtime with the container driver |
A wrapper script, by path or by name, that only sets variables and then runs a supported runtime (docker-ci setting DOCKER_HOST) | Refused. Name the runtime and set the wrapper's variables (DOCKER_HOST, DOCKER_CONTEXT, CONTAINER_HOST) in the environment |
A wrapper that does anything else: sudo docker, podman --remote, nerdctl --namespace, a script that picks a runtime | Refused. There is no supported replacement |
cli = "./tools/docker" or cli = "sh" in a project's warden.toml | Refused. This is the hole the limit closes |
A value in one of these forms gets a message that says what to change in
place of the list of supported values: a supported runtime in another letter
case or with .exe, a path to one, nerdctl, and a path to any other
program. For example:
[warden] ERROR: WARDEN_CTR_CLI is "/opt/homebrew/bin/docker"; the container runtime is named, not given as a path
To fix: set WARDEN_CTR_CLI to docker; warden looks docker up on PATH, so if it is installed outside PATH, add its directory to PATH
A wrapper named without a path cannot be told from a typing error and gets the error of the section above.
The container driver runs the runtime by its name with warden's arguments
and nothing else, so a wrapper that added sudo or arguments has nothing to
move to: the runtime has to be reachable by its name alone. For nerdctl,
Finch is the supported runtime built on it. A file named docker on your own
PATH that runs something else is run as docker; that arrangement is
neither tested nor supported.
Driver Selection
When driver is empty (the default), the container driver is used. Use --driver or WARDEN_DRIVER to select another; either may also give the path of a driver binary, which driver in a config file may not (Drivers). The bundled drivers:
container— Unprivileged container with iptables isolation (default)qemu— Two-VM topology, cross-platform, requiresqemu-system-*vz— macOS/arm64 only, uses Virtualization.framework; needs awardenbuilt from source (a released one has no vz driver)hyperv— Windows, two-VM topology on Hyper-V with a host-only NAT switchfirecracker— x86_64 Linux with KVM, two Firecracker microVMs on a network slot made bysudo warden setup --driver firecracker; no config keys of its own
Relay Image
For release builds (warden --version shows a version tag), the relay is pulled as a pre-built container image. For development builds (version = "dev"), it's compiled from source.
Override with [driver.container] relay_image (or its old name [runtime] relay_image), or WARDEN_IMAGE, which replaces it:
"dev"— force build from source (requires Go toolchain, and awardenrun from its source tree:dist/wardenaftermake build)"ghcr.io/buildwarden/relay:v0.1.0"— pin a specific version""— automatic (pull for releases, build for dev)
Any other value must be shaped like an image reference: one that starts with
- or holds a space or a control character (any character that does not
print, a right-to-left override or a zero-width space among them) would reach
the container runtime's command line as an option. It is refused, with the container
driver, by build, shell and doctor before anything is created:
[warden] ERROR: [driver.container] relay_image in /src/repo/warden.toml is "--volume=/:/host": not an image reference
To fix: set it to an image reference such as ghcr.io/buildwarden/relay:v0.2.0 or to "dev", or remove it
Nothing more of a reference is checked: the runtime's own error says what is wrong with a well-shaped one.
CLI Reference
warden build
warden build [path] [flags]
Run an audited build with full network recording. The path argument can be a
directory (default: current directory), a specific Dockerfile, or, for VM
drivers, a build.sh / build.ps1 script. All network traffic during the
build is recorded to a cryptographically signed ledger.
build and shell share one flag set. Every driver accepts it; each driver
rejects only the flags it genuinely cannot use.
Flags:
-o, --output <dir>— Output directory (default:warden-output)--capture <mode>— Capture payloads: none, headers, bodies, all--no-compress— Disable zstd compression of the ledger and CA certificate--timeout <duration>— Maximum build duration (e.g. "10m", "1h"); all drivers--script <path>— Build script to run (VM drivers)--image <path>— Base disk image for the build VM (VM drivers)--guest-os <os>— Guest OS for VM drivers:linux(default) orwindows--cpus <n>— Build VM vCPUs (VM drivers; default per driver)--memory <MiB>— Build VM memory in MiB (VM drivers; default per driver)--network <name>— Pre-provisioned network to reuse (hyperv: the durable network fromwarden setup, whose build switches are<name>-0and up)--keep-vms— Leave VMs, disks and the work dir in place for inspection (VM drivers)--tmpdir <dir>— Directory each build's private work dir is created in (default: the OS temp dir, which honoursTMPDIR)--build-link <cidr>— Advanced: the VM drivers' relay-to-build link, a/30(default:[vm] build_link, then100.127.255.252/30; see Configuration)-q, --quiet— Do not echo the guest build console (still captured tobuild-output.log)
The container driver refuses the VM-only flags (--script, --image, --cpus,
--memory, --keep-vms, --build-link). A driver's own flags, such as the
container driver's --runtime and hyperv's --network, are taken only when
that driver is selected, and --help lists the selected driver's under
Flags of driver "<name>":; with another driver each is refused as unknown flag --network for driver "vz", with the fix see 'warden build --driver vz --help' for the flags this driver takes (firecracker builds take a network
slot made by warden setup).
--guest-os windows is supported by --driver qemu and --driver hyperv;
--driver firecracker runs Linux guests only.
Defaults for --cpus and --memory come from the [vm] section of
warden.toml, and for --network from [driver.hyperv] network (old name
[vm] network; see Configuration). Per-driver VM defaults: qemu 4 CPU / 4096 MiB, vz 4 / 8192,
hyperv 4 / 4096, firecracker 4 / 4096 (its relay VM: 2 / 256).
With --driver firecracker, --keep-vms leaves both VMs running and their
network slot held, and prints their pids; warden clean --driver firecracker
stops them.
Every build stages its working files (overlay disks, seeds, the container
driver's /.warden tree and relay image context) in its own fresh directory,
warden-<driver>-XXXXXXXX, created like mktemp -d under --tmpdir (or
[build] tmpdir). Nothing is written into the build context, so concurrent
builds of the same directory do not interfere. With a VM-backed container
runtime (finch, Docker Desktop, podman machine) the directory must be one the
runtime's VM shares; the macOS temp dir is shared by all three.
Exit status:
| Exit code | Meaning |
|---|---|
0 | The build succeeded |
| the build's own code | The build script exited non-zero (warden: build FAILED (exit code N)) |
124 | --timeout expired |
130 | Interrupted (Ctrl-C) |
1 | Any other failure. A known cause (missing root or Administrator, unprepared image, absent tool, bad flag) is printed with To fix: <what to do>; only an unexplained failure carries the issue link |
warden shell exits with the shell's own exit status, 130 when
interrupted (Ctrl-C), and 1 when the shell could not be attached or for any
other failure. --timeout does not limit a shell.
Example:
# Container driver (default)
warden build ./my-project -o ./audit-results
# QEMU driver with a cloud image
warden build --driver qemu --image ubuntu-24.04.qcow2 ./my-project
# VZ driver with a macOS build script
warden build --driver vz --script build.sh ./my-project
# Windows build in a sized VM
warden build --driver qemu --guest-os windows --cpus 8 --memory 16384 ./win-project
warden shell
warden shell [path] [flags]
Open an interactive shell in the audited build environment. Useful for
debugging network behavior or exploring what a build fetches. Same flags as
build (minus -q/--quiet). Drivers that cannot attach an interactive session
say so.
warden shell ./my-project
# Now inside the isolated environment — try curl, apt-get, etc.
# All traffic is recorded to the ledger.
warden inspect
warden inspect <path> [flags]
Verify and display a build ledger.
Arguments:
path— Ledger file or output directory (auto-findsledger.zstorledger)
Flags:
--json— Output as JSON--verbosity <n>— Detail level: 0=compact, 1=tree, 2=full--extract <dir>— Extract captured payloads to a directory--verify-disks— Re-hash each VM disk layer the environment record names (reads every byte of every base image)
Inspect also decodes the build environment record and checks
environment.json against it; a mismatch fails verification. For VM builds it
lists the disk layers with their hashes and provenance (downloaded and pinned,
prepared by warden, or local).
warden inspect warden-output --json | jq '.summary'
warden inspect warden-output --json | jq '.environment'
warden inspect --verify-disks warden-output
warden image
Prepare and list build-guest base images for the VM drivers.
warden image prepare
warden image prepare [source] [flags]
Acquire, verify and ready a base image for a VM driver. One verb covers every
driver; it replaces the old image restore, image fetch, and vz-only
image prepare. The driver comes from --driver (or warden.toml); --os
defaults per driver (vz: macos, qemu and firecracker: linux, hyperv: windows). [source] (or
--source) is a local path or URL.
| Driver / OS | Source | Behavior |
|---|---|---|
vz / macos | IPSW URL, a local .ipsw file, or a prepared image directory in ~/.cache/warden/images (or its disk.img). No source: the active image | Run under sudo. With no source, refreshes the active image (the one builds use without --image) in place, with no IPSW download, and warns when a newer macOS is available; with no image prepared yet, restores the latest supported IPSW. An IPSW whose image is already prepared, and a prepared image directory, are refreshed in place; another IPSW is restored. A local .ipsw is read in place and kept; a downloaded IPSW is deleted from the cache once its image is prepared. The result becomes the active image. --update moves to the latest supported IPSW |
qemu / linux | cloud image ref (alpine:3.21, ubuntu:24.04, debian:bookworm) or qcow2 | Downloads and verifies the cloud image |
firecracker / linux | cloud image ref (default ubuntu:24.04), or a local qcow2 or raw image | Downloads the cloud image if needed (as qemu does), checks it with qemu-img info (a backing file, an external data file or another format is refused), and converts it once to the raw image builds copy, in ~/.cache/warden/firecracker/images |
qemu / windows | Windows install ISO (required the first time) | Unattended install ending in sysprep /generalize (skipped if already installed unless --force), then prepares the layer builds boot from. With no source, re-prepares |
hyperv / windows | Windows Server evaluation VHDX: URL, or a local file registered in place (default: [driver.hyperv] windows_image, else Microsoft's current Server 2025 evaluation download) | Fetches or registers the base, then prepares the layer builds boot from. With no source it is the refresh: re-checks a downloaded base for new media and re-prepares |
Flags:
--os <os>— Guest OS: macos, linux or windows (default per driver)--source <path|url>— Image source (same as[source])--sha256 <hash>— Expected SHA256 of the image; verified (the digest of what was used is always recorded)--force— Re-acquire even if a valid cached copy exists--name <n>— Registry name of the image (hyperv; default windows-server-2025)--edition <e>— Windows edition / install.wim image name (qemu windows)--virtio <v>— virtio-win driver ISO path or URL (qemu windows)--arch <a>— Guest arch: arm64 or amd64 (default host arch)--keep-vms— Leave the prepare VM and its disk for inspection (hyperv)--update— Move to the newest supported OS release: restore it, or refresh its image in place when it is already prepared, and make it active (vz only; takes no source; refused on other drivers)
sudo warden image prepare --driver vz
sudo warden image prepare --driver vz --update
sudo warden image prepare --driver vz ~/Downloads/UniversalMac_27.2_26B123_Restore.ipsw
sudo warden image prepare --driver vz ~/.cache/warden/images/macos-90a1b1f94f64b00a
warden image prepare --driver qemu ubuntu:24.04
warden image prepare --driver firecracker ubuntu:24.04
warden image prepare --driver qemu --os windows --source Win11_Arm64.iso
warden image prepare --driver hyperv --source https://.../server2025.vhd
warden image list
warden image list
List prepared base images for every driver. Every prepared vz image is
listed, the active one (used by builds without --image) first and marked
active, the others older, each with the IPSW it was restored from when
that was recorded.
warden image list
# vz macos /Users/me/.cache/warden/images/macos-a139c218a2010753 active UniversalMac_27.2_26B123_Restore.ipsw
# vz macos /Users/me/.cache/warden/images/macos-90a1b1f94f64b00a older UniversalMac_27.0.1_26A100_Restore.ipsw
# qemu linux /Users/me/.cache/warden/images/alpine.qcow2
# firecracker linux /home/me/.cache/warden/firecracker/images/ubuntu_24_04-1a2b3c4d5e6f.raw
# hyperv windows base C:\...\server2025.vhdx (pinned)
# hyperv windows prepared windows-server-2025-20261020T193301Z.vhdx, 2.0d old,
# evaluation grace ends 2026-10-30 19:33Z (8.0d left)
warden image verify
warden image verify [--driver <driver>]
Re-hash, in full, every base-image file a VM driver has recorded in its layer
cache: the hashes builds write into the ledger's environment record. Fetch and
prepare record each image's hash and provenance once; builds reuse it while the
file's size and modification time are unchanged. verify reads every byte
instead, re-records a changed file as local (its download/prepare provenance no
longer applies), drops missing files, and exits 1 if anything drifted. Without
--driver it checks every VM driver's cache on this host.
warden image verify --driver hyperv
# hyperv ok C:\...\images\windows-server-2025.vhd
warden doctor
warden doctor --driver <name> [--build-link <cidr>]
Read-only preflight for the selected driver. The report's first line says
which config file was read and how it was chosen, the same config: line
the other commands print on stderr
(Configuration). It then checks a container runtime
(container), qemu-system-* + qemu-img and relay VM assets (qemu), Apple
Silicon macOS, a warden built with cgo (a released binary is not, and has no
vz driver) and the virtualization entitlement (vz), or the hypervisor and
management stack and the privilege tier this process holds (hyperv). For
firecracker it checks /dev/kvm, the firecracker binary (v1.17.0 or later),
the boot assets, the disk-image tools (qemu-img, genisoimage; a warning
only), the network slots owned by this user and their sysctls, firewalld, an
off-host upstream resolver, reflink support on the cache filesystem (a warning)
and VMMs left on a slot with no warden (a warning). Run as root (sudo warden doctor --driver firecracker) it also checks the warden_fc bridge table, that
each WARDEN-FC jump is first in its chain, and the FORWARD policy, and counts
the slots, /dev/kvm access (kvm group membership) and leftover VMMs of the
user who ran sudo, skipping the reflink probe so nothing is written into that
user's cache.
With the container driver, a runtime in effect that is not finch, podman
or docker fails doctor with the error a build would get
(Configuration), and so does a
relay image that is not shaped like an image reference
(Configuration). Doctor is also the
runtime's health check: it asks the runtime it would use, named or
detected, for its engine's version (docker version --format '{{.Server.Version}}', podman version --format '{{.Server.Version}}', or finch version on Linux) and waits up to 10
seconds. A runtime that is not on PATH, or whose engine is down or does
not answer in that time, fails doctor with the fix to install or start it.
finch on macOS and Windows is checked with finch vm status instead, the
state of its VM, and doctor never starts the VM. A stopped VM with
[driver.container] start_finch_vm true (the default) is the one a build
would start, so doctor reports it on a line under container runtime: finch, naming the setting and finch vm start, and is not blocked: it
prints ok and exits 0. With start_finch_vm = false a stopped VM fails
doctor, as it would fail the build; a VM that does not exist
(Nonexistent), or a state finch does not give, fails it either way.
A stopped VM whose state finch gave only after detection's 3 seconds fails
doctor with the fix to name finch, as builds that name no runtime skip it
(Configuration).
With upstream CA paths configured (WARDEN_UPSTREAM_CA_CERTS, else [relay] upstream_ca_certs), every driver's doctor reads them as a build would and
prints the same lines in its report: each block or file that is skipped, with
its reason, and each path's count of certificates to send. A CA path a build
would refuse (it does not exist, cannot be read or gives no certificate) is
upstream CA: BLOCKED and fails doctor
(Configuration).
Every VM driver's doctor also prints its build link and where it came from
(build link 100.127.255.252/30 (default), the config file's name such as
warden.toml, or --build-link), whether a host interface overlaps it (an address inside the
link is BLOCKED, since every build would refuse it; a host network that only
contains it is a warning), and the state of each launcher asset's
link-channel stamp: current, or missing/stale with the one-time rebuild
(the qemu and Firecracker direct-boot initramfs, the Hyper-V relay boot VHDX,
the vz prepared image). A missing or stale stamp on the Hyper-V relay boot
VHDX or the vz prepared image is BLOCKED and fails doctor, since every build
of that driver uses the asset; on the direct-boot initramfs, which only direct
boot uses, it is reported only. --build-link checks a value before you configure it;
the container driver refuses it.
Every VM driver's doctor also prints the relay's upstream resolvers and their
source ([vm] dns, or the host source it read them from), or the refusal a
build would get, which is BLOCKED and fails doctor. The hyperv doctor adds a
Build network block: the NAT's name, prefix and host IP as read back from
the host (or the NAT a build would make), a NAT prefix that overlaps the build
link (BLOCKED, naming that NAT, or the default prefix when the host has none
yet), any other address on the NAT's vNIC (a warning naming the
Remove-NetIPAddress that removes it; two in the NAT prefix leave the host IP
ambiguous, which is BLOCKED), and for the durable strategy each slot switch, free or in use by the VMs attached to it, or a missing-slots line naming warden setup --driver hyperv.
Exits non-zero when a required capability is unmet, so it works as a CI or agent gate.
Replaces the old warden hyperv doctor.
warden setup
warden setup --driver <name> [flags]
Idempotent host preparation. Hyper-V and Firecracker need it.
--driver hypervcreates the durable network builds reuse:--slotsPrivate build switches (default 4) named<network>-0to<network>-<N-1>(--network, defaultwarden-dev), one per concurrent build, plus an Internal NAT switch, host IP and NAT rule for relay egress. Slot switches above--slotswith nothing attached are removed, and the single<network>Private switch of earlier setups is retired when nothing is attached to it; either refuses, naming the VMs, while one is in use. Re-run it after upgrading from a warden whose setup made that single switch: durable builds refuse to start until the slots exist. Run once from an elevated terminal; afterwards builds run without elevation.--driver firecracker(as root, withsudo) creates--slotsnetwork slots owned by the user who ran sudo: per slot a bridge and three TAPs with their sysctls, plus thewarden_fcbridge table and theWARDEN-FCiptables and ip6tables chains, andnet.ipv4.ip_forward=1last. It refuses, printing the fix, when the filter FORWARD policy is ACCEPT, firewalld is running, or an nftables forward chain drops by default, and while any slot is in use (a VM has its TAPs open, or a build holds it), since the reload would leave that slot unfiltered. The slots are runtime state: run it after every boot (the drivers guide has a systemd unit). Afterwards builds need only/dev/kvm.
Other drivers print that no host setup is needed. Replaces the old
warden hyperv setup.
Flags:
--network <name>— Durable network name, the prefix of its build switches<name>-0to<name>-<N-1>and of its NAT<name>-nat(default:[driver.hyperv] network, thenwarden-dev)--nat-prefix <cidr>— NAT CIDR for relay egress (default 192.168.240.0/20). Every build reads the NAT back from the host and gives its relay its own address in this prefix, so a non-default value takes effect on every build. Refused, before anything changes, when it overlaps the build link ([vm] build_link, or the default100.127.255.252/30); setup has no--build-linkof its own, and a build refuses an overlapping NAT too. Durable builds use only the NAT<network>-nat, so setup refuses, naming it and how to remove it, when another NAT already owns this prefix, and when<network>-natexists on another prefix--host-ip <ip>— Host gateway IP on the NAT switch (default 192.168.240.1), the relay's upstream gateway on every build. When setup makes the NAT, the host IP is the only IPv4 address left on its vNIC,vEthernet (<network>-nat): an address an earlier setup left there (on the old prefix, after that NAT was removed) is removed, and no other interface is touched--slots <n>— hyperv: build switches to create, 1 to 64 (default 4), the number of durable builds that can run at once; firecracker: network slots to create, 1 to 256 (default 16). Refused for other drivers
warden hyperv service
warden hyperv service install|uninstall|run
Manage the privileged Hyper-V helper service (a LocalSystem Windows service
that performs only host network standup on behalf of non-elevated builds, over
a named pipe ACL'd to Administrators and Hyper-V Administrators). With it
installed, warden build --driver hyperv runs entirely without elevation and
stands up a fresh isolated network per build. VM lifecycle always runs
in-process; only network standup is delegated.
A service installed by a warden that speaks another protocol version is
stale: warden doctor --driver hyperv reports it, and a non-elevated build
is refused, naming the reinstall (uninstall, then install, elevated). A
stale service is never treated as absent, so the build does not fall back
to the durable network.
A service that is installed but not running (stopped, say) is reported as
such, not as not installed, with the fix: from an elevated shell, Start-Service WardenHyperV (or sc start WardenHyperV); one that runs but whose pipe does
not answer, Restart-Service WardenHyperV. Doctor's blocked remedies then name
starting it rather than installing it. When the service manager will not give
this process the service's state, a failed read is never reported as not
installed: doctor says the state could not be read and why (installed, but its state could not be read when access is denied, since the service manager
found the name), and names checking it from an elevated shell with
Get-Service WardenHyperV, starting it if it is stopped.
install— Install and start the service (run once, elevated)uninstall— Stop and remove the service (elevated)run— Run the helper (invoked by the SCM; or in a console to smoke-test)
warden clean
warden clean [--cache]
Remove orphaned containers, networks and per-build images left by interrupted or crashed builds. Only removes resources not associated with a currently running warden process, and nothing a later build would reuse: prepared and downloaded VM images, the Hyper-V relay boot disk and the support images stay.
Under every driver it first cleans up after the selected driver's builds
whose warden is gone: a build holds a lock in warden's lock directory
(buildwarden/locks in the user cache directory) while it runs, and for each
build whose lock nobody holds clean removes its stage directory
(warden-stage-<id>, where warden staged the build script, under the
build's temporary directory) and then its lock and record, printing
Cleaning up after build <id> (<driver>). A running build's are left alone.
Under the container driver, qemu and vz it removes leftover containers,
so there a runtime in effect that is not finch, podman or docker fails
the command before anything is listed or removed
(Configuration); under
firecracker and hyperv the setting is not read.
Under the container driver a running build, a warden shell session
included, is left alone while its warden-driver-container runs, even
another user's, whose lock is not in your lock directory: clean lists every user's processes and keeps a build
whose driver still waits on its warden-build-<id> container. A build whose
warden and driver were both killed is removed, although its containers may
still be running. On Windows, which has no ps, only the lock keeps a
running build, so another user's running build there is removed.
With --driver firecracker it needs no container runtime: it kills VMMs
recorded on a network slot that no build holds (left by a warden that was
killed, or by --keep-vms), and removes the work dirs and per-build rootfs
copies of builds that are no longer running and the partial raw images
(*.raw.tmp) of image conversions that were killed.
With --driver hyperv it needs no container runtime either: for each build
that is no longer running (left by a warden that was killed, or by
--keep-vms), it removes its warden-build-<id> and warden-relay-<id> VMs,
then its ephemeral warden-<id> switch, then its warden-hyperv-<id>-* work
dir (in [build] tmpdir when set, else the OS temp dir). A running build holds a lock
that keeps clean away from it. The durable switches and NAT from warden setup, and prepare VMs (the next warden image prepare reaps those), stay.
Run it as a Hyper-V Administrator.
| Flag | Description |
|---|---|
--cache | Also remove warden's whole cache directory. The next VM build downloads and prepares its images again. |
warden driver list
warden driver list [--json]
Lists one entry per driver name warden can find: the five bundled drivers and
every warden-driver-<name> on PATH or beside warden. Each entry gives the
file that would run and where it was found (PATH, beside warden,
linked, or path (--driver) / path (WARDEN_DRIVER) when the selection
names a file), and beneath it every other copy in lookup order: the ones it
shadows and the ones it skips because they cannot be run, with the reason.
* marks the driver this invocation's --driver, WARDEN_DRIVER and config
file select; a selection that cannot be used is said in a line under the
table. It reads directories only and runs no driver.
NAME RUNS FOUND
container * /home/ana/bin/warden-driver-container PATH
shadows /home/ana/.local/bin/warden-driver-container (beside warden)
qemu (linked into warden) linked
With --json it prints one object:
{"drivers":[{"name","path","found","source","selected","shadowed":[{"path","found"}],"skipped":[{"path","reason"}]}]},
where found is path, PATH, beside-warden or linked, and source
names the flag or variable behind a path.
warden <driver> ...
A first argument that is not a flag and not a warden command is looked up as a
driver's name: warden <name> <args...> runs that driver's own commands with
the arguments as typed, and warden <name> --help lists them. Nothing after
<name> is warden's. A name that finds no driver is the unknown-command
error.
Global Flags
warden's own; a driver's flags are listed by --help with the driver
selected (the container driver's --runtime <name>, on build, shell,
doctor and clean: finch, podman or docker, see
Configuration).
| Flag | Description |
|---|---|
--config <path> | The config file to read, which is then the only one read (default: the file WARDEN_CONFIG names, then ./warden.toml if it exists; see Configuration). It has no short form. Given with an empty value it is an error |
--driver <name> | The driver to run: container (default), qemu, vz, hyperv or firecracker, or the name or path of another driver binary (Drivers) |
--color <mode> | Color output (auto, always, never) |
-v, --verbose | Verbose output; with upstream CA paths, also the list of the files that give a certificate and of the entries not read |
--version | Print version |
-h, --help | Help |
Output Directory
Every warden build produces a self-contained output directory with everything needed to verify the build. The layout is identical for every driver.
Structure
warden-output/
├── ledger.zst # Cryptographic ledger (compressed by default)
├── ca.cert.pem.zst # Ephemeral CA cert (compressed by default)
├── environment.json # Signed environment descriptor (what the build ran on)
├── driver.json # Which driver ran the build, and where it was found
├── build-output.log # Captured build console output
├── artifacts/ # Build outputs posted to the ledger
│ └── myapp-1.0.0.whl
├── captures/ # Captured payloads (only with --capture)
│ └── <name> -> ../payloads/<hash>
└── payloads/ # Content-addressed payload storage
└── <hash>
A build from a Dockerfile also gets inputs/, holding the Dockerfile you
submitted, kept as Containerfile, and the build.sh it was translated to
(ORCH-02):
warden-output/
└── inputs/
├── Containerfile # Your Dockerfile, unchanged
└── build.sh # The translated build script: what ran
The container driver always builds from a Dockerfile, so its output always has
inputs/; the qemu, hyperv and firecracker drivers write it for a Linux guest
built from a Dockerfile. A --script or a build.sh / build.ps1 from the context runs as
given, so it is not copied. The container driver also writes console.log.
The container and vz drivers, whose relay runs as a container or host process,
also write relay.log.
File Details
driver.json
Written before the driver starts. It names the driver, its version and
contract version, the file that ran and its SHA-256 digest, where it was found
(path when --driver or WARDEN_DRIVER named the file, PATH,
beside-warden, or linked, for a driver linked into warden, whose path and
digest are warden's own), and the copies the lookup passed over:
{"name": "container", "version": "0.9.0", "contract": 1,
"path": "/home/ana/bin/warden-driver-container", "sha256": "9f2c...",
"found": "PATH",
"shadowed": [{"path": "/home/ana/.local/bin/warden-driver-container",
"found": "beside-warden"}]}
A bundled driver was replaced exactly when found is PATH or path and
shadowed holds a beside-warden or linked entry. The file is not signed
and is not part of the ledger.
ledger.zst
The binary ledger containing chained Ed25519 signatures over every network request and source file transfer. Compressed with zstd by default (use --no-compress for raw).
Inspect with:
warden inspect warden-output
inputs/Containerfile
Your original Dockerfile, unchanged. It is kept under the fixed name
Containerfile whatever it was called (Dockerfile, Containerfile,
Dockerfile.simple, ...). Preserved for comparison with what actually ran.
inputs/build.sh
The build script translated from your Dockerfile: what the build environment
actually ran. Each COPY became one warden-io fetch per file, resolved
against the build context on the host. The relay also recorded these exact
bytes in the ledger when the guest fetched them.
console.log
The build container's own console: warden-io's setup steps followed by the
build's output as the container printed it. It is the place to look when a
build fails before the relay is reachable. Written by the container driver only.
environment.json
The payload of the ledger's environment record: a descriptor of what the build
ran on, whose hash the relay signed as the ledger's first record. For the
container driver it is the base image's manifest (oci-image/v1); for the VM
drivers it is a vm-disk-chain/v1 descriptor listing the boot disks (hash,
size, path, and provenance) and the per-build seed files. warden inspect
checks it against the ledger, and warden inspect --verify-disks re-hashes the
disks it names. Absent when the build recorded no environment.
ca.cert.pem
The ephemeral CA certificate generated for this build's TLS interception. The private key existed only in the relay's memory and was destroyed on teardown; the orchestrator receives only the public certificate when it claims the relay, and writes it here.
build-output.log
The build's console output, streamed from the guest to the collector as the
build runs. Written for every driver (suppressed from the terminal, but not
from this file, by -q/--quiet). When the build environment exits before
the build completes, warden's error points here for the last thing the
build printed.
relay.log
Application-level log from the relay process. Written by the container and vz
drivers (on vz it is echoed to the terminal only with -v). Contains:
- DNS resolution events
- Artifact storage confirmations
- Error messages (if any)
artifacts/
Named build outputs. Each artifact was:
- POSTed to
http://artifacts/<name>from within the build - Hashed (blake2b_256, sha256, sha1, md5)
- Signed into the ledger
- Streamed to the collector and saved to disk
Compression
By default, the ledger and CA certificate are compressed with zstd. This applies to every driver (previously the container driver only).
Disable with:
warden build --no-compress .
Or in config:
[build]
compress = false
Custom Location
warden build -o /path/to/my-output .
Or in config:
[build]
output_dir = "/path/to/my-output"
Examples
BuildWarden ships with example Dockerfiles demonstrating progressively complex builds.
Running Examples
warden build examples/Dockerfile.simple
warden inspect warden-output
The examples are written for the container driver: their FROM images
(python:3.12-slim and the like) are container images, not ones the VM
drivers' image catalogs resolve. To run one under --driver qemu or
--driver firecracker, base it on a catalog image such as ubuntu:24.04
and install the toolchain it expects (see
Cloud Images and the Firecracker
Images).
Available Examples
Dockerfile.simple
Builds a Python requests wheel from source using pip.
- Demonstrates: Basic end-to-end flow — package fetch, wheel build, artifact posting
- Time: ~1 minute
- Network fetches: Docker Hub, Debian repos, PyPI
- Artifact:
requests-2.32.3-py3-none-any.whl(deterministic with SOURCE_DATE_EPOCH)
Dockerfile.expanded
Same wheel build plus test suite and type checking.
- Demonstrates: Ledger truncatability — test/lint network fetches appear as separate entries
- Time: ~3 minutes
- Extra fetches: pytest, mypy, type stubs from PyPI
Dockerfile.cryptography
Builds Python cryptography from source (includes Rust/Cargo backend).
- Demonstrates: Multi-ecosystem auditing — apt packages, Rust crates, pip packages all in one ledger
- Time: ~3 minutes
- Network fetches: Debian repos, crates.io (Cargo), PyPI
Dockerfile.pytorch-aarch64
Builds PyTorch from source with CUDA support on ARM64.
- Demonstrates: Large-scale build with hundreds of network fetches
- Time: ~3 hours
- Network fetches: NVIDIA CUDA, GitHub (submodules), PyPI
- Requires: ARM64 host, ~50GB disk space
Writing Your Own
Any standard Dockerfile works. To post build outputs to the ledger:
RUN curl -fsSL -X POST --data-binary @/path/to/output \
"http://artifacts/my-artifact-name"
The artifacts hostname is reserved — it resolves to the relay and triggers artifact recording in the ledger.
Reproducibility Demo
The simple and expanded examples both pin requests==2.32.3 with SOURCE_DATE_EPOCH set. Despite fetching source from different places (PyPI sdist vs git clone), they produce byte-identical wheels — demonstrating that the ledger can prove two independent builds created the same artifact.
Corporate Networks
Some corporate networks filter or proxy specific traffic. This page covers common workarounds.
Go Module Proxy
If your network blocks proxy.golang.org, set GOPROXY=direct in your Dockerfile to download modules directly from source repositories:
RUN GOPROXY=direct GONOSUMCHECK=* GONOSUMDB=* go mod download
If your organization runs an internal Go module proxy:
ENV GOPROXY=https://goproxy.corp.example.com
RUN go mod download
Internal Container Registries
If your base images come from an internal registry, they'll work normally — BuildWarden intercepts all HTTPS traffic regardless of hostname:
FROM registry.corp.example.com/base/golang:1.26
The relay will MITM the TLS connection to your internal registry and record all layer pulls in the ledger.
HTTP Proxies
BuildWarden doesn't currently support explicit forward proxy (http_proxy/https_proxy) mode. All traffic is intercepted transparently via iptables DNAT. If your network requires an explicit proxy to reach the internet, the relay handles this — it has unrestricted outbound access and forwards traffic upstream.
DNS Filtering and Internal Resolvers
The relay answers the build's DNS queries itself and forwards them upstream.
With the container driver it uses the resolvers of its own container, as the
runtime's network gives them. The VM drivers give their relay the host's
resolvers by default, so a build resolves names the way the machine it runs
on does, internal names included: Hyper-V reads the IPv4 DNS servers of the
default-route interface, Firecracker the host's /etc/resolv.conf (or
systemd-resolved's upstreams), qemu the host's /etc/resolv.conf and vz the
Mac's. There is
no public fallback: a network that blocks public DNS still works, and a
domain your corporate resolver blocks is blocked in the build too, the same
as building without BuildWarden.
Name the resolvers yourself when the host's are not the ones a build should
use: a VPN's split-DNS resolvers (macOS leaves its per-domain resolvers out
of /etc/resolv.conf), a filtering resolver only builds go through, or a
host whose only resolver is local to it. In the config file (warden.toml,
or for every build on the machine the file an absolute WARDEN_CONFIG
names):
[vm]
dns = ["10.20.0.53", "10.20.0.54"]
The list is used exclusively and in order: the relay asks the next server
only when one does not answer in time, and never falls back to the host's.
An entry the relay cannot reach (a loopback address for a relay VM, one
inside the build link, on Hyper-V the host itself or its NAT, and so on)
refuses the
build before any VM boots, naming it. warden doctor --driver <d> prints
the resolvers a build would use and where they came from. The details are in
Configuration.
Address Collisions with the Build Link
The VM drivers join the build VM to the relay over a private /30, the build
link, by default 100.127.255.252/30 (RFC 6598 shared address space, which
LANs, VPCs and VPNs normally leave alone). Inside the relay that link is a
connected route, so anything upstream at one of its four addresses (a
resolver, a private mirror, a collector, a VPN or Tailscale peer) cannot be
reached from a build: the relay refuses to dial it.
Most networks never meet this. Move the link when yours does:
warden doctorprintsbuild link: BLOCKED: host interface address ... is inside the link, or a build refuses to start because the link holds a host interface address;- on Firecracker, a build stops before booting because every host resolver is inside the link;
- a fetch from an internal host whose address is inside the link fails while the same fetch works outside BuildWarden.
Pick any free /30 and check it before you commit to it:
warden doctor --driver qemu --build-link 100.126.255.252/30
Then set it in the config file (warden.toml, or the file WARDEN_CONFIG
names for a machine-wide setting), so every build and warden doctor use it:
[vm]
build_link = "100.126.255.252/30"
Changing the link needs no rebuild, refresh or re-prepare. A host network
that only contains the link, such as a carrier-grade NAT WAN on
100.64.0.0/10, is a doctor warning, not a collision: only the link's own
four addresses are shadowed. The rules a value must satisfy, and the
precedence of the flag and the config file, are in
Configuration.
Address Collisions with the Hyper-V NAT
The Hyper-V relay VM reaches upstream through warden's Internal NAT switch,
by default on 192.168.240.0/20 with the host at 192.168.240.1. Each
build's relay takes its own free address in that prefix. If your LAN, VPN or
a mirror you fetch from uses addresses in it, set the durable network up on
another prefix, from an elevated terminal:
warden setup --driver hyperv --nat-prefix 192.168.250.0/24 --host-ip 192.168.250.1
Every build then reads the NAT back from the host and addresses its relay inside it; nothing else needs changing. Setup refuses a prefix that overlaps the build link, and one another NAT on the host already owns, naming that NAT and how to remove it. A build checks the build link against the NAT it reads back too, by name, before any per-build work. Elevated and service builds use the same NAT once setup has made it.
When setup makes the NAT, the host IP is the only IPv4 address it leaves on
the NAT's vNIC, vEthernet (warden-dev-nat): an address from the old prefix
is removed, and no other interface is touched. warden doctor --driver hyperv
prints the NAT a build would use under Build network, and warns about any
other address on that vNIC, naming the Remove-NetIPAddress that removes it.
Certificate Trust
The relay generates an ephemeral CA per build, and warden-io installs it in the build environment's trust store before your build runs. Tools that use the system certificate store (apt, curl, most language package managers) trust the relay automatically, and warden-io also points pip, npm, Maven, Gradle, Bazel and others at it. See Trust and the Build Baseline for the full list.
On Independent Guarantees of Completeness
Completeness is a guarantee necessary to assure that nothing was potentially missed due to a lack of measurement. Attesting the completeness of inputs is not the same as attesting that all inputs are necessarily human-identifiable, safe, or even necessarily used in their entirety, but that all resources have been accounted for in a way that either contains the content itself or a verifiable identifier of the content (e.g. hash). As such, documents providing a guarantee of completeness should ideally also provide tamper-resistance and clearly show the inputs either directly used or which were available and unmeasured. It is also important that the process not attempt to characterize the inputs beyond what could be measured outside the build process’s influences. This is because bundling or vendoring a tool or dependency into an output artifact is common practice for many packages and can be done in such a way that is hard to detect without specific expertise (e.g. static compilation) and so cannot be easily or simply guaranteed to the same degree of confidence that a naive completeness can.
In the current day, a naive guarantee of completeness could be written for all resources simply saying they were open to all influences at time of the ledger’s writing, though the utility of that would be exceedingly low given it means the resources they would describe are open to potentially any vulnerability. However, there are notable ways to still guarantee completeness while narrowing down possibilities. One example that limits external influences is usage of a hermetic build process, which cuts off all access to the network, allowing only resources proscribed in the source which are downloaded independently prior to the build and can be fully tracked. It isn’t the only method of making that guarantee, just the simplest at face-value: it can’t contain more software than what can be created from what was on disk at the start.
However, most developers today don’t locally build or test in hermetic environments. This is because full network isolation requires knowledge on how to store/communicate all of the remote resources necessary in the environment prior to network isolation. This isn’t universally configurable and the standards (e.g. proxy support) are opt-in rather than opt-out behavior, so it’s common for it to be inconsistently followed, even when common. However, if completeness is the goal, than simply measuring everything that goes in during the process is equivalent for consumers of that software and any additional consistency guarantees offered by the author being proscriptive aren’t strictly required for the supply chain itself to be secured.
Note that I am not saying the author needs to guarantee completeness. It need not be the author and, in most cases, it shouldn’t be. Having an independent guarantee of completeness of inputs gives the most confidence when the guarantor is able to be held accountable specifically on their completeness and the security of the platform which generates it, not the security of the artifact itself. This guarantee can come from for-profit CI platforms or non-profit organizations and the same hash-identified artifact can have a completeness document from multiple providers. As an example, if a vulnerability is found in an SSL library and was recently patched, a rebuild of a consuming package which generates a content-identical artifact using the patched version shows the artifact could not have been vulnerable originally and so can still be safely used. This applies to vulnerabilities across the spectrum, including the builder themselves having a compromised platform. It also opens possibilities for standards that can be audited by independent entities and security experts, instead of solely by a self-signed attestation.
What is a Build Ledger?
A build ledger is a document that provides a completeness guarantee for inputs and outputs during a build process as strictly-ordered entries with a chaining signature. Its logical specification is as follows:
- The first entry is the Certificate header, containing the public portion of an ephemeral, self-signed certificate pair used to sign all of the entries in the ledger. Its signature is based on the content of the public portion of the certificate and signing by the private portion, so it validates the private portion matches the public portion.
- All following entries have a signature including previous entry + their content hash
- Additional metadata can be included as annotations, such as urls for remote resources or directory/file for local resources, but it is not strictly required nor signed and only helps during later analysis steps. This metadata can also be potentially stripped out or modified for internal resources that need to be anonymized but identifiable
- All requests are considered asynchronous and bidirectional, with explicit opening and closing entries, with transfers in each direction and the close of the entry referencing the opening signature. For any entity in the document, it is considered to have a complete ledger at the entry where it and all entities opened before it have closed. This handles the potential surface area around partial usage of a streamed resource before it is able to be fully logged in the ledger.
- Note that while complete, if an input is not identifiable at later stages, it is essentially a known unknown which in general will be a yellow/red flag that not all inputs are able to be properly accounted for
- There is no specific entry marking the end of a ledger. This is intentional as it allows for truncation of ledgers when additional verification, testing, and documentation generation are done before considering the process successful.
BuildWarden
BuildWarden is intended to be a reference implementation to generate build ledgers through a simple ContainerFile as the declaration of starting environment through a parent container and following instructions with fully tracked http/https inputs and outputs. All exported artifacts and metadata are simply done as POST/PUT requests to endpoints without a valid top-level domain, e.g. https://artifacts or e.g. https://file-inputs
- Authoritative restriction of HTTP/HTTPS network resources retrieved by content hash with URL metadata, logged headers and content, and with all other network interfaces blocked
- Filesystem resources available are accounted for by concrete container hash, which is fully resolved
- This could be improved with content-hash+path for every file read/written, but due to added complexity around ensure completeness, may not be part of initial implementation
Build Warden Proposal
When doing research on SBOMs and attempting to evaluate automatic generation of attestations, I realized how easily the attestations of the artifact — excluding the hash-manifest — can be incredibly hard to verify and so could be incomplete, incorrect, or tampered with. It also sets expectations around both good behavior and perpetual vigilance by the author/publisher of an OSS package and gets orders-of-magnitude more complex for any package that bundles/vendors other packages. Given the reliance that most build systems take advantage of having both source and/or artifact repositories being available (and usually over the public internet), your artifact can accidentally or purposely contain almost anything. But it struck me that these are potentially answerable questions as we do so today with network isolation and tracked interfaces, it is just not necessarily guaranteed by the code’s author but by the build executor **** who generates the artifacts.
Build Warden is a platform for build executors which combines the security of network-isolated build containers with an ephemeral HTTPS Man-in-the-middle which logs all requests and responses during the build process and yields a verifiable non-falsifiable* ledger meant to be used along-side any author-provided attestations. This creates a significantly more-exhaustive manifest of all possible software included within the created artifacts and allows build providers (e.g. CodeBuild, GitHub Actions, CI and CI providers) to be able to attest that the build of the artifact (identifiable by hash and size) was secure separately and independently from the source’s author.
*As close as ephemeral private 2022 SSL certificates can achieve
How does it work?
BuildWarden is an application which orchestrates and configures 2 components, a Relay and network-isolated build container, instantiating a new instance of both on every build. BuildWarden’s input is a ContainerFile that contains the starting necessary starting container reference followed with the necessary build instructions on subsequent lines and with output artifacts as POST requests to an internal endpoint with their artifact filename/path (e.g. https://artifact/<filename> though the idiomatic name may be a form-data parameter or otherwise decoupled from url semantics).
To run the build, BuildWarden creates a new Relay instance and a new ephemeral ContainerFile which injects the network configuration between the initial container reference and the build instructions. This installs the ephemeral public Certificate-Authority certificate generated by the Relay to the container’s root certificates and updates any necessary network configurations so DNS properly points to the Relay IP for all requests. It then runs the build through network-isolating the build container to only be able to contact the Relay endpoint.
The Relay is an SSL-terminating intentional Man-In-The-Middle proxy that generates an build-ephemeral Certificate Authorizing public/private certificate pair at startup. The private portion is never stored outside its process and is used to both generate site-specific ephemeral certificates for all HTTPS requests it receives as well as sign individual ledger entries. The Relay then forwards the request to its intended target or a secondary proxy and records both the requests and responses separately to the ledger, both for simplicity of the ledger’s timeline and allowing for build processes that do requests concurrently. Any POST requests to the specific artifact endpoint are simply not forwarded externally and are logged in the same way as any contents retrieved.
Each entry in the ledger is signed with the ephemeral certificate, where the first entry is the public certificate itself alongside an entry for the initial ContainerFile Warden starts the build with. All subsequent entries contain metadata including URL and content hashes, references to specific separate output files for headers and content, and their previous entry’s signature. The Relay is shut down when the build container shuts down, which removes any reference to the private certificate’s contents. This ensures that the ledger cannot be altered afterwards without cracking the ephemeral private certificate.
When the ledger is given an immutable reference and signed by a build executor to a persistent tamper-resistent ledger web service like SigStore, this can give software consumers an additional layer of transparency and closes potential gaps where author-supplied SBOM attestations may be incomplete, inaccurate, or intentionally tampered with. It also opens new possibilities around automatically generating, correcting, or identifying relationships that SBOMs may or may not attest to as a result.
FAQ
Wait, didn’t you start saying you wanted to generate SBOMs? Why does this not generate an SBOM?
So while the ledger’s contents combined with the artifact could potentially be used to generate an SBOM, it differs in the source of the attestations (the build executor), is notably more-exhaustive (leading to many ways it may lead to false-positives) and has different provability guarantees for all sides. This portion can also be developed separately in tandem and for more than one format of SBOM, but given both the different guarantees and attestations that can be made in the formats and the difference between “this is everything the build used” versus “this is what is in the artifact” and the false-positives/negatives that can occur, it is meant to be a separate data source.
Shouldn’t this be able to solve more problems? Like what about the ‘artifact hash catalog’ to help identify actual sources?
We want to prioritize this foundational piece’s simplicity to ensure the base system is both secure and performant. This doesn’t preclude many solutions being built upon the data it provides, but we also don’t want to deeply couple its success to exact strategies or data analysis/warehouses as there are many different ways both the verifiable ledger and the available redirection to another proxy can be used (i.e. redirects to a proxy that talks to an internal/CodeArtifact/Artifactory repository or which refuses/allows specific endpoints) and it is meant to help close a specific gap in data-gathering separate from analysis portions. While it may be expandable to also include other resources (e.g. file system mount), keeping its surface area small of both measurement and interaction interface means a lower likelihood of opening an unverifiable or unmeasured gap.
What about certificate pinning?
This is a space that gets more-complicated and I am open for ideas. I honestly don’t know enough about what makes certificate pinning an actually good idea. The reason the relay is not an HTTPS Proxy is due to proxy support being opt-in for respecting the proxy configuration and, as such, can be subject to bugs in individual build system implementations and lead to more issues when multiple build-systems are used together. At the network layer, it’s notably more uniform and standardized and allows for external/internal/mirror repository replacements without additional configuration for the build system itself.
What if I want to add test coverage or documentation generation as a part of the build process? Doesn’t that generate a lot more false-positives?
Because artifacts are themselves POST requests, each can be considered to have a valid artifact-specific ledger within the full ledger, consisting of all entries up through the completion of the last request started before the artifact’s completion record. This is to protect against a streaming data source not being a properly tracked as a potential input. This means that if all of your build steps finish and the artifacts are posted, any requests occurring afterwards in the ledger can either be ignored or even truncated off the ledger without compromising the security of the ledger for earlier artifacts.
While you may not care about having a ledger for your coverage or documentation artifacts, it can be useful towards troubleshooting differences between local and build-executor-driven builds
How does this relate to In-Toto?
Admittedly, the project started before in-toto was known about. That said, they fundamentally differ on their intention. In-Toto puts an additonal burden on OSS authors to put together detailed metadata verifying that the stages during the production of an artifact come from the actors the author expects. As such, while it gives much greater detail and data on what the author intended their build process to be and the resources they intend to use, it does so at the cost of the author’s attention to details
Component seams
A seam is a boundary between two of BuildWarden's components where another implementation may take the place of one side: a relay written in another language, a collector that stores outputs somewhere other than a disk, an executor for another guest. Each seam is specified in its own document, with numbered requirements, and comes with a conformance suite that checks an implementation of either side against them.
The specifications of every seam but the ledger and the driver contract live
in their own repository,
buildwarden/buildwarden-specs,
and are released one at a time, each under its own tags
<directory>/vX.Y.Z. Where this book's other pages describe a seam (the
architecture among them), they explain it; the
specification is the contract.
The seams
| Seam | Between | Specification | Implemented here by | Suite | Pinned at |
|---|---|---|---|---|---|
| 1, the claim | The claimant and the relay | relay-claim (OpenAPI) | relaycfg/, cmd/relay/; the claimant, driver.Session | relay-claim cases | relay-claim@v0.1.0 |
| 2, the outputs a collector stores | The relay and the collector | collector-outputs (OpenAPI) | collector/ (cmd/collector); the relay's side, relay/collector_client.go | collector-outputs cases | collector-outputs@v0.1.0 |
| 2, the inputs and signals a collector serves | The relay and the collector | collector-inputs (OpenAPI) | collector/ (cmd/collector); the relay's side, relay/collector_client.go | collector-inputs cases | collector-inputs@v0.1.0 |
| 3, the relay's guest API | The relay and the build environment | relay-guest-api (OpenAPI: artifacts, context, control) | relay/, cmd/relay/ | relay-guest-api cases | relay-guest-api@v0.1.0 |
| 4, the ledger | The relay and every reader | Ledger Wire Format v1 and its metadata schemas, in this repository until milestone M6 | ledger/ | specs/specs_test.go and the ledger's own tests | Not pinned: it is in this repository |
5, the executor's initialize | The launcher and the executor | executor-initialize | cmd/warden-io/ | None yet: its cases come with phase S2 | executor-initialize@v0.1.0 |
| 6, the bootstrap config | Its producer and the executor, carried by the relay | bootstrap-config | bootstrap/ | bootstrap-config cases | bootstrap-config@v0.1.0 |
| 9, the driver contract | warden and a driver binary | Driver contract v1 and its schema, in this repository until phase K2 | cmd/warden/ (warden's side); driver/drivercmd/ (the kit) and cmd/warden-driver-container/ (the container driver) | conformance/driver/ (make driver-conformance) | Not pinned: it is in this repository |
Which version this repository implements
This repository pins one version of each of the six specifications, in a Go
module of its own, tools/conformance/<directory>/go.mod, which requires that
specification's module and names its command, bw-conformance-<directory>, in
a tool directive. The last column above is that pin, as
<directory>@<version>, and every link in a row names the ref the pin is at:
the tag <directory>/vX.Y.Z for a release, or, for a branch in progress that
pins an unreleased commit of the specifications, that commit. main pins
releases only.
The conformance workflow builds each pinned command and runs its suite
against the relay and the disk collector built from this repository, each
described by a target file in tools/conformance/targets/: the relay in host,
vm and container mode and as its container image, and the disk collector on
Linux, macOS and Windows. make conformance runs the same locally. A pin is
moved with make pin-specs, which rewrites the module and the refs on this
page together, and never with go get:
make pin-specs SPECS="relay-claim@v0.2.0" # the named specifications, to releases
make pin-specs SPECS=latest # all six, to their newest releases
make pin-specs REF=<commit> # all six, to one unreleased commit
Specifications
The BuildWarden ledger format, versioned and long-lived (RELAY-05). The relay is a reference implementation of these documents; a third-party reader or writer needs nothing else.
The driver contract, how an orchestrator such as warden runs a driver
binary, is specified here too, in driver-contract/, until it moves to the
specifications repository with its conformance suite.
The specifications of BuildWarden's other component seams (the claim, the
collector, the relay's guest API, the executor's initialize and the bootstrap
config) are kept in their own repository; the
Component seams
page lists them, with the version of each this repository implements.
Layout
specs/
README.md this index
build-ledger/v<N>.md ledger wire format, one per major version (prose only)
metadata-<name>/v<N>.md a record metadata schema's document
metadata-<name>/v<N>.schema.json ... and its machine schema, beside it
environment-<type>/v<N>.md a signed environment payload's document
environment-<type>/v<N>.schema.json ... and its machine schema, beside it
driver-contract/v<N>.md the driver contract, one per contract version
driver-contract/v<N>.schema.json ... and the schema of its JSON documents
build-ledger/v<N+1>.md a working draft of the next major version, on a program trunk only
A schema and its document share a major version and change together; a new
major version adds v<N+1>.schema.json and v<N+1>.md beside the old pair,
which stays for ledgers already written.
While the componentization program runs (FLOW-20), the next major version of the ledger format, or of a schema it adds or changes, may be developed as a working draft beside the current one, on a program trunk only. Each draft document opens with this status block:
Working draft, unreleased (FLOW-20). Not a released version of the ledger format. No released or pre-released build writes it; it may change until the program lands, when it is finalized as v
.
and the Documents list below names it "vmain only finalized, when the program lands:
specs/specs_test.go fails a document with the status block on a pull
request or push to main.
Documents
- Ledger wire format, v1
- Driver contract, v1, with the schema of its JSON
documents,
v1.schema.json($idhttps://github.com/buildwarden/buildwarden/specs/driver-contract/v1.schema.json). Its examples are checked against the schema byspecs/specs_test.go.
$id | Document | Machine schema |
|---|---|---|
https://github.com/buildwarden/buildwarden/schemas/v1/http-open.json | metadata-http-open v1 | v1.schema.json |
https://github.com/buildwarden/buildwarden/schemas/v1/http-headers.json | metadata-http-headers v1 | v1.schema.json |
https://github.com/buildwarden/buildwarden/schemas/v1/http-body.json | metadata-http-body v1 | v1.schema.json |
https://github.com/buildwarden/buildwarden/schemas/v1/artifact.json | metadata-artifact v1 | v1.schema.json |
https://github.com/buildwarden/buildwarden/schemas/v1/redacted.json | metadata-redacted v1 | v1.schema.json |
https://github.com/buildwarden/buildwarden/schemas/v1/environment.json | metadata-environment v1 | v1.schema.json |
https://github.com/buildwarden/buildwarden/schemas/v1/environment-container.json | metadata-environment-container v1 (legacy) | v1.schema.json |
https://github.com/buildwarden/buildwarden/schemas/v1/environment-oci-image.json | environment-oci-image v1 | v1.schema.json |
https://github.com/buildwarden/buildwarden/schemas/v1/environment-vm-disk-chain.json | environment-vm-disk-chain v1 | v1.schema.json |
$id policy
A schema's $id is a stable name, not a location. Ledgers list these
strings in their header's schemas array, so they never change:
- The
$ids above, of the formhttps://github.com/buildwarden/buildwarden/schemas/v1/<name>.json, date from before this layout and are kept for good. They do not resolve to a file; use the table above to find one. - A schema added after this layout takes an
$idthat mirrors its path:https://github.com/buildwarden/buildwarden/specs/<dir>/v<N>.schema.json.
BuildWarden Ledger Specification
This is version 1 of the ledger wire format (header version byte 0x01). It
specifies the binary layout only; each metadata schema the ledger references is
specified in its own document, listed in the specifications index.
Purpose
A build ledger is a document providing a completeness guarantee for inputs and outputs during a build process as strictly-ordered entries with a chaining signature. It is produced by the BuildWarden relay — an ephemeral TLS-terminating proxy that observes all network traffic during an isolated build.
The ledger is designed to be:
- Verifiable: Any holder of the ledger can validate the signature chain using only the public key embedded in the header. Verification requires no knowledge of hash algorithm names or metadata schemas — only the declared sizes.
- Tamper-evident: Altering, reordering, inserting, or removing any entry invalidates all subsequent signatures.
- Redactable: Metadata is CBOR-encoded, not part of signatures, and can be stripped or modified without affecting ledger integrity.
- Complete: Every network resource consumed or produced during the build is recorded with content-addressable identity (size + ordered hash block).
- Deterministic: All signed content has a fixed byte layout derivable from header parameters. No parsing ambiguity exists in the signed portion of any record.
Conventions
- All multi-byte integers are big-endian (network byte order).
- Strings in the binary prefix of the header are null-terminated UTF-8.
- CBOR objects follow RFC 8949.
- Signature inputs are the raw concatenation of the specified fields — no additional framing or separators.
File Layout
<ledger_root>/
├── ledger # The binary ledger file
├── ledger.cert.pem # Public certificate in PEM format (convenience copy)
├── payloads/
│ └── <hex_hash> # Payload files stored by primary hash
├── artifacts/
│ └── <name> # Artifact files (or symlinks to payloads/)
└── metadata/
└── <stream> # Optional append-only metadata streams
Ledger File Structure
The ledger file is a concatenation of:
[Header] [Record 0] [Record 1] ... [Record N]
There are no delimiters between records. Record boundaries are determined by the record structure and sizes declared in the header.
Header
The header establishes the cryptographic parameters, embeds the public key, and provides informational metadata.
Binary Prefix
| Offset | Size | Field | Description |
|---|---|---|---|
| 0 | 4 | Magic | ASCII BLDL (0x42 0x4C 0x44 0x4C) |
| 4 | 1 | Version | Ledger spec version (0x01 for this spec) |
| 5 | variable | Signature scheme | Null-terminated UTF-8 string (e.g., ed25519-sha512\0) |
| — | 2 | Signature size | uint16 — byte length of all signatures in this ledger |
| — | 2 | Hash block size | uint16 — total byte length of concatenated hashes per payload |
| — | 2 | Public key length | uint16 — byte length of the public key |
| — | variable | Public key bytes | Raw public key (length per above field) |
The binary prefix ends immediately after the public key bytes. Its total size is:
5 + len(signature_scheme) + 1 + 2 + 2 + 2 + public_key_length
Header Signature
Immediately following the binary prefix:
| Size | Field | Description |
|---|---|---|
| signature-size | Header signature | Signs all bytes of the binary prefix |
Signature input: All bytes from offset 0 through the end of the public key bytes (the entire binary prefix).
The header signature serves as the chain root — it becomes the prev_sig for the first record.
Header Metadata (CBOR)
Following the header signature:
| Size | Field | Description |
|---|---|---|
| 4 | Metadata length | uint32 — byte length of the CBOR object that follows |
| variable | CBOR object | Informational header metadata |
The header metadata is a CBOR map containing:
{
"hashes": ["blake2b_256", "sha256", "sha1", "md5"],
"schemas": [
"https://github.com/buildwarden/buildwarden/schemas/v1/http-open.json",
"https://github.com/buildwarden/buildwarden/schemas/v1/http-headers.json",
"https://github.com/buildwarden/buildwarden/schemas/v1/http-body.json",
"https://github.com/buildwarden/buildwarden/schemas/v1/artifact.json",
"https://github.com/buildwarden/buildwarden/schemas/v1/redacted.json",
"https://github.com/buildwarden/buildwarden/schemas/v1/environment.json"
],
"environment": {
"type": "vm-disk-chain/v1"
}
}
| Key | Type | Description |
|---|---|---|
hashes | array of text | Ordered list of hash algorithm names. The concatenation of their outputs equals hash_block_size bytes. |
schemas | array of text | Ordered list of JSON Schema $ids. Index position maps to the schema index byte in records. An $id is a stable name, not a location; the specifications index maps each one to its file. |
environment | map | {"type": <environment type>}: an untrusted label echoing the type the environment record's signed payload names. Absent when the ledger has no environment record. Ledgers written before environment types were specified carry {"type": "container"}, which readers treat as oci-image/v1. |
The header metadata is not signed and may be modified without invalidating the ledger. It is informational context for consumers.
Note: The schemas list may be updated after ledger creation (e.g., appending new schemas) without invalidating the signature chain, since header metadata is not signed. Existing schema indices remain stable.
Record Types
| Byte Value | Name | Description |
|---|---|---|
| 0x01 | open | Opens a new channel |
| 0x02 | checkpoint | Intermediate data on an open channel |
| 0x03 | close | Closes a channel |
| 0x04 | artifact | Closes a channel, marking the payload as a build artifact |
Record Layout
Open Record
[Record type: 1 byte] — 0x01
[Previous signature] — signature-size bytes
[Payload size: 8 bytes] — int64, big-endian (typically 0)
[Hash block] — hash-block-size bytes (OMITTED if payload size = 0)
[Record signature] — signature-size bytes
[Schema index: 1 byte] — 0-254 = index, 255 = no metadata
[Metadata length: 4 bytes] — uint32 (OMITTED if schema index = 255)
[CBOR metadata] — (OMITTED if schema index = 255)
Open records do not include an open-signature field.
Signature input:
record_type(0x01) + prev_sig + payload_size
When payload size = 0 (the common case), the signature input is:
0x01 + prev_sig + 0x0000000000000000
When payload size ≠ 0, the hash block is appended to the signature input:
0x01 + prev_sig + payload_size_bytes + hash_block
Checkpoint Record
[Record type: 1 byte] — 0x02
[Previous signature] — signature-size bytes
[Open signature] — signature-size bytes
[Payload size: 8 bytes] — int64, big-endian (sign = direction)
[Hash block] — hash-block-size bytes (OMITTED if payload size = 0)
[Record signature] — signature-size bytes
[Schema index: 1 byte] — 0-254 = index, 255 = no metadata
[Metadata length: 4 bytes] — uint32 (OMITTED if schema index = 255)
[CBOR metadata] — (OMITTED if schema index = 255)
Signature input:
record_type(0x02) + prev_sig + open_sig + payload_size_bytes + hash_block
When payload size = 0:
0x02 + prev_sig + open_sig + 0x0000000000000000
Close Record
[Record type: 1 byte] — 0x03
[Previous signature] — signature-size bytes
[Open signature] — signature-size bytes
[Payload size: 8 bytes] — int64, big-endian (sign = direction)
[Hash block] — hash-block-size bytes (OMITTED if payload size = 0)
[Record signature] — signature-size bytes
[Schema index: 1 byte] — 0-254 = index, 255 = no metadata
[Metadata length: 4 bytes] — uint32 (OMITTED if schema index = 255)
[CBOR metadata] — (OMITTED if schema index = 255)
Signature input: Identical structure to checkpoint.
record_type(0x03) + prev_sig + open_sig + payload_size_bytes + hash_block
Artifact Record
[Record type: 1 byte] — 0x04
[Previous signature] — signature-size bytes
[Open signature] — signature-size bytes
[Payload size: 8 bytes] — int64, big-endian
[Hash block] — hash-block-size bytes (OMITTED if payload size = 0)
[Record signature] — signature-size bytes
[Schema index: 1 byte] — 0-254 = index, 255 = no metadata
[Metadata length: 4 bytes] — uint32 (OMITTED if schema index = 255)
[CBOR metadata] — (OMITTED if schema index = 255)
Signature input: Identical structure to close.
record_type(0x04) + prev_sig + open_sig + payload_size_bytes + hash_block
The artifact record closes its channel (same semantics as close). Its record type structurally identifies the payload as a build output.
Constraints:
- Payload size of 0 is valid (empty artifact).
- When payload size is non-zero, it SHOULD be negative (indicating
outdirection), though validators MUST NOT reject based on sign alone — the record type is authoritative.
Payload Size and Direction
The payload size field is a signed 64-bit big-endian integer.
| Value | Meaning |
|---|---|
| > 0 (positive) | Data flowing into the build (response bodies, downloaded resources) |
| < 0 (negative) | Data flowing out of the build (request bodies, artifact submissions) |
| = 0 | No payload / directionless |
The absolute value of the payload size is the byte length of the payload content. When non-zero, the hash block immediately follows the payload size field.
When payload size = 0, the hash block is omitted entirely — no bytes are present for it. This applies uniformly to all record types.
Hash Block
The hash block is the raw concatenation of hash digests in the order declared by the header's hashes array. Its total size equals the header's hash_block_size field.
Example with default hashes ["blake2b_256", "sha256", "sha1", "md5"]:
| Hash | Output Size |
|---|---|
| blake2b_256 | 32 bytes |
| sha256 | 32 bytes |
| sha1 | 20 bytes |
| md5 | 16 bytes |
| Total | 100 bytes |
The hash block size declared in the header would be 100 (0x0064).
Payload content is written to payloads/<primary_hash_hex> where the primary hash is the first algorithm in the header's hash list.
Signature Computation
Signature Schemes
The signature scheme is declared as a null-terminated string in the header. The scheme name encodes both the signing algorithm and the digest algorithm.
| Scheme | Signing Algorithm | Digest | Key Size | Signature Size |
|---|---|---|---|---|
ed25519-sha512 | Ed25519 | SHA-512 | 32 bytes | 64 bytes |
rsa-pkcs1v15-sha512 | RSA PKCS#1 v1.5 | SHA-512 | variable | variable |
For all schemes:
- Concatenate the signature input bytes as specified per record type.
- Compute the digest (SHA-512) of the concatenated input.
- Sign the digest with the private key using the declared algorithm.
Chain Integrity
Each record's signature incorporates the previous record's signature (prev_sig), forming a hash chain:
Header sig ← Record 0 sig ← Record 1 sig ← ... ← Record N sig
Altering, removing, or reordering any record breaks the chain for all subsequent records.
Metadata
Schema Index
Each record carries a 1-byte schema index:
| Value | Meaning |
|---|---|
| 0–254 | Index into the header's schemas array |
| 255 | No metadata attached |
When schema index = 255, no metadata length or CBOR bytes follow. When schema index is 0–254, a 4-byte uint32 length followed by that many bytes of CBOR-encoded metadata immediately follow.
Metadata is never part of the signature input. It can be freely added, modified, or stripped without affecting ledger validity.
One Schema Per Record
Each record has at most one metadata attachment. The schema index identifies which schema the CBOR object conforms to.
Default Schemas
BuildWarden defines the following default schemas. Their indices are
determined by position in the header's schemas array (not fixed by this
spec); the relay writes them in the order below. Each schema's fields are
specified in its own document, beside its machine schema.
| Index | Name | $id | Document |
|---|---|---|---|
| 0 | http-open | https://github.com/buildwarden/buildwarden/schemas/v1/http-open.json | metadata-http-open v1 |
| 1 | http-headers | https://github.com/buildwarden/buildwarden/schemas/v1/http-headers.json | metadata-http-headers v1 |
| 2 | http-body | https://github.com/buildwarden/buildwarden/schemas/v1/http-body.json | metadata-http-body v1 |
| 3 | artifact | https://github.com/buildwarden/buildwarden/schemas/v1/artifact.json | metadata-artifact v1 |
| 4 | redacted | https://github.com/buildwarden/buildwarden/schemas/v1/redacted.json | metadata-redacted v1 |
| 5 | environment | https://github.com/buildwarden/buildwarden/schemas/v1/environment.json | metadata-environment v1 |
Ledgers written before typed environments list the legacy
https://github.com/buildwarden/buildwarden/schemas/v1/environment-container.json
instead of environment.json; see
metadata-environment-container v1.
Environment Record
The first records after the header describe the build environment: an open
followed by a close on the
environment metadata schema (ledgers written
before typed environments use the legacy
environment-container schema).
The close record's payload size is −len(payload) and its hash block hashes
the environment payload, a descriptor of what the build ran on. The payload
itself is not in the ledger: it is written beside it as environment.json in
the output directory (by the collector, the relay's only output path), and a
verifier hashes that file and compares it with the signed hash block.
| # | Type | Payload Dir | Payload Content | Schema |
|---|---|---|---|---|
| 1 | open | — (0) | — | environment ({"type": "environment"}) |
| 2 | close | out (−) | Environment payload | environment ({"type": <environment type>, ...}) |
A ledger may have no environment record (for example one written by a third-party orchestrator that sends none).
What the record proves
The relay signs what the orchestrator asserts. The orchestrator is trusted: it builds the payload host-side, before the build guest starts, from files the guest never writes. The guest is not trusted and has no way to influence the payload. The relay does not inspect the environment itself; the record binds the orchestrator's statement into the signed chain, and it is exactly as trustworthy as the orchestrator and the host it ran on. It is not a measurement taken inside the guest.
Environment types
Because the header label, the schema index and record metadata are all unsigned, the payload names its own type inside the signed bytes. A reader takes the type from the payload, never from the label or metadata; a relay refuses an environment whose declared type disagrees with the type its payload names, so an honest ledger's label always matches.
Each environment type is specified by its own document,
specs/environment-<type>/v<N>.md, beside a JSON schema
(v<N>.schema.json) stating what the payload must contain. Adding a type is a
new document and schema; the wire format does not change. Type names carry
their own major version (/v1).
| Type | Payload | Document |
|---|---|---|
oci-image/v1 | A container image's manifest or index, as the runtime returned it | environment-oci-image v1 |
vm-disk-chain/v1 | A VM's ordered disk chain plus per-build seed files | environment-vm-disk-chain v1 |
HTTP Protocol Mapping
For HTTP/HTTPS requests proxied by the relay, the typical entry sequence is:
GET Request (resource consumed by build)
| # | Type | Payload Dir | Payload Content | Schema |
|---|---|---|---|---|
| 1 | open | — (0) | — | http-open |
| 2 | checkpoint | out (−) | Request headers (raw bytes) | http-headers |
| 3 | checkpoint | in (+) | Response headers (raw bytes) | http-headers |
| 4 | close | in (+) | Response body | http-body |
POST Request (data sent from build)
| # | Type | Payload Dir | Payload Content | Schema |
|---|---|---|---|---|
| 1 | open | — (0) | — | http-open |
| 2 | checkpoint | out (−) | Request headers (raw bytes) | http-headers |
| 3 | checkpoint | out (−) | Request body | http-body |
| 4 | checkpoint | in (+) | Response headers (raw bytes) | http-headers |
| 5 | close | in (+) | Response body | http-body |
Artifact Submission
| # | Type | Payload Dir | Payload Content | Schema |
|---|---|---|---|---|
| 1 | open | — (0) | — | http-open |
| 2 | checkpoint | out (−) | Request headers (raw bytes) | http-headers |
| 3 | artifact | out (−) | Artifact body | artifact |
Redactability
Metadata is excluded from all signatures. This allows:
- Stripping URLs, hostnames, and internal identifiers from
http-openmetadata. - Replacing any record's metadata with the
redactedschema (changing the schema index byte and CBOR content). - Removing metadata entirely (setting schema index to 255 and removing the length + CBOR bytes).
After redaction, the signature chain remains fully valid. The content identity (payload size + hash block) is preserved, proving what was transferred without revealing where it came from.
The redacted schema provides attribution — identifying who owns or is responsible for the redacted information — enabling downstream consumers to request the full metadata from the appropriate party if needed.
Completeness
A channel is complete when its open entry has a corresponding close or artifact entry.
A ledger is complete when all opened channels are closed.
A payload's provenance is complete when:
- The channel containing the payload is closed.
- All channels opened before that close are themselves closed.
Verification Algorithm
A minimal verifier needs only:
- The binary prefix fields (signature scheme, signature size, hash block size, public key)
- The ability to compute the declared digest (SHA-512) and verify the declared signature scheme
1. Read binary prefix, extract: sig_scheme, sig_size, hash_block_size, public_key
2. Verify header signature over the binary prefix bytes
3. Set prev_sig = header_signature
4. Skip header metadata (read 4-byte length, skip that many bytes)
5. For each record:
a. Read record_type (1 byte)
b. Read prev_sig_field (sig_size bytes) — must equal prev_sig
c. If record_type != 0x01: read open_sig (sig_size bytes)
d. Read payload_size (8 bytes, signed int64)
e. If payload_size != 0: read hash_block (hash_block_size bytes)
f. Reconstruct signature input from fields read in (a–e)
g. Read record_signature (sig_size bytes)
h. Verify record_signature against signature input using public_key
i. Set prev_sig = record_signature
j. Read schema_index (1 byte)
k. If schema_index != 255: read metadata_length (4 bytes), skip that many bytes
6. If all signatures verify: ledger is valid
Note: The verifier does not need a CBOR parser, knowledge of hash algorithm names, or awareness of metadata schemas. It operates entirely on the deterministic byte layout.
Error Handling
If a network request fails (timeout, connection reset, server error):
- The relay still emits a close entry for the channel.
- The close entry's payload size may be 0 (nothing received).
- Metadata may indicate the error condition.
- No open channel is left dangling in a well-formed ledger.
Future Considerations
- File-system tracing: Additional record types for local file I/O via syscall tracing.
- Payload recording configuration: Configurable rules for which payloads are stored to disk vs. only hashed.
- Auto-redaction: Configuration-driven redaction of metadata for specific hostnames at ledger-creation time.
- Additional signature schemes: The null-terminated scheme string and explicit size fields allow new schemes without format changes.
- Compression: CBOR metadata could be compressed; the length-prefix framing supports this transparently.
Appendix: Worked Example
Given: ed25519-sha512 scheme, default hash set [blake2b_256, sha256, sha1, md5].
Header parameters:
- Signature size: 64 bytes
- Hash block size: 100 bytes (32 + 32 + 20 + 16)
- Public key length: 32 bytes
Record sizes (excluding metadata)
| Record Type | Fixed Size |
|---|---|
| Open (payload=0) | 1 + 64 + 8 + 64 + 1 = 138 bytes |
| Open (payload≠0) | 1 + 64 + 8 + 100 + 64 + 1 = 238 bytes |
| Checkpoint/Close/Artifact (payload=0) | 1 + 64 + 64 + 8 + 64 + 1 = 202 bytes |
| Checkpoint/Close/Artifact (payload≠0) | 1 + 64 + 64 + 8 + 100 + 64 + 1 = 302 bytes |
Metadata adds: 4 bytes (length) + CBOR content length.
http-open metadata schema, v1
$id | https://github.com/buildwarden/buildwarden/schemas/v1/http-open.json |
| Machine schema | metadata-http-open/v1.schema.json |
| Applies to | open records of HTTP/HTTPS channels |
| Default header index | 0 (see the ledger spec's Default Schemas) |
Purpose
Names the request a channel carries: what was asked for, from where, and over which protocol version. It is the metadata most often stripped by redaction, because the URL reveals hosts and paths.
Fields
{
"method": "GET",
"url": "https://example.com/path",
"protocol": "HTTP/1.1"
}
| Field | Type | Required | Description |
|---|---|---|---|
method | text | yes | HTTP method (GET, POST, PUT, DELETE, HEAD, ...) |
url | text (URI) | yes | Full request URL, including scheme, host and path |
protocol | text | yes | Protocol version (HTTP/1.1, HTTP/2, ...) |
No other fields are allowed.
http-headers metadata schema, v1
$id | https://github.com/buildwarden/buildwarden/schemas/v1/http-headers.json |
| Machine schema | metadata-http-headers/v1.schema.json |
| Applies to | checkpoint records whose payload is HTTP request or response headers |
| Default header index | 1 (see the ledger spec's Default Schemas) |
Purpose
Surfaces the headers a reader is likely to care about without parsing the raw header bytes, which are the record's payload. Credentials never appear in it.
Fields
{
"headers": [
["X-Amz-Request-Id", "abc123"],
["X-Custom-Header", "value"],
["Authorization", "<redacted>"],
["Cookie", "<redacted>"],
["Set-Cookie", "<redacted>"]
]
}
| Field | Type | Required | Description |
|---|---|---|---|
headers | array of [name, value] | yes | Non-standard headers, each a two-element array of text. Auth-related headers (Authorization, Cookie, Set-Cookie, Proxy-Authorization) are listed with value <redacted>. Standard/structural HTTP headers (those defined in HTTP/1.1 and HTTP/2 base specifications) are omitted — they exist in the raw payload bytes. |
No other fields are allowed.
http-body metadata schema, v1
$id | https://github.com/buildwarden/buildwarden/schemas/v1/http-body.json |
| Machine schema | metadata-http-body/v1.schema.json |
| Applies to | checkpoint or close records whose payload is an HTTP request or response body |
| Default header index | 2 (see the ledger spec's Default Schemas) |
Purpose
Carries the response status alongside a body, so a reader can tell a successful download from an error page without the response headers.
Fields
{
"status": 200
}
| Field | Type | Required | Description |
|---|---|---|---|
status | unsigned int, 100–599 | no | HTTP response status code. Present only for response bodies; a request body's metadata is an empty map. |
No other fields are allowed.
Known producer deviation
Ledgers written by relays v0.2.0 through v0.6.0 carry a path text field in
some http-body close records of relay-served inputs, under this document's
$id at index 2. From v0.2.0 it is on the close of each build-context file. In
v0.6.0 it is also on the close of the build script (unreleased builds from
b716d9e onward) and of the bootstrap config (from 5ab774b onward). It
duplicates the path of the matching open record's url in its
http-open metadata. Readers ignore it.
Current relays write {"status": 200} for these records instead.
artifact metadata schema, v1
$id | https://github.com/buildwarden/buildwarden/schemas/v1/artifact.json |
| Machine schema | metadata-artifact/v1.schema.json |
| Applies to | artifact records |
| Default header index | 3 (see the ledger spec's Default Schemas) |
Purpose
Names a build output. The record type already marks the payload as an artifact; this metadata says where to find it in the output directory.
Fields
{
"name": "my-binary",
"context": {
"content_type": "application/octet-stream"
}
}
| Field | Type | Required | Description |
|---|---|---|---|
name | text | yes | Filename as stored in the ledger's artifacts/ directory |
context | map | yes | Freeform key-value map for additional artifact metadata; may be empty |
No other fields are allowed.
redacted metadata schema, v1
$id | https://github.com/buildwarden/buildwarden/schemas/v1/redacted.json |
| Machine schema | metadata-redacted/v1.schema.json |
| Applies to | Any record whose original metadata has been stripped or was never recorded |
| Default header index | 4 (see the ledger spec's Default Schemas) |
Purpose
Attribution for removed metadata. Because metadata is outside every signature, a holder may replace a record's metadata with this schema (changing the schema index byte and the CBOR content) without invalidating the ledger; see Redactability. The owner tells a downstream consumer whom to ask for the full metadata.
Fields
{
"owner": "build.example.com"
}
| Field | Type | Required | Description |
|---|---|---|---|
owner | text | yes | Identifier of the party responsible for or owning the redacted information |
No other fields are allowed.
environment metadata schema, v1
$id | https://github.com/buildwarden/buildwarden/schemas/v1/environment.json |
| Machine schema | metadata-environment/v1.schema.json |
| Applies to | The environment record's open and close |
| Default header index | 5 (see the ledger spec's Default Schemas) |
Purpose
Informational, unsigned context on the environment record. The signed
environment payload names its own type and is described by its
environment-<type> document; this metadata only echoes it. Readers take the
type from the payload, never from this metadata.
Ledgers written before typed environments use the legacy
environment-container schema
in this position instead.
Fields
{
"type": "oci-image/v1",
"reference": "docker.io/library/python:3.12-slim",
"digest": "sha256:<64 hex>",
"mediaType": "application/vnd.oci.image.manifest.v1+json"
}
| Field | Type | Required | Description |
|---|---|---|---|
type | text | yes | "environment" on the open record; on the close record an echo of the payload's environment type, such as oci-image/v1 or vm-disk-chain/v1 (unsigned; the payload is authoritative) |
driver | text | no | vm-disk-chain/v1: the driver that booted the environment |
reference | text | no | oci-image/v1: image reference as the user gave it |
digest | text, sha256:<64 lowercase hex> | no | oci-image/v1: registry digest of the pulled reference. Equals sha256(payload) only when the runtime returned the registry's exact manifest bytes |
mediaType | text | no | oci-image/v1: manifest media type |
The schema allows other fields.
environment-container metadata schema, v1 (legacy)
$id | https://github.com/buildwarden/buildwarden/schemas/v1/environment-container.json |
| Machine schema | metadata-environment-container/v1.schema.json |
| Applies to | The environment record in ledgers written before typed environments |
| Status | Legacy. The relay no longer writes it. It is kept so those ledgers resolve. |
Purpose
Before environment types were specified, the environment record's metadata
schema was environment-container.json and the only environment was a
container image. New ledgers reference
environment instead.
Compatibility
A ledger that uses this schema has the header label
"environment": {"type": "container"}. Readers treat that label as
oci-image/v1. The signed payload is the raw
OCI manifest bytes with no type member, which is exactly an oci-image/v1
payload, so the reader takes the same type from the payload itself.
Fields
{
"reference": "docker.io/library/python:3.12-slim",
"digest": "sha256:<64 hex>",
"mediaType": "application/vnd.oci.image.manifest.v1+json"
}
| Field | Type | Required | Description |
|---|---|---|---|
reference | text | yes | Image reference as specified by the user |
digest | text, sha256:<64 lowercase hex> | yes | OCI manifest digest |
mediaType | text | no | Manifest media type |
No other fields are allowed. All of them are informational and unsigned.
oci-image/v1 environment payload
$id | https://github.com/buildwarden/buildwarden/schemas/v1/environment-oci-image.json |
| Machine schema | environment-oci-image/v1.schema.json |
| Applies to | The signed payload of an environment record of type oci-image/v1 |
| Written by | The container driver |
Purpose
A container image. This schema describes the signed payload bytes, not record metadata: a reader takes the environment type from the payload (see Environment types).
Payload
The image's OCI image manifest or index (or Docker v2 equivalent), exactly as
the container runtime returned it. For compatibility with ledgers written
before typed environments this is the one type whose payload is not a wrapper
object: it has no type member, and it is identified by the manifest's own
schemaVersion together with layers, manifests or a manifest/index
mediaType. See the
OCI image spec for the full
manifest format.
| Field | Type | Required | Description |
|---|---|---|---|
schemaVersion | integer, always 2 | yes | Manifest schema version |
mediaType | text | see below | Manifest or index media type |
config | object | no | Image config descriptor |
layers | array | see below | Layer descriptors (a manifest) |
manifests | array | see below | Manifest descriptors (an index) |
type | — | must be absent | A payload with type is a typed descriptor, not this type |
At least one of layers, manifests, or a mediaType containing
manifest or image.index must be present.
Metadata
The record's unsigned environment
metadata carries reference (as the user gave it), digest (the registry
digest of the pulled reference) and mediaType.
Verify
Hash the payload against the record. digest equals sha256(payload) only
when the runtime returned the registry's exact bytes; runtimes may
re-serialize the manifest, and the digest may name an index, so a mismatch
there is informational.
vm-disk-chain/v1 environment payload
$id | https://github.com/buildwarden/buildwarden/schemas/v1/environment-vm-disk-chain.json |
| Machine schema | environment-vm-disk-chain/v1.schema.json |
| Applies to | The signed payload of an environment record of type vm-disk-chain/v1 |
| Written by | The qemu, vz, hyperv and firecracker drivers |
Purpose
A virtual machine booted from an ordered chain of disk layers plus per-build
seed files. This schema describes the signed payload bytes, not record
metadata: a reader takes the environment type from the payload's type
member (see Environment types).
The relay signs this descriptor as the orchestrator asserts it; the build
guest never writes it.
Payload
{
"type": "vm-disk-chain/v1",
"driver": "hyperv",
"guest_os": "windows",
"arch": "amd64",
"generation": 1,
"layers": [
{"role": "disk", "name": "windows-server-2025.vhd", "format": "vhd",
"path": "C:\\Users\\me\\AppData\\Local\\warden\\hyperv\\images\\windows-server-2025.vhd",
"sha256": "<64 hex>", "size": 10737418240,
"source": {"kind": "url", "url": "https://...", "pinned": true}}
],
"seed": [
{"name": "build-script", "sha256": "<64 hex>", "size": 120},
{"name": "warden-io.exe", "sha256": "<64 hex>", "size": 9123456}
]
}
No member outside those listed below is allowed, at any level.
| Field | Required | Description |
|---|---|---|
type | yes | "vm-disk-chain/v1". |
driver | yes | The driver that booted the VM (qemu, vz, hyperv, firecracker). |
guest_os, arch | yes | Guest OS (linux, windows, macos) and Go architecture name (amd64, arm64, ...). |
generation | no | Hyper-V VM generation, an integer of at least 1; omitted elsewhere. |
layers | yes | Ordered files the VM boots from, at least one. Entries with role: disk form the disk chain base-first: each later disk is a child (differencing / backing-file overlay) of the one before. The per-build writable disk is not a layer: an empty child of the last disk, or for firecracker, which boots a raw image with no overlay, a copy of it. |
layers[].role | yes | disk, or one of kernel, initrd (direct boot), nvram (UEFI variables, VZ auxiliary storage), platform (VZ hardware model, machine identifier). |
layers[].name | yes | Non-empty file name. |
layers[].format | no | Disk format (vhd, vhdx, qcow2, raw, ...). |
layers[].sha256, size | yes | SHA-256 (64 lowercase hex) and size in bytes of the file as booted. |
layers[].path | no | Host path at build time, where a verifier finds the file. Host-local; it may reveal the host's directory layout. |
layers[].source | yes | Provenance. kind: url — downloaded from url (required); pinned when it verified against an expected hash supplied independently of the download. kind: local — supplied by the user, or changed since warden recorded it. kind: prepared — produced by warden: prepared_by (required) is "warden <version>" and inputs lists the hashed inputs ({name, sha256?, size?, url?}, name required) it was produced from, e.g. the install ISO or IPSW, or for a prepared differencing layer the preparation script and payloads. |
seed | no | Per-build files handed to the guest (agent binary, bootstrap script, answer files, cloud-init data, the build script as build-script), sorted by name. Each entry has name (non-empty), sha256 and size, all required. They are per-build and generally not available to re-check later; their hashes record what the guest was given. |
The encoding is deterministic for a given descriptor (fixed member order, sorted seed).
Metadata
The record's unsigned environment
metadata carries type and driver.
Verify
(1) Hash environment.json against the record; (2) for each layer, hash the
file at path (or a copy obtained elsewhere) and compare sha256 and
size. Disks are never embedded in the ledger.
driver-contract, version 1
How an orchestrator runs a driver binary: how it finds the driver, the commands it runs on it, the messages of a build, the files they share, and how a driver reads its own configuration.
| Seam | 9, the driver contract |
| Requirement identifiers | DRV-<n>; the configuration requirements DRV-C<n> |
| Roles | orchestrator, driver |
| Machine schema | v1.schema.json, beside this document |
| Reference implementation | The orchestrator warden (cmd/warden); the drivers under driver/, the kit driver/drivercmd, and the container driver's binary warden-driver-container, in buildwarden/buildwarden |
| Conformance suite | driver-conformance, under conformance/driver/ in the same repository |
| Status | Unstable. Version 1 may change in any release before BuildWarden 1.0 (Versions) |
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY" and "OPTIONAL" in this document are to be interpreted as described in BCP 14 (RFC 2119, RFC 8174) when, and only when, they appear in all capitals. A requirement is a paragraph or list item that starts with its identifier in bold. Text that is not a requirement is informative.
Every JSON example in this document is a code block whose info string names
the definition of v1.schema.json it is an instance of ( ```json describe);
the schema is checked against every example (specs/specs_test.go).
Scope and roles
A driver creates the isolated environment of a build, starts the relay that
is the build's only network path, and makes that relay claimable. An
orchestrator finds the driver, runs its commands, claims the relay, serves
the relay its collector, waits for the build and reports it. warden is the
orchestrator of this repository; the conformance suite is a second one.
Two roles take part:
- The orchestrator starts the driver's process for each command, writes its requests and reads its output.
- The driver is an executable file, named for the driver, that answers the
commands of this document. It is written in any language. A driver written
in Go may use the kit (
driver/drivercmd); nothing in this document depends on it.
Terms:
- A build ID is eight lowercase letters and digits, made by the orchestrator for one build. A driver names everything it creates for a build from it.
- A probe is a request that asks a driver to check what it would check before doing any work, and to do nothing else (Probes).
- A linked driver is a driver compiled into
wardenitself, reached through the same sequence as Go calls. It is an implementation detail of the reference orchestrator while the bundled drivers become binaries; a requirement of this document on "a driver" is a requirement on a driver binary.
Outside this document:
- The claim and the tunnel the orchestrator opens on the relay: seam 1, the
specification
relay-claim. This document says only where the claim is sent and which of its fields the driver supplies. - What the relay and the collector exchange:
collector-outputsandcollector-inputs. - The executor's
initialize, the bootstrap config and what the build environment is served:executor-initialize,bootstrap-config,relay-guest-api. - The orchestrator's own command line, configuration and output, beyond what this document requires of them.
What a driver needs besides this contract
This contract says how an orchestrator runs a driver. A driver that is to run real builds also has to start the project's relay and executor correctly, and those are other seams, not all of them written yet:
| A driver must | Stated by |
|---|---|
| Launch the project's relay in one of its release forms, and give it its pre-claim values (the claim token and the address it accepts the claim on) on its boot channel | Seam 8 (relay release forms), not yet written; seam 1, relay-claim, for the pre-claim values |
Report an environment record for the claim (claim_values.environment) | Seam 4, metadata-environment |
Deliver the executor and start it once (warden-io initialize), and nothing else out of band | Seam 5, executor-initialize |
| Report the guest OS, which selects the bootstrap config | Seam 6, bootstrap-config |
| Make the relay the build's only network path | Seam 7, the build-link contract, not yet written |
Until each exists, the reference for it is the bundled drivers' source. The conformance suite checks none of them: it tests the commands and the build's lifecycle.
Finding a driver
Names and files
DRV-1. A driver's name MUST match [a-z][a-z0-9]{0,31} and MUST NOT be
the name of a command of the orchestrator. The name is used as a TOML table
([driver.<name>]), in lock and record file names and as the orchestrator's
subcommand that reaches the driver's own commands (ext).
DRV-2. A driver's file MUST be named warden-driver-<name>, and on
Windows warden-driver-<name>.exe. On Windows a file of another extension
(.bat, .cmd) MUST NOT be taken for a driver: a batch file runs under
cmd.exe, whose quoting no other program's matches, and the process the
orchestrator starts and stops would be cmd.exe and not the driver.
DRV-3. The name a driver reports in describe MUST be the name the
orchestrator looked up, and the base name of its file without .exe MUST be
warden-driver- followed by it. The orchestrator MUST refuse a driver whose
describe reports another name.
warden's commands, the names no driver may take: build, shell,
doctor, setup, image, clean, inspect, driver, help,
completion. While the Hyper-V driver is linked into warden, hyperv is
also a warden command (warden hyperv service ...).
Selection
The orchestrator selects one driver by its first source that is set: its
--driver flag, the variable WARDEN_DRIVER, [runtime] driver in the
config file, else the name container.
DRV-4. A selection that contains a path separator (/, and \ on
Windows) is a path; anything else is a name. A path MAY come from
--driver or WARDEN_DRIVER, and a relative one is taken against the
working directory. A config file MUST NOT name a driver by path: the
orchestrator MUST refuse a path in [runtime] driver, naming the file, with
the two places a path may come from as the fix. It MAY select any driver by
name.
DRV-5. There is no auto-detection, and a name that is not found MUST be an error that says where the orchestrator looked. It MUST NOT be replaced by another driver.
Lookup
DRV-6. A selection is resolved once per invocation to an absolute path, which every later command of that invocation runs. The first match wins:
- A path. The file is used as given and nothing else is searched.
PATH. Each entry inPATH's order is searched for the driver's file name, and the first candidate is the driver.- The directory of the orchestrator's own executable, symbolic links
resolved, when
PATHgave nothing. - A driver linked into the orchestrator, when the name is one.
DRV-7. A file named by path MUST exist and, after symbolic links are resolved, be a regular file the user may execute; otherwise the orchestrator MUST refuse it with an error that names the file and what is wrong with it.
DRV-8. On PATH and in the orchestrator's directory, a directory, or a
file without execute permission, is not a candidate, and the search goes on.
The orchestrator SHOULD show a file it passed over this way, with the reason,
where it lists drivers and in its not-found error.
DRV-9. A candidate reached through a relative PATH entry, or on Unix an
empty one, MUST NOT be run, and the lookup MUST stop there with an error that
names the entry and the file. On Windows the orchestrator MUST NOT search the
current directory before PATH, and it skips an empty entry.
DRV-10. Candidates are compared by identity after symbolic links are resolved. A candidate that is the same file as the driver's file in the orchestrator's own directory is the bundled copy, whichever step met it. Two candidates that are one file are one candidate.
Nothing in the lookup compares owners, modes or directory permissions: what is
on PATH is the user's to arrange, and a file earlier on PATH replaces a
driver the orchestrator ships. warden shows the result (warden driver list) and records it in the build's output (driver.json).
Finding the driver before the command line is parsed
The orchestrator cannot parse a command line before it knows the driver's
flags, and it knows them only from the driver's describe. So it finds the
driver from the raw arguments first.
DRV-11. The orchestrator MUST find the driver by this scan, which needs the arity of no flag but its own:
- The
extform. When the argument right after the orchestrator's name is not a flag and not one of its commands, the line is<orchestrator> <name> <args...>: the driver is<name>, and nothing after it is the orchestrator's. - Otherwise, the command. The orchestrator's own persistent flags are skipped from the left; the first argument after them that is not a flag names the command. A command that selects no driver stops here.
- Then
--driver. The arguments are scanned left to right, up to a--argument or the end.--driver <value>takes the next argument as its value, whatever it looks like;--driver=<value>holds its own; the last wins.--configis found by the same scan, in the same forms. - With no
--driver, the selection isWARDEN_DRIVER, else[runtime] driverfrom the config file the scan found, elsecontainer.
DRV-12. After describe, the orchestrator MUST parse the line with the
flags the driver declares (DRV-C1), and MUST refuse a line whose parsed
--driver or --config is not the one its scan found (as in build --network --driver hyperv, where a flag that takes a value took --driver
as it), naming the flag that took it.
DRV-13. The orchestrator MUST refuse, before it runs any driver command
but describe, a flag that neither it nor the selected driver declares for
the command.
Reserved flag names
A flag of the orchestrator's on a command is a name a driver cannot declare
for that command (DRV-C1). warden's, without their dashes:
| Commands | Names |
|---|---|
| Every command | driver, config, verbose, color, help, version |
run (warden build, warden shell) | capture, output, no-compress, timeout, tmpdir, quiet, guest-os, script, image, cpus, memory, keep-vms, build-link |
doctor | build-link |
image-prepare | os, source |
clean | cache |
Commands
Invocation
DRV-14. The command is the driver's first argument (argv[1]). describe
takes no request. Every other command takes one request, a JSON object that
carries contract, the version the orchestrator chose (Versions).
DRV-15. The request MUST be written on the driver's standard input, except
for attach and ext, which inherit the terminal's standard input: for those
two the orchestrator writes the request to a file and names it in the
environment variable WARDEN_DRIVER_REQUEST.
DRV-16. describe and run own their standard output: every byte a
driver writes there MUST be the command's output as this document gives it.
Every other command inherits the terminal for standard output and standard
error, prints its own lines there, and MUST write its result as one JSON
object to the file the environment variable WARDEN_DRIVER_RESULT names.
DRV-17. The orchestrator MUST create the request and result files with mode 0600 in its own temporary directory, and MUST remove them when the command has ended.
DRV-18. A secret travels only in a request on standard input. The
orchestrator MUST NOT put a secret in a driver's arguments, its environment or
a file, and a driver SHOULD declare no flag that takes one (a build's args
are kept in its record).
DRV-19. Paths in requests are UTF-8 strings. The orchestrator MUST refuse, before it starts the driver, a context, output or temporary path that is not valid UTF-8, with an error the user can act on.
DRV-20. An orchestrator and a driver MUST each ignore a field of a JSON
object that they do not know, in describe, a request, a result and a
message, and a message whose type they do not know.
Exit codes
DRV-21. For every command but attach and ext, a driver MUST exit with
one of these codes:
| Code | Meaning |
|---|---|
| 0 | Done |
| 1 | Failed: the result (for run, the failed message) carries an error object |
| 2 | The request is not valid for this contract version |
| 3 | The command is not implemented by this driver |
| 4 | No contract version in common |
DRV-22. Another exit code, a result file that is missing or not one JSON object, or output that is not what the command owes, is a defect of the driver; the orchestrator MUST report it as one (Errors), and MUST NOT take it for success.
The commands and their requests
| Command | Required | Request | Result | Exit |
|---|---|---|---|---|
describe | yes | none | One JSON object on standard output (describe) | 0 |
run | yes | start on standard input, then messages | Messages on standard output (The build) | 0 after stopped, 1 after failed |
reap <build-id> | yes | reap | {removed} | 0, 1 |
doctor | no | doctor | {blocked} | 0, 1 |
setup | no | setup | {} | 0, 1 |
image-prepare | no | image-prepare | {path} | 0, 1 |
image-list | no | image-list | {count} | 0, 1 |
image-verify | no | image-verify | {checked, drift} | 0, 1 |
clean | no | clean | {removed} | 0, 1 |
attach <build-id> | when capabilities.shell | attach, in the request file | {}, or {error} | The shell's own |
ext <args...> | when describe.ext is not empty | ext, in the request file; the arguments in argv, as typed | none | The driver's own |
DRV-23. A driver MUST implement describe, run and reap. Every
command it implements but describe MUST be listed in describe.commands,
and a command of this table that it does not list MUST exit 3 with an
unsupported-command error.
DRV-24. reap <build-id> removes whatever the build of that ID left. Exit
0 MUST mean that nothing of that build is left; reap MAY be repeated, and a
reap of an ID that never existed exits 0 with removed: 0. When the driver
cannot look where the build's leftovers would be (its runtime does not
answer, it is on another host), it MUST exit 1 with a fixable error; it
MUST NOT report success for a place it could not look in. reap is sent the
values the build was started with (The build record), and works from the
state file (DRV-C10).
DRV-25. doctor reports on standard output whether this host can run the
driver's builds, and MUST change nothing on the host. Its result's blocked
is true when a build could not run.
DRV-26. setup makes the one-time host changes the driver needs, and MAY
be repeated. image-prepare prepares a base image for os from source,
with progress on standard error, and returns its path, or an empty path when
it has already reported the outcome. image-list prints one line per prepared
image and returns their count. image-verify prints one line per cached
layer and returns how many it checked and how many showed drift. doctor
and image-list MUST change nothing under the temporary directory they are
given.
DRV-27. clean removes the driver's leftovers of every build whose ID is
not in keep_ids, printing a Removing ... line on standard error for each,
and its own cache when cache is true. It returns how many it removed. A
driver whose resources are shared between users SHOULD keep a liveness check
of its own beside keep_ids, which holds only the builds whose locks this
user's orchestrator can see (The build lock).
DRV-28. attach <build-id> enters the shell of a build started with
mode: shell, on the inherited terminal, and exits with the shell's own exit
code. When the attach itself failed, the driver MUST write an error object
to its result. The orchestrator MUST exit with the shell's code when the
result holds no error, and MUST print the error and exit 1 when it does.
DRV-29. ext <args...> runs the driver's own subcommands, which
describe.ext lists, with the arguments as typed. The orchestrator MUST run a
line <orchestrator> <name> <args...> (DRV-11) as ext <args...> on the
driver <name>.
Probes
DRV-30. Any request MAY carry "probe": true. A driver given a probe MUST
check contract, read and check its own flags and keys from args and
config_file (DRV-C7), make the checks it would make before doing any work,
create nothing, and exit 0 or with its refusal.
DRV-31. A driver MUST answer a probe within 30 s.
DRV-32. A probe of run is a start message with probe: true and
without build_id, claim_token, build_script, diagnostics_dir and
state_file. The driver answers it with one message, stopped or failed,
and exits.
DRV-33. The orchestrator MUST probe run before it takes the build's lock,
creates its output directory or stages anything, so that a bad value of a
driver's flag or key, or a host that cannot run the build, is refused before
anything is left behind. The orchestrator SHOULD likewise probe clean before
it reaps any dead build in its clean command.
Commands not started by the orchestrator
DRV-34. A driver's ext started with no WARDEN_DRIVER_REQUEST (a process
the operating system starts, such as a registered service) MUST run with no
config file and the driver's defaults. It MUST NOT exit 2 for the missing
request, and MUST NOT look for a config file by itself (DRV-C3).
DRV-35. A driver that starts one of its own commands as a process (a detached refresh) MUST write that command's request itself, as the orchestrator would.
describe
DRV-36. describe MUST exit 0 within 10 s, print exactly one JSON object
on standard output and nothing else, have no side effects, and print the same
object each time it is run.
{"contract": [1],
"name": "qemu", "version": "0.9.0", "vendor": "buildwarden",
"bug_url": "https://github.com/buildwarden/buildwarden/issues/new",
"commands": ["run", "reap", "doctor", "image-prepare", "image-list", "image-verify"],
"capabilities": {"vm": true, "shell": false, "keep": "stopped", "exited": false,
"containerfile": "translate", "guest_os": ["linux", "windows"],
"image_os": ["linux", "windows"], "default_image_os": "linux",
"reserved_ranges": ["10.0.2.0/24"]},
"flags": [{"name": "edition", "value": true, "commands": ["image-prepare"],
"usage": "Windows edition / install.wim image name (qemu windows)"},
{"name": "force", "value": false, "commands": ["image-prepare"],
"usage": "re-acquire even if a valid cached copy exists"}],
"keys": [{"key": "driver.image_refresh_after", "type": "string",
"aliases": ["vm.image_refresh_after"], "commands": ["run"],
"usage": "age after which a prepared Windows layer is refreshed"}],
"ext": [],
"help": {"doctor": "Checks qemu-system and qemu-img on PATH."}}
| Field | Meaning |
|---|---|
contract | The contract versions the driver speaks, as integers |
name | The driver's name (DRV-1, DRV-3) |
version, vendor, bug_url | The driver's own version, its vendor and where its bugs are reported, for the build's record and the text of a defect |
commands | The commands it implements, describe aside |
capabilities.vm | It boots a separate build machine: it takes the shared VM settings (start.vm) and builds a script or a Containerfile. Without it, it builds a Containerfile only, and the orchestrator refuses its VM flags |
capabilities.shell | run accepts mode: "shell", and attach is implemented |
capabilities.keep | What the orchestrator's keep request (warden --keep-vms) leaves: running (the machines), stopped (the work directory only) or none, for which the orchestrator refuses the request |
capabilities.exited | It sends exited when its relay or its environment stops on its own |
capabilities.containerfile | translate: the orchestrator translates a Containerfile to the build script and sends its base image. ignore: the guest cannot run one, and the orchestrator drops it and records nothing |
capabilities.guest_os | The guest OS values the orchestrator accepts for it; the first is sent when none is asked for |
capabilities.image_os, default_image_os | The OS values image-prepare takes, and the one it takes when none is given |
capabilities.reserved_ranges | Fixed address ranges it uses on the host, as CIDR prefixes; a build link must not overlap them |
flags | The flags it takes (DRV-C1) |
keys | The config keys it reads (DRV-C4) |
ext | Its own subcommands, each a path of words and a usage line |
help | A paragraph of its own for a command's long help, keyed by command |
DRV-37. describe MUST be consistent with itself: run and reap are in
commands; attach is listed exactly when capabilities.shell is true;
ext exactly when the ext list is not empty; and capabilities.image_os
is present exactly when image-prepare is listed.
DRV-38. The orchestrator MUST run describe on the selected driver only,
once per invocation, and MUST refuse a describe that does not match the
schema, lists no contract version it speaks, lacks run or reap, reports a
name other than the one looked up, declares a flag whose name it uses on the
same command, or declares a key outside the driver's place in the config file
(DRV-C4). Each refusal names the field it is about.
The build
Messages
run is one process per build. The orchestrator writes messages to the
driver's standard input and reads the driver's from its standard output.
DRV-39. A message is one JSON object on one line, UTF-8, ending with a
newline, at most 1 MiB long, and has a type. A driver's standard output in
run MUST hold nothing but messages.
DRV-40. A driver's standard error in run is its human-readable log. The
orchestrator MUST read it, pass it on to its own standard error, and keep its
tail for an error report.
| From | type | Carries |
|---|---|---|
| orchestrator | start | The build (below) |
| driver | relay-started | claim, claim_values, guest_os, old_relay_fix |
| orchestrator | claimed | Nothing: the relay is configured and ready |
| driver | environment-started | Nothing |
| driver | exited (optional) | which (relay or build) and detail |
| orchestrator | stop | reason and detail |
| driver | stopped | kept: the paths and names left behind under keep |
| driver | failed | error |
{"type": "start", "contract": 1, "build_id": "k3v9x2ab", "mode": "build",
"claim_token": "c2VjcmV0LXRva2Vu", "guest_os": "linux", "image": "",
"base_image": "alpine:3.21",
"build_script": "/tmp/warden-stage-k3v9x2ab/build.sh",
"context_dir": "/home/ana/project", "tmpdir": "",
"diagnostics_dir": "/home/ana/project/warden-output",
"state_file": "/home/ana/.cache/buildwarden/locks/build-qemu-k3v9x2ab.state",
"keep": false, "verbose": false,
"vm": {"cpus": 8, "memory_mb": 0, "build_link": "", "build_link_source": "default",
"dns": []},
"config_file": "/home/ana/project/warden.toml",
"args": ["--network=warden-ci"]}
The fields of start:
| Field | Meaning |
|---|---|
build_id | The build ID (Scope and roles) |
mode | build runs the build script. shell holds the environment after setup for attach; only for a driver with capabilities.shell |
claim_token | The claim token. The driver puts it on the relay's boot channel, where it is one of the relay's pre-claim values. It is the only secret a driver is given |
guest_os | The guest OS asked for, or the first of the driver's capabilities.guest_os |
image | The image the user named, or empty |
base_image | The FROM image of the build's Containerfile, as written there, whenever the build has a Containerfile and the driver's capabilities.containerfile is translate, whether or not the build script was translated from it. Empty when there is no Containerfile, when it cannot be parsed, or when its FROM is scratch. The driver resolves it to what it boots or runs |
build_script | The absolute path of the staged build script. The driver may read it to describe the environment; it never serves it (the collector does) |
context_dir | The build context, absolute |
tmpdir | Where work directories are made; empty means the system's |
diagnostics_dir | The build's output directory. The driver may write relay.log and console.log there, and nothing else |
state_file | The absolute path of the build's state file (The build record) |
keep | Leave what capabilities.keep names in place, and report it in kept. True only when capabilities.keep is not none |
verbose | The user asked for verbose output |
vm | For a driver with capabilities.vm: {cpus, memory_mb, build_link, build_link_source, dns}. Zero or empty means "not set", and the driver applies its default |
config_file, args | The driver's configuration (Configuration) |
probe | A probe (DRV-32) |
collector | Reserved. Never sent in version 1 |
DRV-41. The orchestrator MUST send collector in no message of version 1.
{"type": "relay-started",
"claim": {"network": "tcp", "address": "127.0.0.1:41233"},
"claim_values": {
"environment": {"type": "vm-disk-chain/v1", "payload": "eyJ0eXBlIjoidm0tZGlzay1jaGFpbi92MSJ9",
"metadata": null},
"build_link": {"prefix": "10.9.0.0/30", "relay": "10.9.0.1", "guest": "10.9.0.2"},
"upstream_dns": ["10.20.0.53"]},
"guest_os": "linux",
"old_relay_fix": "reinstall warden so its relay binary matches it"}
DRV-42. claim.address is where the relay accepts its claim, and MUST be
reachable from the orchestrator's process as the user it runs as.
claim.network is an enumeration whose only value in version 1 is tcp.
DRV-43. The orchestrator MUST copy claim_values into the claim
unchanged, as its environment, build_link and upstream_dns fields; their
shape is the claim protocol's (relay-claim), not this document's. A driver
supplies no other claim field: collector_url, collector_token,
capture_mode and the upstream CA fields are the orchestrator's.
DRV-44. relay-started's guest_os is the guest the environment really
runs, and selects the bootstrap config the collector serves; it MAY differ
from the one asked for. old_relay_fix is the fix the orchestrator shows if
the relay refuses a claim field as unknown.
{"type": "claimed"}
{"type": "environment-started"}
{"type": "exited", "which": "build", "detail": "the build VM powered off"}
{"type": "stop", "reason": "completed", "detail": "the build script exited 0"}
reason is one of completed, failed, interrupted, timeout and
shell-exited; detail is a sentence for the driver's log (for failed,
what failed, such as the claim's error).
{"type": "stopped", "kept": ["/tmp/warden-qemu-k3v9x2ab"]}
{"type": "failed", "error": {"code": "fixable",
"msg": "qemu-system-aarch64 not found on PATH",
"fix": "install qemu (brew install qemu)"}}
The sequence
DRV-45. A build follows this order. The actor is named at each step.
- The orchestrator runs
describe, picks the contract version, parses the command line with the driver's flags, and probesrun. - The orchestrator makes the build ID, takes the build lock and writes the build record (The build lock).
- The orchestrator creates the output directory and stages the build
script; for
capabilities.containerfile: ignoreit drops the Containerfile first. - The orchestrator makes the claim token, starts
runand sendsstart. A build's time limit counts from here. - The driver writes its state file if it needs one, starts the relay with
the claim token, and sends
relay-started. - The orchestrator starts the collector, with the
guest_osthe driver reported, and claims the relay atclaim.address: it opens the tunnel, sends the claim, and waits for the relay's ready, at most 90 s from the start of the claim. - The orchestrator sends
claimed. The driver isolates the environment, delivers the executor, starts it, and sendsenvironment-started. - The collector takes the console output, heartbeats and completion. The driver's messages carry none of them.
- The orchestrator sends
stopwhen the build completes, fails, times out or is interrupted. The driver writes its diagnostics, tears down everything it created (underkeep, all but whatcapabilities.keepleaves), sendsstopped, and exits 0.
DRV-46. A driver MUST send relay-started before it starts the build
environment, and MUST NOT start the build environment before it has read
claimed: the relay is claimed and configured before the environment
exists.
DRV-47. A driver MUST send environment-started only after claimed, and
at most once.
DRV-48. A driver MAY send exited at any time after relay-started. On
which: relay the orchestrator MUST cancel a claim in progress, or fail the
build at once. On which: build it MUST give the build 10 s to deliver a
completion already on its way, and then fail it.
DRV-49. A driver's last message MUST be exactly one of stopped and
failed, sent after it has torn down. stopped answers stop or the end of
its input. failed MAY be sent at any time, without waiting for stop, when
the driver itself cannot go on.
DRV-50. A driver MUST treat the end of its standard input as it treats
stop: tear down, then exit. A run whose input ends before start MUST
exit without writing anything to standard output.
DRV-51. After the end of its input a driver MUST complete its teardown whether or not it can still write to its standard output and standard error, itself or through a child. (On Unix, a process that writes to a closed pipe is killed by SIGPIPE unless it ignores it.)
DRV-52. The orchestrator MUST start run in its own process group, so that
the terminal's signals reach the orchestrator only. On the first interrupt or
termination signal it MUST send stop (reason: interrupted), close the
driver's input, and wait for stopped or failed for its teardown wait. A
second signal, or the wait passing, MUST kill the driver's process group (on
Windows, its process) and run reap <build-id>.
The teardown wait is the orchestrator's own setting; warden's is [build] teardown_timeout, 60 s unless set. warden bounds the reap it runs after a
kill by the same wait, and an interrupted build exits 130.
DRV-53. In shell mode the driver sends environment-started once the
shell can be entered. The orchestrator then runs attach <build-id> and,
when it ends, sends stop with reason: shell-exited.
When something fails
DRV-54. Each failure has one outcome:
| What fails | When | Sent | What the orchestrator does |
|---|---|---|---|
| The driver refuses the build (its preflight, or the relay cannot start) | Before relay-started | The driver removes what it made, sends failed and exits 1 | Prints the error. Runs no reap. Removes the build's stage directory, record and lock |
| The orchestrator's claim fails or times out | After relay-started | stop with reason: failed and the claim's error as detail; the driver tears down and sends stopped | Prints the claim's error, with old_relay_fix when the relay refused a field; exits 1 |
| The relay exits | Any time after relay-started | The driver sends exited, which: relay | Cancels a claim in progress, or fails the build at once; then stop with reason: failed |
| The environment cannot be started | After claimed | The driver tears down, sends failed and exits 1 | Prints the error. Runs no reap |
| The environment exits before the build completes | After environment-started | The driver sends exited, which: build | Waits 10 s for a completion, then fails the build; stop with reason: failed |
The driver's process ends with neither stopped nor failed, writes a line that is not a JSON object, or does not stop within the teardown wait | Any time | Nothing | Kills the driver's process group, shows the tail of its standard error as a driver defect, and runs reap <build-id> with the record's values. A completion the collector already holds stands, with the defect reported beside it; otherwise the build fails. When that reap fails or does not finish, the record and lock stay |
failed and stopped both promise that the driver has torn down, so the
orchestrator runs reap only when it got neither.
The build lock
The convention below is how an orchestrator says which builds are alive. Every orchestrator that runs builds on a driver follows it, the conformance suite included.
DRV-55. The lock directory is <user cache directory>/buildwarden/locks,
mode 0700 (on Linux $XDG_CACHE_HOME, else ~/.cache; on macOS
~/Library/Caches; on Windows %LocalAppData%). For a build of the driver
<name> with the ID <id>, the orchestrator keeps three files there:
| File | Written by | Holds |
|---|---|---|
build-<name>-<id>.lock | The orchestrator | Nothing. The orchestrator holds an exclusive OS file lock on it for the life of the build, released by the operating system if the orchestrator dies. A held lock means the build is live |
build-<name>-<id>.json | The orchestrator, before it creates anything else | The build record (below) |
build-<name>-<id>.state | The driver, if it needs one | The state file (below) |
DRV-56. The orchestrator MUST take the lock before it writes the record and before it creates anything else for the build. After it holds the lock it MUST check that the path still names the file it locked, and start again with a new file when it does not.
DRV-57. An orchestrator MUST remove a lock file only while it holds that
lock, after the same check. It removes the three files when the build ends
cleanly, and otherwise only after a reap of the build that exited 0.
DRV-58. keep_ids in a clean request MUST be the IDs of the driver's
build locks that are held when the request is made.
The build record
DRV-59. The record holds the driver's name, the path and SHA-256 digest of
its file (or that it is linked), the contract version, the build's temporary
directory and stage directory, and the config_file and args that run
was started with. It MUST hold no secret: the claim token is not in it.
DRV-60. reap and attach MUST be sent the record's tmpdir,
config_file and args and the state file's path, whoever runs them and
whenever, and not those of the invocation that runs them.
DRV-61. The state file is the driver's to write for one build: whatever it
needs to find the build again that the ID does not give, and everything it
resolved from its configuration that attach or reap depends on. It MUST
be at most 64 KiB, and the driver MUST write it before it creates the thing
its content describes. It is opaque to the orchestrator.
The record names the config file and repeats the flags; it does not freeze
what the file said. A value reap or attach depends on therefore belongs
in the state file (DRV-C10).
Configuration
A driver reads its own configuration, in its own process: its flags from the
request's args, and its keys from the one config file the request names.
The orchestrator reads its own flags and keys, looks at none of the driver's
values, and sends the driver none of its own beyond the fields of the
requests.
DRV-62. Every request MUST carry config_file when the orchestrator has a
config file for the invocation, and every request of a command that takes
flags MUST carry args.
| Field | Holds |
|---|---|
config_file | The absolute path of the one config file the orchestrator read, or would read, for this invocation: for warden, the file --config names, else the one WARDEN_CONFIG names, else ./warden.toml when it exists. Absent when there is none. Never a list, and it says nothing of how the file was found. The file is TOML v1.1.0 |
args | The driver's flags from the command line. A flag declared with a value: one element per occurrence, in the order typed, as --name=value, whether it was typed --name value or --name=value; the value's bytes unchanged, an empty value included. A switch (a flag declared without a value): --name, once, when the switch is on, and nothing when it is off. Empty when the user gave none |
DRV-63. The orchestrator MUST settle a switch itself: it MUST NOT send
--name=false or --name=true, and a switch that is off is absent.
A driver is not told whether its file is the defaulted ./warden.toml, which
may have come with a build context someone else wrote, or a file the user
named. A driver whose key names a program or a host path SHOULD take the file
for the first, and the safe form of such a key is a closed list of names.
Flags
{"name": "network", "value": true, "commands": ["run", "doctor", "setup"],
"usage": "durable build switch name (default: [driver.hyperv] network, then warden-dev)"}
| Field | Meaning |
|---|---|
name | The flag without its dashes, [a-z][a-z0-9-]*. There are no short forms |
value | True when the flag takes a value, false for a switch |
commands | The commands that take it, each one the driver lists: run, doctor, setup, image-prepare, clean. image-list and image-verify take none. Everything after <orchestrator> <name> is ext's, in its argv |
usage | One line for help |
The orchestrator places a declared flag and does nothing else with it: it does not know its type, read its value or apply a default. A driver's flag is accepted after the subcommand's name; one declared for every command the driver lists is also accepted before it.
Keys and their two tables
A driver's keys have two tables in the config file:
| Table | Holds | Who says what a key means |
|---|---|---|
[driver] | The common keys: a short list of keys that more than one driver reads and means the same thing by | This document (The common keys of version 1) |
[driver.<name>] | That driver's overrides of the common keys it honours, each under the common key's own name; and the driver's own keys, in any shape | This document for an override; the driver for its own keys |
The orchestrator reads neither table. [runtime] driver selects the driver
and is the orchestrator's; [driver] configures drivers and selects nothing.
{"key": "driver.hyperv.network", "type": "string", "aliases": ["vm.network"],
"commands": ["run", "doctor", "setup"], "usage": "durable build switch name"}
| Field | Meaning |
|---|---|
key | The key as a dotted path: a common key the driver honours as driver.<key>, which also stands for its override driver.<name>.<key>; a key of its own under driver.<name>. |
type | The TOML type of its value: string, integer, float, boolean, array, table, or any for a key whose shape the driver does not state |
aliases | The key's deprecated old names, each one this document lists for the driver's name (Old names) |
commands | The commands that read it |
usage | One line |
The common keys of version 1
| Key | Type | Meaning |
|---|---|---|
image_refresh_after | A string holding an age, such as "7d" or "36h" | The age at which a prepared base image is prepared again in the background; the build goes on with the image it has |
image_min_grace | A string holding an age | The least evaluation grace a prepared image must still have; a build on an image with less is refused |
An age is a Go duration ("90m", "36h"), or a whole or fractional number
of days followed by d ("7d", "1.5d"). The value a driver uses when
nobody sets a key is the driver's to state.
DRV-64. A common key's name matches [a-z][a-z0-9_]*. A later version
that names a common key without an underscore MUST also refuse that name for
a driver, since [driver] <key> and a driver of that name would claim one
place in the file.
The precedence
For one setting of the driver <name>, the first of these that sets it is the
value:
- its flag, in
args; - its environment variable, where this document gives it one (DRV-C9);
[driver.<name>]in the config file;[driver]in the config file, for a common key;- nothing: the driver's default.
A key of the driver's own has no place in [driver], so for it step 4 does
not exist. In words: the flag, then the variable, then the file, and in the
file the driver's own table before [driver]. Nothing is merged, and no step
is a fallback: a value found at one step that the driver cannot use is an
error that names where it was found, and the next step is not tried.
A worked example, with drivers named hyperv, qemu and container whose
defaults for the two ages are 7d and 1d:
# warden.toml
[driver]
image_refresh_after = "3d"
[driver.hyperv]
image_refresh_after = "12h"
[driver.qemu]
image_min_grace = "6h"
[driver.container]
cli = "podman"
| Driver | Setting | Value | Step |
|---|---|---|---|
| hyperv | image_refresh_after | 12h | 3: its own table. [driver]'s 3d is not reached |
| hyperv | image_min_grace | 1d | 5: nothing sets it for hyperv, so its default. [driver.qemu] is not hyperv's table |
| qemu | image_refresh_after | 3d | 4: [driver] |
| qemu | image_min_grace | 6h | 3: its own table |
| container | cli | podman | 3. With WARDEN_CTR_CLI=docker in the environment, docker (step 2); with --runtime finch as well, finch (step 1) |
| container | the two ages | not read | It lists neither key |
Old names
Seven keys of the bundled drivers had other names before this contract. Each old name is a deprecated second name for the same key, read as the key itself until BuildWarden 1.0, and only by a driver of that name:
| Driver name | Old name | Key |
|---|---|---|
container | runtime.cli | driver.container.cli |
container | runtime.relay_image | driver.container.relay_image |
qemu | vm.image_refresh_after | driver.image_refresh_after |
qemu | vm.image_min_grace | driver.image_min_grace |
hyperv | vm.image_refresh_after | driver.image_refresh_after |
hyperv | vm.image_min_grace | driver.image_min_grace |
hyperv | vm.network | driver.hyperv.network |
hyperv | vm.windows_image | driver.hyperv.windows_image |
hyperv | vm.windows_image_update | driver.hyperv.windows_image_update |
An old name stands where its key stands: [vm] image_refresh_after is step 4,
below the driver's own table; [runtime] cli is step 3. An old name in
another letter case, such as [Runtime] CLI, is refused as DRV-C12 says, and
the key to write is the new name.
The environment variables of version 1 are the container driver's two:
WARDEN_CTR_CLI for driver.container.cli and WARDEN_IMAGE for
driver.container.relay_image.
The configuration requirements
DRV-C1. A driver MUST declare every flag it takes in describe.flags,
with its arity and its commands, and MUST use no name the orchestrator uses
on the same command (Reserved flag names). Each command a flag names MUST be
one the driver lists.
DRV-C2. A driver MUST take each declared flag from args: a flag with a
value as --name=value (for a flag that holds one value, the last occurrence
wins), a switch as --name, on when present and off when absent. It MUST
refuse an element it did not declare for the command with a fixable error
that names it.
DRV-C3. A driver MUST read configuration only from the file named in
config_file. It MUST NOT look for a warden.toml by itself, in its working
directory or through WARDEN_CONFIG, which it inherits from the
orchestrator. Sent no config_file, or started with no request, it reads no
file and uses its defaults.
DRV-C4. A driver MUST list the keys it reads in describe.keys, each in
its place in the config file and with the commands that read it: a common key
it honours as driver.<key>, with the type this document gives it; a key of
its own under driver.<name>., with the TOML type of its value (or any)
and a name that is no common key's. Listing a common key is also listing its
override, driver.<name>.<key>. It MUST read nothing in [driver] that it
did not list, and no override of a common key it did not list. No two places
where a driver's listed keys may be written (each key's name, the override of
each common key it lists, and each old name) may be equal when ASCII letters
are folded.
DRV-C5. A driver MUST ignore every table and key it does not own: the
orchestrator's tables, another driver's table, and a common key it does not
list, in [driver] and in its own table, except as DRV-C12 says. It MUST
read any file the orchestrator reads: the file is TOML v1.1.0.
DRV-C6. When it lists a key, a driver MUST refuse a config_file that does
not exist, cannot be read or cannot be parsed, and a key of its own whose
value has the wrong type, with a fixable error that names the file, and the
key where there is one (not in reap and attach: DRV-C10). A file that was
named and is missing MUST NOT be read as if none had been named, and no other
file is tried in its place.
DRV-C7. A driver MUST read and check all of its configuration before any
work: in the probe of run, and first in every other command but reap and
attach (DRV-C10).
DRV-C8. A driver MUST apply the precedence: a flag, else the setting's
environment variable where this document gives it one (DRV-C9), else the key
in config_file, else its default. A common key is read from the driver's
own table, and from [driver] only when that table does not set it. A flag
given with an empty value, and a variable that is set but empty, are not set,
and the next place is read. The place that sets a value is the value, not
merged with another, and an unusable value is an error, never replaced by a
lower place's value or by the default. What an empty string in the file means
is the driver's.
DRV-C9. A driver MUST take its settings as flags and keys, not as
environment variables of its own. The two that exist, WARDEN_CTR_CLI and
WARDEN_IMAGE, stay the container driver's.
DRV-C10. In reap and attach, a driver MUST take from the state file
what it holds, and MUST NOT resolve it again from args and config_file. It
MUST read a config_file that no longer exists as if none had been named,
saying so on standard error, and MUST NOT fail the command for it. When a
state file exists, it MUST NOT fail because a recorded file cannot be parsed
or holds a value it would refuse. When no state file exists, a driver that
still wants a setting resolves it from the record's args and the recorded
file if it exists; a file that is there and cannot be used is a fixable
error that names it.
DRV-C11. A driver MUST read a key under an old name only where this
document lists that name for the driver's own name, and then as the same key.
It MUST refuse a file that sets a key under both names, with a fixable error
that names the file and both names. It MUST say on standard error, once per
old name the file sets, that the name is deprecated and what the new one is:
when it answers a probe, and in a request that is not a probe only for a
command the orchestrator does not probe first (doctor, setup, the image
commands, ext); so not in a run or clean that is not a probe, nor in
reap or attach. A driver whose name has no old names reads none.
DRV-C12. A driver MUST refuse a config_file that holds, at a key path
equal, when ASCII letters are folded, to a place where one of its listed keys
may be written (the key's name, the override driver.<name>.<key> of a common
key it lists, an old name this document lists for it), a key that is not spelt
as that place, with a fixable error that names the file, each spelling found
and the key to write. It MUST do so at the points DRV-C7 gives, before it
reads the value or applies DRV-C11; in reap and attach, only where DRV-C10
has it resolve a setting from the recorded file because no state file exists.
A key that equals no listed place ignoring letter case is ignored (DRV-C5).
Requests and results
Every request carries contract, and MAY carry probe.
{"contract": 1, "build_id": "k3v9x2ab", "tmpdir": "",
"config_file": "/home/ana/project/warden.toml", "args": ["--runtime=docker"],
"state_file": "/home/ana/.cache/buildwarden/locks/build-container-k3v9x2ab.state"}
{"contract": 1, "vm": {"build_link": "", "build_link_source": "default"},
"config_file": "/home/ana/project/warden.toml", "args": [], "verbose": false}
{"contract": 1, "vm": {}, "args": ["--slots=2"], "verbose": true}
{"contract": 1, "os": "windows", "source": "/isos/win.iso",
"args": ["--force", "--edition=Windows Server 2025 Datacenter"], "verbose": false}
{"contract": 1, "config_file": "/home/ana/project/warden.toml"}
{"contract": 1}
{"contract": 1, "keep_ids": ["k3v9x2ab"], "cache": false, "tmpdir": "",
"args": [], "probe": true}
{"contract": 1, "build_id": "k3v9x2ab", "args": [],
"state_file": "/home/ana/.cache/buildwarden/locks/build-container-k3v9x2ab.state"}
{"contract": 1, "config_file": "/home/ana/project/warden.toml"}
The results:
{"removed": 4}
{"blocked": false}
{}
{"path": "/home/ana/.cache/warden/images/windows-server-2025.qcow2"}
{"count": 2}
{"checked": 3, "drift": 1}
{"removed": 0}
{"error": {"code": "fixable", "msg": "no build k3v9x2ab is held for a shell",
"fix": "start one with warden shell"}}
DRV-65. A command that exits 1 MUST put an error object in its result
(for run, in its failed message).
Errors
{"code": "internal", "msg": "relay container exited: exit status 125",
"details": {"container": "warden-relay-k3v9x2ab"}}
DRV-66. An error object has a code, a msg, and MAY have a fix and
details. code is one of:
code | Meaning | How the orchestrator reports it |
|---|---|---|
fixable | A known cause with a remedy, given in fix | The message and the fix, with no bug link |
busy | Another process already does this | The message |
invalid-request | The request was not valid (exit 2) | A defect of the orchestrator or the driver: bug text |
unsupported-command | The command is not implemented (exit 3) | For an optional command the driver did not list, the orchestrator never calls it; if returned anyway, a driver defect |
unsupported-contract | No contract version in common (exit 4) | An error the user can act on, naming both versions and which side to update |
internal | Anything else | The message, the tail of the driver's standard error, and bug text that names the driver, its version and its bug_url |
DRV-67. A driver defect (an exit code outside the table, a missing result,
a line on run's output that is not a JSON object) MUST be reported as
internal is, naming the driver and its bug_url, and not with the
orchestrator's own bug link.
DRV-68. A value of a driver's flag or key that it cannot use MUST be a
fixable error that names where the value came from: the flag as typed, the
variable, or the file with the table and key as written there. It is reported
at the points DRV-33 and DRV-C7 give, and exits 1, never 2.
Versions
DRV-69. describe.contract lists the versions a driver speaks. The
orchestrator MUST pick the highest version it also speaks and send it in every
request. With none in common, it MUST refuse the driver with an
unsupported-contract error, and a driver sent a version it does not list
MUST exit 4.
DRV-70. A request that is not a JSON object, or that is not valid for the
contract version, MUST make the driver exit 2 with an invalid-request error.
Adding a field, a command, a capability or a message type does not change the
contract version. Removing one, changing its meaning, or adding a common key
does: a driver and an orchestrator that agree on a version agree on what
[driver] holds. Version 1 is unstable until BuildWarden 1.0, and may change
in any release, its list of common keys with it. A driver's own version is
independent of the orchestrator's.
Requirements that are not machine-checked
Each requirement below is not checked by a case of the conformance suite, for the reason given; every other requirement is checked by a case that names it.
| Requirement | Why not |
|---|---|
| DRV-2 | Which files the orchestrator takes on Windows is the orchestrator's lookup, which the suite does not exercise; warden's own tests hold it |
| DRV-4, DRV-5, DRV-6, DRV-7, DRV-8, DRV-9, DRV-10, DRV-11, DRV-12, DRV-13 | Requirements on the orchestrator's lookup and command line, which the suite, playing the orchestrator, does not exercise; warden's own tests hold them |
| DRV-17, DRV-18 | Requirements on the orchestrator's files and arguments; the suite writes its own requests |
| DRV-19 | The orchestrator's refusal of a path before it starts a driver; warden's tests hold it |
| DRV-22, DRV-38, DRV-67, DRV-69 (the orchestrator's half) | How the orchestrator reports a defect or refuses a describe is its own; warden's tests hold them |
DRV-26 (setup, image-prepare, image-verify) | Their effects are host- and driver-specific and can take hours; only their exit codes and results are checked |
| DRV-28 (the orchestrator's half), DRV-29 | How the orchestrator maps the attach result and an ext line; warden's tests hold them |
| DRV-35 | A process the driver starts itself is not visible to the suite |
| DRV-40 | What the orchestrator does with the driver's standard error is its own |
| DRV-41 | A requirement on the orchestrator's messages |
| DRV-42 (reachability as the user) | The suite runs as one user, the one it checks from |
| DRV-43 (no other claim field) | The driver supplies claim_values only; what it cannot send is not observable beyond the schema |
DRV-44 (guest_os is the real guest) | The suite cannot see which guest runs |
DRV-46 (the environment not started before claimed) | The suite sees the order of the messages, not when the environment really started; the build-link suite holds isolation |
| DRV-52, DRV-54 (the orchestrator's column), DRV-56, DRV-57, DRV-59, DRV-60, DRV-62, DRV-63 | Requirements on the orchestrator; warden's tests hold them |
| DRV-61 (written before what it describes) | The suite sees the state file only after the fact |
| DRV-64 | A rule on later versions of this document |
| DRV-C8 | The suite does not know what a value means to a driver, so it cannot see which place won. The kit's tests hold it for a driver built on the kit, and the suite's self-test for the reference fake, which echoes its values and their places in a probe |
| DRV-C9 | A process may read any variable |
| DRV-C11 (the value used, both names refused, when the warning is printed) | The suite cannot make a value a driver accepts; the kit's tests hold it for each of the seven old names. That the old names in describe.keys are this document's, and that a wrong type under an old name is refused, is checked |
Contributing to BuildWarden
Thank you for your interest in contributing! This guide covers setup, building,
testing, and how a change gets merged. The standards a change is held to live in
docs/development/,
and the process for designing, reviewing and merging a feature is
process.md.
Setup
All platforms:
- Go at the version in
go.mod(we manage it with mise; runmise exec -- go ...if yourGOROOTis misconfigured) - golangci-lint v2
- A container runtime: finch, podman, or docker
- git 2.40 or later where the feature loop's
wfruns: its merge check proves a squash merge withgit merge-tree --merge-base, and with an older git it leaves the branch unconfirmed and says why
VZ driver (macOS 13+ on Apple Silicon):
- Xcode Command Line Tools, for cgo and Objective-C
- The host binary needs the virtualization entitlement.
make buildsigns it ad hoc; to sign by hand:codesign --sign - --entitlements entitlements.plist dist/warden
QEMU driver (any platform):
qemu-system-aarch64orqemu-system-x86_64, plusqemu-img(brew install qemuon macOS,apt install qemu-systemon Linux)
Hyper-V driver (Windows):
- Hyper-V and its management stack enabled
- Membership in Hyper-V Administrators, or an elevated terminal
- One-time network setup from an elevated terminal:
warden setup --driver hyperv
Firecracker driver (x86_64 Linux with KVM):
/dev/kvm, your user in thekvmgroup, andfirecrackerv1.17.0 or later onPATHiproute2,nftables,iptables,qemu-imgandgenisoimage(ormkisofs); the guest kernel build needsmake,gcc,flex,bison,bc,libelf-devandlibssl-dev- Boot assets and network slots, re-created after each host boot: installation.md
Building and testing
make build # Compile all binaries to dist/
make test # Unit tests: run on every platform, no external dependencies
make release-build # Compile what a release compiles: each target, without cgo
make lint # golangci-lint, then the tier-1 checks on your diff
make fmt # gofmt -s -w
make tidy # go mod tidy
make cover # Tests with a coverage report
make deadcode # Code unreachable on Linux, macOS and Windows
make integration-test # Real builds plus ledger checks; needs a container runtime
make driver-conformance # The driver suite's both tiers against DRIVER (default:
# dist/warden-driver-container, .exe on Windows); the lifecycle tier runs
# real builds; DRIVER_CONFORMANCE_FLAGS for the host;
# a case still running after the slowest case's
# worst path (3 h) fails as hung and ends the tier;
# --case-deadline <duration> changes it
make integration-test-vz # VZ end to end; needs macOS/arm64 and a prepared image
make clean # Remove built binaries
make build cross-compiles the relay and warden-io for linux/amd64 and
linux/arm64; on macOS/arm64 it also builds warden-io for darwin/arm64 and signs
the host binary. Run a development warden from its tree as dist/warden: it
finds its source only from where its executable is, never from the working
directory, so go run ./cmd/warden or a copy elsewhere stops at the first
thing it would build from source. Platform-specific code has build-tagged
stubs, so make test passes everywhere. The test tiers and what each one
needs are in
testing.md.
The warden-io keytool comparison skips where no JDK's keytool runs; CI's
keytool job installs Java and runs it on Linux, macOS and Windows.
Tier-1 checks
make lint ends by building dist/tier1 from tools/tier1/ and running it
over the diff from origin/main to HEAD (committed changes only). These are
the deterministic checks of the behavioral linter (LINT-02): the coupling
checks (a design in the diff, its drivers claim, the bootstrap surface, the
ledger schemas and their spec, the CLI and config surface and its guide
pages), go/analysis passes for the relay and the executor, and a
golangci-lint config limited to the lines you changed.
- The base is the merge base of
TIER1_BASE(defaultorigin/main) andHEAD. If it cannot be resolved, tier 1 exits 2 and prints the fix, usuallygit fetch origin main. It never falls back to checking the whole repository. Usemake tier1 TIER1_BASE=v0.5.0to check everything since a release. - Other platforms. The analyzers load packages for the host
GOOS. If you changed build-tagged files for another platform, also runGOOS=<os> make lint. - No design. A change that needs no design (FLOW-01) passes
TIER1_FLAGS=-no-design; in CI theno-designlabel does the same. A push, and a program sync's PR, are not judged on it (FLOW-01). - Design front-matter. Every
docs/design/*.mdthe change adds, modifies or renames must have front-matter that passes the same FLOW-02 validatorwfuses, with the file name (without.md) as thefeature. An existing design that never had front-matter predates FLOW-02 and is listed as a hint rather than failed (FLOW-12); a new design without front-matter fails.dist/tier1 designsprints the verdict for each touched design, anddist/tier1 designs -allfor every design. Archived designs kept as merged although they lack a later key are listed underdesign_tolerateintools/tier1/rules.yaml, and their tolerated problems are reported without failing. - Suppressing a finding. Add a trailer to any commit in the change:
Tier1-Allow: <RULE-ID> <path-glob>: <reason>, for exampleTier1-Allow: UX-01 cmd/warden/*: guide pages follow in #123. The reason is required. Every applied suppression is printed in its own section, so the review and the sign-off see it (LINT-05).*matches within one path element,**across elements, and a glob ending in/matches a whole directory. The trailer must reach the trunk, because tier 1 reads it from the commits in the range it judges: a merge commit keeps it, a squash merge keeps it only if the line is in the squash message, and a lost one failsmain'scion every push until a commit carrying it again lands (LINT-04). - Exit codes. 0 means clean, or only SHOULD findings and hints. 1 means an unsuppressed MUST or MUST-review finding. 2 means a usage or environment error, such as an unresolvable base or a missing golangci-lint. Hints never fail; they are signals for the tier-2 review, such as a package whose code changed with no test change (GLOBAL-04).
- Output.
dist/tier1 -jsonprints the report in the formtools/tier1/report.schema.jsondeclares, keyed by rule andfile:line. - Whole-tree audit.
dist/tier1 -allalso runs the checks of invariants that hold over the whole tree, today thespecs/layout (RELAY-05), even when the diff does not touch them. - The rule index.
dist/tier1 rules [-json]prints every rule parsed fromdocs/development/.tools/tier1/rules.yamlmaps eachautomated-tagged rule to a tier-1 check, an outside owner orfollow-up, and tier 1 fails a change to the standards that leaves a rule unmapped.
Local builds report version = "dev", which builds the relay from source. After
changing the relay or orchestrator, a quick end-to-end check is:
./warden build . # self-build: COPY provenance, Go modules, artifacts
./warden build examples/Dockerfile.simple # pip and Debian packages
./warden inspect warden-output # check the ledger
./warden clean # if a build crashed or was interrupted
Seam specifications and conformance
The specifications of the component seams (the claim, the collector, the
relay's guest API, the executor's initialize and the bootstrap config) live in
buildwarden/buildwarden-specs.
This repository pins one version of each in a Go module of its own,
tools/conformance/<directory>/go.mod, which the root module does not require;
Component seams shows each pin and links each
specification at it.
make conformance # Every pinned suite against every target this OS can run
make conformance TARGETS="relay-host collector-disk" # Exactly those targets
make conformance SUITES="relay-claim" # Exactly those specifications' suites
make conformance SPECS_DIR=../buildwarden-specs # Suites from a specs checkout, not the pins
OCI_RUNTIME=podman make conformance # relay-oci with podman in place of docker
make pin-specs SPECS="relay-claim@v0.2.0" # Move named pins to those releases
make pin-specs SPECS=latest # Move all six pins to their newest releases
make pin-specs REF=<commit> # Pin all six at one commit, on a branch only
make conformanceruns the seam specifications' suites against the relay and the disk collector built from this checkout. It builds each pinned specification's command,bw-conformance-<directory>, from its own module withGOWORK=off, so each runs with the harness its own release names, and builds what the targets run intodist/conformance/:relay,collectorand, forrelay-oci, the imagebuildwarden-relay:conformancefromDockerfile.relay. A target is a file intools/conformance/targets/(relay-host,relay-vm,relay-container,relay-oci,collector-disk) that declares the operating systems it runs on. WithTARGETSunset it runs every target that declares this host's, and prints a line for each one it leaves out; a target named inTARGETSthat cannot run here is an error. The relay targets run in the harness's sandbox, which needs Linux and root or unprivileged user namespaces;relay-ocineeds root and the runtime its file names, with the image built from this checkout. It prints one table per target, a row for each specification with its version, its harness's and its counts, and keeps each report indist/conformance/reports/. A failed case is not retried.SPECS_DIRruns the suites from a local checkout of the specifications instead, and says so. Theconformanceworkflow runs it on pull requests and on pushes to branches other thanmainthat change a path on its list, weekly and on demand: the relay targets as root on Linux,collector-diskon Linux, macOS and Windows.make pin-specsis the only way a pin moves. It takesSPECSorREF, never both and never neither. It writes each module it moves from nothing, builds every command in a scratch directory first, and only then moves the files into place and rewrites the refs on the seams page, so a failure changes nothing. Never move a pin withgo get: it keeps the old pin's harness version.mainpins releases only; the workflow'spinjob fails a pull request whose pins name a commit or carry areplaceline. A pull request to a program trunk (program/componentization, FLOW-20) may also pin a pre-release,vX.Y.Z-dev.Nor-rc.N, named inSPECS;SPECS=newestpins each specification at its highest version, pre-releases included, and is refused onmain.
Pull requests
- Fork the repo and branch from
main. - Changes that make design decisions start with a design document in
docs/design/, written fromTEMPLATE.md(FLOW-01). Dependency bumps, typo fixes and CI-only changes are labelledno-designinstead. - Run
make lint && make testbefore pushing. Keep commits focused: one logical change per commit. - Open a PR against
main. On a PR that changes code, CI runs lint, tests and cross-platform builds. A PR that changes onlydocs/(outsidedocs/development/) or top-level Markdown files runs tier 1, the FLOW-18 check and, when it touchesdocs/book/, an mdBook build. Theci-okcheck sums up the run. A maintainer signs off before merging (FLOW-08).
Cutting a release
- Make sure
make testpasses onmain. The release workflow runs tier 1 against the previousv*tag without a suffix and checks every design's front-matter (tier1 designs -all) before it publishes; every push tomainor a program trunk runs the same tier 1 and design check (CI'stier1job, LINT-04), so a green head has already passed it. Runmake tier1 TIER1_BASE=<previous tag>first to see what it will report. The full release gate (tier-1 checks, the test matrix, the security suite and the behavioral report) is described inbehavioral-linter.mdand is being built out. Runmake release-buildtoo: it compiles each program a release builds, for each release target, without cgo, as GoReleaser does (CI'sbuildjob runs it on every PR that changes code). A released macOS arm64wardentherefore has no vz driver, and says so. - Tag the commit and push the tag:
git tag v0.x.y && git push origin v0.x.y. - GoReleaser, run by GitHub Actions, builds and publishes the binaries.
A release without a suffix is cut from main by a maintainer, as above.
While the componentization program runs (FLOW-20), the loop also tags
pre-releases on a program trunk, vX.Y.Z-dev.N after a merge that changes
what the repository releases and -rc.N once a component's last phase has
merged, where X.Y.Z is the next minor after the latest release without a
suffix (v0.1.0 when there is none). Each publishes as a GitHub
pre-release that never becomes Latest and never moves the relay image's
latest, and is never moved or deleted (wf tag-next names the next one,
and wf tag-next -rc -feature <last phase> the next -rc.N).
Security
Report security issues as described in
SECURITY.md.
Do not open a public GitHub issue for them.
License
See the LICENSE file for details.
Project Structure
buildwarden/
├── cmd/
│ ├── relay/ # Relay binary (thin mode-based main)
│ │ ├── main.go # CLI flags, mode detection, per-mode claim start steps
│ │ ├── mode_host.go # Host mode: FD ingress via gvisor netstack, built at the claim
│ │ ├── vmlink.go # vm mode: address the build interface from the claim
│ │ ├── buildif_linux.go # ...over rtnetlink (stub elsewhere: vm mode needs Linux)
│ │ ├── dhcp.go # The stateless DHCP answer both modes share
│ │ ├── dhcp_vm.go # vm mode's responder; dhcp_vm_linux.go binds it to the build interface
│ │ ├── chanlistener.go # Channel-based net.Listener (for host mode)
│ │ ├── ingress_fd.go # gvisor netstack: Ethernet frames → TCP/UDP
│ │ └── ingress_dhcp.go # Host mode's DHCP framing around dhcp.go
│ ├── warden-driver-container/ # The container driver's binary: drivercmd.Main(container.Driver())
│ ├── warden/ # Host binary (CLI + driver dispatch)
│ │ ├── main.go # Cobra commands: build, shell
│ │ ├── config.go # Config loading (TOML), runtime detection, validation
│ │ ├── host.go # warden doctor, setup, hyperv service
│ │ ├── image.go # warden image prepare / list (all drivers)
│ │ ├── inspect.go # warden inspect (subcommand registration)
│ │ ├── inspect_impl.go # warden inspect (implementation)
│ │ ├── clean.go # warden clean
│ │ └── output.go # Colored terminal output
│ ├── collector/ # Standalone collector (third-party orchestrators)
│ │ └── main.go # Claim a running relay, serve inputs, land outputs
│ ├── warden-io/ # Build-environment agent binary
│ │ ├── main.go # Subcommands: initialize, fetch, post, trust
│ │ ├── initialize.go # Full init: network, CA + bootstrap config, baseline, script, heartbeats
│ │ ├── baseline.go # Always-on baseline: Java truststore, bazelrc, CA and default env
│ │ ├── jks.go # Minimal JKS writer (matches keytool byte for byte)
│ │ ├── trust_linux.go # Exclusive system trust, OpenSSL subject hash
│ │ ├── platform_darwin.go # macOS: keychain CA install, network config
│ │ ├── platform_linux.go # Linux: CA install, resolv.conf
│ │ └── platform_windows.go # Windows: cert store, network config
│ ├── warden-pause/ # Container driver's namespace holder (blocks until signalled)
│ │ └── main.go
│ └── warden-vmnet/ # macOS vmnet.framework helper (C, for future use)
│ └── main.c
├── relay/ # Relay library (core logic)
│ ├── relay.go # Config, Start(), MITM proxy, input/artifact handlers
│ ├── collector_client.go # Streams outputs to / pulls inputs from the collector
│ ├── dns.go # DNS server (UDP, forwards upstream)
│ ├── proxy.go # HTTP/HTTPS MITM, SSRF filter, TLS cert generation
│ ├── ledger.go # Ledger writer (single-writer channel pattern)
│ ├── heartbeat.go # Forwards guest heartbeats to the collector; completion
│ ├── controlplane.go # Control plane HTTP (/health, /ca.pem, /v1/output, /v1/complete)
│ ├── capture.go # Payload capture (streamed to the collector)
│ └── fair.go # Fair scheduling for concurrent connections
├── bootstrap/ # The bootstrap config the executor fetches (trust policy)
│ └── bootstrap.go
├── collector/ # Collector library (relay's single output path + input source)
│ ├── collector.go # HTTP handler: artifacts, captures, ledger, output, inputs
│ ├── signals.go # ready / heartbeat / complete / status signalling
│ └── paths.go # Shared artifact/context path safety rules
├── relaycfg/ # Claim protocol between orchestrator and relay
│ ├── relaycfg.go # Serve/Claim: push config, return relay identity
│ ├── buildlink.go # The claim's build_link and its validation
│ └── tunnel.go # Host-initiated tunnel carrying the collector (HTTP/2)
├── driver/ # The kit for drivers, and the drivers; warden's session
│ ├── driver.go # BuildRequest, BuildResult
│ ├── host.go # Start, Host, RelayStarted: the build dialogue's Go types
│ ├── drivercmd/ # The driver contract for a Go driver: Main, Call, Setting, Resolve
│ ├── relaysource/ # Where a relay comes from: Bundled, Path, Image, Relay.Verify
│ ├── session.go # Shared Session: collector, claim, wait, output finalize
│ ├── hostlink.go # Build-link checks every VM driver runs: host overlap, launcher stamps
│ ├── buildlink/ # The VM build link: default, parse, checks, claim and boot-arg renders, stamps
│ ├── compress.go # Zstd compression of ledger + CA cert (all drivers)
│ ├── hostutil.go # Host-side helpers
│ ├── subnet.go # Address constants, utilities
│ ├── container/ # Container driver (iptables isolation)
│ │ ├── command.go # Driver(): probe, run, reap, doctor, clean, attach
│ │ ├── runtime.go # The runtime: finch, podman or docker, and detection
│ │ ├── container.go # Run/Attach: holder, sidecar, create, copy, start
│ │ ├── network.go # The per-build network: allocation and its check
│ │ ├── images.go # Holder + sidecar images: by digest, or built for dev
│ │ ├── images/ # holder.Containerfile, netns.Containerfile
│ │ └── environment.go # OCI manifest extraction, environment record
│ ├── qemu/ # QEMU driver (cross-platform VM)
│ │ ├── driver.go # Run: prepare, boot relay VM, boot build VM, wait
│ │ ├── vm.go # QEMU subprocess management (relay VM + build VM args)
│ │ ├── seedfat.go # FAT seed image for Windows guests
│ │ ├── windows.go # Windows guest support
│ │ ├── winacq.go # Windows media acquisition + unattended install
│ │ └── autounattend.go # Autounattend.xml generation
│ ├── vz/ # VZ driver (macOS Apple Silicon)
│ │ ├── driver.go # StartBuild: host relay, boot macOS VM, wait
│ │ ├── image.go # IPSW restore, image preparation, personalization
│ │ ├── network.go # Socketpair networking for build VM
│ │ ├── vm.go # VM lifecycle helpers
│ │ ├── vz_darwin_arm64.go # Virtualization.framework CGo bindings (darwin/arm64, cgo)
│ │ ├── vz_darwin.h # Objective-C header
│ │ ├── vz_darwin_arm64.m # Objective-C implementation
│ │ └── vz_stub.go # Stub for every build without the bindings (incl. darwin/arm64 without cgo)
│ ├── hyperv/ # Hyper-V driver (Windows)
│ │ ├── driver.go # StartBuild: boot relay VM + build VM, claim, wait
│ │ ├── setup.go # warden setup: durable switches + NAT
│ │ ├── doctor.go # warden doctor preflight
│ │ ├── service.go # Privileged helper service (network standup)
│ │ ├── evalimage.go # Windows Server eval VHD fetch + pin
│ │ └── relayvm.go # Relay VM lifecycle
│ ├── firecracker/ # Firecracker driver (x86_64 Linux with KVM)
│ │ ├── driver_linux.go # StartBuild: slot, relay VM + claim, build VM, wait, teardown
│ │ ├── deliver_linux.go # Both delivery paths: raw rootfs + CIDATA seed, or direct boot
│ │ ├── vm.go, vm_linux.go # Firecracker config JSON; --no-api process start, pids
│ │ ├── slots.go # Slot naming, addresses, the setup command list
│ │ ├── slots_linux.go # Slot locking and stale-VMM reaping
│ │ ├── setup.go, doctor.go # warden setup / doctor --driver firecracker
│ │ ├── posture.go # Firewall posture refusals, upstream resolver selection
│ │ ├── images.go, gpt.go # qemu-img gate + raw conversion cache; GPT root finder
│ │ ├── wait.go # Exit ordering: build VM exit, completion grace
│ │ ├── clean.go # warden clean: orphaned VMMs, stale work dirs
│ │ └── driver_other.go # Stub for non-Linux hosts
│ ├── linuxguest/ # Linux guest family (qemu, firecracker)
│ │ ├── seed.go # Cloud-init NoCloud seed (runcmd tail per driver)
│ │ ├── seediso.go # ISO9660 seed image builder
│ │ └── images.go # Cloud image resolution + download + caching
│ ├── relayvm/ # Relay VM lifecycle shared by qemu and firecracker
│ │ ├── assets.go # Boot asset lookup (beside warden, then the tools output)
│ │ └── initrd.go # Append a binary to a prebuilt initramfs as a cpio
│ └── script/ # Dockerfile-to-shell-script translator (every driver)
│ └── translate.go # COPY expanded against the context on the host
├── conformance/
│ └── driver/ # The driver contract's suite (driver-conformance), the reference
│ # fake (warden-driver-fake) and stubrelay
├── ledger/ # Shared library: wire format, reader, verifier
│ └── ledger.go
├── specs/ # Ledger format specs, versioned (RELAY-05); published in the book
│ ├── README.md # Index: layout, $id -> file table, $id policy
│ ├── build-ledger/v1.md # Wire format (prose only)
│ ├── driver-contract/ # The driver contract: v1.md beside v1.schema.json (GLOBAL-08)
│ ├── metadata-<name>/ # A record metadata schema: v<N>.md beside v<N>.schema.json
│ ├── environment-<type>/ # A signed environment payload: v<N>.md beside v<N>.schema.json
│ └── specs_test.go # Tier-0: relay header, schemas and book mirror agree; seams page refs match the pins
├── tools/
│ ├── conformance/ # Pins of the seam specifications (buildwarden/buildwarden-specs)
│ │ ├── <directory>/ # One Go module per specification: go.mod pins it, a tool directive names its command
│ │ ├── targets/ # Target files: the relay in each mode and as an image, the disk collector
│ │ ├── conformance.sh # make conformance: every pinned suite against each target
│ │ ├── pin-specs.sh # make pin-specs: moves the pins and the seams page's refs together
│ │ └── check-pins.sh # The conformance workflow's pin job: release tags only, no replace line
│ ├── relay-vm/ # Relay VM assets (Alpine + kernel)
│ │ ├── build-initramfs.sh # Build the prebuilt relay initramfs
│ │ ├── init # ONE relay VM init script (qemu, hyperv, firecracker)
│ │ └── hyperv/ # Hyper-V UKI boot-disk build (/sbin/relay baked in)
│ │ └── build.sh
│ ├── firecracker-vm/ # Firecracker boot assets (x86_64)
│ │ ├── build-kernel.sh # Pinned 6.1 guest kernel (vmlinux) for both VMs
│ │ ├── kernel-required.config # Options that must be built in (checked by a test)
│ │ ├── build-initramfs.sh # Direct-boot base initramfs (busybox + launcher)
│ │ ├── init # Direct-boot launcher (exec warden-io initialize)
│ │ └── slots.sh # Hand-made slots for debugging (warden setup does this)
│ ├── build-vm/ # Build VM initramfs builder (direct-boot testing)
│ │ ├── build-initramfs.sh
│ │ └── init # Build VM init script (exec warden-io initialize)
│ ├── vz-image-prep/ # Standalone VZ image preparation tools
│ │ ├── personalize.go # 4-phase macOS image prep pipeline
│ │ ├── netfwd.go # Transparent TCP/UDP forwarder (image prep)
│ │ └── uv-build-test.go # End-to-end build validation
│ ├── win-image-prep/ # Windows image preparation notes/tools
│ │ └── README.md
│ ├── tier1/ # Tier-1 static checks, run by make lint (own Go module; LINT-02)
│ │ ├── cmd/tier1/ # Entry point: flags, stages, exit codes
│ │ ├── diff/ # Base, changed paths and lines, Tier1-Allow trailers
│ │ ├── rules/ # Rule index from docs/development/, rules.yaml self-check
│ │ ├── coupling/ # Path-set checks; design front-matter (FLOW-02)
│ │ ├── surface/ # Cobra flags and toml keys at base and HEAD
│ │ ├── analyzers/ # go/analysis passes for the relay and the executor
│ │ ├── golangci/ # Runs golangci.yml on changed lines, maps issues to rules
│ │ ├── rules.yaml # Every automated rule: check, owner or follow-up
│ │ └── report.schema.json # The -json output
│ └── workflow/ # Feature-loop tooling (own Go module; FLOW-03, FLOW-18)
│ ├── cmd/wf/ # Queue tool: next step, leases, done-when checks, native gate
│ ├── native/ # Scheduled native sessions: wrapper, installers, permissions, the native-run.sh launcher and their test
│ └── flow18-check.sh # Sessions stay out of the public repo
├── docs/
│ ├── book/ # mdBook documentation (guide, concepts, contributing)
│ ├── design/ # Design documents: the archive, plus TEMPLATE.md
│ └── development/ # Development standards and process (the rulebook)
├── Dockerfile.relay # Multi-arch relay container image
├── Makefile # build, test, lint, codesign
├── .goreleaser.yaml # Release configuration
├── AGENTS.md # Agent context: a map into docs/development and the book
└── CLAUDE.md # Imports AGENTS.md for Claude Code
Package Boundaries
cmd/warden/— Host-side binary. CLI, driver dispatch, config, inspect, image management, doctor/setup. Finds the driver--drivernames (awarden-driver-<name>binary, or a driver linked into it: qemu, vz, hyperv, firecracker) and runs every build through one build sequence.cmd/warden-io/— Build-environment agent, and the only thing the host puts in the build environment. Bootstraps itself from the relay (CA and trust policy, the baseline, the build script), runs the build, fetches context files, posts artifacts. Cross-compiled for linux (containers, QEMU VMs), darwin (VZ macOS VMs), and windows (QEMU and Hyper-V VMs).cmd/warden-pause/— The container driver's namespace holder: owns the build's network namespace while it is isolated, and does nothing else.cmd/relay/— Relay binary. Thin mode-based main that selects container/vm/host mode and calls into therelay/library. Cross-compiled for linux (container/VM relay) or built natively (host-mode relay for VZ).cmd/collector/— Standalone collector for third-party orchestrators: claims an already-running relay, serves inputs, lands outputs, exits with the build result.relay/— Relay library. All core logic: DNS, HTTP/HTTPS MITM proxy, ledger writer, control plane, heartbeat, fairness scheduling, capture. Keeps no build state on disk; streams every output to, and pulls every input from, the collector. Used bycmd/relay/in all modes.collector/— The host side of the relay's single output path and the source of its build inputs (artifacts, captures, ledger, build output, build script, bootstrap config, context).bootstrap/— The bootstrap config: the declarative trust policy the executor fetches from the relay (BOOT-05). Policy only; no paths, contents or commands. Run in-process by every driver (driver.Session) and standalone bycmd/collector.relaycfg/— The claim protocol: a relay boots unconfigured, the orchestrator pushes the per-build config over a host-initiated tunnel and receives the relay's identity (MITM CA cert + ledger key).cmd/warden-driver-container/— The container driver as a binary that speaks the driver contract; warden finds it beside itself.driver/— The kit for writing a driver, warden's session (Session: collector, claim, wait, output finalize), and the drivers. A driver is a binary that speaks the driver contract (specs/driver-contract/), or, until each becomes one, linked into warden; either runs through warden's one build sequence.driver/drivercmd/— The driver contract for a driver written in Go: command dispatch,describefrom theSettingdeclarations, reading the driver's configuration (Resolve), the result file and the run dialogue.driver/relaysource/— Where a driver's relay comes from: beside the binary or in the source tree, a path or an image the user named, and its verification.conformance/driver/— The driver contract's conformance suite: its static tier runs undermake test, its lifecycle tier withmake driver-conformance; the reference fake andstubrelay.specs/driver-contract/— The driver contract's specification and its machine schema.driver/container/— Container driver. Namespace holder isolated by the iptables sidecar before the build container exists; build container created withwarden-io initializeas its entrypoint; relay as container.driver/qemu/— QEMU driver. Two-VM topology with cloud images, cross-platform; Linux and Windows guests.driver/vz/— VZ driver. Host relay with gvisor netstack, macOS build VM.driver/hyperv/— Hyper-V driver. Two-VM topology with a host-only NAT switch; Windows guests (a Linux guest seed is not yet implemented). Includes host setup, doctor, and the privileged helper service.ledger/— Shared wire format library. Binary ledger types, reader, verifier. Used bywarden inspectand the relay's test suite.specs/— The ledger format's documents, not code: one wire-format spec per ledger major version and each schema's document beside its machine schema (RELAY-05).docs/book/src/specs/mirrors it with one-line includes. Its only Go file is a test.specs/specs_test.go— Besides the ledger documents, holds the seams page to the pins: a tier-0 test fails when a row ofdocs/book/src/concepts/seams.mdlinks a specification at a ref other than the version its module intools/conformance/pins.tools/conformance/— Not part of any binary. Six Go modules, one per seam specification kept in buildwarden/buildwarden-specs, each pinning one version of that specification and naming its conformance command; the root module requires none of them. The pins are moved withmake pin-specsand never withgo get, andmake conformancebuilds each pinned command from its own module and runs it against each target file intools/conformance/targets/, which theconformanceworkflow does on every change to the relay, the disk collector or a pin. See Component seams.
Key Patterns
Runtime model
Every driver follows one sequence: start a collector, boot the relay unconfigured,
claim it, isolate the build environment, deliver and start warden-io, and stream
everything back through the relay. The step-by-step pseudocode is in
How It Works, and the bootstrap rules every driver
follows are in
docs/development/bootstrap.md.
Single-writer ledger
All ledger writes go through one goroutine (Ledger.loop()), so records are
strictly ordered without locks. The rule is RELAY-01 in
docs/development/relay.md.
Relay modes
The relay binary detects its mode at startup:
- Container mode: binds :53, :80, :443, :8300 directly (isolation via iptables)
- VM mode: same as container but the relay runs in its own Alpine VM, and addresses its build interface from the claim and serves the build VM's DHCP lease there
- Host mode: receives connections via gvisor netstack on an inherited FD (no port binding on host); SSRF filtering active
Trust and the baseline
warden-io initialize installs the relay CA and a fixed baseline itself, from the
relay; support for a new tool goes in cmd/warden-io/baseline.go so it reaches
every driver. See Trust and the Build Baseline.
Dynamic subnet allocation
The container driver allocates /29 subnets from 100.64.87.0/24 (CGNAT range), in driver/container: after each create it checks the runtime's networks and yields a /29 another network also has, since the runtime's own overlap check is not atomic across builds of different HOMEs. VM drivers use one build link per build segment, [vm] build_link (default 100.127.255.252/30), defined once in driver/buildlink and delivered per build: the claim for the relay, the seed, kernel command line or the relay's DHCP lease for the guest.
Transparent MITM
The relay generates per-host TLS certificates on the fly, signed by an ephemeral CA. The CA is installed into the build environment's trust store by warden-io during initialization.