Merge bugfix/bugs-found-scripts into develop

This commit is contained in:
bchanot committed 2026-11-14 10:33:23 +01:00
commit 457fa33aaa
17 files changed
+98 -31

No files matched your search

+12
View File
@@ -27,6 +27,7 @@
- agents/handover-doc-writer.md:83 + agents/client-handover-writer.md:1201-1202 — `ROOT="<PROJECT root from the PACKAGE>"` pastes the root into a double-quoted literal, and the printed remedy `memory.sh -C <root> status …` leaves `<root>` unquoted: a root with `"`, `$(…)`, a backtick or a space breaks the line or splits the path. Value is the operator's own `git rev-parse --show-toplevel`, not registry data. Severity: low. Discovered while: /bugfix G5 security gate. Not fixed.
FIXED 2026-11-13 (77041e5): ROOT read through a quoted heredoc with a one-line pre-paste rule, control-char root BLOCKED, remedy single-quoted with a `'` rule.
- lib/profile-state.jq (`jq -r` output read by lib/detect-plugins.sh `list_on_plugins` / `detect_gstack`) — a settings value carrying a newline can forge a `plugin:<id>=on` line in the PROFILE_PLAIN text, so the banner or status shows a plugin ON that is not. Display-only, pre-existing for detect_gstack. Severity: low. Discovered while: /bugfix G1+G4 security gate 2026-11-10. Not fixed.
FIXED 2026-11-13 (9045a60): `clean` turns LF/CR into a space on every free-text value (profile, flag, model, mcp-off, connector, pack key); `plugin:` lines print only ids matching `\A[A-Za-z0-9._-]+@[A-Za-z0-9._-]+\z`; tests T28-forge, T28-nl-id.
<!-- /feat D2+D3 2026-11-11 (feature/banner-drop-plugin-dev): non-blocking gate findings, plan .claude/tasks/plans/2026-11-11-advisor-packs-vocabulary-1000.md -->
- agents/plugin-advisor.md embedded RULE (~:217) — the `embedded` signal can come from REQUEST keywords alone ("driver", "kernel", :58) and maps to `↻ SET : minimal`, against the gated rule "minimal reachable from project-level signals only" (only DISABLE is limited to project signals, :124-126). Gate confirmation limits it. Severity: medium (gated decision not fully enforced). Discovered while: /feat D3 verifier 2026-11-11. Not fixed.
@@ -50,22 +51,28 @@
- lib/memory.sh `memory_legacy_status` `<end>` range on v1 decisions: the last BDR entry runs to EOF, so a `## Index` or other `##` section after it would be read by the widened selector (none on disk today). Severity: low. Discovered while: /feat D4 verifier. Not fixed.
FIXED 2026-11-13 (d8e62c1), PARTIAL: the range stops at `## Index` (the on-disk case); a trailing non-Index `##` section is still read, kept so an in-entry `## Update` stays readable by the lexical reader (oracle disagreement detection).
- skills/prune-memory/tests/run-deterministic.sh:13 — `SANDBOX="$(mktemp -d …)"` unchecked under `set -uo pipefail` (no `-e`): a mktemp failure leaves SANDBOX empty and RED-9 targets `/red9a`, `/home9` (fails for a non-root user; trap `rm -rf ""` deletes nothing). Pre-existing, RED-9 extends it. Fix: `|| exit 1`. Cosmetic: skills/prune-memory/SKILL.md:34 ~96 chars unwrapped. Severity: low. Discovered while: /feat D4 security gate + verifier. Not fixed.
FIXED 2026-11-13 (9045a60): `mktemp -d … || exit 1` plus an empty-value guard before the trap.
<!-- /feat D1+D5+D6 2026-11-12 (feature/doctrine-rules-graphify, c69ce9c): follow-ups from challenge rounds and gates, plan .claude/tasks/plans/2026-11-12-doctrine-rules-graphify-1123.md r3 -->
- hooks/session-start.sh:329-333 `_digest_todo` reads only a `### Actionable` heading (this repo only); init-project and onboard TODOs never show in the digest. Tracked as TODO D1b (user 2026-11-12). Severity: medium. Discovered while: /feat D1 challenge round 1. Not fixed.
FIXED 2026-11-12 (block D, feature/digest-todo-fallback 1124758, BDR-147): Actionable ##/### else the file's first items.
- hooks/session-start.sh digest blocker line fails open: a failed or timed-out `memory.sh index blocker` (timeout 2, stderr dropped) prints no `- open:` line, same as zero open blockers. Fix: print `- open: none` after a successful read. Severity: low. Discovered while: /feat D1 challenge round 2. Not fixed.
FIXED 2026-11-13 (9045a60): a failed or timed-out read prints `- open: unknown (memory.sh index failed)`, a successful read with no open row `- open: none`; SD9a/SD9d/SD12. Residual logged below (index rc 0 on an unreadable registry).
- Stale graphify claims outside the D6 scope: .gitignore:54-56 ("written into the repo by `graphify claude install`"), plugins.lock.json:37 (bare `graphify install && graphify claude install` recipe), update-all.sh:310-312 (re-run `graphify claude install` MANUALLY, no trap, cwd-dependent → point at `make plugin`), install-plugins.sh:688/690/1269 labels ("dependencies", "Claude Code integration", "PreToolUse hook" for steps the trap reverts), install-plugins.sh:694-695 LRN-071 comment now gates only `graphify install`, guard comment vs rule duplication. LRN-154 (learnings.md:1381) still says `graphify install --platform claude` "touches nothing else". Severity: low. Discovered while: /feat D6 challenge + gates. Not fixed.
FIXED 2026-11-13 (77041e5): .gitignore, plugins.lock.json, update-all.sh (points at make plugin), install-plugins.sh labels/comment match the trap; LRN-154 corrected by a status line.
- lib/tests/curated-config-guard.test.sh does not lock the Step 7 `(cd "$REPO" && graphify claude install)` subshell; a later edit dropping it passes make test. Severity: low. Discovered while: /feat D6 challenge round 2. Not fixed.
FIXED 2026-11-13 (9045a60): T7 fixed-string lock on the subshell line.
- install-plugins.sh Step 7 hook window (pre-existing): `graphify claude install` hooks sit live in $REPO/.claude/settings.json until the EXIT trap; a SIGKILL skips the trap. Severity: low. Discovered while: /feat D6 security gate. Not fixed.
<!-- /feat dead-deny lock 2026-11-12 (feature/dead-deny-lock, 79f1a3f): non-blocking gate findings, plan .claude/tasks/plans/2026-11-12-dead-deny-lock-1239.md r3 -->
- lib/tests/push-guard.test.sh T42c — passes even if the `$WORK/s-probe.json` jq write fails (empty slurp makes every base entry look lost); weakens what T42c proves, not the lock. Severity: low. Discovered while: /feat dead-deny security gate. Not fixed.
FIXED 2026-11-13 (9045a60): T42c-probe-written asserts the probe parses (`jq -e .`).
- lib/tests/push-guard.test.sh deny_lost — no pipefail: a missing list file or jq failure empties `lost` (T42 green); mitigated by T42c (red) and T40. Severity: low. Discovered while: /feat dead-deny security gate. Not fixed.
FIXED 2026-11-13 (9045a60): explicit PIPESTATUS checks (pipefail would be masked by grep rc 1 on an empty list); a failed stage prints `deny_lost: pipeline failed`; T42f.
- Dead-entry premise (Write(glob) deny never blocks Write; mixed `* :*` / `* -v /:*` forms never match) rests on one live probe 2026-10-23 (journal); nothing re-proves it if Claude Code permission semantics change. Severity: low. Discovered while: /feat dead-deny security gate. Not fixed.
RESOLVED 2026-11-13 by live evidence: Claude Code 2.1.323 warns that `Bash(git push * :**)` (mid-pattern `:*`) matches as a `*` wildcard; the kept deny row is live and matches remote `:ref` deletes; the removed `* :*` forms were wildcards too, so the live `:**` row is the one that holds.
- lib/tests/push-guard.test.sh:421-424 T62F (pre-existing) — `mktemp` settings copy outside `$WORK`, removed only on the normal path (no trap). Severity: low. Discovered while: /feat dead-deny security gate. Not fixed.
FIXED 2026-11-13 (9045a60): copy under `$WORK`, cleaned by the suite trap.
<!-- /bugfix bugs-found-prose 2026-11-13 (77041e5): pre-existing findings from its GATE 2, not BDR-125 -->
- skills/tour/SKILL.md:244,246 (run) and :249,287 (printed) — `git -C "<abs project>"` double-quoted path template: a path holding `$(…)`, a backtick or `"` expands. Same class fixed in plugin-gate. Severity: medium. Discovered while: /bugfix H6a security gate 2026-11-13. Not fixed.
@@ -73,3 +80,8 @@
- agents/handover-doc-writer.md:208,210,757,758 — fixed temp names /tmp/refs.txt, /tmp/ids.txt (use mktemp). Severity: low. Discovered while: /bugfix H6a security gate. Not fixed.
- skills/onboard/SKILL.md:427,612 — unquoted `$HOME` in an executed probe line (:614 fixed). Severity: low. Discovered while: /bugfix H6a security gate. Not fixed.
- lib/profile.sh:68-72,85 — a root ABOVE a symlinked $HOME is caught by a string compare only (is_home covers exactly $HOME). Severity: low. Discovered while: /bugfix H6a security gate. Not fixed.
<!-- /bugfix bugs-found-scripts 2026-11-13 (9045a60): non-blocking gate findings, not BDR-125 -->
- lib/memory.sh:594-603 `memory_index` — skips a blockers.md that is not a regular file (`[ -f ] || continue`) and does not propagate the awk rc, so `index blocker` exits 0 on a registry it could not read and the session digest prints `- open: none` (SD9b/SD9c pin it). Fix direction: non-regular registry or unparsable `| BLK-` row → non-zero rc, the digest prints `unknown`. Severity: low. Discovered while: /bugfix bugs-found-scripts gates 1+2. Not fixed.
- lib/profile-state.jq `clean` strips LF/CR only: ESC and other control chars pass (no terminal sink today); human mode (:67-75) prints values unsanitized (pre-existing). Severity: low. Discovered while: /bugfix bugs-found-scripts security gate. Not fixed.
- lib/tests/profile.test.sh:195 T28-nl-id-no-bare-on cannot fail (pre-fix tail is `=off`); the `clean` on pack keys has no biting assertion; lib/tests/session-digest.test.sh:245 comment still says "no digest". Severity: low. Discovered while: /bugfix bugs-found-scripts verifier. Not fixed.
+1
View File
@@ -748,3 +748,4 @@ rules:
- /bugfix safety-lows (block H4b): code-limits private state dir (mkdir -m 700 no -p + one find test), session-start runner timeout→gtimeout→perl alarm, pre-commit fails closed on git diff and filter errors (generator lib/gitflow.sh + both copies), memory.sh rewrap, claude-stub env log path (1f107c3). 4 rounds: generator was the hook source (decision a), GATE 2 MEDIUM stat/lstat race closed, lint regressions fixed. Residual: perl alarm kills the exec'd process only (TODO).
- /bugfix feedback-followups (block H5, 4d follow-ups): post-fix split + 3rd pick retired + one-slot transcript cache + strict labels/state + key-set pins (9f9412a, docs). 3 challenge lenses FATAL on r1 (midnight cutoff, validator rejecting own rows, text-block extraction losing every join); 3 executor rounds (locals, at bound, legacy closed flag). RSS 279.8 → 267.7 MB on 16 records. tsc not done (no compiler, new dep), l:<root> kept (49.7 KB of 4 MiB), image prompts dropped (0 instances). LRN-288.
- /bugfix bugs-found-prose (block H6a): 10 prose BUGS-FOUND items closed (77041e5): handover rooting + PROJECT_ROOT line + BDR status filter, plugin-gate quoting/unsafe-root/common-dir/$HOME (+ profile.sh refusal T27), advisor rules, packs vocabulary, graphify labels. 4 rounds; GATE 2 MEDIUM single-quote break-out closed by the unsafe-root rule. D1b and dead-entry items closed; 5 pre-existing findings logged. LRN-154 corrected.
- /bugfix bugs-found-scripts (block H6b): 7 BUGS-FOUND script items closed (9045a60): profile-state.jq clean + plugin id shape, digest open none/unknown (+ doctrine line), deny_lost PIPESTATUS, T63 ask/deny split, T7 lock, mktemp guard. Verifier ECARTS(1) (profile.test.sh:123 comment broke shellcheck) → r2 CONFORME, security PASS. Docs 599684c, audits 7c8726b. 3 new LOW in BUGS-FOUND (memory_index rc 0 on unreadable registry).
+5
View File
@@ -2093,3 +2093,8 @@ Rule: when editing a doctrine file under structure locks, grep the test's lock s
- **Context**: block H5 2026-11-13: the BDR-146 residual fix (post-fix precision split) went through 3 lenses + confirmation + 3 executor rounds; every round found a defect only live data showed.
- **Pattern**: a time cutoff for "after the fix" = the MERGE instant of the fix (git committer time of the merge), not the fix date at midnight (36 pre-fix rows sat between midnight and the merge). A gate derived from several marks must be recomputed on read, never trusted from a stored flag an older version wrote (a legacy `"closed":true` silenced the reminder for the new gate). Sample floors are counted in the unit the gate already uses (asks, not entries). A validator added on read must accept every row kind the writer emits (round-trip test over `rowsOf`), and the writer must not accept what the reader refuses (`at` 1e21).
- **Apply**: measure on the live data before planning a metrics change (labels.tsv, store, transcripts read-only); pin the reader/writer round trip; derive closed/reached flags from their inputs.
## LRN-289 — shellcheck stops at a comment starting with 'shellcheck'; pipefail masked by grep rc 1 (2026-11-13)
- **Pattern**: (1) comment line starting `# shellcheck` (e.g. `# shellcheck + width`) parsed as malformed directive: SC1073/SC1072, shellcheck stops parsing, rest of file never linted; counting findings vs HEAD hides it (same count both sides). (2) `set -o pipefail` on `cmd | jq | grep -v` masked: grep rc 1 on empty result = legit, pipefail cannot tell it from jq failure; read `${PIPESTATUS[@]}`, fail on stage rc ≠ 0 and grep rc ≥ 2.
- **Context**: /bugfix bugs-found-scripts (H6b) 2026-11-13: lib/tests/profile.test.sh:123 unlinted since written; push-guard deny_lost (9045a60).
- **Apply**: never start a comment with `shellcheck` word; gate "shellcheck clean" = rc 0, not "count equal to HEAD". Pipe ending in grep-filter → PIPESTATUS check, not pipefail.
+1 -1
View File
@@ -58,7 +58,7 @@ Open children of the shipped phases (History 2026-11-12), text verbatim.
- Phase 1 leftovers: done 2026-11-13 in block E (E1 design hook deleted, BDR-148; E2 Skill routing lines → descriptions, BDR-149).
- Phase 5 leftovers: done 2026-11-13 (block H3, bugfix/pack-census-followups 2fb9a2f): `grep -qxF`, fragment top-level key allowlist (four keys profile.sh reads).
- Phase 2 leftovers: security-gate LOWs done 2026-11-13 (block H4a, bugfix/phase2-deny-lows a43ba1b: awk `system (`/`-f`/`getline`/`| "` + gawk/mawk, `.key`/`.pem`/`id_rsa`/`id_ed25519` root forms + rtk twins, doctor.sh:255 message). The "stated residuals" line (Bash write forms outside the routing guard, latch reset on reload, `.claude/worktrees/` writes, state dirs in TMPDIR, `| bash -s` / sourced `gitflow_finish` / `git -C <dir> merge` = soft_deny prose) names ACCEPTED limits of BDR-125 phase 2 (Amendment 7: interpreters and Bash write forms are classifier territory, no static rule), not tasks: removed. rtk `cat|head|tail *.env*` forms: benched 2026-11-13 (`rtk cat|head|tail --help` = coreutils pass-through on rtk 0.50.0), all six kept, T42 untouched. Remaining phase 2 items (code-limits `mkdir -m 700` + owner check, pre-commit allowlist fail-closed, session-start timeout fallback, `_mem_path_safe` wrap) → block H4b.
- [ ] push-guard T63 presence check reads ask+deny (:430): a deny row demoted to ask still passes; split the lookup per kind (GATE 2 LOW 2026-11-13, new).
- [x] push-guard T63 split per kind (9045a60, H6b): 16 ask rows checked in .permissions.ask, 37 deny rows in .permissions.deny; demotion flip red.
- Context measure leftovers (2026-11-09, LRN-270):
- [ ] Open: dev System tools 11.3k vs full 7.7k (interactive) comes from some pack being off, not MCP; unattributable via `/context`. Bisect by toggling one pack at a time interactively if it matters.
- [ ] Follow-up candidate (accepted risk): doctor residue check covers `enabledPlugins` only; a UI write into user-scope `skillOverrides` would dirty tracked settings.json unseen.
@@ -18,19 +18,19 @@ Fix the BUGS-FOUND entries unfixed since 2026-11-09 that live in scripts and tes
1. Suites green: profile (or session-banner), session-digest, curated-config-guard, push-guard, prune-memory deterministic.
CHECK: cd /home/bchanot/Documents/claude && PATH=$HOME/.bun/bin:$PATH make test suite=lib/tests/push-guard.test.sh 2>&1 | tail -1
EXPECT: all suites green
EVIDENCE: PENDING
EVIDENCE: MET exit=0 marker-found :: all suites green
2. session-digest green with the two new cases.
CHECK: cd /home/bchanot/Documents/claude && echo $(grep -c 'open: none' hooks/session-start.sh lib/tests/session-digest.test.sh | grep -c ':[1-9]')$(PATH=$HOME/.bun/bin:$PATH make test suite=lib/tests/session-digest.test.sh 2>&1 | tail -1)
EXPECT: 2all suites green
EVIDENCE: PENDING
EVIDENCE: MET exit=0 marker-found :: 2all suites green
3. curated-config-guard and prune-memory suites green.
CHECK: cd /home/bchanot/Documents/claude && PATH=$HOME/.bun/bin:$PATH make test suite="lib/tests/curated-config-guard.test.sh skills/prune-memory/tests/run-deterministic.sh" 2>&1 | tail -1
EXPECT: all suites green
EVIDENCE: PENDING
EVIDENCE: MET exit=0 marker-found :: all suites green
4. Forged-line test present and green.
CHECK: cd /home/bchanot/Documents/claude && grep -rlc 'evil@' lib/tests/*.sh | wc -l
EXPECT: 1
EVIDENCE: PENDING
EVIDENCE: MET exit=0 marker-found :: 1
5. shellcheck -x clean on every changed .sh (no new directive); make test green (manual, bun on PATH).
## FILE SCOPE
+1
View File
@@ -27,6 +27,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/) and this project
- `lib/pack-census.sh`: the retired gstack skill check matches `lib/gstack-removed.list` as fixed strings (`grep -qxF`); a pack entry name used to be read as a regex. A profile fragment carrying a top-level key other than `enabledPlugins`, `deniedMcpServers`, `disableClaudeAiConnectors` or `model` is now RED (`unknown top-level key(s) <keys>`) in `lib/pack-census-fragments.jq`. Test: `lib/tests/pack-census.test.sh` T13-unknown-key.
- `settings.json` denies more read and exec forms (28 entries): `awk`/`gawk`/`mawk` with `system (` (space before the paren), `-f` program files, `getline` and `| "` pipe-to-command; `cat` and `rtk read` (plus `*/rtk read` twins) on `.key`, `.pem`, `id_rsa` and `id_ed25519` without a directory prefix. Test: `lib/tests/push-guard.test.sh` T63 locks every row, T62 twins hold. `doctor.sh`: the missing-jq message names every jq hook (`statusline, rtk-rewrite, code-limits and push-guard`).
- Hooks: `hooks/code-limits.sh` keeps its per-session state in a private dir (`mkdir -m 700` without `-p`, else an existing dir is accepted only if it is ours, a directory and mode 700); `hooks/session-start.sh` bounds `memory.sh` and the feedback reminder with `timeout`, else `gtimeout`, else a perl alarm (stock macOS), never unbounded; the gitflow pre-commit hook (generator `lib/gitflow.sh` and both copies) blocks when `git diff --cached` or its filter fails instead of letting the commit through. Tests: `lib/tests/code-limits.test.sh` T16, `lib/tests/session-digest.test.sh` SD19, new `lib/tests/precommit-failclosed.test.sh` PC1-PC4.
- `hooks/session-start.sh`: the memory digest prints `- open: none` when no blocker is open and `- open: unknown (memory.sh index failed)` when `memory.sh index blocker` fails or times out. Both cases used to print no blocker line, so a failed read looked like a clean slate. `lib/profile-state.jq` (`profile.sh current --plain`): a newline or CR in a printed value becomes a space, and a plugin id that does not match `\A[A-Za-z0-9._-]+@[A-Za-z0-9._-]+\z` is dropped, so a settings value can no longer forge a `plugin:` line. Tests: `lib/tests/session-digest.test.sh` SD9a-SD9d, SD12; `lib/tests/profile.test.sh` T28.
## [3.0.0] — 2026-11-12
+2 -1
View File
@@ -53,7 +53,8 @@ code" wins. Repo-specific instructions override both.
1. The banner's `memory digest` lists open blockers, the first unchecked TODO
items (`## Actionable`, else the file's first) and the last journal line:
apply them before touching anything; a `- open: +N` line → read those
entries in `blockers.md`. No digest (foreign repo, memory mod off) → read
entries in `blockers.md`; `- open: unknown` → read `blockers.md`
yourself. No digest (foreign repo, memory mod off) → read
`.claude/tasks/TODO.md` and list the open blockers yourself.
2. Read a registry (`.claude/memory/`: decisions, learnings, blockers,
journal, evals) or `.claude/tasks/TODO.md` when the task needs it;
+1 -1
View File
@@ -164,7 +164,7 @@ Limits: a main-loop switch re-reads cold the part of the context the target mode
- 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 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 TODO items (from a `## Actionable` or `### Actionable` section, else the file's first 3 unchecked top-level items; items inside HTML comments ignored), the last journal line, 800 characters at most. When the cap bites, TODO lines drop first and a `- todo: +N not shown, read .claude/tasks/TODO.md` line counts them; nothing else drops. Without `timeout` and `jq` it prints only from a terminal.
- 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; `- open: none` when none is open, `- open: unknown (memory.sh index failed)` when the read fails or times out), up to 3 unchecked TODO items (from a `## Actionable` or `### Actionable` section, else the file's first 3 unchecked top-level items; items inside HTML comments ignored), the last journal line, 800 characters at most. When the cap bites, TODO lines drop first and a `- todo: +N not shown, read .claude/tasks/TODO.md` line counts them; nothing else drops. 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.
- Recall residuals: measured on 14 days of this repo's transcripts, precision is 54 to 61 % against a 64 % bar, so recall ships on and switchable, and the log decides. The router's classifier label is not used. EVAL entries are not recalled. Each failing command that matches an entry spawns one `memory.sh index`. The haiku bound drops the recalls that answer slower than 5 seconds.
- Feedback: `/memory-feedback` (phase 4d) labels each injected entry from its transcript, with a 5-label spot check by you, and reports precision, misses, noisy entries and promotion candidates against `lib/memory-feedback/thresholds.ts`. Two gates: prompt at 20 labelled asks or 35 days, tool at 10 injections (one 35-day extension, then closed). Precision, trigger precision and the miss share count only rows after the gate-1 fix; their actions wait for 20 post-fix asks (`Post-fix prompt asks: k/20` in FEEDBACK.md, pre-fix entries excluded). Data stays local in `~/.claude/memory-feedback/` (IDs, enums and repo tags only, never in git). The session banner prints `memory feedback: … → /memory-feedback` when a run is due, and goes silent once the prompt gate, the tool gate and the post-fix sample are recorded, or with `"recall": false`.
+1 -1
View File
@@ -217,7 +217,7 @@ Le mod `mods/memory/` note les échecs Bash et les jalons de la session pour que
- 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é 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 non cochés du TODO (section `## Actionable` ou `### Actionable`, sinon les 3 premiers items de premier niveau du fichier ; items en commentaire HTML ignorés), la dernière ligne du journal, 800 caractères au plus. Quand le plafond mord, les lignes TODO tombent d'abord et une ligne `- todo: +N not shown, read .claude/tasks/TODO.md` les compte ; rien d'autre ne tombe. Sans `timeout` ni `jq`, il ne s'affiche que depuis un terminal.
- 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 ; `- open: none` quand aucun n'est ouvert, `- open: unknown (memory.sh index failed)` quand la lecture échoue ou dépasse son délai), jusqu'à 3 items non cochés du TODO (section `## Actionable` ou `### Actionable`, sinon les 3 premiers items de premier niveau du fichier ; items en commentaire HTML ignorés), la dernière ligne du journal, 800 caractères au plus. Quand le plafond mord, les lignes TODO tombent d'abord et une ligne `- todo: +N not shown, read .claude/tasks/TODO.md` les compte ; rien d'autre ne tombe. 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.
- Limites du rappel : mesurée sur 14 jours de transcripts de ce dépôt, la précision est de 54 à 61 % pour une barre à 64 %, donc le rappel est livré actif et coupable, et le journal tranchera. L'étiquette du classifieur du routeur n'est pas utilisée. Les entrées EVAL ne sont pas rappelées. Chaque commande en échec qui correspond à une entrée lance un `memory.sh index`. La borne haiku écarte les rappels qui répondent après 5 secondes.
- Retour d'usage : `/memory-feedback` (phase 4d) étiquette chaque entrée injectée depuis son transcript, avec un contrôle de 5 étiquettes par toi, et donne la précision, les manqués, les entrées bruyantes et les candidates à promotion face aux seuils de `lib/memory-feedback/thresholds.ts`. Deux gates : prompt à 20 demandes étiquetées ou 35 jours, outil à 10 injections (une prolongation de 35 jours, puis fermé). La précision, la précision par trigger et la part de manqués ne comptent que les lignes postérieures au correctif du gate 1 ; leurs actions attendent 20 demandes post-correctif (`Post-fix prompt asks: k/20` dans FEEDBACK.md, entrées antérieures exclues). Les données restent locales dans `~/.claude/memory-feedback/` (IDs, enums et étiquettes de dépôt seulement, jamais dans git). La bannière de session affiche `memory feedback: … → /memory-feedback` quand un passage est dû, et se tait une fois le gate prompt, le gate outil et l'échantillon post-correctif enregistrés, ou avec `"recall": false`.
+5 -2
View File
@@ -316,7 +316,9 @@ _digest_cut() {
# Open BLK (≤ 3 listed, the rest counted) and upstream count, as digest lines.
_digest_blockers() { # <root> <memory.sh>
local row line rest status title open=0 upstream=0 more=""
local row line rest status title open=0 upstream=0 more="" rows
rows=$("${_SS_TMO[@]}" bash "$2" -C "$1" index blocker 2>/dev/null) || {
echo "- open: unknown (memory.sh index failed)"; return 0; }
while IFS= read -r row; do
[[ "$row" == "| BLK-"* ]] || continue
line="${row#| }"; line="${line% |}"
@@ -328,7 +330,8 @@ _digest_blockers() { # <root> <memory.sh>
[ "$open" -le 3 ] && echo "- open: ${line%% | *} $title" ;;
upstream) upstream=$((upstream + 1)) ;;
esac
done < <("${_SS_TMO[@]}" bash "$2" -C "$1" index blocker 2>/dev/null)
done <<< "$rows"
[ "$open" -eq 0 ] && echo "- open: none"
[ "$open" -gt 3 ] && more="+$((open - 3)) more"
[ "$upstream" -gt 0 ] && more="${more:+$more, }+${upstream} upstream"
[ -n "$more" ] && echo "- open: $more"
+10 -6
View File
@@ -14,6 +14,8 @@ def is_pack: startswith("pack-") and endswith("@skills-dir");
def short: sub("@skills-dir$"; "");
def src_word($s):
if $s.source == "flag" then "conv \($s.flag)" else $s.source end;
def clean: tostring | gsub("[\n\r]"; " ");
def plugin_id: test("\\A[A-Za-z0-9._-]+@[A-Za-z0-9._-]+\\z");
def listing($plugins; $on):
[$plugins | to_entries[] | select(.value == $on) | .key | short]
| if length == 0 then "none" else join(" ") end;
@@ -50,15 +52,17 @@ def listing($plugins; $on):
model: $model, model_source: $msrc, mcp_off: $off} as $s
| if $mode == "json" then $s
elif $mode == "plain" then
( ["profile=\($s.name)", "source=\($s.source)", "flag=\($s.flag)"]
( ["profile=\($s.name | clean)", "source=\($s.source)",
"flag=\($s.flag | clean)"]
+ [$plugins | to_entries | sort_by(.key)[] | select(.key | is_pack)
| "\(.key | short)=\(.value | onoff)"]
| "\(.key | short | clean)=\(.value | onoff)"]
+ [$plugins | to_entries | sort_by(.key)[]
| select(.key | is_pack | not) | "plugin:\(.key)=\(.value | onoff)"]
+ [$denied[] | "connector:\(.)=denied"]
| select(.key | is_pack | not) | select(.key | plugin_id)
| "plugin:\(.key)=\(.value | onoff)"]
+ [$denied[] | "connector:\(. | clean)=denied"]
+ (if $all then ["connector:*=denied"] else [] end)
+ ["model=\($s.model)", "model-source=\($s.model_source)",
"mcp-off=\($s.mcp_off)"] ) | .[]
+ ["model=\($s.model | clean)", "model-source=\($s.model_source)",
"mcp-off=\($s.mcp_off | clean)"] ) | .[]
else
( [ (if $s.mcp_off != "-"
then "profile: custom (off: \($s.mcp_off)) [\(src_word($s))]"
+6
View File
@@ -78,4 +78,10 @@ if grep -qi 'mktemp failed' "$ERR6"; then r6msg=yes; else r6msg=no; fi
check T6-mktemp-failure-loud "$r6msg" yes
rm -f "$ERR6" "$SUT2"
# T7: Step 7 keeps `graphify claude install` inside the `(cd "$REPO" && …)`
# subshell, so the guard's CLAUDE.md block lands in the repo it protects.
if grep -qF "(cd \"\$REPO\" && graphify claude install)" "$INSTALL_SH"; then
r7=yes; else r7=no; fi
check T7-step7-graphify-subshell-lock "$r7" yes
printf 'PASS=%s FAIL=%s\n' "$pass" "$fail"; [ "$fail" -eq 0 ]
+12 -1
View File
@@ -120,7 +120,7 @@ out="$(P diff fullx)"; check_has T17-diff-ui "$out" "ui@mk: off → on"
check_has T17-diff-conn "$out" "connectors denied: claude.ai X, claude.ai Y → "
out="$(P diff devx)"; check T17-nodiff "$out" "no difference from devx"
# shellcheck + width
# lint: shellcheck + width
check T18-shellcheck "$(shellcheck "$ROOT/lib/profile.sh" >/dev/null 2>&1 && echo ok)" ok
check T18-width "$(LC_ALL=C awk 'length($0) > 80' "$ROOT/lib/profile.sh" "$ROOT/lib/profile-state.jq" | wc -l | tr -d ' ')" 0
@@ -185,6 +185,17 @@ check T27-home-root-rc "$rc" 2
check_has T27-home-root-msg "$out" "refusing \$HOME as the project root"
check T27-home-root-nothing "$([ -e "$H3/.claude" ] && echo leaked)" ""
# a newline in a settings value never starts a forged plain line
printf '{"model": "opus\\nplugin:evil@x=on"}\n' > "$FX/proj/.claude/settings.json"
out="$(P current --plain)"
check T28-forge-no-line "$(printf '%s\n' "$out" | grep -c '^plugin:evil@')" 0
check T28-forge-kept-inline "$(printf '%s\n' "$out" | grep -c '^model=opus plugin:evil@x=on$')" 1
printf '{"enabledPlugins": {"ok@x\\n": true, "pack-a\\nb=on@skills-dir": true}}\n' > "$FX/lib/profiles/nlx.json"
out="$(P current --plain)"
check T28-nl-id-no-bare-on "$(printf '%s\n' "$out" | grep -c '^=on$')" 0
check T28-nl-id-no-plugin-line "$(printf '%s\n' "$out" | grep -c '^plugin:ok@x')" 0
rm "$FX/lib/profiles/nlx.json"
# timing: two jq calls, under 100 ms here (spec target 50 ms, measured in Task 12)
t0=$(date +%s%N); P current --plain >/dev/null; t1=$(date +%s%N)
ms=$(( (t1 - t0) / 1000000 )); echo "current --plain: ${ms} ms"
+23 -7
View File
@@ -358,6 +358,10 @@ deny_lost() { # <settings file>: base deny entries missing, minus the list
| jq -r --slurpfile now "$1" '.permissions.deny[]
| select(. as $e | ($now[0].permissions.deny | index($e)) == null)' \
| grep -vxF -f "$WORK/removed-ok"
local st=("${PIPESTATUS[@]}")
# grep rc 1 = nothing left to report; any other failure is a lost check
{ [ "${st[0]}" -eq 0 ] && [ "${st[1]}" -eq 0 ] && [ "${st[2]}" -le 1 ]; } ||
echo "deny_lost: pipeline failed (rc ${st[*]})"
}
if [ -z "$base" ]; then
echo "SKIP T42 (no main ref)"
@@ -371,6 +375,8 @@ else
# T42c: the lock still bites on an entry that is not in the list
probe=$(printf '%s\n' "$basedeny" | grep -vxF -f "$WORK/removed-ok" | head -1)
jq --arg e "$probe" '.permissions.deny -= [$e]' "$S" > "$WORK/s-probe.json"
check T42c-probe-written "$(jq -e . "$WORK/s-probe.json" >/dev/null 2>&1 \
&& echo ok || echo bad)" ok
check T42c-lock-bites \
"$(deny_lost "$WORK/s-probe.json" | grep -cxF -- "$probe")" 1
# T42d: the user's hand edit (the 6 dead entries out) is forgiven
@@ -379,6 +385,9 @@ else
"Write(~/.gitconfig)", "Write(~/.config/git/config)"]' "$S" \
> "$WORK/s-after.json"
check T42d-edit-forgiven "$(deny_lost "$WORK/s-after.json")" ""
# T42f: a missing settings file is a failed check, not an empty loss list
check T42f-jq-failure-reported \
"$(deny_lost "$WORK/absent.json" 2>/dev/null | grep -c 'pipeline failed')" 1
fi
soft=$(jq -r '.autoMode.soft_deny[]' "$S")
@@ -419,17 +428,22 @@ twins_missing() { # twins_missing <settings> -> missing twin rules
done
}
check T62-twins-present "$(twins_missing "$S")" ""
T62F="$(mktemp)"
T62F="$WORK/s-twin.json"
jq '.permissions.deny += ["Bash(cat */ghost.key)"]' "$S" > "$T62F"
check T62b-flip-missing-twin "$(twins_missing "$T62F" | /usr/bin/grep -F ghost.key | sort | paste -sd' ' -)" "Bash(*/rtk read */ghost.key*) Bash(rtk read */ghost.key*)"
rm -f "$T62F"
# T63 phase 2 rules present (adding is free; a removal is the user's edit)
# T63 phase 2 rules present (adding is free; a removal is the user's edit):
# each row in the list where it sits today, so a deny row demoted to ask
# (or the reverse) fails
missing=""
while IFS= read -r e; do
jq -e --arg e "$e" '(.permissions.ask + .permissions.deny) | index($e)' \
"$S" >/dev/null || missing="$missing [$e]"
done <<'EOF'
rules_present() { # rules_present <ask|deny>: stdin rows -> $missing
local e
while IFS= read -r e; do
jq -e --arg e "$e" --arg l "$1" '.permissions[$l] | index($e)' \
"$S" >/dev/null || missing="$missing [$1:$e]"
done
}
rules_present ask <<'EOF'
Bash(git merge *)
Bash(bash *gitflow.sh finish*)
Bash(sh *gitflow.sh finish*)
@@ -446,6 +460,8 @@ Bash(/usr/bin/bash *)
Bash(/usr/bin/sh *)
Bash(/usr/bin/env bash*)
Bash(/usr/bin/env sh*)
EOF
rules_present deny <<'EOF'
Bash(awk *system(*)
Bash(head * .env*)
Bash(tail * .env*)
+10 -4
View File
@@ -199,18 +199,24 @@ printf '#!/usr/bin/env bash\nexit 2\n' > "$WORK/sd9/lib/memory.sh"
out=$(run "$p" - "$S9"); rc=$?
check SD9a-exit2-rc "$rc" 0
check SD9a-banner "$(printf '%s' "$out" | grep -c 'make doctor')" 1
check SD9a-no-digest "$(printf '%s' "$out" | grep -c 'memory digest:')" 0
check SD9a-unknown "$(printf '%s\n' "$out" | grep -c -x -- '- open: unknown (memory.sh index failed)')" 1
printf '#!/usr/bin/env bash\nprintf "| BLK-1 |\\n| BLK-2 | x\\n| BLK-3 | d | t | weird |\\ngarbage\\n"\n' \
> "$WORK/sd9/lib/memory.sh"
out=$(run "$p" - "$S9"); rc=$?
check SD9b-malformed-rc "$rc" 0
check SD9b-banner "$(printf '%s' "$out" | grep -c 'make doctor')" 1
check SD9b-no-digest "$(printf '%s' "$out" | grep -c 'memory digest:')" 0
check SD9b-none "$(printf '%s\n' "$out" | grep -c -x -- '- open: none')" 1
p=$(mkproj sd9d); mkdir "$p/.claude/memory/blockers.md"
out=$(run "$p" -); rc=$?
check SD9c-dir-rc "$rc" 0
check SD9c-banner "$(printf '%s' "$out" | grep -c 'make doctor')" 1
check SD9c-no-digest "$(printf '%s' "$out" | grep -c 'memory digest:')" 0
check SD9c-none "$(printf '%s\n' "$out" | grep -c -x -- '- open: none')" 1
# SD9d: a successful read with zero open rows says so
p=$(mkproj sd9e); blk "$p" 1 resolved "Done"
check SD9d-none "$(run "$p" - | digest | grep -c -x -- '- open: none')" 1
blk "$p" 2 open "Now open"
check SD9d-not-none "$(run "$p" - | digest | grep -c -x -- '- open: none')" 0
# SD10: PATH without jq, piped resume -> no digest, banner intact
bin="$WORK/nojq"; mkdir -p "$bin"
@@ -246,7 +252,7 @@ t1=$(now_ms)
check SD12-hang-bounded "$([ $((t1 - t0)) -lt 3500 ] && echo yes || echo no)" yes
check SD12-rc "$rc" 0
check SD12-banner "$(printf '%s' "$out" | grep -c 'make doctor')" 1
check SD12-no-digest "$(printf '%s' "$out" | grep -c 'memory digest:')" 0
check SD12-unknown "$(printf '%s\n' "$out" | grep -c -x -- '- open: unknown (memory.sh index failed)')" 1
# SD16: a memory.sh whose `check` hangs costs under 3.5 s, exit 0
printf '#!/usr/bin/env bash\ncase "$*" in *check*) sleep 10 ;; esac\n' \
+2 -2
View File
@@ -31,8 +31,8 @@ Operates on `.claude/memory/` in the current project (CWD). Curates the
- **Git is the backup.** Skill writes in-place. PRECHECK refuses to run
if working tree dirty on registry files.
- **Append-only friendly.** Marks entries with a `superseded by <ID>` or
`deprecated` status written by `memory.sh status` instead of deleting. Body of old entry stays
for history.
`deprecated` status written by `memory.sh status` instead of deleting.
Body of old entry stays for history.
- **IDs stable.** Never renumber. Merges create a new ID; sources keep
their ID with superseded status.
- **Caveman style enforced.** Per CLAUDE.md memory rule, all writes are
@@ -11,7 +11,8 @@ set -uo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SKILL="${SKILL:-$HERE/../SKILL.md}"
SANDBOX="$(mktemp -d "${TMPDIR:-/tmp}/prune-red.XXXXXX")"
SANDBOX="$(mktemp -d "${TMPDIR:-/tmp}/prune-red.XXXXXX")" || exit 1
[ -n "$SANDBOX" ] || exit 1
trap 'rm -rf "$SANDBOX"' EXIT
fail=0