From f2a81108544f20b301a099528d87d7780f1dd587 Mon Sep 17 00:00:00 2001 From: bchanot Date: Thu, 12 Nov 2026 20:32:24 +0100 Subject: [PATCH] chore(memory): BDR-146, LRN-281..283, gate 1 fixes contract and plan --- .claude/memory/decisions.md | 8 ++++ .claude/memory/journal.md | 1 + .claude/memory/learnings.md | 15 ++++++ .claude/tasks/TODO.md | 9 ++-- .../2026-11-12-recall-gate1-fixes-1830.md | 47 +++++++++++++++++++ .../2026-11-12-recall-gate1-fixes-1830.md | 37 +++++++++++++++ 6 files changed, 113 insertions(+), 4 deletions(-) create mode 100644 .claude/tasks/contracts/2026-11-12-recall-gate1-fixes-1830.md create mode 100644 .claude/tasks/plans/2026-11-12-recall-gate1-fixes-1830.md diff --git a/.claude/memory/decisions.md b/.claude/memory/decisions.md index df09afb..41e8334 100644 --- a/.claude/memory/decisions.md +++ b/.claude/memory/decisions.md @@ -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":{"":"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 ` = idempotence token), promotion → BDR-100 mechanism proposal + `memory.sh status ", promoted to "`. +- **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]]. diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index 420a800..ad446b1 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -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 ``, 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. diff --git a/.claude/memory/learnings.md b/.claude/memory/learnings.md index f5c03dc..0438ae1 100644 --- a/.claude/memory/learnings.md +++ b/.claude/memory/learnings.md @@ -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=`; 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 ""` 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 " 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. diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index 4ee7fa1..dbbb802 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -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:` 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. diff --git a/.claude/tasks/contracts/2026-11-12-recall-gate1-fixes-1830.md b/.claude/tasks/contracts/2026-11-12-recall-gate1-fixes-1830.md new file mode 100644 index 0000000..d53c86c --- /dev/null +++ b/.claude/tasks/contracts/2026-11-12-recall-gate1-fixes-1830.md @@ -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 "promoted to "` 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 `. +- [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 ", promoted to "`, `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` and `promote` from `~/.claude/memory-feedback/FEEDBACK.md` (`Noisy:` / `Promotion candidates:` lines, comma-separated ` ` items), `no-feedback-run` when the file is absent, header lines `tag\t` / `date\t` and `other\t` 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 ", promoted to "`; `d` joins the approve list (`all / a / b / c / d / edit / 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). diff --git a/.claude/tasks/plans/2026-11-12-recall-gate1-fixes-1830.md b/.claude/tasks/plans/2026-11-12-recall-gate1-fixes-1830.md new file mode 100644 index 0000000..bf339e0 --- /dev/null +++ b/.claude/tasks/plans/2026-11-12-recall-gate1-fixes-1830.md @@ -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 ` (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` and `date\t` 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` (visibility). +- R6 idempotence: `promote` rows dropped when the entry already has an `implemented, promoted to` status line; `noisy` rows dropped when `git log --since= --grep="noisy-rewrite "` finds a curation commit (STEP 3 names `noisy-rewrite ` 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 `; promotion = `memory.sh status "implemented, promoted to "` 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()`, 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 [, …]` 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 `): `memory.sh status ", promoted to "` (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; `## — `, the `[status]` tag and the `(date)` stay verbatim; the lesson sentence is the only body change.