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; run mise exec -- go ... if your GOROOT is misconfigured)
  • golangci-lint v2
  • A container runtime: finch, podman, or docker
  • git 2.40 or later where the feature loop's wf runs: its merge check proves a squash merge with git 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 build signs it ad hoc; to sign by hand: codesign --sign - --entitlements entitlements.plist dist/warden

QEMU driver (any platform):

  • qemu-system-aarch64 or qemu-system-x86_64, plus qemu-img (brew install qemu on macOS, apt install qemu-system on 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 the kvm group, and firecracker v1.17.0 or later on PATH
  • iproute2, nftables, iptables, qemu-img and genisoimage (or mkisofs); the guest kernel build needs make, gcc, flex, bison, bc, libelf-dev and libssl-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 (default origin/main) and HEAD. If it cannot be resolved, tier 1 exits 2 and prints the fix, usually git fetch origin main. It never falls back to checking the whole repository. Use make tier1 TIER1_BASE=v0.5.0 to 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 run GOOS=<os> make lint.
  • No design. A change that needs no design (FLOW-01) passes TIER1_FLAGS=-no-design; in CI the no-design label does the same. A push, and a program sync's PR, are not judged on it (FLOW-01).
  • Design front-matter. Every docs/design/*.md the change adds, modifies or renames must have front-matter that passes the same FLOW-02 validator wf uses, with the file name (without .md) as the feature. 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 designs prints the verdict for each touched design, and dist/tier1 designs -all for every design. Archived designs kept as merged although they lack a later key are listed under design_tolerate in tools/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 example Tier1-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 fails main's ci on 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 -json prints the report in the form tools/tier1/report.schema.json declares, keyed by rule and file:line.
  • Whole-tree audit. dist/tier1 -all also runs the checks of invariants that hold over the whole tree, today the specs/ layout (RELAY-05), even when the diff does not touch them.
  • The rule index. dist/tier1 rules [-json] prints every rule parsed from docs/development/. tools/tier1/rules.yaml maps each automated-tagged rule to a tier-1 check, an outside owner or follow-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 conformance runs 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 with GOWORK=off, so each runs with the harness its own release names, and builds what the targets run into dist/conformance/: relay, collector and, for relay-oci, the image buildwarden-relay:conformance from Dockerfile.relay. A target is a file in tools/conformance/targets/ (relay-host, relay-vm, relay-container, relay-oci, collector-disk) that declares the operating systems it runs on. With TARGETS unset it runs every target that declares this host's, and prints a line for each one it leaves out; a target named in TARGETS that 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-oci needs 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 in dist/conformance/reports/. A failed case is not retried. SPECS_DIR runs the suites from a local checkout of the specifications instead, and says so. The conformance workflow runs it on pull requests and on pushes to branches other than main that change a path on its list, weekly and on demand: the relay targets as root on Linux, collector-disk on Linux, macOS and Windows.
  • make pin-specs is the only way a pin moves. It takes SPECS or REF, 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 with go get: it keeps the old pin's harness version. main pins releases only; the workflow's pin job fails a pull request whose pins name a commit or carry a replace line. A pull request to a program trunk (program/componentization, FLOW-20) may also pin a pre-release, vX.Y.Z-dev.N or -rc.N, named in SPECS; SPECS=newest pins each specification at its highest version, pre-releases included, and is refused on main.

Pull requests

  1. Fork the repo and branch from main.
  2. Changes that make design decisions start with a design document in docs/design/, written from TEMPLATE.md (FLOW-01). Dependency bumps, typo fixes and CI-only changes are labelled no-design instead.
  3. Run make lint && make test before pushing. Keep commits focused: one logical change per commit.
  4. Open a PR against main. On a PR that changes code, CI runs lint, tests and cross-platform builds. A PR that changes only docs/ (outside docs/development/) or top-level Markdown files runs tier 1, the FLOW-18 check and, when it touches docs/book/, an mdBook build. The ci-ok check sums up the run. A maintainer signs off before merging (FLOW-08).

Cutting a release

  1. Make sure make test passes on main. The release workflow runs tier 1 against the previous v* tag without a suffix and checks every design's front-matter (tier1 designs -all) before it publishes; every push to main or a program trunk runs the same tier 1 and design check (CI's tier1 job, LINT-04), so a green head has already passed it. Run make 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 in behavioral-linter.md and is being built out. Run make release-build too: it compiles each program a release builds, for each release target, without cgo, as GoReleaser does (CI's build job runs it on every PR that changes code). A released macOS arm64 warden therefore has no vz driver, and says so.
  2. Tag the commit and push the tag: git tag v0.x.y && git push origin v0.x.y.
  3. 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.