From d8e62c1420848e3b9f4cb84c5ec089252d8dba56 Mon Sep 17 00:00:00 2001 From: bchanot Date: Fri, 13 Nov 2026 14:45:15 +0100 Subject: [PATCH] fix(memory): one lexical status reader, body label beats a stale Index, clean stderr memory_legacy_status is one fence-aware awk program (selector as a positional, end derived from the ID prefix, stops at another entry or ## Index; no MEM_LEGACY_RE env read). upgrade computes one effective status (strict word, else the v1 body label) for flush, Index-stated and the oracle: a **Statut** : line is written as the dated upgrade status instead of losing to the Index cell. Control chars become ? on stderr and in written cells; journal keeps exactly one blank line. --- lib/memory.sh | 114 ++++++++++++++++++++++++++------------- lib/reconcile.sh | 8 +-- lib/tests/memory.test.sh | 74 +++++++++++++++++++++++-- 3 files changed, 151 insertions(+), 45 deletions(-) diff --git a/lib/memory.sh b/lib/memory.sh index 54762ed..2bf862e 100755 --- a/lib/memory.sh +++ b/lib/memory.sh @@ -97,6 +97,7 @@ function mem_key(line, key, c) { if (index(line, "## " key) != 1) return 0 c = substr(line, length(key) + 4, 1) return c == "" || c !~ /[0-9A-Za-z]/ } +function mem_est(st, vw) { return (st != "" || vw == "mixed") ? st : vw } function mem_want(p, c, st, w) { w = mem_word(c) if (w == "") return "" @@ -346,9 +347,13 @@ memory_status() { # } _mem_journal_locked() { # + local sep=$'\n' # exactly one blank line before a new heading _mem_insert "$1" "$2" "$3" exact case $? in - 1) printf '\n## %s\n%s\n' "$2" "$3" >> "$1" ;; + 1) [ -s "$1" ] || sep='' + [ -z "$(tail -c1 "$1")" ] || sep=$'\n\n' + [ -n "$(tail -n1 "$1")" ] || sep='' + printf '%s## %s\n%s\n' "$sep" "$2" "$3" >> "$1" ;; 0) return 0 ;; *) return 2 ;; esac @@ -602,15 +607,22 @@ _mem_index_table() { # → "IDdatelast column" per Index row print c[2] "\t" c[3] "\t" c[n - 1] }' "$1" } -_mem_upgrade_text() { # → the v2 text on stdout +_mem_upgrade_text() { # → the v2 text on stdout awk -v p="$3" -v today="$(_mem_date)" -v MEMW="$_MEM_WORDS" "$_MEM_AWK"' - function flush( i, s, w) { - w = mem_word(col[cur]) - if (cur != "" && (s = mem_want(p, col[cur], st[cur])) != "") - print "- **Status (" today ", upgrade)**: " s + function clean(x) { gsub(/[[:cntrl:]]/, "?", x); return x } + function flush( i, s, w, v) { + w = mem_word(col[cur]); v = vw[cur] + if (cur != "" && + (s = mem_want(p, col[cur], mem_est(st[cur], v))) != "") + print "- **Status (" today ", upgrade)**: " clean(s) + else if (cur != "" && st[cur] == "" && v != "" && v != "mixed") { + print "- **Status (" today ", upgrade)**: " v + if (w != "" && w != v) + print "memory: " cur ": kept body " v ", dropped Index " \ + clean(col[cur]) > "/dev/stderr" } else if (cur != "" && w != "" && p !~ /^(LRN|EVAL)$/ && w != st[cur]) print "memory: " cur ": kept body " st[cur] ", dropped Index " \ - col[cur] > "/dev/stderr" + clean(col[cur]) > "/dev/stderr" for (i = 1; i <= n; i++) print buf[i] n = 0 } FILENAME == ARGV[1] { split($0, r, "\t"); dt[r[1]] = r[2] @@ -618,6 +630,7 @@ _mem_upgrade_text() { # → the v2 text on stdout FILENAME == ARGV[2] { split($0, r, / \| /); sub(/^\| /, "", r[1]) sub(/ \|$/, "", r[4]); hd[r[1]] = r[2] != ""; st[r[1]] = r[4] next } + FILENAME == ARGV[3] { split($0, r, "\t"); vw[r[1]] = r[2]; next } FNR == 1 { print; print "format: 2"; next } /^```/ { fence = !fence } $0 == "## Index" { skip = 1; next } @@ -631,58 +644,82 @@ _mem_upgrade_text() { # → the v2 text on stdout next } cur != "" && ($0 == "" || $0 == "---") { buf[++n] = $0; next } { for (i = 1; i <= n; i++) print buf[i]; n = 0; print } - END { flush() }' "$1" <(_mem_index_rows "$2" "$3") "$2" + END { flush() }' "$1" <(_mem_index_rows "$2" "$3") \ + <(_mem_v1_words "$4" "$3") "$2" } _mem_heading_ids() { # → the entry IDs, any heading level "$MEM_GREP" -oE "^#+ *$2-[0-9]+" "$1" | sed 's/^#* *//' } -_MEM_LEGACY_RE='status|RESOLVED|REVERTED|upstream|resolved|[^a-z]open' -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; - # a same-ID sub-heading (`### ID UPDATE`) continues the range, unread. - local end="${3:-}" - if [ -z "$end" ]; then - sed -n "/^## ${2} /,/^## BLK-/p" "$1" \ - | "$MEM_GREP" -v '^## BLK-' \ - | "$MEM_GREP" -iE "$_MEM_LEGACY_RE" \ - | tail -1 - return - fi - # callers may widen the selector (reconcile: the decisions range) - RE="${MEM_LEGACY_RE:-$_MEM_LEGACY_RE}" END_RE="$end" awk -v id="$2" ' +_MEM_LEGACY_BLK_RE='status|RESOLVED|REVERTED|upstream|resolved|[^a-z]open' +# v1 decisions carry `**Statut** :` and `Superseded by …` lines the blocker +# selector skips; an unlabelled winner stays unreadable (_mem_v1_word) +_MEM_LEGACY_BDR_RE="$_MEM_LEGACY_BLK_RE|statut|superseded|deprecated" +memory_legacy_status() { # [] → the v1 lexical status line + # (reconcile reads it on a v1 file; `upgrade` proves its verdicts against + # it). selects the line (default: the blocker selector). The range + # is fence-aware: from `## ID` to the next heading of another ID of the + # same prefix or to `## Index`, that heading not read; a same-ID + # sub-heading (`### ID UPDATE`) continues the range, unread. + local file + file=$(_mem_path_safe "$1") + RE="${3:-$_MEM_LEGACY_BLK_RE}" END_RE="^##* *${2%%-*}-[0-9]" \ + awk -v id="$2" ' /^```/ { fence = !fence; next } !fence && $0 ~ ("^#+ *" id "( |$)") && on { next } + !fence && $0 == "## Index" { on = 0 } !fence && $0 ~ ENVIRON["END_RE"] { on = 0 } !fence && $0 ~ "^## " id " " { on = 1; next } on && !fence && tolower($0) ~ tolower(ENVIRON["RE"]) { last = $0 } - END { if (last != "") print last }' "$1" + END { if (last != "") print last }' "$file" } _mem_legacy_open() { # → rc 0 when reconcile's v1 reader local st # lists the blocker open (its status is not RESOLVED); # upgrade reads the entry's own range, up to a heading of any level - st=$(memory_legacy_status "$1" "$2" '^##* *BLK-[0-9]') + st=$(memory_legacy_status "$1" "$2") case "$st" in *RESOLVED*|*resolved*) return 1 ;; esac } +_mem_v1_words() { # → "IDword|mixed" for each Index ID + # the strict reader finds no word for, when a v1 status/statut label of + # its body (anchored: line start, ` · ` or `| `) is there; `mixed` = + # label without exactly one word. Blocker and decision selectors only. + local id re line word + case "$2" in + BLK) re=$_MEM_LEGACY_BLK_RE ;; + BDR) re=$_MEM_LEGACY_BDR_RE ;; + *) return 0 ;; + esac + while read -r id; do + line=$(memory_legacy_status "$1" "$id" "$re") + [[ "$line" =~ ^(-\ )?(\*\*)?[Ss]tatu[st]|(\ ·\ |\|\ )[Ss]tatu[st] ]] \ + || continue + word=$(_mem_v1_word "$line") + printf '%s\t%s\n' "$id" "${word:-mixed}" + done < <(awk -F'\t' 'FILENAME == ARGV[1] { ix[$1] = 1; next } + { split($0, a, / \| /); sub(/^\| /, "", a[1]); sub(/ \|$/, "", a[4]) + if (a[1] in ix && a[4] == "") print a[1] }' \ + <(_mem_index_table "$1") <(_mem_index_rows "$1" "$2")) +} + _mem_index_stated() { # → IDs whose Index status upgrade # writes into the body (mem_want): a fact the v1 reader never saw awk -F'\t' -v p="$2" -v MEMW="$_MEM_WORDS" "$_MEM_AWK"' FILENAME == ARGV[1] { col[$1] = $3; next } + FILENAME == ARGV[2] { vw[$1] = $2; next } { split($0, a, / \| /); id = a[1]; sub(/^\| /, "", id); s = a[4] sub(/ \|$/, "", s) - if (id in col && mem_want(p, col[id], s) != "") print id }' \ - <(_mem_index_table "$1") <(_mem_index_rows "$1" "$2") + if (id in col && vw[id] != "mixed" && + mem_want(p, col[id], mem_est(s, vw[id])) != "") print id }' \ + <(_mem_index_table "$1") <(_mem_v1_words "$1" "$2") \ + <(_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 + v1=$(memory_legacy_status "$1" "$3") # 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 @@ -719,8 +756,11 @@ _mem_v1_word() { # → the one status word of its status/statut _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]') + v1=$(memory_legacy_status "$1" "$3") word=$(_mem_v1_word "$v1") + # foreign bytes never reach the terminal; under a C locale UTF-8 bytes + # are not printable either and degrade to `?` in this echo only + v1=${v1//[![:print:]]/?} if ! memory_closed "$word"; then echo "memory: $3: v1 closed by an unlabelled, mixed or negated line," \ "status unknown: ${v1:0:100}" >&2 @@ -763,17 +803,19 @@ _mem_upgrade_oracle() { # → rc 2 on a lost fact awk -F'\t' -v p="$3" -v MEMW="$_MEM_WORDS" "$_MEM_AWK"' function f(s, k) { split(s, a, / \| /); return a[k] } FILENAME == ARGV[1] { dt[$1] = $2; col[$1] = $3; next } + FILENAME == ARGV[2] { vw[$1] = $2; next } { id = f($0, 1); sub(/^\| /, "", id) } - FILENAME == ARGV[2] { old[id] = f($0, 4); sub(/ \|$/, "", old[id]); next } + FILENAME == ARGV[3] { old[id] = f($0, 4); sub(/ \|$/, "", old[id]); next } !(id in col) { next } { d = f($0, 2); s = f($0, 4); sub(/ \|$/, "", s) - m = mem_want(p, col[id], old[id]) - want = m != "" ? mem_word(m) : old[id] + e = mem_est(old[id], vw[id]); m = mem_want(p, col[id], e) + want = m != "" ? mem_word(m) : e if (dt[id] != "" && d == "") bad = bad " " id ":date" if (want != "" && p != "BLK" && s != want) bad = bad " " id ":" s "!=" want } END { if (bad != "") { print "memory: upgrade lost:" bad; exit 2 } }' \ - <(_mem_index_table "$1") <(printf '%s\n' "$o") \ + <(_mem_index_table "$1") <(_mem_v1_words "$1" "$3") \ + <(printf '%s\n' "$o") \ <(printf '%s\n' "$n") >&2 || return 2 o=$(_mem_verdict_diff "$1" "$2" | awk -F'\t' '$2 == "resolved" \ { printf "%s ", $1 }') @@ -832,7 +874,7 @@ _mem_upgrade_build() { # → the v2 text, blocker { _mem_upgrade_front "$1" > "$front" \ && _mem_upgrade_headings "$front" "$2" > "$src" \ && _mem_index_table "$src" > "$rows" \ - && _mem_upgrade_text "$rows" "$src" "$2" > "$3" \ + && _mem_upgrade_text "$rows" "$src" "$2" "$1" > "$3" \ && _mem_upgrade_repair "$1" "$3" "$2"; } || rc=2 rm -f "$front" "$src" "$rows" return "$rc" diff --git a/lib/reconcile.sh b/lib/reconcile.sh index 64fa211..26ee994 100644 --- a/lib/reconcile.sh +++ b/lib/reconcile.sh @@ -50,9 +50,6 @@ RECONCILE_GREP="${RECONCILE_GREP:-/usr/bin/grep}" RECONCILE_DEFER_RE='[Dd]efer|[Ff]ollow-?up|[Oo]ut.of.scope|OUT-OF-SCOPE' RECONCILE_DEFER_RE+='|[Rr]econsider|[Rr]evisit|2e passage|won.t.do' RECONCILE_DEFER_RE+='|optional\)|one-line ticket' -# v1 decisions carry `**Statut** :` and `Superseded by …` lines the blocker -# selector skips; an unlabelled winner stays unreadable (_mem_v1_word) -RECONCILE_BDR_RE="$_MEM_LEGACY_RE|statut|superseded|deprecated" # --- recursive coherence: enumerate IDs from the BODY, never the ## Index --- # $1 registry file, $2 prefix (BDR|LRN|BLK|EVAL). Emits one id per line, unique. @@ -94,7 +91,7 @@ reconcile_oracle_path_present() { [ -e "${1:?}" ]; } # cannot see it. reconcile_blk_current_status() { if memory_is_v2 "$1"; then memory_entry_status "$1" "$2"; return; fi - MEM_GREP="$RECONCILE_GREP" memory_legacy_status "$1" "$2" + memory_legacy_status "$1" "$2" } # blockers whose CURRENT status does not close them → "idstatus". # v2: memory_closed (resolved | superseded | deprecated); v1: the substring. @@ -114,8 +111,7 @@ reconcile_blk_open() { _reconcile_status() { # → 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]" + memory_legacy_status "$1" "$2" "$_MEM_LEGACY_BDR_RE" } # entries of one prefix (BLK blockers, BDR decisions) → "idopen| # unreadableword or line"; closed ones are omitted. A status no diff --git a/lib/tests/memory.test.sh b/lib/tests/memory.test.sh index 6b462f7..e9aeedf 100755 --- a/lib/tests/memory.test.sh +++ b/lib/tests/memory.test.sh @@ -378,6 +378,17 @@ printf '\n## 2026-10-28 (cont. 1) — legacy\n- kept\n' >> "$J" MEMORY_DATE=2026-10-28 bash "$MEM" journal 'new day' check T14l-cont-not-matched "$(grep -c '^## 2026-10-28$' "$J")" 1 check T14m-cont-untouched "$(sed -n '/(cont. 1)/{n;p;}' "$J")" '- kept' +# one blank line before a new heading whatever the file's last bytes are +# (none, a newline, a blank line); `tail -c1` is the final-newline probe +gap() { # → blank lines before the heading + local f="j14/$1/.claude/memory/journal.md" + mkdir -p "$(dirname "$f")"; printf '%b' "$2" > "$f" + bash "$MEM" -C "j14/$1" journal x >/dev/null 2>&1 + check "T14l-gap-$1-last" "$(tail -n1 "$f")" '- x' + check "T14l-gap-$1" "$(awk '/^## 2026-10-27$/ { print NR - p - 1 } NF { p = NR }' "$f")" 1; } +gap nofinal '# J\n\n## 2026-10-20\n- a' +gap newline '# J\n\n## 2026-10-20\n- a\n' +gap blank '# J\n\n## 2026-10-20\n- a\n\n' bash "$MEM" check --staged /abs 2>/dev/null check T14n-staged-absolute "$?" 2 bash "$MEM" status BLK-404 'open' 2>&1 >/dev/null | grep -c restored > rs @@ -398,7 +409,7 @@ openset() { bash -c '. "$1/lib/reconcile.sh"; reconcile_blk_open "$2"' _ \ dialect() { # — fixture already in d15/ local f="d15/$1/blockers.md" before before=$(openset "$f") - bash "$MEM" upgrade "d15/$1" >/dev/null 2>&1 + bash "$MEM" upgrade "d15/$1" >/dev/null 2>"d15/$1/err" check "T15-$1-rc" "$?" 0 check "T15-$1-v2" "$(sed -n 2p "$f")" 'format: 2' check "T15-$1-heading" "$(grep -c "$2" "$f")" 1 @@ -424,6 +435,7 @@ check T15-hashes-2-open "$(memory_word_of d15/hashes/blockers.md BLK-002)" open # probe d: a ### entry after a ## one must not leak its status into it v1blk d15/probed '## BLK-003 — three, open' 'Status: open' '' \ '### BLK-001 — x' 'Status: resolved' +check T15-probed-openset "$(openset d15/probed/blockers.md)" 'BLK-003 ' bash "$MEM" upgrade d15/probed >/dev/null 2>&1 check T15-probed-no-repair "$(grep -c 'upgrade)' d15/probed/blockers.md)" 0 check T15-probed-open "$(memory_word_of d15/probed/blockers.md BLK-003)" open @@ -456,7 +468,7 @@ v1blk d15/v1only '## BLK-001 — v1 file' 'Status: resolved' printf '#!/bin/sh\necho STUB >&2\nexec /usr/bin/grep "$@"\n' > gstub chmod +x gstub stubbed=$(RECONCILE_GREP="$PWD/gstub" bash -c \ - '. "$1/lib/reconcile.sh"; reconcile_blk_current_status "$2" BLK-001' \ + '. "$1/lib/reconcile.sh"; reconcile_blk_open "$2"' \ _ "$ROOT" d15/v1only/blockers.md 2>&1 >/dev/null | grep -c STUB) check T15-reconcile-grep "$([ "$stubbed" -gt 0 ] && echo reached || echo missed)" reached v1blk d15/suffix '## BLK-001 — suffix — RESOLVED' 'Status: resolved in repo' \ @@ -468,9 +480,11 @@ v1blk d15/datestatus '## BLK-001 — one line' \ 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 +check T15-datestatus-wrote "$(grep -c 'BLK-001: wrote upgrade status resolved' d15/datestatus/err)" 1 v1blk d15/statut '## BLK-001 — fr' '- **Statut** : resolved' '' \ '## BLK-002 — fr open' '- **Statut** : open' dialect statut '^- \*\*Status ([0-9-]*, upgrade)\*\*: resolved$' +check T15-statut-wrote "$(grep -c 'BLK-001: wrote upgrade status resolved' d15/statut/err)" 1 mkdir -p d15/nofm printf '# Blockers\n\n## BLK-001 | 2026-05-18 | no frontmatter\n%s\n' \ '- **Statut** : resolved' > d15/nofm/blockers.md @@ -541,8 +555,9 @@ 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 +bash "$MEM" -C d15/e upgrade >/dev/null 2>d15/e/err check T15-remedy-roundtrip "$?/$(grep -c 'upgrade)' $E)/$(memory_word_of $E BLK-001)" 0/0/upstream +check T15-remedy-roundtrip-kept "$(grep -c 'BLK-001: dated status line kept' d15/e/err)" 1 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 @@ -566,6 +581,59 @@ err=$(bash -c '. "$1"; _mem_upgrade_repair() { local 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 +# T15 the body label beats a stale Index cell, by writing its word as the +# dated upgrade line (BDR-129); one effective status for flush, Index-stated +# and the oracle. Index-bearing v1 fixtures, one entry under a one-row Index +idxreg() { # + local n="$1" p="$2" d="$3" id="$4" cell="$5"; shift 5 + mkdir -p "$d"; { printf -- '---\ntype: registry\nentry_prefix: %s\n---\n\n' "$p" + printf '# R\n\n## Index\n\n| ID | Date | Title | Status |\n|---|---|---|---|\n' + printf '| %s | 2026-05-01 | x | %s |\n\n## %s — x\n' "$id" "$cell" "$id" + printf '%s\n' "$@"; } > "$d/$n.md"; } +idxrun() { # → stderr in /err, rc in /rc + bash "$MEM" upgrade "$1" >/dev/null 2>"$1/err"; echo $? > "$1/rc"; } +idxreg blockers BLK d15/ix1 BLK-001 open '- **Statut** : resolved' +idxrun d15/ix1 +check T15-statut-beats-index "$(cat d15/ix1/rc)/$(memory_word_of d15/ix1/blockers.md BLK-001)" 0/resolved +check T15-statut-dropped-index "$(grep -c 'BLK-001: kept body resolved, dropped Index open' d15/ix1/err)" 1 +idxreg blockers BLK d15/ix2 BLK-001 resolved '- **Statut** : resolved' +idxrun d15/ix2 +check T15-statut-agrees "$(cat d15/ix2/rc)/$(memory_word_of d15/ix2/blockers.md BLK-001)/$(grep -c 'dropped Index' d15/ix2/err)" 0/resolved/0 +idxreg decisions BDR d15/ix3 BDR-001 accepted '**Statut** : proposed' +idxrun d15/ix3 +check T15-bdr-statut-beats-index "$(cat d15/ix3/rc)/$(memory_word_of d15/ix3/decisions.md BDR-001)" 0/proposed +check T15-bdr-dropped-index "$(grep -c 'BDR-001: kept body proposed, dropped Index accepted' d15/ix3/err)" 1 +idxreg blockers BLK d15/ix4 BLK-001 open '- **Statut** : resolved (x), open (y)' +refused ix4 BLK-001 T15-idx-mixed-statut-refused +idxreg decisions BDR d15/ix5 BDR-001 'superseded by BDR-004' '**Statut** : accepted' +idxrun d15/ix5 +check T15-bdr-superseded-index-wins "$(cat d15/ix5/rc)/$(memory_word_of d15/ix5/decisions.md BDR-001)" 0/superseded +idxreg decisions BDR d15/ix6 BDR-001 accepted '**Statut** : accepted (x), proposed (y)' +idxrun d15/ix6 +check T15-bdr-mixed-keeps-index "$(cat d15/ix6/rc)/$(memory_word_of d15/ix6/decisions.md BDR-001)" 0/accepted +idxreg blockers BLK d15/ix7 BLK-001 resolved '- **Status**: closed' +idxrun d15/ix7 +check T15-unknown-word-keeps-index "$(cat d15/ix7/rc)/$(memory_word_of d15/ix7/blockers.md BLK-001)" 0/resolved +# control bytes of a foreign registry never reach the terminal: the v1 line +# on the refusal, the Index cell on the flush echo and the written line +esc=$(printf '\033') +v1blk d15/ctl '## BLK-001 — x' "prose: ${esc}[31m already resolved" +err=$(bash "$MEM" upgrade d15/ctl 2>&1 >/dev/null) +check T15-ctl-v1-line-no-esc "$(printf '%s\n' "$err" | grep -c "$esc")" 0 +check T15-ctl-v1-line-qmark "$(printf '%s\n' "$err" | grep -c 'prose: ?\[31m already')" 1 +idxreg blockers BLK d15/ctl2 BLK-001 "${esc}[31m resolved" 'prose' +idxrun d15/ctl2 +check T15-ctl-index-no-esc "$(cat d15/ctl2/rc)/$(grep -c "$esc" d15/ctl2/blockers.md)" 0/0 +check T15-ctl-index-qmark "$(grep -c 'upgrade)\*\*: ?\[31m resolved' d15/ctl2/blockers.md)" 1 +# the lexical range stops at a trailing ## Index and ignores the environment +# (MEM_LEGACY_RE once widened every reader of `upgrade`) +printf -- '---\ntype: d\nentry_prefix: BDR\n---\n\n## BDR-001 — a\n%s\n\n## BDR-002 — b\n%s\n\n## Index\n\n%s\n' \ + '**Statut** : accepted' 'no label here' 'status: resolved row' > d15/dec.md +legacy() { bash -c '. "$1"; memory_legacy_status "$2" "$3" "$_MEM_LEGACY_BDR_RE"' _ "$MEM" d15/dec.md "$1"; } +check T15-trailing-index-not-read "$(legacy BDR-002)" '' +check T15-first-entry-read "$(legacy BDR-001)" '**Statut** : accepted' +check T15-env-selector-ignored "$(MEM_LEGACY_RE=open legacy BDR-001)" '**Statut** : accepted' + # T16 final-review fixes # lock dir not writable: bounded, named, rc 2 (never a spin) chmod a-w .git