From 2f7ef8cc53200a125ff64a891ed2baeca6ddd0be Mon Sep 17 00:00:00 2001 From: Benjamin Borbe Date: Tue, 2 Jun 2026 11:46:45 +0200 Subject: [PATCH] feat(precommit): add check-index target to catch walker-output drift PR #9 trimmed a doc that contained pre-canonicalized rule blocks but shipped without running 'make build-index'. The 7 new agent-cmd/* entries were silently absent from rules/index.json until PR #10 picked them up retroactively. The lesson: walker-output drift is silent at review time; rules/index.json passes JSON validation regardless. Fix: add 'check-index' to the precommit chain. The target regenerates the walker output to a tmp file, diffs against the committed index, and fails with the diff + a 'run make build-index and commit' message if they differ. Behavior verified: - Clean state (master HEAD c07b809): precommit passes - Synthetic drift (extra line appended to rules/index.json): precommit fails with diff output and non-zero exit code This closes the gap that turned a one-PR change (PR #9) into a two-PR walker-regen catch-up (PR #10). Future trim/bootstrap PRs that touch rule blocks will fail precommit locally if the walker output isn't also committed. --- Makefile | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 87201c6..cc6ecab 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ SHELL := /bin/bash .PHONY: precommit -precommit: check-links check-json +precommit: check-links check-json check-index .PHONY: release-check release-check: precommit check-versions @@ -26,3 +26,15 @@ check-versions: build-index: @python3 scripts/build-index.py > rules/index.json @echo "rules/index.json updated" + +.PHONY: check-index +check-index: + @python3 scripts/build-index.py > /tmp/coding-rules-index-check.json + @if ! diff -q rules/index.json /tmp/coding-rules-index-check.json > /dev/null 2>&1; then \ + echo "ERROR: rules/index.json is stale. Run 'make build-index' and commit the result."; \ + diff -u rules/index.json /tmp/coding-rules-index-check.json | head -40; \ + rm -f /tmp/coding-rules-index-check.json; \ + exit 1; \ + fi + @rm -f /tmp/coding-rules-index-check.json + @echo "rules/index.json up-to-date"