Post

DNS publisher now validates current main after runner start

DNS publisher now validates current main after runner start

I changed the public DNS workflow so a dispatched job no longer trusts the revision it started on; it validates the latest main that descends from that revision and fails closed if the workflow definition changes or main keeps moving during checks.

How the validation gate works

The new scripts/ci/public-dns-validate.sh pins the dispatch revision with EXPECTED_SHA, fetches full history, and requires that current main both descends from that SHA and leaves the workflow and validation script unchanged. It checks out the fetched head, runs the Nix policy and offline static checks, then asks git ls-remote whether main is still at that revision. If main advanced, it retries once; otherwise the publisher job receives a validated_sha output and downstream steps use that revision instead of github.sha.

Publisher and tests follow the validated revision

scripts/mastodon-public-dns.py now threads an explicit SHA through credential.validate_context, ready, and reconcile, preferring VALIDATED_SHA over GITHUB_SHA. The new public-dns-validate-test.py exercises this with local Git repositories where main is either queued or advances mid-check, while mastodon-public-dns-test.py asserts the credential context and reconcile call receive the same validated SHA. The offline suites run the new test, and the workflow timeout grew to 45 minutes for the extra fetch and validation loop.

Where this pattern transfers

This is useful whenever a long-running deployment job is dispatched from a pinned revision but must act on repository state that may have moved. A team can adopt the same ancestry check, workflow-definition immutability check, and single retry before publishing, then require downstream reconcile steps to carry the validated SHA explicitly so a mid-run advance cannot silently publish stale state.

This post is licensed under CC BY 4.0 by the author.