Fix review.sh inventing 12 removals that the prune never makes

It round-tripped the pruned text through a shell variable, and command
substitution strips every trailing newline while printf added exactly one
back, so any file whose pruned output ended in more than one blank line
diffed against a reshaped copy of itself. Comparing files directly instead
brings review.sh to 270 removals across 118 files, matching validate.py,
which derives the same number from the drop set rather than from a diff.

The counting was wrong too: a removed `- [x] foo` is `-- [x] foo` in a
unified diff, so the `^-[^-]` pattern skipped every checkbox it was meant
to be counting.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PU5ZFfQFtDTFqqhvMTWdGH
This commit is contained in:
Connor JohnstoneandClaude Opus 5 committed 2026-09-09 18:35:25 -04:00
1 parent 1053310d32
commit caa367feb2
1 file changed
+16 -6
+16 -6
View File
@@ -1,17 +1,27 @@
#!/bin/sh #!/bin/sh
# Regenerate the whole-corpus prune diff. The plan requires reviewing this # Regenerate the whole-corpus prune diff. The plan gates the timer on reviewing
# before the timer runs, and again after any change to the rule. # this, and the same gate should be re-runnable after any change to the rule.
set -eu set -eu
NOTES="${1:-$HOME/docs/notes/todo}" NOTES="${1:-$HOME/docs/notes/todo}"
HERE=$(cd "$(dirname "$0")" && pwd) HERE=$(cd "$(dirname "$0")" && pwd)
OUT="${OUT:-$HOME/todo-prune-review.diff}" OUT="${OUT:-$HOME/todo-prune-review.diff}"
tmp=$(mktemp)
trap 'rm -f "$tmp"' EXIT
: > "$OUT" : > "$OUT"
files=0
for f in "$NOTES"/*.md; do for f in "$NOTES"/*.md; do
p=$(python3 "$HERE/prune.py" "$f") # Compare files rather than shell strings: command substitution eats
if [ "$p" != "$(cat "$f")" ]; then # trailing newlines and would invent differences that are not there.
printf '%s\n' "$p" | diff -u --label "$f (now)" --label "$f (pruned)" "$f" - >> "$OUT" || true python3 "$HERE/prune.py" "$f" > "$tmp"
if ! cmp -s "$f" "$tmp"; then
diff -u --label "$f (now)" --label "$f (pruned)" "$f" "$tmp" >> "$OUT" || true
files=$((files + 1))
fi fi
done done
echo "$OUT: $(grep -c '^-[^-]' "$OUT" || true) lines removed across $(grep -c '^---' "$OUT" || true) files"
all=$(grep -c '^-' "$OUT" || true)
hdr=$(grep -c '^--- ' "$OUT" || true)
echo "$OUT: $((all - hdr)) lines removed across $files files"