Separate tracked source from generated artifacts so the repo root stops accumulating helper scripts, manifests, and local runtime outputs. Move manual shell entrypoints under scripts/, manifests under config/, and the Firecracker API reference under docs/reference/. Make build and runtimebundle now target build/bin, build/runtime, and build/dist as the canonical source-checkout paths. Update runtime discovery, helper scripts, tests, and docs to follow the new layout while keeping legacy source-checkout runtime fallbacks for existing local bundles during migration. Validated with bash -n on the moved scripts, make build, and GOCACHE=/tmp/banger-gocache go test ./....
6.6 KiB
6.6 KiB
Repository Guidelines
Project Structure & Module Organization
cmd/bangerandcmd/bangerdare the primary user-facing entrypoints.internal/contains the daemon, CLI, RPC, storage, Firecracker, and system integration code.- The VM lifecycle is now organized around daemon capabilities plus a structured guest-config builder. New host-integrated VM features should plug into that Go path instead of adding more one-off branches through
internal/daemon/vm.go. scripts/customize.sh,scripts/make-rootfs.sh, andscripts/interactive.shremain as manual rootfs/customization helpers; normal VM lifecycle, NAT,.vmDNS, and daemon-driven image builds are handled by the Go control plane.- Source checkouts use a generated
./build/runtime/bundle for Firecracker, kernels, modules, rootfs images, and helper copies. Bundle defaults come from./build/runtime/bundle.jsonwhen present. Those runtime artifacts are not meant to be tracked directly in Git. - The daemon keeps state under XDG directories rather than the old repo-local
state/layout.
Build, Test, and Development Commands
make buildbuilds./build/bin/banger,./build/bin/bangerd, and the bundled./build/runtime/banger-vsock-agentguest helper.make bench-createbenchmarksvm createand first-SSH readiness on the current host.make runtime-bundlebootstraps./build/runtime/from the archive referenced byRUNTIME_MANIFEST; the checked-inconfig/runtime-bundle.tomlis only a template.make void-kerneldownloads and stages a Voidlinux6.12kernel under./build/runtime/void-kernel, including extractedvmlinux, rawvmlinuz, a matching generatedinitramfs, config, and matching modules.make rootfs-voidbuilds an experimental local-onlyx86_64-glibcVoid rootfs plus work-seed under./build/runtime/; it prefers staged./build/runtime/void-kernelmodules when present, but does not replace the default Debian path or teachbanger image buildabout Void.make verify-voidregistersvoid-expand runs the normal smoke test against that image.bangervalidates required host tools per command and reports actionable missing-tool errors; do not assume one workstation's package set../build/bin/banger vm create --name testboxcreates and starts a VM../build/bin/banger vm createnow blocks until the guest reaches the daemon's default readiness checks and shows live progress stages on TTY stderr while it waits../build/bin/banger vm ssh testboxconnects to a running guest using the runtime bundle SSH key and reminds the user if the VM is still running when the session exits../build/bin/banger vm stop testboxstops a VM while preserving its disks../build/bin/banger vm stop vm-a vm-b vm-cand./build/bin/banger vm set --nat web-1 web-2are supported; multi-VM lifecycle andsetactions fan out concurrently through the CLI../build/bin/banger doctorreports runtime bundle, host tool, feature, and image-build readiness from the same Go checks used by the daemon../build/bin/banger image register --name local --rootfs /abs/path/rootfs.ext4creates or updates an unmanaged image record without changing the default image config; use it for experimental guest iteration paths such as Void.bangerdnow also serves a localhost web UI onhttp://127.0.0.1:7777by default unlessweb_listen_addr = ""disables it; the UI uses server-rendered templates, polls async VM/image operations, and keeps image path selection on the host via a server-side file picker.make testrunsgo test ./...../scripts/verify.shruns the smoke test for the Go VM workflow.
Coding Style & Naming Conventions
- Go code should stay small, direct, and standard-library-first unless there is a clear reason otherwise.
- Shell helpers use Bash with
set -euo pipefail; keep remaining shell scripts strict and explicit. - Prefer lowercase filenames with short descriptive names.
- Use
gofmtfor Go formatting; no extra formatter is configured for shell files.
Testing Guidelines
- Primary automated coverage is
go test ./.... - Manual verification for VM lifecycle changes:
./build/bin/banger vm create, confirm SSH access, then stop/delete the VM. - For host-integration changes, run
./build/bin/banger doctoras a quick readiness check before the live VM smoke. - The web UI follows the same sudo model as the CLI path: bangerd stays unprivileged and privileged writes only work when
sudo -vis already warm or sudo is passwordless. - Rebuilt images now include
mise,opencode, a host-reachable defaultopencodeserver service on guest TCP port4096,tmux-resurrect/tmux-continuumdefaults forroot, and thebanger-vsock-agentservice used by the SSH reminder and guest health-check path; if you change guest provisioning, document whether users need to rebuild./build/runtime/rootfs-docker.ext4or another base image to pick it up. - The experimental Void rootfs path now includes the repo's basic dev baseline plus Docker and Compose, alongside boot, SSH, a guest network bootstrap sourced from the kernel
ip=cmdline, the vsock HTTP health agent, pinnedmiseplusopencodeforroot, the default host-reachableopencodeserver service on guest TCP port4096, abashroot shell while leaving/bin/shalone, and the/rootwork-seed. When./build/runtime/void-kernel/exists, the Void image registration path expects a complete staged Void kernel, initramfs, and modules tree and pointsvoid-expat it. Keep further baked-in tooling deliberate and user-driven. - Rebuilt images also emit a
work-seed.ext4sidecar used to speed up future VM creates. Older managed images may take one slower create to refresh seeded SSH access before they rejoin the fast path. If you touch/rootprovisioning, verify both the rootfs and the work-seed output. - The daemon may keep idle TAP devices in a pool for faster creates. Smoke tests should treat
tap-pool-*devices as reusable capacity, not cleanup leaks. - If you add a new operational workflow, document how to exercise it in
README.md. - For NAT changes, verify both guest outbound access and host rule cleanup, for example with
./scripts/verify.sh --nat.
Commit & Pull Request Guidelines
- Git history uses short, imperative subjects.
- Prefer a real commit body when the change affects lifecycle behavior, storage semantics, or host integration.
- PRs should call out runtime requirements, migration impact, and any host-side verification performed.
Security & Configuration Tips
- The VM workflow requires
sudoand/dev/kvmaccess; do not commit secrets. id_ed25519lives inside the runtime bundle; rotate or replace it before publishing a shared bundle.