diff --git a/.claude/tasks/contracts/2026-10-27-memory-v2-write-2030.md b/.claude/tasks/contracts/2026-10-27-memory-v2-write-2030.md
index 41fa4c6..8231fe5 100644
--- a/.claude/tasks/contracts/2026-10-27-memory-v2-write-2030.md
+++ b/.claude/tasks/contracts/2026-10-27-memory-v2-write-2030.md
@@ -18,7 +18,7 @@ Phase 4a of the context mod queue (BDR-125), TODO.md "Phase 4a, memory v2 write
5. `memory.sh check [--staged]` validates: heading shape, ID uniqueness, v2 marker present, no `## Index` block in a v2 file; `--staged` also refuses a removed line inside an existing entry. It runs inside `add` and in `make test`; the generated pre-commit hook is untouched.
6. One shared status parser (lib function used by memory.sh and lib/reconcile.sh): candidates are the entry's own header `[tag]` and labelled status lines only (never a free word in prose); the last candidate in document order wins. `reconcile_blk_open` on a fixture holding BLK-032..034 as written today returns none of them; the existing run-reconcile T1/T2 stay green.
7. The four `## Index` blocks of this repo's registries are removed in one deterministic step; every status or supersession that lived only in an Index row is first materialized as a status line in the entry body (oracle: parser(body) == former Index status for every such row); heading count unchanged.
-8. Per-file v2 marker: every registry of this repo and every `templates/memory/*.md` carries it; a file without it is v1: the writer still appends, `check` reports it, and the per-project session banner warns `registry v1`.
+8. Per-file v2 marker: every registry of this repo and the four registry templates `templates/memory/{decisions,learnings,blockers,evals}.md` carry it (journal is not a registry: no marker); a file without it is v1: the writer still appends, `check` reports it, and the per-project session banner warns `registry v1`.
9. Citers patched in the same branch: capitalize, close, prune-memory (§ D removed, STEP 3 status carrier = `memory.sh status`, STEP 4 verify = `memory.sh check`), CAPITALIZE steps of feat/bugfix/hotfix/ship-feature/commit-change, init-project, lib/capitalize-commit.md (rc 5 documented), lib/analyze-before-plan.md, lib/reconcile.sh, templates/memory, onboard; doctrine-citers census green.
10. CLAUDE.global.md "Memory registries": writes go only through `lib/memory.sh`; the "Registries load every session" premise replaced; the heading and the bold label `Always English, always caveman` kept (census); file line count not above today's 333.
11. Dropped, must NOT appear: Meta line, 434-entry backfill, scope/critical labels, triggers field, English validator.
diff --git a/docs/superpowers/plans/2026-10-27-memory-v2-write.md b/docs/superpowers/plans/2026-10-27-memory-v2-write.md
index f781f24..681873e 100644
--- a/docs/superpowers/plans/2026-10-27-memory-v2-write.md
+++ b/docs/superpowers/plans/2026-10-27-memory-v2-write.md
@@ -2,89 +2,93 @@
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
-**Goal:** `lib/memory.sh` becomes the only writer of `.claude/memory` registries, one status parser serves memory.sh and reconcile, this repo's registries move to v2 (no `## Index`), every citer writes through the lib.
+**Goal:** `lib/memory.sh` becomes the only writer of `.claude/memory` registries, one status parser and one classifier serve memory.sh and reconcile on v2 registries, this repo's registries move to v2 (no `## Index`), every citer writes through the lib.
-**Architecture:** One sourceable bash lib on the `lib/project-rules.sh` skeleton (`-C
`, verbs, rc 2 + named reason). The awk status parser lives once in `_MEM_AWK` and is shared by `index`, `upgrade` and `lib/reconcile.sh`. Writers serialize through a noclobber lock file in the git common dir. `memory-commit.sh` runs `check --staged` as the chokepoint.
+**Architecture:** One sourceable bash lib on the `lib/project-rules.sh` skeleton (`-C `, verbs, rc 2 + named reason). The awk parser lives once in `_MEM_AWK` and is shared by `index`, `upgrade` and `lib/reconcile.sh` (v2 files). Writers serialize through a noclobber lock file in the git common dir. `memory-commit.sh` runs `check --staged` as the chokepoint. Revision r2 (2026-10-28) after a 3-lens challenge: FATAL(2) simplicity, CONCERNS(5) robustness, FATAL(6) correctness, every BLOCKER and MAJOR closed below.
-**Tech Stack:** bash 5, POSIX awk (no gawk-only features, no `{n}` intervals), git. Tests via `make test`.
+**Tech Stack:** bash 5, POSIX awk (no gawk-only features, no `{n}` intervals, no byte-count slicing around `—`), git. Tests via `make test`.
**Spec:** `docs/superpowers/specs/2026-10-27-memory-v2-write-design.md` (user-approved 2026-10-27). Contract: `.claude/tasks/contracts/2026-10-27-memory-v2-write-2030.md`.
-**Reference implementation (proven before this plan was written):** `docs/superpowers/plans/memory-v2-write/` holds `memory.sh`, `memory.test.sh` and `blockers-v2-status.md`. They were run in a mock repo: suite `PASS=72 FAIL=0` five runs in a row, shellcheck clean, no line over 80 chars; `upgrade` on a copy of this repo's live registries is oracle-green, `check`-green, idempotent, and its diff passes `check --staged`. Task 1 copies them; do not rewrite them.
+**Reference implementation (proven r2):** `docs/superpowers/plans/memory-v2-write/` holds `memory.sh`, `memory.test.sh`, `blockers-v2-status.md`, `blockers-v1-dialects.md`. Proven in a mock repo: suite `PASS=97 FAIL=0` five runs in a row and under `LC_ALL=C`, shellcheck clean, no `# shellcheck disable`, no line over 80 chars. `upgrade` on a copy of this repo's live registries: oracle-green, `check`-green, idempotent, its diff `--staged`-green, 26 statuses and 129 dates materialized, one Index status dropped and named (BDR-012). Task 2 and Task 3 code below was applied to a `git clone --shared` of this repo and run through `make test`. Task 1 copies the files; do not rewrite them.
## Global Constraints
- Branch `feature/memory-v2-write` (already started, spec at cdc0a47). Never switch, never merge, never push by hand (hooks push).
-- Our code: functions ≤ 25 logic lines (an embedded awk program counts as one statement), ≤ 5 locals, ≤ 5 params, lines ≤ 80 chars in `lib/*.sh`.
+- Our code: functions ≤ 25 logic lines (see Deviations for awk programs), ≤ 5 locals, ≤ 5 params, lines ≤ 80 chars in `lib/memory.sh`.
- No `# shellcheck disable` anywhere in the diff (floor guard, LRN-234). `# shellcheck source=/dev/null` directives are allowed.
- `/usr/bin/grep` pinned in libs (`MEM_GREP`, LRN-074); no `grep -q` reading a pipe under pipefail (LRN-189); no `sed -i`, `stat -c`, `realpath -m`, `grep -P` (portability census, BDR-110).
- No recursive delete through a variable except the existing `trap 'rm -rf "$FIX"' EXIT` mktemp pattern.
- Hermetic tests run through `make test [suite=…]` only.
-- Census-cited strings stay byte-identical: every `CLAUDE.md "Memory registries" (Always English, always caveman)` citation, the CLAUDE.global.md heading `## Memory registries (\`.claude/memory/\`)` and the bold label `**Always English, always caveman**` (doctrine-citers, LRN-166). Single-line fixed strings: do not rewrap a line that holds one.
+- Census-cited strings stay byte-identical: every `CLAUDE.md "Memory registries" (Always English, always caveman)` citation, the CLAUDE.global.md heading `## Memory registries (\`.claude/memory/\`)` and the bold label `**Always English, always caveman**` (doctrine-citers, LRN-166). Do not rewrap a line that holds one.
- CLAUDE.global.md line count must not exceed 333 after the edit.
- Worked examples use fictional 9xx IDs (LRN-073).
- Entry text written to registries is English caveman (BDR-009).
-## Deviations from the spec (found while proving the reference)
+## Deviations from the spec (named for the human gate)
-- Lock = a file created under bash noclobber, not a `mkdir` dir: uutils `mkdir` 0.10 on this host is not atomic (5 concurrent adds lost 2-4 entries). Same path (`/memory.lock`), same 30 s steal.
-- `journal` takes no `--date` flag: `MEMORY_DATE` already pins the date for tests; YAGNI.
-- `upgrade` writes an Index status into the body only when the body has none, or when the Index says superseded/deprecated and the body does not. Otherwise the body wins: the Index is the stale copy (BDR-012: Index accepted, body shipped). Status words rank in `_MEM_WORDS` order with `open` last, measured on the live registries: identical verdicts to today's reconcile on every blocker except BLK-032..034.
+1. **Lock** = a file created under bash noclobber (`open(O_EXCL)`), not a `mkdir` dir: uutils `mkdir` 0.10 on this host is not atomic (5 concurrent adds lost 2-4 entries). Same path, same 30 s steal; the steal renames the stale lock to a private name before removing it, never `rm` on the shared path. Released by an INT/TERM/HUP trap (an interrupted `add` also restores its backup), not an EXIT trap: a sourced lib must not own the caller's EXIT.
+2. **`journal` takes no `--date`**: `MEMORY_DATE` already pins the date for tests.
+3. **`upgrade` body wins**: an Index status reaches the body only when the body has none, or when the Index says superseded/deprecated and the body does not. Every other conflicting Index status is dropped and named on stderr (`memory: BDR-012: kept body shipped, dropped Index accepted`, the only one on this repo).
+4. **Status word**: a lib-written `**Status (YYYY-MM-DD…)**:` line reads its leading word (`status` requires the text to start with one: "open, reopened by abc"); other labelled lines rank words in `_MEM_WORDS` order, `open` last ("accepted. check OPEN" = accepted). A heading candidate is its `[tag]` only, never the title.
+5. **One classifier on v2, the lexical reader kept on v1**: on a v2 registry reconcile classifies by word (`memory_closed`: resolved | superseded | deprecated); `accepted` on a blocker stays open. On a v1 registry reconcile keeps today's lexical reader verbatim: the strict parser, measured on copies of all 13 other projects' blockers, changed the open set of 4 (config `— RESOLVED` title suffix, game `date: … · status:`, zenquality and angelscar356 `**Statut** :`); with the v1 branch the 13 sets are identical to today.
+6. **Heading dialects**: `mem_key` accepts `## ID` followed by any non-alphanumeric char (` — `, ` - `, ` | `), so `status` and `--supersedes` work on v1 hyphen and pipe files. The em-dash shape check is v2-only. `upgrade` refuses a non-em-dash file (`heading dialect " - ": not upgraded`) and a file without frontmatter; the banner says `memory.sh check`, never promises an upgrade.
+7. **Journal template** carries no `format: 2`: journal.md is not a registry (`check` excludes it). Contract criterion 8 says "every `templates/memory/*.md`": the four registry templates.
+8. **awk programs**: an embedded awk program counts as one statement toward the 25-logic-line limit (`_mem_upgrade_text`, `_mem_upgrade_oracle`, `_mem_index_rows` hold 20-30 awk lines). Splitting them would scatter one parser across files.
## Review Focus
-1. **Concurrent writers.** Two sessions capitalizing at once must get two IDs; a lock that is not atomic loses entries silently. Found while proving the reference: `mkdir` from uutils coreutils 0.10 (this host) is NOT atomic, two concurrent `mkdir` both succeed; the lock uses bash noclobber (`open(O_EXCL)`). T6e/T6f are the flip test (they were red with the mkdir lock).
-2. **Status words in prose.** A Solution line saying "fail-open" or "`data:` OPEN" must never reopen a resolved blocker; "accepted. Behavioral check OPEN" must read accepted. Covered by T10b/c/e and run-reconcile T8.
-3. **Index-only facts lost at upgrade.** 13 BDR statuses, 2 BDR + 2 BLK + 12 LRN supersessions and ~130 dates live only in Index rows today; a stale Index status (BDR-012 says accepted, body says shipped) must NOT overwrite the body. The upgrade oracle refuses on any loss; T9e pins the stale case.
-4. **v1 projects keep working.** 13 other repos on this machine run this lib through `~/.claude/lib`; a v1 registry is written leniently, `check` never fails on it, `--staged` ignores it, memory-commit keeps committing it. T7e/f and the memory-commit v1 test pin this.
-5. **The chokepoint must not block the upgrade commit itself.** Removing the Index (lines before the first entry) and inserting Date/Status lines are not "removed lines inside an entry". Proven on the live copy; Task 7 commits it through memory-commit.sh.
+1. **Concurrent writers.** The noclobber lock is proven by T6e/T6f (red with the mkdir lock on this host). An interrupted add restores its backup and frees the lock.
+2. **Status words in prose and titles.** "fail-open", "`data:` OPEN", a title saying "DNS resolved", "open again, not resolved by abc": T10b/c/h/i and run-reconcile T8a/b.
+3. **Index-only facts at upgrade.** 13 BDR statuses, BDR-038 + BLK-019/020 + 12 LRN supersessions, 129 dates; a stale Index (BDR-012) never overwrites the body and is named. BLK-019/020 must read closed after Task 7 (superseded).
+4. **v1 projects keep working.** 13 other repos run this lib through `~/.claude/lib`: v1 writes are lenient, `check` never fails on v1, `--staged` ignores v1, reconcile on v1 is byte-for-byte today's reader (Deviation 5), `status` works on hyphen and pipe headings (T10m-o).
+5. **The chokepoint never blocks a legitimate commit.** Only NEW culprits count (a duplicate a merge left behind blocks neither `add` nor a staged append: T7i-k); the upgrade commit passes (Index lines sit above the first entry); a refused commit leaves nothing staged.
---
-### Task 1: lib/memory.sh, its suite and the parser fixture
+### Task 1: lib/memory.sh, its suite and the parser fixtures
**Files:**
- Create: `lib/memory.sh` (copy of `docs/superpowers/plans/memory-v2-write/memory.sh`)
-- Create: `lib/tests/memory.test.sh` (copy of `docs/superpowers/plans/memory-v2-write/memory.test.sh`)
-- Create: `lib/tests/fixtures/blockers-v2-status.md` (copy of `docs/superpowers/plans/memory-v2-write/blockers-v2-status.md`)
+- Create: `lib/tests/memory.test.sh` (copy of `…/memory.test.sh`)
+- Create: `lib/tests/fixtures/blockers-v2-status.md` (copy of `…/blockers-v2-status.md`)
+- Create: `lib/tests/fixtures/blockers-v1-dialects.md` (copy of `…/blockers-v1-dialects.md`; used by Task 2)
-**Interfaces:**
-- Produces (sourceable, used by Tasks 2-7): `memory_entry_status ` (winning candidate line, rc 1 if none), `memory_status_word ` (status word or first 40 chars), `memory_check [--staged] []` (rc 2 on a culprit), `memory_add`, `memory_status`, `memory_journal`, `memory_index`, `memory_upgrade`. CLI: `bash lib/memory.sh [-C dir] add|status|journal|index|check|upgrade …`. Env: `MEMORY_DATE`, `MEM_GREP`, `MEM_LOCK_TRIES`.
+**Interfaces (produced, used by Tasks 2-7):** `memory_entry_status ` (winning candidate: `[tag]` or the labelled line; rc 1 if none), `memory_status_word ` (status word or first 40 chars), `memory_closed ` (rc 0 for resolved | superseded | deprecated), `memory_is_v2 `, `_mem_names` (the four registry basenames, from `_MEM_TABLE`), `memory_check [--staged] []`, `memory_add`, `memory_status`, `memory_journal`, `memory_index`, `memory_upgrade`. CLI: `bash lib/memory.sh [-C dir] add|status|journal|index|check|upgrade …`. Env: `MEMORY_DATE`, `MEM_GREP`, `MEM_LOCK_TRIES`.
-- [ ] **Step 1: Copy the three files**
+- [ ] **Step 1: Copy the four files**
```bash
cp docs/superpowers/plans/memory-v2-write/memory.sh lib/memory.sh
cp docs/superpowers/plans/memory-v2-write/memory.test.sh lib/tests/memory.test.sh
cp docs/superpowers/plans/memory-v2-write/blockers-v2-status.md lib/tests/fixtures/blockers-v2-status.md
+cp docs/superpowers/plans/memory-v2-write/blockers-v1-dialects.md lib/tests/fixtures/blockers-v1-dialects.md
chmod +x lib/memory.sh lib/tests/memory.test.sh
```
- [ ] **Step 2: Run the suite and the static checks**
-Run: `make test suite=lib/tests/memory.test.sh` → expected last lines `PASS=72 FAIL=0` and `all suites green`. Run it three times (the race test T6e must be stable).
+Run: `make test suite=lib/tests/memory.test.sh` three times → each ends `PASS=97 FAIL=0` and `all suites green` (T6e race must be stable).
Run: `shellcheck lib/memory.sh lib/tests/memory.test.sh && awk 'length > 80' lib/memory.sh` → no output after shellcheck.
Run: `make test suite=lib/tests/portability-census.test.sh` → green.
- [ ] **Step 3: Commit**
```bash
-git add lib/memory.sh lib/tests/memory.test.sh lib/tests/fixtures/blockers-v2-status.md
+git add lib/memory.sh lib/tests/memory.test.sh lib/tests/fixtures/blockers-v2-status.md lib/tests/fixtures/blockers-v1-dialects.md
git commit -m "feat(memory): lib/memory.sh single registry writer — add/status/journal/index/check/upgrade, shared status parser, noclobber lock"
```
---
-### Task 2: reconcile reads status through the shared parser
+### Task 2: reconcile reads v2 status through the shared parser and classifier
**Files:**
-- Modify: `lib/reconcile.sh:57-67` (`reconcile_blk_current_status`) and its header comment `:8-12`
-- Modify: `lib/tests/run-reconcile.sh` (new T8 block before the final summary line)
+- Modify: `lib/reconcile.sh` (source line after `RECONCILE_GREP=`; `reconcile_blk_current_status` and `reconcile_blk_open` with their comments)
+- Modify: `lib/tests/run-reconcile.sh` (T8 block before the final summary line)
- Modify: `skills/reconcile/SKILL.md:25`
-**Interfaces:**
-- Consumes: `memory_entry_status` from Task 1.
-- Produces: `reconcile_blk_current_status ` unchanged signature, now prints the winning candidate line (empty when none).
+**Interfaces:** consumes `memory_is_v2`, `memory_entry_status`, `memory_status_word`, `memory_closed`. `reconcile_blk_current_status` and `reconcile_blk_open` keep their signatures.
- [ ] **Step 1: Write the failing test** — insert before the `echo; echo "================ $pass GREEN` line of `lib/tests/run-reconcile.sh`:
@@ -92,70 +96,84 @@ git commit -m "feat(memory): lib/memory.sh single registry writer — add/status
echo; echo "=== T8 shared parser — header [tag] + labelled lines, prose never (BLK-032..034) ==="
v2="$FIX/blockers-v2-status.md"
open_v2=$(reconcile_blk_open "$v2" | cut -f1 | sort | tr '\n' ' ')
-if [ "$open_v2" = "BLK-041 BLK-042 " ]; then ok "T8a open = {041,042}: 032..034, 008, 040 read resolved/accepted"; else no "T8a open = [$open_v2], expected {041,042}"; fi
+if [ "$open_v2" = "BLK-040 BLK-041 BLK-042 BLK-043 BLK-044 " ]; then ok "T8a open = {040..044}: 032..034 and 008 closed, accepted stays open"; else no "T8a open = [$open_v2], expected {040,041,042,043,044}"; fi
case "$(reconcile_blk_current_status "$v2" BLK-034)" in
- *'[resolved]'*) ok "T8b BLK-034 status = its own header tag";;
+ '[resolved]') ok "T8b BLK-034 status = its own header tag, title never read";;
*) no "T8b BLK-034 read from prose (fail-open), not the header tag";;
esac
+v1d="$FIX/blockers-v1-dialects.md"
+open_v1=$(reconcile_blk_open "$v1d" | cut -f1 | tr '\n' ' ')
+if [ "$open_v1" = "BLK-002 " ]; then ok "T8c v1 hyphen and pipe headings still parsed"; else no "T8c v1 dialects open = [$open_v1], expected {002}"; fi
```
-- [ ] **Step 2: Run it, expect red**
+- [ ] **Step 2: Run, expect red** — `make test suite=lib/tests/run-reconcile.sh` → T8a and T8b red (today: 032..034 open, BLK-034 read from prose).
-Run: `make test suite=lib/tests/run-reconcile.sh` → `RED ✗ T8a open = [BLK-032 BLK-033 BLK-034 BLK-040 BLK-041 BLK-042 ]…` (exact list may differ; it must be red).
-
-- [ ] **Step 3: Delegate the parser** — in `lib/reconcile.sh`, after the `RECONCILE_GREP=` line add:
+- [ ] **Step 3: Implement** — in `lib/reconcile.sh`, right after the `RECONCILE_GREP=…` line add:
```bash
-# the status parser is shared with lib/memory.sh (BDR-125 phase 4a)
+# the status parser and classifier are shared with lib/memory.sh (BDR-125 4a)
# shellcheck source=/dev/null
. "$(dirname "${BASH_SOURCE[0]}")/memory.sh"
```
-and replace the whole `reconcile_blk_current_status` function and the two comment lines above it with:
+Replace everything from the comment `# --- registry status: LAST status-bearing line wins …` through the closing `}` of `reconcile_blk_open` by:
```bash
# --- registry status: LAST candidate wins (the BLK-008 trap A fell into) ---
-# $1 blockers file, $2 id. Echoes the winning status line: the entry's own
-# header `[tag]` or a labelled body line (lib/memory.sh); a status word in
-# prose is never read (the BLK-032..034 false-open). Empty when none.
+# $1 blockers file, $2 id. A v2 registry (lib/memory.sh): the entry's own
+# header `[tag]` or a labelled body line, never a status word in prose or in
+# the title (the BLK-032..034 false-open). A v1 registry keeps the lexical
+# reader below: its dialects (title suffix `— RESOLVED`, `date: … · status:`,
+# `**Statut** :`) carry status where the strict parser cannot see it.
reconcile_blk_current_status() {
- memory_entry_status "$1" "$2"
+ if memory_is_v2 "$1"; then memory_entry_status "$1" "$2"; return; fi
+ # v1: drop ALL `## BLK-` header lines first: the range is inclusive of the
+ # NEXT entry's header, and a sibling header may carry a status word.
+ sed -n "/^## ${2} /,/^## BLK-/p" "$1" \
+ | "$RECONCILE_GREP" -v '^## BLK-' \
+ | "$RECONCILE_GREP" -iE 'status|RESOLVED|REVERTED|upstream|resolved|[^a-z]open' \
+ | tail -1
+}
+# blockers whose CURRENT status does not close them → "idstatus".
+# v2: memory_closed (resolved | superseded | deprecated); v1: the substring.
+reconcile_blk_open() {
+ local id st v2=""
+ memory_is_v2 "$1" && v2=1
+ for id in $(reconcile_enumerate_ids "$1" BLK); do
+ st=$(reconcile_blk_current_status "$1" "$id")
+ if [ -n "$v2" ]; then
+ memory_closed "$(memory_status_word "$st")" && continue
+ else
+ case "$st" in *RESOLVED*|*resolved*) continue ;; esac
+ fi
+ printf '%s\t%s\n' "$id" "$st"
+ done
}
```
-In the header comment, insert one line right after line 12 (`# preaches — the recursive-coherence test (run-reconcile.sh T1) reds if this is broken.`):
-`# v2 registries carry no Index at all (lib/memory.sh); v1 ones still may.`
+Header comment: insert one line right after line 12 (`# preaches — the recursive-coherence test (run-reconcile.sh T1) reds if this is broken.`): `# v2 registries carry no Index at all (lib/memory.sh); v1 ones still may.`
-- [ ] **Step 4: Run, expect green**
+- [ ] **Step 4: Run, expect green** — `make test suite=lib/tests/run-reconcile.sh` → `28 GREEN / 0 RED` (T1-T7 unchanged, T8a/b/c green). `make test suite=lib/tests/run-review-guards.sh` → green (G4: T8 reads fixtures only).
-Run: `make test suite=lib/tests/run-reconcile.sh` → `T8a`, `T8b` green, T1-T7 still green, `0 RED`.
-Run: `make test suite=lib/tests/run-review-guards.sh` → green (G4: run-reconcile must not read `.claude/memory`; T8 reads the fixture).
-
-- [ ] **Step 5: Skill line** — `skills/reconcile/SKILL.md:25`, replace
-`` (`reconcile_oracle_*`, `reconcile_blk_current_status` = last block wins) `` by
-`` (`reconcile_oracle_*`, `reconcile_blk_current_status` = last candidate wins: header `[tag]` or a labelled status line, via `lib/memory.sh`) ``
+- [ ] **Step 5: Skill line** — `skills/reconcile/SKILL.md:25`: replace `` (`reconcile_oracle_*`, `reconcile_blk_current_status` = last block wins) `` by `` (`reconcile_oracle_*`, `reconcile_blk_current_status` = last candidate wins: header `[tag]` or a labelled status line on a v2 registry via `lib/memory.sh`, today's lexical reader on v1) ``.
- [ ] **Step 6: Commit**
```bash
git add lib/reconcile.sh lib/tests/run-reconcile.sh skills/reconcile/SKILL.md
-git commit -m "fix(reconcile): blocker status through the shared memory.sh parser — BLK-032..034 no longer false-open"
+git commit -m "fix(reconcile): v2 blocker status through the shared memory.sh parser and classifier — BLK-032..034 no longer false-open; v1 reader unchanged"
```
---
-### Task 3: memory-commit.sh refuses a staged in-place edit (rc 6)
+### Task 3: memory-commit.sh refuses a staged in-place edit or new culprit (rc 6)
**Files:**
-- Modify: `lib/memory-commit.sh` (header usage comment, `commit_memory` between `git add` and `git diff --cached --quiet`)
-- Modify: `lib/tests/run-deterministic.sh` (two new tests before the summary)
+- Modify: `lib/memory-commit.sh` (usage comment, `MC_MEMORY_SH`, `commit_memory` right after `git add`)
+- Modify: `lib/tests/run-deterministic.sh` (block before the final `echo` + `printf 'RESULT: …'`)
- Modify: `lib/capitalize-commit.md` (rc table)
-**Interfaces:**
-- Consumes: `bash lib/memory.sh check --staged .claude/memory`.
-- Produces: `memory-commit.sh commit` rc 6 = check refused, nothing committed.
-
-- [ ] **Step 1: Write the failing tests** — read `lib/tests/run-deterministic.sh` first (helpers `new_repo`, `ok`, `ko`, `HELPER`); append before its final summary block:
+- [ ] **Step 1: Write the failing tests** — insert right before the final `echo` / `printf 'RESULT: %d passed, %d failed\n' "$PASS" "$FAIL"` lines of `lib/tests/run-deterministic.sh`:
```bash
echo "== check --staged chokepoint (v2 registry, phase 4a)"
@@ -164,66 +182,62 @@ printf -- '---\nformat: 2\ntype: decisions_registry\nentry_prefix: BDR\n---\n\n#
> "$d/.claude/memory/decisions.md"
git -C "$d" add -A && git -C "$d" commit -qm v2
head_before=$(git -C "$d" rev-parse HEAD)
-printf -- '---\nformat: 2\ntype: decisions_registry\nentry_prefix: BDR\n---\n\n## BDR-001 — rewritten (2026-10-27)\n- **Status**: accepted\n' \
- > "$d/.claude/memory/decisions.md"
+sed 's/kept/rewritten/' "$d/.claude/memory/decisions.md" > "$d/x.tmp" \
+ && cat "$d/x.tmp" > "$d/.claude/memory/decisions.md"
out="$(cd "$d" && bash "$HELPER" commit "chore(memory): bad" 2>/dev/null)"; rc=$?
-if [ "$rc" -eq 6 ] && [ -z "$out" ] && [ "$(git -C "$d" rev-parse HEAD)" = "$head_before" ]; then ok "in-place edit of a v2 entry → rc 6, nothing committed"; else ko "rc=$rc out=[$out] — in-place edit was committed or wrong rc"; fi
+staged="$(git -C "$d" diff --cached --name-only)"
+if [ "$rc" -eq 6 ] && [ -z "$out" ] && [ -z "$staged" ] && [ "$(git -C "$d" rev-parse HEAD)" = "$head_before" ]; then ok "in-place edit of a v2 entry → rc 6, nothing committed, nothing staged"; else ko "rc=$rc out=[$out] staged=[$staged] — in-place edit committed or left staged"; fi
git -C "$d" checkout -q HEAD -- .claude/memory/decisions.md
printf '\n## BDR-002 — added (2026-10-27)\nbody\n' >> "$d/.claude/memory/decisions.md"
out="$(cd "$d" && bash "$HELPER" commit "chore(memory): BDR-002" 2>/dev/null)"; rc=$?
if [ "$rc" -eq 0 ] && [ -n "$out" ]; then ok "append to a v2 registry → committed"; else ko "append refused rc=$rc"; fi
```
-(The existing tests write `baseline` registries with no frontmatter: v1, `check` skips them, they must stay green unchanged.)
+(Existing tests write `baseline` registries with no frontmatter: v1, skipped by the check, unchanged and green.)
-- [ ] **Step 2: Run, expect red**
-
-Run: `make test suite=lib/tests/run-deterministic.sh` → the rc 6 test fails (today rc 0, the edit is committed).
+- [ ] **Step 2: Run, expect red** — `make test suite=lib/tests/run-deterministic.sh` → the rc 6 test fails (today rc 0, the edit is committed).
- [ ] **Step 3: Implement** — in `lib/memory-commit.sh`:
- - under `MC_PATHS=(...)` add:
-
-```bash
-MC_MEMORY_SH="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)/memory.sh"
-```
-
+ - after `MC_PATHS=(".claude/memory" ".claude/tasks")` add `MC_MEMORY_SH="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)/memory.sh"`;
- in `commit_memory`, right after `git add -- "${changed[@]}"`, insert:
```bash
- # Chokepoint (BDR-125 phase 4a): a staged v2 registry may only grow. An
- # in-place rewrite of an existing entry is curation: /prune-memory, then
- # /commit-change. v1 registries are skipped by the check.
+ # Chokepoint (BDR-125 phase 4a): a staged v2 registry may only grow and
+ # never gains a new culprit (duplicate ID, bad heading, open fence). v1
+ # registries are skipped. Unstage on refusal so no later plain commit
+ # sweeps the refused change in.
if [ -d .claude/memory ] \
&& ! bash "$MC_MEMORY_SH" check --staged .claude/memory; then
+ git reset -q -- "${changed[@]}"
echo "memory-commit: REFUSED — memory.sh check --staged failed (above);" \
- "NOTHING committed, the scoped paths stay staged." >&2
+ "NOTHING committed, nothing left staged." >&2
return 6
fi
```
- - header usage line becomes `# memory-commit.sh commit "" # surgical commit; exit 0 ok/no-op, 3 unsafe state, 5 commit rejected, 6 check --staged refused`
+ - usage comment line becomes two lines: `# memory-commit.sh commit "" # surgical commit; exit 0 ok/no-op, 3 unsafe` / `# # state, 5 commit rejected, 6 check refused`.
-- [ ] **Step 4: Run, expect green**
+- [ ] **Step 4: Run, expect green** — `make test suite=lib/tests/run-deterministic.sh` → `RESULT: 18 passed, 0 failed`.
-Run: `make test suite=lib/tests/run-deterministic.sh` → all green including the two new ones.
-
-- [ ] **Step 5: Document rc 5 and rc 6** — in `lib/capitalize-commit.md` step 3 "Report by (rc, mem_hash)", after the `rc 3` bullet add:
+- [ ] **Step 5: Document rc 5 and rc 6** — `lib/capitalize-commit.md` step 3 "Report by (rc, mem_hash)", after the `rc 3` bullet:
```
- rc 5 → `git commit` rejected (hook, protected branch,
signing); nothing committed, surface stderr.
- - rc 6 → `memory.sh check --staged` refused: a staged
- v2 registry rewrites an existing entry line
- (only appends pass). Curation goes through
- /prune-memory then /commit-change; surface
- the culprit lines, never bypass the helper.
+ - rc 6 → `memory.sh check --staged` refused, nothing
+ committed, nothing left staged. Two causes,
+ named on stderr: a line removed inside an
+ existing v2 entry (only appends pass), or a NEW
+ culprit (duplicate ID, heading shape, open
+ fence). Fix the file, then commit the fix with
+ /commit-change; never bypass the helper.
```
- [ ] **Step 6: Commit**
```bash
git add lib/memory-commit.sh lib/tests/run-deterministic.sh lib/capitalize-commit.md
-git commit -m "feat(memory): memory-commit refuses a staged in-place edit of a v2 registry (rc 6); rc 5/6 documented"
+git commit -m "feat(memory): memory-commit refuses a staged in-place edit or new culprit in a v2 registry (rc 6, unstaged); rc 5/6 documented"
```
---
@@ -231,10 +245,10 @@ git commit -m "feat(memory): memory-commit refuses a staged in-place edit of a v
### Task 4: v2 templates and the registry v1 banner line
**Files:**
-- Modify: `templates/memory/{decisions,learnings,blockers,evals}.md`
-- Modify: `hooks/session-start.sh` (after the CLAUDE.global.md line-count guard, before `# Version check`)
+- Modify: `templates/memory/{decisions,learnings,blockers,evals}.md` (journal.md unchanged, Deviation 7)
+- Modify: `hooks/session-start.sh` (before `# Version check: compare local vs remote (non-blocking)`)
- Modify: `lib/tests/memory.test.sh` (T13, before the final `echo "PASS=…"`)
-- Modify: `agents/onboarder.md:126` (template description)
+- Modify: `agents/onboarder.md:126`
- [ ] **Step 1: Write the failing test** — insert before `echo "PASS=$pass FAIL=$fail"` in `lib/tests/memory.test.sh`:
@@ -246,20 +260,15 @@ for t in decisions learnings blockers evals; do
done
banner() { (cd "$1" && SESSION_START_OFFLINE=1 bash "$ROOT/hooks/session-start.sh" \
/dev/null); }
-check T13c-banner-v1 "$(banner "$FIX/v1-proj" | grep -c 'registry v1: 1 file')" 1
+check T13c-banner-v1 "$(banner "$FIX/v1h" | grep -c 'registry v1: 1 file(s) (memory.sh check)')" 1
check T13d-banner-v2 "$(banner "$FIX" | grep -c 'registry v1')" 0
```
-and, just above it, the v1 fixture project:
+(`$FIX/v1h` is the v1 pipe/hyphen project T10 built; `$FIX/.claude/memory` is v2. The hook resolves `memory.sh` next to itself, so the test exercises `$ROOT/lib/memory.sh`, never the installed copy.)
-```bash
-mkdir -p "$FIX/v1-proj/.claude/memory"
-printf '# Decisions\n\n## BDR-001 - legacy\n' > "$FIX/v1-proj/.claude/memory/decisions.md"
-```
+- [ ] **Step 2: Run, expect red** — `make test suite=lib/tests/memory.test.sh` → the ten T13 checks fail.
-- [ ] **Step 2: Run, expect red** — `make test suite=lib/tests/memory.test.sh` → T13 checks fail.
-
-- [ ] **Step 3: Templates** — in each of the four templates: insert `format: 2` as line 2 (right after the opening `---`); delete the `## Index` heading, the blank line after it, the two table lines and the blank line after them; replace the `` comment by this shape (per file, adapt the kind, title word and body labels already in that template; the heading line is indented two spaces so no line starts with `## `):
+- [ ] **Step 3: Templates** — in each of the four registry templates: insert `format: 2` as line 2 (right after the opening `---`); delete `## Index`, the blank line after it, the two table lines and the blank line after them; replace the `` comment by (shown for blockers; the heading line is indented two spaces so no line starts with `## `):
```
```
-Kinds and labels: decisions → `decision`, ``, `[accepted]`, labels Decision / Why / Rejected alternatives / Reference; learnings → `learning`, ``, no status, labels Pattern / Context / Future application; evals → `eval`, `