fix(memory): phase 4a minors — negated status words, dead empty steal, body heading, blob errors, dropped partial stages

- status parser: a word negated in its clause (not|no|never|pas, at most
  one word between, no `, ; . : ( ) -> → —`) is not a status; shared by
  the v2 parser and the v1 legacy word reader, so `upgrade` refuses a
  "not resolved yet" instead of writing resolved
- lock: an empty memory.lock.steal older than 60 s is a dead stealer
- add: refuse an unfenced `## ` body line (rc 2, line named)
- _mem_blob: rc 1 absent, rc 2 read error; check --staged refuses rc 2
- memory-commit rc 6 names each dropped partial stage with its blob id
  and a `git update-index --cacheinfo` restore line
- upgrade header: a non-table `## Index` is refused (rc 2)
Tests: memory.test.sh T17 block, run-deterministic rc 6 partial-stage case.
This commit is contained in:
bchanot committed 2026-11-01 11:39:51 +01:00
1 parent 4175401516
commit e4fb8f7670
4 files changed
+164 -18

No files matched your search

+19
View File
@@ -171,6 +171,25 @@ printf '\n## BDR-002 — added (2026-10-27)\nbody\n' >> "$d/.claude/memory/decis
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
echo "== rc 6 names the partial stage it drops"
d="$(new_repo)"
printf -- '---\nformat: 2\ntype: decisions_registry\nentry_prefix: BDR\n---\n\n## BDR-001 — kept (2026-10-27)\n- **Status**: accepted\n' \
> "$d/.claude/memory/decisions.md"
git -C "$d" add -A && git -C "$d" commit -qm v2
sed 's/kept/versionA/' "$d/.claude/memory/decisions.md" > "$d/x.tmp"
cat "$d/x.tmp" > "$d/.claude/memory/decisions.md"
git -C "$d" add .claude/memory/decisions.md
oid="$(git -C "$d" rev-parse :.claude/memory/decisions.md)"
sed 's/versionA/versionB/' "$d/x.tmp" > "$d/.claude/memory/decisions.md"
printf -- '- [ ] task\n' > "$d/.claude/tasks/TODO.md"
git -C "$d" add .claude/tasks/TODO.md
err="$(cd "$d" && bash "$HELPER" commit "chore(memory): partial" 2>&1 >/dev/null)"; rc=$?
staged="$(git -C "$d" diff --cached --name-only)"
want="memory-commit: partial stage dropped on: .claude/memory/decisions.md (blob $oid; restore: git update-index --cacheinfo 100644,$oid,.claude/memory/decisions.md)"
if [ "$rc" -eq 6 ] && [ -z "$staged" ] && [ "$(printf '%s\n' "$err" | grep -cxF "$want")" -eq 1 ]; then ok "rc 6 names a dropped partial stage (blob id), nothing left staged"; else ko "rc=$rc staged=[$staged] err=[$err]"; fi
if [ "$(printf '%s\n' "$err" | grep -c 'dropped on: .*TODO.md')" -eq 0 ]; then ok "a fully staged file is not listed"; else ko "fully staged TODO.md listed as a dropped partial stage"; fi
rm -rf "$d"
echo
printf 'RESULT: %d passed, %d failed\n' "$PASS" "$FAIL"
[ "$FAIL" -eq 0 ]