Merge feature/recall-gate1-fixes into develop
This commit is contained in:
commit
d3d5e6cc90
13 files changed
+423
-43
No files matched your search
@@ -1523,6 +1523,7 @@ Supersedes [[BDR-030]].
|
||||
- **Alternatives rejected**: raise cleanupPeriodDays (reverses secret hygiene); cron job (machinery, background claude); labels committed (client names on Gitea); one joint gate (prompt waits on rare tool channel); Stop-hook cited flag (BDR-125).
|
||||
- **Deviations from spec (user-gated 2026-11-07)**: reader in lib/ not mods/ (plugin validate/test scope); miss causes no-overlap|overlap only; labels.tsv without cited; noisy/promotion lines carry repo tag.
|
||||
- **Reference**: feature/memory-feedback 21483dc..b44b19f; contract .claude/tasks/contracts/2026-11-06-memory-feedback-4d-1825.md. See [[BDR-125]], [[BDR-137]], [[BDR-100]].
|
||||
- **Status (2026-11-12)**: accepted, 4d.4 built 2026-11-12 (BDR-146, feature/recall-gate1-fixes); later gate reads count only rows after 2026-11-12
|
||||
|
||||
## BDR-141 — claude.ai-synced skills off via global skillOverrides, not sync flag or profiles [accepted] (2026-11-09)
|
||||
- **Decision**: claude.ai-synced skills (19: docx, pptx, xlsx, pdf, docs, computer-use, cv-*, veille-emploi…) turned off by top-level `skillOverrides` {name: "off"} in tracked user settings.json. Global so plain `claude` (no profile = full, user rule 2026-11-09) gets it. Project re-enables one: `{"skillOverrides":{"<name>":"on"}}` in `.claude/settings.local.json` (per-key merge proven). Budget stays 50000.
|
||||
@@ -1554,3 +1555,10 @@ Supersedes [[BDR-030]].
|
||||
- **Decision**: removal of a released deny entry goes through a justified list in push-guard T42 (exact rows, `#` reason line each), forgiven until `removed_ok_until` (=3.0.0); T42e fails once version.txt passes it while list non-empty, list emptied in that bump. T42c proves unlisted removal still fails, T42d simulates exact hand edit. Write twins never shipped -> just leave T41. User gated 2026-11-12 (2 re-gates).
|
||||
- **Alternatives**: row-absent-from-base -> fail (no green path: base ref flips at finish; red on empty list); NOTE only (not fail-closed); Claude editing settings.json (rejected: own deny list = user hand edit).
|
||||
- **Consequences**: CHANGELOG entries land with the user's settings edit (TODO:92). Commit 79f1a3f.
|
||||
|
||||
## BDR-146 — Recall gate 1 fixes: idle needs 8 words, 2 picks, no-overlap misses accepted, 4d.4 prune step D [accepted] (2026-11-12)
|
||||
- **Decision**: gate 1 (EVAL-058) fixes: idle recall fires only at ≥ 8 content words (`IDLE_MIN_WORDS`, fresh/keyword stay 5, `IDLE_MS` unchanged); rerank keeps ≤ 2 picks (`MAX_PICKS` 2); no-overlap misses ACCEPTED (BM25 already indexes body, register.ts docOf; replay 2026-11-12: 4 misses rank 53-322 of 185/473 with body overlap, BM25 13-38 ms, p90 3355 ms = haiku rerank, not BM25); 4d.4 built: /prune-memory STEP 1.D reads FEEDBACK.md for repo tag, noisy → title + lesson sentence rewrite (commit subject `noisy-rewrite <ID>` = idempotence token), promotion → BDR-100 mechanism proposal + `memory.sh status <ID> "<current word>, promoted to <mechanism>"`.
|
||||
- **Why**: idle 44 % on short follow-ups ("ok on y va"); 3rd pick 35 %; user brief "resserrer, pas supprimer".
|
||||
- **Alternatives rejected**: drop idle (user: tighten); index body (already done); add `promoted` to `_MEM_WORDS` (classifier change for annotation only).
|
||||
- **Residual**: metricsOf has no fix-date split, pre-fix rows keep 3rd-pick + idle actions in later FEEDBACK.md (TODO); tool-channel noisy entries not fixed by title rewrite (body spans).
|
||||
- **Reference**: feature/recall-gate1-fixes 7e87d77 + 39f9790; contract .claude/tasks/contracts/2026-11-12-recall-gate1-fixes-1830.md; plan r3; gates: 3 lenses (BLOCKER x3) + confirmation, GATE 0 MET, verifier ECARTS(2)→CONFORME x2, security PASS x2. See [[BDR-140]], [[EVAL-058]], [[BDR-100]].
|
||||
@@ -729,3 +729,4 @@ rules:
|
||||
- 2026-11-12: /reconcile before 3.0.0: 75 SHAs + 31 merges verified, nothing blocks the cut; TODO restructured (9 stale boxes fixed, shipped BDR-125 phase blocks to History, residuals grouped, post-3.0.0 items: empty push-guard removed-ok at next bump, D3 MEDIUM /bugfix). CHANGELOG internal headings -> [internal X.Y.Z].
|
||||
- 2026-11-12: /memory-feedback gate 1 (prompt 26/20): 28 records, 75 labels, 5 spot-checked (0 flip), 7 misses on 5 asks. Precision 57 % under the 64 % target, idle 44 %, tool channel empty. EVAL-058 + 4 TODO lines on chore/memory-feedback-gate1.
|
||||
- 2026-11-12: phase 4b/4c proofs (chore/phase4-proofs): known-error replay `bash -c 'PATH=/nonexistent npm install'` → tool.call context `memory: known BLK-013 …` + store log record {channel: tool, ids: [BLK-013]} (4d tool channel works; 0 records = no matching error); live redaction: `API_KEY=…` + `Bearer …` in a failing echo → key/line/excerpt/command all `<redacted>`, 0 raw hits in the store (Bearer swallows trailing `";`, harmless); headless /context full 27.1k (base 26.9k, +/memory-feedback skill), dev 25.2k, CLI now prints System tools (deferred) 14.1k; digest after a real compaction: no compaction in retained transcripts, waits for this run's first auto-compact.
|
||||
- 2026-11-12: /feat recall-gate1-fixes (block C): idle ≥ 8 content words, MAX_PICKS 2, /prune-memory step D (noisy rewrite, BDR-100 promotion); no-overlap misses accepted after replay (body already indexed). 3 lenses FATAL (promoted ∉ _MEM_WORDS) → r2 → confirmation CONCERNS → r3; GATE 0 MET, verifier ECARTS(2)→CONFORME, security PASS (LOWs folded, re-gated). BDR-146, LRN-281..283.
|
||||
@@ -2052,3 +2052,18 @@ Rule: when editing a doctrine file under structure locks, grep the test's lock s
|
||||
- **Gotcha**: GNU grep 3.12 `grep -c -f emptyfile` prints nothing (rc 1), not `0`: count comparisons break on empty pattern list. Compare named rows (`grep -vxF -f base list` expected "") so failures name the row.
|
||||
- **Context**: /feat dead-deny lock 2026-11-12, challenge round 2 FATAL(2) on plan r2 T42e.
|
||||
- **Apply**: any lock/allowlist with expiry in this repo -> version-keyed, fail-closed on unreadable version.
|
||||
|
||||
## LRN-281 — gates.sh EXPECT is a literal substring; runnable criterion needs EVIDENCE line; 120 s per CHECK (2026-11-12)
|
||||
- **Pattern**: `lib/gates.sh` EXPECT = literal substring of CHECK output (`[[ "$out" != *"$EXPECT"* ]]`, gates.sh:177); every runnable criterion needs `EVIDENCE: PENDING` line else ERROR; per-CHECK timeout 120 s (`make test` exceeds it). Prose EXPECT ("both counts ≥ 1") = NOT-MET forever.
|
||||
- **Context**: /feat recall-gate1-fixes 2026-11-12: contract first ran ERROR(8) (no EVIDENCE), then UNMET(7) (prose EXPECT), then `make test` criterion timed out.
|
||||
- **Apply**: write CHECK to print one stable token (`grep -c X | grep -c '^[1-9]'` → EXPECT `1`; suite tail line → EXPECT `SUITE: all GREEN`); add `EVIDENCE: PENDING` under each; whole `make test` = manual line with recorded run, or `make test suite=<file>`; bun suites need `PATH=$HOME/.bun/bin:$PATH` in CHECK.
|
||||
|
||||
## LRN-282 — memory.sh status text must lead with a _MEM_WORDS word; a non-closing lead word reopens a closed entry (2026-11-12)
|
||||
- **Pattern**: `memory.sh status <ID> "<text>"` refuses text whose first word is not in `_MEM_WORDS` (lib/memory.sh:56-57, rc 2); leading word of last status line = entry's current status (`memory_entry_status`), so a non-closing word (`implemented`) on a resolved BLK or superseded BDR reopens it (reconcile, handover, recall liveness).
|
||||
- **Context**: /feat recall-gate1-fixes 2026-11-12, 4 challengers: "promoted to <mechanism>" refused (BLOCKER x3), then "implemented, promoted…" would reopen closed entries (confirmation MAJOR).
|
||||
- **Apply**: annotation status lines repeat entry's CURRENT word first (`resolved, promoted to …`); `implemented` only when no readable word; never invent a status verb without adding it to `_MEM_WORDS` + classifier tests.
|
||||
|
||||
## LRN-283 — git log --since with a bare date uses the current time of day (2026-11-12)
|
||||
- **Pattern**: `git log --since=YYYY-MM-DD` reads bare date at CURRENT time of day: same-day commits earlier than now drop out. Use `--since="YYYY-MM-DD 00:00"`, or no window when an idempotence token in the subject does the job.
|
||||
- **Context**: /feat recall-gate1-fixes 2026-11-12 confirmation challenger: `git log --since=2026-11-12` at 19:01 returned nothing despite commits at 18:44.
|
||||
- **Apply**: any skill/test filtering commits by a FEEDBACK/report date; pin time explicitly.
|
||||
@@ -8,7 +8,7 @@ Decisions at start (asked once): faunosteo memory v2 on `chore/memory-v2` off de
|
||||
- [ ] A merge chore/memory-feedback-gate1 (b7505d1 + routing `confirmed` row) into develop
|
||||
- [ ] A' /release-candidate 3.0.0 (scope as ticked 2026-11-11)
|
||||
- [x] B chore/phase4-proofs (journal 2026-11-12): known-error replay → `memory: known BLK-013` + tool record; redaction proven (0 raw hits); /context full 27.1k / dev 25.2k; digest-after-compaction waits for this run's first auto-compact (no compaction in retained transcripts)
|
||||
- [ ] C /feat gate 1: idle trigger tightened (≥ 8 words AND a real idle gap), recall cap 2, body indexed for BM25 with p90 before/after (> 3 s → back to title+lesson, "accepted"), 4d.4 built (/prune-memory step D: noisy rewrite + BDR-100 promotion)
|
||||
- [x] C /feat gate 1 (feature/recall-gate1-fixes 7e87d77 + 39f9790, BDR-146): idle ≥ 8 words, cap 2, body was already indexed (replay: BM25 13-38 ms; p90 3355 ms is the haiku rerank) → no-overlap misses accepted; 4d.4 built
|
||||
- [ ] D /feat D1b: digest falls back on the first unchecked items when `### Actionable` is absent; init-project + onboard templates emit the heading; local repos' TODO migrated on `chore/*` (one per repo, merge on ask); Session-start step 1 "Read TODO.md" dropped from the doctrine, citers census
|
||||
- [ ] E phase 1 + 2 decisions: design hook DELETED (web-building.md loads by path); "Skill routing" lines → skills' `description:`; `npm -g` deny lines out + dry-run test; rtk `cat|head|tail *.env*` forms benched, every form kept without proof of obsolescence, T42 list updated; BLK-022 buried (phase 2 covers it): guard-bash.test.sh SKIP spec deleted, BLK-022 → superseded, TODO "Blocked" block removed
|
||||
- [ ] F faunosteo `chore/memory-v2`: `memory.sh upgrade`, `/context` before/after, /prune-memory there for BDR-080 (noisy) + LRN-080 (promotion); never merged by me
|
||||
@@ -34,6 +34,7 @@ Shared rules for every phase:
|
||||
- **4c read side (built 2026-11-05 on feature/memory-recall, merged 2026-11-06 ddb04f4).** Two channels only: intent recall at `prompt.submit` for classifier labels design/analysis or the first coding prompt after idle (BM25 top-30 over title + lesson + body → haiku keeps ≤3, bounded 3 s, fail open) and tool-error 4-gram match (PostToolUse; a classic hook is acceptable if the mod ledger is not needed). Session digest (open BLK via the status parser, actionable TODO, last journal line) in `hooks/session-start.sh` on `source: startup|compact|clear` (native matchers; the mod's `session.compact` only skips); a SubagentStart twin if sub-agents need it. Injection = ID + title + lesson line; superseded never injected; budget ~1.5k chars per turn; once per context. Deferred: Read path triggers, Bash command triggers, "critical → deny once", Tier 1, cross-repo scope=global index, `memory_search` tool.
|
||||
- [x] 4c follow-up from the 4b live proof: `memory_pending` lists earlier-session milestones marked `(earlier session)` (done 78eff1c 2026-11-05, mods/memory/hooks/register.ts milestoneLines).
|
||||
- **4d feedback (4d.1-4d.3 built 2026-11-08 on feature/memory-feedback, BDR-140, merged 2026-11-08 dcb593a).** Mod logs `cands`+`ms`; bun reader `lib/memory-feedback/`; `/memory-feedback` skill; banner reminder; two gates (prompt 20 or 35 d, tool 10 or 35 d +1 extension). Plan r3 `docs/superpowers/plans/2026-11-06-memory-feedback.md` (purged at finish; git keeps it), contract `.claude/tasks/contracts/2026-11-06-memory-feedback-4d-1825.md`. 4d.4 (/prune-memory step D, BDR-100 promotion) stays conditional: built only when a gate reports a noisy entry or a promotion candidate.
|
||||
- [ ] metricsOf: split rows by the 2026-11-12 fix date and retire the 3rd-pick signal (pre-fix rows keep re-emitting the idle and cap actions; BDR-146 residual)
|
||||
- [ ] 4d follow-ups (final review + task reviews 2026-11-08, non-blocking): transcript cache holds every parsed file per run (~1 GB at steady state: process per (root, session, agent) and drop); image prompts (array content) become `lost` (counted); no boundary tests for the threshold actions (3rd pick, late, tool, miss, noisy/promotion, idle tie-break), eviction note, torn count, toolItem; `replyAfter` hides `seen.add` in a filter; no `tsc` type check on lib/memory-feedback; kit test pinning the exact field set of a prompt log record (IR11 is toMatchObject since 4d.1, so a future text field would pass); labels.ts minors (fromLine checks column count only, readState accepts non-object JSON, .bak keeps one state, misleading error on an entry label with a cause).
|
||||
- [ ] shortcut: the injection log lives under `l:<root>` store keys (about 28 KiB each, 200 records and 64 KiB at most); `sweepLogs` counts them with the `p:` keys and evicts the oldest log key (by its newest record, never the current root's) once the total nears the engine's 4 MiB store cap; upgrade = one global log key or a smaller per-root cap (`mods/memory/hooks/register.ts`).
|
||||
- [x] residual: the pre-existing `memory.sh check` call in `hooks/session-start.sh` is not time-bounded (the digest's `memory.sh index blocker` call is); upgrade = wrap it in `timeout 2`. Done 2026-11-06 d93f06c (SD16).
|
||||
@@ -44,10 +45,10 @@ Shared rules for every phase:
|
||||
- [ ] safety-residuals gate LOWs (2026-11-06, bugfix/safety-residuals): `rtk read -n server.key` / `rtk read id_rsa` at repo root pass (`.key`/`.pem`/`id_*` rtk denies all need `*/`; pre-existing, bench before adding); session-start `memory.sh check` and digest unbounded when `timeout` is absent (stock macOS); pre-commit allowlist fails open if `git diff --cached` errors (pre-existing, Gitea backstop); `lib/memory.sh` `_mem_path_safe` line > 80 chars; `claude-stub.sh` interpolates the mktemp log path into the generated stub (test-only).
|
||||
- Proof (closed 2026-11-12, block B): precision = EVAL-058 (prompt gate; the ≥10-error half folded into the tool gate, BDR-140); redaction, `/context` delta and the known-error recall proven live (journal 2026-11-12); digest after a real compaction = pending this run's first auto-compact.
|
||||
- Gate 1 result (2026-11-12, EVAL-058): prompt precision 57 % (n=75), under the 64 % target; fresh 78 %, idle 44 %, keyword 55 %; tool gate 0 records.
|
||||
- [ ] 4d gate 1 (2026-11-12, EVAL-058): idle trigger at 44 % precision: tighten (skip prompts under N words, or only after a real idle gap) or drop; decide before the next gate
|
||||
- [ ] 4d gate 1: cap recall at 2 entries (3rd pick 35 %)
|
||||
- [x] 4d gate 1: idle tightened to ≥ 8 content words (BDR-146, 7e87d77)
|
||||
- [x] 4d gate 1: recall capped at 2 (BDR-146, 7e87d77)
|
||||
- [x] 4d gate 1: tool channel proven live 2026-11-12 (BLK-013 replay: context line + `channel: tool` record); 0 records = no matching error in the window
|
||||
- [ ] 4d gate 1: misses 4/7 no-overlap: BM25 over title+lesson cannot reach them; option = index body too, or accept
|
||||
- [x] 4d gate 1: no-overlap misses accepted (body already indexed; replay ranks 53-322, BDR-146)
|
||||
|
||||
### BDR-125 residuals (after 3.0.0)
|
||||
Open children of the shipped phases (History 2026-11-12), text verbatim.
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
# CONTRACT — recall-gate1-fixes (phase 4d gate 1 + 4d.4)
|
||||
- date: 2026-11-12 | flow: feat | branch: feature/recall-gate1-fixes (off develop b661fb9)
|
||||
- status: active
|
||||
|
||||
## REQUEST (verbatim — IMMUTABLE)
|
||||
memory recall gate 1 (EVAL-058) fixes in mods/memory + /prune-memory step D (4d.4). Scope: (1) mods/memory/hooks/register.ts `triggerKind`: the `idle` trigger fires only when the prompt has at least 8 content words (new constant, `fresh` and `keyword` keep MIN_CONTENT_WORDS=5) and the idle gap stays the measured IDLE_MS since the last composer prompt; (2) MAX_PICKS 3 → 2 (rerank prompt text + parseIds cap); kit tests updated/added in register.test.ts; (3) skills/prune-memory/SKILL.md gains STEP 1 "D. Feedback — noisy and promotion (phase 4d.4)": reads `~/.claude/memory-feedback/FEEDBACK.md` lines `Noisy:` and `Promotion candidates:` filtered on the current repo tag (`basename#sha1(root)[0:6]`, same tag the reader writes; lib/memory-feedback/labels.ts has it), a noisy entry → candidate "inline rewrite: title + lesson narrowed to the concrete trigger so BM25/rerank stop picking it for unrelated prompts" (allowed under a /prune-memory curation commit like C), a promotion candidate → BDR-100 proposal: name the mechanism (rule line, hook, guard, test) in STEP 2, user decides; on accept the entry gets `memory.sh status <ID> "promoted to <mechanism>"` and the mechanism is a separate /feat; no FEEDBACK.md → "no feedback run" line in STEP 2; test in skills/prune-memory/tests/run-deterministic.sh with a fixture FEEDBACK.md (tag match, tag mismatch, absent file). Docs: BDR-140 "4d.4 conditional" amended by a dated status line, CHANGELOG Unreleased, USAGE if /prune-memory is described there. NOT in scope: body indexing (already indexed, register.ts docOf; replay 2026-11-12 shows the 4 "no-overlap" misses rank 53-322 with body overlap → accepted ranking limit), IDLE_MS change, logging candidate IDs.
|
||||
|
||||
(user decisions 2026-11-12, close-out brief: idle "resserrer, pas supprimer" = ≥ 8 words + real idle gap; cap 2; no-overlap misses = accepted after the replay; 4d.4 built now.)
|
||||
|
||||
## CLARIFICATIONS
|
||||
- [gated 2026-11-12, user brief "a decision not listed: take the one answering the phase's original ask, note it, continue"] constant name `IDLE_MIN_WORDS = 8` exported beside `MIN_CONTENT_WORDS`; the idle gap keeps `IDLE_MS` (30 min, measured from the last composer prompt of the session, in-process; a new process = no idle).
|
||||
- [gated] STEP 2 block `[D. Feedback — noisy rewrite / promotion]` printed after `[C. Bloated]`; with no FEEDBACK.md the line reads `[D. Feedback] no feedback run (~/.claude/memory-feedback/FEEDBACK.md absent)`; a FEEDBACK.md whose Noisy/Promotion lines carry no entry of this repo's tag reads `[D. Feedback] none for <tag>`.
|
||||
- [gated, amended 2026-11-12 after challenge: `promoted` is not a memory.sh status word] status wording on an accepted promotion (r3): `memory.sh status <ID> "<current word>, promoted to <mechanism>"`, `implemented` when the entry has no readable word, so a closed entry stays closed; a noisy rewrite is an inline edit of the title + lesson under the curation commit (append-only exception already granted to C), never a status line.
|
||||
- [gated] the repo tag is computed in the SKILL.md bash block as `"$(basename "$root")#$(printf '%s' "$root" | sha1sum | cut -c1-6)"` with `root = git rev-parse --show-toplevel` (must equal labels.ts `tagOf` for the same absolute root; locked by a test that compares both on one path).
|
||||
|
||||
## ACCEPTANCE CRITERIA
|
||||
1. `triggerKind(text, false, IDLE_MS)` returns `undefined` for a prompt of 5-7 content words and `'idle'` at 8+; `fresh` (5+ words) and `keyword` (5+ words) unchanged; `IDLE_MIN_WORDS` exported = 8; `MIN_CONTENT_WORDS` stays 5.
|
||||
CHECK: cd mods/memory/hooks && grep -c IDLE_MIN_WORDS register.ts register.test.ts | grep -c ':[1-9]'
|
||||
EXPECT: 2
|
||||
EVIDENCE: MET exit=0 marker-found :: 2
|
||||
2. `MAX_PICKS` = 2: the rerank prompt ends "at most 2 candidate IDs", `parseIds` through the rerank path keeps 2 at most (existing test at register.test.ts:1991 updated; a test feeding a 3-ID answer gets 2 entries injected).
|
||||
CHECK: cd mods/memory/hooks && echo $(grep -c 'MAX_PICKS = 2' register.ts)$(grep -c 'at most 2 candidate IDs' register.test.ts)
|
||||
EXPECT: 11
|
||||
EVIDENCE: MET exit=0 marker-found :: 11
|
||||
3. Mod kit green: `claude plugin test mods/memory` (or the suite `make test suite=lib/tests/mods.test.sh`) passes with the new tests.
|
||||
CHECK: cd mods/memory && PATH=$HOME/.bun/bin:$PATH timeout 300 claude plugin test . 2>&1 | tail -5
|
||||
EXPECT: 0 fail
|
||||
EVIDENCE: MET exit=0 marker-found :: (pass) FR4: the protect read happens once per root and session [25.33ms] 288 pass 0 fail Ran 288 tests across 1 file. [6.81s]
|
||||
4. skills/prune-memory/SKILL.md STEP 1 has a `### D. Feedback — noisy and promotion (phase 4d.4)` subsection with ONE fenced bash block that prints, for the current repo tag, lines `noisy<TAB><ID>` and `promote<TAB><ID>` from `~/.claude/memory-feedback/FEEDBACK.md` (`Noisy:` / `Promotion candidates:` lines, comma-separated `<tag> <ID>` items), `no-feedback-run` when the file is absent, header lines `tag\t<tag>` / `date\t<date>` and `other\t<tag>` lines but no `noisy`/`promote` row when no item carries the tag (r3); the path is `$HOME/.claude/memory-feedback/FEEDBACK.md` (same as lib/memory-feedback-remind.sh); tests pin `HOME` like RED-6/RED-9, no new env seam.
|
||||
CHECK: grep -c '### D. Feedback' skills/prune-memory/SKILL.md
|
||||
EXPECT: 1
|
||||
EVIDENCE: MET exit=0 marker-found :: 1
|
||||
5. STEP 2 example block gains `[D. Feedback — noisy rewrite / promotion]` with fictional 9xx IDs: a noisy row proposes the inline rewrite (title + lesson narrowed), a promotion row proposes a named mechanism per BDR-100 and the status line `memory.sh status <ID> "<current word>, promoted to <mechanism>"`; `d` joins the approve list (`all / a / b / c / d / edit <ID> / skip`); STEP 3 applies a noisy rewrite like C and a promotion as the status line only (the mechanism = separate /feat, named in the final report).
|
||||
CHECK: grep -c 'promoted to' skills/prune-memory/SKILL.md | grep -c '^[2-9]'
|
||||
EXPECT: 1
|
||||
EVIDENCE: MET exit=0 marker-found :: 1
|
||||
6. `skills/prune-memory/tests/run-deterministic.sh` gains RED-10 executing the REAL step D block (extract_block on `### D.` heading or the STEP 1 block index) in a sandbox repo with `HOME` pinned to a sandbox dir holding `.claude/memory-feedback/`: (a) FEEDBACK.md with this sandbox's tag → both rows printed; (b) a FEEDBACK.md carrying another tag only → no row; (c) directory without FEEDBACK.md → `no-feedback-run`; (d) the tag the block computes equals `tagOf` from lib/memory-feedback/labels.ts for the sandbox root (bun available → compare; bun absent → skip (d) with a SKIP line, (a)-(c) still run).
|
||||
CHECK: PATH=$HOME/.bun/bin:$PATH bash skills/prune-memory/tests/run-deterministic.sh 2>&1 | tail -1
|
||||
EXPECT: SUITE: all GREEN
|
||||
EVIDENCE: MET exit=0 marker-found :: SUITE: all GREEN
|
||||
7. `make test` green (suites touched: mods, prune-memory deterministic via its runner if wired, doctrine-citers), shellcheck clean on changed .sh.
|
||||
(manual: make test exceeds the 120 s gate timeout; run 2026-11-12 on the feater diff: "all suites green")
|
||||
8. Limits on our code: new functions ≤ 25 logic lines / 5 params / 5 locals, lines ≤ 80 in .ts and .sh and SKILL.md bash blocks.
|
||||
|
||||
## FILE SCOPE
|
||||
(r2: README.md:165, USAGE.md:163/217 patched by the STEP 6 doc-syncer, not the executor.)
|
||||
mods/memory/hooks/register.ts, mods/memory/hooks/register.test.ts, skills/prune-memory/SKILL.md, skills/prune-memory/tests/run-deterministic.sh (+ a fixture under skills/prune-memory/tests/fixtures/ if the runner uses files rather than printf), CHANGELOG.md (STEP 6 doc sync), .claude/memory/decisions.md (BDR-140 status line, STEP 7 via memory.sh).
|
||||
@@ -0,0 +1,37 @@
|
||||
# PLAN — recall-gate1-fixes (r2, after 3 lenses: correctness FATAL(7), robustness FATAL(4), simplicity CONCERNS(3))
|
||||
Contract: `.claude/tasks/contracts/2026-11-12-recall-gate1-fixes-1830.md`
|
||||
|
||||
## Changes from r1 (named)
|
||||
- R1 BLOCKER (all 3 lenses): `promoted` is not in `_MEM_WORDS` (lib/memory.sh:56-57) → status text = `implemented, promoted to <mechanism>` (leading word accepted, memory.sh untouched, classifier unchanged); RED-10e runs it through `memory.sh status` in the sandbox.
|
||||
- R2 idle fixtures: NOTES (5 words) loses idle → new `NOTES8` constant with 8+ content words and no rule word drives LO2, IR2/IR3, SP2; :2729 SUITE (5 words) flips to false; 7-word false / 8-word true pair; one 5-7-word end-to-end case after 31 min asks nothing; idle+DESIGN_RULE → keyword pinned.
|
||||
- R3 MAX_PICKS 2: SP1 (:2795-2813) updated to the 2-pick block size (it is the "3-ID answer → 2 injected" test; add a third live entry so 3 candidates really exist); TE9 (:3004-3021) rebuilt so the turn spends > budget − known-line before the checked line (pre-spend through a second known line refused, then a new prompt lets it through); no hardcoded "2" in the prompt template.
|
||||
- R4 AC2 CHECK amended: `grep -c 'MAX_PICKS = 2' register.ts` + the test literal.
|
||||
- R5 D block prints header lines `tag\t<tag>` and `date\t<FEEDBACK date>` first, then rows; tag = `basename#` + `{ sha1sum 2>/dev/null || shasum -a 1; }`; items split on `, `, matched on prefix `tag + " "`, ID = last field (spaces/commas in basenames survive); `no-git-root` when `git rev-parse` fails; `no-feedback-run` when the file is absent; unmatched tags present listed as `other\t<tag>` (visibility).
|
||||
- R6 idempotence: `promote` rows dropped when the entry already has an `implemented, promoted to` status line; `noisy` rows dropped when `git log --since=<date> --grep="noisy-rewrite <ID>"` finds a curation commit (STEP 3 names `noisy-rewrite <ID>` in the commit message).
|
||||
- R7 lesson field named: the rerank line is `id | title | lesson`, lesson = first sentence (≤ 280 chars) of the first labelled field in order BDR Decision; LRN Apply → Future application → Pattern; BLK Solution → Real cause (register.ts LESSON_LABELS). Noisy rewrite narrows the title and THAT sentence only; a title or sentence under the NEGATION GUARD → skipped, reported as manual; prompt-channel noise only (tool matcher reads body backtick spans: limit stated).
|
||||
- R8 thresholds cited, never restated: `lib/memory-feedback/thresholds.ts` T.noisyHits / T.promoteHits / T.promoteSessions.
|
||||
- R9 STEP 2: D is one run-level block after the per-registry blocks, fictional LRN-905/LRN-906, approve line keeps the `Approve per category?` prefix and gains `d`; no live ID, no `status: `, no `frontmatter` in the new prose (RED-7/RED-9 guards); rows filtered to registries in `$ARGUMENTS`. Stale "STEP 3.4 NEGATION GUARD" citation (SKILL.md:236) fixed to 3.3.
|
||||
- R10 extract: `extract_block`'s heading regex `"^## " h` → `"^#+ " h` (no new helper); bun = `command -v bun` only; root resolved once with `git -C "$S10" rev-parse --show-toplevel` for fixture and tagOf.
|
||||
- R11 docs: README.md:165 and USAGE.md:217 (5 words → idle needs 8, "at most 3" → 2) and USAGE.md:163 (/prune-memory: + feedback rewrite/promotion) go to STEP 6 doc sync (doc-syncer), BDR-140 status line in STEP 7 records the fix date and "later gate reads count rows after 2026-11-12 only".
|
||||
- Deferred (TODO line, out of scope, lib/memory-feedback outside FILE SCOPE): retire the `thirdPick` metric/action and split pre-fix rows by date in metricsOf.
|
||||
|
||||
## Files
|
||||
- `mods/memory/hooks/register.ts`
|
||||
- beside `MIN_CONTENT_WORDS` (:1641): `export const IDLE_MIN_WORDS = 8` (comment: gate 1 2026-11-12, idle 44 % on short follow-ups).
|
||||
- `triggerKind`: `const words = tokensOf(text).length`; `< MIN_CONTENT_WORDS` → undefined; fresh → 'fresh'; `idleMs >= IDLE_MS && words >= IDLE_MIN_WORDS` → 'idle'; keyword branch unchanged.
|
||||
- :707 `const MAX_PICKS = 2`. Nothing else.
|
||||
- `mods/memory/hooks/register.test.ts`: import IDLE_MIN_WORDS; R2 + R3 edits (NOTES8, :2729 flip + 7/8 pair + `IDLE_MIN_WORDS` 8 + idle+design → keyword expect, 5-7-word idle e2e case, SP1, TE9, :1991 text "at most 2").
|
||||
- `skills/prune-memory/SKILL.md`: STEP 1 `### D. Feedback — noisy and promotion (phase 4d.4)` (prose per R6-R8 + one bash block per R5/R6, ≤ 80 cols, mirrors the `for k in a:b` idiom of STEP 1), STEP 2 run-level D block (R9), STEP 3 item 4 (noisy = narrow title + lesson sentence per R7, commit message carries `noisy-rewrite <ID>`; promotion = `memory.sh status <ID> "implemented, promoted to <mechanism>"` only, the mechanism = separate /feat named in the report), 3.4 → 3.3 citation fix.
|
||||
- `skills/prune-memory/tests/run-deterministic.sh`: extract regex (R10); RED-10 a (match → rows + tag/date header), b (other tag only → no row, `other` line), c (no file → `no-feedback-run`), d (bun present: fixture written with `tagOf(<physical root>)`, the block emits its row; absent: `RED-10d: SKIP`), e (`memory.sh status` on a sandbox LRN with the promotion text → rc 0, then the block drops that promote row), f (outside a git repo → `no-git-root`). Header comment updated.
|
||||
|
||||
## Disposition
|
||||
honors BDR-140 (4d.4 built because gate 1 reported noisy + promotion), BDR-100 (promotion = mechanism, thresholds in one file), BDR-129 (writes through memory.sh, single status vocabulary untouched), registry append-only via the curation exception already granted to C; BDR-125 (no per-turn nag) untouched.
|
||||
|
||||
## r3 (confirmation CONCERNS(3), no BLOCKER; folded, no further challenge)
|
||||
- C1/C2 noisy idempotence: no `--since` window. The D block drops a noisy row when `git log -E --format=%s --grep="noisy-rewrite ${id}([^0-9]|$)" -- .claude/memory` finds a commit (whole history). The skill writes the token itself: STEP 4's final report prints the exact commit subject `chore(memory): noisy-rewrite <ID>[, <ID>…]` and says /commit-change keeps it verbatim. RED-10g: a sandbox commit with that subject made today → the noisy row is dropped.
|
||||
- C3 promotion status word: the leading word = the entry's CURRENT word (from `memory.sh index <kind>`): `memory.sh status <ID> "<current word>, promoted to <mechanism>"` (e.g. `resolved, promoted to …`, `accepted, promoted to …`); an entry with no readable word (LRN, v1) → `implemented, promoted to …`. A closed entry stays closed; RED-10e asserts the classifier word is unchanged after the status line on a resolved BLK. The D drop rule for promote = an existing status line containing `promoted to`.
|
||||
- C4 SP1: three entries already exist; raise the KNOWN-1 claim cost to 800 (> 1500 − 778) and fix its comment.
|
||||
- C5 tests import `triggerKind` (assert 'idle' / 'keyword' values); NOTES8 keeps the word `notes` (shares a token with LRN-002) and holds no DESIGN/ANALYSIS rule word.
|
||||
- C6 AC4 amended (contract): header lines (`tag`, `date`) plus `other` lines may print; "no row" means no `noisy`/`promote` row.
|
||||
- C7 parse anchored, case-sensitive, on `^Noisy: ` and `^Promotion candidates: `; the literal `none` skipped; the Actions section never parsed; "commas survive" claim dropped (a `, ` in a basename is an accepted limit, stated in the prose); RED-10 fixture includes `Noisy: none`.
|
||||
- C8 STEP 3 item 4: only the title TEXT changes; `## <ID> — `, the `[status]` tag and the `(date)` stay verbatim; the lesson sentence is the only body change.
|
||||
@@ -6,6 +6,12 @@ Format follows [Keep a Changelog](https://keepachangelog.com/) and this project
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
- **/prune-memory feedback step (D)**: reads this repo's `Noisy:` and `Promotion candidates:` lines from `~/.claude/memory-feedback/FEEDBACK.md` (written by `/memory-feedback`). A noisy entry gets an inline rewrite of its title and lesson sentence, narrowed to its concrete trigger, committed as `chore(memory): noisy-rewrite <ID>`. A promotion candidate gets a mechanism proposal (rule line, hook, guard, test); on accept, a `<current status word>, promoted to <mechanism>` status line is recorded (a closed entry stays closed) and the mechanism is built in a separate `/feat`. Rows already rewritten or promoted are dropped. Cutoffs stay in `lib/memory-feedback/thresholds.ts`.
|
||||
|
||||
### Changed
|
||||
- **memory recall**: a prompt after 30 minutes idle now needs 8 content words, up from 5 (a context's first prompt or a design/analysis prompt still needs 5), and the haiku rerank keeps at most 2 entries, down from 3. Measured on the first feedback gate: idle precision 44 %, third pick 35 %.
|
||||
|
||||
## [3.0.0] — 2026-11-12
|
||||
|
||||
### Added
|
||||
|
||||
@@ -162,7 +162,7 @@ Limits: a main-loop switch re-reads cold the part of the context the target mode
|
||||
- Store: the plugin's `$.store`, keyed by project root: the 3 most recent sessions per project, 50 failures per session, 2 KiB per entry. Session keys (`p:<root>`) are swept at 1 MiB; log keys (`l:<root>`) hold about 28 KiB per project; both sit under the engine's 4 MiB cap for the whole store, and when the total nears it the oldest log key is evicted first (never the current project's). It survives `/clear`. The store is the plugin's JSON file under the Claude configuration directory (observed here as `~/.claude/plugins/store/memory_skills-dir-<hash>.json`, an engine layout, not fixed by this repo); delete it to wipe the captures.
|
||||
- Note: one context line, `memory: <kind> <label> — <n> new failure mode(s) this session; /capitalize when ready.`, at the first composer prompt after a milestone. Never per turn, never at Stop, never in a sub-agent.
|
||||
- Tool: `mcp__memory__memory_pending` (deferred: a skill loads it once with `ToolSearch("select:mcp__memory__memory_pending")`). `/capitalize`, `/close` and the CAPITALIZE steps of `/feat`, `/bugfix`, `/hotfix`, `/ship-feature` and `/commit-change` call it first. It lists the milestones of this session and of the earlier ones kept in the store, then the failures as `NEW` or `known <ID>` (word 4-grams matched against the backticked spans of BLK and LRN entries, superseded ones excluded through `lib/memory.sh index`; when that reader is unavailable every entry is matched and the `index:` line ends `status reader unavailable`), earlier sessions marked. Every text it returns is data. It never writes a registry; every call reads the statuses through `lib/memory.sh index`.
|
||||
- Recall: the mod hands registry entries back at the moment they matter. A prompt typed in the composer (never a slash command, at least 5 content words, stop words excluded) triggers it when it is the first of a context (start, `/clear`, `/compact`), comes after 30 minutes idle, or holds a design or analysis word (plan, architecture, design, why, explain, analyse, review, audit and their French forms). BM25 ranks the live BDR, LRN and BLK entries, one haiku call keeps at most 3, bounded to 5 seconds. The context block `memory recall:` carries one line per entry (ID, title, lesson), at most 1500 characters per turn, each entry once per context. Any failure or timeout injects nothing.
|
||||
- Recall: the mod hands registry entries back at the moment they matter. A prompt typed in the composer (never a slash command, at least 5 content words, stop words excluded) triggers it when it is the first of a context (start, `/clear`, `/compact`), comes after 30 minutes idle with at least 8 content words, or holds a design or analysis word (plan, architecture, design, why, explain, analyse, review, audit and their French forms). BM25 ranks the live BDR, LRN and BLK entries, one haiku call keeps at most 2, bounded to 5 seconds. The context block `memory recall:` carries one line per entry (ID, title, lesson), at most 1500 characters per turn, each entry once per context. Any failure or timeout injects nothing.
|
||||
- Known error: a Bash failure whose key matches a live BLK or LRN entry attaches `memory: known <ID> <title> — <lesson>` to the tool answer, once per ID per context, from the same 1500-character budget. Sub-agents get this channel only.
|
||||
- Digest: `hooks/session-start.sh` prints `memory digest:` on `startup`, `clear` and `compact` (never `resume`) in a project that has `.claude/memory/`: up to 3 open BLK from `memory.sh index blocker` (the rest counted, upstream ones counted), up to 3 unchecked Actionable TODO items, the last journal line, 800 characters at most. When the cap bites, TODO lines drop first, then nothing else. Without `timeout` and `jq` it prints only from a terminal.
|
||||
- Recall switch: `{"enabled": true, "recall": false}` in `~/.claude/memory.json` cuts the injections (recall and known-error line) and keeps capture. Every ask is logged under the `l:<root>` store key (last 200 records, 64 KiB), never shown: when, session, agent, channel, the IDs injected, the `trigger` (`fresh`, `idle`, `keyword`, `tool`) and the `outcome` (`injected`, `none`, `timeout`, `refused`, `paused`; an ask that injects nothing is logged with no IDs); a prompt ask also logs `cands` (BM25 candidates after the seen filter) and `ms` (rerank wall time, when a rerank ran). `/memory-feedback` reads it.
|
||||
@@ -250,7 +250,7 @@ a different package, ships its own conflicting `graphify` bin) — see
|
||||
| `/skills-perso` | List personal (user-created) skills |
|
||||
| `/audit-delta` | Recurring audit of changes since last run (norms, bugs, dead code, security) |
|
||||
| `/capitalize` | Flush uncapitalized context + reconcile TODO before /clear or /compact (`--ritual` adds the end-of-session reflection) |
|
||||
| `/prune-memory` | Curate and compress the .claude/memory/ registries |
|
||||
| `/prune-memory` | Curate and compress the .claude/memory/ registries; rewrite noisy recall entries and propose promotions from `/memory-feedback` |
|
||||
| `/memory-feedback` | Label the memory mod's recall injections relevant or irrelevant from the transcripts, spot-check 5 labels with you, report precision and the phase 4d gates in ~/.claude/memory-feedback/FEEDBACK.md. Run it weekly: transcripts live 7 days |
|
||||
| `/reconcile` | Confront declared status (TODO, registries) against real git/fs state — surface stale items |
|
||||
| `/pdf-translate` | Translate a PDF to another language, output as HTML (via Vision) |
|
||||
|
||||
@@ -160,7 +160,7 @@ Tu veux...
|
||||
| `/status` | Reprendre après une pause | Snapshot : plugins, git, GSD milestone |
|
||||
| `/audit-delta` | Audit récurrent du delta depuis le dernier run | Axes : conformité / bugs / dead code / sécurité |
|
||||
| `/capitalize` | Avant /clear ou /compact | Flush contexte non capitalisé + réconcilie .claude/tasks/TODO.md |
|
||||
| `/prune-memory` | Registres trop longs / bruyants | Curation : merge, superseded, compression |
|
||||
| `/prune-memory` | Registres trop longs / bruyants | Curation : merge, superseded, compression ; réécriture des entrées bruyantes et propositions de promotion en mécanisme (règle, hook, garde, test) lues dans `~/.claude/memory-feedback/FEEDBACK.md` |
|
||||
| `/memory-feedback` | Chaque semaine, ou quand la bannière le rappelle | Étiquette les injections du rappel mémoire depuis les transcripts, contrôle de 5 étiquettes avec toi, précision et gates de la phase 4d dans `~/.claude/memory-feedback/FEEDBACK.md` |
|
||||
| `/reconcile` | Connaître l'état réel du travail ouvert (TODO/registres douteux) | Confronte statut déclaré vs git/fs réel |
|
||||
| `/close` | Fin de session | Alias de /capitalize --ritual — dedup + TODO + réflexion 3 questions |
|
||||
@@ -214,7 +214,7 @@ Le mod `mods/memory/` note les échecs Bash et les jalons de la session pour que
|
||||
- Stockage : le `$.store` du plugin, par racine de projet : 3 sessions les plus récentes par projet, 50 échecs par session, 2 Kio par entrée. Les clés de session (`p:<racine>`) sont purgées à 1 Mio ; les clés de journal (`l:<racine>`) pèsent environ 28 Kio par projet ; les deux restent sous le plafond de 4 Mio du moteur pour tout le store, et quand le total s'en approche la plus ancienne clé de journal part d'abord (jamais celle du projet courant). Il survit à `/clear`. Le store est le fichier JSON du plugin sous le dossier de configuration de Claude (observé ici en `~/.claude/plugins/store/memory_skills-dir-<hash>.json`, disposition du moteur, non fixée par ce dépôt) ; le supprimer efface les captures.
|
||||
- La note : une ligne de contexte, `memory: <kind> <label> — <n> new failure mode(s) this session; /capitalize when ready.`, au premier prompt tapé après un jalon. Jamais à chaque tour, jamais au Stop, jamais dans un sous-agent.
|
||||
- L'outil : `mcp__memory__memory_pending` (différé : un skill le charge une fois avec `ToolSearch("select:mcp__memory__memory_pending")`). `/capitalize`, `/close` et les étapes CAPITALIZE de `/feat`, `/bugfix`, `/hotfix`, `/ship-feature` et `/commit-change` l'appellent en premier. Il liste les jalons de la session et ceux des sessions précédentes gardés dans le store, puis les échecs `NEW` ou `known <ID>` (4-grammes de mots comparés aux passages entre accents graves des entrées BLK et LRN, les remplacées exclues via `lib/memory.sh index` ; si ce lecteur est indisponible, toutes les entrées sont comparées et la ligne `index:` finit par `status reader unavailable`), les sessions précédentes signalées. Chaque texte est une donnée. Il n'écrit aucun registre ; chaque appel lit les statuts via `lib/memory.sh index`.
|
||||
- Rappel : le mod ramène les entrées des registres au bon moment. Un prompt tapé dans le composer (jamais une commande slash, au moins 5 mots de contenu, mots vides exclus) le déclenche s'il est le premier d'un contexte (démarrage, `/clear`, `/compact`), s'il suit 30 minutes d'inactivité, ou s'il contient un mot de conception ou d'analyse (plan, architecture, design, pourquoi, explique, analyse, review, audit et leurs équivalents anglais). BM25 classe les entrées BDR, LRN et BLK vivantes, un appel haiku en garde 3 au plus, borné à 5 secondes. Le bloc de contexte `memory recall:` porte une ligne par entrée (ID, titre, leçon), 1500 caractères par tour au plus, chaque entrée une fois par contexte. Un échec ou un dépassement n'injecte rien.
|
||||
- Rappel : le mod ramène les entrées des registres au bon moment. Un prompt tapé dans le composer (jamais une commande slash, au moins 5 mots de contenu, mots vides exclus) le déclenche s'il est le premier d'un contexte (démarrage, `/clear`, `/compact`), s'il suit 30 minutes d'inactivité avec au moins 8 mots de contenu, ou s'il contient un mot de conception ou d'analyse (plan, architecture, design, pourquoi, explique, analyse, review, audit et leurs équivalents anglais). BM25 classe les entrées BDR, LRN et BLK vivantes, un appel haiku en garde 2 au plus, borné à 5 secondes. Le bloc de contexte `memory recall:` porte une ligne par entrée (ID, titre, leçon), 1500 caractères par tour au plus, chaque entrée une fois par contexte. Un échec ou un dépassement n'injecte rien.
|
||||
- Erreur connue : un échec Bash dont la clé correspond à une entrée BLK ou LRN vivante ajoute `memory: known <ID> <titre> — <leçon>` à la réponse de l'outil, une fois par ID et par contexte, sur le même budget de 1500 caractères. Les sous-agents n'ont que ce canal.
|
||||
- Digest : `hooks/session-start.sh` affiche `memory digest:` sur `startup`, `clear` et `compact` (jamais `resume`) dans un projet qui a `.claude/memory/` : jusqu'à 3 BLK ouverts issus de `memory.sh index blocker` (le reste compté, les « upstream » comptés), jusqu'à 3 items Actionable non cochés du TODO, la dernière ligne du journal, 800 caractères au plus. Quand le plafond mord, les lignes TODO tombent d'abord, rien d'autre. Sans `timeout` ni `jq`, il ne s'affiche que depuis un terminal.
|
||||
- Interrupteur du rappel : `{"enabled": true, "recall": false}` dans `~/.claude/memory.json` coupe les injections (rappel et ligne d'erreur connue) et garde la capture. Chaque demande est journalisée sous la clé de store `l:<racine>` (200 enregistrements, 64 Kio), jamais affichée : date, session, agent, canal, IDs injectés, `trigger` (`fresh`, `idle`, `keyword`, `tool`) et `outcome` (`injected`, `none`, `timeout`, `refused`, `paused` ; une demande qui n'injecte rien est journalisée sans ID) ; une demande sur prompt note aussi `cands` (candidats BM25 après le filtre des entrées déjà vues) et `ms` (durée du rerank, quand il a tourné). `/memory-feedback` la lit.
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
segments, suiteKeyOf, commitLabel, finishLabel,
|
||||
newState, switchOf, claim, onContextStart, resetContext, endContext,
|
||||
appendLog, loadLog, isLogRecord, RECALL_CAP, isTrigger,
|
||||
MIN_CONTENT_WORDS, promptContext,
|
||||
MIN_CONTENT_WORDS, IDLE_MIN_WORDS, triggerKind, promptContext,
|
||||
DESIGN_RULE, ANALYSIS_RULE, HAIKU, RERANK_MS, IDLE_MS,
|
||||
} from './register'
|
||||
import type { LogRecord } from './register'
|
||||
@@ -1988,7 +1988,7 @@ test('RB4: rerankPrompt is the literal prompt', () => {
|
||||
const cands = [mk('LRN-1', 'T one', 'Do a.'), mk('BLK-2', 'T two', '')]
|
||||
expect(rerankPrompt('fix the heredoc', cands)).toBe(
|
||||
'Prompt: fix the heredoc\nCandidates:\nLRN-1 | T one | Do a.\n' +
|
||||
'BLK-2 | T two | \nAnswer with at most 3 candidate IDs that would ' +
|
||||
'BLK-2 | T two | \nAnswer with at most 2 candidate IDs that would ' +
|
||||
'help with this prompt, comma separated, or none.')
|
||||
})
|
||||
|
||||
@@ -2317,6 +2317,8 @@ const REC_INDEX = rowsOut([['BLK-001', 'mod design'],
|
||||
const GO = 'on va concevoir la suite du mod memory recall'
|
||||
const DESIGN = 'design the mod suite and tests please'
|
||||
const NOTES = 'write notes about the mod now'
|
||||
// 8 content words, no rule word: the shortest prompt an idle gap can ask on
|
||||
const NOTES8 = 'write some notes about the mod behaviour during session'
|
||||
|
||||
/** Boots the notes world with recall fixtures; the model picks BLK-001. */
|
||||
async function bootRecall($: Engine, on: On, o: Opts = {}) {
|
||||
@@ -2358,7 +2360,7 @@ test('LO2: idle and keyword triggers are told apart', async ($, on) => {
|
||||
await start($)
|
||||
await say($, GO)
|
||||
await w.clock.advance(1860000)
|
||||
await say($, NOTES)
|
||||
await say($, NOTES8)
|
||||
await say($, DESIGN)
|
||||
expect((await askLog(w)).map(r => r[0]))
|
||||
.toEqual(['fresh', 'idle', 'keyword'])
|
||||
@@ -2497,14 +2499,23 @@ test('IR2 IR3: an ordinary prompt 1 min later is silent, 31 min asks',
|
||||
await start($)
|
||||
await say($, GO)
|
||||
await w.clock.advance(60000)
|
||||
await say($, NOTES)
|
||||
await say($, NOTES8)
|
||||
expect(w.asks).toHaveLength(1)
|
||||
expect(seen[1]).toBeUndefined()
|
||||
await w.clock.advance(1860000)
|
||||
await say($, NOTES)
|
||||
await say($, NOTES8)
|
||||
expect(w.asks).toHaveLength(2)
|
||||
})
|
||||
|
||||
test('IR2b: a 5-word prompt after 31 min asks nothing', async ($, on) => {
|
||||
const { w } = await bootRecall($, on)
|
||||
await start($)
|
||||
await say($, GO)
|
||||
await w.clock.advance(1860000)
|
||||
await say($, NOTES)
|
||||
expect(w.asks).toHaveLength(1)
|
||||
})
|
||||
|
||||
test('IR4: slash, mid-turn, sdk and short prompts never ask', async (
|
||||
$, on,
|
||||
) => {
|
||||
@@ -2726,13 +2737,29 @@ test('isTrigger: rules, fresh, idle, slash and length', () => {
|
||||
expect(isTrigger(long, false, 0)).toBe(true)
|
||||
expect(isTrigger(SUITE, false, 0)).toBe(false)
|
||||
expect(isTrigger(SUITE, true, 0)).toBe(true)
|
||||
expect(isTrigger(SUITE, false, IDLE_MS)).toBe(true)
|
||||
expect(isTrigger(SUITE, false, IDLE_MS)).toBe(false)
|
||||
expect(isTrigger('/feat design the thing', true, IDLE_MS)).toBe(false)
|
||||
expect(isTrigger('design note', true, 0)).toBe(false)
|
||||
expect(isTrigger('un-design-ed thing here', false, 0)).toBe(false)
|
||||
expect(HAIKU).toBe('claude-haiku-5-5')
|
||||
})
|
||||
|
||||
test('isTrigger: idle needs IDLE_MIN_WORDS content words', () => {
|
||||
const seven = 'write some notes about mod behaviour during'
|
||||
expect(IDLE_MIN_WORDS).toBe(8)
|
||||
expect(MIN_CONTENT_WORDS).toBe(5)
|
||||
expect(triggerKind(seven, false, IDLE_MS)).toBeUndefined()
|
||||
expect(triggerKind(`${seven} session`, false, IDLE_MS)).toBe('idle')
|
||||
expect(triggerKind(seven, false, IDLE_MS - 1)).toBeUndefined()
|
||||
expect(triggerKind(seven, true, 0)).toBe('fresh')
|
||||
expect(triggerKind('please review this module and the new tests', false, 0))
|
||||
.toBe('keyword')
|
||||
// a rule word still fires on a short idle prompt, as a keyword
|
||||
expect(triggerKind('please review this module and the new tests',
|
||||
false, IDLE_MS)).toBe('keyword')
|
||||
expect(triggerKind(`${NOTES8} and design`, false, IDLE_MS)).toBe('idle')
|
||||
})
|
||||
|
||||
test('isTrigger: fewer than five content words never triggers', () => {
|
||||
expect(MIN_CONTENT_WORDS).toBe(5)
|
||||
// 2-letter function words (finding I1) are no content
|
||||
@@ -2804,13 +2831,14 @@ test('SP1: an ordinary prompt resets the main key spent budget', async (
|
||||
onContextStart(st, 's1')
|
||||
const [block] = await promptContext(api(), st,
|
||||
e('design alpha now, whole team'))
|
||||
expect(block?.length).toBe(1160) // 14 header + 3 x (381 line + 1)
|
||||
expect(st.spent.get('s1:main')).toBe(1160)
|
||||
// 3 candidates, the answer lists 3, the cap keeps 2
|
||||
expect(block?.length).toBe(778) // 14 header + 2 x (381 line + 1)
|
||||
expect(st.spent.get('s1:main')).toBe(778)
|
||||
expect(await promptContext(api(), st, e('nothing special at all')))
|
||||
.toEqual([])
|
||||
expect(st.spent.has('s1:main')).toBe(false)
|
||||
// a 400-char line fits after the reset; 1160 + 400 > 1500 would not
|
||||
expect(claim(st, 's1:main', ['KNOWN-1'], [400])).toEqual(['KNOWN-1'])
|
||||
// an 800-char line fits after the reset; 778 + 800 > 1500 would not
|
||||
expect(claim(st, 's1:main', ['KNOWN-1'], [800])).toEqual(['KNOWN-1'])
|
||||
})
|
||||
|
||||
test('SP2: a prompt without a known last prompt is not idle', async (
|
||||
@@ -2820,7 +2848,7 @@ test('SP2: a prompt without a known last prompt is not idle', async (
|
||||
w.proc = { stdout: REC_INDEX }
|
||||
const api = () => fakeApi(w)
|
||||
const st = switchedOn()
|
||||
const e = { text: NOTES, origin: { kind: 'composer' } }
|
||||
const e = { text: NOTES8, origin: { kind: 'composer' } }
|
||||
expect(await promptContext(api(), st, e)).toEqual([])
|
||||
expect(w.asks).toEqual([])
|
||||
expect(st.lastPrompt.get('s1')).toBe(1000)
|
||||
@@ -3001,22 +3029,27 @@ test('TE8: a failing known-line step returns the answer unchanged',
|
||||
expect(failuresOf(w)).toHaveLength(1)
|
||||
})
|
||||
|
||||
test('TE9: a recall of ~1160 chars, an ordinary prompt, then a ~395 known ' +
|
||||
'line is injected', async ($, on) => {
|
||||
const span = 'fatal: alpha cluster is down'
|
||||
const known = entryText('BLK-004', 't'.repeat(89) + '4', 'Solution',
|
||||
'alpha '.repeat(50).slice(0, 279) + '.') + `seen: \`${span}\`\n`
|
||||
test('TE9: a recall of 778 chars, two known lines of ~395: the second ' +
|
||||
'is refused until an ordinary prompt resets the budget', async ($, on) => {
|
||||
const spans = ['fatal: alpha cluster is down', 'fatal: beta cluster is down']
|
||||
const known = (n: number) => entryText(`BLK-00${n}`,
|
||||
't'.repeat(89) + n, 'Solution', 'alpha '.repeat(50).slice(0, 279) + '.') +
|
||||
`seen: \`${spans[n - 4]}\`\n`
|
||||
const { w, seen } = await bootNotes($, on, { files: { [BLK]:
|
||||
[...[1, 2, 3].map(longEntry), known].join('\n') } })
|
||||
w.proc = { stdout: rowsOut([1, 2, 3, 4].map((n): [string, string] =>
|
||||
[...[1, 2, 3].map(longEntry), known(4), known(5)].join('\n') } })
|
||||
w.proc = { stdout: rowsOut([1, 2, 3, 4, 5].map((n): [string, string] =>
|
||||
[`BLK-00${n}`, 't'.repeat(89) + n])) }
|
||||
w.model = { text: 'BLK-001, BLK-002, BLK-003' }
|
||||
await start($)
|
||||
await say($, 'design alpha now, whole team')
|
||||
expect(seen[0]?.[0]?.length).toBe(1160) // 14 + 3 x (381 + 1)
|
||||
expect(seen[0]?.[0]?.length).toBe(778) // 14 + 2 x (381 + 1)
|
||||
const first = await failing($, w, EXIT1 + spans[0]) as
|
||||
{ context?: string[] }
|
||||
expect(first.context?.[0]?.length).toBe(395) // 778 + 395 = 1173
|
||||
// 1173 + 395 > 1500: refused until the per-prompt reset
|
||||
expect(await failing($, w, EXIT1 + spans[1])).toEqual(w.answer)
|
||||
await say($, 'nothing special at all')
|
||||
const out = await failing($, w, EXIT1 + span) as { context?: string[] }
|
||||
// 1160 + 395 > 1500: only the per-prompt reset lets it through
|
||||
const out = await failing($, w, EXIT1 + spans[1]) as { context?: string[] }
|
||||
expect(out.context?.[0]?.length).toBe(395)
|
||||
})
|
||||
|
||||
|
||||
@@ -704,7 +704,7 @@ const MAX_QUERY = 2000
|
||||
const MAX_DOC = 65536
|
||||
const BM25_K1 = 1.2
|
||||
const BM25_B = 0.75
|
||||
const MAX_PICKS = 3
|
||||
const MAX_PICKS = 2
|
||||
|
||||
/** Lowercase word runs (2-40 letters or digits) minus function words. */
|
||||
export function tokensOf(text: string): string[] {
|
||||
@@ -1639,6 +1639,9 @@ export const ANALYSIS_RULE = wordRule(
|
||||
const MIN_PROMPT = 12 // code points
|
||||
// Measurement gate: fewer content words than this never asks for recall.
|
||||
export const MIN_CONTENT_WORDS = 5
|
||||
// Gate 1 (2026-11-12): idle precision was 44 % on short follow-ups, so an
|
||||
// idle prompt needs more words than a fresh or keyword one.
|
||||
export const IDLE_MIN_WORDS = 8
|
||||
const MAX_CANDS = 30
|
||||
const RERANK_FAILS = 3 // failed reranks in a row that pause it
|
||||
const RERANK_PAUSE_MS = 900000
|
||||
@@ -1652,9 +1655,10 @@ export function triggerKind(
|
||||
if (text.startsWith('/') || Array.from(text).length < MIN_PROMPT) {
|
||||
return undefined
|
||||
}
|
||||
if (tokensOf(text).length < MIN_CONTENT_WORDS) return undefined
|
||||
const words = tokensOf(text).length
|
||||
if (words < MIN_CONTENT_WORDS) return undefined
|
||||
if (fresh) return 'fresh'
|
||||
if (idleMs >= IDLE_MS) return 'idle'
|
||||
if (idleMs >= IDLE_MS && words >= IDLE_MIN_WORDS) return 'idle'
|
||||
const asked = cap(text, MAX_REGEX_INPUT)
|
||||
return DESIGN_RULE.test(asked) || ANALYSIS_RULE.test(asked)
|
||||
? 'keyword'
|
||||
|
||||
@@ -137,6 +137,84 @@ age comparisons. Today's date is in the system context.
|
||||
- Detect filler density: count `\b(the|a|an|just|really|basically|actually|simply)\b`
|
||||
matches; if > 5% of word count → bloated.
|
||||
|
||||
### D. Feedback — noisy and promotion (phase 4d.4)
|
||||
The recall feedback gate (`/memory-feedback`) writes
|
||||
`~/.claude/memory-feedback/FEEDBACK.md`. Its `Noisy:` and `Promotion
|
||||
candidates:` lines list `<repo tag> <ID>` items; this run reads the ones
|
||||
of the current repo only. The cutoffs live in
|
||||
`lib/memory-feedback/thresholds.ts` (`T.noisyHits`, `T.promoteHits`,
|
||||
`T.promoteSessions`): cite them, never restate a number.
|
||||
|
||||
```bash
|
||||
# Feedback rows for THIS repo. Rows: tag<TAB>T, date<TAB>D, noisy<TAB>ID,
|
||||
# promote<TAB>ID, other<TAB>tag; or one word: no-git-root, no-feedback-run.
|
||||
# The tag is the reader's (lib/memory-feedback/labels.ts tagOf).
|
||||
fb="$HOME/.claude/memory-feedback/FEEDBACK.md"
|
||||
root=$(git rev-parse --show-toplevel 2>/dev/null) \
|
||||
|| { echo "no-git-root"; exit 0; }
|
||||
sum=$(printf '%s' "$root" | { sha1sum 2>/dev/null || shasum -a 1; } \
|
||||
| cut -c1-6)
|
||||
tag="$(basename "$root")#$sum"
|
||||
[ -f "$fb" ] || { echo "no-feedback-run"; exit 0; }
|
||||
printf 'tag\t%s\n' "$tag"
|
||||
printf 'date\t%s\n' "$(sed -n '1s/^.*(\([^)]*\)).*$/\1/p' "$fb")"
|
||||
items() { # $1 = line prefix -> one "<tag> <ID>" item per line
|
||||
sed -n "s/^$1: //p" "$fb" | tr -d '\r' | awk '{ n = split($0, a, ", ")
|
||||
for (i = 1; i <= n; i++) if (a[i] != "none") print a[i] }'
|
||||
}
|
||||
rows() { # $1 = line prefix, $2 = row kind
|
||||
items "$1" | while IFS= read -r it; do
|
||||
id=${it##* }
|
||||
case "$it" in
|
||||
"$tag "*) [[ $id =~ ^(BDR|LRN|BLK)-[0-9]+$ ]] || continue
|
||||
printf '%s\t%s\n' "$2" "$id" ;;
|
||||
*) printf 'other\t%s\n' "${it% *}" ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
promoted() { # $1 = ID: rc 0 when its entry holds a "promoted to" line
|
||||
awk -v id="$1" '$0 ~ "^## " id "( |$)" { e = 1; next }
|
||||
/^## / { e = 0 }
|
||||
e && /^- \*\*Status \(.*promoted to/ { f = 1 }
|
||||
END { exit !f }' "$root"/.claude/memory/*.md 2>/dev/null
|
||||
}
|
||||
noisy_done() { # $1 = ID: rc 0 when a curation commit rewrote it
|
||||
[ -n "$(git -C "$root" log -E --format=%s \
|
||||
--grep="noisy-rewrite $1([^0-9]|\$)" -- .claude/memory 2>/dev/null)" ]
|
||||
}
|
||||
{ rows Noisy noisy; rows 'Promotion candidates' promote; } |
|
||||
while IFS=$'\t' read -r kind id; do
|
||||
case "$kind" in
|
||||
noisy) noisy_done "$id" || printf 'noisy\t%s\n' "$id" ;;
|
||||
promote) promoted "$id" || printf 'promote\t%s\n' "$id" ;;
|
||||
*) printf 'other\t%s\n' "$id" ;;
|
||||
esac
|
||||
done | awk '!seen[$0]++'
|
||||
```
|
||||
|
||||
Rules: the lines are matched anchored and case-sensitive (`Noisy: `,
|
||||
`Promotion candidates: `), the literal `none` is skipped, the Actions
|
||||
section is never parsed. An item is `<tag> <ID>`, the ID being its last
|
||||
field; a `, ` inside a repo basename would split an item (accepted limit).
|
||||
`other` rows name tags of other repos, for visibility only. A `promote`
|
||||
row is dropped once its entry holds a `promoted to` status line; a `noisy`
|
||||
row is dropped once a curation commit subject carries `noisy-rewrite <ID>`
|
||||
(STEP 3 item 4 names it). With a `$ARGUMENTS` filter, keep the rows whose ID
|
||||
prefix belongs to a filtered registry.
|
||||
- A `noisy` row → candidate: inline rewrite of the title and of the
|
||||
lesson sentence, narrowed to the concrete trigger so BM25 and the
|
||||
rerank stop picking it for unrelated prompts. The lesson sentence is the
|
||||
one the recall line shows: the first sentence (up to 280 characters) of
|
||||
the first labelled field, in the order BDR `Decision`; LRN `Apply`,
|
||||
`Future application`, `Pattern`; BLK `Solution`, `Real cause`. A title
|
||||
or sentence under the NEGATION GUARD (STEP 3.3) is skipped and reported
|
||||
as a manual rewrite. Limit: the tool matcher reads the backtick spans
|
||||
of the body, which this rewrite leaves alone.
|
||||
- A `promote` row → a BDR-100 proposal: name the mechanism (rule line,
|
||||
hook, guard, test) in STEP 2; the user decides.
|
||||
- `no-feedback-run` → one line in STEP 2. No `noisy`/`promote` row (only
|
||||
`tag`, `date`, `other`) → the `none for <tag>` line.
|
||||
|
||||
## STEP 2 — PRESENT PLAN ★ MANDATORY STOP
|
||||
|
||||
Print one block per registry. Example:
|
||||
@@ -166,9 +244,23 @@ PRUNE PLAN — decisions.md (N entries → M after if approved)
|
||||
decisions.md: 3 (BDR-905, BDR-906, BDR-907)
|
||||
→ you give the word per ID: memory.sh status <ID> "<word>"
|
||||
|
||||
Approve per category? (all / a / b / c / edit <ID> / skip)
|
||||
[D. Feedback — noisy rewrite / promotion] (run-level, repo <tag>, <date>)
|
||||
LRN-905 — noisy: picked for unrelated prompts
|
||||
→ inline rewrite: title + lesson narrowed to the concrete
|
||||
trigger, "<narrowed title>" / "<narrowed lesson sentence>"
|
||||
LRN-906 — promotion candidate (a mechanism, not a note)
|
||||
→ mechanism: <rule line | hook | guard | test>, a separate /feat
|
||||
→ on accept: memory.sh status LRN-906 "<current word>, promoted
|
||||
to <mechanism>" (implemented when the entry has no word)
|
||||
|
||||
Approve per category? (all / a / b / c / d / edit <ID> / skip)
|
||||
```
|
||||
|
||||
D is one run-level block after the per-registry ones. No feedback file
|
||||
prints `[D. Feedback] no feedback run (~/.claude/memory-feedback/FEEDBACK.md
|
||||
absent)`; no row for this repo prints `[D. Feedback] none for <tag>`;
|
||||
`no-git-root` prints `[D. Feedback] not in a git repo`.
|
||||
|
||||
A [B] merge of decisions, blockers or evals names the merged entry's
|
||||
status word on its line (default: the sources' common word; sources
|
||||
differ → ask in `edit <ID>`). The count line folds IDs (first 10, then
|
||||
@@ -221,6 +313,15 @@ Registry writes follow `lib/capitalize-commit.md` § WRITE (single writer).
|
||||
- Short synonyms (`big` not `extensive`, `fix` not `implement a solution for`).
|
||||
- Keep code blocks, URLs, error messages, file paths VERBATIM.
|
||||
- Keep IDs (BDR-XXX, LRN-XXX, commit hashes) verbatim.
|
||||
4. **Feedback (D)** — a noisy rewrite changes only the title TEXT (the
|
||||
`## <ID> — `, the `[status]` tag and the `(date)` stay verbatim) and
|
||||
the one lesson sentence of STEP 1.D, under the same NEGATION GUARD as
|
||||
item 3; it is an inline edit under the curation commit, never a status
|
||||
line. A promotion is one line:
|
||||
`bash "$HOME/.claude/lib/memory.sh" status <ID> "<current word>,
|
||||
promoted to <mechanism>"`, the current word from `memory.sh index <kind>`
|
||||
(`implemented` when none is readable), so a closed entry stays closed.
|
||||
The mechanism itself is a separate /feat, named in the final report.
|
||||
|
||||
## STEP 4 — VERIFY
|
||||
|
||||
@@ -233,7 +334,7 @@ bash "$HOME/.claude/lib/memory.sh" check .claude/memory \
|
||||
# RED-5 fidelity guard (count-based, per-entry x per-category). STEP 0 ensured
|
||||
# a clean tree, so git HEAD is the pre-prune backup. Fails the run if any
|
||||
# negation/permanent token COUNT drops within an entry vs HEAD -- immune to the
|
||||
# line-sharing false positives a removed-line grep produces. The STEP 3.4
|
||||
# line-sharing false positives a removed-line grep produces. The STEP 3.3
|
||||
# NEGATION GUARD keeps negation sentences verbatim; this proves none slipped.
|
||||
# Journal entries are date-keyed and legitimately collapse, so the journal is
|
||||
# restricted to {never,always,permanent} -- the markers the STEP 1.A safety
|
||||
@@ -297,6 +398,11 @@ CHECK: OK
|
||||
NEXT: review `git diff .claude/memory/`, then `/commit-change`
|
||||
```
|
||||
|
||||
After a noisy rewrite (D), the report also prints the exact commit subject
|
||||
`chore(memory): noisy-rewrite <ID>[, <ID>…]` and says `/commit-change`
|
||||
keeps it verbatim: STEP 1.D finds the rewrite again through that token.
|
||||
After a promotion it names the mechanism to build as a separate `/feat`.
|
||||
|
||||
## What NOT to prune
|
||||
|
||||
- Journal entries < 30 days old.
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
# Deterministic RED suite for /prune-memory — RED-1, RED-2, RED-5, RED-6, RED-7, RED-9.
|
||||
# Deterministic RED suite for /prune-memory — RED-1, RED-2, RED-5, RED-6,
|
||||
# RED-7, RED-9, RED-10.
|
||||
# Each MUST be red on the current (v1) skill. Pure mechanical oracles,
|
||||
# no LLM. Faithful: RED-2/RED-6/RED-9 execute the REAL bash blocks extracted
|
||||
# from SKILL.md (no copy that could drift).
|
||||
# no LLM. Faithful: RED-2/RED-6/RED-9/RED-10 execute the REAL bash blocks
|
||||
# extracted from SKILL.md (no copy that could drift).
|
||||
#
|
||||
# Sandbox only (mktemp). NEVER touches real registries or the repo.
|
||||
# Usage: bash run-deterministic.sh (exit 0 = all green, 1 = >=1 red)
|
||||
@@ -17,11 +18,11 @@ fail=0
|
||||
red() { printf 'RED-%s: RED (skill defective, expected pre-GREEN) -- %s\n' "$1" "$2"; fail=1; }
|
||||
green() { printf 'RED-%s: GREEN (skill fixed) -- %s\n' "$1" "$2"; }
|
||||
|
||||
# Pull the real fenced ```bash block under a "## <heading>" from SKILL.md.
|
||||
# Pull the real fenced ```bash block under a "#.. <heading>" from SKILL.md.
|
||||
# Verified by the extract-check before the suite was written.
|
||||
extract_block() {
|
||||
awk -v h="$1" '
|
||||
$0 ~ "^## " h "( |$)" {f=1}
|
||||
$0 ~ "^#+ " h "( |$)" {f=1}
|
||||
f && /^```bash/ {c=1; next}
|
||||
f && /^```/ && c {c=0; f=0; next}
|
||||
c {print}
|
||||
@@ -114,10 +115,12 @@ printf '## BDR-901 — old idea [proposed] (2026-01-01)\n- **Context**: resolved
|
||||
printf '## BDR-902 — kept [accepted] (2026-02-01)\n- **Status (2026-03-01)**: superseded by BDR-903\n' \
|
||||
>> "$S9A/.claude/memory/decisions.md"
|
||||
printf '## BLK-903 — c\n- **Status**: upstream\n' > "$S9A/.claude/memory/blockers.md"
|
||||
printf '## BDR-904 — x\ndate: 2026-01-01 · status: accepted\n\n' > "$S9B/.claude/memory/decisions.md"
|
||||
printf '## BDR-905 — y\nStatus: closed.\n\n' >> "$S9B/.claude/memory/decisions.md"
|
||||
printf '## BDR-906 — z\nStatus: proposed\n- **Statut** : accepted (2026-05-01)\n\n' \
|
||||
>> "$S9B/.claude/memory/decisions.md"
|
||||
{
|
||||
printf '## BDR-904 — x\ndate: 2026-01-01 · status: accepted\n\n'
|
||||
printf '## BDR-905 — y\nStatus: closed.\n\n'
|
||||
printf '## BDR-906 — z\nStatus: proposed\n'
|
||||
printf -- '- **Statut** : accepted (2026-05-01)\n\n'
|
||||
} > "$S9B/.claude/memory/decisions.md"
|
||||
printf '## BDR-907 — w\n- Status: proposed\nSuperseded by BDR-911 (2026-05-01).\n' \
|
||||
>> "$S9B/.claude/memory/decisions.md"
|
||||
extract_block "STEP 1" > "$SANDBOX/step1.sh"
|
||||
@@ -144,6 +147,125 @@ else
|
||||
red 9 "$msg9"
|
||||
fi
|
||||
|
||||
# ---- RED-10: STEP 1.D reads FEEDBACK.md for THIS repo's tag -----------------
|
||||
# Runs the shipped D block in a sandbox repo, HOME pinned to a sandbox dir
|
||||
# holding .claude/memory-feedback/, like RED-9 (memory.sh by absolute path).
|
||||
S10="$SANDBOX/red10"; H10="$SANDBOX/home10"
|
||||
mkdir -p "$S10/.claude/memory" "$H10/.claude/memory-feedback"
|
||||
git -C "$S10" init -q
|
||||
printf -- '---\nformat: 2\n---\n# Blockers\n\n'\
|
||||
'## BLK-905 — x [resolved] (2026-01-01)\n- **Real cause**: y\n' \
|
||||
> "$S10/.claude/memory/blockers.md"
|
||||
printf -- '---\nformat: 2\n---\n# Learnings\n\n'\
|
||||
'## LRN-906 — z (2026-01-01)\n- **Apply**: w\n' \
|
||||
> "$S10/.claude/memory/learnings.md"
|
||||
git -C "$S10" add -A
|
||||
git -C "$S10" -c user.email=t@t -c user.name=t commit -qm seed >/dev/null 2>&1
|
||||
ROOT10="$(git -C "$S10" rev-parse --show-toplevel)"
|
||||
TAG10="$(basename "$ROOT10")#$(printf '%s' "$ROOT10" | sha1sum | cut -c1-6)"
|
||||
FB10="$H10/.claude/memory-feedback/FEEDBACK.md"
|
||||
extract_block "D. Feedback" > "$SANDBOX/step1d.sh"
|
||||
run10() { ( cd "$S10" && HOME="$H10" bash "$SANDBOX/step1d.sh" 2>&1 ); }
|
||||
feedback10() { # $1 = tag of the items, $2 = file
|
||||
{
|
||||
printf '# Memory feedback (2026-11-12)\n\nNoisy: none\n'
|
||||
printf 'Noisy: %s LRN-905, other#abc123 BDR-001\n' "$1"
|
||||
printf 'Promotion candidates: %s LRN-906, %s BLK-907\n\n' "$1" "$1"
|
||||
printf 'Actions:\n- noisy: /prune-memory rewrites %s LRN-905\n' "$1"
|
||||
} > "$2"
|
||||
}
|
||||
rows10() { printf '%s\n' "$1" | /usr/bin/grep -E '^(noisy|promote)'"$TAB"; }
|
||||
msg10=""
|
||||
|
||||
# (a) this repo's tag: both row kinds, header lines, the other tag named
|
||||
feedback10 "$TAG10" "$FB10"
|
||||
out10="$(run10)"
|
||||
has9 "$out10" "tag${TAB}$TAG10" || msg10="a: tag header missing"
|
||||
has9 "$out10" "date${TAB}2026-11-12" || msg10="${msg10:-a: date header missing}"
|
||||
has9 "$out10" "noisy${TAB}LRN-905" || msg10="${msg10:-a: noisy row missing}"
|
||||
has9 "$out10" "promote${TAB}LRN-906" \
|
||||
|| msg10="${msg10:-a: promote LRN-906 missing}"
|
||||
has9 "$out10" "promote${TAB}BLK-907" \
|
||||
|| msg10="${msg10:-a: promote BLK-907 missing}"
|
||||
has9 "$out10" "other${TAB}other#abc123" \
|
||||
|| msg10="${msg10:-a: other row missing}"
|
||||
[ "$(rows10 "$out10" | wc -l)" -eq 3 ] \
|
||||
|| msg10="${msg10:-a: not exactly 3 rows}"
|
||||
|
||||
# (a2) a malformed ID is skipped silently; a subdirectory run reads the
|
||||
# same registries (root-relative) and gives the same 3 rows as (a)
|
||||
mkdir -p "$S10/sub"
|
||||
{ printf '# Memory feedback (2026-11-12)\n\n'
|
||||
printf 'Noisy: %s LRN-905, %s BDR-1 (x\n' "$TAG10" "$TAG10"
|
||||
printf 'Promotion candidates: %s LRN-906, %s BLK-907\n' "$TAG10" "$TAG10"
|
||||
} > "$FB10"
|
||||
out10="$(run10)"
|
||||
printf '%s\n' "$out10" | /usr/bin/grep -q 'BDR-1' \
|
||||
&& msg10="${msg10:-a2: malformed ID produced output}"
|
||||
out10="$( cd "$S10/sub" && HOME="$H10" bash "$SANDBOX/step1d.sh" 2>&1 )"
|
||||
[ "$(rows10 "$out10" | wc -l)" -eq 3 ] \
|
||||
|| msg10="${msg10:-a2: subdir run: not 3 rows}"
|
||||
|
||||
# (b) another tag only: no noisy/promote row, the tag named as other
|
||||
feedback10 "zzz#000000" "$FB10"
|
||||
out10="$(run10)"
|
||||
[ -z "$(rows10 "$out10")" ] || msg10="${msg10:-b: a row for a foreign tag}"
|
||||
has9 "$out10" "other${TAB}zzz#000000" || msg10="${msg10:-b: other row missing}"
|
||||
|
||||
# (c) no FEEDBACK.md
|
||||
rm -f "$FB10"
|
||||
out10="$(run10)"
|
||||
[ "$out10" = "no-feedback-run" ] || msg10="${msg10:-c: got: $out10}"
|
||||
|
||||
# (d) the tag the block computes equals labels.ts tagOf (bun only)
|
||||
if command -v bun >/dev/null 2>&1; then
|
||||
labels10="$HERE/../../../lib/memory-feedback/labels.ts"
|
||||
bun10="import { tagOf } from '$labels10'; "
|
||||
bun10+="console.log(tagOf(process.argv[1]))"
|
||||
tag10="$(bun -e "$bun10" "$ROOT10" 2>&1)"
|
||||
feedback10 "$tag10" "$FB10"
|
||||
out10="$(run10)"
|
||||
has9 "$out10" "noisy${TAB}LRN-905" \
|
||||
|| msg10="${msg10:-d: block tag differs from tagOf ($tag10 vs $TAG10)}"
|
||||
else
|
||||
echo "RED-10d: SKIP (bun absent, tagOf comparison not run)"
|
||||
fi
|
||||
|
||||
# (e) memory.sh status with "<word>, promoted to": rc 0, the word stays,
|
||||
# and the D block drops both promote rows
|
||||
feedback10 "$TAG10" "$FB10"
|
||||
for st in 'BLK-905|resolved, promoted to guard test' \
|
||||
'LRN-906|implemented, promoted to hook'; do
|
||||
( cd "$S10" && HOME="$H10" bash "$HERE/../../../lib/memory.sh" \
|
||||
status "${st%%|*}" "${st#*|}" >/dev/null 2>&1 ) \
|
||||
|| msg10="${msg10:-e: memory.sh status refused ${st%%|*}}"
|
||||
done
|
||||
idx10="$( cd "$S10" && HOME="$H10" bash "$HERE/../../../lib/memory.sh" \
|
||||
index blocker 2>&1 )"
|
||||
printf '%s\n' "$idx10" | /usr/bin/grep -qE '^\| BLK-905 .*\| resolved \|$' \
|
||||
|| msg10="${msg10:-e: BLK-905 word changed after the status line}"
|
||||
out10="$(run10)"
|
||||
printf '%s\n' "$out10" | /usr/bin/grep -qE "^promote${TAB}(LRN-906|BLK-905)" \
|
||||
&& msg10="${msg10:-e: a promoted row survived}"
|
||||
has9 "$out10" "promote${TAB}BLK-907" || msg10="${msg10:-e: BLK-907 row lost}"
|
||||
|
||||
# (f) outside a git repo
|
||||
out10="$( cd "$SANDBOX" && HOME="$H10" bash "$SANDBOX/step1d.sh" 2>&1 )"
|
||||
[ "$out10" = "no-git-root" ] || msg10="${msg10:-f: got: $out10}"
|
||||
|
||||
# (g) a curation commit subject carrying the token drops the noisy row
|
||||
printf '\n' >> "$S10/.claude/memory/learnings.md"
|
||||
git -C "$S10" add -A
|
||||
git -C "$S10" -c user.email=t@t -c user.name=t \
|
||||
commit -qm 'chore(memory): noisy-rewrite LRN-905' >/dev/null 2>&1
|
||||
out10="$(run10)"
|
||||
has9 "$out10" "noisy${TAB}LRN-905" && msg10="${msg10:-g: noisy row not dropped}"
|
||||
if [ -z "$msg10" ]; then
|
||||
green 10 "D block: tag match, foreign tag, absent file, drops, no-git-root"
|
||||
else
|
||||
red 10 "$msg10"
|
||||
fi
|
||||
|
||||
echo "----"
|
||||
if [ "$fail" -eq 0 ]; then
|
||||
echo "SUITE: all GREEN"
|
||||
|
||||
Reference in new issue
Block a user