Skip to content

fix(ci): refuse to deploy an image older than the code it claims to ship - #600

Merged
athvin merged 1 commit into
mainfrom
bm/ci-deploy-refuses-stale-rust
Nov 5, 2026
Merged

athvin merged 1 commit into
mainfrom
bm/ci-deploy-refuses-stale-rust

Conversation

@athvin

@athvin athvin commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

Why a warning was not enough

The stale-digest ::warning:: fired on four deploys on 2026-11-05 — P12's
metrics, P15's structured logging, P22's gate and P7's action header all merged,
green, and absent from the running binary — and nobody read it, including the
person who added it for exactly this failure
.

Something that must not be missed has to fail a check, not annotate one.

The guard

The digest step now refuses when the tree that builds an image actually
moved between what is running and what is being deployed.

That is answerable because the reused digest carries the sha it was built from:

git diff <built_from>..<DEPLOY_SHA> -- rust Dockerfile entities   # er-api
git diff <built_from>..<DEPLOY_SHA> -- frontend                   # er-web

Validated against the real incident, not a hypothetical

running er-api built from : 8360868d   (2026-11-04 23:13)
main had moved to         : 17db1dde
changed under watched paths: 51 files

The guard fires. It would have refused all four of today's deploys.

One flaw caught before pushing

fetch-depth: 0 is load-bearing, not hygiene. The checkout's default depth of
1 clones a single commit, so the diff cannot resolve its left side and the
guard would take its "cannot verify" branch on every deploy — a check that
always abstains, which is worse than no check because it looks like one.
That
was the first version of this change.

A tag that is not a commit in the checkout still only warns: that is a real
state for a hand-pushed image, and refusing on it would block a legitimate
deploy over a bookkeeping gap.

Relationship to #599

#599 stops the builds being cancelled in the first place. This is the guard
for when something else swallows one
— they are complements, not alternatives.

🤖 Generated with Claude Code


One thing checked rather than assumed

The guard reads imageTags[0] — the first tag on the reused digest. If an
image ever carried latest alongside its sha, that could pick the wrong one.

Measured against the live registry rather than reasoned about:

er-api images with tags : 16
...with more than one   : 0
non-sha-shaped tags     : none

images.yml tags by full sha only, so [0] is correct by the actual scheme
rather than by luck. And if a second tag is ever added, the guard degrades to
its "cannot verify" warning — a safe abstention, not a silent pass.

Recorded because the alternative was to "harden" something that did not need it,
which is its own kind of noise.

The stale-digest `::warning::` was not enough, and the evidence is specific:
it fired on four deploys on 2026-11-05 — P12's metrics, P15's structured
logging, P22's gate and P7's action header all merged, green, and absent from
the running binary — and nobody read it, including the person who added it for
exactly this failure. Something that must not be missed has to fail a check,
not annotate one.

So the digest step now REFUSES when the tree that builds an image actually
moved between what is running and what is being deployed.

The question is answerable because the reused digest carries the sha it was
built from: `git diff <that sha>..<DEPLOY_SHA>` over the image's own source
paths (`rust`, `Dockerfile`, `entities` for er-api; `frontend` for er-web)
says whether this deploy would ship older code than it claims. No image tag
and no source change is the legitimate case — #587's platform-only path, or a
tree that genuinely did not move. No image tag WITH a source change is the
bug, and it is now red.

Validated against the real incident rather than a hypothetical: the running
er-api was built from `8360868d`, main had moved to `17db1dde`, and 51 files
under the watched paths changed between them. The guard fires.

`fetch-depth: 0` on the checkout is load-bearing, not hygiene. The default of
1 clones a single commit, so the diff cannot resolve its left side and the
guard would take its "cannot verify" branch on EVERY deploy — a check that
always abstains, which is worse than no check because it looks like one. That
flaw was in the first version of this change and caught before pushing.

A tag that is not a commit in the checkout still only warns: that is a real
state for a hand-pushed image, and refusing on it would block a legitimate
deploy on a bookkeeping gap.

Companion to #599, which stops the builds being cancelled in the first place.
This is the guard for when something else swallows one.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@athvin
athvin merged commit 684acb6 into main Nov 5, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants