Bladeren bron

fix(prune-memory): STEP 4 verify — prefix mapping bug (TDD RED→GREEN)

First end-to-end run of /prune-memory on real .claude/memory/ surfaced
a broken verify script:

Old: `prefix=$(basename "$f" .md | tr a-z A-Z | cut -c1-3)` derived
the prefix from the filename's first 3 letters → produced DEC / LEA /
BLO. Actual prefixes are BDR / LRN / BLK. The grep then matched zero
entries, no MISSING/ORPHAN was ever reported, and the script printed
its "OK if blank" footer regardless of real state. False clean signal.

Fixed: hard-mapped filename → prefix via `declare -A PREFIX_MAP`.
Verified against current registries — 14 BDR + 16 LRN + 2 BLK + 1 EVAL
entries all index-consistent, no false negatives.

Added EVAL prefix to the map (evals.md was missing from the loop in
v1). Footer line clarified to `(blank above = OK)`. `wc -l` excludes
`.original.md` backups from the output.

Note: caveat in skill body said "v1 ships without baseline TDD test —
STEP 2 approval gate is the safety net". First real test caught a
verify bug that bypassed STEP 2 entirely. Lesson: STEP 4 is its own
safety net and needs its own test.

Co-Authored-By: Claude <noreply@anthropic.com>
bastien 5 dagen geleden
bovenliggende
commit
0fe6153ead
1 gewijzigde bestanden met toevoegingen van 18 en 3 verwijderingen
  1. 18 3
      skills/prune-memory/SKILL.md

+ 18 - 3
skills/prune-memory/SKILL.md

@@ -154,9 +154,23 @@ After each write, regenerate Index from body when rows changed.
 ## STEP 4 — VERIFY
 
 ```bash
+# Filename → ID-prefix map. Hard-mapped because filenames don't share
+# their first 3 chars with the prefix (decisions → BDR, not DEC).
+# v1 bug: derived prefix via `basename | cut -c1-3` → never matched,
+# verify printed false-clean signal. Fixed in v1.1 (TDD found it).
+declare -A PREFIX_MAP=(
+  [decisions]=BDR
+  [learnings]=LRN
+  [blockers]=BLK
+  [evals]=EVAL
+)
+
 # All body entries have Index rows; no orphans
-for f in .claude/memory/decisions.md .claude/memory/learnings.md .claude/memory/blockers.md; do
-  prefix=$(basename "$f" .md | tr a-z A-Z | cut -c1-3)
+for fname in decisions learnings blockers evals; do
+  f=".claude/memory/${fname}.md"
+  [ -f "$f" ] || continue
+  prefix="${PREFIX_MAP[$fname]}"
+
   /usr/bin/grep -oE "^## (${prefix})-[0-9]+" "$f" | while read marker; do
     id="${marker##\#\# }"
     /usr/bin/grep -q "^| ${id} " "$f" || echo "MISSING INDEX: $id in $f"
@@ -166,8 +180,9 @@ for f in .claude/memory/decisions.md .claude/memory/learnings.md .claude/memory/
     /usr/bin/grep -q "^## ${id} " "$f" || echo "ORPHAN INDEX: $id in $f"
   done
 done
+echo "(blank above = OK)"
 
-wc -l .claude/memory/*.md
+wc -l .claude/memory/*.md | grep -v "\.original\.md"
 ```
 
 Report: