diff --git a/.claude/audits/BUGS-FOUND.md b/.claude/audits/BUGS-FOUND.md index ad5294e..39acfd7 100644 --- a/.claude/audits/BUGS-FOUND.md +++ b/.claude/audits/BUGS-FOUND.md @@ -13,3 +13,11 @@ - agents/status-reporter.md:35 + agents/plugin-probe.md:22-23,69 — report installed (cache) or user-scope `claude plugin list` state as "active"; the per-project state is the PROFILE line (`current --plain`). Severity: low. Discovered while: code-clean 2026-11-09. Not fixed. FIXED 2026-11-10 (/bugfix, bugfix/banner-effective-profile): status-reporter takes `Plugins ON:` from `list_on_plugins` + `pack-*=on` (cache = installed only); plugin-probe comment and plugin-advisor INPUT name PROFILE as the per-project source (PLUGINS = installed). - agents/handover-doc-writer.md:77-84 — parses registry statuses by hand ("open vs resolved"), the class behind the BLK-032..034 false-open (BDR-129). A fix must read `memory.sh -C index` on v2 registries and keep the `## Index` read on v1 registries never upgraded (`memory.sh index` ignores a v1 Index; memory.sh:21-23). Severity: medium (client deliverable). Discovered while: code-clean 2026-11-09. Not fixed. + FIXED 2026-11-11 (/bugfix, bugfix/handover-memory-status): new `reconcile_blk_classify` (lib/reconcile.sh: strict word on v2, single-word status label on v1 via `_mem_v1_word`, never the `## Index`; closed omitted, prose/mixed/`closed`/`###` entries = unreadable); STEP 9 rooted on the PACKAGE root; SYNTH REPORT fenced with a mandatory `MEMORY:` line, relayed to the user and into the 9.7 report; test lib/tests/handover-memory-contract.test.sh HM1-HM3 runs the shipped STEP 9 block. The request's "keep the v1 Index read" was dropped after challenge round 1 (the Index drifts, BDR-129, LRN-055). + + +- agents/handover-doc-writer.md §6.1 — vulgarizes BDRs with no status filter: a superseded or deprecated decision can read as current in the client deliverable. Severity: medium (client deliverable). Discovered while: /bugfix G5 challenge round 1. Not fixed. +- lib/memory.sh `upgrade` (`mem_want`, `_mem_verdict_diff` skips Index-stated IDs) — may take a stale v1 `## Index` cell over a `**Statut** :` body line. UNVERIFIED: check before recommending `upgrade` on v1 repos (faunosteo). Severity: medium if real (wrong status written into the body). Discovered while: /bugfix G5 challenge round 1. Not fixed. +- agents/handover-doc-writer.md STEP 10 and other paths — `git log` and file reads are cwd-relative, not rooted on the PACKAGE root; the PACKAGE `PROJECT:` line is space-separated, so a root containing a space mis-parses (the G5 orchestrator check only catches it when blockers.md exists). Severity: low. Discovered while: /bugfix G5 challenge round 1. Not fixed. +- lib/memory.sh `memory_legacy_status` default range (`## ID` to the next `## BLK-`) — on a v1 registry a `### BLK-` entry after a `## BLK-` entry feeds its status line to the `##` entry: a resolved `###` entry can close the open `##` entry above it, which then leaves the handover §5 (the `###` ID itself is flagged unreadable). Severity: low (rare dialect, flagged indirectly). Discovered while: /bugfix G5 verifier. Not fixed. +- agents/handover-doc-writer.md:83 + agents/client-handover-writer.md:1201-1202 — `ROOT=""` pastes the root into a double-quoted literal, and the printed remedy `memory.sh -C status …` leaves `` 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. diff --git a/.claude/memory/blockers.md b/.claude/memory/blockers.md index 1026814..74b8bf0 100644 --- a/.claude/memory/blockers.md +++ b/.claude/memory/blockers.md @@ -403,3 +403,8 @@ rules: - **Friction**: passive-cost figures disagreed: banner `_plugin_costs` (gstack 2750, ui-ux-pro-max 400, context7 200, graphify 300) and plugin-advisor `~Nt` vs doctor.sh (ui-ux 670 only). Banner 💰 row divided by per-plan "budget" (Pro 11000, Max 20000). - **Real cause**: hand-copied constants. 2026-09-28 skill-catalog prune re-measured doctor (ui-ux 400 → 670, gstack/context7/graphify dropped: skills already in catalog) but missed banner + advisor citers (BDR-100 class). Measured 2026-11-10: gstack 3 packs ~445t (~196/120/129), ui-ux ~666t, context7 = CLI, find-docs skill always loads. - **Solution**: user split. Bugfix removed constants, 💰 row, budget block, dead `detect_plan` (BLK-043 source); advisor + status-reporter point to `make doctor`; detect-plan.test.sh → hook-recursion-guard.test.sh; SB9/SB10. Commit 1971b8d. Measured-cost API = TODO feature (spec input: two challenge rounds in plan 2026-11-10-passive-cost-source-1330). + +## BLK-048 — Handover STEP 9 parsed blocker status by hand, client section 5 could list closed or drop open [resolved 93a8e19] (2026-11-11) +- **Friction**: handover-doc-writer STEP 9 said "parse manually", blocker status read from prose of cwd-relative `.claude/memory`. Client §5 could list closed blocker or drop open one (BLK-032..034 class). +- **Real cause**: agent prompt bypassed shared readers. `reconcile_blk_open` not reusable as is: v1 branch closes on substring "resolved" (drops `unresolved`); v1 non-word lines (`closed`, prose) leak as open; `###` entries invisible to enumerator. +- **Solution**: new `reconcile_blk_classify` (lib/reconcile.sh): strict word v2, `_mem_v1_word` v1, never `## Index`; closed omitted; empty/prose/mixed/`closed`/`###` = unreadable. STEP 9 rooted on PACKAGE root, `no-file` / `reader-unavailable` lines. Fenced SYNTH REPORT, mandatory `MEMORY:` line; orchestrator retries when missing or contradicted by existing blockers.md, relays unreadable IDs + `memory.sh status` remedy in 9.7. Test handover-memory-contract.test.sh HM1-HM3. Commit 93a8e19. Real data: game repo 14 unreadable (v1 `status:` lines left after upgrade). Follow-ups G6-G9 in BUGS-FOUND. diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index d313e32..9884e0e 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -716,3 +716,6 @@ rules: ## 2026-11-10 - 2026-11-10: /bugfix G1+G4 banner effective profile: list_on_plugins (profile managed ids, user scope rest) feeds ✅ row, detect_uiux_pro_max, /status; 2 challenge rounds (doctor pipefail BLOCKER r2), gates MET/CONFORME/PASS; 556d0e6, changelog 6cdc374. - 2026-11-10: /bugfix G2 passive-cost constants: 2 challenge rounds (FATAL r2) showed measured-cost API = feature; user split: constants, banner 💰 budget row, dead detect_plan removed, agents → make doctor; 1971b8d (amended, force push by user), docs 9777a47; API in TODO. + +## 2026-11-11 +- 2026-11-11: /bugfix G5 handover blocker status: 2 challenge rounds -> r3 reconcile_blk_classify (open/closed/unreadable), STEP 9 rooted on PACKAGE root, mandatory SYNTH MEMORY line relayed to user; gates MET/CONFORME/PASS first pass; commit 93a8e19 + changelog; G6-G9 + 2 LOW logged in BUGS-FOUND; BLK-048, LRN-276. diff --git a/.claude/memory/learnings.md b/.claude/memory/learnings.md index dab9929..6bae354 100644 --- a/.claude/memory/learnings.md +++ b/.claude/memory/learnings.md @@ -2026,3 +2026,8 @@ Rule: when editing a doctrine file under structure locks, grep the test's lock s - **Context**: G2 commit. `git add a b lib/tests/detect-plan.test.sh 2>/dev/null` after `git mv` of that path: pathspec missing → git aborts WHOLE add, stderr silenced. Commit 63832fd landed with only pre-staged rename under full fix message; post-commit auto-push published it. Repair = amend + force push (user ran it: force push denied to Claude). - **Pattern**: never `2>/dev/null` on `git add`; one bad pathspec stages nothing. After any commit check `git show --stat HEAD` against intended file list before reporting. - **Future application**: every commit step in skills (bugfix, feat, hotfix, commit-change) after a rename/delete; stage renamed paths by new name only. + +## LRN-276 — Test the shipped prompt snippet, not a copy; status consumer has an unreadable bucket (2026-11-11) +- **Context**: G5 handover fix. Agent prompt carries bash snippet (STEP 9). Census grep on tokens stays green when snippet logic breaks; retyped copy in test drifts from shipped one. +- **Pattern**: test extracts shipped fenced block (awk: first ```bash fence under its heading), sed swaps placeholders (root, lib dir) for fixture paths, runs with `bash `; negative control = HEAD block prints nothing. Status consumer classifies by ONE known word: closed → omit, known open word → list, anything else → unreadable bucket, flagged to user, never dropped, never substring close. +- **Future application**: any agent/skill prompt holding shell (handover, reconcile, status-reporter); any new reader of registry status. diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index 307fa53..a7ccce3 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -138,7 +138,7 @@ Shared rules for every phase: - [ ] D3 visible (= docs backlog P34): packs vocabulary in agents/plugin-advisor.md (:99 PROFILE template in the old `profile.sh current` format, :126-129 rollback, gstack ON/OFF rules, context7 ON) and USAGE.md:181,232,233,1090,1092,1095 - [ ] D4 skill behavior: skills/prune-memory STEP 1.A/3 detection (per-entry frontmatter, raw `status:` lines) → read statuses via `memory.sh index` (v1 + v2); keep example IDs 9xx (RED-7) - [ ] D5 user rules: rules/web-security.md vs rules/secure-by-default.md: strict duplicates (web-security :11, :19, "Login rate limiting," in :20) and password wording conflict ("bcrypt/argon2" vs "argon2id (bcrypt or scrypt otherwise)"); cookie flags, upload type/size, forced HTTPS, security headers are unique to web-security - - [x] G1+G4 fixed (bugfix/banner-effective-profile, merged a655b06); G3 fixed (merged 9f9821e); G2 hand figures removed (bugfix/passive-cost-source, plan `.claude/tasks/plans/2026-11-10-passive-cost-source-1330.md` r3); G5 open + - [x] G1+G4 fixed (bugfix/banner-effective-profile, merged a655b06); G3 fixed (merged 9f9821e); G2 hand figures removed (bugfix/passive-cost-source, plan `.claude/tasks/plans/2026-11-10-passive-cost-source-1330.md` r3); G5 fixed (bugfix/handover-memory-status, 93a8e19, plan `.claude/tasks/plans/2026-11-10-handover-memory-status-1600.md` r3); follow-ups G6-G9 + 2 LOW quoting in BUGS-FOUND - [ ] feature (G2 split, user 2026-11-10): measured passive-cost API, one source for doctor / /status / plugin-advisor (probe COSTS field). Spec input = the two challenge rounds in the G2 plan: unit = pack or ON plugin (skills + agents + commands descriptions; pr-review-toolkit ~1550t, example-skills ~2350t), doctor counts OFF packs (higgsfield, extras), `detect_plugin_dev` globs the wrong cache level and ignores enabled state, `?` for not-installed or empty units, rc-0 sentinels (`costs-unavailable`/`unknown`) for doctor's `set -euo pipefail`, profile.sh failure → unknown, `python3 -I` (probe runs in the user's project), installPath from installed_plugins.json. Doctor keeps its measured ui-ux 670 until then. - [ ] D3 add-ons from G2 (plugin-advisor.md): plan-budget WARN :317 (unreachable: plugin-gate never sends PLAN, detect_plan gone), :42 "absolute COST ESTIMATE still reported", :105 `(budget: ~t | n/a)`, :222 "passive cost estimate = highest-cost package profile", "0t passive" claims for impeccable / design-motion-principles (:226 :227 :268 :269); USAGE.md :248 "Budget Pro (~11k tokens/5h)", :494 `(~400t)`, :923 `(~200t)`; session-banner.test.sh SB10 `gone()` passes on a missing file (add an existence check) - [ ] D6 project rule: .claude/rules/graphify-vendored.md says `graphify install --platform claude` "touches nothing else", but graphifyy 0.9.67 appends a `# graphify` block to ~/.claude/CLAUDE.md (= CLAUDE.global.md); `graphify claude install` writes into the caller's cwd, so the install-plugins.sh trap protects $REPO only when run from $REPO diff --git a/.claude/tasks/contracts/2026-11-10-handover-memory-status-1600.md b/.claude/tasks/contracts/2026-11-10-handover-memory-status-1600.md new file mode 100644 index 0000000..59585de --- /dev/null +++ b/.claude/tasks/contracts/2026-11-10-handover-memory-status-1600.md @@ -0,0 +1,30 @@ +# CONTRACT — handover-memory-status +- date: 2026-11-10 | flow: bugfix | branch: bugfix/handover-memory-status +- status: active + +## REQUEST (verbatim — IMMUTABLE) +G5 from .claude/audits/BUGS-FOUND.md (code-clean 2026-11-09): agents/handover-doc-writer.md:77-84 parses memory registry statuses by hand ("open vs resolved"), the class behind the BLK-032..034 false-open (BDR-129). A fix must read `bash ~/.claude/lib/memory.sh -C index` on v2 registries and keep the `## Index` read on v1 registries never upgraded (`memory.sh index` ignores a v1 Index; lib/memory.sh:21-23). Severity medium (client deliverable). Regression test if the repo has a harness for agent prompts or memory.sh index on v1/v2 fixtures. Mark BUGS-FOUND G5 FIXED. make test needs GATES_TIMEOUT=600 + PATH=$HOME/.bun/bin:$PATH (LRN-271). Foreign-code style. Lessons in force: LRN-274 (pipefail), LRN-275 (never silence git add, check commit stat). + +## CLARIFICATIONS +Q: which blockers are "open" for §5? / A: status not closed (closed = resolved | superseded | deprecated): open and upstream both listed (user, 2026-11-10) [gated] +Q: a blocker whose status cannot be read? / A: kept out of §5, flagged in the SYNTH REPORT, relayed to the user by the orchestrator (user, 2026-11-10) [gated] +Q: "cannot be read" = ? / A: no reader maps the status to exactly one known word of $_MEM_WORDS (empty, prose, mixed, `closed`, `###` entry); reading of the gated decision (orchestrator, from both r2 challenge lenses) +Q: the request's "keep the `## Index` read on v1"? / A: dropped after challenge round 1 (BLOCKER: the Index drifts, BDR-129/LRN-055); v1 uses the legacy lexical reader, never the Index (orchestrator) +Q: plan revisions? / A: plan r3 after two challenge rounds: .claude/tasks/plans/2026-11-10-handover-memory-status-1600.md is the binding FIX PLAN (orchestrator) + +## ACCEPTANCE CRITERIA +1. Symptom gone: STEP 9 reads blocker statuses through `reconcile_blk_classify` rooted on the PACKAGE root, never by hand; the shipped snippet run on v1/v2 fixtures lists open/upstream blockers, omits closed ones (an Index row saying open does not reopen a resolved body), and puts unreadable ones (empty, `closed`, mixed, negated-only, `###` heading) in the unreadable bucket; regression suite present and green. + CHECK: cd /home/bchanot/Documents/claude && GATES_TIMEOUT=600 PATH="$HOME/.bun/bin:$PATH" make test suite=lib/tests/handover-memory-contract.test.sh 2>&1 | tail -1 | grep -q 'all suites green' && grep -q 'HM3' lib/tests/handover-memory-contract.test.sh && grep -q '^reconcile_blk_classify()' lib/reconcile.sh && ! grep -q 'parse manually' agents/handover-doc-writer.md && echo SYMPTOM-GONE + EXPECT: SYMPTOM-GONE + EVIDENCE: MET exit=0 marker-found :: SYMPTOM-GONE +2. Report contract: the SYNTH REPORT is a fenced template with a mandatory `MEMORY:` line; the orchestrator treats a missing MEMORY line, or `no blockers file` / `reader unavailable` while blockers.md exists, as malformed, prints any other non-`none` value and carries it into the 9.7 report. + CHECK: cd /home/bchanot/Documents/claude && grep -q 'MEMORY: unreadable BLK:' agents/handover-doc-writer.md && grep -q 'reader-unavailable' agents/handover-doc-writer.md && grep -q 'MEMORY:' agents/client-handover-writer.md && grep -q -- '- Memory:' agents/client-handover-writer.md && ! grep -q 'bash -c' agents/handover-doc-writer.md && echo REPORT-OK + EXPECT: REPORT-OK + EVIDENCE: MET exit=0 marker-found :: REPORT-OK +3. Build/tests green (full suite, GATES_TIMEOUT=600, bun on PATH); shellcheck at warning level clean on the touched shell files. + CHECK: cd /home/bchanot/Documents/claude && shellcheck -S warning lib/reconcile.sh lib/tests/handover-memory-contract.test.sh && GATES_TIMEOUT=600 PATH="$HOME/.bun/bin:$PATH" make test 2>&1 | tail -1 | grep -q 'all suites green' && echo GREEN + EXPECT: GREEN + EVIDENCE: MET exit=0 marker-found :: GREEN + +## FILE SCOPE +lib/reconcile.sh (new function + Layers line only), agents/handover-doc-writer.md (STEP 9, §5 source line, SYNTH REPORT template), agents/client-handover-writer.md (SYNTH REPORT parse, 9.7 report bullet), lib/tests/handover-memory-contract.test.sh (new); bookkeeping (orchestrator): .claude/audits/BUGS-FOUND.md diff --git a/.claude/tasks/plans/2026-11-10-handover-memory-status-1600.md b/.claude/tasks/plans/2026-11-10-handover-memory-status-1600.md new file mode 100644 index 0000000..dd6a85d --- /dev/null +++ b/.claude/tasks/plans/2026-11-10-handover-memory-status-1600.md @@ -0,0 +1,98 @@ +# FIX — handover-memory-status (/bugfix G5, 2026-11-10) — r3 after two challenge rounds + +Source: .claude/audits/BUGS-FOUND.md entry G5. + +## Diagnosis +Symptom: the client deliverable can list a closed blocker as open, or an open one as closed. `agents/handover-doc-writer.md` STEP 9 (:71-87) says "read each file (full contents, parse manually)" and "`blockers.md` → BLK-XXX entries (open vs resolved)"; §5 "Ce qui vous reste à faire" (:315-318) lists "open `blockers.md` entries" to the client. Statuses parsed from prose are the BLK-032..034 false-open class (BDR-129): a word like "resolved" in a Solution or title line is not a status; the status is the heading `[tag]` or a labelled Status/Resolution/Action/UPDATE/FINAL line, last candidate wins (lib/memory.sh header :28-38). Also `MEMORY_DIR=".claude/memory"` is relative while a dispatched agent's cwd is the session's, not necessarily the project's; the PACKAGE carries `PROJECT: … root=`. +Evidence (2026-11-10, scratch fixtures): `memory.sh index` on a v1 registry whose statuses live only in `## Index` prints empty Date and Status. Robustness r2 probes: `reconcile_blk_open`'s v1 branch drops any line containing the substring "resolved" (reconcile.sh:103), so `Statut : unresolved` and `open (not resolved)` vanish as closed (contradicts BDR-133); a v1 `- **Status**: closed` or a prose `HTTP status 500` line comes out of memory_status_word as a non-word and would land in §5; `### BLK-` entries are invisible to reconcile_enumerate_ids (`^## ` only). Real data: /home/bchanot/Documents/game blockers.md (v2) gives an empty strict status for 15 of 34 blockers (v1 `date: · status:` lines left in an upgraded file), BLK-019 `status: upstream (ops)` among them. +Blast radius: handover-doc-writer synthesize mode only; its orchestrator agents/client-handover-writer.md relays the reports. Other memory readers already go through memory.sh or headings. +RELATED MEMORY: honors BDR-129 (strict reader on v2, legacy lexical reader on v1, never the Index), BDR-133 (a negated status word does not count, v1 included), LRN-055 (a reconciler never trusts the Index); BLK-032..034 (the false-open class); LRN-271 (make test env); LRN-274 (pipefail-safe lib functions); LRN-275 (stage by explicit paths, check commit stat). + +## User decisions (2026-11-10) [gated] +- Open blocker for §5 = status not closed (closed = resolved | superseded | deprecated, `memory_closed`): `open` and `upstream` both listed. +- A blocker whose status cannot be read: kept out of §5, flagged in the SYNTH REPORT and relayed to the user by the orchestrator. +- Reading of "cannot be read" (orchestrator, from decision 2, both r2 lenses): no reader maps the status to exactly one known word of `$_MEM_WORDS` (empty, prose, mixed, negated, `closed`/`fixed`/`done`, or an entry under a `###` heading). Fail-safe: such an entry is never listed open and never dropped silently. + +## Fix plan (r3) +1. `lib/reconcile.sh`: new public function after `reconcile_blk_open` (header Layers list gets one line): + ```bash + # blockers for a client deliverable → "idopen|unreadableword or + # line": closed ones are omitted. A status no reader maps to exactly one + # known word is unreadable, never open (BDR-129, BDR-133): v2 strict word, + # v1 the single word of a status/statut label (_mem_v1_word: prose, mixed + # or negated lines give none). Entries under a heading the enumerator + # cannot see (`### BLK-`) are unreadable too. + reconcile_blk_classify() { + local id st w v2="" + memory_is_v2 "$1" && v2=1 + for id in $(reconcile_enumerate_ids "$1" BLK); do + st=$(reconcile_blk_current_status "$1" "$id") + if [ -n "$v2" ]; then w=$(memory_status_word "$st") + else w=$(_mem_v1_word "$st"); fi + [ -n "$st" ] || w="" + memory_closed "$w" && continue + case " $_MEM_WORDS " in + *" $w "*) [ -n "$w" ] && { printf '%s\topen\t%s\n' "$id" "$w"; continue; } ;; + esac + printf '%s\tunreadable\t%s\n' "$id" "${st:0:80}" + done + MEM_GREP="$RECONCILE_GREP" _mem_heading_ids "$1" BLK | sort -u \ + | comm -23 - <(reconcile_enumerate_ids "$1" BLK) \ + | while read -r id; do printf '%s\tunreadable\theading level\n' "$id"; done + return 0 + } + ``` + (Exact shape is the executor's within the file's style; the contract is the output format and the classification. `return 0`: LRN-274, rc must not depend on the last test under pipefail.) `reconcile_blk_open` is unchanged (/reconcile keeps its own semantics). +2. `agents/handover-doc-writer.md` STEP 9 — LOAD MEMORY REGISTRIES (:71-87), rewrite: + ```bash + ROOT="" + MEMORY_DIR="$ROOT/.claude/memory" + test -d "$MEMORY_DIR" || MEMORY_DIR="" + # Blocker statuses through the shared reader (BDR-129): never parsed by hand. + B="$MEMORY_DIR/blockers.md" + if [ -z "$MEMORY_DIR" ] || [ ! -f "$B" ]; then echo "blockers: no-file" + elif . "$HOME/.claude/lib/reconcile.sh"; then reconcile_blk_classify "$B" + else echo "blockers: reader-unavailable"; fi + ``` + (no `bash -c`: settings.json asks on it.) Prose after it: + - Rows `IDopenword` = the open blockers for §5. Rows `IDunreadable…` = kept out of §5, their IDs go on the SYNTH REPORT `MEMORY:` line. + - `blockers: no-file` → no blocker in §5, `MEMORY: no blockers file`. `blockers: reader-unavailable` → no blocker in §5, `MEMORY: reader unavailable`. + - Read each registry file in full for the narrative fields (titles, decisions, why, alternatives, cause, solution, journal summaries). A blocker's status is never taken from the file's prose, only from the reader above. + - Bullet list kept; the `blockers.md` line → "BLK-XXX entries: open/unreadable from the reader above, narrative from the file". The `decisions.md` bullet keeps "status" (BDR status handling = G6, not this fix). + - Memory dir missing or empty: unchanged (git data only, flagged). +3. `agents/handover-doc-writer.md` §5 source list (:317-318): "open `blockers.md` entries" → "open blockers from STEP 9 (unreadable ones excluded)". +4. `agents/handover-doc-writer.md` synthesize mode (:56-57): the inline SYNTH REPORT list becomes a fenced template, same layout as the HANDOVER-DOC REPORT (:842-853): + ``` + SYNTH REPORT + STATUS: DONE | BLOCKED + RUNID: + PHASE CLUSTERS: + WORDS: §1= §2= §3= §4= §5= §6= + MEMORY: unreadable BLK: | no blockers file | reader unavailable + ``` + The MEMORY line is mandatory on DONE. +5. `agents/client-handover-writer.md` SYNTH REPORT parse (:1150-1152): `STATUS: DONE` with no `MEMORY:` line = malformed (existing retry-once-then-escalate path). `MEMORY: no blockers file` or `MEMORY: reader unavailable` while `/.claude/memory/blockers.md` exists = malformed too (a mis-parsed root or a broken lib, never a quiet empty §5). Any MEMORY value other than `unreadable BLK: none` → printed to the user before render, and repeated in the 9.7 final report as a bullet `- Memory: `, with for unreadable IDs the remedy `bash ~/.claude/lib/memory.sh -C status ", …"` then a re-run. +6. Regression test: new `lib/tests/handover-memory-contract.test.sh` (house style: `set -u`, pass/fail counters, final `handover-memory-contract: %d passed, %d failed`, exit 1 on fail; fixtures under `mktemp -d`, cleanup only by the EXIT trap, printf-built, no link to the real ~/.claude): + - HM1 census agents/handover-doc-writer.md: contains `reconcile_blk_classify`, `MEMORY: unreadable BLK:`, `reader-unavailable`, a fenced `SYNTH REPORT`; no `parse manually`; no `MEMORY_DIR=".claude/memory"`; no `bash -c`. + - HM2 census agents/client-handover-writer.md: the SYNTH REPORT parse names `MEMORY:`, treats its absence as malformed, and the 9.7 report carries `- Memory:`. + - HM3 behaviour, on the SHIPPED snippet: extract the first fenced bash block under `## STEP 9` of agents/handover-doc-writer.md, substitute `` with the fixture root and `$HOME/.claude/lib` with the repo's lib dir, run it with bash. Fixtures: + (a) v1 blockers.md (no `format: 2`): `## Index` row says open but body `- **Statut** : resolved` → absent; `- **Statut** : upstream` → `open upstream`; `- **Status**: superseded by BLK-002` → absent; no status line → unreadable; `- **Status**: closed` → unreadable; `- **Statut** : upstream (superseded by #42)` → unreadable (mixed); `- **Statut** : open (not resolved)` → `open open` (negated word ignored, BDR-133; probed 2026-11-10); `- **Statut** : unresolved` → unreadable, never absent; `- **Status**: open` → `open open`; a `### BLK-009` entry → unreadable `heading level`. + (b) v2 blockers.md (`format: 2`): `## BLK-001 — t [open]` whose Solution says "resolved the issue partially" → `open open`; `- **Status (2026-11-01)**: resolved` → absent; `[upstream]` → `open upstream`; no status → unreadable. + (c) no blockers.md → `blockers: no-file`; (d) lib dir substituted with an empty dir → `blockers: reader-unavailable`. +7. Bookkeeping (orchestrator): BUGS-FOUND G5 FIXED; new BUGS-FOUND lines (not fixed here): (G6) handover-doc-writer §6.1 vulgarizes BDRs with no status filter (a superseded decision can read as current); (G7, unverified) `memory.sh upgrade` `mem_want` may take a stale v1 Index cell over a `**Statut** :` body (`_mem_verdict_diff` skips Index-stated IDs): check before recommending upgrade on v1 repos; (G8) handover-doc-writer STEP 10 `git log` and other paths are cwd-relative, not `$ROOT`-rooted, and the PACKAGE `PROJECT:` line is space-separated (a root with a space mis-parses; the step 5 check only catches it when blockers.md exists). + +## Edge cases +- Agent cwd ≠ project: STEP 9 is rooted on `$ROOT` (other relative paths: G8). +- A v1 `## Index` placed after the last entry can leak into that entry's legacy range (memory_legacy_status reads to the next `## BLK-`): an Index row's text may become its status line. _mem_v1_word then needs a status/statut label with exactly one word, so a table row gives none → unreadable (flagged), not a false open. +- v1 title-suffix statuses (`— RESOLVED` in the heading) are not read by memory_legacy_status's default range: such entries come out unreadable (flagged), the remedy is `memory.sh status` or `upgrade`. +- v2 registries with leftover v1 `status:` lines (game repo: 15/34) come out unreadable: correct per BDR-129, the flag + remedy reach the user in 9.7. +- Entries after an unclosed fence: the enumerator and `_mem_heading_ids` are both plain greps, same view; accepted limit as in /reconcile. +- No `bash -c`, no write: the snippet only reads. Sourcing reconcile.sh sets `-uo pipefail` in the agent's shell, as /reconcile already does. + +## In-force +BDR-129, BDR-133, LRN-055, BLK-032..034, LRN-271, LRN-274, LRN-275. Foreign-code style (prompt files keep their voice and layout; reconcile.sh keeps its function/comment style). +Files: lib/reconcile.sh, agents/handover-doc-writer.md, agents/client-handover-writer.md, lib/tests/handover-memory-contract.test.sh (new). + +## Challenge summary +- Round 1: BLOCKER (v1 Index fallback re-opened the bug) → r2 legacy reader. +- Round 2 (cap reached, no round 3): correctness CONCERNS(3), robustness CONCERNS(3), simplicity CONCERNS. Folded into r3: classification by known word (v1 `_mem_v1_word`, unreadable bucket), reconcile_blk_open dropped from the snippet (its v1 substring close), `###` entries flagged, no-file vs reader-unavailable split + orchestrator check, MEMORY carried to the 9.7 report with remedy, fenced SYNTH REPORT, HM3 runs the shipped block, decisions bullet keeps "status", Index-after-entries edge case. diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a650e4..d9806ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -74,6 +74,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/) and this project ### Fixed - `/guardrails` and the interviewer cite the secure-by-default, Supabase, cloud-function and a11y rules by their absolute `~/.claude/rules/.md` path; run from a project repo, the bare `rules/.md` path resolved against that project and missed the rule files. - `/reconcile` no longer reports a v2 blocker as open because a status word appears in its title or prose (BLK-032..034). +- `/client-handover` §5 lists only open blockers: statuses come from `reconcile_blk_classify` (lib/reconcile.sh) at the project root instead of being parsed by hand, and a blocker whose status cannot be read stays out of §5 and is named in the final report (`Memory:` line, with the `memory.sh status` command that fixes it). - model-router probes the model main is about to run on, moved to or kept (the session's own model included), before routing main to it: with a model out of usage credits, every new session and hold lapse used to route main there, or keep it there, and lose the turn to a 429. That model is tried once with a small completion bounded to 8 s; a timeout or error marks it down (reason `probe`) and the decision is taken again once. A model that answered is not probed again until marked down (kept across `/clear`). `"probe": false` in `~/.claude/model-router.json` turns it off; `/route show` prints `probe:`. When a lower model stands in for its tier's held head, the phase's own effort goes one notch up (reflect xhigh, plan max, orchestrate high on Opus); explicit and floor efforts are never raised. Tests: `mods/model-router/hooks/register.test.ts`. - model-router residuals of waves 1-4 (2026-10-11): the kill switch fails closed (a `~/.claude/model-router.json` present but unreadable at first load, or an `enabled` that is not a boolean, turns the router off and says so; `/route reload` answers `config unreadable; previous config kept` instead of `config reloaded`); a prompt rule whose pattern nests quantifiers (`(a+)+$`) is dropped; a config file that is not a regular file reads as failed; every log of a caught error prints its kind and code only, never the message (a JSON parse error quotes the file); rejected table keys are masked in logs and model alias keys must be short printable names; `__proto__`, `constructor` and `prototype` are never read or written as keys; the agent offers map is capped like the descriptions; a `models` alias added without a `fallback` list is ranked at the end of the default chain (the upgrade gates now apply to it); a dated or variant id maps to its table id only at a `-` boundary (`claude-sonnet-5-50` no longer reads as sonnet); the status refresh and the main-decision log on the step path can no longer unroute a step; the route tool's failure answer says the route may be partly applied. `lib/tests/mods.test.sh` proves `claude plugin test` exists from its usage line (an unknown subcommand exits 0), `doctor.sh` bounds `claude plugin list --json` to 60 s, `update-all.sh` skips `@skills-dir` mods. Kit 428 → 431. - model-router residuals of the confirmation waves: a failed `/route forget` or `/route ask` write logs its cause and answers a generic text; forget answers clean every file-sourced name, phase and key; a restore names a frontmatter file only for a valid skill name and refuses a `__proto__` row; `/route forget` never restores `changed.phases`; the dialog's Change offers and writes shipped phases only (a machine-only phase never reaches routing.json, and an alias no shipped phase uses says so); a failure after the user answered keeps the key asked instead of asking again at every use. diff --git a/agents/client-handover-writer.md b/agents/client-handover-writer.md index b4d84ce..ff81579 100644 --- a/agents/client-handover-writer.md +++ b/agents/client-handover-writer.md @@ -1150,7 +1150,12 @@ PACKAGE: Parse its `SYNTH REPORT`: `STATUS: BLOCKED` → surface verbatim, stop (do not patch the PACKAGE silently); malformed/mute → retry ONCE fresh, then -escalate. `STATUS: DONE` → THEN render: +escalate. `STATUS: DONE` with no `MEMORY:` line is malformed (same +retry-once path); so is `MEMORY: no blockers file` or `MEMORY: reader +unavailable` while `/.claude/memory/blockers.md` exists (a +mis-parsed root or a broken lib, never a quiet empty §5). Any `MEMORY:` +value other than `unreadable BLK: none` is printed to the user before +the render and repeated in 9.7. `STATUS: DONE` → THEN render: ``` Agent(subagent_type="handover-doc-writer") @@ -1190,6 +1195,12 @@ Parse the returned `HANDOVER-DOC REPORT`: markers left in NAP, deploy chapter included/skipped). Re-run PUSH STATE READ right before printing, then add the bullet: - Push: + When the synthesize `MEMORY:` value was not `unreadable BLK: none`, + add the bullet: + - Memory: + For unreadable IDs, give the remedy: `bash ~/.claude/lib/memory.sh -C + status ", …"` (a status word, e.g. resolved or + open), then re-run. - `STATUS: BLOCKED` → surface the report verbatim (including which PACKAGE field the doc-writer flagged) and stop — do not retry or patch the PACKAGE silently. Re-run PUSH STATE READ and add the same diff --git a/agents/handover-doc-writer.md b/agents/handover-doc-writer.md index 2c981d0..baf2714 100644 --- a/agents/handover-doc-writer.md +++ b/agents/handover-doc-writer.md @@ -54,8 +54,7 @@ The parent dispatches this agent TWICE, with the FULL PACKAGE both times the chapters (§1-§6 full, §7/§8 stubs) into the RUN-SCOPED DRAFT `.audit/handover-draft-.md`, ending the file with the line `DRAFT COMPLETE — RUNID: `. Then emits a `SYNTH REPORT` - (`STATUS: DONE | BLOCKED`, RUNID, phase-cluster count, per-chapter word - counts) and STOPS — STEP 13-16, the final MD, HTML and PDF are NEVER + (template below, `MEMORY:` line mandatory on DONE) and STOPS — STEP 13-16, the final MD, HTML and PDF are NEVER this mode's job. - **`MODE: render`** — runs on its sonnet row (frontmatter = off-state floor). FIRST loads the draft: absent file, RUNID mismatch, or missing `DRAFT COMPLETE` sentinel @@ -65,21 +64,48 @@ The parent dispatches this agent TWICE, with the FULL PACKAGE both times REPORT`. `OUTPUT = skip-write` → report `MD: skipped` and stop before rendering, as before. +The synthesize mode ends with: + +``` +SYNTH REPORT +STATUS: DONE | BLOCKED +RUNID: +PHASE CLUSTERS: +WORDS: §1= §2= §3= §4= §5= §6= +MEMORY: unreadable BLK: | no blockers file | reader unavailable +``` + --- ## STEP 9 — LOAD MEMORY REGISTRIES ```bash -MEMORY_DIR=".claude/memory" +ROOT="" +MEMORY_DIR="$ROOT/.claude/memory" test -d "$MEMORY_DIR" || MEMORY_DIR="" +# Blocker statuses through the shared reader (BDR-129): never parsed by hand. +B="$MEMORY_DIR/blockers.md" +if [ -z "$MEMORY_DIR" ] || [ ! -f "$B" ]; then echo "blockers: no-file" +elif . "$HOME/.claude/lib/reconcile.sh"; then reconcile_blk_classify "$B" +else echo "blockers: reader-unavailable"; fi ``` -If memory dir exists, read each file (full contents, parse manually): +Rows `IDopenword` are the open blockers for §5. Rows +`IDunreadable…` are kept out of §5; their IDs go on the +SYNTH REPORT `MEMORY:` line. `blockers: no-file` → no blocker in §5, +`MEMORY: no blockers file`. `blockers: reader-unavailable` → no blocker +in §5, `MEMORY: reader unavailable`. + +If memory dir exists, read each file in full for the narrative fields +(titles, decisions, why, alternatives, cause, solution, journal +summaries). A blocker's status is never taken from the file's prose, +only from the reader above: - `decisions.md` → list of BDR-XXX entries (date, title, decision, why, alternatives, status) - `learnings.md` → LRN-XXX entries -- `blockers.md` → BLK-XXX entries (open vs resolved) +- `blockers.md` → BLK-XXX entries: open/unreadable from the reader + above, narrative from the file - `journal.md` → date headings + 3-5 line session summaries - `evals.md` → EVAL-XXX entries @@ -315,7 +341,7 @@ End with two callouts: [Action-only checklist for the client. Pull from: **`.claude/audits/HUMAN-ACTIONS.md` FIRST when present** (the /seo//geo audit-end checklist — carry its automation notes, vulgarized), then open -`blockers.md` entries, ongoing-monitoring items, external platforms to +blockers from STEP 9 (unreadable ones excluded), ongoing-monitoring items, external platforms to claim, content updates only the client can make, deploy steps if self-hosted. If any axis passed via the code-ceiling rule, its unlocking user actions appear HERE with their expected score gain diff --git a/lib/reconcile.sh b/lib/reconcile.sh index 383cf36..47c88df 100644 --- a/lib/reconcile.sh +++ b/lib/reconcile.sh @@ -31,6 +31,8 @@ # parser on v2, legacy lexical reader on v1 # reconcile_blk_open — blockers whose CURRENT status is not closed # (resolved | superseded | deprecated on v2) +# reconcile_blk_classify — blockers for a client deliverable: open +# (word) | unreadable, closed omitted # reconcile_verdict — pure kernel: declared checkbox × real fact # → verdict # reconcile_deferrals — lexical deferral sweep (honest limit) @@ -105,6 +107,32 @@ reconcile_blk_open() { printf '%s\t%s\n' "$id" "$st" done } +# blockers for a client deliverable → "idopen|unreadableword or +# line"; closed ones are omitted. A status no reader maps to exactly one +# known word is unreadable, never open (BDR-129, BDR-133): v2 strict word, +# v1 the single word of a status/statut label (_mem_v1_word: prose, mixed +# or negated lines give none). Entries under a heading the enumerator +# cannot see (`### BLK-`) are unreadable too. +reconcile_blk_classify() { + local id st w v2="" + memory_is_v2 "$1" && v2=1 + for id in $(reconcile_enumerate_ids "$1" BLK); do + st=$(reconcile_blk_current_status "$1" "$id") + if [ -n "$v2" ]; then w=$(memory_status_word "$st") + else w=$(_mem_v1_word "$st"); fi + [ -n "$st" ] || w="" + memory_closed "$w" && continue + case " $_MEM_WORDS " in + *" $w "*) + [ -n "$w" ] && { printf '%s\topen\t%s\n' "$id" "$w"; continue; } ;; + esac + printf '%s\tunreadable\t%s\n' "$id" "${st:0:80}" + done + MEM_GREP="$RECONCILE_GREP" _mem_heading_ids "$1" BLK | sort -u \ + | comm -23 - <(reconcile_enumerate_ids "$1" BLK) \ + | while read -r id; do printf '%s\tunreadable\theading level\n' "$id"; done + return 0 +} # --- pure reconciliation kernel: declared checkbox × real fact → verdict # (no git, fully testable) --- diff --git a/lib/tests/handover-memory-contract.test.sh b/lib/tests/handover-memory-contract.test.sh new file mode 100644 index 0000000..4317393 --- /dev/null +++ b/lib/tests/handover-memory-contract.test.sh @@ -0,0 +1,105 @@ +#!/usr/bin/env bash +# lib/tests/handover-memory-contract.test.sh — handover-doc-writer STEP 9 +# reads blocker statuses through reconcile_blk_classify, never by hand +# (BDR-129, BDR-133; BUGS-FOUND G5). HM1/HM2 census the prompts, HM3 runs +# the SHIPPED STEP 9 block on printf-built fixtures under one mktemp -d. +set -u +ROOT="$(cd "$(dirname "$0")/../.." && pwd)" +HDW="$ROOT/agents/handover-doc-writer.md" +CHW="$ROOT/agents/client-handover-writer.md" +WORK="$(mktemp -d)" || exit 1; trap 'rm -rf "$WORK"' EXIT +pass=0; fail=0 +check() { if [ "$2" = "$3" ]; then pass=$((pass+1)); else fail=$((fail+1)); + printf 'FAIL %s: got[%s] want[%s]\n' "$1" "$2" "$3"; fi; } +# has : 1 when the file contains it, else 0 +has() { if grep -qF -- "$2" "$1"; then echo 1; else echo 0; fi; } + +# --- HM1: handover-doc-writer census +check HM1-classify "$(has "$HDW" 'reconcile_blk_classify')" 1 +check HM1-memory-line "$(has "$HDW" 'MEMORY: unreadable BLK:')" 1 +check HM1-reader-unavailable "$(has "$HDW" 'reader-unavailable')" 1 +check HM1-synth-fence "$(grep -c '^SYNTH REPORT$' "$HDW")" 1 +check HM1-no-manual "$(has "$HDW" 'parse manually')" 0 +check HM1-no-relative "$(has "$HDW" 'MEMORY_DIR=".claude/memory"')" 0 +check HM1-no-bash-c "$(has "$HDW" 'bash -c')" 0 + +# --- HM2: client-handover-writer census +check HM2-memory-parse "$(has "$CHW" 'with no `MEMORY:` line is malformed')" 1 +check HM2-report-bullet "$(has "$CHW" '- Memory: ')" 1 +check HM2-remedy "$(has "$CHW" 'memory.sh -C')" 1 + +# --- HM3: run the shipped STEP 9 block +# first fenced bash block under `## STEP 9`, with the two placeholders +# (project root, lib dir) substituted +mkscript() { # + awk '/^## STEP 9/ {s=1; next} s && /^## / {exit} + s && /^```bash/ {b=1; next} b && /^```/ {exit} b' "$HDW" \ + | sed -e "s||$1|" \ + -e "s|\$HOME/\.claude/lib|$2|" >"$3" +} +run_step9() { mkscript "$1" "$2" "$WORK/step9.sh"; bash "$WORK/step9.sh" 2>&1; } +# row : the row of one blocker, empty when absent +row() { printf '%s\n' "$1" | grep "^$2 " || true; } +TAB="$(printf '\t')" +# fixture : a project root with blockers.md +fixture() { + mkdir -p "$WORK/$1/.claude/memory" || exit 1 + printf '%b' "$2" >"$WORK/$1/.claude/memory/blockers.md" || exit 1 +} +LIB="$ROOT/lib" + +# (a) v1: no `format: 2`; the Index claims open, the body decides +V1='# Blockers\n\n## Index\n| ID | Status |\n|---|---|\n| BLK-001 | open |\n\n' +V1+='## BLK-001 — a\n- **Statut** : resolved\n\n' +V1+='## BLK-002 — b\n- **Statut** : upstream\n\n' +V1+='## BLK-003 — c\n- **Status**: superseded by BLK-002\n\n' +V1+='## BLK-004 — d\nno status here\n\n' +V1+='## BLK-005 — e\n- **Status**: closed\n\n' +V1+='## BLK-006 — f\n- **Statut** : upstream (superseded by #42)\n\n' +V1+='## BLK-007 — g\n- **Statut** : open (not resolved)\n\n' +V1+='## BLK-008 — h\n- **Statut** : unresolved\n\n' +V1+='## BLK-010 — i\n- **Status**: open\n\n' +V1+='### BLK-009 — j\n- **Status**: open\n' +fixture v1 "$V1" +out=$(run_step9 "$WORK/v1" "$LIB") +check HM3a-resolved-absent "$(row "$out" BLK-001)" "" +check HM3a-upstream "$(row "$out" BLK-002)" "BLK-002${TAB}open${TAB}upstream" +check HM3a-superseded-absent "$(row "$out" BLK-003)" "" +check HM3a-no-status "$(row "$out" BLK-004 | cut -f1,2)" \ + "BLK-004${TAB}unreadable" +check HM3a-closed-word "$(row "$out" BLK-005 | cut -f1,2)" \ + "BLK-005${TAB}unreadable" +check HM3a-mixed "$(row "$out" BLK-006 | cut -f1,2)" \ + "BLK-006${TAB}unreadable" +check HM3a-negated "$(row "$out" BLK-007)" "BLK-007${TAB}open${TAB}open" +check HM3a-unresolved "$(row "$out" BLK-008 | cut -f1,2)" \ + "BLK-008${TAB}unreadable" +check HM3a-open "$(row "$out" BLK-010)" "BLK-010${TAB}open${TAB}open" +check HM3a-heading-level "$(row "$out" BLK-009)" \ + "BLK-009${TAB}unreadable${TAB}heading level" + +# (b) v2: the heading tag or a labelled line decides, never Solution prose +V2='---\nformat: 2\n---\n# Blockers\n\n' +V2+='## BLK-001 — t [open]\n- **Solution**: resolved the issue partially\n\n' +V2+='## BLK-002 — u [open]\n- **Status (2026-11-01)**: resolved\n\n' +V2+='## BLK-003 — v [upstream]\n\n' +V2+='## BLK-004 — w\nplain prose, no status\n' +fixture v2 "$V2" +out=$(run_step9 "$WORK/v2" "$LIB") +check HM3b-open "$(row "$out" BLK-001)" "BLK-001${TAB}open${TAB}open" +check HM3b-resolved-absent "$(row "$out" BLK-002)" "" +check HM3b-upstream "$(row "$out" BLK-003)" "BLK-003${TAB}open${TAB}upstream" +check HM3b-no-status "$(row "$out" BLK-004 | cut -f1,2)" \ + "BLK-004${TAB}unreadable" + +# (c) no blockers.md +mkdir -p "$WORK/none/.claude/memory" || exit 1 +check HM3c-no-file "$(run_step9 "$WORK/none" "$LIB")" "blockers: no-file" + +# (d) lib dir without reconcile.sh +mkdir -p "$WORK/emptylib" || exit 1 +check HM3d-reader-unavailable "$(run_step9 "$WORK/v2" "$WORK/emptylib" \ + | tail -1)" "blockers: reader-unavailable" + +printf 'handover-memory-contract: %d passed, %d failed\n' "$pass" "$fail" +[ "$fail" -eq 0 ] || exit 1