Repository navigation
🐛 fix(ci): guard changelog-sync against demoting a released section - #285
Conversation
changelog-sync regenerated CHANGELOG.md from a HEAD where the release tag was not pushed yet, so git-cliff rendered the cut section as [Unreleased] and bot commit fbb5196 pushed that demotion of ## [0.17.0] to main. docs launch-truth then resolved the released version as 0.16.0 and Docs CI went red on every PR. Diff every regeneration against the committed CHANGELOG.md before pushing. Released version tokens are compared as sets, so dates and compare links may change freely. Tag visibility discriminates the ordinary release path (top section demoted, tag not pushed yet -> warn and refuse to push, job green) from a real regression (tag visible, or a non-top section vanished -> error, fail, push nothing). [Unreleased] drift-healing is untouched.
034062f to
15d32ea
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
REVIEW — Kollect/fix-changelog-sync-release-guard @ 15d32ea — APPROVE — 2026-08-07Verdict: APPROVE (P2/P3 notes only, none blocking) Independent review; I did not write this code and verified the author's claims rather than accepting them. Gate matrix
Diagnosis — verified, and more strongly than claimed
Mutation testing — 6/6 caught, suite is not vacuousI re-ran the author's three and added three more. For the workflow mutations I re-prepended the original header comment so the separate
The previously-vacuous Exit 2 — the risky path, examinedIt is monotonically safer than the status quo: its worst case is "no push", never "wrong push". Convergence is proven, not asserted — with the tag restored at the same HEAD, cliff's output byte-matches the hand-written committed file, so the guard returns 0 and the next push to main heals cleanly. The only way a hold persists is an aborted release leaving an untagged hand-written header, and that re-emits the tag-naming Over-fire — disproven on real dataOn the repo's actual current HEAD the regenerated file differs from the committed one and the guard still exits 0 ( Other verifications
Findings
Functional correctnessAll stated acceptance criteria hold under independent replay. The guard blocks the real incident (exit 2, green), escalates the genuine-regression variant (exit 1, red), converges once the tag lands (exit 0, byte-exact), and does not over-fire on the repo's live state. The exit-code contract in the script header, the workflow header comment, and the PR body agree with observed behaviour. TDD / coverage deltaNo Go coverage surface. New production unit Summary / next stepsAPPROVE — clear to merge (maintainer merges; this review does not authorize it). Recommended non-blocking follow-ups: a short note in |



Incident
Bot commit
fbb5196a3(:page_facing_up: docs: sync CHANGELOG.md [skip ci]) rewroteThat is the exact inverse of the human release-cut commit
aa9118919(:memo: docs(changelog): cut v0.17.0 release notes).docs/_snippetslaunch-truth then resolved the released version as0.16.0, and Docs CI went red on every open PR until it was patched by hand in #283. The symptom was fixed; the mechanism was not.Diagnosed mechanism — tag-push race (established, not guessed)
main(3815a3bd8) → triggerschangelog-syncfbb5196a3)v0.17.0created/pusheddocs/RELEASE.mdlands the release-prep PR onmainfirst and pushesvX.Y.Zafterwards.changelog-syncfires on that push, checks out aHEADwhere the tag does not exist yet, andgit-cliffcorrectly classifies those commits as unreleased — rendering## [Unreleased]over the hand-written header. Eight minutes later the tag arrives, but a tag push does not re-triggeron: push: branches: [main], so nothing re-heals it.Confirmed by reproduction:
git-cliff --config hack/release/cliff.tomlin this worktree (tag now present) emits## [0.17.0](…) - 2026-08-05. The config is not at fault —cliff.tomlandtask changelog:writeare unchanged here.This is structural, not a one-off: every release takes this path.
Why the guard is not "compare against existing git tags"
The obvious check — "a header matching an existing tag must not disappear" — would have caught nothing, because at sync time the tag did not exist. The load-bearing invariant is old-vs-new: a released section present in the committed CHANGELOG must not vanish from the regenerated one. Tag visibility is used only as a discriminator, not as the invariant.
The guard
hack/check-changelog-release-guard.sh <committed> <regenerated>, run inchangelog-sync.yamlbefore anything is committed or pushed:[Unreleased], its tag not visible::warning, no push, job green — release in flight::error, job fails, nothing pushedDesign notes:
0.18.0-rc.1, matchingtag_pattern = "v[0-9].*") are handled.[Unreleased]drift-healing is untouched — the guard only inspects## [X.Y.Z]tokens, so the workflow's actual purpose still works.Replayed against the real incident blobs
Either way the bad push is blocked.
Convergence caveat (deliberate scope choice)
After an exit-2 refusal,
CHANGELOG.mdstays as committed (which is correct — the hand-written header is the truth) and is regenerated by the next push tomainafter the tag lands. Addingtags:to the workflow trigger would heal it within seconds, but on a tag eventactions/checkoutresolves the tag ref andgit push origin HEAD:mainwould then target a non-maincommit; doing it safely needs an explicitref: mainand cannot be verified locally. Adding an untestable push path tomainin the very lane that exists to stop bad bot pushes is the wrong trade — noted here as a follow-up rather than smuggled in.Testing (TDD)
hack/test/changelog_sync_release_guard_test.sh— offline, fixture CHANGELOGs plus throwaway git repos whose tag sets are controlled by which repo the guard runs in (no test-only backdoor in the production script). No release needs to be cut to exercise it. Written first, confirmed red (FAIL: missing hack/check-changelog-release-guard.sh), then made green.21 checks, covering both directions:
[Unreleased]body re-render; no[Unreleased]section at all (the file's current state — all post-tag commits are cliff-skippeddocs); gaining an[Unreleased]section; a newly rendered release header; changed date/compare-link on an intact release-rc.1prerelease; refusal names the pending tag and emits::warning::errorWired into the
ci.yamllint job next tocore_events_rbac_test.sh.Structural assertions (mutation-tested)
The test also locks the workflow wiring. These deliberately parse the YAML (
python3+yaml, thecore_events_rbac_test.shpattern) rather than grepping lines — the header comment also contains the script path, so a line-basedgrep/head -1check would match the comment and pass even with the guard step deleted or moved after the push. It asserts, withinjobs.sync.steps:runinvokescheck-changelog-release-guard.sh;git push origin HEAD:main;if:referencessteps.<guard-id>.outputs— a verdict nobody consumes is not a guard.Each was mutation-tested against the real workflow to confirm it is not vacuous:
if: steps.guard.outputs.verdict == 'push'guard step (index 5) must run BEFORE the push step (index 4))no step in job 'sync' runs check-changelog-release-guard.sh)Both new scripts are committed
100755, matching their siblings.Documentation
The workflow header comment previously said the job "soft-fails with a warning (it is NOT a required check, so it never blocks a merge)" — now false in one branch. Rather than appending, that paragraph is rewritten to state which conditions soft-fail (missing App-token secrets / push failure — unchanged) and which are now fatal, and it documents the release-guard verdicts and the convergence caveat. No documented caveat was dropped: the App-token activation notes, the ruleset-bypass setup, and the
paths-ignore/[skip ci]loop guards are all retained verbatim.No CHANGELOG entry in this PR — verified, not assumed
cliff.tomlevaluatescommit_parsersin order and^fixprecedes^(test|chore|ci|build|style), sofix(ci):lands under Bug Fixes, not skipped (cf. existing- **ci:** Drop doomed changelog:verify from preflight (#139)). It is still not hand-written here: the entry needs the post-squash SHA, which is unknowable pre-merge — that is precisely whychangelog-syncexists and whychangelog:verifywas removed from preflight in #139. The (now guarded) sync will add it.Gates
task lint:shell(shellcheck 0.11.0,--severity=warning) — cleanhack/test/changelog_sync_release_guard_test.sh— 19/19 passactionlint—changelog-sync.yamlclean; the oneci.yamlSC2129 style note is pre-existing onmain(unrelated "Job summary" step, shifted two lines by this diff)python3 -c "import yaml; yaml.safe_load(...)"on both workflows — okhack/scrub.sh— ok