diff --git a/.claude/memory/blockers.md b/.claude/memory/blockers.md index 065a03c..4751af9 100644 --- a/.claude/memory/blockers.md +++ b/.claude/memory/blockers.md @@ -53,6 +53,7 @@ rules: | BLK-031 | 2026-10-16 | model-router: session starting on Fable w/o credits lost 1st turn + each hold lapse; probe skipped kept cur | resolved | | BLK-032 | 2026-10-19 | Main loop pinned on Fable in long sessions: session model Fable 1M + downgrade cap 120k + prompt rule `plan` → inline code on Fable xhigh; feat A+B shipped (BDR-123), closes after feat C | open | | BLK-033 | 2026-10-21 | Guardrails residuals: probe trusted plan `supabase.url`, redirects free of budget, unread bodies read CLOSED, `str(URLError)` hid budget signal; rules 5 FP / 7 misses | resolved | +| BLK-034 | 2026-10-22 | mods.test.sh red on CLI 2.1.306: whole-output `warning` grep caught advisory plugin-directory section (ICON_MISSING, blocking: false); verdict = `--strict` exit code now | resolved | --- @@ -341,3 +342,9 @@ rules: - **Cause**: `supabase.url` read from the plan w/o `_http_url` → planted SUPABASE_URL would receive GUARDRAILS_ANON_KEY / JWT2, `file://` read CLOSED; `_SameHost` redirector followed hops w/o charging `session.budget`; `_rows_state` collapsed non-200 / empty / >1 MB / non-JSON into CLOSED (unobserved = CLOSED, breaks LRN-220); plan r2 mapped budget exhaustion on `str(URLError)`, which wraps the reason → never matched. Rules: SENSITIVE_KEY on metadata names (`token_type`, `has_password`), 403 on first map candidate stopped the walk, hydrated scan read whole route file, NOSQL `$where` fired on GraphQL `_bool_exp`; misses: Go backtick Sprintf, `rf`/triple-quoted f-strings, `sql|db|trx.raw`, empty `.select()`, multi-line hidden input, Rust `{}` shell arg, `"sources"` map head. - **Solution**: 5a98c2c (`_BudgetExhausted(URLError)` + `BUDGET_EXHAUSTED` constant, `_SameHost(session)` charges per hop, `_rows_state` rows|empty|unreadable → SKIPPED, `_map_outcome` full candidate walk, `data:` OPEN w/o decoding, `printable` on remote strings, `_safe_text` in scanner, rule fixes + mutant per language variant) + 633faa2 (checks.md: `IN (…)` placeholder list flagged, judged by hand). Plan r3 after 2 challenge rounds, contract 22 oracles MET, verifier CONFORME, auditor PASS. Suites probe 84, scan 241. - **Residual** (LOW, parked in TODO): table names not `IDENT.fullmatch`-checked per table (`/` → path walk on the approved host); `printable` lets Unicode bidi/format controls through. Links [[LRN-219]], [[LRN-220]], [[LRN-222]], [[LRN-223]]. + +## BLK-034 — mods.test.sh red on CLI 2.1.306: whole-output `warning` grep caught the advisory plugin-directory section [resolved] +- **Friction**: `make test suite=lib/tests/mods.test.sh` → `FAIL model-router: validate printed a warning`, pre-existing on develop (git archive baseline), surfaced as feat B criterion 8 (NEED-DECISION, BDR-123 run). +- **Cause**: CLI 2.1.306 `claude plugin validate` prints "Plugin directory checks" section (submission catalogue): `⚠ Found 1 plugin directory warning:` ICON_MISSING, `--json` `directory.findings[].blocking: false`. mods.test.sh:57 grepped whole output for `warning` (also matched hooks notes quoting register.ts identifiers, checkout paths). Prose scraping of a CLI with an exit-code contract: `--strict` → per-file warnings rc 1, directory findings rc only under `--profile directory`. +- **Solution**: 801992a (bugfix/mods-validate-advisory). Helper `validate_strict` = rc of `claude plugin validate --strict`; check_cli + positive control share it; control = scratch manifests `{"name":"warnfix"}` (rc 1) / cleanfix with version+description+author (rc 0) under script-level `mktemp -d`. Plan r3 after 3 lenses + 1 re-challenge (sed range on closing marker killed: CLI prints it only when findings > 0, fail-open to EOF). GATE 0 7/7, verifier ECARTS(2) = out-of-scope routing.json dialog write only, auditor PASS. +- **Residual**: 3 historical contracts carry old scrape as CHECK oracle (`.claude/tasks/contracts/2026-10-08-model-router-w1a-1533.md:22`, `2026-10-08-model-router-floor-1835.md:22`, `2026-10-09-model-router-tiers-1237.md:23`), left unedited; re-run fails on ICON_MISSING, not a model-router regression. Unverified: whether `--strict` escalates `advice[]`. Links [[LRN-225]], [[BDR-123]]. diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index 47d3efe..3a2e2d2 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -635,3 +635,6 @@ rules: - /bugfix guardrails residuals (bugfix/guardrails-residuals): plan r3 after 2 challenge rounds (4 BLOCKERs r1: WARN severity, budget must raise, three-way SKIPPED, vacuous timing; r2: `str(URLError)` wrap), contract 22 oracles, 3 part executors, GATE 0/1/2 green, 5a98c2c + 633faa2 (checks.md IN() wording caught by doc-syncer, not the gates). BLK-033, LRN-222/223. Two LOW parked. Both branches await merge signal. Next: /feat routing policy (BLK-032). - /feat routing policy A (feature/routing-audit-phase, BLK-032): `audit` phase (best/xhigh) for verifier + security-auditor, opus frontmatter = outage floor (LRN-224), census tier_floor, citers. 2 challenge rounds (r1 2 BLOCKERs: dead-Fable floor, test fixture), GATE 0 15/15, verifier CONFORME, auditor PASS. d3635b6 dialog writes + session model opus, a7d747c, dae142b docs. Feat B next: ceiling rule, BDR, README doctrine. - /feat routing policy B (feature/routing-ceiling-rule): ceiling bullet compacted into CLAUDE.global.md (320 budget), README doctrine + challenge citers on `opus` session model, deploy `effort: xhigh`, `changed` cleared. 3 challengers r1→r3, GATE 0 12/12, verifier CONFORME, auditor PASS. ef13713 + docs 887cf89, BDR-123 ([deferred] inline-writing skills, keyword-lift gap → feat C). Merge on user go; then bugfix mods.test.sh, feat C. + +## 2026-10-22 +- feat B merged (df38fd4). /bugfix mods.test.sh (bugfix/mods-validate-advisory): CLI 2.1.306 advisory ICON_MISSING section read as warning → verdict = `claude plugin validate --strict` rc through one helper + warnfix/cleanfix control; plan r3 (3 lenses + 1 re-challenge, sed-range fail-open killed), GATE 0 7/7, verifier ECARTS = out-of-scope routing.json dialog write (`confirmed.phases.audit`, uncommitted, user call), auditor PASS. 801992a. BLK-034, LRN-225. Next: feat C keyword rules capped at session model, close BLK-032. diff --git a/.claude/memory/learnings.md b/.claude/memory/learnings.md index 09b3972..dcab282 100644 --- a/.claude/memory/learnings.md +++ b/.claude/memory/learnings.md @@ -244,6 +244,7 @@ rules: | LRN-222 | 2026-10-21 | Map an error to a verdict on a typed exception or carried constant, never on `str(err)`: URLError wraps its reason | probe/fetch error mapping, any err→verdict code | | LRN-223 | 2026-10-21 | Regex timing lock is vacuous when the input matches early: feed a non-matching worst-path input, assert `is None`, keep ≥ 2x margin under the lock | every bounded regex test | | LRN-224 | 2026-10-21 | Best-tier agent row floors on tier 2nd alias: inTier writes head-or-above only, fable frontmatter = no fallback in credit outage | pinning agents on best tier, census floors | +| LRN-225 | 2026-10-22 | Gate on tool's exit-code contract, never its prose; positive control through gate's own helper on clean/dirty fixture pair; mktemp EXIT trap script-level | any test that wraps a CLI verdict | --- @@ -1871,3 +1872,9 @@ Rule: when editing a doctrine file under structure locks, grep the test's lock s ## LRN-224 — Best-tier agent row floors on tier's 2nd alias: inTier writes head-or-above only - **Context**: feat A (routing policy BLK-032) moved verifier + security-auditor to new `audit` phase (best = fable>opus>sonnet). Plan r1 set frontmatter `model: fable` (census rule floor = tier head) and claimed "Fable down → falls to opus". False: `inTier` (register.ts) writes a model only if it is the head or ranks above it, else logs "tier … down, frontmatter model kept" → fable frontmatter = gates spawn on dead Fable every credit outage (BLK-030/031). Lower tiers never hit it (head sonnet/opus always has a higher alias). Caught by correctness + robustness lenses r1, not by plan author. - **Apply**: an agent on a best-tier row keeps opus frontmatter; router lifts to Fable when up. Census `tier_floor` (effort-routing.test.sh) locks 2nd alias for best. Residual: spawn path unprobed → first gate of an outage window still dies once, retry lands on floor (register.test.ts audit-row case b). Links [[BLK-030]], [[BLK-032]], [[LRN-204]]. + +## LRN-225 — Gate on the tool's own exit-code contract, never on its prose; control through the gate's own helper on a clean/dirty pair + +- **Context**: BLK-034. `grep -qi warning` on `claude plugin validate` output broke when CLI 2.1.306 added an advisory section; first plan (sed range delete between two markers) was fail-open: closing marker printed only when findings > 0, else range ran to EOF and hid `✔ Validation passed with warnings`. +- **Pattern**: (1) a CLI with `--strict` / `--json` / rc semantics → gate on rc, prose only in the ko message. (2) Positive control runs the SAME helper the gate uses (a copy of the invocation stays green when the gate drifts). (3) Pair of fixtures differing only in the guarded cause (warnfix vs cleanfix): parse error (`error: unknown option`, rc 1 on both) or scrape added back turns the pair red; a lone "rc must be 1" accepts any failure. (4) Inline sample strings test the author's literal, not the code: a check that cannot fail is not a check. (5) `WORK=$(mktemp -d); trap 'rm -rf "$WORK"' EXIT` stays script-level: `local` WORK + EXIT trap → `unbound variable` under `set -u`, dir leaks. +- **Apply**: any suite wrapping a third-party CLI verdict (plugin validate, linters, validators). Links [[BLK-034]], [[LRN-223]]. diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index 4f061b1..f92e89a 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -8,7 +8,7 @@ - [x] feat A audit phase: d3635b6 (dialog writes, session model opus), a7d747c (audit row, opus floor, census, citers), dae142b (docs); gates 0/1/2 green, LRN-224 - [x] feat B (feature/routing-ceiling-rule): ceiling rule CLAUDE.global.md, README doctrine, challenge citers, deploy `effort: xhigh`, routing.json `changed` cleared; ef13713 + 887cf89, gates 0/1/2 green, BDR-123; merge = user go - [ ] feat C: cap the default keyword prompt rules (plan|design|architecture, why|review|audit|analyze, ultrathink) at the session model, effort only like the classifier; close BLK-032 after - - [ ] bugfix lib/tests/mods.test.sh:57: CLI 2.1.306 `claude plugin validate` advisory "plugin directory warning" (ICON_MISSING) read as failure; exclude that section, keep other warnings blocking + - [x] bugfix lib/tests/mods.test.sh (bugfix/mods-validate-advisory): verdict = `--strict` rc, positive control warnfix/cleanfix; 801992a, gates green, BLK-034 LRN-225; merge = user go. Residual: 3 historical contracts keep the old scrape oracle (BLK-034) - [ ] deferred (BDR-123): remap inline-writing best-tier skills (design Build stack, writing-skills, deprecation-and-migration, /tour single-project, /audit-delta 3d, /harden STEP 3); stale citers skills/feat/SKILL.md:6, skills/code-clean/SKILL.md:36 - [ ] residuals (accepted): spawn path unprobed, 1st gate of an outage window dies once (tour/onboard/audit-delta no retry); onAutoSwitch with main on opus marks nothing if engine auto-falls a gate off Fable diff --git a/.claude/tasks/contracts/2026-10-22-mods-validate-advisory-2004.md b/.claude/tasks/contracts/2026-10-22-mods-validate-advisory-2004.md new file mode 100644 index 0000000..2c9f6e3 --- /dev/null +++ b/.claude/tasks/contracts/2026-10-22-mods-validate-advisory-2004.md @@ -0,0 +1,44 @@ +# CONTRACT — mods-validate-advisory (bugfix of lib/tests/mods.test.sh) + +## REQUEST (verbatim) +lib/tests/mods.test.sh:57 fails on develop: Claude Code CLI 2.1.306 `claude plugin validate` prints an advisory "plugin directory warning" section (ICON_MISSING) and the suite treats any warning as a failure. Exclude that advisory section only; every other validate warning stays blocking. Suite: make test suite=lib/tests/mods.test.sh. Pre-existing on develop (proven via git archive baseline in the previous session). + +## CLARIFICATIONS +- Internal (after the challenge, 3 lenses + 1 re-challenge): the "exclusion" is the CLI's own contract, `claude plugin validate --strict`: per-file warnings → rc 1, the plugin-directory advisory never changes the rc (only under `--profile directory`, never requested). No prose scraping is left in the suite. +- Internal: the regression proof is a positive control run through the gate's own helper on two scratch manifests (warnfix rc 1, cleanfix rc 0), written by the suite under a script-level `mktemp -d`; no tracked fixture. +- Internal: three historical contracts carry the old scrape as oracle (2026-10-08-model-router-w1a-1533.md:22, 2026-10-08-model-router-floor-1835.md:22, 2026-10-09-model-router-tiers-1237.md:23); left unedited, named at CAPITALIZE. +- Plan: `.claude/tasks/plans/2026-10-22-mods-validate-advisory-2004.md` (r3). +- GATE 1 ECARTS(2) → disposition (main loop): both gaps = criterion 6 on `mods/model-router/routing.json` (`confirmed.phases.audit` written by the mod on the main loop's first `route(phase="audit")`, register.ts:2054, after GATE 0 ran). Not an executor edit, not staged with this fix; commit of that dialog write = user call. Criterion 6 holds on the committed diff. + +## ACCEPTANCE CRITERIA +1. The suite is green on CLI 2.1.306 with the ICON_MISSING advisory present in validate's output. + CHECK: make test suite=lib/tests/mods.test.sh 2>&1 | grep -E '^mods: ' | sed 's/^/n=/' + EXPECT: n=mods: 6 pass, 0 fail + EVIDENCE: MET exit=0 marker-found :: n=mods: 6 pass, 0 fail +2. The validate verdict is the exit code of `--strict`, through one helper used by check_cli and the control; no `warning` scrape and no `Validation passed` scrape remain. + CHECK: f=lib/tests/mods.test.sh; a=$(grep -c 'plugin validate --strict "' $f); b=$(grep -c 'validate_strict "' $f); c=$(grep -ciE "grep -qi? *'?warning|Validation passed" $f); echo "$a/$b/$c" + EXPECT: 1/3/0 + EVIDENCE: MET exit=0 marker-found :: 1/3/0 +3. Positive control: the clean scratch manifest passes `--strict` and the warning one fails it, both through the helper, both reported as suite checks. + CHECK: make test suite=lib/tests/mods.test.sh 2>&1 | grep -cE '^PASS strict control: (clean fixture passes --strict|per-file warnings fail --strict)$' + EXPECT: 2 + EVIDENCE: MET exit=0 marker-found :: 2 +4. The control is not vacuous: with `--strict` removed from the helper the control goes red (the warning fixture passes). + CHECK: S=/tmp/claude-1000/-home-bchanot-Documents-claude/09872630-52ba-43d2-b0a9-f9fe56869e15/scratchpad/chk; mkdir -p "$S"; sed 's/validate --strict "\$1"/validate "$1"/' lib/tests/mods.test.sh > "$S/m.sh"; MODS_ROOT=$PWD bash "$S/m.sh" 2>&1 | grep -c '^FAIL strict control: per-file warnings fail --strict' + EXPECT: 1 + EVIDENCE: MET exit=0 marker-found :: 1 +5. The scratch dir is script-level with an EXIT trap (never inside a function), and the ko tail names the rerun command. + CHECK: f=lib/tests/mods.test.sh; a=$(grep -c "^WORK=\"\$(mktemp -d)\"; trap 'rm -rf \"\$WORK\"' EXIT$" $f); b=$(grep -c 'rerun: claude plugin validate --strict' $f); echo "$a/$b" + EXPECT: 1/1 + EVIDENCE: MET exit=0 marker-found :: 1/1 +6. Only lib/tests/mods.test.sh changes; shellcheck clean on it. + CHECK: a=$(git status --short | grep -v '^?? .claude/' | grep -vc '^ M lib/tests/mods.test.sh$'); b=$(shellcheck lib/tests/mods.test.sh >/dev/null 2>&1 && echo ok || echo ko); echo "$a/$b" + EXPECT: 0/ok + EVIDENCE: MET exit=0 marker-found :: 0/ok +7. The suite still fails loudly when no mod exists (never vacuous): MODS_ROOT on an empty dir. + CHECK: d=$(mktemp -d); MODS_ROOT=$d bash lib/tests/mods.test.sh 2>&1 | grep -c '^FAIL no mod found' + EXPECT: 1 + EVIDENCE: MET exit=0 marker-found :: 1 + +## FILE SCOPE +lib/tests/mods.test.sh diff --git a/.claude/tasks/plans/2026-10-22-mods-validate-advisory-2004.md b/.claude/tasks/plans/2026-10-22-mods-validate-advisory-2004.md new file mode 100644 index 0000000..4cc0ae1 --- /dev/null +++ b/.claude/tasks/plans/2026-10-22-mods-validate-advisory-2004.md @@ -0,0 +1,91 @@ +# BUGFIX PLAN r3 — mods.test.sh reads the advisory plugin-directory section as a warning + +## DIAGNOSIS +BUG: `make test suite=lib/tests/mods.test.sh` fails on develop with +`FAIL model-router: validate printed a warning` (pre-existing, proven on +develop's copy via git archive in the previous session). +ROOT CAUSE: Claude Code CLI 2.1.306 `claude plugin validate` prints a +"Plugin directory checks for