From 0fe6153ead5e46ab7cc27c21a551f795277aa15c Mon Sep 17 00:00:00 2001 From: bastien Date: Mon, 11 May 2026 16:27:31 +0200 Subject: [PATCH] =?UTF-8?q?fix(prune-memory):=20STEP=204=20verify=20?= =?UTF-8?q?=E2=80=94=20prefix=20mapping=20bug=20(TDD=20RED=E2=86=92GREEN)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- skills/prune-memory/SKILL.md | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/skills/prune-memory/SKILL.md b/skills/prune-memory/SKILL.md index 2cf900e..65e6fbe 100644 --- a/skills/prune-memory/SKILL.md +++ b/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: