xpsoasis · devops
01xpsoasis · devops · 2026-11-27

A team's servers, declared in Nix and proven in Bend, production unchanged

xpsoasis is a team's web platform (two apps, xpsOasis and AASpectra, on Postgres) whose machines are NixOS, deployed with deploy-rs from one repo, oasis-infra. This deck is the second step after directo's: the same method brought to a repo two people run, with one rule from the owner: do not touch xpsoasis or xesoasis production.

doneOn a branch: CI on every branch, checking every host, every gate with a test that must fail, and the owner's rule in Bend; the dev box and the builder brought under OpenTofu; promote limited to dev → staging; twenty laws, proven.oasis-infra (github.com/rdataa/oasis-infra, private), branch phase3-ci at 26fb50e, git log master..phase3-ci

measuredApplied once, on the owner's OK: the dev box and the builder imported into OpenTofu, with delete and rebuild protection turned on. Nothing destroyed, production unchanged.oasis-infra (github.com/rdataa/oasis-infra, private), branch phase3-ci at 26fb50e, tf/hetzner.nix; HANDOFF.md, "The machines"

openNot merged: master deploys the dev box, so merging waits for the owner.oasis-infra HANDOFF.md, "Binding scope rule"

Each claim is marked: done (built, in a branch), proved (Bend's checker and the BendTT kernel accept it), tested (a check that runs), measured, claimed (a document says so), open, lead (proposed), decided. Keys: → or space for the next slide, ← back, Home and End, a for the whole deck on one page.

02The machines

Five hosts, two of them production and out of reach

hostroleproductionOpenTofudeployed by
oasis-devthe dev boxnoimported, protectedCI, from master and the apps' branches
oasis-builderbuilds, runs CI, activates devnoimported, protectedan admin, by hand
staginga placeholder, not rentednonot yetto be decided
xesOasisthe legacy site, real usersyesneveran admin, by hand
xpsoasis-8gbxpsoasis productionyesneveranother repo, never from here
oasis-infra HANDOFF.md, "The machines"

claimedThe dev box never builds: the builder, an organization GitHub Actions runner, builds the closure and activates it on dev.oasis-infra HANDOFF.md, "The design, in four sentences"

decidedProduction is declared only so a check can prove nothing here acts on it.the owner's rule of 2026-11-26

03The rule, as data

"Do not touch production" is a file, and CI fails when it is broken

spec/Pins.bend is the owner's file: production's names, addresses and DNS records, the two production deploy nodes that predate the rule, and what CI may deploy. nix/facts.nix reads off the flake what each tool would act on, and spec/Check.bend claims the rules find nothing; the BendTT kernel computes it.

testedOn deliberately bad facts, the failures are exactly these, and that list is itself a checked claim (addresses elided here):oasis-infra (github.com/rdataa/oasis-infra, private), branch phase3-ci at 26fb50e, spec/BadNamed.bend, checks.facts-bad-named

scope: production host in tofu or ci: xpsoasis-8gb
scope: production host in tofu or ci: xesOasis
scope: a workflow names a production address: …
scope: deploy node on production: prod
scope: production DNS record in tofu: www.xesoasis.org
ci: deploys more than dev: xesOasis
topology: deploy nodes share an address: …
hosts: no pure gate and no exemption: stray
promote: writes a production pin: prod
promote: copies a pin CI does not deploy: staging

testedA production server slipped into the OpenTofu config under a harmless name is caught by its Hetzner name and by its id.oasis-infra (github.com/rdataa/oasis-infra, private), branch phase3-ci at 26fb50e, checks.facts-tofu-must-fail

04CI on every branch

Before: CI built one host, and master broke twice while it stayed green

claimedMaster did not evaluate at two commits, and CI was green through both, because the workflow built the dev node alone; one of the two was caught later by a pre-deploy check.oasis-infra HANDOFF.md, "Where the convergence stands"

  • check.yml runs nix build .#ci on every branch but the two that deploy, on the builder; a laptop runs the same command.
  • It holds one key, for github.com only, to read the apps' private repos, and removes it at the end; it names no host and deploys nothing.
  • A newer push to the same branch cancels the older check: nothing in it activates anything.
29checks in one build: every host evaluated, every pure gate, the spec, the OpenTofu checksdoneoasis-infra (github.com/rdataa/oasis-infra, private), branch phase3-ci at 26fb50e, flake.nix, gateChecks
14of them must fail: a test per gate that feeds it the defect it is fortestedoasis-infra (github.com/rdataa/oasis-infra, private), branch phase3-ci at 26fb50e, flake.nix, gateChecks
≈90 sthe whole build on olimpo when the spec changedmeasuredoasis-infra (github.com/rdataa/oasis-infra, private), branch phase3-ci at 26fb50e, nix build .#ci

measuredThe builder's first run of it, which builds Lean v4.34.0 for the kernel once, passed in 58 min (28d2368, 2026-11-27).github.com/rdataa/oasis-infra/actions, run 45995511405

05OpenTofu, on live servers

Imported as they are, then protected

tf/hetzner.nix ── terranix ──► OpenTofu JSON
   import blocks: oasis-dev, oasis-builder, their four addresses
   prevent_destroy on all six; ignore_changes on what only matters at creation

$ nix run .#tf -- hetzner plan
Plan: 6 to import, 0 to add, 0 to change, 0 to destroy.     (as they are)
Plan: 6 to import, 0 to add, 6 to change, 0 to destroy.     (protection on)

measuredFirst the import alone, to prove the config matched Hetzner exactly: nothing to change. Then the owner's choice: also turn on delete and rebuild protection, and keep each address if its box is ever deleted.oasis-infra (github.com/rdataa/oasis-infra, private), branch phase3-ci at 26fb50e, 28d2368, 511bbae

measuredApplied 2026-11-27 from olimpo: 6 imported, 6 changed in place, 0 destroyed; both boxes running; drift finds no change.oasis-infra HANDOFF.md, "The machines"

  • State and saved plans are encrypted by OpenTofu with a passphrase in agenix that only people's keys open, no machine's.
  • apply runs only from a terminal, on a saved plan that passed the Bend delete check and has not changed since.
  • CI checks that each server's address in OpenTofu is the one its deploy target uses, with a test that moves dev's address by one and must fail.
06Promotion

The plan said promoting to production stays refused; the code did not

claimedpromote copied any environment's pinned revision onto any other's, and the README showed promote xpsoasis staging prod as a normal step.oasis-infra (github.com/rdataa/oasis-infra, private), branch phase3-ci at 26fb50e, README.md before 2a964dd

Now one list in the flake, promoteEdges, holds the only moves: dev → staging. Anything else is refused before any file is touched, with a message that points to the rule.

$ nix run .#promote -- xpsoasis staging prod
promote: refusing staging -> prod: the only moves are dev -> staging
(promoteEdges in flake.nix). Nothing promotes onto prod from here.

testedCI runs the real app on four moves it must refuse, and checks that dev → staging gets past the refusal; adding staging → prod to the list must fail the facts check.oasis-infra (github.com/rdataa/oasis-infra, private), branch phase3-ci at 26fb50e, checks.promote-refuses, checks.facts-promote-must-fail

provedpromote_meaning: the facts pass the promote rule iff no move ends on a production pin and every move copies from a pin CI deploys, so a promoted revision is one that ran.oasis-infra (github.com/rdataa/oasis-infra, private), branch phase3-ci at 26fb50e, spec/LAWS.bend

07Denotational design

Each gate gets a meaning first; the laws are about the meaning

thingmeaninglaw
pre-deploy checksfacts → list of failuresa monoid homomorphism: Both ↦ ++, Pass ↦ []; passing both ⇔ passing each
scopewhat each tool acts onsilent ⇔ nothing OpenTofu or CI acts on is production; it splits per tool, per address, per node, per DNS record
CIthe hosts the workflows deployCI deploys only what the owner allows
hostsgated or exemptevery host has a pure gate, or the owner exempted it by name
promotethe moves it may makenothing lands on production; a move copies only a pin CI deploys
OpenTofu plansresource → attributesapplying plan(desired, state) gives desired, except a kept resource is never deleted
ssh access(principal, key) pairsthe guard is silent ⇔ every live key survives
backupssnapshots (age, paths)fresh ⇔ some snapshot young enough holds every path; the gate implies fresh
oasis-infra (github.com/rdataa/oasis-infra, private), branch phase3-ci at 26fb50e, spec/Model.bend, spec/LAWS.bend

claimedThe method is Conal Elliott's: a type's meaning is a mathematical object, and each operation must agree with its meaning's.Conal Elliott, "Denotational design with type class morphisms" (2009)

08Proved

Twenty laws, by Bend's checker and again by the BendTT kernel

20laws in spec/LAWS.bend, each with its proof (and 18 lemmas)provedoasis-infra (github.com/rdataa/oasis-infra, private), branch phase3-ci at 26fb50e, spec/PROOF.bend
0tactics: a proof is a Bend def; induction is recursion, rewriting is %edoneoasis-infra (github.com/rdataa/oasis-infra, private), branch phase3-ci at 26fb50e, spec/PROOF.bend
--verdictrechecks every proof with a kernel that has a proof in LeanclaimedBend 2.0.39 guide, "Laws and Proofs"
$ nix build .#checks.x86_64-linux.spec
oasis-spec> ALL PROOFS CHECK

tested--check-only alone is not validity: the gate runs --verdict, and a law false on purpose (a node on production's address "is off production") must be refused, or CI fails. New proofs were also broken on purpose, and refused.oasis-infra (github.com/rdataa/oasis-infra, private), branch phase3-ci at 26fb50e, checks.spec, checks.spec-must-fail

provedThe plan laws are directo's, unchanged: the same model checks both repos.directo-devops.hhefesto.dev, slide 8

09Backups and access

Two live gates, given a meaning

  • The dev box snapshots nightly with restic to its own repository on a Storage Box. check-dev-backups runs inside the deploy: the timer is active, the last run succeeded, the newest snapshot is at most 26 h old and holds every path the host declares, and restic check is clean.
  • pre-deploy-<env>-access compares the (principal, key) pairs of the system about to be activated with the live host's, and reports every pair the deploy would take away. It warns, it never blocks.

provedgate_fresh: what the backup gate passes is fresh. gate_stricter, by example: a newer snapshot missing a path fails the gate even with a complete one behind it, where "fresh" alone would pass.oasis-infra (github.com/rdataa/oasis-infra, private), branch phase3-ci at 26fb50e, 26fb50e, spec/LAWS.bend

provedaccess_silent: the guard is silent iff every live key survives.oasis-infra (github.com/rdataa/oasis-infra, private), branch phase3-ci at 26fb50e, 26fb50e, spec/LAWS.bend

openBoth gates are still shell; the laws are about what they mean, not about the shell.oasis-infra (github.com/rdataa/oasis-infra, private), branch phase3-ci at 26fb50e, README.md, "Checks on a branch"

10A gate per incident

What running these machines taught, and what it left

incidentwhat it left
an automatic rollback fired on a slow ssh reconnect and caused an outage (2026-07-07)deploy-rs magic and auto rollback off everywhere; rollback is the system profile, switched by a person
a deploy from a stale checkout deleted the deployer's account, and fail2ban then locked him out (2026-08-20)the access guard, which compares against the live host: a stale tree's own checks are stale too
master did not evaluate, twice, under a green CIevery host evaluated on every branch
two deploy targets on one machinenodes-distinct, and the topology rule in Bend
a plan that said production promotion was refused, and code that allowed itpromote limited to one list, tested by running it, and a law
oasis-infra HANDOFF.md, incidents; flake.nix, accessGuard
11For Infrastructure & Operations at Flox

What the role asks, and where this deck shows it

the role asksshown here
TerraformOpenTofu through terranix: live servers imported with no change, protection turned on through a reviewed plan, encrypted state, person-only apply, a plan check in Bend
Nix builders and binary cachesan organization runner that builds every host on every branch and activates dev; the dev box never builds
reliabilitya gate per incident, each with a test that must fail; backups checked inside the deploy
securityproduction as data that CI enforces, a check job holding one key for github.com only, secrets in agenix, apply only by a person
working in a shared repoeverything on a branch, nothing merged without the owner
Flox, "Member of Technical Staff, Infrastructure & Operations" (jobs.ashbyhq.com/flox/87f6bc08)

claimedFlox builds an AI release-engineering agent; this work puts limits on an AI agent in code (production as checked data, person-only applies), after an agent overstepped them in practice.flox.dev; the owner's notes, 2026-11

12Open

What waits for the owner

openA binary cache from the builder: over SSH, signed, admin keys only (proposed), or over HTTPS with a login. The cached builds hold private code, so a public cache would leak it.the plan, phase 3, step 3

openDNS for the non-production names (dev and the staging names): the zones are at GoDaddy, and any DNS change needs the owner's OK.oasis-infra HANDOFF.md, "Binding scope rule"

openStaging, then moving the builder and the dev box: the plan put them on OVH, which is paused.the owner's answer of 2026-11-26

openA drift check in CI needs a read-only Hetzner token.oasis-infra (github.com/rdataa/oasis-infra, private), branch phase3-ci at 26fb50e, README.md, "OpenTofu"

openMerging the branch: master deploys the dev box.oasis-infra HANDOFF.md, "Binding scope rule"

13Limits

What the proofs do not cover

  • The proofs cover the model and the facts handed to it. The Nix that reads the facts off the flake (nix/facts.nix), OpenTofu, the provider and NixOS are trusted, not verified.
  • The access guard and the backup gate are shell: their laws are about their meaning.
  • Bend's parser and its translation into the kernel are not proven (the guide says so).
  • The rule about production is checked against the owner's file and the flake, not against the machines.

claimed"--verdict checks the translated terms; the parser and translation into the kernel are not proven."Bend 2.0.39 README

14This deck

Made with bend-frp

The slides are data in Bend (Deck.bend); bend-frp runs the page, and the navigation is a small pure machine (Nav.bend), the same as directo-devops.hhefesto.dev's.

provedIts laws: moving never changes the number of slides, next then back returns where you were, going to slide k lands on k, the keys and addresses mean what this page says, and every claim, table and card names a source. bend PROOF.bend --verdict prints ALL PROOFS CHECK.xpsoasis-devops-site's LAWS.bend and PROOF.bend