build: add CHANGELOG-structure check to precommit#49
Merged
Conversation
There was a problem hiding this comment.
ast-grep is not accessible. The toolchain check fails — following the fail-fast discipline, I'll skip the mechanical funnel (Step 4) and proceed directly to the consolidated report.
PR Review: build: add CHANGELOG-structure check to precommit
Target: master ← feature/changelog-structure-check
Files changed: CHANGELOG.md, Makefile, scripts/check-changelog.sh (+44/−1)
Step 5: Consolidated Report
Must Fix (Critical)
None.
Should Fix (Important)
None.
Nice to Have (Optional)
scripts/check-changelog.sh: The new bash script has no unit tests. The plan noted this and it remains unaddressed. Edge cases worth covering: (a) CHANGELOG with missing preamble, (b)##section placed before the preamble (the very bug this script guards against), (c) a correctly structured CHANGELOG. A simple table-driven test suite using the script's exit code would be appropriate here.
precommit skipped (selector mode) — CI covers lint+test
Step 4 skipped — toolchain gap
ast-grep/sg is not in PATH. The mechanical funnel could not run. Install via:
npm install -g @ast-grep/cli # or apk add ast-grep in alpine
Container fix: bborbe/maintainer agent/pr-reviewer/Dockerfile commit 1de083f.
Step 6: Next Steps
No test-coverage gaps in Go/Python code. For the shell script, consider:
/shellcheck scripts/check-changelog.sh # validate errexit/pipefail correctness
Step 7: Manual Review
Reviewed all three changed files:
Makefile:check-changelogtarget correctly calls@bash scripts/check-changelog.sh. It is added tocheck(notprecommit), which is the intended scope —make checkis what gates the build. Wiring is correct.scripts/check-changelog.sh:set -euo pipefailis correctly used. The|| trueguard on the twogrepcommands is intentional and correct — underset -e, grep returns exit code 1 on no-match, which would otherwise abort the script before the emptiness checks. The comment documents this. The logic forPREAMBLE_LINEandFIRST_SECTION_LINEcomparison is sound: only fires whenFIRST_SECTION_LINEis non-empty and less thanPREAMBLE_LINE. Preamble-only files (no sections yet) pass cleanly.CHANGELOG.md: The new## Unreleasedentry is correctly placed below the preamble and above## v0.96.3, matching the DoD this same PR codifies.
{
"verdict": "approve",
"summary": "Three-file PR adds a targeted CHANGELOG-structure check script wired into `make check`. The shell script is well-commented, handles `set -euo pipefail` correctly with the `|| true` guard, and the Makefile wiring is clean. One optional improvement: add a simple unit-test suite for the script covering the missing-preamble and section-before-preamble edge cases.",
"comments": [
{
"file": "scripts/check-changelog.sh",
"line": 1,
"severity": "nit",
"message": "Nice to Have: no test suite for this script — consider adding a table-driven test covering missing preamble, section-before-preamble, and valid-CHANGELOG cases"
}
],
"concerns_addressed": [
"correctness: grep -n -m1 combined with || true under set -euo pipefail is correct — confirmed: grep exit 1 on no-match would abort without || true",
"correctness: PREAMBLE_LINE and FIRST_SECTION_LINE emptiness logic is sound — only fires when FIRST_SECTION_LINE is non-empty AND less than PREAMBLE_LINE",
"tests: scripts/check-changelog.sh has no unit tests — raised as Nice to Have"
]
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Prompt 159 (the
work-onfix) once produced a malformed CHANGELOG — a## Unreleasedsection inserted above the "All notable changes…" preamble — and it shipped in v0.96.2 because nothing checks CHANGELOG structure. #48 hardened the DoD doc; this adds the mechanical guard so it fails the build instead of relying on the author.What
scripts/check-changelog.sh— fails if any##section (Unreleased or version) appears before the preamble, or the preamble is missing. Mirrorscheck-versions.shstyle;set -euo pipefail-safe (|| trueon the greps).Makefile— newcheck-changelogtarget, wired into thecheckaggregate thatprecommitdepends on.## Unreleased(placed correctly — dogfoods the check).Verified: positive (current CHANGELOG) passes, negative (section above preamble) fails with a clear message,
make precommitgreen.Provenance
Authored by dark-factory prompt 160; the daemon built it correctly but couldn't land it (container died on flaky integration-test timeouts — unrelated to this change, which touches no Go). Reproduced by hand and run through the normal PR/review flow. Prompt 160 will be marked complete separately.