Skip to content

ci: guard tagged changelog sections - #1239

Closed
WilliamK112 wants to merge 7 commits into
squirrelscan:mainfrom
WilliamK112:codex/changelog-tag-guard-1234
Closed

WilliamK112 wants to merge 7 commits into
squirrelscan:mainfrom
WilliamK112:codex/changelog-tag-guard-1234

Conversation

@WilliamK112

Copy link
Copy Markdown
Contributor

Summary

  • fetch release tags in pull-request CI and reject a tagged CHANGELOG section when a PR changes it away from the snapshot stored at that tag
  • leave Unreleased edits and a newly named, not-yet-tagged release section alone so normal feature and release-bump PRs continue to pass
  • compare only sections changed from the PR base, so historical differences do not make unrelated PRs fail; touching one requires restoring the tag snapshot
  • add fixture coverage for unchanged notes, Unreleased additions, released-section additions, the diagnostic, and release bumps

Closes #1234.

Verification

  • bash scripts/test-released-changelog.sh
  • bash scripts/check-released-changelog.sh upstream/main — 60 tagged sections available, no released section changed by this PR
  • bun run test:release — 19 Bun tests plus both shell suites pass
  • bash scripts/test-ci-classify.sh — 38 cases pass
  • bun run format:check
  • bun run lint
  • bun run typecheck
  • git diff --check

Checklist

  • I added or updated tests for behavioral changes.
  • I did not include secrets, customer data, or incompatible third-party material.
  • Every commit includes a DCO Signed-off-by line (git commit -s).

Docs: CHANGELOG.md. Skill: none.

@WilliamK112
WilliamK112 requested a review from nc9 as a code owner October 28, 2026 21:09
@nc9 nc9 added chore github_actions Pull requests that update GitHub Actions code labels Oct 28, 2026

nc9 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed head: 3c7233f

Verdict: looks good. Thanks for this. All CI checks are green, the DCO sign-off is present, there is no new runtime dependency, and the CHANGELOG bullet is under [Unreleased]. The findings below are all minor.

Low

  • The check compares the PR's section against the tag snapshot only for sections the PR changed relative to the base, which is a sensible way to avoid failing on old drift. It also catches a deleted or renamed released section, since the section then differs from the tag. Worth one fixture for the delete case in scripts/test-released-changelog.sh.
  • check-released-changelog.sh and test-released-changelog.sh are committed as mode 100644. They are invoked through bash, so it works, but the neighbouring ci-classify.sh is 755. Match it for consistency.
  • The new steps run in the job named "Classify changed files". That works, but a reader looking for the gate may not expect it there. A short comment in ci.yml saying why would help.

Notes for the maintainer

  • This edits .github/workflows/ci.yml, so it is a workflow change and needs a human decision before merge.
  • git show "$BASE:CHANGELOG.md" needs the base commit in the checkout. It passed here, so the checkout depth is evidently enough, but it is worth confirming on a PR whose base is far behind.

@nc9 nc9 mentioned this pull request Oct 28, 2026
3 tasks done
@nc9 nc9 added the ci label Oct 28, 2026 — with Claude
@WilliamK112

Copy link
Copy Markdown
Contributor Author

Addressed the review suggestions in 98ef683:

  • added a fixture proving deletion of a tagged release section is rejected and names that release
  • made both new shell scripts executable, matching the neighbouring CI helpers
  • added a workflow comment explaining why the guard lives in the always-running classification job

The shell syntax checks, both changelog test suites, the real repository comparison (60 tagged sections), and all 19 release-version tests pass locally.

nc9 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed head: 98ef683

Verdict: looks good. Thanks for the updates. The new head adds the deleted-section fixture and the scripts are now mode 755, which covers the earlier findings. CI is green, the DCO sign-off is present, there is no new runtime dependency, and the CHANGELOG bullet is under [Unreleased].

Low

  • git show "$BASE:CHANGELOG.md" needs the base commit in the checkout. It passed in CI here, but confirm on a PR whose base is far behind main.

Notes for the maintainer

  • This edits .github/workflows/ci.yml, so it is a workflow change and needs a human decision before merge.

@nc9

nc9 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Reviewed head: 98ef683

Thanks @WilliamK112. This is a clean design: it compares only the sections a PR changes against their tag snapshot, skips untagged versions so release-bump PRs pass, and the fixture script covers the right cases. The acceptance criteria in #1234 hold.

Security (workflow change): nothing to fix.

  • Permissions stay contents: read, with no new actions and no secrets.
  • The trigger stays pull_request, so a fork gets a read-only token.
  • The only interpolated value is the base SHA, passed via env: and quoted.
  • Version strings are regex-limited before they reach git or awk, so a fork can't inject anything.

Two things before merge:

  1. (medium) Tag fetch inside the 2-minute changes job. Fetching all ~138 v* tags at --depth=1 pulls a tree per tag on every PR, and the changes job has timeout-minutes: 2. A slow fetch would turn classification red for everyone. Please add --filter=blob:none, or better, fetch only the tags for versions whose section actually changed (the script already computes them).
  2. (medium) Fail-closed step in a fail-open job. changes deliberately falls back to "run everything" when the base fetch fails, but the new step errors the whole job if the base or tag fetch hiccups. Please move the guard into its own small job (for example "Changelog guard") so a failure is clearly named and doesn't take classification down with it.

Smaller:

  • (low) check-released-changelog.sh ~line 80: use git show "refs/tags/$version:CHANGELOG.md", as line 69 already does, so a branch with the same name can't shadow the tag.
  • (low) Add rows for the two new script paths to scripts/test-ci-classify.sh.
  • (info) There's no override for a deliberate typo fix in a released section. That's fine; restoring the tag snapshot is the documented path.

Verdict: merge after the two medium fixes.

@nc9

nc9 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Sorry for the mixed signals, @WilliamK112. The two "looks good" passes were automated; the latest review is the one to follow. The workflow is fine security-wise, but please move the guard into its own job and make the tag fetch cheaper (--filter=blob:none, or only the changed versions' tags) before we merge. Your deleted-section fixture is a good addition.

@WilliamK112

Copy link
Copy Markdown
Contributor Author

Addressed the latest review in b421933.

  • Moved the released-section check into its own always-visible Changelog guard job, separate from the fail-open path classifier.
  • The new job fetches the PR base explicitly and fetches release tags with --filter=blob:none and depth 1.
  • Qualified the changelog lookup as refs/tags/$version:CHANGELOG.md.
  • Added classifier table rows for both new changelog scripts.

Validation:

  • shell syntax checks
  • bash scripts/test-released-changelog.sh
  • bash scripts/test-ci-classify.sh (40 cases)
  • bun run test:release (19 version tests plus both changelog suites)
  • real repository comparison: 60 tagged sections
  • clean partial-clone probe against GitHub: all 138 tags fetched with --filter=blob:none, and the newest tag's changelog blob resolved successfully
  • bun run format:check
  • workflow YAML parse
  • git diff --check

@nc9

nc9 commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Reviewed head: b421933

Thanks @WilliamK112. All four items from the last round are in:

  • the separate "Changelog guard" job;
  • --filter=blob:none on the tag fetch;
  • refs/tags/$version everywhere;
  • the two test-ci-classify.sh rows.

Security is unchanged and clean: contents: read, the pull_request trigger, the same pinned checkout, no secrets, and ${{ }} only in env:.

One fix before merge:

  1. (medium) The blobless fetch turns into ~138 lazy fetches. With --filter=blob:none, check-released-changelog.sh runs git show refs/tags/$version:CHANGELOG.md for every tagged version before the "did this section change?" comparison. Each call triggers its own on-demand blob fetch, which means roughly 138 sequential round trips inside a 2-minute job. And 2>/dev/null || continue turns a failed fetch into a silent skip, so a network blip could let a released-section edit through. Please:
    • compare current against base first and read a tag snapshot only for sections that actually changed, so a normal PR fetches no tag blobs at all;
    • make a failed snapshot read for a changed section fail the job rather than continue.

Low:

  • If branch protection lists required checks by name, "Changelog guard" will need adding there. That's on us, not you.

Verdict: merge after the fix above.

@WilliamK112

Copy link
Copy Markdown
Contributor Author

Addressed the final review item in ddba585.

  • The checker now extracts and compares current/base sections before resolving a tag or reading any tag snapshot, so an ordinary PR performs zero lazy tag-blob fetches.
  • It reads refs/tags/$version:CHANGELOG.md only for a section this PR actually changed.
  • If that snapshot cannot be read for a changed tagged release, the job now fails with an explicit error instead of silently continuing.
  • Added fixtures proving an unchanged section does not read its unavailable tag snapshot and a changed section fails when that snapshot is unavailable.

Validation:

  • shell syntax checks
  • bash scripts/test-released-changelog.sh
  • bash scripts/test-ci-classify.sh (40 cases)
  • real repository comparison against current main: 0 changed, 0 compared
  • git diff --check

nc9 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed head: ddba585

Thanks @WilliamK112. Verdict: the last requested change is in, pending maintainer review because this edits a workflow.

Earlier requests, checked against this head:

  • Separate "Changelog guard" job, so a failure no longer takes classification down: done (ci.yml:83).
  • Cheap tag fetch: --filter=blob:none at ci.yml:95.
  • refs/tags/$version everywhere: done (check-released-changelog.sh:83 and :94).
  • Compare against base before reading any tag snapshot, so an ordinary PR fetches no tag blobs: done (check-released-changelog.sh:70-77, snapshot read only at :94).
  • A failed snapshot read for a changed tagged section now fails the job instead of continue (:94-99), and the two new fixtures cover both cases.
  • Conventions: DCO sign-off is present on every commit, no new runtime dependency, and the CHANGELOG bullet sits under [Unreleased].

Security (workflow change): unchanged and clean. contents: read by default, pull_request trigger, SHA-pinned checkout, no secrets, and ${{ }} only inside env: or the checkout input.

Low:

  • check-released-changelog.sh:83: if the tag fetch were ever to succeed partially, a changed section whose tag is missing locally is treated as a release bump and skipped. Because the fetch step runs with set -e semantics that is unlikely, but a one-line note that the tag fetch must succeed for this skip to be safe would help.

CI on this head: the new "Changelog guard" job is green and every other finished check is green; CLI tests and the audit engine golden tests were still running when I looked.

Notes for the maintainer: workflow change, so it needs a human decision before merge. If branch protection lists required checks by name, "Changelog guard" needs adding.

@WilliamK112

Copy link
Copy Markdown
Contributor Author

Additional final-head validation: bun run test:release passes, including both changelog shell suites and all 19 release-version tests.

nc9 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed head: b25b08d

Thanks @WilliamK112. Verdict: pending maintainer review, because this edits a workflow. No code change since the last reviewed head.

The only new commit is a merge of main (b25b08d2, which brings in #1243 and touches only tech-detect). The changelog guard is identical to ddba585e, where every requested change was confirmed: separate "Changelog guard" job, blobless tag fetch, refs/tags/$version lookups, classifier rows, and base-first comparison with a hard failure when a changed section's snapshot cannot be read.

Security (workflow change): unchanged and clean. contents: read, pull_request trigger, no secrets, and ${{ }} only in env:.

Still open (low): note at check-released-changelog.sh:83 that the tag fetch must succeed for the "missing tag means release bump" skip to be safe. If branch protection lists required checks by name, "Changelog guard" needs adding.

CI on this head: all checks green, including "Changelog guard".

@nc9

nc9 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Reviewed head: b25b08d

A merge of main on top of ddba585; the guard's own changes are identical. Maintainer check of the last change: it compares current against base first and reads a tag snapshot only for a changed section, so an ordinary PR does no tag-blob fetches, and an unreadable snapshot for a changed released section fails the job. Approved for merge. Thanks @WilliamK112.

One low follow-up, not blocking: running the script locally without v* tags now passes an edited released section silently, because the earlier "no tagged sections" error is gone. CI can't hit this, since a failed tag fetch fails the job.

@nc9

nc9 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

@WilliamK112 this is approved and ready to merge, but v0.0.140 just shipped and the PR now conflicts with main, almost certainly in CHANGELOG.md: the old [Unreleased] bullets moved into the v0.0.140 section. Could you merge main once more and keep your bullet under the new ## [Unreleased] heading? Please leave the released sections untouched. If the only new commit is that merge, it goes straight in with no further review round.

@nc9

nc9 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Update-branch (merge of main, no rebase): head 1c9aa4e = merge commit, parents b25b08d (approved) and 660dcfc (main tip). Non-CHANGELOG patch unchanged: git patch-id --stable 873f85e914b7aff633fe3dea46c43424923c7586 for both, same file list. CHANGELOG bullet under [Unreleased]; released sections equal their tags. Pin for merge once checks are green: 1c9aa4e.

@nc9 nc9 mentioned this pull request Oct 29, 2026
@nc9

nc9 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Landed, thank you @WilliamK112. Your four commits are on main under your name: e3dc102, 75f0f2b, bdec991 and bdc6c82, shipped in v0.0.141 via the stacked release PR #1272 (rebase-merged, so this PR shows as closed rather than merged). The Changelog guard ran green on the release PR and is now enforcing that tagged sections stay untouched. (Nik)

@nc9 nc9 closed this Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore ci github_actions Pull requests that update GitHub Actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: fail a PR that edits a released CHANGELOG section

2 participants