← mohithgajjela.com
SYSTEM / 04
MOHITH GAJJELA
REAL CODE
recorded run + live WebAssembly

A rollout that finishes after the leader dies.

Airlock is a deployment control plane for cloud regions that drop off the network, or never had one. Below is a recorded run of the real code: the leader crashes, a region goes dark, a worker dies halfway through a deploy, and a package gets tampered with on its way across an air gap. Every region still ends up on the right version, exactly once.

01THE RUN · 10 STEPS, 3 REPLICAS, 3 REGIONS

Ten things go wrong.
None of them stick.

Three control-plane replicas keep one replicated log of what every region should run. us-east and eu-west pull from it over the network. adc-1 has no network path at all, so it only ever sees signed packages carried in by hand.

RECORDED RUN

This replays airlock demo, recorded from the code on GitHub. Times are simulated: one tick is 10 ms. Section 02 runs the same code live.

EVENT LOG
    02BREAK IT YOURSELF · THE GO CODE, COMPILED TO WEBASSEMBLY

    Your turn.
    Try to make it install something twice.

    This is not a replay. The Raft implementation, the state machine and the region agents from the repository run in this tab, on a simulated network and clock. Kill the leader during a deploy. Cut eu-west off, deploy twice, then reconnect it. Tamper a package. The counters at the bottom are checked after every tick.

    LIVE

    Running in your browser. One tick is 10 ms of simulated time and the page runs about 60 ticks a second, so it moves at roughly 0.6x real time.

    SHIP
    CONTROL PLANE
    REGIONS
    Loading the WebAssembly build…
    Starting three replicas…
    EVENT LOG
      03RESULTS · FROM results/*.json IN THE REPO

      Measured, not described.

      Two kinds of numbers, kept apart on purpose. Failover times come from real HTTP servers with fsync'd write-ahead logs and a wall clock. The 10,000-job run uses a simulated network so every fault is reproducible from a seed, and it is about correctness, not speed.

      LEADER FAILOVER · REAL NETWORK · airlock failover -trials 30

      Each trial starts three replicas as HTTP servers on loopback, commits 20 jobs, kills the leader's server, and times how long until another replica wins an election and until a client write succeeds again.

      10,000 JOBS UNDER CONTINUOUS FAULTS · airlock bench

      04HOW IT WORKS

      Three rules.
      Everything else follows from them.

      01 · ONE LOG

      Intent is replicated before anything happens

      A deploy is a command in a Raft log. It only counts once a majority of replicas have it on disk, so losing any one replica, leader included, loses nothing.

      I wrote the Raft core as a pure state machine with no clock or network of its own. That is why the same code runs over HTTP in the binary, on a seeded network in tests, and in this page.

      02 · TRUST THE KEY, NOT THE PIPE

      Regions verify everything themselves

      Releases are signed with Ed25519 over the artifact's SHA-256 and size. A region checks the signature and the bytes before it installs, whatever delivered them.

      Air-gap packages are signed again by the control plane, scoped to one region, and numbered, so an old package cannot be replayed to roll a region back.

      03 · EVERY STEP CAN REPEAT

      Retries are the normal case

      The job id is the idempotency key. A second ack never changes a result. An agent writes each outcome to a local ledger before it reports back, so a crash between installing and reporting never runs the job twice.

      After a backlog, an agent jumps to the newest version and marks the rest superseded. It never installs an older generation over a newer one.

      Where this shape shows up

      Isolated government and defense cloud regions, edge sites with satellite links, factory floors, ships. Anywhere a deploy has to cross a gap that is sometimes or always closed.

      What it is not

      Not a new consensus algorithm. Raft, idempotency keys and signed artifacts are standard. The work was putting them together so that each failure mode has a specific mechanism and a test that breaks if the mechanism stops working.

      How it is checked

      31 Go tests, including a randomized Raft safety check over 60 seeds, run under the race detector, plus a script that runs six real processes and kill -9s the leader.

      # run it yourself (Go 1.23+, no dependencies) git clone https://github.com/Mohith26/airlock && cd airlock make test # vet, 31 tests, then -race make e2e # 3 replicas + agents as separate processes, kill -9 the leader make results # regenerate every number on this page
      05LIMITS

      What it doesn't do yet.

      01

      No log compaction

      The log and state grow without bound. A real deployment needs snapshots and truncation.

      02

      No TLS or membership changes

      Replicas talk plain HTTP and the replica set is fixed at startup. Artifact integrity does not depend on the transport, but confidentiality would need mTLS.

      03

      Loopback, not regions

      The failover numbers are from one machine. Real cross-region latency would stretch every number, and the simulated benchmark says nothing about throughput.

      04

      Artifacts in the log

      Fine for small artifacts. Large ones belong in a content-addressed blob store, with only digests in the log.

      05

      Leader reads without read-index

      A deposed leader can serve a stale pending list for one election timeout. That is safe here because every delivery is idempotent, but it is not linearizable.

      06

      Keys are files

      The release key would live in an HSM or cloud KMS, with signing behind an approval step.

      Home