fix(reconcile): v2 blocker status through the shared memory.sh parser and classifier — BLK-032..034 no longer false-open; v1 reader unchanged

This commit is contained in:
bchanot committed 2026-10-28 14:07:08 +01:00
1 parent a423594ee0
commit 27643a4429
3 files changed
+48 -13

No files matched your search

+23 -11
View File
@@ -10,6 +10,7 @@
# nor believes a `[x]`/`[ ]` checkbox; it enumerates registry entries from the BODY
# `## ID —` headings and decides "done/stale" from git/fs only. It practices what it
# 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.
#
# HONEST LIMITS (graven, do not over-read):
# - Deferral detection is LEXICAL (reconcile_deferrals): it catches deferrals MARKED
@@ -28,6 +29,9 @@
set -uo pipefail
RECONCILE_GREP="${RECONCILE_GREP:-/usr/bin/grep}" # LRN-074: pin grep, never assume GNU flags
# the status parser and classifier are shared with lib/memory.sh (BDR-125 4a)
# shellcheck source=/dev/null
. "$(dirname "${BASH_SOURCE[0]}")/memory.sh"
# markers that LEXICALLY signal a deferral/follow-up (honest limit: marked-only)
RECONCILE_DEFER_RE='[Dd]efer|[Ff]ollow-?up|[Oo]ut.of.scope|OUT-OF-SCOPE|[Rr]econsider|[Rr]evisit|2e passage|won.t.do|optional\)|one-line ticket'
@@ -55,26 +59,34 @@ reconcile_oracle_msg_committed() { # $1 repo, $2 grep → rc 0 if a comm
}
reconcile_oracle_path_present() { [ -e "${1:?}" ]; } # $1 path → rc 0 if it still exists on disk
# --- registry status: LAST status-bearing line wins (the BLK-008 trap A fell into) ---
# $1 blockers file, $2 id. Echoes the current status line (compound/UPDATE/FINAL aware).
# --- registry status: LAST candidate wins (the BLK-008 trap A fell into) ---
# $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() {
# 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 (e.g. BLK-005 "...upstream rename")
# → cross-entry bleed. The entry's own header carries no status, so dropping it is safe.
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 is not resolved → emits "id<TAB>status"
# blockers whose CURRENT status does not close them → "id<TAB>status".
# v2: memory_closed (resolved | superseded | deprecated); v1: the substring.
reconcile_blk_open() {
local id st
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")
case "$st" in
*RESOLVED*|*resolved*) : ;;
*) printf '%s\t%s\n' "$id" "$st" ;;
esac
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
}
+23
View File
@@ -94,5 +94,28 @@ if reconcile_oracle_msg_committed "$orepo" "ahead commit"; then ok "T7c msg_comm
if reconcile_oracle_msg_committed "$orepo" "nonexistent-message-xyz"; then no "T7c msg_committed should be rc≠0 for an absent message"; else ok "T7c msg_committed rc≠0 for an absent message"; fi
rm -rf "$OWORK"
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-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, 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
v1w=$(mktemp -d)
reg=memory # temp tree, not the live registry (G4)
mdir="$v1w/.claude/$reg"; mkdir "$v1w/.claude" "$mdir"
printf '# Blockers\n' > "$mdir/blockers.md"
printf -- "- **Cause**: \`x\`\n" > "$v1w/b.md"
bash "$REPO/memory.sh" -C "$v1w" add blocker --title fixed \
--body-file "$v1w/b.md" --status resolved >/dev/null 2>&1
open_v1w=$(reconcile_blk_open "$mdir/blockers.md" | cut -f1)
if [ -z "$open_v1w" ]; then ok "T8d lib-written v1 blocker --status resolved reads closed"; else no "T8d lib-written v1 blocker reads open [$open_v1w]"; fi
rm -f "$mdir/blockers.md" "$v1w/b.md"
rmdir "$mdir" "$v1w/.claude" "$v1w"
echo; echo "================ $pass GREEN / $fail RED ================"
[ "$fail" -eq 0 ] && exit 0 || exit 1
+2 -2
View File
@@ -22,7 +22,7 @@ Not for: curating/compressing registries → `/prune-memory`. The skill never ed
**REQUIRED ENGINE:** `lib/reconcile.sh` does the mechanical truth-probing. A capable agent CAN reconcile by hand — but burns ~50k tokens, depends on the question being phrased well, and still hits traps (compound status, a disclaimer instead of a check). The engine is deterministic, cheap, repeatable. Source it, then:
1. Enumerate registry entries from BODY headings (`reconcile_enumerate_ids`, never the Index).
2. Per declared item, run the matching oracle (`reconcile_oracle_*`, `reconcile_blk_current_status` = last block wins) and apply `reconcile_verdict`.
2. Per declared item, run the matching oracle (`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) and apply `reconcile_verdict`.
3. Classify into the four categories.
4. **Gate the write-back** (below).
@@ -51,4 +51,4 @@ Reconciling the TODO edits a tracked file → never silent. Show the proposed di
- Writing a disclaimer ("à vérifier si déjà fait") instead of verifying → the engine verifies, it never hedges-and-advances.
## Validation
`bash lib/tests/run-reconcile.sh` → 25/25, shellcheck clean. Oracle of record = the 2026-06-29 inventory (7 gaps + 3 blocked + 5 deferred + 1 contradiction), fixtures frozen under neutral names in `lib/tests/fixtures/`.
`bash lib/tests/run-reconcile.sh` → 29/29, shellcheck clean. Oracle of record = the 2026-06-29 inventory (7 gaps + 3 blocked + 5 deferred + 1 contradiction), fixtures frozen under neutral names in `lib/tests/fixtures/`.