rehearsal-4: gateway image — generic NixOS + idss-agent as a DO golden snapshot (ADR 0048 made real; first build = Ben's !) #646
Labels
No labels
agent-blocked
agent-working
autopilot
bug
deferred
deploy-pending
enhancement
landing-pr
model-haiku
model-opus
model-sonnet
needs-design
needs-info
needs-triage
no-triage
out-of-scope
priority
ready-for-agent
ready-for-human
ready-for-session
rehearsal-183
snapshot-pending
standing-drive
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Reference
Matou/idss#646
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Arc: #183 rehearsal phase 4 — rented gateway (S4a). Spec:
docs/superpowers/specs/2026-08-21-183-phase-4-rented-gateway-rehearsal-design.md. Plan:docs/superpowers/plans/2026-08-21-183-phase-4-rented-gateway-rehearsal.md(read its Global Constraints first — they apply to this task). This ticket's body is the plan's task verbatim. Phase-3 precedent: #515–#523.Task 2: Gateway image — generic NixOS + agent, built as a DO golden snapshot
Files:
nix/gateway-image/configuration.nixnix/gateway-image/disko.nix(the hybrid BIOS+UEFI layout — byte-equivalent to whatinternal/clan/enrollment.gorenderDiskoemits for/dev/vda; read that function first)flake.nix— addnixosConfigurations.gateway-image(x86_64-linux) importing both filesscripts/gateway-image/build.shscripts/gateway-image/latest.shscripts/gateway-image/tests/latest-test.sh(offline, fakedoctlon PATH)docs/GOTCHAS.md(append: "image disko must matchDiskoLayoutorclan updateboots a box that never comes back")STATUS.mdInterfaces:
Produces: DO snapshot naming
idss-gateway-<12-char-sha>;scripts/gateway-image/latest.shprints<snapshot-id>\t<name>for the newest; the image's root SSH trusts only keys DO injects at create (ssh_keys),idss-agent.serviceruns/usr/local/bin/idss-agent join(unit text copied frombootstrap/cmd/bootstrap/installscript.go:53-64), agent binary fetched at build from the Forgejo generic registryhttps://git.matou.nz/api/packages/Matou/generic/idss-agent/<sha>/agent-x86_64(the ADR 0185 artifactscripts/bootstrap-reseed/publish.shpublishes).Consumes: nothing from other tasks.
Step 1: Write
latest-test.sh(failing): puts a fakedoctlon PATH that prints two snapshot rows (111 idss-gateway-aaaaaaaaaaaa 2026-08-01T00:00:00Zand222 idss-gateway-bbbbbbbbbbbb 2026-08-20T00:00:00Z) plus an unrelatedclan-lab-golden-xrow; assertslatest.shprints222\tidss-gateway-bbbbbbbbbbbb; with no matching rows asserts exit 1 and the messageno idss-gateway-* snapshot.Step 2: Run it —
bash scripts/gateway-image/tests/latest-test.sh→ FAIL (script missing).Step 3: Write
latest.sh:Step 4: Run the test → PASS.
Step 5: Write
configuration.nix— imports(modulesPath + "/profiles/qemu-guest.nix"),(modulesPath + "/profiles/headless.nix"),./disko.nix;boot.loader.grub = { enable = true; efiSupport = true; efiInstallAsRemovable = true; device = "/dev/vda"; };networking.useDHCP = lib.mkForce true;networking.firewall.allowedTCPPorts = [ 22 ];services.openssh = { enable = true; settings.PermitRootLogin = "prohibit-password"; };services.cloud-init = { enable = true; network.enable = true; }(DO injectsssh_keysvia metadata — cloud-init lands them in/root/.ssh/authorized_keys);systemd.services.idss-agent= the bootstrap unit verbatim withExecStart=/usr/local/bin/idss-agent join;system.activationScripts.idssAgentinstalls${agentBinary}to/usr/local/bin/idss-agentwhereagentBinary = pkgs.fetchurl { url = "https://git.matou.nz/api/packages/Matou/generic/idss-agent/${agentSha}/agent-x86_64"; hash = agentHash; }andagentSha/agentHashcome fromnix/gateway-image/agent-pin.json({ "sha": "...", "hash": "sha256-..." }, written bybuild.sh). Header comment: GENERIC — nothing community-specific (ADR 0048); disko MUST equalDiskoLayout(nodeconfig.go).Step 6: Write
disko.nixby transcribingrenderDisko(enrollment.go ~1430) for device/dev/vda; add a Go testinternal/clan/gateway_image_disko_test.gothat rendersrenderDisko("/dev/vda")and asserts the partition labels/types it emits appear verbatim innix/gateway-image/disko.nix(reads the file relative to the repo root) — the contract test.Step 7: Run
go test ./internal/clan -run GatewayImageDisko→ PASS;nix eval .#nixosConfigurations.gateway-image.config.system.build.toplevel.drvPathon a Linux host → evaluates (document in the ticket if the worker host lacks nix: the seam test + flake syntax checknix flake check --no-buildare the gate).Step 8: Write
build.sh(Ben runs it; not CI yet):set -euo pipefail; requiresdoctl,nix,DIGITALOCEAN_ACCESS_TOKEN;sha=$(git rev-parse --short=12 HEAD); writesagent-pin.jsonfromscripts/bootstrap-reseedregistry for$sha(fails loud if the registry lacks it: "publish first");doctl compute droplet create idss-gateway-build-$sha --region syd1 --size s-2vcpu-4gb --image ubuntu-24-04-x64 --ssh-keys "$(doctl compute ssh-key list --format FingerPrint --no-header | paste -sd,)" --tag-names idss-gateway-build --wait --format PublicIPv4 --no-header; waits for SSH;nix run github:nix-community/nixos-anywhere -- --flake .#gateway-image --target-host root@$ip; waits for SSH again and assertssystemctl is-active idss-agent=active(the image contract, proven at build);doctl compute droplet-action power-off --wait;doctl compute droplet-action snapshot --snapshot-name idss-gateway-$sha --wait;doctl compute droplet delete -f; prints the snapshot id vialatest.sh. Trap on EXIT deletes the build droplet.Step 9: Run
bash -n scripts/gateway-image/build.shandshellcheck(if present) → clean. Add the GOTCHAS entry.Step 10: Commit —
git commit -m "rehearsal-4: gateway image — generic NixOS + idss-agent as a DO golden snapshot (ADR 0048 made real) (#646)".close-report for #646 — status
success✅ close-report gates passed — every claim verified against main; closing.
envelope
deploy, image stays generic #655deploy, image stays generic #655