feat(memory): lib/memory.sh single registry writer — add/status/journal/index/check/upgrade, shared status parser, noclobber lock
This commit is contained in:
1 parent
0ccd4af88f
commit
a423594ee0
4 files changed
+1106
No files matched your search
+10
@@ -0,0 +1,10 @@
|
||||
# Blockers
|
||||
|
||||
## BLK-001 - hyphen dialect, resolved
|
||||
- **Status**: resolved
|
||||
|
||||
## BLK-002 | 2026-05-18 | pipe dialect, open
|
||||
Status: open
|
||||
|
||||
## BLK-003 | 2026-05-19 | pipe dialect, resolved
|
||||
Status: resolved.
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
---
|
||||
format: 2
|
||||
type: blockers_registry
|
||||
entry_prefix: BLK
|
||||
---
|
||||
|
||||
# Status parser fixture: BLK-032..034 as written 2026-10-27 (false-open
|
||||
# before phase 4a), BLK-008 compound (frozen snapshot), BLK-040..042 shapes.
|
||||
|
||||
## BLK-008 — gstack ./setup fails on Ubuntu 26.04 — Playwright chromium unsupported
|
||||
|
||||
- **Date**: 2026-06-23
|
||||
- **Friction**: fresh Ubuntu 26.04, `make install` / `make plugin` → "Failed to install browsers / ERROR: Playwright does not support chromium on ubuntu26.04-x64" → "GStack ./setup failed". Non-fatal in our wrapper (warn only) but gstack's browser (`/browse`, `/qa`, design screenshots) is silently dead once gstack is enabled.
|
||||
- **Real cause**: Playwright 1.58.2 (pinned in the gstack submodule) registry lists `ubuntu20.04/22.04/24.04` only; 26.04 released later → not in list → `getHostPlatform` errors. Pure OS-newness, not an install bug.
|
||||
- **Solution**: gated `export PLAYWRIGHT_HOST_PLATFORM_OVERRIDE=ubuntu24.04-x64` (ubuntu >24.04 only) before gstack setup + persisted to `.bashrc` for runtime. Playwright then pulls a Chrome-for-Testing fallback build for ubuntu24.04. Verified on 26.04: `ldd` resolves all libs + real headless render OK.
|
||||
- **Status**: resolved (commit 211c7d4). Residual: exact rev 1208 launch not in-session-tested (sandbox download hung at extraction); proved via sibling rev 1228 same-platform CfT build. Confirm on next real `make plugin`. Proper upstream fix = gstack bumps Playwright to a version that lists ubuntu26.04. See [[LRN-038]].
|
||||
|
||||
- **2026-06-23 UPDATE — Solution REVERTED, status downgraded to UPSTREAM/open** (commit b9c3937): the `PLAYWRIGHT_HOST_PLATFORM_OVERRIDE` solution above does NOT work on 26.04. The fallback build downloads to 100% then HANGS at extraction (chrome binary never appears, no headless-shell download starts; reproduced on real machine + sandbox) → turned a 0.5s fast-fail into an install-blocking hang (user Ctrl+C). Reverted to the fast-fail (non-fatal; gstack OFF by default, browser only for /browse,/qa,screenshots). The earlier "verified ldd + headless render" was an isolated test on a sibling already-extracted build (rev 1228) — it masked the rev-1208 install-path hang. **Real fix = upstream**: gstack bumps Playwright to a version that lists ubuntu26.04. Until then gstack's browser is unavailable on 26.04, install completes cleanly. See [[LRN-038]] correction.
|
||||
|
||||
- **2026-06-23 FINAL — RESOLVED** (commit 3b8ffb1): gstack browser now works on Ubuntu 26.04. Two layers fixed: (1) bumped gstack's pinned Playwright 1.58.2 → 1.61 (`bun add playwright@latest` in the submodule; 1.61 ships a native ubuntu26.04 build — chromium rev 1228), automated in the installer (`gstack_bump_playwright_if_unsupported`, idempotent, OS-gated); (2) `GSTACK_CHROMIUM_NO_SANDBOX=1` to work around the AppArmor userns restriction (`sysctl kernel.apparmor_restrict_unprivileged_userns=1`), persisted to `.bashrc` + installer Step 9 (sysctl-gated). Verified end-to-end: `browse goto https://example.com` → "Navigated (200)". Caveat: the Playwright bump is a local submodule edit, reset by `git submodule update`, re-applied by the next install. See [[BDR-029]], [[LRN-040]].
|
||||
|
||||
---
|
||||
|
||||
## BLK-032 — Main loop pinned on Fable in long sessions: session model Fable 1M + downgrade cap 120k + prompt rule `plan` → inline code on Fable xhigh [resolved]
|
||||
- **Cause**: `~/.claude/settings.json` `"model": "claude-fable-5-1[1m]"` (every session starts on Fable); model-router never moves main above the session model, moves DOWN only under `downgradeMaxTokens` 120000 (LRN-204 cold read) → a long session (faunosteo R4.x, context > 120k) never reaches `implement`/sonnet; prompt rule `(plan|design|architecture…)` → phase plan = best/xhigh each turn ("plan §B.1.7"). No doctrine ceiling: CLAUDE.md allows inline work "doable in a few tool calls", BDR-115 "pin = default, never ceiling".
|
||||
- **User policy 2026-10-19**: session model Opus 5.5; sonnet writes, opus decides what to write; Fable only for orchestrator reflection/plans and the important audits (security, functional), other judges opus. → next `/feat`: settings model, `judge` split, ceiling rule in CLAUDE.md, BDR superseding part of BDR-066 / BDR-115. Links [[BDR-066]], [[BDR-107]], [[BDR-115]], [[LRN-204]].
|
||||
|
||||
- **Solution (2026-10-23)**: feat A+B (BDR-123) + feat C 786ee13 (feature/router-keyword-cap): keyword prompt rules, `ultrathink` floor, derived `orchestrate` dispatch write effort-only routes (`effortRoute`, `belowRun` pattern) → never lift main above session model; held best-tier run keeps its model (per-axis fall-through); `mainModelSlot` drops `turnFloor`. Fable on main only via skill row, `route` tool, `/route`. Docs d2d590f. Links [[LRN-226]], [[EVAL-048]].
|
||||
|
||||
## BLK-033 — Guardrails residuals: probe trusted plan `supabase.url`, redirects free of budget, unread bodies read CLOSED; rules 5 FP / 7 misses [resolved]
|
||||
- **Friction**: GATE 2 of the a11y split (f586304) left a MEDIUM + 3 LOW on probe.py, opus review left Minors on the rules. Parked in TODO, fixed via `/bugfix` 2026-10-20/21.
|
||||
- **Cause**: `supabase.url` read from the plan w/o `_http_url` → planted SUPABASE_URL would receive GUARDRAILS_ANON_KEY / JWT2, `file://` read CLOSED; `_SameHost` redirector followed hops w/o charging `session.budget`; `_rows_state` collapsed non-200 / empty / >1 MB / non-JSON into CLOSED (unobserved = CLOSED, breaks LRN-220); plan r2 mapped budget exhaustion on `str(URLError)`, which wraps the reason → never matched. Rules: SENSITIVE_KEY on metadata names (`token_type`, `has_password`), 403 on first map candidate stopped the walk, hydrated scan read whole route file, NOSQL `$where` fired on GraphQL `_bool_exp`; misses: Go backtick Sprintf, `rf`/triple-quoted f-strings, `sql|db|trx.raw`, empty `.select()`, multi-line hidden input, Rust `{}` shell arg, `"sources"` map head.
|
||||
- **Solution**: 5a98c2c (`_BudgetExhausted(URLError)` + `BUDGET_EXHAUSTED` constant, `_SameHost(session)` charges per hop, `_rows_state` rows|empty|unreadable → SKIPPED, `_map_outcome` full candidate walk, `data:` OPEN w/o decoding, `printable` on remote strings, `_safe_text` in scanner, rule fixes + mutant per language variant) + 633faa2 (checks.md: `IN (…)` placeholder list flagged, judged by hand). Plan r3 after 2 challenge rounds, contract 22 oracles MET, verifier CONFORME, auditor PASS. Suites probe 84, scan 241.
|
||||
- **Residual** (LOW, parked in TODO): table names not `IDENT.fullmatch`-checked per table (`/` → path walk on the approved host); `printable` lets Unicode bidi/format controls through. Links [[LRN-219]], [[LRN-220]], [[LRN-222]], [[LRN-223]].
|
||||
|
||||
## BLK-034 — mods.test.sh red on CLI 2.1.306: whole-output `warning` grep caught the advisory plugin-directory section [resolved]
|
||||
- **Friction**: `make test suite=lib/tests/mods.test.sh` → `FAIL model-router: validate printed a warning`, pre-existing on develop (git archive baseline), surfaced as feat B criterion 8 (NEED-DECISION, BDR-123 run).
|
||||
- **Cause**: CLI 2.1.306 `claude plugin validate` prints "Plugin directory checks" section (submission catalogue): `⚠ Found 1 plugin directory warning:` ICON_MISSING, `--json` `directory.findings[].blocking: false`. mods.test.sh:57 grepped whole output for `warning` (also matched hooks notes quoting register.ts identifiers, checkout paths). Prose scraping of a CLI with an exit-code contract: `--strict` → per-file warnings rc 1, directory findings rc only under `--profile directory`.
|
||||
- **Solution**: 801992a (bugfix/mods-validate-advisory). Helper `validate_strict` = rc of `claude plugin validate --strict`; check_cli + positive control share it; control = scratch manifests `{"name":"warnfix"}` (rc 1) / cleanfix with version+description+author (rc 0) under script-level `mktemp -d`. Plan r3 after 3 lenses + 1 re-challenge (sed range on closing marker killed: CLI prints it only when findings > 0, fail-open to EOF). GATE 0 7/7, verifier ECARTS(2) = out-of-scope routing.json dialog write only, auditor PASS.
|
||||
- **Residual**: 3 historical contracts carry old scrape as CHECK oracle (`.claude/tasks/contracts/2026-10-08-model-router-w1a-1533.md:22`, `2026-10-08-model-router-floor-1835.md:22`, `2026-10-09-model-router-tiers-1237.md:23`), left unedited; re-run fails on ICON_MISSING, not a model-router regression. Unverified: whether `--strict` escalates `advice[]`. Links [[LRN-225]], [[BDR-123]].
|
||||
|
||||
## BLK-040 — accepted with an open check
|
||||
- **Status**: accepted. Behavioral check OPEN: `x` must ask first.
|
||||
|
||||
## BLK-041 — "Use when [triggers]" mid-title bracket
|
||||
- **Status**: open. `y` pending.
|
||||
|
||||
## BLK-042 — no status anywhere
|
||||
- **Solution**: fail-open guard, `data:` OPEN in prose.
|
||||
|
||||
## BLK-043 — DNS resolved to stale IP after failover [open] (2026-10-28)
|
||||
- **Friction**: `dig` answers the old address.
|
||||
|
||||
## BLK-044 — reopened after a regression [resolved] (2026-10-28)
|
||||
- **Cause**: `abc` reverted the fix.
|
||||
- **Status (2026-10-28)**: open again, not resolved by abc
|
||||
Executable
+385
@@ -0,0 +1,385 @@
|
||||
#!/usr/bin/env bash
|
||||
# lib/tests/memory.test.sh — lib/memory.sh (add / status / journal / index /
|
||||
# check / upgrade) and the shared status parser. Hermetic fixtures under one
|
||||
# mktemp dir with its own git repo; flip-tests first (LRN-096), then the
|
||||
# real check on this repo's registries.
|
||||
set -u
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
MEM="$ROOT/lib/memory.sh"
|
||||
pass=0; fail=0
|
||||
check() { if [ "$2" = "$3" ]; then pass=$((pass+1)); else fail=$((fail+1));
|
||||
printf 'FAIL %s: got[%s] want[%s]\n' "$1" "$2" "$3"; fi; }
|
||||
FIX=$(mktemp -d); trap 'rm -rf "$FIX"' EXIT
|
||||
cd "$FIX" || exit 1
|
||||
git init -q . && git config user.email t@t && git config user.name t
|
||||
export MEMORY_DATE=2026-10-27
|
||||
mkdir -p .claude/memory
|
||||
reg() { # <file> <type> <PREFIX> <title> → a v2 registry with no entry
|
||||
printf -- '---\nformat: 2\ntype: %s\nentry_prefix: %s\n---\n\n# %s\n' \
|
||||
"$2" "$3" "$4" > ".claude/memory/$1"
|
||||
}
|
||||
reg decisions.md decisions_registry BDR 'Decisions registry (BDR)'
|
||||
reg learnings.md learnings_registry LRN 'Learnings registry (LRN)'
|
||||
reg blockers.md blockers_registry BLK 'Blockers registry (BLK)'
|
||||
reg evals.md evals_registry EVAL 'Evals registry (EVAL)'
|
||||
printf -- '---\ntype: journal\n---\n\n# Journal\n\n## 2026-10-26\n- old\n' \
|
||||
> .claude/memory/journal.md
|
||||
B=.claude/memory/blockers.md
|
||||
printf -- "- **Friction**: \`make\` red\n- **Cause**: x\n\n" > body.md
|
||||
|
||||
# T1 add: next ID from headings, canonical heading, ID alone on stdout
|
||||
out=$(bash "$MEM" add blocker --title 'make red' --body-file body.md \
|
||||
--status open)
|
||||
check T1-first-id "$out" BLK-001
|
||||
check T1b-heading "$(grep -c '^## BLK-001 — make red \[open\] (2026-10-27)$' "$B")" 1
|
||||
check T1c-body-trimmed "$(tail -1 "$B")" '- **Cause**: x'
|
||||
check T1d-second-id "$(bash "$MEM" add blocker --title 'two' --body-file body.md)" BLK-002
|
||||
check T1e-check-green "$(bash "$MEM" check; echo $?)" 0
|
||||
check T1f-index-row "$(bash "$MEM" index blocker | grep -c '^| BLK-001 | 2026-10-27 | make red | open |$')" 1
|
||||
|
||||
# T2 add refuses, rc 2, registry unchanged
|
||||
sum=$(cksum < "$B")
|
||||
refused() { # <name> <add args…> → the add is rc 2
|
||||
local name="$1"; shift
|
||||
bash "$MEM" add "$@" >/dev/null 2>&1
|
||||
check "T2-$name" "$?" 2
|
||||
}
|
||||
refused kind unknown --title t --body-file body.md
|
||||
refused bracket blocker --title 'a[b]' --body-file body.md
|
||||
refused pipe blocker --title 'a|b' --body-file body.md
|
||||
refused no-body blocker --title t --body-file missing.md
|
||||
refused status-bracket blocker --title t --body-file body.md --status 'a]'
|
||||
refused cross-prefix blocker --title t --body-file body.md --supersedes LRN-001
|
||||
refused unknown-sup blocker --title t --body-file body.md --supersedes BLK-099
|
||||
refused no-value blocker --title t --body-file
|
||||
refused bad-option blocker --title t --body-file body.md --bogus x
|
||||
printf 'no backtick here\n' > plain.md
|
||||
bash "$MEM" add blocker --title t --body-file plain.md 2>/dev/null
|
||||
check T2b-blocker-needs-backtick "$?" 2
|
||||
check T2c-unchanged "$(cksum < "$B")" "$sum"
|
||||
bash "$MEM" add learning --title t --body-file plain.md >/dev/null
|
||||
check T2d-learning-without-backtick "$?" 0
|
||||
printf 'x\n```\nopen fence\n' > fence.md
|
||||
bash "$MEM" add learning --title f --body-file fence.md 2>/dev/null
|
||||
check T2e-open-fence-body "$?" 2
|
||||
|
||||
# T3 status: a dated line ends the entry, before the next heading's blank
|
||||
bash "$MEM" status BLK-001 'resolved abc1234'
|
||||
check T3-rc "$?" 0
|
||||
check T3b-placed "$(awk '/^## BLK-001/{on=1} on && /^- \*\*Status/{print; exit}' "$B")" \
|
||||
'- **Status (2026-10-27)**: resolved abc1234'
|
||||
check T3c-before-next "$(awk '/Status \(2026-10-27\)/{getline n; print n; exit}' "$B")" ''
|
||||
bash "$MEM" status BLK-002 'upstream, open'
|
||||
check T3d-at-eof "$(tail -1 "$B")" '- **Status (2026-10-27)**: upstream, open'
|
||||
bash "$MEM" status BLK-404 x 2>/dev/null
|
||||
check T3e-unknown-id "$?" 2
|
||||
bash "$MEM" status BLK-001 "$(printf 'a\nb')" 2>/dev/null
|
||||
check T3f-multi-line "$?" 2
|
||||
bash "$MEM" status BLK-001 'reopened by abc' 2>/dev/null
|
||||
check T3g-needs-status-word "$?" 2
|
||||
bash "$MEM" status BLK-002 'open \b \n \| kept'
|
||||
check T3h-backslash-verbatim "$(tail -1 "$B")" \
|
||||
'- **Status (2026-10-27)**: open \b \n \| kept'
|
||||
|
||||
# T4 journal: appended under today, heading created once, old date untouched
|
||||
J=.claude/memory/journal.md
|
||||
bash "$MEM" journal 'first'
|
||||
bash "$MEM" journal '- second'
|
||||
check T4-heading-once "$(grep -c '^## 2026-10-27$' "$J")" 1
|
||||
check T4b-order "$(tail -2 "$J" | tr '\n' '|')" '- first|- second|'
|
||||
check T4c-old-kept "$(sed -n '/^## 2026-10-26$/,/^$/p' "$J" | grep -c '^- old$')" 1
|
||||
bash "$MEM" journal "$(printf 'a\nb')" 2>/dev/null
|
||||
check T4d-multi-line "$?" 2
|
||||
bash "$MEM" journal 'grep \bword\b w/ \n'
|
||||
check T4e-backslash-verbatim "$(tail -1 "$J")" '- grep \bword\b w/ \n'
|
||||
|
||||
# T5 --supersedes: forward link on the new entry, status line on the old one
|
||||
L=.claude/memory/learnings.md
|
||||
new=$(bash "$MEM" add learning --title 'better' --body-file plain.md \
|
||||
--supersedes LRN-001)
|
||||
check T5-id "$new" LRN-002
|
||||
check T5b-forward "$(tail -1 "$L")" 'Supersedes [[LRN-001]].'
|
||||
word() { # <file> <ID> → the entry's status word, through the lib
|
||||
# shellcheck source=/dev/null
|
||||
(. "$MEM"; memory_status_word "$(memory_entry_status "$1" "$2")")
|
||||
}
|
||||
check T5c-old-status "$(word "$L" LRN-001)" superseded
|
||||
check T5d-index "$(bash "$MEM" index learning | grep -c '^| LRN-001 | 2026-10-27 | t | superseded |$')" 1
|
||||
|
||||
# T6 lock: a held lock refuses, a stale one is stolen, concurrent adds get
|
||||
# distinct IDs
|
||||
lock="$(git rev-parse --git-common-dir)/memory.lock"
|
||||
date +%s > "$lock"
|
||||
sum=$(cksum < .claude/memory/evals.md)
|
||||
MEM_LOCK_TRIES=2 bash "$MEM" add eval --title t --body-file plain.md 2>/dev/null
|
||||
check T6-held-rc "$?" 2
|
||||
check T6b-held-unchanged "$(cksum < .claude/memory/evals.md)" "$sum"
|
||||
echo $(( $(date +%s) - 60 )) > "$lock"
|
||||
check T6c-stale-stolen "$(bash "$MEM" add eval --title t --body-file plain.md)" EVAL-001
|
||||
check T6d-lock-released "$([ -e "$lock" ] && echo held || echo free)" free
|
||||
for i in 1 2 3 4 5; do
|
||||
bash "$MEM" add decision --title "d$i" --body-file plain.md > "out$i" &
|
||||
done
|
||||
wait
|
||||
check T6e-distinct "$(cat out1 out2 out3 out4 out5 | sort -u | wc -l | tr -d ' ')" 5
|
||||
check T6f-max "$(cat out1 out2 out3 out4 out5 | sort | tail -1)" BDR-005
|
||||
check T6g-check-green "$(bash "$MEM" check; echo $?)" 0
|
||||
|
||||
# T7 check: shape, duplicate, Index in v2 are rc 2; v1 is named, not failed
|
||||
cp .claude/memory/decisions.md d.bak
|
||||
printf '\n## BDR-005 — again\nx\n' >> .claude/memory/decisions.md
|
||||
err=$(bash "$MEM" check 2>&1 >/dev/null); rc=$?
|
||||
check T7-duplicate-rc "$rc" 2
|
||||
check T7b-duplicate-named "$(printf '%s\n' "$err" | grep -c 'duplicate BDR-005')" 1
|
||||
cat d.bak > .claude/memory/decisions.md
|
||||
printf '\n## BDR-7 — short\nx\n' >> .claude/memory/decisions.md
|
||||
bash "$MEM" check 2>/dev/null
|
||||
check T7c-shape-rc "$?" 2
|
||||
cat d.bak > .claude/memory/decisions.md
|
||||
printf '\n## Index\n' >> .claude/memory/decisions.md
|
||||
bash "$MEM" check 2>/dev/null
|
||||
check T7d-index-in-v2-rc "$?" 2
|
||||
cat d.bak > .claude/memory/decisions.md
|
||||
mkdir v1 && printf '# Decisions\n\n## BDR-001 - legacy\n' > v1/decisions.md
|
||||
err=$(bash "$MEM" check v1 2>&1 >/dev/null); rc=$?
|
||||
check T7e-v1-rc "$rc" 0
|
||||
check T7f-v1-named "$(printf '%s\n' "$err" | grep -c '^memory: v1: v1/decisions.md$')" 1
|
||||
printf '\n## BDR-006 — fenced\n```\nx\n' >> .claude/memory/decisions.md
|
||||
err=$(bash "$MEM" check 2>&1 >/dev/null); rc=$?
|
||||
check T7g-open-fence-rc "$rc" 2
|
||||
check T7h-open-fence-named "$(printf '%s\n' "$err" | grep -c 'fence open at end')" 1
|
||||
cat d.bak > .claude/memory/decisions.md
|
||||
# a duplicate a merge left behind blocks neither add nor a staged append
|
||||
printf '\n## BDR-005 — merged twice (2026-10-27)\nx\n' >> .claude/memory/decisions.md
|
||||
check T7i-dup-still-adds "$(bash "$MEM" add decision --title after --body-file plain.md)" BDR-006
|
||||
check T7j-dup-still-reported "$(bash "$MEM" check >/dev/null 2>&1; echo $?)" 2
|
||||
git add -A && git commit -qm dup
|
||||
bash "$MEM" add decision --title later --body-file plain.md >/dev/null
|
||||
git add .claude/memory/decisions.md
|
||||
check T7k-dup-staged-append "$(bash "$MEM" check --staged >/dev/null 2>&1; echo $?)" 0
|
||||
git reset -q
|
||||
cat d.bak > .claude/memory/decisions.md
|
||||
|
||||
# T8 check --staged: an append passes, a removed entry line is rc 2
|
||||
git add -A && git commit -qm base
|
||||
bash "$MEM" add blocker --title three --body-file body.md >/dev/null
|
||||
git add "$B"
|
||||
check T8-append-staged "$(bash "$MEM" check --staged; echo $?)" 0
|
||||
git commit -qm three
|
||||
sed 's/^## BLK-001 — make red/## BLK-001 — make RED/' "$B" > b.tmp \
|
||||
&& cat b.tmp > "$B"
|
||||
git add "$B"
|
||||
err=$(bash "$MEM" check --staged 2>&1 >/dev/null); rc=$?
|
||||
check T8b-removed-line-rc "$rc" 2
|
||||
check T8c-named "$(printf '%s\n' "$err" | grep -c 'removed inside an entry')" 1
|
||||
git checkout -q HEAD -- "$B"
|
||||
cp "$B" b.keep
|
||||
sed '/^format: 2$/d' b.keep > "$B" && git add "$B"
|
||||
check T8d-downgrade-refused "$(bash "$MEM" check --staged >/dev/null 2>&1; echo $?)" 2
|
||||
git rm -q --cached "$B"
|
||||
check T8e-deletion-refused "$(bash "$MEM" check --staged >/dev/null 2>&1; echo $?)" 2
|
||||
git reset -q && cat b.keep > "$B"
|
||||
|
||||
# T9 upgrade: Index-only dates and statuses become body lines, the marker
|
||||
# lands, the Index goes, headings untouched; idempotent; refusals keep the file
|
||||
mkdir -p up/.claude/memory && cd up || exit 1
|
||||
cat > .claude/memory/decisions.md <<'EOF'
|
||||
---
|
||||
type: decisions_registry
|
||||
entry_prefix: BDR
|
||||
---
|
||||
|
||||
# Decisions registry (BDR)
|
||||
|
||||
## Index
|
||||
|
||||
| ID | Date | Title | Status |
|
||||
|----|------|-------|--------|
|
||||
| BDR-001 | 2026-01-01 | kept | accepted |
|
||||
| BDR-002 | 2026-01-02 | stale index | accepted |
|
||||
| BDR-003 | 2026-01-03 | gone | superseded by BDR-004 |
|
||||
| BDR-004 | 2026-01-04 | no status | accepted |
|
||||
| BDR-005 | 2026-01-05 | suffix date | accepted |
|
||||
|
||||
---
|
||||
|
||||
## BDR-001 — kept (2026-01-01)
|
||||
- **Status**: accepted
|
||||
|
||||
## BDR-002 — stale index
|
||||
- **Date**: 2026-01-02
|
||||
- **Status**: shipped
|
||||
|
||||
## BDR-003 — gone
|
||||
- **Status**: accepted
|
||||
|
||||
## BDR-004 — no status
|
||||
body
|
||||
|
||||
## BDR-005 — suffix date — 2026-01-05
|
||||
- **Status**: accepted
|
||||
EOF
|
||||
cat > .claude/memory/learnings.md <<'EOF'
|
||||
---
|
||||
type: learnings_registry
|
||||
entry_prefix: LRN
|
||||
---
|
||||
|
||||
# Learnings registry (LRN)
|
||||
|
||||
## Index
|
||||
|
||||
| ID | Date | Pattern | Applies to |
|
||||
|----|------|---------|------------|
|
||||
| LRN-001 | 2026-02-01 | old | superseded by LRN-002 |
|
||||
| LRN-002 | 2026-02-02 | new | any shell |
|
||||
|
||||
## LRN-001 — old
|
||||
x
|
||||
|
||||
## LRN-002 — new
|
||||
y
|
||||
EOF
|
||||
D=.claude/memory/decisions.md
|
||||
heads=$(grep '^## BDR-' "$D")
|
||||
err=$(bash "$MEM" upgrade 2>&1 >/dev/null); rc=$?
|
||||
check T9-rc "$rc" 0
|
||||
check T9n-dropped-named "$(printf '%s\n' "$err" | grep -c '^memory: BDR-002: kept body shipped, dropped Index accepted$')" 1
|
||||
check T9b-marker "$(sed -n 2p "$D")" 'format: 2'
|
||||
check T9c-no-index "$(grep -c '^## Index$\|^| BDR-' "$D")" 0
|
||||
check T9d-headings-same "$(grep '^## BDR-' "$D")" "$heads"
|
||||
check T9e-index-out "$(bash "$MEM" index decision | sed -n '5,8p' | tr '\n' '#')" \
|
||||
'| BDR-001 | 2026-01-01 | kept | accepted |#| BDR-002 | 2026-01-02 | stale index | shipped |#| BDR-003 | 2026-01-03 | gone | superseded |#| BDR-004 | 2026-01-04 | no status | accepted |#'
|
||||
for loc in C en_US.UTF-8; do
|
||||
check "T9r-suffix-date-$loc" "$(LC_ALL=$loc bash "$MEM" index decision | grep -c '^| BDR-005 | 2026-01-05 | suffix date | accepted |$')" 1
|
||||
done
|
||||
check T9f-lrn-superseded "$(bash "$MEM" index learning | grep -c '^| LRN-001 | 2026-02-01 | old | superseded |$')" 1
|
||||
check T9g-lrn-applies-dropped "$(grep -c 'any shell' .claude/memory/learnings.md)" 0
|
||||
check T9h-check-green "$(bash "$MEM" check; echo $?)" 0
|
||||
sum=$(cksum < "$D")
|
||||
bash "$MEM" upgrade >/dev/null 2>&1
|
||||
check T9i-idempotent "$(cksum < "$D")" "$sum"
|
||||
cat > .claude/memory/blockers.md <<'EOF'
|
||||
---
|
||||
type: blockers_registry
|
||||
entry_prefix: BLK
|
||||
---
|
||||
|
||||
## Index
|
||||
|
||||
| ID | Date | Friction | Status |
|
||||
|----|------|----------|--------|
|
||||
| BLK-001 | 2026-03-01 | dup | open |
|
||||
|
||||
## BLK-001 — dup
|
||||
- **Status**: open
|
||||
|
||||
## BLK-001 — dup again
|
||||
EOF
|
||||
sum=$(cksum < .claude/memory/blockers.md)
|
||||
bash "$MEM" upgrade >/dev/null 2>&1
|
||||
check T9j-oracle-refuses "$?" 2
|
||||
check T9k-refused-untouched "$(cksum < .claude/memory/blockers.md)" "$sum"
|
||||
printf '# Evals\n\n## EVAL-001 | 2026 | pipe dialect\n' > .claude/memory/evals.md
|
||||
bash "$MEM" upgrade >/dev/null 2>&1
|
||||
check T9l-no-frontmatter-rc "$?" 2
|
||||
check T9m-dialect-untouched "$(sed -n 1p .claude/memory/evals.md)" '# Evals'
|
||||
printf -- '---\ntype: evals_registry\nentry_prefix: EVAL\n---\n\n## Index\n\n| ID | Date | Output | Action |\n|----|------|--------|--------|\n\n## EVAL-001 - hyphen dialect\nx\n' \
|
||||
> .claude/memory/evals.md
|
||||
err=$(bash "$MEM" upgrade 2>&1 >/dev/null)
|
||||
check T9o-hyphen-refused "$(printf '%s\n' "$err" | grep -c 'heading dialect " - ": not upgraded')" 1
|
||||
printf -- '---\ntype: evals_registry\nentry_prefix: EVAL\n---\n\n## Index\n\n| ID | Date | Output | Action |\n|----|------|--------|--------|\n\n## EVAL-001 — empty index (2026-04-01)\nx\n' \
|
||||
> .claude/memory/evals.md
|
||||
bash "$MEM" upgrade >/dev/null 2>&1
|
||||
check T9p-empty-index-upgraded "$(sed -n 2p .claude/memory/evals.md)" 'format: 2'
|
||||
check T9q-empty-index-heading "$(grep -c '^## EVAL-001 — empty index' .claude/memory/evals.md)" 1
|
||||
cd "$FIX" || exit 1
|
||||
|
||||
# T10 parser: header tag and labelled lines only, last wins, open ranks last
|
||||
cp "$ROOT/lib/tests/fixtures/blockers-v2-status.md" st.md
|
||||
check T10-header-tag "$(word st.md BLK-032)" resolved
|
||||
check T10b-prose-open-ignored "$(word st.md BLK-033)" resolved
|
||||
check T10c-fail-open-ignored "$(word st.md BLK-034)" resolved
|
||||
check T10d-final-wins "$(word st.md BLK-008)" resolved
|
||||
check T10e-accepted-before-open "$(word st.md BLK-040)" accepted
|
||||
check T10f-mid-title-bracket "$(word st.md BLK-041)" open
|
||||
check T10h-title-prose-ignored "$(word st.md BLK-043)" open
|
||||
check T10i-dated-lead-word "$(word st.md BLK-044)" open
|
||||
# shellcheck source=/dev/null
|
||||
check T10j-tag-only "$(. "$MEM"; memory_entry_status st.md BLK-043)" '[open]'
|
||||
closed() { # <word> → yes when memory_closed accepts it
|
||||
# shellcheck source=/dev/null
|
||||
(. "$MEM"; memory_closed "$1") && echo yes || echo no; }
|
||||
check T10k-closed "$(closed resolved)$(closed superseded)$(closed deprecated)" yesyesyes
|
||||
check T10l-not-closed "$(closed accepted)$(closed open)$(closed upstream)" nonono
|
||||
mkdir -p v1h/.claude/memory
|
||||
printf '# Blockers\n\n## BLK-001 - hyphen\n- **Status**: resolved\n\n## BLK-002 | 2026-05-18 | pipe\nStatus: open\n' \
|
||||
> v1h/.claude/memory/blockers.md
|
||||
check T10m-hyphen-dialect "$(word v1h/.claude/memory/blockers.md BLK-001)" resolved
|
||||
check T10n-pipe-dialect "$(word v1h/.claude/memory/blockers.md BLK-002)" open
|
||||
bash "$MEM" -C v1h status BLK-002 'resolved by abc' 2>/dev/null
|
||||
check T10o-status-on-v1-pipe "$(word v1h/.claude/memory/blockers.md BLK-002)" resolved
|
||||
# shellcheck source=/dev/null
|
||||
(. "$MEM"; memory_entry_status st.md BLK-042) >/dev/null
|
||||
check T10g-no-candidate-rc "$?" 1
|
||||
|
||||
# T11 -C runs from elsewhere
|
||||
check T11-dash-C "$(cd / && bash "$MEM" -C "$FIX" index blocker | grep -c '^| BLK-00')" 3
|
||||
bash "$MEM" -C /nonexistent check 2>/dev/null
|
||||
check T11b-bad-dir "$?" 2
|
||||
bash "$MEM" frobnicate 2>/dev/null
|
||||
check T11c-usage "$?" 2
|
||||
|
||||
# T14 r3: any-level ID allocation, open fence refused, v1 status as a body
|
||||
# line, token lock, empty-lock steal, journal exact key, --staged dir
|
||||
cd "$FIX" || exit 1
|
||||
mkdir -p h3/.claude/memory && cd h3 || exit 1
|
||||
printf '# Decisions\n\n### BDR-001 — a\nx\n\n### BDR-007 — b\ny\n' \
|
||||
> .claude/memory/decisions.md
|
||||
check T14-h3-next "$(bash "$MEM" add decision --title c --body-file "$FIX/plain.md" 2>/dev/null)" BDR-008
|
||||
printf '# Blockers\n\n## BLK-001 - legacy\n- Status: open\n' \
|
||||
> .claude/memory/blockers.md
|
||||
bash "$MEM" add blocker --title fixed --body-file "$FIX/body.md" \
|
||||
--status resolved >/dev/null 2>&1
|
||||
check T14b-v1-no-tag "$(grep -c '^## BLK-002 — fixed (2026-10-27)$' .claude/memory/blockers.md)" 1
|
||||
check T14c-v1-status-line "$(sed -n '/^## BLK-002/{n;p;}' .claude/memory/blockers.md)" '- **Status**: resolved'
|
||||
bash "$MEM" add blocker --title t --body-file "$FIX/body.md" --status fixed 2>/dev/null
|
||||
check T14d-status-word-required "$?" 2
|
||||
cd "$FIX" || exit 1
|
||||
cp .claude/memory/evals.md e.bak
|
||||
printf '\n```\nunclosed\n' >> .claude/memory/evals.md
|
||||
sum=$(cksum < .claude/memory/evals.md)
|
||||
bash "$MEM" add eval --title t --body-file plain.md >/dev/null 2>&1
|
||||
check T14e-open-fence-refused "$?" 2
|
||||
check T14f-open-fence-untouched "$(cksum < .claude/memory/evals.md)" "$sum"
|
||||
cat e.bak > .claude/memory/evals.md
|
||||
lock="$(git rev-parse --git-common-dir)/memory.lock"
|
||||
echo "$(date +%s) someone.1" > "$lock"
|
||||
# shellcheck source=/dev/null
|
||||
(. "$MEM"; _mem_unlock "$lock" me.2)
|
||||
check T14g-foreign-token-kept "$(cut -d' ' -f2 "$lock")" someone.1
|
||||
: > "$lock"
|
||||
check T14h-empty-lock-stolen "$(bash "$MEM" add eval --title e --body-file plain.md)" EVAL-002
|
||||
echo "$(( $(date +%s) - 60 )) dead.1" > "$lock"
|
||||
for i in 1 2 3 4 5 6 7 8 9 10 11 12; do
|
||||
bash "$MEM" add learning --title "r$i" --body-file plain.md > "lr$i" &
|
||||
done
|
||||
wait
|
||||
check T14i-twelve-distinct "$(cat lr1 lr2 lr3 lr4 lr5 lr6 lr7 lr8 lr9 lr10 lr11 lr12 | sort -u | wc -l | tr -d ' ')" 12
|
||||
check T14j-no-lock-left "$([ -e "$lock" ] || [ -e "$lock.steal" ] && echo left || echo none)" none
|
||||
check T14k-check-green "$(bash "$MEM" check; echo $?)" 0
|
||||
J=.claude/memory/journal.md
|
||||
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'
|
||||
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
|
||||
check T14o-no-restore-noise "$(tr -d ' ' < rs)" 0
|
||||
|
||||
# T12 this repo's registries pass the check
|
||||
check T12-live-check "$(bash "$MEM" -C "$ROOT" check >/dev/null 2>&1; echo $?)" 0
|
||||
|
||||
echo "PASS=$pass FAIL=$fail"
|
||||
[ "$fail" -eq 0 ]
|
||||
Reference in new issue
Block a user