Pre-release: the store is not open yet and nothing is for sale. What early access means

Incident write-up

Our gate checked code that was never shipped, and shipped code it never checked

Short version: when several people and AI agents work in the same repository, "run the checks, then deploy" has three gaps. The checks run on the working tree, not on the commit. Another session can commit while the checks run. And a pipe can hide a failed build. We hit all three. The fix is to measure a pinned commit in a clean copy and refuse to ship anything else.

Gap 1: the working tree is not the commit

Our gate ran the type checker, the build and about a hundred other checks in the developer's working tree. Two things followed.

  • One uncommitted file locked everyone. Another agent's half-finished file made the "is the tree clean?" prerequisite fail for every deploy, including deploys that had nothing to do with that file.
  • Worse: uncommitted files went into the build. The type check and the build saw files that would never be shipped. The gate measured code that did not exist in the commit. The type check even passed only because an older build had left generated type files behind.

What gets shipped is git archive of a commit. What gets measured has to be exactly that.

Gap 2: HEAD moves while the gate runs

The gate took minutes. During that time a parallel session committed. The deploy script then packed HEAD, which now included a commit the gate had never seen, and that commit went live without anyone deciding to ship it.

Gap 3: the pipe that hid a failed build

Twice, a step looked like build | tail && up. A pipeline returns the exit code of its last command. tail succeeded, so the failed build looked green, and up started the old image again. The deploy "succeeded" without deploying anything.

The fix

  1. Clean copy. The gate runs in a separate git worktree outside the main tree, brought to the exact commit before every run (checkout --detach -f and clean -fd). Ignored folders such as node_modules stay, so installs stay warm. Secrets are not copied; checks read them from the main tree by path.
  2. Pinned commit. The deploy decides the commit before the gate starts. After the gate, it checks that HEAD has not moved and that the clean copy is still at that commit and still clean. If anything changed, it stops: code the gate did not see is never shipped.
  3. No pipes around checks. Output goes to a log file; the exit code is read directly. Failure output is printed from the file's tail.
  4. A lock around the clean copy, so two gate runs cannot change the tree under each other. A lock whose owner process is dead is taken over.

An uncommitted file is now invisible to the gate, so nobody blocks anybody by having work in progress.

The general rule

The thing you measure and the thing you ship must be the same bytes. With one developer that is almost automatic. With several sessions and agents in one repository, it has to be enforced.

What we built from it

Ship Gate runs your checks in a pinned clean copy, refuses to deploy if HEAD moved during the gate, ships git archive of that commit only, and never wraps a check in a pipe. The core (gate engine, clean copy, self-test) is open source under Apache 2.0.

Checklist for your own pipeline

  • Where do your checks run: in the working tree or on a fresh checkout of the commit?
  • Between "checks passed" and "deploy", can the commit change?
  • Search your scripts for | tail, | tee and | head after a build or test step.
  • If an agent leaves an uncommitted file, does it block or change anyone else's deploy?

What we built from it

Ship Gate

Runs your checks on the exact commit you are about to ship and refuses to deploy anything the checks did not see. Open-source core.

More incidents

Other things that broke.

All incidents