From 2dae5282f6c39da2467f61bf4d6bb4ee386c8a9f Mon Sep 17 00:00:00 2001 From: bchanot Date: Fri, 30 Oct 2026 20:23:40 +0100 Subject: [PATCH 1/5] fix(memory): upgrade refuses a prose or mixed v1 closure instead of writing resolved The repair copied the v1 reader's lexical verdict, read the verdict diff while rewriting the file, and listed same-ID sub-headings twice. It now writes only a single closed word from a Status label, names and refuses the rest, and asserts one upgrade line per entry. --- lib/memory.sh | 99 ++++++++++++++++++++++++++++++++-------- lib/tests/memory.test.sh | 64 ++++++++++++++++++++++++++ 2 files changed, 144 insertions(+), 19 deletions(-) diff --git a/lib/memory.sh b/lib/memory.sh index d0024c2..ad7014c 100755 --- a/lib/memory.sh +++ b/lib/memory.sh @@ -18,9 +18,12 @@ # body lines, `format: 2`, `## Index` removed; a missing # frontmatter comes from the template, ` - ` / ` | date | ` # / `###` headings take the `## ID — title (date)` shape; -# a blocker whose open / closed verdict (reconcile's v1 -# reader) would move gets a `Status (…, upgrade)` line; the -# oracle (IDs, check, verdicts) runs first, else rc 2 +# a blocker the v1 reader closed but the strict one reads +# open gets a `Status (…, upgrade)` line only when its v1 +# line is a Status/Statut label holding one closed word; +# a prose or mixed closure is named and refused (record +# it with `status`, re-run); the oracle (IDs, check, +# verdicts, one upgrade line per entry) runs first, else rc 2 # = decision | learning | blocker | eval. MEMORY_DATE overrides today. # Status of an entry: the last candidate wins. A candidate is the heading's # trailing `[tag]`, or a body line whose bold label names Status, Resolution, @@ -593,7 +596,8 @@ memory_legacy_status() { # [] → the v1 lexical status line # (reconcile reads it on a v1 blockers file; `upgrade` proves its verdicts # against it). Default range: `## ID` to the next `## BLK-`, reconcile's # own. With (ERE) the range is fence-aware: it stops at the next - # heading matching outside a ``` fence, and that header is not read. + # heading matching outside a ``` fence, and that header is not read; + # a same-ID sub-heading (`### ID UPDATE`) continues the range, unread. local end="${3:-}" if [ -z "$end" ]; then sed -n "/^## ${2} /,/^## BLK-/p" "$1" \ @@ -604,6 +608,7 @@ memory_legacy_status() { # [] → the v1 lexical status line fi RE="$_MEM_LEGACY_RE" END_RE="$end" awk -v id="$2" ' /^```/ { fence = !fence; next } + !fence && $0 ~ ("^#+ *" id "( |$)") && on { next } !fence && $0 ~ ENVIRON["END_RE"] { on = 0 } !fence && $0 ~ "^## " id " " { on = 1; next } on && !fence && tolower($0) ~ tolower(ENVIRON["RE"]) { last = $0 } @@ -627,34 +632,78 @@ _mem_index_stated() { # → IDs whose Index status upgrade <(_mem_index_table "$1") <(_mem_index_rows "$1" "$2") } +_mem_explicit_status() { # → rc 0 when the v1 line is a + local v1 win # dated status line written by `memory.sh status`, which + v1=$(memory_legacy_status "$1" "$3" '^##* *BLK-[0-9]') # the strict + win=$(memory_entry_status "$2" "$3") # reader rightly wins + [ "$v1" = "$win" ] || return 1 + printf '%s\n' "$v1" | "$MEM_GREP" -qE '^- \*\*Status \([0-9]' || return 1 + case "$v1" in *", upgrade)"*) return 1 ;; esac +} + _mem_verdict_diff() { # → "IDword" per blocker whose open / - local id was now ix # closed verdict moved (word = the old verdict) - ix=$(_mem_index_stated "$1" BLK) - for id in $(_mem_heading_ids "$2" BLK); do + local id was now ix # closed verdict moved (word = the old verdict, or + ix=$(_mem_index_stated "$1" BLK) # `explicit`: a dated status line) + for id in $(_mem_heading_ids "$2" BLK | awk '!seen[$0]++'); do printf '%s\n' "$ix" | "$MEM_GREP" -qx "$id" && continue # the v1 reader enumerates `## ID` headings only: no verdict to keep "$MEM_GREP" -qE "^## $id( |$)" "$1" || continue _mem_legacy_open "$1" "$id" && was=open || was=resolved memory_closed "$(memory_status_word "$(memory_entry_status "$2" "$id")")" \ && now=resolved || now=open - [ "$was" = "$now" ] || printf '%s\t%s\n' "$id" "$was" + [ "$was" = "$now" ] && continue + [ "$was" = resolved ] && _mem_explicit_status "$1" "$2" "$id" \ + && was=explicit + printf '%s\t%s\n' "$id" "$was" done } +_mem_v1_word() { # → the one status word of its status/statut + # label (e.g. `status: resolved`), nothing for prose or a mixed label + L="$1" MEMW="$_MEM_WORDS" awk 'BEGIN { + s = tolower(ENVIRON["L"]); n = split(ENVIRON["MEMW"], w, " ") + if (!match(s, /(status|statut)[^a-z:]*:[* ]*/)) exit + s = substr(s, RSTART + RLENGTH) + for (i = 1; i <= n; i++) + if (s ~ ("(^|[^a-z])" w[i] "([^a-z]|$)")) { c++; word = w[i] } + if (c == 1) print word }' +} + +_mem_repair_one() { # → write the v1 closure when its line + local v1 word # names one closed word, else name the ID and refuse + v1=$(memory_legacy_status "$1" "$3" '^##* *BLK-[0-9]') + word=$(_mem_v1_word "$v1") + if ! memory_closed "$word"; then + echo "memory: $3: v1 closed by an unlabelled or mixed line, status" \ + "unknown: ${v1:0:100}" >&2 + echo "memory: $3: record it from the project root: memory.sh status" \ + "$3 \", …\" (the leading word decides), then re-run upgrade" >&2 + return 0 + fi + echo "memory: $3: wrote upgrade status $word from v1 line: ${v1:0:100}" >&2 + _mem_insert "$2" "$3" "- **Status ($(_mem_date), upgrade)**: $word" \ + || return 2 +} + _mem_upgrade_repair() { # → no blocker loses its closure - # v1 closed, strict reader open (a dialect it cannot read): a status line - # restores it. v1 open, strict closed is the BLK-032..034 fix (prose words - # read as status by the v1 reader): kept, named - local id word + # v1 closed, strict reader open (a dialect it cannot read): a labelled v1 + # line restores it, prose or a mixed label is named and left to the oracle. + # v1 open, strict closed is the BLK-032..034 fix (prose words read as + # status by the v1 reader): kept, named. The diff is read in full before + # the first insert rewrites the file under it + local id word rows [ "$3" = BLK ] || return 0 + rows=$(_mem_verdict_diff "$1" "$2") + [ -n "$rows" ] || return 0 while IFS=$'\t' read -r id word; do - if [ "$word" = open ]; then - echo "memory: $id: v1 reader open, strict reader closed (kept)" >&2 - continue - fi - _mem_insert "$2" "$id" "- **Status ($(_mem_date), upgrade)**: $word" \ - || return 2 - done < <(_mem_verdict_diff "$1" "$2") + case "$word" in + open) echo "memory: $id: v1 reader open, strict reader closed (kept)" \ + >&2 ;; + explicit) echo "memory: $id: dated status line kept, v1 reader closed" \ + "by prose" >&2 ;; + *) _mem_repair_one "$1" "$2" "$id" || return 2 ;; + esac + done <<< "$rows" } _mem_upgrade_oracle() { # → rc 2 on a lost fact @@ -681,6 +730,18 @@ _mem_upgrade_oracle() { # → rc 2 on a lost fact o=$(_mem_verdict_diff "$1" "$2" | awk -F'\t' '$2 == "resolved" \ { printf "%s ", $1 }') [ -z "$o" ] || { echo "memory: upgrade moved a verdict: $o" >&2; return 2; } + _mem_upgrade_dups "$2" "$3" +} + +_mem_upgrade_dups() { # → rc 2 when an entry holds two + local d # `, upgrade)` status lines + d=$(awk -v p="$2" ' + /^```/ { fence = !fence } + fence { next } + $0 ~ "^## " p "-[0-9]+" { id = $2; next } + /^- \*\*Status \([^)]*, upgrade\)\*\*:/ && ++n[id] == 2 { + printf "%s:dup ", id }' "$1") + [ -z "$d" ] || { echo "memory: upgrade lost: $d" >&2; return 2; } } _mem_upgrade_front() { # → the file; one lacking a frontmatter gets diff --git a/lib/tests/memory.test.sh b/lib/tests/memory.test.sh index 08b62af..d5b9d92 100755 --- a/lib/tests/memory.test.sh +++ b/lib/tests/memory.test.sh @@ -467,6 +467,7 @@ v1blk d15/datestatus '## BLK-001 — one line' \ '## BLK-002 — one line open' 'date: 2026-06-02 · status: open' dialect datestatus '^- \*\*Status ([0-9-]*, upgrade)\*\*: resolved$' check T15-datestatus-one-line "$(grep -c 'upgrade)' d15/datestatus/blockers.md)" 1 +check T15-datestatus-word "$(memory_word_of d15/datestatus/blockers.md BLK-001)" resolved v1blk d15/statut '## BLK-001 — fr' '- **Statut** : resolved' '' \ '## BLK-002 — fr open' '- **Statut** : open' dialect statut '^- \*\*Status ([0-9-]*, upgrade)\*\*: resolved$' @@ -502,6 +503,69 @@ check T15-tamper-rc "$?" 2 check T15-tamper-culprit "$(printf '%s\n' "$err" | grep -c 'moved a verdict: BLK-001')" 1 check T15-tamper-untouched "$(cksum < d15/tamper/blockers.md)" "$sum" +# v1 closed by prose or a mixed label: refused and named, never guessed +refused() { # → rc 2, file untouched, ID and remedy on stderr + local f="d15/$1/blockers.md" before err rc + before=$(cksum < "$f") + err=$(bash "$MEM" upgrade "d15/$1" 2>&1 >/dev/null); rc=$? + check "$3-rc" "$rc" 2 + check "$3-untouched" "$(cksum < "$f")" "$before" + check "$3-named" "$(printf '%s\n' "$err" | grep -c "memory: $2: v1 closed")" 1 + check "$3-remedy" "$(printf '%s\n' "$err" | grep -c "memory.sh status $2 ")" 1; } +v1blk d15/prose '## BLK-001 — x' 'date: 2026-09-20 · status: open' \ + 'prose: another tab already resolved it' +refused prose BLK-001 T15-prose-refused +v1blk d15/mixdate '## BLK-001 — x' \ + 'date: 2026-10-17 | status: code resolved (abc) · SMTP open' +refused mixdate BLK-001 T15-mixed-date-refused +v1blk d15/mixstatut '## BLK-001 — x' '- **Statut** : resolved (x), open (y)' +refused mixstatut BLK-001 T15-mixed-statut-refused +# boundary: a strict candidate both readers close is no repair +v1blk d15/mixbound '## BLK-001 — x' 'status: code resolved (abc) · SMTP open' +bash "$MEM" upgrade d15/mixbound >/dev/null 2>&1 +check T15-mixed-strict-boundary "$?/$(grep -c 'upgrade)' d15/mixbound/blockers.md)" 0/0 +# a same-ID sub-heading neither doubles the repair nor hides a reopening +v1blk d15/sub '## BLK-008 — x' 'date: 2026-07-20 · status: RESOLVED 2026-07-20' \ + '### BLK-008 UPDATE 2026-07-20 (y)' 'body' +bash "$MEM" upgrade d15/sub >/dev/null 2>&1 +check T15-subhead-one-repair "$?/$(grep -c 'upgrade)' d15/sub/blockers.md)" 0/1 +v1blk d15/subre '## BLK-008 — x' 'date: 2026-07-20 · status: RESOLVED' \ + '### BLK-008 UPDATE 2026-07-20 (y)' 'Status: open, reopened' +bash "$MEM" upgrade d15/subre >/dev/null 2>&1 +check T15-subhead-reopened "$?/$(grep -c 'upgrade)' d15/subre/blockers.md)/$(memory_word_of d15/subre/blockers.md BLK-008)" 0/0/open +# the remedy converges, a "resolved" in its own text included +remedy() { # → the project d15/ with a v1 blockers file + mkdir -p "d15/$1/.claude/memory"; local n="$1"; shift + v1blk "d15/$n/.claude/memory" "$@"; } +remedy e '## BLK-001 — x' 'date: 2026-09-20 · status: open' \ + 'prose: another tab already resolved it' +bash "$MEM" -C d15/e status BLK-001 'upstream, SMTP OVH; code resolved (x)' >/dev/null 2>&1 +E=d15/e/.claude/memory/blockers.md +bash "$MEM" -C d15/e upgrade >/dev/null 2>&1 +check T15-remedy-roundtrip "$?/$(grep -c 'upgrade)' $E)/$(memory_word_of $E BLK-001)" 0/0/upstream +remedy e2 '## BLK-001 — x' 'date: 2026-09-20 · status: open' \ + '### BLK-001 UPDATE 2026-10-01 (y)' 'prose: another tab already resolved it' +bash "$MEM" -C d15/e2 status BLK-001 'upstream, SMTP OVH; code resolved (x)' >/dev/null 2>&1 +E=d15/e2/.claude/memory/blockers.md +bash "$MEM" -C d15/e2 upgrade >/dev/null 2>&1 +check T15-remedy-subhead "$?/$(grep -c 'upgrade)' $E)/$(memory_word_of $E BLK-001)" 0/0/upstream +# a dated line then a later prose closure: the v1 line is the prose, refused +v1blk d15/dated '## BLK-001 — x' 'date: x · status: open' \ + '- **Status (2026-10-30)**: open, waiting' 'later prose: fixed, resolved in abc' +refused dated BLK-001 T15-dated-then-prose-refused +# the v1 range continues past a same-ID sub-heading (fails if it stops there) +v1blk d15/range '## BLK-001 — x' 'prose: fixed, resolved in abc' \ + '### BLK-001 UPDATE 2026-10-01 (y)' 'Status: open, reopened' +bash "$MEM" upgrade d15/range >/dev/null 2>&1 +check T15-range-continues "$?/$(grep -c 'upgrade)' d15/range/blockers.md)" 0/0 +# the oracle refuses two upgrade lines under one entry +v1blk d15/dup '## BLK-001 | 2026-05-18 | dup' 'date: 2026-06-02 · status: RESOLVED' +err=$(bash -c '. "$1"; _mem_upgrade_repair() { local l + l="- **Status (2026-10-30, upgrade)**: resolved" + _mem_insert "$2" BLK-001 "$l"; _mem_insert "$2" BLK-001 "$l"; } + memory_upgrade "$2"' _ "$MEM" d15/dup 2>&1 >/dev/null) +check T15-oracle-dup-refused "$?/$(printf '%s\n' "$err" | grep -c 'BLK-001:dup')" 2/1 + # T16 final-review fixes # lock dir not writable: bounded, named, rc 2 (never a spin) chmod a-w .git From cc9b8682040cc2d3ed1d96735b080975751e6e24 Mon Sep 17 00:00:00 2001 From: bchanot Date: Fri, 30 Oct 2026 20:23:41 +0100 Subject: [PATCH 2/5] chore(contract): memory-upgrade-prose-closure plan r3 + contract (BLK-038) --- ...10-30-memory-upgrade-prose-closure-0105.md | 33 ++++ ...10-30-memory-upgrade-prose-closure-0040.md | 155 ++++++++++++++++++ 2 files changed, 188 insertions(+) create mode 100644 .claude/tasks/contracts/2026-10-30-memory-upgrade-prose-closure-0105.md create mode 100644 .claude/tasks/plans/2026-10-30-memory-upgrade-prose-closure-0040.md diff --git a/.claude/tasks/contracts/2026-10-30-memory-upgrade-prose-closure-0105.md b/.claude/tasks/contracts/2026-10-30-memory-upgrade-prose-closure-0105.md new file mode 100644 index 0000000..3da4c67 --- /dev/null +++ b/.claude/tasks/contracts/2026-10-30-memory-upgrade-prose-closure-0105.md @@ -0,0 +1,33 @@ +# CONTRACT — memory-upgrade-prose-closure + +## REQUEST (verbatim — IMMUTABLE) +lib/memory.sh upgrade: _mem_upgrade_repair cements a v1 legacy-reader false-closed verdict as an explicit `- **Status (date, upgrade)**: resolved` line. Repro: orbistep (/home/bchanot/Documents/game) blockers.md BLK-021 (`date: 2026-09-20 · status: open …`, prose "another tab already resolved it" matched the case-insensitive legacy regex) and BLK-026 (`status: open (user: activate the Plus subscription)`) both get `resolved`; BLK-030 (`status: code resolved (df5818c) · SMTP open (upstream OVH)`) gets `resolved`; zenquality BLK-006 (`**Statut** : resolved (blockage), open (root delivery cause …)`) gets `resolved`. Second defect: the repair line is written twice when a `### BLK-008 UPDATE …` sub-heading repeats the ID (game BLK-008, blockers.md lines 102-103 after upgrade). The upgrade oracle cannot see it because the v1 reader already read these as closed, so the open set is "unchanged". After the fix: reset game and zenquality .claude/memory to HEAD on their chore/memory-v2 branches (user approved), re-apply game's 16-line heading fix, re-run upgrade, and verify. Also user-approved: record an open BLK in claude-config's blockers.md for this bug. + +## CLARIFICATIONS +- 2026-10-30 user: an ambiguous v1 closure (prose or mixed label) → upgrade refuses the file (rc 2) and names the ID, never guesses a status ("Refuser et nommer"). +- Plan r3: `.claude/tasks/plans/2026-10-30-memory-upgrade-prose-closure-0040.md` (fix plan steps 1-6 + R3 ADDENDUM race). The executor implements steps 1-5 + the race fix; step 6 is the oracle of criterion 4. The follow-up (resetting game/zenquality, statuses) is NOT in this diff. +- Diagnosis: BLK-038 (this repo's blockers.md). + +## ACCEPTANCE CRITERIA +1. The memory suite is green with every new T15 fixture of plan step 5 (a, b, b2, b3, c, d, d2, e, e2, e3, e4, g), each check named with the prefix listed here: T15-prose-refused, T15-mixed-date-refused, T15-mixed-statut-refused, T15-mixed-strict-boundary, T15-datestatus-word, T15-subhead-one-repair, T15-subhead-reopened, T15-remedy-roundtrip, T15-remedy-subhead, T15-dated-then-prose-refused, T15-range-continues, T15-oracle-dup-refused. + CHECK: cd /home/bchanot/Documents/claude && out=$(make test suite=lib/tests/memory.test.sh 2>&1) && printf '%s\n' "$out" | grep -q 'FAIL=0' && for n in T15-prose-refused T15-mixed-date-refused T15-mixed-statut-refused T15-mixed-strict-boundary T15-datestatus-word T15-subhead-one-repair T15-subhead-reopened T15-remedy-roundtrip T15-remedy-subhead T15-dated-then-prose-refused T15-range-continues T15-oracle-dup-refused; do grep -q "$n" lib/tests/memory.test.sh || exit 1; done && echo MEMORY-SUITE-OK + EXPECT: MEMORY-SUITE-OK + EVIDENCE: MET exit=0 marker-found :: MEMORY-SUITE-OK +2. The reconcile suite stays green and lib/reconcile.sh is unchanged (reconcile's default 2-arg v1 reader is out of scope). + CHECK: cd /home/bchanot/Documents/claude && git diff --quiet develop -- lib/reconcile.sh && out=$(make test suite=lib/tests/run-reconcile.sh 2>&1) && printf '%s\n' "$out" | grep -q ' 0 RED' && echo RECONCILE-OK + EXPECT: RECONCILE-OK + EVIDENCE: MET exit=0 marker-found :: RECONCILE-OK +3. lib/memory.sh is shellcheck-clean and no added line exceeds 80 columns. + CHECK: cd /home/bchanot/Documents/claude && shellcheck lib/memory.sh && [ "$(git diff develop -- lib/memory.sh | grep '^+' | grep -v '^+++' | awk 'length($0) > 81' | wc -l)" = 0 ] && echo LINT-OK + EXPECT: LINT-OK + EVIDENCE: MET exit=0 marker-found :: LINT-OK +4. Real data (plan step 6): replaying the upgrade with the working-tree lib on the 13 repos' pre-upgrade registries refuses exactly orbistep blockers.md (BLK-021, BLK-026, BLK-030 named) and zenquality blockers.md (BLK-006 named), leaves both files byte-identical, and reproduces every other registry byte-for-byte; no entry carries two upgrade lines. Positive control done 2026-10-30 on the unfixed lib: rc 1 (config BLK-003 race line, game/zenquality not refused, BLK-008 duplicate). + CHECK: bash /tmp/claude-1000/-home-bchanot-Documents-claude/a1113f35-c77c-47c4-95de-a37231ae0306/scratchpad/up4a/realdata.sh /home/bchanot/Documents/claude + EXPECT: REALDATA-OK + EVIDENCE: MET exit=0 marker-found :: work dir: /tmp/claude-1000/-home-bchanot-Documents-claude/a1113f35-c77c-47c4-95de-a37231ae0306/scratchpad/up4a/realdata.5uaw REALDATA-OK +5. The repair names on stderr every ID it writes (with its v1 line) and every ID it refuses (with its v1 line and the `memory.sh status …` remedy); `explicit` rows are named once and never refuse. Judged by the verifier from the code and fixture stderr assertions. +6. The v1-open / strict-closed direction (BLK-032..034 fix, BDR-129) is unchanged: such rows are still kept and named, never repaired. Judged by the verifier (existing tests stay green). + +## FILE SCOPE +- lib/memory.sh (memory_legacy_status `` branch, _mem_verdict_diff, _mem_upgrade_repair, _mem_upgrade_oracle; the header comment if the upgrade contract text changes) +- lib/tests/memory.test.sh (T15 additions) diff --git a/.claude/tasks/plans/2026-10-30-memory-upgrade-prose-closure-0040.md b/.claude/tasks/plans/2026-10-30-memory-upgrade-prose-closure-0040.md new file mode 100644 index 0000000..edae9e4 --- /dev/null +++ b/.claude/tasks/plans/2026-10-30-memory-upgrade-prose-closure-0040.md @@ -0,0 +1,155 @@ +# /bugfix memory-upgrade-prose-closure — DIAGNOSIS + FIX PLAN r2 (BLK-038) + +r2 2026-10-30 after 3 lenses: robustness FATAL(4), correctness FATAL(2), +simplicity CONCERNS(1). Changes vs r1 named in § R2 CHANGES. + +## Bug +`bash lib/memory.sh upgrade` (v1 → v2) writes `- **Status (, upgrade)**: resolved` +under blockers that are open, and writes it twice when a sub-heading repeats the ID. +Seen 2026-10-30 on orbistep (`/home/bchanot/Documents/game`, HEAD of chore/memory-v2): +BLK-021 (`date: 2026-09-20 · status: open …`, "Fix direction (not decided)"), +BLK-030 (`date: 2026-10-17 | status: code resolved (df5818c) · SMTP open (upstream +OVH)`) get `resolved`; BLK-008 gets it twice (its body holds `### BLK-008 UPDATE …`). +zenquality BLK-006 (`- **Statut** : resolved (blockage), open (root delivery cause …)`) +gets `resolved`. The oracle reported the open set unchanged: both its readers agreed. + +## Root cause +- `_mem_upgrade_repair` (lib/memory.sh ~644) writes the v1 verdict for every blocker + `_mem_verdict_diff` reports "v1 closed, strict open". The v1 verdict comes from + `memory_legacy_status` (~592): LAST entry line matching `_MEM_LEGACY_RE`, then + `_mem_legacy_open` says closed when it contains `resolved`/`RESOLVED`. Prose and + mixed lines qualify. A lexical guess becomes an explicit status line. +- `_mem_verdict_diff` (~630) iterates `_mem_heading_ids "$2" BLK` (any heading level): + `### BLK-008 UPDATE` yields BLK-008 twice → two inserts. +- Upgrade's v1 range (`_mem_legacy_open`, end `'^##* *BLK-[0-9]'`) stops at a + same-ID `### BLK-x …` sub-heading, while reconcile's v1 reader and the strict reader + continue: a later `Status: open, reopened` under the sub-heading is unseen by upgrade. + +## Evidence +Scratchpad classify over the 13 repos' pre-upgrade blockers: prose or mixed v1 +closures exist (orbistep BLK-021 really open, BLK-026 prose addendum really resolved, +BLK-030 mixed, zenquality BLK-006 mixed). BLK-021 and BLK-026 share a shape with +opposite truth: no lexical rule decides prose. User decision 2026-10-30: refuse and +name, never guess. + +## Fix plan (r2) +1. `memory_legacy_status` with `` (upgrade-only branch; reconcile's default + 2-arg branch untouched): a heading matching `` whose ID equals the entry's ID + does NOT end the range (same-ID `###` sub-heading = continuation). Pass the ID to + awk through ENVIRON or the existing `-v id` (an ID, not free text). +2. `_mem_verdict_diff`: (a) iterate unique IDs, first-occurrence order; (b) an ID + whose v1 line from OLD (`memory_legacy_status "$1" "$id" '^##* *BLK-[0-9]'`, step-1 + range) is BYTE-EQUAL to the strict winning candidate in NEW, and that line matches + `^- \*\*Status \([0-9]` and does not contain `, upgrade)`, is an explicit status + written by `memory.sh status`: emit row `IDexplicit` (strict wins). The repair + names `explicit` rows once on stderr and writes nothing; the oracle's filter stays + `$2 == "resolved"`, so `explicit` never refuses. A dated line followed by a later + prose closure is NOT byte-equal to the v1 line → normal path → refused (never a + guess). Index-derived `, upgrade)` lines are already excluded by the `ix` skip + (`_mem_index_stated`) and by the `, upgrade)` filter (not by timing: r2 claimed they + did not exist yet, false, `_mem_upgrade_text` writes them before repair). +3. `_mem_upgrade_repair`, for each `resolved` row: read the v1 line once + (`memory_legacy_status "$1" "$id" '^##* *BLK-[0-9]'`). Labelled = the line holds a + `status`/`statut` label (case-insensitive, `[^a-z:]*:` then optional `*`/spaces) + AND the label's value holds exactly ONE distinct `_MEM_WORDS` word AND that word is + closed (memory_closed). Labelled → insert `- **Status (, upgrade)**: ` and name the ID + v1 line on stderr (every write visible at the approval). + Not labelled → no insert; stderr: `memory: : v1 closed by an unlabelled or mixed + line, status unknown: ` + remedy `record it from the project root: + memory.sh status ", …" (the leading word decides), then re-run upgrade`. +4. `_mem_upgrade_oracle`: keep the existing verdict refusal unchanged (it refuses any + ID still v1-closed / strict-open after repair → unlabelled ones refuse the file, + rc 2, file left as it was). ADD an independent entry-level assert not using + `_mem_verdict_diff`: at most one `, upgrade)**:` line per entry ID in the new file + (heading of the entry = `## ID `), else `memory: upgrade lost: :dup` rc 2. +5. Tests, lib/tests/memory.test.sh T15 (fixtures via `v1blk`; remedy cases under + `d15//.claude/memory` and `-C d15/`, the relpath pattern): + a. `## BLK-001 — x` / `date: 2026-09-20 · status: open` / `prose: another tab already + resolved it` → rc 2, file byte-identical, stderr names BLK-001 and the remedy. + b. `date: 2026-10-17 | status: code resolved (abc) · SMTP open` → rc 2. + b2. `- **Statut** : resolved (x), open (y)` → rc 2. + b3. boundary: `status: code resolved (abc) · SMTP open` (strict candidate, both + readers closed) → rc 0, no `upgrade)` line. + c. existing T15-datestatus fixture: add a `memory_word_of` assert = resolved. + d. `## BLK-008 — x` / `date: 2026-07-20 · status: RESOLVED 2026-07-20` / `### BLK-008 + UPDATE 2026-07-20 (y)` / `body` → rc 0, exactly one `upgrade)` line. + d2. same with `Status: open, reopened` under the `###` → rc 0, no `upgrade)` line, + strict open. + e. remedy round trip on (a)'s shape: `memory.sh -C d15/e status BLK-001 "upstream, + SMTP OVH; code resolved (x)"` then `memory.sh -C d15/e upgrade` → rc 0, strict + word upstream, no `upgrade)` line. + e2. same remedy on an entry with a `### BLK-001 UPDATE` sub-heading → rc 0. + (r3: fixture f dropped: a v1-closed line always holds `resolved`, so the single + closed word written is in practice `resolved`; the code still writes the word it + found.) + e3. dated line then later prose closure: `## BLK-001 — x` / `date: x · status: open` + / `- **Status (2026-10-30)**: open, waiting` / `later prose: fixed, resolved in + abc` → rc 2 (no `explicit` skip: v1 line is the prose). + e4. step-1 guard: e2's shape WITHOUT the remedy line, prose closure above the + `### BLK-001 UPDATE` and `Status: open, reopened` below it → rc 0, no + `upgrade)` line (fails if the range still stops at the sub-heading). + g. oracle dup assert: a built text with two `upgrade)` lines under one ID is refused + (tamper pattern, T15-tamper style). +6. Real-data proof before merge-ready (main loop, scratchpad, `MEMORY_DATE=2026-10-30` + = the live pass date). Per repo a fresh `mktemp -d` project with + `.claude/memory` filled from: + - committed repos (config, integration_alphalink, robin_petier, trucks_at_work, + bchanot-cv, game-deploy, gitea-deploy, angelscar356, for_you, nuit-folle): `git + show ^:.claude/memory/.md`; trucks_at_work gets the 3 bullet + Indexes dropped first (live precondition). Baseline = `git show + :…` (robin_petier: 88f8dbc, before its status-line commit; + trucks_at_work: 17536ce minus the BLK-001 status line and journal line). + - orbistep: `git show HEAD:` of chore/memory-v2 + the live 16-line heading sed + (precondition); baseline = its current working tree (uncommitted upgrade). + - zenquality: `git show HEAD:` of chore/memory-v2; baseline = its working tree. + - faunosteo: `git show 81f7639:`; baseline = scratchpad fauno.6sTi/after. + Run `memory.sh -C upgrade`. Expected: orbistep blockers.md refused + naming BLK-021, BLK-026, BLK-030; zenquality blockers.md refused naming BLK-006; + every other registry rc 0 and byte-identical to its baseline (journal excluded: the + live pass appended a line). Any other difference is reported, not waived. + +## R2 CHANGES +- Classifier moved from `_mem_verdict_diff` into `_mem_upgrade_repair`; no `unclear` + protocol word; oracle verdict check unchanged (simplicity 1). +- Labelled = exactly one distinct status word, closed (robustness 1: zenquality + BLK-006); repair writes that word (robustness 5, correctness 5, simplicity 3). +- Dated `Status (date)` lib lines win over the v1 reader in `_mem_verdict_diff` + (correctness 2, robustness 3): the remedy converges even when its text says + "resolved". +- Same-ID sub-heading continues the upgrade's v1 range (robustness 4, correctness 3, + simplicity 5); fixtures d2, e2. +- Every repair write named on stderr + independent dup assert in the oracle + (robustness 2, correctness 6). +- Fixture shapes fixed: b with `date: … |` prefix, b3 boundary, remedy under + `.claude/memory` with `-C` (correctness 1, 4; simplicity 4); old 3c folded into the + datestatus fixture (simplicity 2). +- Real-data run over the 13 copies with `-C` (correctness 7, LRN-237). +- Remedy message names the project-root invocation (robustness 6). + +## R3 ADDENDUM — race found while building the step-6 oracle (main loop, 2026-10-30) +`_mem_upgrade_repair` reads `_mem_verdict_diff "$1" "$2"` through `< <(…)` while +`_mem_insert` rewrites "$2" in place (`cat "$tmp" > "$1"`, memory.sh ~288): the diff's +readers can see a torn file and report an extra blocker. Measured on config's +pre-upgrade blockers (4dc8e77): stage-by-stage trace = 2 rows (BLK-002, BLK-004); the +CLI upgrade = 3 repair lines (BLK-003 extra, its `Status: SUPERSEDED …` line is a +strict candidate, so it is never a real verdict move), 6 of 6 runs; the live run +345ee68 wrote 2. Fix: step 3 captures the full diff into a variable BEFORE the first +insert, then loops over it. Covered by the step-6 oracle (config replay must equal +345ee68); a unit test cannot force the interleaving deterministically. + +## R3 CHANGES (confirmation pass correctness FATAL(3), folded without a 3rd pass) +- Fixture f dropped (unreachable); repair word in practice `resolved` (C1). +- Step 2b skip only when OLD v1 line byte-equals NEW strict winner, dated, not + `, upgrade)`; row `explicit`, named once by the repair; new fixtures e3, e4 (C2, C4). +- Rationale for `, upgrade)` exclusion corrected (C5). +- Step 6 sources, preconditions, MEMORY_DATE and baselines named per repo (C3). + +## Out of scope +reconcile's default v1 reader, the strict parser, heading normalization, other parked +4a minors. + +## Follow-up after the fix (not in this diff) +Reset orbistep and zenquality `.claude/memory` to HEAD on chore/memory-v2 (user +approved), re-apply orbistep's 16-line heading fix, ask the user the real status of +orbistep BLK-021/026/030 and zenquality BLK-006, write them with `memory.sh status`, +re-run upgrade; regenerate the faunosteo patch with the fixed lib. From ce9dc8ec22403ec1ebc00099837271059ce5530d Mon Sep 17 00:00:00 2001 From: bchanot Date: Sat, 31 Oct 2026 13:20:47 +0100 Subject: [PATCH 3/5] docs: memory v2 upgrade refuses a prose or mixed v1 closure (BLK-038) --- CHANGELOG.md | 2 +- MIGRATION.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81e3386..ced21c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/) and this project - **/explain-diff skill**: turns a change (commit, range, branch, merge, PR, staged or uncommitted work) into one self-contained HTML page saved outside the repo, under `~/Documents/explanations//YYYY-MM-DD-.html`. The page has a background, an intuition built on toy data with HTML diagrams, a code walkthrough grouped by concern and a 5-question interactive quiz. Adapted from Geoffrey Litt's explain-diff gist. A bundled template (light and dark, works offline) and a checker (`scripts/check_explanation.py`: file name, location, sections, quiz, code escaping, no ASCII art, no em-dash) hold every page to the same floor. Routing row `reflect`; profiles full, max and dev. - **Project path rules (CLAUDE.md split)**: `lib/project-rules.sh` (`check`, `matches`, `sections`, `extract`, `emit`, optional `-C `) is the glob oracle for `.claude/rules/.md` rules, one-line `paths:` frontmatter, loaded on Read of a matching file; suite `lib/tests/project-rules.test.sh`. `/onboard split` classifies an existing project CLAUDE.md section by section behind a gate and moves the path-bound ones into rules on a `chore/claude-md-split` branch. `extract` also moves a `###` subsection (heading passed as `'### '`; a bare heading stays `##`), which ends at the next heading of level 3 or less outside a fence, and `sections --depth 3` lists each `##` section's subsections with their sizes, so `/onboard split` can move a path-bound subsection out of an always-on parent (one `### <title>` row; a row's parent is never itself a move row). `extract` refuses an absolute `<out>`, one with a `..` part, or one that already exists (a dangling symlink included), with rc 2 and the reason on stderr, and leaves the source CLAUDE.md untouched when the rule directory or file cannot be written. `/onboard` and `/init-project` emit `docker`, `testing` and `ci` rules from `templates/project-rules/` when their globs match. This repo's CLAUDE.md now keeps its header, Health Stack and a pointer; four sections load as path rules. - **InstructionsLoaded logger**: `hooks/instructions-loaded.sh`, wired in `settings.json`, appends one JSON line per instruction file loaded to `~/.claude/logs/instructions-loaded.jsonl` (rotated above 5 MB), the proof that a path rule loaded. -- **Memory registries v2, single writer**: `lib/memory.sh` is the one writer and reader of the `.claude/memory/` registries (every verb takes an optional leading `-C <dir>`): `add <kind> --title … --body-file … [--status …] [--supersedes <ID>]` appends an entry with the next ID from the headings and prints only the new ID; `status <ID> <text>` appends a dated `**Status (<date>)**:` line; `journal <line>` appends under today's `## YYYY-MM-DD`; `index [<kind>]` prints ID, date, title and status from headings and bodies; `check [--staged]` verifies heading shape, unique IDs, no Index and no open fence (a v1 file is named, never failed); `upgrade` migrates v1 to v2 (Index-only dates and statuses become body lines, `format: 2` added, `## Index` removed, every v1 heading dialect becomes `## ID — title (date)`), after an oracle on IDs, check and blocker verdicts, else rc 2 with the file untouched (a duplicate ID or a non-table Index is refused). Writes run under a lock in the git common dir, on a verified backup restored on failure or signal. `templates/memory/` ships v2 templates; the session banner adds `registry v1: N file(s) (memory.sh check)` while a project registry is v1. Suite `lib/tests/memory.test.sh`. +- **Memory registries v2, single writer**: `lib/memory.sh` is the one writer and reader of the `.claude/memory/` registries (every verb takes an optional leading `-C <dir>`): `add <kind> --title … --body-file … [--status …] [--supersedes <ID>]` appends an entry with the next ID from the headings and prints only the new ID; `status <ID> <text>` appends a dated `**Status (<date>)**:` line; `journal <line>` appends under today's `## YYYY-MM-DD`; `index [<kind>]` prints ID, date, title and status from headings and bodies; `check [--staged]` verifies heading shape, unique IDs, no Index and no open fence (a v1 file is named, never failed); `upgrade` migrates v1 to v2 (Index-only dates and statuses become body lines, `format: 2` added, `## Index` removed, every v1 heading dialect becomes `## ID — title (date)`), after an oracle on IDs, check and blocker verdicts, else rc 2 with the file untouched (a duplicate ID, a non-table Index, or a blocker the v1 reader closed only through prose or a mixed Status line is refused and named with the `memory.sh status` remedy; a v1 closure is carried over only from a `Status`/`Statut` label holding one closed word, at most one upgrade status line per entry). Writes run under a lock in the git common dir, on a verified backup restored on failure or signal. `templates/memory/` ships v2 templates; the session banner adds `registry v1: N file(s) (memory.sh check)` while a project registry is v1. Suite `lib/tests/memory.test.sh`. - **Architecture defaults carrier**: `lib/architecture-defaults.md`, read before proposing a stack (new project, scaffolding, stack brainstorm, whole-project rewrite): public sites never SPA, Rust by default, web APIs versioned. Path rules `rules/supabase.md` and `rules/cloud-functions.md` hold the full Supabase and cloud-function domains. Suites `lib/tests/user-rules.test.sh` and `lib/tests/doctor-automem.test.sh`. ### Changed diff --git a/MIGRATION.md b/MIGRATION.md index 6128784..cd88def 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -202,7 +202,7 @@ make doctor A v2 registry is the same `.claude/memory/<name>.md` file, versioned and pushed with the code, with `format: 2` in its frontmatter and no `## Index`. The session banner line `registry v1: N file(s) (memory.sh check)` flags a project still on v1. v1 stays readable and writable (lenient), and the `check --staged` chokepoint skips it. -To migrate, run `bash ~/.claude/lib/memory.sh -C <project> upgrade` on a clean `.claude/memory`, then commit through `/commit-change` when headings were rewritten (memory-commit refuses heading rewrites by design). `upgrade` refuses a registry with duplicate IDs or a non-table Index and leaves the file untouched: a human renumbers or converts first. +To migrate, run `bash ~/.claude/lib/memory.sh -C <project> upgrade` on a clean `.claude/memory`, then commit through `/commit-change` when headings were rewritten (memory-commit refuses heading rewrites by design). `upgrade` refuses a registry with duplicate IDs or a non-table Index and leaves the file untouched: a human renumbers or converts first. A v1 blocker closure is carried over only from a `Status`/`Statut` label holding a single closed word. A blocker the v1 reader closed through prose or a mixed Status line is named with its v1 line and the whole run is refused (rc 2, file untouched). Record its real status with `bash ~/.claude/lib/memory.sh -C <project> status <ID> "<word>, …"` (the leading word decides), then re-run `upgrade`. ## Auto memory off (2026-10-29) From bb7c158187d01341a8e2f57401f1c2240532d502 Mon Sep 17 00:00:00 2001 From: bchanot <chanot.bastien@gmail.com> Date: Sat, 31 Oct 2026 14:33:38 +0100 Subject: [PATCH 4/5] =?UTF-8?q?chore(memory):=20BLK-038=20resolved=20+=20L?= =?UTF-8?q?RN-244=20+=20LRN-245=20=E2=80=94=20bugfix=20memory-upgrade-pros?= =?UTF-8?q?e-closure,=20phase=204a=20pass?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/memory/blockers.md | 8 ++++++++ .claude/memory/journal.md | 3 +++ .claude/memory/learnings.md | 10 ++++++++++ 3 files changed, 21 insertions(+) diff --git a/.claude/memory/blockers.md b/.claude/memory/blockers.md index e7f7b1e..e34748f 100644 --- a/.claude/memory/blockers.md +++ b/.claude/memory/blockers.md @@ -336,3 +336,11 @@ rules: - **Friction**: `/model` picker, pick = session's current model (Opus 5.5) → native "Set model to `Opus 5.5` and saved as your default… settings.local.json pins `Fable 5.1` — that applies on restart"; no scope question; project pin stays. - **Real cause**: engine fires no `PreModelSwitch` when the pick equals the session model (nothing to switch) → handlePicker (BDR-127) never runs. Proof 2026-10-29: user picked Sonnet 5.5 (different) → "Model switch to Sonnet 5.5 was blocked by a PreModelSwitch hook". First guess (gateway ids `anthropic/claude-opus-5.5`) was a logged-out OpenRouter session, not the bug (3 lenses FATAL). - **Solution**: bare `/model` opens router dialog in command.run (BDR-132), 657e5cb. + +## BLK-038 — memory.sh upgrade cements a v1 prose false-closed as an explicit resolved status line [open] (2026-10-30) +- **Date**: 2026-10-30 +- **Friction**: phase 4a per-repo pass. `memory.sh upgrade` on orbistep wrote `- **Status (2026-10-30, upgrade)**: resolved` under BLK-021 (`status: open`, fix not decided) and BLK-030 (`status: code resolved (df5818c) · SMTP open (upstream OVH)`), twice under BLK-008. Oracle silent: "open BLK unchanged (14)". +- **Real cause**: `_mem_upgrade_repair` copies the v1 legacy reader's closed verdict, never asks where it came from. Legacy reader = last line matching `status|resolved|…|open`, prose included ("another tab already resolved it"). v1 false-closed → explicit status line. Oracle shares that reader → blind ([[LRN-237]]). Duplicate: `_mem_verdict_diff` loops `_mem_heading_ids`, which lists `### BLK-008 UPDATE` sub-heading too. +- **Measured**: 13 repos, 4 v1 closures without a labelled leading closed word: orbistep BLK-021 (really open), BLK-026 (prose addendum, really resolved), BLK-030 (mixed), bchanot-cv BLK-001 (strict already resolved, no effect). No lexical rule decides prose: BLK-021 and BLK-026 same shape, opposite truth. +- **Solution**: /bugfix bugfix/memory-upgrade-prose-closure: repair only from a `Status`/`Statut` label whose leading word closes; else refuse file (rc 2), name ID + v1 line + remedy `memory.sh status`. Dedupe IDs. Committed repos audited clean; orbistep + zenquality redone after fix. +- **Status (2026-10-31)**: resolved 2dae528: repair writes only a single closed Status word, prose/mixed refused and named, diff captured before inserts, one upgrade line per entry; orbistep + zenquality redone (144505f, b7edb9c) diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index f199002..fdd9329 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -672,3 +672,6 @@ rules: ## 2026-10-29 - Phase 1 context diet (feature/context-diet): 8 tasks SDD + final opus review (I1 Write gap fixed 789a2b2), GATE 0 MET, verifier CONFORME 21/21 after 2 micro-gates, security PASS. /context 30.5k → 26.2k (own −2.8k). Load proof: faunosteo supabase.md + web-building.md, game cloud-functions.md + supabase.md path_glob_match. robin_petier BDR-075 (auto memory migrated, chore/memory-lan-server). BDR-130/131, LRN-238..241, EVAL-053. Faunosteo/game: nothing lost. - /bugfix /model pin (BLK-037: same-model pick fires no PreModelSwitch; gateway-id plan dropped after 3 lenses FATAL) → /feat bare /model dialog (BDR-132) 657e5cb: 2 challenge rounds (ui.ask 2-4 cap BLOCKER), verifier 8/9 + live c9 MET, security PASS. LRN-242/243. + +## 2026-10-31 +- Phase 4a per-repo pass: 12 repos upgraded to v2 on chore/memory-v2 (game headings demoted, trucks bullet Indexes dropped + BLK-001 resolved, robin BLK-013/015 closures kept); BLK-038 found (upgrade cemented prose false-closed) → /bugfix 2dae528, 3 lenses + confirmation, verifier CONFORME 6/6, security PASS, real-data replay oracle over 13 repos; game/zq redone with user statuses. LRN-244, LRN-245. faunosteo prepared off-repo (V1-2 active). diff --git a/.claude/memory/learnings.md b/.claude/memory/learnings.md index e901a21..0e2ef9b 100644 --- a/.claude/memory/learnings.md +++ b/.claude/memory/learnings.md @@ -1857,3 +1857,13 @@ Rule: when editing a doctrine file under structure locks, grep the test's lock s ## LRN-243 — Interactive engine behavior: one discriminating user test before the fix plan (2026-10-29) - **Pattern**: bugfix diagnosis twice wrong before code: "proven" cause was a logged-out OpenRouter session; real cause found by challengers reading timestamps + session model (same-model pick). A 30 s user-run discriminating test (pick a different model) settled it; a second (`/model opus` typed) proved `$.ui.ask` renders in command.run before building on it. - **Application**: interactive-only engine behavior → design one discriminating user test, ask it in plain text (an open AskUserQuestion blocks the user's slash commands), before any fix plan hardens. + +## LRN-244 — Never stream a reader over a file the same loop rewrites in place (2026-10-31) +- **Context**: BLK-038 fix 2026-10-30. `_mem_upgrade_repair` looped `while … done < <(_mem_verdict_diff old new)` while `_mem_insert` rewrote `new` in place (`cat "$tmp" > "$1"`). +- **Pattern**: process substitution runs concurrently with the loop body. Reader sees a torn file → nondeterministic extra row. Config pre-upgrade blockers: CLI upgrade wrote BLK-003 repair 6 of 6 replays, stage-by-stage trace and live run 345ee68 wrote none. +- **Apply**: never stream a reader over a file the same loop rewrites. Capture the full output into a variable first (`rows=$(…)`), then loop over a here-string. Found only by a byte-for-byte replay oracle on real data, not by unit fixtures. + +## LRN-245 — A migration must not cement a lexical legacy verdict: carry only a labelled single-word status, refuse and name the rest (2026-10-31) +- **Context**: phase 4a per-repo pass 2026-10-30, BLK-038. `memory.sh upgrade` turned the v1 lexical reader's closed verdict into an explicit `Status (…, upgrade): resolved` line; oracle "open set unchanged" passed because both readers agreed on the wrong verdict. +- **Pattern**: prose lines of the same shape carried opposite truth (orbistep BLK-021 "already resolved it" = really open; BLK-026 "ADDENDUM: resolved same day" = really resolved). No lexical rule decides prose. +- **Apply**: a migration carries a status only from a labelled line holding exactly one status word; everything else is named and refused, the human records the truth (`memory.sh status`), then re-run. Audit every written repair line against its source line before trusting "verdicts unchanged" ([[LRN-237]]). From 1407c0e712775c7be425b8a5c919dbc41346889b Mon Sep 17 00:00:00 2001 From: bchanot <chanot.bastien@gmail.com> Date: Sat, 31 Oct 2026 14:33:55 +0100 Subject: [PATCH 5/5] chore(memory): TODO phase 4a per-repo pass done, faunosteo deferred, BLK-038 residuals --- .claude/tasks/TODO.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index 9d007a3..019ce24 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -30,7 +30,9 @@ Shared rules for every phase: - [x] **Phase 4a, memory v2 write side: shell, no mod** (shrunk 2026-10-25: the measured recall channels never read Meta; the measured status bug is a reconcile parser bug) - Done 2026-10-28 on feature/memory-v2-write (a423594..aab9e4d, registries v2 9698473): BDR-129, LRN-236, LRN-237, EVAL-052. memory suite 202/0, make test green. - - [ ] Phase 4a per-repo pass: `bash ~/.claude/lib/memory.sh -C <proj> upgrade` on a clean `.claude/memory`, one `chore/memory-v2` branch per repo, user approval each, commit via `/commit-change` when headings were rewritten (memory-commit rc 6 by design). Ready (proven on copies 2026-10-28): config, faunosteo, game-deploy ×2, integration_alphalink, robin_petier, zenquality, angelscar356, bchanot-cv, for_you, gitea-deploy, nuit-folle. Refused, user decision first: game (`## BDR-027/061 ADDENDUM` headings, duplicate BLK-008/014), trucks_at_work (bullet-list `## Index` holding BLK-001's closure). + - [x] Phase 4a per-repo pass (2026-10-30/31): 12 repos v2 on `chore/memory-v2` (config, integration_alphalink, robin_petier, zenquality, game, trucks_at_work, bchanot-cv, game-deploy, gitea-deploy off develop; angelscar356 off main; for_you, nuit-folle off master). game: 16 headings demoted in place; trucks_at_work: 3 bullet Indexes dropped + BLK-001 resolved; robin_petier: BLK-013 resolved + BLK-015 superseded (closures only in the v1 Index). BLK-038 (upgrade cemented prose false-closed) fixed 2dae528 before game/zenquality; user statuses: game BLK-021 open, BLK-026 resolved, BLK-030 upstream, zenquality BLK-006 open. Replay oracle: the 10 earlier repos byte-identical under the fixed lib. + - [ ] faunosteo: NOT upgraded (V1-2 active in another session's worktree; user: no write to develop or the V1-2 worktree). Patch prepared off-repo from V1-2 587cbb2 (rc 0, 520 lines, open BLK-008/009 unchanged); at integration re-run `memory.sh -C <faunosteo> upgrade` on the branch the user names rather than applying the stale patch. Stale clone `/home/bchanot/faunosteo` (main, 2026-07-01): left alone, user to decide. + - [ ] BLK-038 residuals (gates 2026-10-30, non-blocking): v1 line echoed on stderr unfiltered (CWE-150 LOW, terminal control chars from a foreign registry; same as existing "upgrade lost" path); no fixture asserts the "wrote upgrade status" / "dated status line kept" messages; the real-data replay oracle lives in the session scratchpad (`up4a/realdata.sh`), not re-runnable: port to a `make` target over fixture copies if the upgrade is touched again; `memory.sh journal` leaves two blank lines before a new date heading on files ending with a blank line (commit-changer note). - [ ] Phase 4a parked minors (ledger `.superpowers/sdd/2026-10-27-memory-v2-write/progress.md`): empty `memory.lock.steal` never stale (manual rm); `## Index` comment-edge mismatch; `upgrade` header doc lacks the non-table refusal; memory-commit rc 6 message misleading on a v1→v2 heading-rewrite upgrade; labelled "not resolved yet" reads resolved on v2; body `## ` line splits an entry (refuse at add); `-C` + relative `--body-file` (say absolute in § WRITE); tour/deploy/audit-delta § WRITE pointer; reconcile.sh:24-25 and :41-42 stale comments; `_mem_blob` → `git cat-file blob`; evals template "Later status" line; partial stage dropped on rc 6; 39 pre-existing >80-char lines in reconcile.sh / memory-commit.sh. - Facts 2026-10-24 (scratchpad memeval, 434 entries): registries ~1M chars, never in always-on context, read only by /feat /bugfix /ship-feature (analyze-before-plan); Index drift 6 rows; status in 3 places (title tag, body Status line, Index column) → reconcile false-open BLK-032..034; no single writer (Edit needs a Read of a 357k file, so real writes are ad hoc python/bash); 8 projects on this machine hold v1 registries. Verified 2026-10-25: `lib/reconcile.sh:60-67` drops the entry's OWN header while BLK-032..034 carry `[resolved]` there (the false-open); nothing machine-reads `## Index` (analyze-before-plan.md:42, reconcile.sh:9, test T1); 1 of 1,290 entries across the 8 projects above a 1% accent ratio. - `lib/memory.sh` = single writer, like gitflow.sh: `add <kind> --title --body-file [--status --supersedes]` allocates next ID from headings (never the Index) under `flock` (concurrent conversations, phase 5), appends the entry; `status <ID> <new>` appends a dated status line (append-only); `journal "<line>"`; `index` prints the Index on demand from headings; `check [--staged]` = the validator (heading pattern, ID = max+1 and unique, no removed line from an existing entry outside a /prune-memory commit, new BLK quotes ≥1 error verbatim). The validator runs in `add` and `check` + make test, NOT in the generated pre-commit (undecidable there, and it exits 0 on working branches). No English check (doctrine stays).