Merge feature/memory-v2-minors into develop
This commit is contained in:
commit
c92381e492
14 files changed
+469
-78
No files matched your search
@@ -1450,3 +1450,12 @@ Branch feature/user-writing-web-rules, UNMERGED (human gate).
|
||||
- **Why**: user "il faut que ça soit systématique" (option A, 2026-10-29); BLK-037.
|
||||
- **Rejected**: 8 rows in one ask (engine cap 2-4, LRN-242); native picker + pin-conflict alert only (option B, not systematic); gateway-id normalization (would switch on routing in a gateway session).
|
||||
- **Supersedes**: BDR-126 "no args → native picker untouched". Live proof 2026-10-29: opus → [1m] → This project wrote `claude-opus-5-5[1m]`. Contract `.claude/tasks/contracts/2026-10-29-bare-model-dialog-1617.md`.
|
||||
|
||||
## BDR-133 — Negated status word in clause does not count, shared v1/v2 negation helper [accepted] (2026-11-01)
|
||||
**Context**: v2 parser + v1 legacy reader read `Status: not resolved yet` as resolved (phase 4a minor, robin_petier EVAL-005 `keep, … not accepted until …` read accepted). User pick 2026-10-31/11-01.
|
||||
|
||||
**Decision**: status word negated in its clause does not count. Negator `not|no|never|pas`, at most one word between negator and word, no clause boundary `, ; . : ( ) -> → —` between. Next non-negated occurrence still counts. One helper `mem_has` in `_MEM_AWK`, shared by `mem_word` (v2) and `_mem_v1_word` (v1), so `upgrade` refuses such v1 closure ("unlabelled, mixed or negated line") instead of cementing resolved. Word = maximal `[a-z0-9]` run, loop not ERE interval (BWK awk).
|
||||
|
||||
**Alternatives**: ignore negation (keeps false closures); line-scope negation (`resolved, not open` would read none: wrong); NLP (no).
|
||||
|
||||
**Consequences**: real-data replay 14 repos → 1 move (robin_petier EVAL-005 accepted → keep). mawk run in T17 guards BWK-class awk.
|
||||
@@ -677,3 +677,6 @@ rules:
|
||||
- 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).
|
||||
- Step 2 suites: /hotfix 40a993c (absolute ~/.claude/rules paths in interviewer + guardrails) + 7899670 (analyzer memory field dropped), security PASS x2. Measured design hook: 59 fires, 0 web-building Reads (no once-per-session). Probe: Bash sed -n loads path rules like Read. Census blind spots: 0 real citations.
|
||||
- /feat citers-blind-spots 5bd0de4: census reads nested lib paths, home prefixes, templates/project-rules, citer-aware .claude/rules; 3 lenses + confirmation (0 BLOCKER), verifier ECARTS x1 (SC2088/SC2016 suppressions) → fixtures rewritten, CONFORME, security PASS. /hotfix 3330f0b geo/seo '(dispatcher applies)'.
|
||||
|
||||
## 2026-11-01
|
||||
- memory-v2-minors /feat shipped (e4fb8f7 + 48ade8f): negated status words, dead empty steal, body `## ` refused, blob rc 1/2, rc 6 names dropped partial stages, reflow. Verifier CONFORME, security PASS, replay 14 repos = 1 expected move. Docs synced. Next: doc half, then phase 5 spikes.
|
||||
@@ -1867,3 +1867,17 @@ Rule: when editing a doctrine file under structure locks, grep the test's lock s
|
||||
- **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]]).
|
||||
|
||||
## LRN-246 — Reflow proof: declare -f / declare -p diff, string splits executed on fixture (2026-11-01)
|
||||
**Context**: A9 reflow of reconcile.sh + memory-commit.sh (39 lines > 80 bytes) had to prove zero behaviour change (memory-v2-minors 48ade8f).
|
||||
|
||||
**Pattern**: proof = `bash -c '. lib/x.sh; declare -f; declare -p <consts>'` before vs after, diff. Comment reflow and pipe/`&&` breaks normalize away. Surviving hunk = string split: review by hand, execute both versions on fixture, compare md5. Source old copy next to CURRENT deps so diff isolates the reflow.
|
||||
|
||||
**Application**: any cosmetic reflow of a sourceable shell lib; name the proof in the contract criterion, verifier reproduces it.
|
||||
|
||||
## LRN-247 — awk match() in shared helper clobbers caller RSTART, take substr first (2026-11-01)
|
||||
**Context**: `mem_has` (negation helper) calls awk `match()`; `mem_tag` read `RSTART` after calling `mem_word` → `mem_has`, T10h/T10j broke.
|
||||
|
||||
**Pattern**: awk `match()` sets globals `RSTART`/`RLENGTH`; shared helper calling it clobbers caller's values. Take `substr(line, RSTART)` BEFORE calling any parser helper; audit every `RSTART` reader in programs embedding the shared awk block.
|
||||
|
||||
**Application**: any `_MEM_AWK` change touching match(); same for `$0`, `NF` side effects of `sub()`/`split()` in helpers.
|
||||
@@ -33,7 +33,9 @@ Shared rules for every phase:
|
||||
- [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.
|
||||
- [x] Phase 4a parked minors, code half (/feat memory-v2-minors 2026-11-01, e4fb8f7 + 48ade8f: negated status words, dead empty steal, body `## ` refused at add, `_mem_blob` rc 1/2, rc 6 names dropped partial stages, reflow; A2 Index comment-edge + A7 rc 6 upgrade wording dropped as moot, 0 `## Index` left outside faunosteo). Doc half still open, next line. Original 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.
|
||||
- [ ] Phase 4a minors, doc half (/feat): lib/capitalize-commit.md § WRITE `-C` + absolute `--body-file`; tour/deploy/audit-delta SKILL.md § WRITE pointer; templates/memory/evals.md "Later status" line; capitalize-commit.md:73-74 rc 6 text if affected.
|
||||
- [ ] memory.sh awk operand (security LOW 2026-11-01): a `--body-file` named `x=1.md` is read by awk as a variable assignment in `_mem_fence_open` and `_mem_body_heading` (stdin read, check bypassed; `cat` still inserts the body). Fix: `awk '…' < "$f"`. Also `_partial_stages` passes the path to `git ls-files -s --` as a glob pathspec (quote with `:(literal)`).
|
||||
- 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).
|
||||
- Status: `reconcile_blk_current_status` reads the own-header `[tag]` first, then "last status-bearing line wins" (one parser, shared by memory.sh status and reconcile). Fixes BLK-032..034 false-open; regression test on those three.
|
||||
@@ -48,12 +50,12 @@ Shared rules for every phase:
|
||||
- [ ] User step: delete the auto-memory leftovers by hand (`~/.claude/projects/-home-bchanot-Documents-{faunosteo,jeux-deploy,robin-petier}/memory/`); doctor warns until then.
|
||||
- [x] Remove the dead `memory: project` field from agents/analyzer.md (/hotfix 7899670, 2026-10-31).
|
||||
- [ ] Deferred (gate 2026-10-29): "Skill routing" lines → our skills' `description:` (phase 3 bullet said phase 1 cleanup).
|
||||
- [ ] Census blind spots: nested `lib/<dir>/x.md § Y`, templates/ and .claude/rules/ outside doctrine-citers. Measured 2026-10-31: 0 real citations in all three today (preventive).
|
||||
- [x] Census blind spots (2026-10-31, feature/citers-blind-spots 5bd0de4 → develop 4175401, T8a-T8h): nested `lib/<dir>/x.md § Y`, templates/ and .claude/rules/ outside doctrine-citers. Measured 2026-10-31: 0 real citations in all three today (preventive).
|
||||
- [x] Measure the design hook's "Read … first" re-Read cost (2026-10-31, transcripts since 789a2b2): 59 hook fires, 0 Read-tool reads of web-building.md, 8 Bash mentions (repo maintenance). Re-read cost ≈ 0 → no "once per session" needed.
|
||||
- [ ] Design hook false positives: the pointer is almost never followed, and it fires on non-design prompts (fired on the 2026-10-30 phase 4a memory-work prompt). Decide: tighten the trigger, or drop the hook now that web-building.md loads by path. User call, nothing coded.
|
||||
- [x] Probe Bash `sed -n` (2026-10-31, two `claude -p --model haiku` runs here, mods/model-router/.claude-plugin/plugin.json): Bash `sed -n` AND Read both log `path_glob_match` mods.md with that trigger file. Path rules load after a Bash read too; not isolated whether the harness or the rtk rewrite triggers it.
|
||||
- [x] Minor: relative rule paths in interviewer.md / guardrails SKILL.md → `~/.claude/rules/` (/hotfix 40a993c).
|
||||
- [ ] Agent description losses: user pick 2026-10-31 = restore "(dispatcher applies)" on geo-analyzer + seo-analyzer only; the rest closed (bodies keep it).
|
||||
- [x] Agent description losses (3330f0b): user pick 2026-10-31 = restore "(dispatcher applies)" on geo-analyzer + seo-analyzer only; the rest closed (bodies keep it).
|
||||
- [x] robin_petier `chore/memory-lan-server` (BDR-075): merged 2026-10-29 (6877443).
|
||||
- Facts 2026-10-24 (scratchpad pathtest, memtest): a `paths:` rule loads on Read of a matching file, NOT on Write of a new file; `"autoMemoryEnabled": false` removes the auto-memory system section; classic SessionStart / UserPromptSubmit hooks inject additionalContext; instruction files reload on compaction natively. `hooks/design-toolchain-reminder.sh` fired 2,131 times (16 to 210 per day); `brainstorming` is vendored and gitignored (.gitignore:78), an edit there does not persist.
|
||||
- Section → carrier:
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
# CONTRACT — memory-v2-minors
|
||||
|
||||
## REQUEST (verbatim — IMMUTABLE)
|
||||
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.
|
||||
|
||||
## CLARIFICATIONS
|
||||
- 2026-10-31 user: a status word negated by not/no/never/pas (same clause: no `, ; . : ( ) ->` between, at most one word between) is ignored; `memory.sh add` refuses a body holding an unfenced `## ` line; rc 6 keeps today's reset and names the paths whose partial stage was dropped.
|
||||
- Scope split (main loop): this contract = the code half (plan A1-A9). The doc half (`-C` + `--body-file` in § WRITE, tour/deploy/audit-delta pointer, evals template "Later status") is a separate /feat.
|
||||
- Plan r3: `.claude/tasks/plans/2026-10-31-memory-v2-minors-0400.md` (block T17, not T16; § R3 overrides r2).
|
||||
- 2026-11-01 user: A2 (Index comment-edge) and A7 (rc 6 upgrade wording) dropped as moot (0 `## Index` left outside faunosteo).
|
||||
|
||||
## ACCEPTANCE CRITERIA
|
||||
1. The memory suite and the memory-commit deterministic suite are green and hold the new checks (T17-steal-empty-dead, T17-steal-empty-fresh, T17-negated-status, T17-upgrade-negated-refused, T17-add-body-heading-refused, T17-add-body-heading-fenced, T17-blob-absent, T17-blob-read-error; run-deterministic "rc 6 names a dropped partial stage").
|
||||
CHECK: cd /home/bchanot/Documents/claude && a=$(make test suite=lib/tests/memory.test.sh 2>&1) && printf '%s\n' "$a" | grep -q 'FAIL=0' && b=$(make test suite=lib/tests/run-deterministic.sh 2>&1) && printf '%s\n' "$b" | grep -q 'all suites green' && for n in T17-steal-empty-dead T17-steal-empty-fresh T17-negated-status T17-upgrade-negated-refused T17-add-body-heading-refused T17-add-body-heading-fenced T17-blob-absent T17-blob-read-error; do grep -q "$n" lib/tests/memory.test.sh || exit 1; done && grep -q 'partial stage dropped on' lib/tests/run-deterministic.sh && echo MINORS-OK
|
||||
EXPECT: MINORS-OK
|
||||
EVIDENCE: MET exit=0 marker-found :: MINORS-OK
|
||||
2. reconcile suite green; lib/memory.sh, lib/memory-commit.sh and lib/reconcile.sh are shellcheck-clean and hold no line over 80 columns.
|
||||
CHECK: cd /home/bchanot/Documents/claude && r=$(make test suite=lib/tests/run-reconcile.sh 2>&1) && printf '%s\n' "$r" | grep -q ' 0 RED' && shellcheck lib/memory.sh lib/memory-commit.sh lib/reconcile.sh && [ "$(LC_ALL=C awk 'length($0) > 80' lib/memory.sh lib/memory-commit.sh lib/reconcile.sh | wc -l)" = 0 ] && echo LIB-LINT-OK
|
||||
EXPECT: LIB-LINT-OK
|
||||
EVIDENCE: MET exit=0 marker-found :: LIB-LINT-OK
|
||||
3. Real data: `memory.sh -C <repo> index` over the 14 repos holding registries is identical before and after, except robin_petier EVAL-005 (`accepted` → `keep`, expected) and any other move named in the report. Judged by the verifier from the main loop's replay.
|
||||
4. Each fix check fails on develop's lib (T17-negated-status: at least the r3 biting cases); the over-reach guards (T17-steal-empty-fresh, T17-add-body-heading-fenced) fail on their named mutant instead (`-mmin +0`, fence-blind scan). Executor reports the controls; judged by the verifier.
|
||||
|
||||
5. The reflow (plan A9) changes no behaviour: `declare -f` / `declare -p RECONCILE_DEFER_RE` of reconcile.sh and memory-commit.sh are byte-identical before and after (executor reports the diff). Judged by the verifier.
|
||||
|
||||
## FILE SCOPE
|
||||
- lib/memory.sh
|
||||
- lib/memory-commit.sh
|
||||
- lib/reconcile.sh
|
||||
- lib/tests/memory.test.sh
|
||||
- lib/tests/run-deterministic.sh
|
||||
@@ -0,0 +1,149 @@
|
||||
# /feat memory-v2-minors (code) — PLAN r3 (r3 overrides r2 where they differ: see § R3)
|
||||
|
||||
r2 2026-10-31 after 3 lenses: robustness FATAL(5), correctness CONCERNS(4),
|
||||
simplicity CONCERNS(2). User picks 2026-10-31: (a) negated status word ignored,
|
||||
scope = same clause (no `, ; . : ( ) ->` between negator and word, at most one word
|
||||
between); (b) `memory.sh add` refuses an unfenced body `## ` line; (c) rc 6 keeps
|
||||
today's reset (nothing left staged) and NAMES the paths whose partial stage was lost.
|
||||
|
||||
FEAT: phase 4a parked minors, code half — 5 files: lib/memory.sh,
|
||||
lib/memory-commit.sh, lib/reconcile.sh, lib/tests/memory.test.sh,
|
||||
lib/tests/run-deterministic.sh. Doc half (capitalize-commit § WRITE `-C` +
|
||||
absolute `--body-file`, tour/deploy/audit-delta pointers, evals template "Later
|
||||
status") = separate /feat.
|
||||
|
||||
## Plan (two commits: C1 behaviour A1-A8, C2 cosmetic A9)
|
||||
- [ ] A1 `_mem_steal`: an EMPTY `memory.lock.steal` (stealer killed between its
|
||||
noclobber create and its `date` write) is dead when older than 60 s:
|
||||
`"$MEM_FIND" "$g" -prune -mmin +1` with `MEM_FIND="${MEM_FIND:-/usr/bin/find}"`
|
||||
pinned like MEM_GREP (the harness shell wraps `find` in a function; GNU and BSD
|
||||
`-mmin +1` both mean > 60 s; not POSIX, present on GNU/BSD/busybox). A non-empty
|
||||
steal file keeps the 30 s rule. Header lines 35-38 gain the dead-stealer rule.
|
||||
`shortcut:` comment on the pre-existing check-then-rm window (another waiter may
|
||||
remove + a new stealer recreate between the read and `rm -f "$g"`; upgrade path
|
||||
= compare content just before rm).
|
||||
- [ ] A2 ONE Index-section walker. `_mem_index_table` becomes the single reader of
|
||||
the `## Index` span with the gate's bounds (skip `<!-- … -->` lines and blocks;
|
||||
the span ends at `^#`, `^---$`, or a blank line after the table) and returns rc 1
|
||||
when the span holds a non-table line. `_mem_upgrade_ready` calls it (`> /dev/null`)
|
||||
and `_mem_index_only_table` is deleted. The Index remover inside
|
||||
`_mem_upgrade_text` (~576-580) uses the SAME bounds (shared `_MEM_AWK` function
|
||||
`mem_index_span(line)` or equivalent state machine), so the gate, the row source
|
||||
and the remover cannot disagree.
|
||||
- [ ] A3 header (lines 17-26, `upgrade`): "a `## Index` that is not a table is
|
||||
refused (rc 2)".
|
||||
- [ ] A4 ONE negation-aware occurrence test in `_MEM_AWK` (`mem_has(t, w)`): an
|
||||
occurrence of status word w counts unless a negator `not|no|never|pas` precedes
|
||||
it in the same clause — no `,` `;` `.` `:` `(` `)` `->` between them — with at
|
||||
most one word between. The next non-negated occurrence still counts. Used by
|
||||
`mem_word` AND `_mem_v1_word` (pass `$_MEM_AWK` in), so a v1 `Status: not
|
||||
resolved yet` has no closed word and the upgrade refuses it (named), never writes
|
||||
`resolved`.
|
||||
- [ ] A5 `memory_add`: refuse (rc 2, nothing written, before the lock) a body holding
|
||||
a `^## ` line outside a ``` fence: `memory: add: body line <N> starts with "## ":
|
||||
use "###" or indent it`. A fenced `## ` line is accepted.
|
||||
- [ ] A6 `_mem_blob`: `git cat-file blob "$1" > "$2" 2>/dev/null || return 1`
|
||||
(git exits 128 on an absent path; the function keeps rc 1). Header comment:
|
||||
"rc 1 when absent, out file empty". Drop the two `|| : > "$h"` / `|| : > "$s"`
|
||||
fallbacks only if the out file is provably empty on failure (it is: `>` truncates
|
||||
first); keep behaviour identical.
|
||||
- [ ] A7 `_mem_check_staged`: when HEAD's file is v1 and the staged one is v2, print
|
||||
ONCE per file `memory: <file>: v1 → v2 upgrade — heading rewrites are expected;
|
||||
commit it with /commit-change`, and per removed hunk keep "fix it" wording unless
|
||||
the removed HEAD line at `start` is an entry heading (`^#+ *PREFIX-[0-9]`), whose
|
||||
line then says `heading rewritten by the upgrade`. A body line removed in the
|
||||
same commit still says "fix it".
|
||||
- [ ] A8 memory-commit.sh rc 6 (user pick c): keep `git reset -q -- "${changed[@]}"`.
|
||||
Before `git add`, record the changed paths that already had a staged change
|
||||
differing from HEAD (`git diff --cached --name-only -- "${changed[@]}"`); on
|
||||
refusal, stderr adds `memory-commit: partial stage dropped on: <paths>` when that
|
||||
list is non-empty. "nothing left staged" stays true. Comments unchanged in meaning.
|
||||
- [ ] A9 (commit C2, cosmetic only): reconcile.sh stale comments (lines 24-25:
|
||||
status = lib/memory.sh shared parser on v2, legacy lexical on v1, "not closed" =
|
||||
resolved|superseded|deprecated; line 41-42: `## ID` headings only, v1 `###`
|
||||
entries invisible); reflow every line > 80 BYTES in reconcile.sh (32) and
|
||||
memory-commit.sh (7, two hold em-dashes) without behaviour change.
|
||||
RECONCILE_DEFER_RE value must stay byte-identical (assert: sourced value before
|
||||
== after).
|
||||
- [ ] Tests, lib/tests/memory.test.sh new block **T17** (T16 exists):
|
||||
T17-steal-empty-dead: plant a stale lock (`echo "$(( $(date +%s) - 60 )) dead.1" >
|
||||
"$lock"`), an empty `.steal` with `touch -t 202001010000`; an add → rc 0, `.steal`
|
||||
gone, lock released.
|
||||
T17-steal-empty-fresh: same stale lock, fresh empty `.steal`, `MEM_LOCK_TRIES=3`
|
||||
→ rc 2 "lock busy", `.steal` still there, registry byte-identical. Negative
|
||||
control = the `-mmin +0` mutant (fails this check), not develop.
|
||||
T17-index-comment-row: Index with a multi-line comment holding `| BDR-009 | … |`,
|
||||
then the real table, then a blank line and a stray `| X |` line: rows = only the
|
||||
real table; the UPGRADED file holds no `|` row and no `-->` above the first entry.
|
||||
T17-negated-status: `not resolved yet` → none; `open, not resolved yet` → open;
|
||||
`never superseded` → none; `resolved, not open` → resolved; `no repro,
|
||||
resolved` → resolved; `not yet resolved` → none; `(JS off -> no dialog),
|
||||
accepted` → accepted. Run once under `/usr/bin/mawk` via a PATH shim (BWK-class
|
||||
awk) when present.
|
||||
T17-upgrade-negated-refused (T15-style v1 fixture `Status: not resolved yet`
|
||||
under a v1 reader that reads it closed): upgrade rc 2, file byte-identical, ID
|
||||
named, no `upgrade)` line.
|
||||
T17-add-body-heading-refused: rc 2, registry byte-identical, message names the
|
||||
line. T17-add-body-heading-fenced: accepted (over-reach guard; negative control
|
||||
= a fence-blind scan mutant).
|
||||
T17-blob-absent: pre-filled out file, absent path → rc 1, out file empty.
|
||||
T17-upgrade-staged-message: staged v1→v2 upgrade → the once-per-file line + the
|
||||
heading wording; plus a body line removed in the same staged diff still says
|
||||
"fix it".
|
||||
lib/tests/run-deterministic.sh: "rc 6 names a dropped partial stage": stage
|
||||
version A of a v2 registry edit, write culprit version B to the worktree,
|
||||
commit → rc 6, stderr names the path, the index holds neither A nor B (nothing
|
||||
left staged).
|
||||
|
||||
## Real-data proof (main loop, before merge-ready)
|
||||
`memory.sh -C <repo> index` before/after A4 over every registry of the 12 repos
|
||||
holding one (Documents/{claude,config,faunosteo,game,integration_alphalink,
|
||||
robin_petier,zenquality}, repos/bchanot/{angelscar356,bchanot-cv,for_you,game-deploy,
|
||||
gitea-deploy,nuit-folle,trucks_at_work}); expected move: robin_petier EVAL-005
|
||||
`accepted` → `keep` (its `**Action**: keep, … A guard is not accepted until …` is a
|
||||
real misread today); any other move is reported, not waived.
|
||||
|
||||
## Contract criterion 4 amendment
|
||||
"Each fix check fails on develop's lib; the over-reach guards (T17-steal-empty-fresh,
|
||||
T17-add-body-heading-fenced) fail on their named mutant instead."
|
||||
|
||||
## Disposition
|
||||
Honors BDR-129 (single writer, ONE shared parser: A2 one walker, A4 one negation
|
||||
test for both readers), LRN-237 (oracle not sharing a narrowed reader blindly; assert
|
||||
on the upgraded entry; real-data replay across repos), LRN-244 (no new stream over a
|
||||
rewritten file), LRN-096 (each check bites).
|
||||
|
||||
## R3 (2026-11-01, confirmation robustness CONCERNS(4) folded, no further pass)
|
||||
User pick 2026-11-01: A2 and A7 DROPPED (closed as moot: 0 `## Index` left in the 14
|
||||
registry repos except faunosteo, whose upgrade passes the oracle on a copy). A3 stays.
|
||||
Delete from the plan and tests: A2, A7, T17-index-comment-row,
|
||||
T17-upgrade-staged-message. Changes to the kept items:
|
||||
- A1: dead = `[ -n "$("$MEM_FIND" "$g" -prune -empty -mmin +1 2>/dev/null)" ]`
|
||||
(find exits 0 either way: stdout decides; stderr silenced for a vanished file).
|
||||
`shortcut:` upgrade path = inode/mtime re-check just before rm (content cannot tell
|
||||
two empty files apart).
|
||||
- A4: a "word" = a maximal `[a-z0-9]` run; boundaries `, ; . : ( ) ->` plus `→` and
|
||||
`—`. No ERE interval expressions in `mem_has` (old BWK awks read `{0,1}` literally):
|
||||
count words with a loop. Refusal wording in `_mem_repair_one`: "v1 closed by an
|
||||
unlabelled, mixed or negated line". T17-negated-status adds biting cases:
|
||||
`not reproduced but resolved` → resolved (two words between), `not reproducible ->
|
||||
resolved` → resolved, `not; resolved` → resolved, `not → resolved` → resolved,
|
||||
`never — superseded` → superseded. The mawk run prints `SKIP mawk absent` when
|
||||
/usr/bin/mawk is missing and is called a "mawk run" (not BWK coverage).
|
||||
- A6: keep `git cat-file -e` for absent (rc 1); a failing `git cat-file blob` after a
|
||||
successful `-e` → rc 2; `_mem_check_staged` refuses (rc 2, named) on rc 2 instead of
|
||||
treating the file as new. T17-blob-absent asserts rc 1 + empty out; add
|
||||
T17-blob-read-error (a `git` PATH shim failing `cat-file blob` only → rc 2, check
|
||||
refuses).
|
||||
- A8: list = paths in `git diff --cached --name-only` (index≠HEAD) ∩ `git diff
|
||||
--name-only` (index≠worktree), computed before `git add`; for each, stderr
|
||||
`memory-commit: partial stage dropped on: <path> (blob <oid>; restore: git
|
||||
update-index --cacheinfo 100644,<oid>,<path>)` with the oid from `git ls-files -s`.
|
||||
The run-deterministic case asserts that literal line for the staged path, and that
|
||||
a FULLY staged file (index = worktree) is not listed.
|
||||
- A9: proof = `bash -c '. lib/reconcile.sh; declare -f; declare -p
|
||||
RECONCILE_DEFER_RE'` (and the same for memory-commit.sh functions) byte-identical
|
||||
before and after the reflow; any intended string split reviewed by hand.
|
||||
- Real-data replay: 14 repos (not 12).
|
||||
- awk state in `_MEM_AWK` helpers is namespaced (`_nx_*`) or kept local (function
|
||||
params): no new bare globals.
|
||||
+3
-3
@@ -19,15 +19,15 @@ 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/<project>/YYYY-MM-DD-<slug>.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 <dir>`) is the glob oracle for `.claude/rules/<name>.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 `'### <title>'`; 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, 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`.
|
||||
- **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 (a body line starting `## ` outside a code fence would split the entry and is refused, rc 2); `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, a mixed or a negated 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, non-negated word, at most one upgrade status line per entry). Writes run under a lock in the git common dir (a stale lock is stolen by one waiter at a time; a steal marker left empty over 60 s counts as a dead stealer and is cleared), 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
|
||||
- **model-router bare `/model` dialog**: a bare `/model` opens the router's dialog (model, variant, scope), so the scope question also comes when the pick is the current model (fable, opus, sonnet; a current haiku goes through `/model haiku`). Step 1 asks fable, opus, sonnet or `Other model (native picker)` (the native picker, run with the slot free so a pick inside it asks its scope); step 2 asks Standard or `[1m]`; step 3 is the existing scope question. Esc or free text changes nothing. Tests: `mods/model-router/hooks/register.test.ts`.
|
||||
- Registries are written only through `lib/memory.sh`, never by Edit (`CLAUDE.global.md`, Memory registries); every CAPITALIZE step (`/feat`, `/bugfix`, `/hotfix`, `/ship-feature`, `/capitalize`, `/init-project`, `/onboard`, `commit-changer`) writes through `lib/capitalize-commit.md` § WRITE.
|
||||
- `lib/memory-commit.sh commit` runs `memory.sh check --staged` first: a staged v2 registry that removes or rewrites a line inside an entry, gains a duplicate ID, a bad heading or an open fence, or is deleted or downgraded is unstaged and refused with rc 6; v1 registries are skipped.
|
||||
- `lib/memory-commit.sh commit` runs `memory.sh check --staged` first: a staged v2 registry that removes or rewrites a line inside an entry, gains a duplicate ID, a bad heading or an open fence, or is deleted or downgraded is unstaged and refused with rc 6; a HEAD or staged blob git cannot read is refused too, and stderr names each memory path whose separate partial stage the refusal dropped, with its blob id and `git update-index --cacheinfo` restore command; v1 registries are skipped.
|
||||
- `/prune-memory` drops its Index drift category (§ D): status fixes go through `memory.sh status`, merges through `memory.sh add --supersedes`, STEP 4 verifies with `memory.sh check` (`CHECK: OK`, was `INDEX SANITY: OK`).
|
||||
- `lib/reconcile.sh` reads blocker status through the parser shared with `lib/memory.sh`: on v2, a heading `[tag]` or a labelled status line, last candidate wins, resolved/superseded/deprecated closes the entry; the lexical reader is kept for v1. This repo's registries are upgraded to v2.
|
||||
- `lib/reconcile.sh` reads blocker status through the parser shared with `lib/memory.sh`: on v2, a heading `[tag]` or a labelled status line, last candidate wins, a status word negated in its clause (`not`, `no`, `never`, `pas`, at most one word between, no clause punctuation or arrow in between) does not count, resolved/superseded/deprecated closes the entry; the lexical reader is kept for v1. This repo's registries are upgraded to v2.
|
||||
- impeccable is the Build path for all UI: it replaces `frontend-design` on the design gate's `# GATE-BLOCK:` list and leads the Build line of the design doctrine. `frontend-design` stays installed as the light path for a one-off visual. Detector rule count corrected 45 to 61 (BDR-119).
|
||||
- model-router `verbose: true` logs transitions only: one line when main changes model or effort (`model-router: main: fable/high → fable/xhigh (plan: route tool)`), one hand-off line per dispatch and one per later effort move of an agent, each with its cause; the per-step, "answered by", spawn, route-tool and skill-path lines are gone. An agent answering on a model other than the planned one is said once. A non-boolean `verbose` falls back to `false`, said once.
|
||||
- `verifier` and `security-auditor` run on a new `audit` phase (best/xhigh: Fable, Opus when Fable is down). Their frontmatter floor is `model: opus` (the verifier was `sonnet`): a fable floor would spawn the gates on a dead model during a credit outage. `judge` (big/xhigh, opus) keeps plan-challenger, analyzer and plugin-advisor. The `about` lines of `judge` and `verify` no longer claim audits or security review. The census `lib/tests/effort-routing.test.sh` floors a best-tier agent row on the tier's second alias (opus).
|
||||
|
||||
+1
-1
@@ -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. 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`.
|
||||
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 that is not negated (`Status: not resolved yet` holds none). A blocker the v1 reader closed through prose, a mixed or a negated 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)
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ never by Edit or append; there is no `## Index` to update.
|
||||
- Journal: `bash "$HOME/.claude/lib/memory.sh" journal "<line>"`.
|
||||
- rc 2 names its reason (title chars, empty body, a status not starting
|
||||
with a status word, an open code fence in the body or the registry,
|
||||
an unfenced body line starting `## ` (use `###` or indent it),
|
||||
unknown ID, lock busy): fix the input and re-run.
|
||||
|
||||
## DO
|
||||
@@ -71,13 +72,17 @@ never by Edit or append; there is no `## Index` to update.
|
||||
- rc 5 → `git commit` rejected (hook, protected branch,
|
||||
signing); nothing committed, surface stderr.
|
||||
- rc 6 → `memory.sh check --staged` refused, nothing
|
||||
committed, nothing left staged. Two causes,
|
||||
committed, nothing left staged. Causes,
|
||||
named on stderr: a line removed inside an
|
||||
existing v2 entry (only appends pass), or a NEW
|
||||
culprit (duplicate ID, heading shape); an open
|
||||
existing v2 entry (only appends pass), a NEW
|
||||
culprit (duplicate ID, heading shape), or a
|
||||
HEAD or staged blob git cannot read; an open
|
||||
code fence counts even when it predates the
|
||||
commit. Fix the file, then commit the fix with
|
||||
/commit-change; never bypass the helper.
|
||||
commit. A path staged apart from its working
|
||||
tree loses that stage: stderr names it with
|
||||
its blob id and the git update-index restore
|
||||
command. Fix the file, then commit the fix
|
||||
with /commit-change; never bypass the helper.
|
||||
|
||||
`<mem_hash>` is the MEMORY commit (the one that ADDS the entries). It is NOT
|
||||
the code-commit hash that capitalize anchored INSIDE the entries
|
||||
|
||||
+32
-12
@@ -12,8 +12,9 @@
|
||||
# # 5 commit rejected, 6 check refused
|
||||
#
|
||||
# Output contract for `commit`: diagnostics go to stderr; on a real commit the
|
||||
# short hash of the MEMORY commit is the ONLY thing on stdout (empty on no-op or
|
||||
# unsafe), so callers can capture it: `mem_hash=$(memory-commit.sh commit "msg")`.
|
||||
# short hash of the MEMORY commit is the ONLY thing on stdout (empty on no-op
|
||||
# or unsafe), so callers can capture it:
|
||||
# `mem_hash=$(memory-commit.sh commit "msg")`.
|
||||
#
|
||||
# Sourceable: `commit_memory`.
|
||||
|
||||
@@ -49,8 +50,23 @@ _changed_paths() {
|
||||
done
|
||||
}
|
||||
|
||||
# Paths staged differently from HEAD AND from the worktree: `git add` below
|
||||
# overwrites that staged blob, a refusal then resets it. One line per path,
|
||||
# with the blob id, so the dropped partial stage can be restored by hand.
|
||||
_partial_stages() {
|
||||
local p mode oid
|
||||
while IFS= read -r p; do
|
||||
read -r mode oid _ < <(git ls-files -s -- "$p")
|
||||
echo "memory-commit: partial stage dropped on: $p (blob $oid;" \
|
||||
"restore: git update-index --cacheinfo $mode,$oid,$p)"
|
||||
done < <(comm -12 \
|
||||
<(git -c core.quotepath=off diff --cached --name-only -- "$@" | sort) \
|
||||
<(git -c core.quotepath=off diff --name-only -- "$@" | sort))
|
||||
}
|
||||
|
||||
# Surgical commit of the scoped paths only. Returns 0 (ok or no-op), 3 (unsafe).
|
||||
# On a real commit, prints the memory-commit short hash to stdout (stderr = diag).
|
||||
# On a real commit, prints the memory-commit short hash to stdout (stderr =
|
||||
# diag).
|
||||
commit_memory() {
|
||||
local msg="${1:?commit message required}"
|
||||
_in_git_repo || {
|
||||
@@ -58,18 +74,20 @@ commit_memory() {
|
||||
return 3
|
||||
}
|
||||
if _unsafe_state; then
|
||||
echo "memory-commit: detached HEAD or merge/rebase in progress — skip (no commit)" >&2
|
||||
echo "memory-commit: detached HEAD or merge/rebase in progress —" \
|
||||
"skip (no commit)" >&2
|
||||
return 3
|
||||
fi
|
||||
local changed
|
||||
local changed partial
|
||||
mapfile -t changed < <(_changed_paths)
|
||||
if [ "${#changed[@]}" -eq 0 ]; then
|
||||
echo "memory-commit: nothing pending — no-op" >&2
|
||||
return 0
|
||||
fi
|
||||
# Re-stage working-tree content of the scoped paths over any stale index entry,
|
||||
# then commit ONLY those paths. The pathspec on `git commit` makes it a partial
|
||||
# commit: other staged files (dangling code) are not recorded.
|
||||
# Re-stage working-tree content of the scoped paths over any stale index
|
||||
# entry, then commit ONLY those paths. The pathspec on `git commit` makes
|
||||
# it a partial commit: other staged files (dangling code) are not recorded.
|
||||
partial="$(_partial_stages "${changed[@]}")"
|
||||
git add -- "${changed[@]}"
|
||||
# Chokepoint (BDR-125 phase 4a): a staged v2 registry may only grow and
|
||||
# never gains a new culprit (duplicate ID, bad heading, open fence). v1
|
||||
@@ -78,6 +96,7 @@ commit_memory() {
|
||||
if [ -d .claude/memory ] \
|
||||
&& ! bash "$MC_MEMORY_SH" check --staged .claude/memory; then
|
||||
git reset -q -- "${changed[@]}"
|
||||
[ -z "$partial" ] || printf '%s\n' "$partial" >&2
|
||||
echo "memory-commit: REFUSED — memory.sh check --staged failed (above);" \
|
||||
"NOTHING committed, nothing left staged." >&2
|
||||
return 6
|
||||
@@ -89,10 +108,11 @@ commit_memory() {
|
||||
# Contract: diagnostics go to stderr; on success ONLY the memory-commit short
|
||||
# hash goes to stdout, so a caller can do `mem_hash=$(... commit "msg")`.
|
||||
# FAIL-LOUD on the commit itself. With `set -uo pipefail` (no -e), a rejected
|
||||
# commit (pre-commit hook on a protected branch, signing failure, …) would NOT
|
||||
# abort: the line below would falsely claim "committed" and rev-parse would
|
||||
# emit the PREVIOUS HEAD's hash with exit 0 — a silent masked failure. Reject
|
||||
# → loud, NO hash on stdout, exit 5 (mirrors doc-commit.sh's rc 5).
|
||||
# commit (pre-commit hook on a protected branch, signing failure, …) would
|
||||
# NOT abort: the line below would falsely claim "committed" and rev-parse
|
||||
# would emit the PREVIOUS HEAD's hash with exit 0 — a silent masked
|
||||
# failure. Reject → loud, NO hash on stdout, exit 5 (mirrors doc-commit.sh's
|
||||
# rc 5).
|
||||
if ! git commit -q -m "$msg" -- "${changed[@]}"; then
|
||||
{
|
||||
echo "memory-commit: COMMIT REJECTED — git commit exited non-zero" \
|
||||
|
||||
+57
-17
@@ -22,7 +22,8 @@
|
||||
# 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,
|
||||
# it with `status`, re-run); a `## Index` that is not a
|
||||
# table is refused (rc 2); the oracle (IDs, check,
|
||||
# verdicts, one upgrade line per entry) runs first, else rc 2
|
||||
# <kind> = decision | learning | blocker | eval. MEMORY_DATE overrides today.
|
||||
# Status of an entry: the last candidate wins. A candidate is the heading's
|
||||
@@ -31,11 +32,15 @@
|
||||
# prose (title included) is never one (the BLK-032..034 false-open). A dated
|
||||
# `**Status (YYYY-MM-DD…)**:` line reads its leading word; other lines rank
|
||||
# words in _MEM_WORDS order, `open` last: "accepted, check OPEN" = accepted.
|
||||
# A word negated in its clause ("not resolved yet", "never superseded") is
|
||||
# not one: not|no|never|pas, at most one word before it, no `, ; . : ( ) ->`
|
||||
# `→` `—` between (mem_has).
|
||||
# Closed = resolved | superseded | deprecated (memory_closed).
|
||||
# Lock: <git-common-dir>/memory.lock created under noclobber (flock(1) is
|
||||
# absent on macOS), holding "<epoch> <token>"; released only by its token;
|
||||
# a lock older than 30 s (or seen empty 10 times) is stolen by one waiter
|
||||
# at a time (memory.lock.steal). Every writer runs on a verified backup
|
||||
# at a time (memory.lock.steal; dead when it holds a date over 30 s old or
|
||||
# has stayed empty over 60 s). Every writer runs on a verified backup
|
||||
# of its file, restored on failure or signal. Next ID = max over headings
|
||||
# of any level, fenced or not. Free text reaches awk through ENVIRON,
|
||||
# never `-v` (which expands backslash escapes).
|
||||
@@ -43,6 +48,7 @@
|
||||
# absolute before any `-C` cd: a relative $0 no longer resolves after it
|
||||
_MEM_LIB_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
MEM_GREP="${MEM_GREP:-/usr/bin/grep}"
|
||||
MEM_FIND="${MEM_FIND:-/usr/bin/find}"
|
||||
_MEM_TABLE='decision decisions BDR
|
||||
learning learnings LRN
|
||||
blocker blockers BLK
|
||||
@@ -50,10 +56,22 @@ eval evals EVAL'
|
||||
_MEM_WORDS='resolved superseded deprecated upstream accepted implemented'
|
||||
_MEM_WORDS+=' shipped proposed keep correct deprecate open'
|
||||
_MEM_AWK='
|
||||
function mem_negated(pre, n, a) {
|
||||
gsub(/[,;.:()]|->|→|—/, "\001", pre); sub(/^.*\001/, "", pre)
|
||||
gsub(/[^a-z0-9]+/, " ", pre); n = split(pre, a, " ")
|
||||
return (n >= 1 && a[n] ~ /^(not|no|never|pas)$/) ||
|
||||
(n >= 2 && a[n - 1] ~ /^(not|no|never|pas)$/) }
|
||||
function mem_has(t, w, re, off, ws) {
|
||||
re = "(^|[^a-z])" w "([^a-z]|$)"; off = 0
|
||||
while (match(substr(t, off + 1), re)) {
|
||||
ws = off + RSTART
|
||||
if (substr(t, ws, 1) != substr(w, 1, 1)) ws++
|
||||
if (!mem_negated(substr(t, 1, ws - 1))) return 1
|
||||
off = ws + length(w) - 1 }
|
||||
return 0 }
|
||||
function mem_word(s, t, i, n, w) {
|
||||
t = tolower(s); n = split(MEMW, w, " ")
|
||||
for (i = 1; i <= n; i++)
|
||||
if (t ~ ("(^|[^a-z])" w[i] "([^a-z]|$)")) return w[i]
|
||||
for (i = 1; i <= n; i++) if (mem_has(t, w[i])) return w[i]
|
||||
return "" }
|
||||
function mem_lead(s, v, i, n, w) {
|
||||
v = s; sub(/^[^:]*\*\*: */, "", v); v = tolower(v)
|
||||
@@ -65,8 +83,9 @@ function mem_lineword(s, w) {
|
||||
return mem_word(s) }
|
||||
function mem_tag(line) {
|
||||
if (!match(line, /\[[^]]*\]( \([0-9-]+\))? *$/)) return ""
|
||||
if (mem_word(substr(line, RSTART)) == "") return ""
|
||||
line = substr(line, RSTART); sub(/\].*$/, "]", line); return line }
|
||||
line = substr(line, RSTART) # before mem_word: its match() moves RSTART
|
||||
if (mem_word(line) == "") return ""
|
||||
sub(/\].*$/, "]", line); return line }
|
||||
function mem_cand(line, lab) {
|
||||
if (line ~ /^- \*\*[^*]+\*\*/) {
|
||||
lab = line; sub(/^- \*\*/, "", lab); sub(/\*\*.*/, "", lab)
|
||||
@@ -198,7 +217,13 @@ _mem_stale() { # <lock content> <times seen empty> → rc 0 when stealable
|
||||
_mem_steal() { # <lock> → remove a stale lock; one stealer at a time
|
||||
local g="$1.steal" seen
|
||||
if ! (set -C; date +%s > "$g") 2>/dev/null; then
|
||||
_mem_stale "$(cat "$g" 2>/dev/null) x" 0 && rm -f "$g" # dead stealer
|
||||
# dead stealer: an old date, or a file left empty for over 60 s
|
||||
# shortcut: check-then-rm window (a waiter may remove and a new stealer
|
||||
# recreate between the read and the rm); upgrade = re-check inode/mtime
|
||||
# just before the rm, content cannot tell two empty files apart
|
||||
if _mem_stale "$(cat "$g" 2>/dev/null) x" 0 \
|
||||
|| [ -n "$("$MEM_FIND" "$g" -prune -empty -mmin +1 2>/dev/null)" ]
|
||||
then rm -f "$g"; fi
|
||||
return 0
|
||||
fi
|
||||
seen=$(cat "$1" 2>/dev/null)
|
||||
@@ -338,6 +363,15 @@ memory_journal() { # <line> → `- <line>` under today's heading
|
||||
|| { echo "memory: journal line not written" >&2; return 2; }
|
||||
}
|
||||
|
||||
_mem_body_heading() { # <body-file> → rc 2 on an unfenced `## ` line: it
|
||||
local n # would split the entry (the checks read it as a heading)
|
||||
n=$(awk '/^```/ { fence = !fence; next }
|
||||
!fence && /^## / { print NR; exit }' "$1")
|
||||
[ -z "$n" ] || {
|
||||
echo "memory: add: body line $n starts with \"## \":" \
|
||||
"use \"###\" or indent it" >&2; return 2; }
|
||||
}
|
||||
|
||||
_mem_add_valid() { # <PREFIX> <title> <body-file> <status> <supersedes>
|
||||
_mem_one_line title "$2" || return 2
|
||||
case "$2$4" in *'['*|*']'*|*'|'*)
|
||||
@@ -349,6 +383,7 @@ _mem_add_valid() { # <PREFIX> <title> <body-file> <status> <supersedes>
|
||||
[ -s "$3" ] || { echo "memory: empty or missing body: $3" >&2; return 2; }
|
||||
! _mem_fence_open "$3" \
|
||||
|| { echo "memory: body leaves a code fence open" >&2; return 2; }
|
||||
_mem_body_heading "$3" || return 2
|
||||
if [ "$1" = BLK ] && ! "$MEM_GREP" -q '`' "$3"; then
|
||||
echo "memory: a blocker body quotes ≥1 error in backticks" >&2; return 2
|
||||
fi
|
||||
@@ -472,17 +507,22 @@ memory_check() { # [--staged] [<memory-dir>] → rc 2 on any culprit
|
||||
return "$rc"
|
||||
}
|
||||
|
||||
_mem_blob() { # <rev:path> <out file> → rc 1 when the blob is absent
|
||||
git cat-file -e "$1" 2>/dev/null && git show "$1" > "$2"
|
||||
_mem_blob() { # <rev:path> <out file> → rc 1 when absent, rc 2 when
|
||||
# unreadable; the out file is empty on either
|
||||
git cat-file -e "$1" 2>/dev/null || { : > "$2"; return 1; }
|
||||
git cat-file blob "$1" > "$2" 2>/dev/null || { : > "$2"; return 2; }
|
||||
}
|
||||
|
||||
_mem_check_staged() { # <file> → rc 2 on a new culprit or a lost v2 file
|
||||
local h s rc=0
|
||||
local h s rc=0 hrc src
|
||||
h=$(mktemp) || { echo "memory: no temp file" >&2; return 2; }
|
||||
s=$(mktemp) || { rm -f "$h"; echo "memory: no temp file" >&2; return 2; }
|
||||
_mem_blob "HEAD:./$1" "$h" || : > "$h"
|
||||
_mem_blob ":./$1" "$s" || : > "$s"
|
||||
if [ -s "$h" ] && memory_is_v2 "$h" && ! { [ -s "$s" ] && memory_is_v2 "$s"; }
|
||||
_mem_blob "HEAD:./$1" "$h"; hrc=$?
|
||||
_mem_blob ":./$1" "$s"; src=$?
|
||||
if [ "$hrc" = 2 ] || [ "$src" = 2 ]; then
|
||||
echo "memory: $1: cannot read the HEAD or the staged blob" >&2; rc=2
|
||||
elif [ -s "$h" ] && memory_is_v2 "$h" \
|
||||
&& ! { [ -s "$s" ] && memory_is_v2 "$s"; }
|
||||
then
|
||||
echo "memory: $1: staged deletion, emptying or loss of format: 2" >&2
|
||||
rc=2
|
||||
@@ -660,12 +700,12 @@ _mem_verdict_diff() { # <old> <new> → "ID<TAB>word" per blocker whose open /
|
||||
|
||||
_mem_v1_word() { # <v1 line> → 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 {
|
||||
L="$1" MEMW="$_MEM_WORDS" awk "$_MEM_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 (mem_has(s, w[i])) { c++; word = w[i] }
|
||||
if (c == 1) print word }'
|
||||
}
|
||||
|
||||
@@ -674,8 +714,8 @@ _mem_repair_one() { # <old> <new> <ID> → write the v1 closure when its line
|
||||
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: v1 closed by an unlabelled, mixed or negated line," \
|
||||
"status unknown: ${v1:0:100}" >&2
|
||||
echo "memory: $3: record it from the project root: memory.sh status" \
|
||||
"$3 \"<word>, …\" (the leading word decides), then re-run upgrade" >&2
|
||||
return 0
|
||||
|
||||
+65
-37
@@ -1,63 +1,83 @@
|
||||
#!/usr/bin/env bash
|
||||
# reconcile.sh — deterministic engine for /reconcile.
|
||||
#
|
||||
# Confronts DECLARATIVE sources (TODO checkboxes, registry statuses) against REAL
|
||||
# state (git, fs, registry BODY). It is the engine behind the /reconcile skill;
|
||||
# the skill orchestrates + gates, this file holds the mechanical truth-probes.
|
||||
# Confronts DECLARATIVE sources (TODO checkboxes, registry statuses) against
|
||||
# REAL state (git, fs, registry BODY). It is the engine behind the /reconcile
|
||||
# skill; the skill orchestrates + gates, this file holds the mechanical
|
||||
# truth-probes.
|
||||
#
|
||||
# FOUNDING PRINCIPLE — recursive coherence (LRN-055): a reconciler must NEVER trust
|
||||
# a declarative source as an oracle. So this engine NEVER reads the `## Index` table
|
||||
# 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.
|
||||
# FOUNDING PRINCIPLE — recursive coherence (LRN-055): a reconciler must NEVER
|
||||
# trust a declarative source as an oracle. So this engine NEVER reads the
|
||||
# `## Index` table 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
|
||||
# by a keyword, misses ones phrased without one ("à reprendre quand X"). Deterministic
|
||||
# on the detectable; the skill SURFACES the ambiguous for human review, never asserts.
|
||||
# - Contradiction detection surfaces CANDIDATES (token overlap), never asserts a verdict.
|
||||
# - Deferral detection is LEXICAL (reconcile_deferrals): it catches
|
||||
# deferrals MARKED by a keyword, misses ones phrased without one ("à
|
||||
# reprendre quand X"). Deterministic on the detectable; the skill
|
||||
# SURFACES the ambiguous for human review, never asserts.
|
||||
# - Contradiction detection surfaces CANDIDATES (token overlap), never
|
||||
# asserts a verdict.
|
||||
#
|
||||
# Layers:
|
||||
# reconcile_enumerate_ids — body-only ID enumeration (recursive-coherence core)
|
||||
# reconcile_oracle_* — live git/fs truth probes
|
||||
# reconcile_blk_current_status — registry status, LAST block wins (compound/UPDATE/FINAL)
|
||||
# reconcile_blk_open — blockers whose CURRENT status is not resolved
|
||||
# reconcile_verdict — pure kernel: declared checkbox × real fact → verdict
|
||||
# reconcile_deferrals — lexical deferral sweep (honest limit)
|
||||
# reconcile_contradiction_candidates — accepted-BDR ⇄ open-chantier token overlap (surface)
|
||||
# reconcile_enumerate_ids — body-only `## ID` heading enumeration
|
||||
# (recursive-coherence core); v1 `###` entries
|
||||
# are invisible to it
|
||||
# reconcile_oracle_* — live git/fs truth probes
|
||||
# reconcile_blk_current_status — registry status: lib/memory.sh shared
|
||||
# parser on v2, legacy lexical reader on v1
|
||||
# reconcile_blk_open — blockers whose CURRENT status is not closed
|
||||
# (resolved | superseded | deprecated on v2)
|
||||
# reconcile_verdict — pure kernel: declared checkbox × real fact
|
||||
# → verdict
|
||||
# reconcile_deferrals — lexical deferral sweep (honest limit)
|
||||
# reconcile_contradiction_candidates — accepted-BDR ⇄ open-chantier token
|
||||
# overlap (surface)
|
||||
set -uo pipefail
|
||||
|
||||
RECONCILE_GREP="${RECONCILE_GREP:-/usr/bin/grep}" # LRN-074: pin grep, never assume GNU flags
|
||||
# LRN-074: pin grep, never assume GNU flags
|
||||
RECONCILE_GREP="${RECONCILE_GREP:-/usr/bin/grep}"
|
||||
# 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'
|
||||
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'
|
||||
|
||||
# --- 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.
|
||||
reconcile_enumerate_ids() {
|
||||
"$RECONCILE_GREP" -oE "^## ${2}-[0-9]+" "$1" | "$RECONCILE_GREP" -oE "${2}-[0-9]+" | sort -u
|
||||
"$RECONCILE_GREP" -oE "^## ${2}-[0-9]+" "$1" \
|
||||
| "$RECONCILE_GREP" -oE "${2}-[0-9]+" | sort -u
|
||||
}
|
||||
|
||||
# --- live truth probes (query the REAL repo/fs; this is the "verify, don't believe" core) ---
|
||||
# --- live truth probes (query the REAL repo/fs; the "verify, don't believe"
|
||||
# core) ---
|
||||
reconcile_oracle_tree_clean() { # rc 0 = working tree clean
|
||||
[ -z "$(git -C "${1:-.}" status --porcelain 2>/dev/null)" ]
|
||||
}
|
||||
reconcile_oracle_merge_done() { # $1 repo, $2 branch fragment → rc 0 if a merge commit exists
|
||||
# $1 repo, $2 branch fragment → rc 0 if a merge commit exists
|
||||
reconcile_oracle_merge_done() {
|
||||
[ -n "$(git -C "${1:-.}" log --oneline --grep "Merge .*$2" -1 2>/dev/null)" ]
|
||||
}
|
||||
reconcile_oracle_pushed() { # $1 repo, $2 branch → rc 0 if nothing unpushed vs origin
|
||||
# $1 repo, $2 branch → rc 0 if nothing unpushed vs origin
|
||||
reconcile_oracle_pushed() {
|
||||
[ -z "$(git -C "${1:-.}" rev-list "origin/$2..$2" 2>/dev/null)" ]
|
||||
}
|
||||
reconcile_oracle_sha_exists() { # $1 repo, $2 sha → rc 0 if the commit object exists
|
||||
# $1 repo, $2 sha → rc 0 if the commit object exists
|
||||
reconcile_oracle_sha_exists() {
|
||||
git -C "${1:-.}" cat-file -e "${2}^{commit}" 2>/dev/null
|
||||
}
|
||||
reconcile_oracle_msg_committed() { # $1 repo, $2 grep → rc 0 if a commit message matches
|
||||
# $1 repo, $2 grep → rc 0 if a commit message matches
|
||||
reconcile_oracle_msg_committed() {
|
||||
[ -n "$(git -C "${1:-.}" log --oneline --grep "$2" -1 2>/dev/null)" ]
|
||||
}
|
||||
reconcile_oracle_path_present() { [ -e "${1:?}" ]; } # $1 path → rc 0 if it still exists on disk
|
||||
# $1 path → rc 0 if it still exists on disk
|
||||
reconcile_oracle_path_present() { [ -e "${1:?}" ]; }
|
||||
|
||||
# --- 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
|
||||
@@ -86,7 +106,8 @@ reconcile_blk_open() {
|
||||
done
|
||||
}
|
||||
|
||||
# --- pure reconciliation kernel: declared checkbox × real fact → verdict (no git, fully testable) ---
|
||||
# --- pure reconciliation kernel: declared checkbox × real fact → verdict
|
||||
# (no git, fully testable) ---
|
||||
# $1 checkbox char (x| |~), $2 real_done (true|false).
|
||||
reconcile_verdict() {
|
||||
case "$1:$2" in
|
||||
@@ -97,20 +118,27 @@ reconcile_verdict() {
|
||||
esac
|
||||
}
|
||||
|
||||
# --- lexical deferral sweep (HONEST LIMIT: marked-only) → "src<TAB>line<TAB>text" ---
|
||||
# --- lexical deferral sweep (HONEST LIMIT: marked-only)
|
||||
# → "src<TAB>line<TAB>text" ---
|
||||
reconcile_deferrals() {
|
||||
[ -f "$1" ] && "$RECONCILE_GREP" -nE "$RECONCILE_DEFER_RE" "$1" 2>/dev/null | sed 's/^/TODO\t/'
|
||||
[ -f "$2" ] && "$RECONCILE_GREP" -nE "$RECONCILE_DEFER_RE" "$2" 2>/dev/null | sed 's/^/BDR\t/'
|
||||
[ -f "$1" ] && "$RECONCILE_GREP" -nE "$RECONCILE_DEFER_RE" "$1" 2>/dev/null \
|
||||
| sed 's/^/TODO\t/'
|
||||
[ -f "$2" ] && "$RECONCILE_GREP" -nE "$RECONCILE_DEFER_RE" "$2" 2>/dev/null \
|
||||
| sed 's/^/BDR\t/'
|
||||
return 0
|
||||
}
|
||||
|
||||
# --- contradiction CANDIDATES (surface, never assert): CLI-flag token shared by a BDR + the TODO ---
|
||||
# $1 decisions file, $2 todo file. CLI-flag-like tokens are distinctive enough to flag for review.
|
||||
# --- contradiction CANDIDATES (surface, never assert): CLI-flag token shared
|
||||
# by a BDR + the TODO ---
|
||||
# $1 decisions file, $2 todo file. CLI-flag-like tokens are distinctive enough
|
||||
# to flag for review.
|
||||
reconcile_contradiction_candidates() {
|
||||
local tok
|
||||
for tok in $("$RECONCILE_GREP" -oE '\-\-[a-z][a-z-]+' "$1" 2>/dev/null | sort -u); do
|
||||
local tok why=' in a BDR title and an open TODO chantier'
|
||||
why+=' — review for contradiction'
|
||||
for tok in $("$RECONCILE_GREP" -oE '\-\-[a-z][a-z-]+' "$1" 2>/dev/null \
|
||||
| sort -u); do
|
||||
"$RECONCILE_GREP" -qF -- "$tok" "$2" 2>/dev/null \
|
||||
&& printf 'CANDIDATE\t%s\tflag "%s" in a BDR title and an open TODO chantier — review for contradiction\n' "$tok" "$tok"
|
||||
&& printf 'CANDIDATE\t%s\tflag "%s"%s\n' "$tok" "$tok" "$why"
|
||||
done
|
||||
return 0
|
||||
}
|
||||
@@ -607,6 +607,77 @@ printf -- '---\ntype: blockers_registry\nentry_prefix: BLK\n---\n\n# B\n\n' \
|
||||
bash "$MEM" upgrade t16/dt >/dev/null 2>&1
|
||||
check T16-date-spacing "$(grep -c '^- \*\*Date\*\*' t16/dt/blockers.md)" 1
|
||||
|
||||
# T17 parked minors: dead empty steal file, negated status, body heading,
|
||||
# blob read errors
|
||||
# an empty steal file (stealer killed before its date write) is dead after
|
||||
# 60 s; a fresh one is a live stealer (over-reach guard: `-mmin +0` fails it)
|
||||
echo $(( $(date +%s) - 60 )) dead.1 > "$lock"
|
||||
: > "$lock.steal"; touch -t 202001010000 "$lock.steal"
|
||||
out=$(bash "$MEM" add learning --title steal --body-file plain.md 2>&1); rc=$?
|
||||
check T17-steal-empty-dead "$rc/$([ -e "$lock.steal" ] && echo kept || echo gone)/$([ -e "$lock" ] && echo held || echo free)" 0/gone/free
|
||||
echo $(( $(date +%s) - 60 )) dead.1 > "$lock"
|
||||
: > "$lock.steal"
|
||||
sum=$(cksum < .claude/memory/learnings.md)
|
||||
out=$(MEM_LOCK_TRIES=3 bash "$MEM" add learning --title steal \
|
||||
--body-file plain.md 2>&1); rc=$?
|
||||
check T17-steal-empty-fresh "$rc/$([ -e "$lock.steal" ] && echo kept || echo gone)/$(printf '%s\n' "$out" | grep -c 'lock busy')/$(cksum < .claude/memory/learnings.md)" "2/kept/1/$sum"
|
||||
rm -f "$lock" "$lock.steal"
|
||||
# a status word negated in its clause is no status word
|
||||
negword() { # <status text> → the entry's status word, empty when none
|
||||
printf -- '---\nformat: 2\n---\n\n## BLK-001 — x\n- **Status**: %s\n' "$1" \
|
||||
> neg.md
|
||||
word neg.md BLK-001; }
|
||||
negcases() { # <label> → the negation cases under the current awk
|
||||
check "$1-not-resolved" "$(negword 'not resolved yet')" ''
|
||||
check "$1-open-then-not" "$(negword 'open, not resolved yet')" open
|
||||
check "$1-never" "$(negword 'never superseded')" ''
|
||||
check "$1-closed-not-open" "$(negword 'resolved, not open')" resolved
|
||||
check "$1-no-comma" "$(negword 'no repro, resolved')" resolved
|
||||
check "$1-not-yet" "$(negword 'not yet resolved')" ''
|
||||
check "$1-arrow" "$(negword '(JS off -> no dialog), accepted')" accepted
|
||||
check "$1-two-between" "$(negword 'not reproduced but resolved')" resolved
|
||||
check "$1-arrow-bare" "$(negword 'not reproducible -> resolved')" resolved
|
||||
check "$1-semicolon" "$(negword 'not; resolved')" resolved
|
||||
check "$1-unicode-arrow" "$(negword 'not → resolved')" resolved
|
||||
check "$1-em-dash" "$(negword 'never — superseded')" superseded
|
||||
check "$1-plain" "$(negword 'resolved')" resolved; }
|
||||
negcases T17-negated-status
|
||||
if [ -x /usr/bin/mawk ]; then
|
||||
mkdir -p t17/mawk && ln -sf /usr/bin/mawk t17/mawk/awk
|
||||
OLDPATH=$PATH; PATH="$FIX/t17/mawk:$PATH"
|
||||
negcases T17-negated-status-mawk
|
||||
PATH=$OLDPATH
|
||||
else echo "SKIP mawk absent"; fi
|
||||
# a v1 line the lexical reader closes but only by a negated word is refused
|
||||
v1blk d15/negated '## BLK-001 — x' 'Status: not resolved yet'
|
||||
refused negated BLK-001 T17-upgrade-negated-refused
|
||||
check T17-upgrade-negated-none "$(grep -c 'upgrade)' d15/negated/blockers.md)" 0
|
||||
# a body `## ` line would split the entry: refused; fenced it is text
|
||||
printf 'first\n## Sub\nsecond\n' > sub.md
|
||||
sum=$(cksum < .claude/memory/learnings.md)
|
||||
err=$(bash "$MEM" add learning --title sub --body-file sub.md 2>&1); rc=$?
|
||||
check T17-add-body-heading-refused "$rc/$(cksum < .claude/memory/learnings.md)/$(printf '%s\n' "$err" | grep -c 'body line 2 starts with "## "')" "2/$sum/1"
|
||||
printf 'first\n```\n## Sub\n```\nsecond\n' > subf.md
|
||||
out=$(bash "$MEM" add learning --title subf --body-file subf.md 2>&1); rc=$?
|
||||
check T17-add-body-heading-fenced "$rc/$(grep -c '^## Sub$' .claude/memory/learnings.md)" 0/1
|
||||
# _mem_blob: absent = rc 1 and an empty out file; unreadable = rc 2
|
||||
echo stale > blob.out
|
||||
(. "$MEM"; _mem_blob HEAD:./no/such blob.out); rc=$?
|
||||
check T17-blob-absent "$rc/$(wc -c < blob.out | tr -d ' ')" 1/0
|
||||
mkdir -p t17/ro/.claude/memory t17/shim
|
||||
reg decisions.md decisions_registry BDR 'Decisions registry (BDR)'
|
||||
cat .claude/memory/decisions.md > t17/ro/.claude/memory/decisions.md
|
||||
printf '#!/bin/sh\n[ "$1" = cat-file ] && [ "$2" = blob ] && exit 128\n' \
|
||||
> t17/shim/git
|
||||
printf 'exec %s "$@"\n' "$(command -v git)" >> t17/shim/git
|
||||
chmod +x t17/shim/git
|
||||
(cd t17/ro && git init -q . && git config user.email t@t \
|
||||
&& git config user.name t && git add -A && git commit -qm base)
|
||||
(cd t17/ro && bash "$MEM" check --staged >/dev/null 2>&1)
|
||||
check T17-blob-readable-baseline "$?" 0
|
||||
err=$(cd t17/ro && PATH="$FIX/t17/shim:$PATH" bash "$MEM" check --staged 2>&1)
|
||||
check T17-blob-read-error "$?/$(printf '%s\n' "$err" | grep -c 'cannot read the HEAD or the staged blob')" 2/1
|
||||
|
||||
# T12 this repo's registries pass the check
|
||||
check T12-live-check "$(bash "$MEM" -C "$ROOT" check >/dev/null 2>&1; echo $?)" 0
|
||||
|
||||
|
||||
@@ -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 ]
|
||||
Reference in new issue
Block a user