ChiselOps

Reproducible builds: what we verify with checksums

Our test is single and checkable: build the same commit twice, on different machines, and the artefacts must match byte for byte. Not “roughly”, not “behaves the same” - match by checksum.

“Reproducibility” sounds like an academic luxury until the first incident you cannot reproduce. A build you cannot repeat means you cannot return to the version that worked yesterday: you can only return to its source and hope the same thing comes out again. Usually it does not, and you find this out at the worst possible moment.

How we verify - literally

Take a commit, build the artefact on one machine, compute its checksum. Build the same commit on another machine, from a clean state, compute it again. Compare. If the sums are equal, the build is deterministic along those two axes, machine and time. If not, the interesting part begins: we unpack both artefacts and find the file in which they diverged, because the place of the difference almost always names its cause.

Five places non-determinism hides

In descending order of how often we meet them. The first two account for more than half the cases.
SourceHow it looks in the diff
TimestampsA build date baked into the artefact; two runs differ by exactly the seconds between them
File orderAn archive or image built in filesystem-traversal order, which is not guaranteed
Locale and time zoneString sorting by the current language’s rules; another machine, another language, another order
Absolute pathsThe working-directory path baked inside the artefact; two engineers have different ones
ParallelismSteps whose result depends on which thread finished first

The fixes are dull and repetitive: a fixed timestamp instead of the current one, an explicit sort instead of filesystem order, one locale per build, relative paths, and removing steps where the finishing order matters. None of it is heroics - it is hygiene, set once and then held by a check on every commit.

A lockfile that is actually enforced

Almost everyone has a file locking dependency versions. Almost nowhere is it truly enforced: it is committed, and the build still pulls “latest” because the lock is treated as a hint rather than a law. We make it a law - the build must fail if what is installed differs from the lock, not silently take a newer version. Without that, reproducibility rests on luck: today the upstream served the same versions as yesterday, tomorrow it will not.

We pin not only direct dependencies but their dependencies too - that is usually where the thing that “we didn’t change anything” quietly drifts.

Why it is worth paying for

On the project in case 01, a manual release took forty minutes and fourteen steps, and above all nobody could say with confidence that what ran in production was exactly what was in the repository. Once the build was reproducible, the release shrank to six minutes and one step - but the point is not the minutes. The point is that rollback stopped being a lottery: returning yesterday’s version is fetching yesterday’s artefact with a known checksum, not rebuilding and praying.

We measure before and after the same way: minutes per release, the share of releases in a quarter that ended in a rollback or an on-the-fly fix, and minutes to roll back. Reproducibility moves all three, but the second most, because it removes a whole class of releases that “almost built”.