13 KiB
FEAT — prune-memory-status-reader (/feat D4, 2026-11-11) — r3
Source: .claude/tasks/TODO.md § Release 3.0.0 scope, D4 (user 2026-11-11 [gated]: "/prune-memory reads statuses through memory.sh (v1+v2), example IDs 9xx"); evidence .claude/tasks/plans/2026-11-09-bdr125-obsolescence-clean-1650.md D4.
User decisions 2026-11-11 [gated] (after challenge round 1)
- ONE classifier for decisions and blockers: generalize
reconcile_blk_classifyto a prefix (strict word on v2, single status word on v1 via_mem_v1_word, never the## Index, never prose). Same grammar for both registries. - Unreadable statuses: ONE count line per registry, info only: outside "all", never a candidate, never written by the skill; the status word comes from the user, per ID, never from the entry text. Dialect migration is a separate follow-up, logged, not done here.
Round 2 rulings (no BLOCKER; CONCERNS robustness 4, simplicity 1, correctness 2)
- STEP 4 status drift check DROPPED (simplicity 1: ungated new certification gate; it misfires on every approved merge and on v1 prose compression, robustness 2/3, correctness 2). Logged as follow-up.
- v1 decisions line selector widened (robustness 1):
statut,superseded,deprecatedadded for the BDR range, through an env override of the existing selector (BLK path untouched). - One status-line rule for compression and merges, v1 included (correctness 1); merged status written by
--status <word>shown on the [B] line, evals included (robustness 4, 9). - v1 date dialects give no 90-day candidate: stated in 1.A, part of the dialect follow-up (simplicity 2, correctness 6).
- RED-9: no
grep -P, nosed -i(portability census); BLK rows cut to one; census onstatus:(catches backticked forms); extract_block anchored.
Context
- skills/prune-memory/SKILL.md raw
status: …wording at :33-34, :81-82, :87-89, :122-123, :130, :252, :260-261; "frontmatter" at :157, :159. v2 registries have no per-entry frontmatter: heading## ID — title [status] (date)+- **Label**: valuelines + dated- **Status (date)**:lines. On v1 filesmemory.sh add --status swrites a- **Status**: sbody line (lib/memory.sh:396-399). - Real data (read-only, challenge rounds):
memory.sh index decisionStatus empty for game 107/107 (format: 2butdate: … · status:dialect), config 19/19, faunosteo 76/80 (v1 wordsclosed,active), faunosteo-v1-2 79/110. Most stay unreadable with any reader: hence the count line. reconcile_blk_classify(lib/reconcile.sh:116-137) is BLK-only. Column 2 isopenfor every known non-closed word; the word is column 3.memory_legacy_status <file> <ID> <end>(lib/memory.sh:642-663) keeps the LAST line of the range matching_MEM_LEGACY_RE='status|RESOLVED|REVERTED|upstream|resolved|[^a-z]open'(case-insensitive in the<end>awk branch viaRE="$_MEM_LEGACY_RE");_mem_v1_wordneeds exactly ONE known word after a status/statut label, else empty.- run-deterministic.sh: RED-1,2,5,6,7 in Makefile SUITES;
extract_blockmatches"^## " hunanchored, so "STEP 0" re-arms on## STEP 0b(step0.sh today also carries STEP 4's block). RED-6 pins HOME to a sandbox whose.claude/liblinks this repo's lib. lib/tests/portability-census.test.sh flagsgrep -…Pandsed -iin tracked *.sh. tests/BACKLOG.md already has a "RED-8 (candidate)": the new test is RED-9.
Plan
- lib/memory.sh
memory_legacy_status,<end>branch only:RE="$_MEM_LEGACY_RE"→RE="${MEM_LEGACY_RE:-$_MEM_LEGACY_RE}"; one comment line: callers may widen the selector (reconcile's decisions range). Default branch untouched; no other memory.sh change. - lib/reconcile.sh — generalize, BLK output byte-identical:
- constant near RECONCILE_DEFER_RE:
RECONCILE_BDR_RE="$_MEM_LEGACY_RE|statut|superseded|deprecated"with a comment (v1 decisions carry**Statut** :andSuperseded by …lines the blocker selector skips; an unlabelled winner stays unreadable through_mem_v1_word). - helper:
_reconcile_status() { # <file> <ID> <PREFIX> → the current status line [ "$3" = BLK ] && { reconcile_blk_current_status "$1" "$2"; return; } if memory_is_v2 "$1"; then memory_entry_status "$1" "$2"; return; fi MEM_GREP="$RECONCILE_GREP" MEM_LEGACY_RE="$RECONCILE_BDR_RE" \ memory_legacy_status "$1" "$2" "^##* *$3-[0-9]" } reconcile_status_classify <file> <PREFIX>= today'sreconcile_blk_classifybody withBLK→$2(enumerate,_mem_heading_ids) and the status call →_reconcile_status "$1" "$id" "$2";reconcile_blk_classify() { reconcile_status_classify "$1" BLK; }. Header "Layers" list: addreconcile_status_classify(any prefix;reconcile_blk_classify= its BLK wrapper).
- constant near RECONCILE_DEFER_RE:
- skills/prune-memory/SKILL.md STEP 1 — AUDIT: right after "For each target registry…", the status source, run once:
Prose under it: these rows are the ONLY status source of STEP 1.A; a status word in an entry's prose or title is never a status. With a
# Current statuses: one reader for decisions and blockers (BDR-129: # strict word on v2, one status word on v1, never the ## Index, never a # word in prose). Rows: ID<TAB>open<TAB>word | ID<TAB>unreadable<TAB>line; # closed entries (resolved, superseded, deprecated) are omitted. for k in decisions:BDR blockers:BLK; do f=".claude/memory/${k%%:*}.md" [ -f "$f" ] || { echo "== $f: no-file"; continue; } echo "== $f" ( . "$HOME/.claude/lib/reconcile.sh" \ && reconcile_status_classify "$f" "${k#*:}" ) \ || echo "== $f: reader-unavailable" done$ARGUMENTSfilter, use only the rows of the filtered registries.reader-unavailable→ no status-based candidate for that registry this run (say so in STEP 2).unreadablerows → the[Status unreadable]count line (STEP 2), never an A candidate. - STEP 1.A rules on that source (word = column 3):
- "Decisions whose word is
proposedand whose date is older than 90 days → proposememory.sh status <ID> "deprecated, no follow-up after 90 days". Date = the newer of thememory.sh index decisionDate cell and the date of the entry's last- **Status (YYYY-MM-DD)**:line; no date → not a candidate (v1 dialect dates such as| date |headings ordate: … ·lines give none)." - Successor rule: "… whose word is still
accepted" (drop itsmemory.sh index decisionmention). - "Blockers whose word is exactly
open(never upstream, accepted or any other word) whose root cause matches a commit in the last 30 days (grepgit log --since=30.days --grep=<keyword>) → proposememory.sh status <ID> "resolved <commit>"." - Journal rule unchanged.
- "Decisions whose word is
- STEP 2 — PRESENT PLAN example (9xx IDs only, RED-7):
- :122-123 →
BDR-901 — example proposed decision — word proposed, dated <90+ days ago>/→ memory.sh status BDR-901 "deprecated, no follow-up after 90 days". - [B] line :128-130 →
→ propose: merge into NEW LRN-904 (learnings carry no status) with both bodies appended + caveman pass; sources: memory.sh status <ID> "superseded by LRN-904". Census reminder: nowhere in SKILL.md maystatusbe followed by a colon and a space in lowercase. - new block after [C]:
[Status unreadable — info only, never applied, not part of "all"] decisions.md: 3 (BDR-905, BDR-906, BDR-907) → you give the word per ID: memory.sh status <ID> "<word>" - Prose after the example: a [B] merge of decisions, blockers or evals names the merged entry's status word on its line (default: the sources' common word; sources differ → ask in
edit <ID>); the count line folds IDs (first 10, then+N more); the word always comes from the user, never from the entry text; on a v1 file the status text carries one status word only (else it stays unreadable); a rowheading levelneeds its heading fixed to## IDfirst (memory.sh statuscannot reach it). Approve prompt unchanged.
- :122-123 →
- STEP 3, one definition used by 3.2 and 3.3 — a STATUS LINE is any line of the entry that holds (case-insensitive)
status,statut,resolved,reverted,upstream,superseded,deprecatedor the wordopen, or a- **<label>**:line whose label holds status/resolution/action/update/final.- 3.2 Merges:
memory.sh add <kind> --title … --body-file … [--status <word>] --supersedes …with the word shown on the [B] line (decisions, blockers, evals; learnings none). The merged body drops the sources' labelled status lines (- **Status…**:,Status:/statutlines,- **Resolution|Action|Update|Final…**:); the new entry's status is the--statusword (v2: heading tag; v1: a- **Status**:body line, and a later prose STATUS LINE can make it unreadable: it then shows in the count line). Replace the "Keeps frontmatter fields: …" bullet with "memory.sh addwrites the heading (new ID, title, date) and the status; the body keeps the union of**Reference**:lines." - 3.3 Compression: "preserve frontmatter exactly (id, date, title, status, references)" → "keep VERBATIM the heading line, every
- **Label**:key and every STATUS LINE; rewrite only the other prose."
- 3.2 Merges:
- Core principles :33-34, What NOT to prune :252, Common mistakes :260-261:
status: superseded by …/status: deprecated/status: superseded→ "asuperseded by <ID>/deprecatedstatus written bymemory.sh status"; "Entries the user markedstatus: acceptedin the current session" → "Entries whose status the user set this session". After the run SKILL.md holds nostatus:(lowercase, colon, space) and nofrontmatter. - skills/prune-memory/tests/run-deterministic.sh:
extract_block: anchor the heading,$0 ~ "^## " h "( |$)"(STEP 0 no longer re-arms on STEP 0b); RED-2 and RED-6 stay GREEN.- RED-9 (behaviour, LRN-276: runs the shipped STEP 1 block), fixtures written with printf in
$SANDBOX/red9aand$SANDBOX/red9b(no fixture files), HOME pinned like RED-6,TAB=$'\t', assertions/usr/bin/grep -qxF "<row>"on the block output (whole-line, fixed string; unreadable rows matched with/usr/bin/grep -qF "BDR-905${TAB}unreadable${TAB}"). Nogrep -P, nosed -i.- red9a decisions.md v2 (
---/format: 2/---frontmatter):## BDR-901 — old idea [proposed] (2026-01-01)with body "resolved later" →BDR-901${TAB}open${TAB}proposed;## BDR-902 — kept [accepted] (2026-02-01)+- **Status (2026-03-01)**: superseded by BDR-903→ no BDR-902 row. red9a blockers.md v1:## BLK-903 — c+- **Status**: upstream→BLK-903${TAB}open${TAB}upstream(wiring only; HM3a covers the BLK cases). - red9b decisions.md v1 (no frontmatter):
## BDR-904 — x+date: 2026-01-01 · status: accepted→BDR-904${TAB}open${TAB}accepted;## BDR-905 — y+Status: closed.→ unreadable row;## BDR-906 — z+Status: proposedthen a later- **Statut** : accepted (2026-05-01)→BDR-906${TAB}open${TAB}accepted;## BDR-907 — w+- Status: proposedthenSuperseded by BDR-911 (2026-05-01).→ noopenrow for BDR-907 (unreadable). - Census:
/usr/bin/grep -c 'status: ' "$SKILL"= 0 and/usr/bin/grep -c 'frontmatter' "$SKILL"= 0. - GREEN when every assertion holds; a RED message names the first failing one.
- red9a decisions.md v2 (
- Header comment lists RED-9; summary lines unchanged.
Edge cases
- No decisions.md / blockers.md:
no-fileline. reconcile.sh missing or failing:reader-unavailableline. - BLK output unchanged (wrapper, default selector): HM1-HM3 and run-reconcile.sh stay green.
- Fixture IDs 9xx only. learnings / evals / journal are not read by the STEP 1 block.
- G7 (memory.sh upgrade may take a stale v1 Index cell): the remedy names
memory.sh status, neverupgrade.
Disposition
honors BDR-129 (strict v2, legacy v1, never the Index: one classifier, both registries), BDR-133 (negated words: _mem_v1_word), LRN-276 (RED-9 runs the shipped STEP 1 block), LRN-277 (executor brief forbids stdin readers), LRN-275 (explicit staging), LRN-271 (make test env), LRN-074 (pinned /usr/bin/grep). Deviation from the gated wording "through memory.sh": the classifier lives in lib/reconcile.sh, built on memory.sh readers (user chose it 2026-11-11). Foreign-code style.
Files (4)
lib/memory.sh, lib/reconcile.sh, skills/prune-memory/SKILL.md, skills/prune-memory/tests/run-deterministic.sh.
Follow-ups (log in BUGS-FOUND / TODO, not done)
- Dialect migration:
format: 2registries indate: … · status:(game 107 decisions), v1 words outside_MEM_WORDS(closed,active, faunosteo), v1 date dialects invisible to the 90-day rule. - Status drift check at /prune-memory STEP 4 (classify HEAD vs working, expected-drift set from STEP 2 incl. merges, whole-file restore remedy): dropped from D4 round 2.