From 038670e4e8478c2757088eff17e652db3dc7768e Mon Sep 17 00:00:00 2001 From: bchanot Date: Sun, 15 Nov 2026 20:40:28 +0100 Subject: [PATCH] docs: digest unknown line also covers an unparsable BLK row; changelog for index fail-closed --- CHANGELOG.md | 1 + README.md | 2 +- USAGE.md | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4b8d71..f68073f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ The BDR-125 context queue is delivered: phases 0, 0b, 4a, 1, 5, 2 and 4b-4d ship ### Fixed - `settings.json` denies a docker mount of the host root in 7 spellings: `/:/` after a space (`-v`, `--volume`) or after `=` (`-v=`, `--volume=`), the attached `-v/:/`, and `--mount` with `source=/` or `src=/` followed by a comma or a space. Each shape is denied under any subcommand and four prefixes (`docker`, `rtk docker`, `*/rtk docker`, `*/docker`): 28 rows. The 3.0.0 row `Bash(docker run * -v /:/*)` needed a token before `-v`, so a plain `docker run -v /:/x img` passed, and `Bash(docker run -v /:*)` (legacy prefix syntax) matched nothing. Both stay until the next removal window. The `autoMode.soft_deny` docker entry now names `docker create`, `docker container run` and `docker compose up` next to `docker run`. Left to the classifier: attached flag clusters (`-itv/:/x`), a host path from a variable or a substitution, root aliases (`//`, `/.`, `/..`), upper-case mount keys and compose-file volumes. Test: `lib/tests/push-guard.test.sh` T41 locks the 28 rows. +- `lib/memory.sh index ` exits 2 when the named registry exists but is not a readable regular file (directory, FIFO, dangling symlink, unreadable) or `.claude/memory` is not a searchable directory; `index` with no kind skips such a registry with a stderr line and exits 0. A non-regular `blockers.md` used to be skipped silently, so the session digest printed a false `- open: none`. The digest also prints `- open: unknown` on a `| BLK-` row it cannot parse. - `cc [profile]` (lib/cc.sh) raises the session's `oom_score_adj` to 500 before `exec claude` (raise-only, silent if the write fails). sshd's systemd override `OOMScoreAdjust=-1000` was inherited through tmux and dtach by every claude started with `cc`, so the OOM killer never picked a runaway session; `systemd-run --scope` rejects that property, hence the write inside the session (BLK-044). Test: `lib/tests/cc.test.sh` T7-oom. - `lib/project-rules.sh` (`extract`, `emit`): the out-path check resolves the rule file's first existing parent physically and refuses (rc 2, `must stay under the project`) a path a symlinked component sends outside the project; 3.0.0 checked `..` lexically only. `emit` goes through the same check and reports `cannot create` or `not written` (no partial file) with rc 2 where it printed `emitted`. An `extract` that wrote the rule but fails to rewrite CLAUDE.md keeps the rule file and the rewritten text in a temp file and names both on stderr with the command to complete or abort; it used to delete both. `/onboard` and `/init-project` keep an existing rule on an rc 2 ending in ` exists` and stop on any other rc 2. Tests: `lib/tests/project-rules.test.sh` T9h (re-asserted), T9z3 to T9z13. - `lib/memory.sh`: `memory_legacy_status` (the v1 status reader behind `memory.sh upgrade`, `/reconcile`, `/prune-memory`) ends an entry's range at the next heading of another entry of the same prefix, any level, outside a code fence, or at `## Index`: a `### BLK-` entry no longer lends its status to the `## BLK-` entry above, and a trailing `## Index` is no longer read. `memory.sh upgrade` on an entry with no strict status word writes the single word of its v1 `Status`/`Statut` label as the dated upgrade status line; when the `## Index` cell disagrees the body word wins and stderr says `kept body , dropped Index ` (the Index used to win); an Index `superseded`/`deprecated` still wins; a label without exactly one word is refused on a blocker and leaves the Index cell on a decision. Control characters from a v1 line or an Index cell print as `?`. `memory.sh journal` leaves exactly one blank line before a new date heading (a file ending with a blank line got two, one without a final newline got none). Tests: `lib/tests/memory.test.sh` T14l-gap, T15-statut-*, T15-bdr-*, T15-idx-*, T15-ctl-*, T15-trailing-index-not-read. diff --git a/README.md b/README.md index 4b0773e..79429f2 100644 --- a/README.md +++ b/README.md @@ -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 ` (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 — <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; `- 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. +- 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, times out or returns a `| BLK-` row it cannot parse), 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`. diff --git a/USAGE.md b/USAGE.md index 0174745..61d77b8 100644 --- a/USAGE.md +++ b/USAGE.md @@ -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 ; `- 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. +- 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, dépasse son délai ou renvoie une ligne `| BLK-` illisible), 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`.