From caa367feb2cb15d1152551ebea027ccad4220252 Mon Sep 17 00:00:00 2001 From: Connor Johnstone Date: Wed, 9 Sep 2026 18:35:25 -0400 Subject: [PATCH] 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) Claude-Session: https://claude.ai/code/session_01PU5ZFfQFtDTFqqhvMTWdGH --- rollover/review.sh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/rollover/review.sh b/rollover/review.sh index e459832..61ae157 100755 --- a/rollover/review.sh +++ b/rollover/review.sh @@ -1,17 +1,27 @@ #!/bin/sh -# Regenerate the whole-corpus prune diff. The plan requires reviewing this -# before the timer runs, and again after any change to the rule. +# Regenerate the whole-corpus prune diff. The plan gates the timer on reviewing +# this, and the same gate should be re-runnable after any change to the rule. set -eu NOTES="${1:-$HOME/docs/notes/todo}" HERE=$(cd "$(dirname "$0")" && pwd) OUT="${OUT:-$HOME/todo-prune-review.diff}" +tmp=$(mktemp) +trap 'rm -f "$tmp"' EXIT + : > "$OUT" +files=0 for f in "$NOTES"/*.md; do - p=$(python3 "$HERE/prune.py" "$f") - if [ "$p" != "$(cat "$f")" ]; then - printf '%s\n' "$p" | diff -u --label "$f (now)" --label "$f (pruned)" "$f" - >> "$OUT" || true + # Compare files rather than shell strings: command substitution eats + # trailing newlines and would invent differences that are not there. + 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 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"