76 Commits
Author SHA1 Message Date
bchanot db7a18f525 chore(tasks): advisor-usage merged 6e45536 2026-11-19 18:11:39 +01:00
bchanot 6e455361db Merge feature/advisor-usage into develop 2026-11-19 18:11:30 +01:00
bchanot 3ffd81f3a5 chore(memory): Run C advisor usage, LRN-301 LRN-302, TODO:18 done, leak + timeout follow-ups 2026-11-19 18:10:47 +01:00
bchanot 77aac4b73e chore(audits): mods.test.sh model-router timeout under load 2026-11-19 18:10:46 +01:00
bchanot 7d09837854 docs: /memory-feedback advisor usage section in README, USAGE, CHANGELOG 2026-11-19 18:10:39 +01:00
bchanot 63f5fa4a9c fix(memory-feedback): retention note only when its cut day passes the start day
A weekly run's window is just over 7 days, so the note fired every week with a cut day equal to the heading's start. SKILL.md names advisor counts in the local data line.
2026-11-19 18:10:38 +01:00
bchanot c6f2dad39a feat(memory-feedback): advisor usage section in FEEDBACK.md
apply appends served advisor calls since the last run, per caller (main
loop or sub-agent type) and model, with input tokens, deduped by message.id.
Retention, no-transcript and shape-drift lines replace false zeros.
2026-11-19 17:56:46 +01:00
bchanot 52689ae535 chore(tasks): merge-reuse merged 82dee85 2026-11-19 16:18:56 +01:00
bchanot 82dee85f8a Merge feature/advisor-merge-reuse into develop 2026-11-19 16:18:46 +01:00
bchanot 1ec72d918f chore(memory): merge-reuse runs 1-2, TODO:14 done, 3 follow-ups 2026-11-19 16:16:52 +01:00
bchanot 17a60fd5ef chore(audits): log run 1 feater's unexplained make test red 2026-11-19 16:16:47 +01:00
bchanot 87566e2a1e feat(doctrine): feat and bugfix end lines restate the merge-reuse clause
Completes the six gate flows: a later merge proposal reuses the last run's
answer, or its skip, and names code commits made after it. loops-light
locks both sites and pins the doc/memory exception in both loops.
2026-11-19 16:16:24 +01:00
bchanot af846d6dbe feat(doctrine): end-of-run sites restate the merge-reuse clause
a11y, guardrails, ship-feature and init-project cite lib/effort-shift.md
without loading it; their end step now says a later merge proposal reuses
the answer and names code commits made after it. loops-light locks it.
2026-11-19 14:49:05 +01:00
bchanot 9d4d10b1fc chore(tasks): degraded-tool-line merged 4a8dffb 2026-11-19 14:07:56 +01:00
bchanot 4a8dffb0ba Merge bugfix/degraded-tool-line into develop 2026-11-19 14:07:42 +01:00
bchanot 9f8cf974a2 chore(memory): BLK-051 DEGRADED read off TOOL line, TODO:13 done 2026-11-19 13:59:00 +01:00
bchanot b120ba50b6 chore(audits): BUGS-FOUND:134 fixed 9814720, two DEGRADED minors logged 2026-11-19 13:58:59 +01:00
bchanot 4bb0a95534 docs(changelog): security readers take DEGRADED off the TOOL line 2026-11-19 13:58:55 +01:00
bchanot 981472033a fix(doctrine): security readers take DEGRADED off the TOOL line, not the VERDICT line
The auditor prints VERDICT: PASS on a DEGRADED scan, so the three parse lists
read it as a clean PASS. The PASS branch now reads the TOOL line first, a PASS
without one is structural, and loops-light locks it.
2026-11-19 13:49:30 +01:00
bchanot c7d3677350 chore(tasks): run B3 merged 366f1f6 2026-11-19 11:14:00 +01:00
bchanot 366f1f63bd Merge feature/advisor-points-b3 into develop 2026-11-19 11:13:37 +01:00
bchanot 6e3c811998 chore: purge transient planning artifacts (BDR-065) 2026-11-19 11:13:36 +01:00
bchanot 8f23683ef2 chore(audits): run B3 residuals before the plan purge 2026-11-18 16:26:16 +01:00
bchanot 575408cdc7 docs: feat/bugfix and audit-delta/tour end-call skips in README and USAGE 2026-11-18 16:21:08 +01:00
bchanot 8733669373 chore(audits): advisor entries fixed by run B3, DEGRADED root fix logged 2026-11-18 16:19:44 +01:00
bchanot 49cc13ccb6 chore(memory): LRN-300, BDR-150 amended, run B3 journal and TODO 2026-11-18 16:19:43 +01:00
bchanot 51f343f79c docs(doctrine): feat/bugfix skip names where DEGRADED shows and the global trigger; changelog names both skips 2026-11-18 15:44:58 +01:00
bchanot 78aad7db1a chore(plan): B3 review fix blocks (DEGRADED line, global trigger, changelog skips) 2026-11-18 15:19:23 +01:00
bchanot 55edd0a6c7 chore(tasks): B3 contract evidence, GATE 0 MET 2026-11-18 15:08:41 +01:00
bchanot 2b7aeb8605 docs(doctrine): challenge route rides the first challenge call; summary Advisor row; feat/bugfix skip the end call on clean gates 2026-11-18 14:57:07 +01:00
bchanot 858bd41782 chore(plan): advisor points run B3 plan, applier and contract 2026-11-18 14:56:35 +01:00
bchanot ce8d1b1dfb chore(memory): gates hotfix merged 2026-11-18 10:44:32 +01:00
bchanot 2d8e4578d3 Merge bugfix/gates-label-timeout into develop 2026-11-18 10:44:22 +01:00
bchanot 15c6d096c2 docs: gates.sh label guard and 600 s default in changelog 2026-11-18 10:44:09 +01:00
bchanot 482fd37808 chore(memory): LRN-299 cursor parser guards the sink 2026-11-18 10:43:54 +01:00
bchanot 44dc0b3015 chore(memory): gates hotfix journal, TODO 88-89 done, residuals logged 2026-11-18 00:32:38 +01:00
bchanot c25a7ea017 fix(gates): reject an oracle under a missed criterion label; default timeout 600 s 2026-11-18 00:30:28 +01:00
bchanot 2a5e3a41d8 chore(memory): run B2 merged 2026-11-17 23:26:57 +01:00
bchanot 6c4d24fcc4 Merge feature/advisor-points-b2 into develop 2026-11-17 23:26:33 +01:00
bchanot 019bacd5a5 chore: purge transient planning artifacts (BDR-065) 2026-11-17 23:26:32 +01:00
bchanot 0ceaa580c3 chore(audits): B2 residual, end call sits at the feat/bugfix commit step 2026-11-17 19:40:47 +01:00
bchanot 5bc64f4c3a docs: advisor run B2 in changelog, dispatch scope in README and USAGE 2026-11-17 19:38:33 +01:00
bchanot bfcf21aa91 chore(audits): advisor entries fixed by run B2, review residuals logged 2026-11-17 19:08:19 +01:00
bchanot 9917ade7a7 chore(memory): LRN-297 + LRN-298, BDR-150 amended — ship-feature advisor points B2 2026-11-17 19:08:18 +01:00
bchanot 6022b9dfb9 docs(doctrine): end-of-run lines name the diff stat and the gate path; release hold is a recommendation 2026-11-17 18:44:18 +01:00
bchanot 25660542d3 chore(plan): advisor points B2 review fix blocks (fix path, hold wording, bugfix route) 2026-11-17 18:34:54 +01:00
bchanot 24354d9b68 docs(doctrine): judgment agents advise only when dispatched; auditor raises only upward; protocol mirror; end-of-run point sites 2026-11-17 18:10:02 +01:00
bchanot f48343e2d7 docs(doctrine): advisor stuck trigger in gate skills, end-of-run call in code flows 2026-11-17 18:08:37 +01:00
bchanot b11d642841 chore(plan): advisor points run B2 plan and applier 2026-11-17 18:07:38 +01:00
bchanot d659e25d8d chore(memory): run B1 merged, run B2 resized 2026-11-17 15:31:37 +01:00
bchanot eb1f594644 Merge feature/advisor-points-b1 into develop 2026-11-17 15:31:14 +01:00
bchanot d55f4911ce chore(memory): LRN-296 simulate checks, BDR-150 amended, run B1 journal 2026-11-17 14:07:02 +01:00
bchanot 9033b4a944 chore(audits): two advisor residuals from run B1 2026-11-17 14:07:01 +01:00
bchanot 47e5ee8389 docs: advisor plan point, stuck lines and analyzer in README, USAGE, changelog 2026-11-17 14:07:00 +01:00
bchanot 58a5273b5c docs(doctrine): advisor before plan challenge, at gate stuck points, analyzer joins
Main loop consults the advisor on the written plan before the challengers (once per skill run) and at a gate loop's second failure; dispatched analyzer may call it once; new trigger before recommending a doctrine, architecture or public-interface change (amends BDR-150).
2026-11-17 14:03:42 +01:00
bchanot d059658067 chore(memory): run A merged, run B scope 2026-11-17 13:11:07 +01:00
bchanot fc2d84dd41 Merge feature/advisor-call-points into develop 2026-11-17 13:10:55 +01:00
bchanot 78a694299b chore(memory): LRN-295 advisor measurement, BDR-150 amended, run A journal 2026-11-17 13:07:43 +01:00
bchanot c1a0c32417 chore(audits): advisor residual superseded by 6ef3069; block E direction LOW 2026-11-17 13:07:42 +01:00
bchanot 09277f528a docs: advisor call points in README and USAGE; changelog amended 2026-11-17 13:07:41 +01:00
bchanot 6ef3069f6e docs(doctrine): advisor call points; judgment agents may consult it once
Main loop calls the advisor before a skill's plan, once per verify-secure run when stuck, and before a merge. plan-challenger, verifier and security-auditor may call it once before the verdict; advice only adds, never clears (amends BDR-150).
2026-11-17 12:59:15 +01:00
bchanot f3b3987acf chore(memory): BDR-077/150 status, LRN advisor tool reaches sub-agents 2026-11-17 01:08:21 +01:00
bchanot bf0bc2fc95 Merge feature/advisor-doctrine into develop 2026-11-17 01:01:35 +01:00
bchanot d027dfab3a chore(memory): advisor doctrine journal 2026-11-17 00:59:38 +01:00
bchanot 8ffe7e7ddd docs: advisor rules in README and USAGE; changelog for the advisor doctrine 2026-11-17 00:59:37 +01:00
bchanot d292911343 chore(audits): log the prose-only advisor scope residual 2026-11-17 00:38:07 +01:00
bchanot c3507ea447 docs(doctrine): main loop calls the Fable advisor; Fable prose moves to opus
Global line and effort-shift Advisor section: the main loop calls the advisor when a stronger model is needed, sub-agents do not, advice waives no gate. Skill-runner, Limits, ask-tier and audit-row prose match BDR-150.
2026-11-17 00:37:53 +01:00
bchanot 1c2e5e8b7a Merge feature/fable-pins-to-opus into develop 2026-11-17 00:01:09 +01:00
bchanot ef57846754 chore(memory): Fable pins journal, doctrine tracker 2026-11-16 23:59:21 +01:00
bchanot 609550e7ad docs: skill-runner pins on opus, gate passes a sub-agent fixed at spawn 2026-11-16 23:59:20 +01:00
bchanot ff6a550aff chore(audits): log BDR-150 routing and pin residuals 2026-11-16 23:56:00 +01:00
bchanot beebfe2d82 feat(routing): skill-runner pins move from fable to opus
Fable is the advisor (BDR-150): the client-handover skill-runner children and the model-gate dispatch doctrine pin opus. A pinned child's route answer "fixed at spawn" passes the gate; a repo-wide census refuses any fable pin.
2026-11-16 23:55:31 +01:00
bchanot d12c2b045c Merge feature/router-no-fable into develop 2026-11-16 23:33:39 +01:00
bchanot 67f27e65ae chore(memory): BDR-150 Fable advisor-only routing 2026-11-16 23:18:48 +01:00
bchanot 42385d2936 docs: router routes no Fable, Opus heads best and big; changelog 2026-11-16 23:04:48 +01:00
bchanot 24b0f35960 feat(model-router): Fable leaves auto-routing, Opus heads best and big
Fable is the advisor now: the best and big tiers default to opus then sonnet, the row dialog drops it, and the ask-before-Fable dialog runs only when an override heads best with fable. Fable stays ranked and hand-pickable.
2026-11-16 20:31:06 +01:00
70 changed files with 3561 additions and 219 deletions

No files matched your search

+38
View File
@@ -101,8 +101,46 @@
- settings.json `autoMode.hard_deny[6]` mod off-switch clause is a closed list: it does not name removing the `skills/<name>` symlink, a same-name dev copy shadowing a mod (`--plugin-dir`, `~/.claude/dev-mods/<session>/`), the memory mod's partial `"recall": false`, or `/route off` typed inside a skill run (the "Passing a gate" entry only bars `/route` outside a run). Its closing "The user maintains these files by hand" may now read as covering every edit to `~/.claude/<mod>.json`, including ordinary routing overrides (classifier over-refusal, unmeasured). `profile.sh disable` reaches only `model-router@skills-dir` (memory is not a managed id). Severity: low. Discovered while: /hotfix hard-deny-mod-off security gate and doc audit. Not fixed.
- mods/model-router/hooks/register.ts write guard: if the config load keeps throwing, no hook latches in-session (Skill and skill.prompt await ensureConfig first), so main-loop code writes stay held until a sub-agent writes; no throw source known today. The `next.called` replay branch is pinned only indirectly (the kit hides the downstream error). Severity: low. Discovered while: /feat guard-fail-closed plan challenge and security gate. Not fixed.
<!-- /feat router-no-fable 2026-11-16 (24b0f35) and /feat fable-pins-to-opus (beebfe2): residuals of BDR-150, not BDR-125 -->
- mods/model-router (BDR-150 shipped tiers): an opus outage spawns best/big agents on the held opus (frontmatter floor; the gates fail, verify-secure retries then escalates; they used to move up to Fable); a single opus outage makes sonnet stand in for best and big with the effort notch; a fable-baseline session (native /model Everywhere) is demoted per downgradeCall caps and sessionPin pins general-purpose spawns to fable; a skill row answering opus + xhigh in the Change dialog lands on run-holding `plan`. isStandIn and tierWord still read a stored `tierChoice === 'big'` directly. Severity: low. Discovered while: /feat router-no-fable challenges and executor. Accepted, not fixed.
- lib/model-gate.md `fixed at spawn` row: inside a sub-agent the gate proceeds whatever model the child really runs on (the route answer names no id); fix direction: print the spawn id from `agentModels` in `routedText` ("fixed at spawn: <id>") and keep the id check. The repo-wide fable census (lib/tests/model-routing.test.sh) uses `git grep` (tracked files only) and the regex `model ?[:=] ?"fable"` (misses single quotes and unquoted frontmatter); skills/tour runner inherits the session model by design (BDR-084), so a hand-picked Fable session runs it on Fable. Severity: low. Discovered while: /feat fable-pins-to-opus security gate and verifier. Not fixed.
- CLAUDE.global.md § Workflow + lib/effort-shift.md § Advisor: "sub-agents do not" call the advisor is prose only; sub-agents get the advisor tool listed and the harness prompt tells them to call it (seen live in this run's challengers and gates), each call forwarding that agent's whole transcript to Fable outside the router's caps (cost, BLK-030 credits). Fix direction: a mechanical scope (advisorModel for the main session only, if the CLI allows it), else accept. Severity: low. Discovered while: /feat advisor-doctrine plan challenge and security gate. Not fixed.
SUPERSEDED 2026-11-17 (6ef3069, /feat advisor-call-points): plan-challenger, verifier, security-auditor now may call it at most once before the verdict; other sub-agents do not. Residual kept: still prose only, and the harness prompt asks sub-agents for "at least once before … and once before declaring done" (a verifier made 2 calls on 2026-11-16), against "at most one call". Severity: low.
- agents/security-auditor.md:166 (advisor bullet) — "overrides the STEP 2 mapping for that finding only" has no direction: read alone, an advisor "raise" into a lower STEP 3 class could take a semgrep HIGH out of BLOCK(n); only the closing "never removes, lowers or waives" stops it. Fix direction: "overrides it upward only". Severity: low. Discovered while: /feat advisor-call-points security gate r5 (advisor-sourced LOW). Not fixed.
FIXED 2026-11-17 (24354d9, /ship-feature advisor-points-b2): a raise applies only when its class's severity is higher than the finding's own; a raise that does not apply, or matches no class, changes nothing (no tag, no PROOF count); "Advice never removes, lowers or waives" kept.
- agents/verifier.md + agents/security-auditor.md advisor bullets — not scoped to dispatch (analyzer's is, 58a5273); lib/verify-secure-loop.md:54,:96 still allow "or load agents/<x>.md" inline, where the gate's own call would be a main-loop call and void the stuck-call unit "no main-loop advisor call since GATE 0 first ran". No skill takes the inline path today. Fix direction: "when dispatched" in both bullets. Severity: low. Discovered while: /feat advisor-points-b1 re-challenge. Not fixed.
FIXED 2026-11-17 (24354d9): verifier, security-auditor and plan-challenger read "Advisor, when dispatched as a sub-agent". Residual kept: lib/verify-secure-loop.md:57-58, :106-107 still offer "or load agents/<x>.md" inline (unused today).
- agents/plan-challenger.md ORCHESTRATOR PROTOCOL (~:111-112, :133-135) — mirror of lib/challenge-plan.md lacks the main-loop "Advisor first" step and the CHALLENGE SUMMARY `Advisor:` row (58a5273); the 12 skills' own summary templates also lack the row (lib rule says append it anyway). Fix direction: patch the mirror, optionally add the row to the templates. Severity: low. Discovered while: /feat advisor-points-b1 re-challenge. Not fixed.
FIXED 2026-11-17 (24354d9): the mirror gains ADVISOR FIRST (pointer to the lib, its guards) and the `Advisor:` row. Residual kept: the 12 skills' own CHALLENGE SUMMARY templates still lack the row.
FIXED 2026-11-18 (2b7aeb8, run B3): the 12 callers' CHALLENGE SUMMARY templates carry the `Advisor` row (9 block rows, 3 one-line summaries).
<!-- /ship-feature advisor-points-b2 2026-11-17 (f48343e, 24354d9, 6022b9d): review residuals, not fixed in the run -->
- skills/tour/SKILL.md STEP 0b item 2 — in fan-out the end-of-run advisor call sees only the runners' one-line rows (no diff, no report section), and a `RUNNER FAILED` row can hide fixes already committed, so "when any row reports a fix" can skip the call. Fix direction: read each REPORT's new section (or `git -C <p> diff --stat develop..<branch>`) before the call. Severity: low. Discovered while: /ship-feature advisor-points-b2 STEP 6 review.
- lib/effort-shift.md § Advisor item 3 + lib/verify-secure-loop.md stuck unit — after a fix the end call drives, the re-run gates find a main-loop call "since GATE 0 first ran", so the stuck call is already spent on that re-gate; the budget is plausible but unstated. Wording: "the six flows that run the gates" unnamed; "a later proposal" fits finish flows only; in feat/bugfix the doc and memory commits after the call always make "predates the newer commits" true; item 3 and the CHANGELOG say "the end step" of feat and bugfix, where the call sits at their commit step (STEP 5 / STEP 6), before doc sync and capitalize (the skill lines are placed right). Severity: low. Discovered while: /ship-feature advisor-points-b2 SDD final review and STEP 6 review.
PARTLY FIXED 2026-11-18 (2b7aeb8, run B3): item 3 names the six gate flows, puts feat/bugfix at their commit step, and replaces "predates the newer commits" with "names any code commit made after it (doc and memory commits excepted)". Open: the stuck-budget half.
- skills/release-candidate/SKILL.md STEP 4 — the end call's `route(phase="reflect")` has no route back, so STEP 5 (finish and tag) runs at reflect against an apply/low row. Severity: low (cost). Discovered while: same.
- skills/{feat,bugfix,audit-delta,tour}/SKILL.md summary templates — FEAT/BUGFIX/AUDIT-DELTA/TOUR COMPLETE have no `Advisor:` field (only the prose asks for the line), and the end call has no "not called (absent | error | skipped)" wording like the CHALLENGE SUMMARY row. Severity: low. Discovered while: same.
PARTLY FIXED 2026-11-18 (2b7aeb8, run B3): FEAT and BUGFIX COMPLETE carry `ADVISOR : <one-line answer | skipped (gates clean on first pass) | not called (absent | error)>`. Open: audit-delta and tour.
- skills/{ship-feature,init-project}/SKILL.md — the end call runs after STEP 6/10 code review, capitalize and doc sync; a fix it drives re-runs the gates but neither the code review nor the doc sync. Severity: low. Discovered while: same.
- agents/security-auditor.md STEP 5 dedup keys on (file:line, rule/check): an advisor-added `advisor:<class>` finding on a semgrep line counts twice in BLOCK(n) (pre-existing); "An added or applied finding" reads oddly; PROOF suffix for n=0 unspecified. Severity: low. Discovered while: same.
<!-- /hotfix doctor-skilloverrides-residue 2026-11-14: non-blocking gate finding, not BDR-125 -->
- doctor.sh `warn`/`pass`/`fail` print through `echo -e`: jq's `\uXXXX` escapes in the residue diff (:153) come back as raw control bytes (ESC sequences) on the terminal. Source = the user's own tracked settings.json (no trust boundary). Fix direction: `printf '%s\n'` in the shared helpers. Severity: low. Discovered while: /hotfix doctor-skilloverrides-residue security gate. Not fixed.
<!-- /bugfix perl-timeout-group 2026-11-14 (490ad83): non-blocking gate findings, not BDR-125 -->
- hooks/session-start.sh perl runner sends KILL to the group at the deadline (timeout sends TERM): a WRITER later put under `_SS_TMO` would skip memory.sh's INT/TERM/HUP restore trap and leave `memory.lock` until the 30 s steal. Today's three callers are readers (check, index blocker, feedback remind). Severity: low. Discovered while: /bugfix perl-timeout-group security gate. Not fixed.
<!-- /ship-feature advisor-points-b3 2026-11-18 (2b7aeb8, 51f343f): STEP 6 review root fix, not in the run's file scope -->
- lib/verify-secure-loop.md:111,:126-128 + agents/security-auditor.md:184,:190-192 — teach parsing DEGRADED off the `SECURITY — VERDICT:` line, but the auditor prints `VERDICT: PASS` on a DEGRADED scan and DEGRADED only on its `TOOL:` line (agents/security-auditor.md:133-134). A reader checking the VERDICT line misses it. feat/bugfix skip text now names the TOOL line at the site (51f343f). Fix direction: say DEGRADED shows on the TOOL line beside a PASS, in both. Severity: low. Discovered while: /ship-feature advisor-points-b3 STEP 6 opus review.
FIXED 2026-11-19 (9814720, /bugfix degraded-tool-line): the three readers (+ hotfix) read the `TOOL:` line inside the PASS bullet, the VERDICT-line `DEGRADED` value is gone, a PASS without `TOOL:` is structural; lib/effort-shift.md item 3 names the line; loops-light locks it.
- Run B3 residuals (plan purged at finish, recorded here): (a) the challenge route line pairs `mcp__model-router__route` with the server-side advisor call, unverified in this repo (lib/effort-shift.md: the router cannot see the advisor tool; pairing only saves a request). (b) skills/{feat,bugfix} end line prints the diff stat even on a skip (cost one cheap command, nothing reads it). (c) lib/effort-shift.md item 3 "Two skips only" sentence ~65 words; feat/bugfix end-line first sentence ~60 words (prose length, oracle-safe splits exist). (d) contract 2026-11-18-advisor-points-b3-1056 criterion 9 says the exempt rows "run as wide as the rows beside them"; they run wider (Advisor rows 125-132 cols vs 77-96), wording only. Severity: low. Discovered while: /ship-feature advisor-points-b3 STEP 2b/STEP 6.
<!-- /bugfix degraded-tool-line 2026-11-19 (9814720): confirmation-pass minors, pre-existing, not fixed -->
- A DEGRADED scan that BLOCKs and hits the cap: the STOP/escalation text (lib/verify-secure-loop.md, agents/security-auditor.md) does not name the missing semgrep or `make plugin`, so the human sees a checklist-only BLOCK without the remedy. Severity: low. Discovered while: /bugfix degraded-tool-line STEP 3b.
- DEGRADED is read by word presence on the `TOOL:` line: a garbled `TOOL:` line (no `semgrep <ver>`, no DEGRADED) reads as a full scan. Fix direction: allowlist `TOOL: semgrep <ver>` as the only full-scan shape, anything else DEGRADED or structural. Severity: low. Discovered while: same.
<!-- /feat merge-reuse-clause 2026-11-19 (af846d6): executor report -->
- Run 1 feater: first full `make test` exited `make: *** [Makefile:36: test] Error 1`, suite unknown (only the tail captured); rerun green, GATE 0 + verifier make test green, no stray process after. Possibly a flaky suite or overlap with the scratch-clone `make test` running at the same time (the scratch run's only red was run-reconcile T6c = darwin-skill path absent in a fresh clone, environment). Next red: keep the full log, name the suite. Severity: low. Discovered while: /feat merge-reuse-clause STEP 3.
<!-- /feat advisor-usage 2026-11-19 (c6f2dad): GATE 0 first run -->
- lib/tests/mods.test.sh: `FAIL model-router: plugin test timed out after 120s` in a full make test at load avg ~30; the suite alone took 121 s (CLI_TIMEOUT=120 at :12) and passed. Probable cause of the run 1 feater's unexplained red (entry above). Fix direction: raise CLI_TIMEOUT for the plugin test or cut its runtime. Severity: low. Discovered while: /feat advisor-usage GATE 0.
+6
View File
@@ -424,3 +424,9 @@ rules:
- **Real cause**: lib/memory.sh `memory_index` `[ -f "$file" ] || continue` treated present non-regular registry as absent; awk rc of `_mem_index_rows` dropped (fn rc = trailing echo). hooks/session-start.sh `_digest_blockers` skipped unparsable `| BLK-` rows.
- **Solution**: 87aecc1. Kind named (strict) → rc 2 + stderr `memory: <file>: not a readable regular file`; no kind (lax, mods/memory register.ts recall) → skip bad registry + stderr, rc 0. Rows captured before print, healthy output byte-identical. Digest prints `- open: unknown (memory.sh index failed)` on unparsable row. Tests SD9b/c re-pinned, SD9f/g/h, T20*. Residuals BUGS-FOUND 07f9a7f.
- **Reference**: lib/memory.sh, hooks/session-start.sh, lib/tests/memory.test.sh, lib/tests/session-digest.test.sh
## BLK-051 — DEGRADED security scan read as clean PASS: readers parsed VERDICT line, DEGRADED prints on TOOL line [resolved] (2026-11-19)
- **Friction**: DEGRADED security scan (semgrep absent) read as clean PASS: checklist + `make plugin` hint never surfaced, hotfix `SECURITY: DEGRADED (checklist only)` unreachable.
- **Real cause**: security-auditor prints `SECURITY — VERDICT: PASS` on DEGRADED scan, DEGRADED only on `TOOL:` line. lib/verify-secure-loop.md, agents/security-auditor.md ORCHESTRATOR PROTOCOL, skills/hotfix/SKILL.md STEP 4 listed `DEGRADED` as VERDICT-line sibling value after terminal `PASS` bullet → never fired. PASS without `TOOL:` line not structural → also read as full scan. Shipped in v3.0.0.
- **Solution**: 9814720. PASS bullet reads `TOOL:` line first; old DEGRADED bullets removed; PASS without `TOOL:` = structural (retry once, escalate). lib/effort-shift.md item 3 names line (LRN-300). loops-light section locks readers + feat/bugfix skip sentence (78/78; 16 FAIL on develop). Residual minors BUGS-FOUND 2026-11-19.
- **Reference**: lib/verify-secure-loop.md, agents/security-auditor.md, skills/hotfix/SKILL.md, lib/effort-shift.md, lib/tests/loops-light.test.sh, BUGS-FOUND:134
+17
View File
@@ -1004,6 +1004,7 @@ Reverses the BDR-066 rejected alternative "opus pins on audit agents (session-in
## BDR-077 — Model-tiering v2: 4-tier explicit routing, mode-based splits, no-inherit dispatches [accepted] (2026-07-19)
Supersedes BDR-076 scope + amends BDR-066. Doctrine: session model (Fable) = main-loop reflection/orchestration/planning/logic ONLY; main-loop retention criteria = interactive | conversation-context access | orchestration decision | dispatch overhead > step cost. NOTHING dispatched inherits: typed agents = frontmatter pin, built-ins = `model=` at every call site (`fable` for skill-runner reflection children, else complexity tier). Spike+smoke proven: `model:"fable"` resolves claude-fable-5 (enum-validated, loud fail, no silent fallback); call-site override BEATS a typed pin (sonnet-pinned verifier ran haiku). Fail-safe pin rule: mixed-mode agents keep the HIGH tier as pin, overrides go DOWN — forgotten override over-tiers (cost), never downgrades judgment. Mode-based splits (commit-changer precedent generalized; file splits rejected): doc-syncer audit(opus)/patch(sonnet) — ALSO fixed a latent defect: /doc dispatched an agent whose STEP 8 interactive gate could never fire; gates hoisted to a DISPATCHER PROTOCOL section; handover-doc-writer synthesize(opus)/render(sonnet) via run-scoped `.audit/handover-draft-<RUNID>.md` + DRAFT COMPLETE sentinel; seo/geo collect(sonnet)/judge(OPUS PIN)/template(sonnet) via `.audit/*-signals-<RUNID>.md` + COLLECTION COMPLETE + fail-closed judge + dispatcher ERROR contract (mute/ERROR judge NEVER carried into templating; retry once, escalate). File split only for a genuinely new role: plugin-probe (sonnet, facts-only) + plugin-advisor repinned opus reasoner (fail-closed on missing PROBE REPORT) + lib/plugin-gate.md (checkpoint + apply gate, doc-commit ×N include pattern). Inline→dispatch conversions: scaffolder, onboarder, doc-commit steps ×5 flows — their sonnet pins were INERT since creation, now live; CHANGE SUMMARY crosses the doc dispatch into doc-commit (LRN-126 wire). Tier moves: validator-analyzer opus→sonnet (deterministic runner); commit-changer propose=opus/apply=pin; ship-feature/init-project code-review dispatches = opus explicit (WAS an inherit leak); client-handover-writer's 7 skill-runners = model:"fable". Every wave shipped an IN-WAVE planted-input smoke as its merge gate — all PASSED disk-verified. Census §12-18 (125 pass; one vacuous line-wrapped lock self-caught = LRN-093 live). 6 waves, branches feature/model-tiering-w1..w6, merged on user standing signal. Plan: challenged 3 blind lenses + 1 confirmation (1 BLOCKER closed by spike, 8 MAJORs + 8 MINORs closed by named changes, 0 deferred). Refs: `.claude/tasks/plans/2026-07-19-model-tiering-v2-{analysis,plan}.md`.
- **Status (2026-11-17)**: accepted, amended by BDR-150: skill-runner pins opus (beebfe2); session opus, Fable is the advisor
## BDR-078 — ctx7 coverage: central fast-libs list + once-per-session reminder hook; every code path covered [accepted] (2026-07-20)
Refines BDR-053 (single surface). Audit 2026-07-20: coverage PARTIAL — find-docs fired on user doc-questions only; ship-feature 0c / init-project 5c pre-fetched; /feat //bugfix executors + ad-hoc coding NEVER consulted ctx7; fast-libs list hardcoded 3× (drift risk). 4 closures shipped: (a) find-docs description += BEFORE-writing-code trigger (fast-moving lib, even without doc question, unless fresh cache) + cache-first rule in body (tee fetched docs to .ctx7-cache/); (b) feater+bugfixer briefs += fast-lib docs rule — read fresh `.ctx7-cache/<lib>*.md`, else `npx ctx7@latest` fetch max 2 topics, else `ctx7 cache miss: <lib>` in NOTES + proceed (executors lack Skill tool → Bash path); (c) hooks/ctx7-reminder.sh UserPromptSubmit — ONE fire/session (sentinel on session_id), only when project manifest carries fast-libs; reports cache state; skips <task-notification> turns; always exit 0; (d) lib/fast-libs.sh = SINGLE SOURCE (detect / cache-status verbs, JS package.json anchored full-key match + Python requirements/pyproject, 7-day freshness, LC_ALL=C sort locale-independent) consumed by hook + 3 pipeline skills + 2 briefs. 2nd session surface DELIBERATE, not a BDR-053 reversal: 053 killed a 490-tok ALWAYS-ON rule duplicate; hook costs ~0 quiet, 1 line once when fast-libs present. Alternatives rejected: PreToolUse Edit/Write gate (fires per-edit = noise); description-only fix (probabilistic, executors unreachable). Tests: lib/tests/fast-libs.test.sh 11 checks (anchored/near-miss/py/none, cache fresh/stale/missing, hook fire/sentinel/quiet×2); shellcheck + full make test green. Branch feature/ctx7-coverage, unmerged (human gate).
@@ -1386,6 +1387,7 @@ Branch feature/user-writing-web-rules, UNMERGED (human gate).
- **Amendment (2026-10-23, feat C 786ee13 + docs d2d590f)**: keyword-lift gap CLOSED: prompt rules (keywords, `ultrathink`, user rules) + derived `orchestrate` on main Agent dispatch (user pick 2026-10-23) write effort-only routes; model axis falls through to held run or stays on cur. Amends [[BDR-115]] amendment 2026-10-13 clause "ultrathink floor model beats guess": mid-turn ultrathink after classifier demotion keeps guessed model that turn (floor raises effort only). Accepted edges: haiku session → keywords no-op; session model held → keyword turn = plain-turn fallback (sonnet), not fable; no stand-in notch on keyword/dispatch turns; dispatch after demotion orchestrates on demoted model. Rejected: cap in `wantedModel` (r1) → shadowed held run slot + fail-open on `sessionModel` '' after /reload-plugins. Contract `.claude/tasks/contracts/2026-10-23-router-keyword-cap-0019.md`, plan r2.1 `.claude/tasks/plans/2026-10-23-router-keyword-cap-0019.md`. Links [[LRN-226]], [[EVAL-048]].
- **Amendment (2026-10-25, bugfix 8e93507)**: accepted edge "haiku session → keywords no-op" REVERSED (user pick: Haiku 5.x like any model). No-effort rule now Haiku 4.x only (`NO_EFFORT = 'claude-haiku-4'`); on Haiku 5.x keyword rules, `ultrathink`, sticky effort and derived orchestrate apply, unrouted step passes engine effort. Links [[BLK-035]], [[LRN-230]].
- **Status (2026-11-16)**: accepted, amended by BDR-136: ceiling model-agnostic, main loop writes no code outside a skill run on any model, held by router write guard (fail-closed since 859e504); Fable-only /hotfix-scope ceiling gone (0bf4620)
- **Status (2026-11-16)**: accepted, amended by BDR-150: no Fable via rows, opus heads best and big; session opus, Fable is the advisor
## BDR-124 — Foreign code keeps its own style; limits strict in our code only [accepted] (2026-10-23)
- **Decision**: CLAUDE.global.md header: strict limits in our code, "Foreign code: keep its style" section wins on foreign code (granularity, layout, naming, comments, idioms; limits = guidelines; no refactor toward our norms unless asked). Origin = `lib/code-origin.sh`: `git config claude.origin` (ours|foreign, per clone, invalid → foreign) > root commit author vs `user.email` + global `claude.identity` list; undecidable (no git, shallow, no commit) → foreign, said. Session banner line `code : ours|foreign (reason)`. refactorer, /refactor, /audit-delta conformity follow it; refactorer cites CLAUDE.md limits, no copy.
@@ -1490,6 +1492,7 @@ Supersedes [[BDR-030]].
- **Residual (user-accepted, F)**: Fable held or cap exceeded at the route event → no question, slot unstamped; hold lapse / compaction → next step upgrades unasked (breaker behaviour today). `/model <x>` while any dialog holds `asking` falls to native (pre-existing, BDR-126).
- **Gates**: r1 correctness FATAL(6) robustness FATAL(6) simplicity CONCERNS(4) → r2 → confirmation CONCERNS(6) → r3; feater DONE 28 TIER tests (590 → 618); GATE 0 MET 5/5; verifier CONFORME 11/11 first pass; security PASS (1 LOW fixed: `clean(skill)`). Commits 9a24a62, docs 789fd00.
- **Refs**: [[BDR-116]], [[BDR-123]], [[BLK-032]], [[LRN-231]], [[LRN-242]], [[LRN-254]].
- **Status (2026-11-16)**: accepted, amended by BDR-150: ask-before-Fable inert unless an override heads best with fable; stored answers gate on fableHeadsBest
## BDR-136 — Phase 2 guards: native ask merge gate, bench-proven shell rules, rtk rc 3 passthrough, router write guard with a session skill latch, code-limits signal [accepted] (2026-11-02)
- **Context**: BDR-125 phase 2, feature/phase2-guards, contract `.claude/tasks/contracts/2026-11-02-phase2-guards-1545.md`, bench `.claude/tasks/plans/2026-11-02-phase2-bench/`.
@@ -1596,3 +1599,17 @@ Supersedes [[BDR-030]].
- **Alternatives rejected**: drop every routing line (loses the gstack counterweight + pack-off remedy); "never gstack ship" text in ship-feature description (ship retired from every pack, lib/gstack-removed.list: dead text); trigger "open a PR" (no skill opens a PR).
- **Accepted**: description triggers not pinned by a test (darwin rewrite risk, MINOR); listing budget +~60 chars.
- **Amends**: BDR-130 Deferred item done; BDR-125 phase 3 "Skill routing table lines → descriptions" done.
## BDR-150 — Fable = advisor only, never auto-routed; Opus heads best and big [accepted] (2026-11-16)
- **Context**: user 2026-11-16: Fable set as advisor (`/advisor`, settings `advisorModel: fable`, bdbf1cd); "no auto-route on Fable, Opus = strongest model to auto-route; advisor called whenever a smarter agent is needed". feature/router-no-fable, contract `.claude/tasks/contracts/2026-11-16-router-no-fable-1100.md`, plan r3 after 2 challenge rounds.
- **Decision**: DEFAULT_CONFIG tiers `best` and `big` = ['opus','sonnet']; fable kept in `models` and at `fallback[0]` (capability rank: hand pick of fable ranks above opus, breaker never moves up to it). Row Change dialog (CHOICE_ALIASES) drops fable; bare /model keeps it ("fable (custom)"). Ask-before-Fable (askTier) fires only when alias heading best = fable (override); stored "instead" answers gate on fableHeadsBest; `/route ask-tier on` replies inert. "tiers.best does not lead the fallback chain" log deleted. routing.json untouched (askTier "best"): mod runs live from tree, old-code sessions would route Fable unasked on `askTier: false`. Agents floor = tier head (opus) for every tier.
- **Why**: Fable reasoning now comes via advisor tool (server tool, hooks cannot see/refuse it); routing main/agents to Fable duplicated cost (BLK-030 credits) and ceiling logic.
- **Alternatives rejected**: tiers in tracked routing.json (new layer code, breaks machine-key doctrine); per-machine `~/.claude/model-router.json` (not portable to work machine, near hard_deny mod clause); removing askTier feature (churn; kept dormant, `shortcut:` at TIER_HEAD); fable out of `fallback` (appended last → hand-picked fable ranks below haiku); routing.json `askTier: false` (live-install consent gap).
- **Residuals**: opus outage → best/big agents spawn on held opus (gates fail, verify-secure retries then escalates; was move-up to Fable); single opus outage → sonnet stands in with effort notch; fable-baseline session (native Everywhere) demoted to opus per downgrade caps, sessionPin pins general-purpose to fable; skill row answering opus+xhigh in Change lands on `plan`. Test rig: shipped tiers default, `legacyTiers: true` on 47 fable-mechanics tests.
- **Gates**: r1 3 lenses CONCERNS → r2 → re-challenge CONCERNS → r3; feater DONE 661 tests; GATE 0 MET; verifier CONFORME; security PASS (MEDIUM fixed: stored answer survives ask-tier off); commits 24b0f35, docs 42385d2.
- **Refs**: amends [[BDR-123]], [[BDR-135]]; supersedes [[LRN-224]]; [[BLK-030]], [[BDR-077]] (Fable dispatch pins: separate run).
- **Status (2026-11-17)**: accepted, completed: pins opus beebfe2 (gate row 'fixed at spawn' passes a pinned sub-agent), doctrine c3507ea (main loop calls advisor, sub-agents do not, absent advisor -> proceed, advice waives no gate)
- **Status (2026-11-17)**: accepted, amended 6ef3069: main loop named call points (before a skill's plan, once per verify-secure run at first gate loop failing twice, before merge); plan-challenger/verifier/security-auditor at most one call before verdict, advice add-only (security: STEP 3 class severity, no class -> REPORTED LOW); other sub-agents do not
- **Status (2026-11-17)**: accepted, amended 58a5273: plan point in lib/challenge-plan.md (on written plan before challengers, once per skill run, Advisor: row in CHALLENGE SUMMARY, no attribution in plan); stuck lines inline in verify-secure-loop (main-loop calls only since GATE 0); dispatched analyzer joins; trigger before recommending doctrine/architecture/public-interface change
- **Status (2026-11-17)**: accepted, amended 6022b9d: B2 stuck trigger in 6 gate skills (points to verify-secure-loop); end-of-run call before done/merge in feat, bugfix, ship-feature, init-project, a11y, guardrails, audit-delta+tour (fix applied only), release-candidate STEP 4; own budget; gate flows print diff stat, fix back through gates; verifier/security-auditor/plan-challenger advise only when dispatched; auditor raise upward only; plan-challenger protocol mirror. Commits f48343e 24354d9 6022b9d
- **Status (2026-11-18)**: accepted, amended 51f343f: B3: challenge route rides first lib/challenge-plan.md call; summary Advisor row in 12 callers; feat/bugfix skip end call when GATE 0 MET + verifier CONFORME + security PASS (not DEGRADED, TOOL line) first attempt, ADVISOR field shows skip; item 3 reuse clause names later code commits
+17
View File
@@ -769,3 +769,20 @@ rules:
- A6 router write guard fail-closed: .catch uses next.called (called → replay next(e); not called → hold main-loop out-of-run non-doc write with user-chosen deny); Skill latch ignores isError answers (BDR-137 shape, was one-call bypass) (859e504). BDR-136 (4) amended. 3 plan rounds: r1/r2 latches unreachable, engine-documented pattern won. gates.sh 120s timeout < make test ~135s: GATES_TIMEOUT=400. Next A7.
- C7 hard_deny mod off-switch clause: entry 6 names enabled:false in ~/.claude/<mod>.json, enabledPlugins false, profile.sh disable of mod (8c21c4b); off switches only, no source paths (2026-10-25 challenge). Staged via crafted index blob so user's dirty settings.json /model change stayed out. Residuals (closed list, /route off in run, over-refusal risk) BUGS-FOUND e22893d.
- C1-C3 BDR-125 gap: 11 status lines (BDR-125 summary; BDR-079/017 + LRN-155 superseded, 7 amended by BDR-134/136; amended entries still recalled with old title, only superseded/deprecated leave recall); C3 deferrals → 7 TODO lines + 3 dated drops; C6 dropped (throwaway repos, user).
- Router no-Fable (BDR-150, 24b0f35, docs 42385d2): best/big = opus>sonnet, fable ranked + hand pick only, Change dialog drops fable, askTier inert unless override heads best with fable; routing.json untouched (live install). 2 challenge rounds caught dialog labels, live-install consent gap, legacy rig masking. BDR-123/135 amended, LRN-224 superseded. Next: Fable pins → opus, advisor doctrine.
- Fable pins → opus (beebfe2, docs): client-handover 7 skill-runner pins + model-gate doctrine opus, gate row 'fixed at spawn' proceeds in sub-agent, repo-wide census refuses fable pins. Amends BDR-077 W1 per BDR-150. Next: doctrine run (effort-shift, advisor rule, Fable prose).
## 2026-11-17
- Advisor doctrine (c3507ea, docs): CLAUDE.global § Workflow + effort-shift § Advisor: main loop calls Fable advisor (approach, stuck, before done), sub-agents do not (they have tool listed: prose-only, residual), absent → proceed, advice waives no gate/cap/guard. Stale Fable prose → opus (effort-shift, challenge-plan, plan-challenger, tour). BDR-150 change complete: router 24b0f35, pins beebfe2, doctrine c3507ea.
- Advisor call points run A (6ef3069): transcript count showed main loop 2 calls on Opus (409k/680k uncached) vs 18/20 opus sub-agents on Fable (~70k); doctrine now names main-loop points (plan, first gate loop failing twice, merge) + judgment agents once, advice add-only; 2 challenge rounds, gates found block E double count, fixed r5. Runs B, C next.
- Advisor run B1 (58a5273): plan point moved into lib/challenge-plan.md (once per skill run, Advisor: row), stuck lines inline in verify-secure-loop (main-loop calls only), analyzer joins, trigger for doctrine/architecture/public-interface recommendations. 2 challenge rounds (2 BLOCKERs were my own oracle markers), scratch simulation then MET first run; gates sequential, CONFORME + PASS.
- Advisor run B2 (/ship-feature, f48343e 24354d9 6022b9d): stuck line in 6 gate skills, end-of-run call at each flow's end step (9 flows, capitalize-commit untouched), 3 judgment agents dispatch-scoped, auditor raise upward only; plan r3 after 3 lenses + confirm; STEP 6 review fix restated fix path in skills (LRN-297); gates green first pass and after fix. Merge waits for user go.
## 2026-11-18
- gates.sh hotfix c25a7ea (bugfix/gates-label-timeout): digit label not `N. text` = parse error; 2nd CHECK/EXPECT/EVIDENCE on one criterion = error (indented/bullet/bold labels gave same false MET, advisor caught it); no-criteria die names first parse error; default timeout 120 -> 600. GATE 0 MET 5/5 incl full make test at default, security PASS, 3 challengers SOLID. ABANDON-id aliasing + verify-secure-loop cause list -> TODO.
- Advisor run B3 (/ship-feature, 2b7aeb8 51f343f): 12 callers route rides first challenge-plan call + summary Advisor row; feat/bugfix skip end call on strict clean gates (MET, CONFORME, PASS not DEGRADED, first attempt), ADVISOR field; item 3 commit step + reuse names later code commits. 3 lenses + re-challenge (3 MAJOR fixed), opus STEP 6 caught DEGRADED on TOOL line (LRN-300). Gates clean x2.
## 2026-11-19
- /bugfix degraded-tool-line 9814720: 3 security readers read DEGRADED off TOOL line (BLK-051), BUGS-FOUND:134 FIXED, TODO:13 done, 2 pre-existing minors logged; CHANGELOG Fixed entry.
- /feat x2 merge-reuse (af846d6, 87566e2, feature/advisor-merge-reuse): 6 gate-flow end lines restate effort-shift item 3 merge-reuse clause, loops-light 97; TODO:14 done, 3 follow-ups logged; run 1 GATE 0 ERROR = contract without EVIDENCE: pending (LRN-173 again).
- Run C /feat advisor-usage (c6f2dad + retention fix, feature/advisor-usage): FEEDBACK.md advisor usage table per caller/model, reconciled vs probe (156 calls, 21.7M); found general-purpose sub-agent advisor leak (30 calls, 7.1M) → TODO; LRN-301 (call = served iteration), LRN-302 (scratch develop ref); mods.test.sh timeout under load → BUGS-FOUND.
+53
View File
@@ -1771,6 +1771,7 @@ Rule: when editing a doctrine file under structure locks, grep the test's lock s
- **Date**: 2026-10-21
- **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]].
- **Status (2026-11-16)**: superseded by BDR-150: best and big headed by opus, agents floor on tier head for every tier (2nd-alias rule gone)
## 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
- **Date**: 2026-10-22
@@ -2121,3 +2122,55 @@ Rule: when editing a doctrine file under structure locks, grep the test's lock s
- **Context**: A6 router write guard fail-closed (859e504). r1 try/catch around guardWrite, r2 cfgErr hold + `.catch` latches: challengers found latches unreachable (no ensureConfig throw source), typed-skill latch unable to fire. claude-code.d.ts tool.call remark already prescribes `.catch(($, e, next) => next.called ? next(e) : { deny })`; Caught.called splits guard failure from downstream error, next(e) replays without re-run. r3 used it: guardWrite unchanged, 3 `.catch` blocks only.
- **Apply**: grep `~/.claude/plugins/marketplaces/claude-code-plugins/mods/types/claude-code.d.ts` for the event + `@remarks` before planning; prefer documented idiom over hand-built try/catch. Engine refusals reach hooks as `isError`, not `deny` (BDR-137): latch/success predicates test both.
- **Reference**: mods/model-router/hooks/register.ts guardCaught, guardPasses; BDR-136 amended
## LRN-294 — Scope rules to main loop only after checking which tools sub-agents really get (2026-11-17)
- **Pattern**: before scoping a rule to "main loop only" or "sub-agents never", check which tools sub-agents actually receive; harness may list tool + prompt them to use it, so prose rule fights harness instruction.
- **Context**: 2026-11-17 advisor doctrine (BDR-150, c3507ea). Plan assumed advisor = main-loop tool. Robustness challenger (typed sub-agent, tools Read/Grep/Glob/Bash) had `advisor` listed + system prompt saying call it before/after work; same for verifier, security-auditor, executors. Each call forwards that agent's full transcript to Fable outside router caps (server tool, hooks cannot see/refuse).
- **Apply**: ask a dispatched agent what tools it has (or read its prompt) before writing a scope rule; prefer mechanical scope (settings/tool lists) over prose; when only prose exists, log as residual (BUGS-FOUND d292911).
- **Reference**: CLAUDE.global.md § Workflow, lib/effort-shift.md § Advisor
## LRN-295 — Measure advisor calls from transcripts: per caller, model, uncached input (2026-11-17)
- **Pattern**: measure advisor use from session transcripts, not from feel. Main transcript `~/.claude/projects/<proj>/<session>.jsonl`, sub-agents `<session>/subagents/*.jsonl` (+ `.meta.json` agentType). Call = content block `server_tool_use` name `advisor`; model + tokens = `message.usage.iterations[]` with `type=="advisor_message"`. Usage rows repeat once per content block: dedupe by `message.id`.
- **Context**: 2026-11-17, user asked if advisor called when needed. Since /advisor (2026-11-16 16:19Z): main loop 2 calls, served by Opus (conversation kept old advisor), 409k + 680k input tokens, cache_read 0; 18/20 opus sub-agents 19 calls on Fable, median 70k (43k-119k), total 1.46M; 8 sonnet sub-agents 0. Data reversed "main loop only" (c3507ea) → 6ef3069 (judgment agents once, main loop named points).
- **Apply**: before scoping who calls advisor, or judging cost: count per caller + model + uncached input; main-loop call in long session costs ~6-10 sub-agent calls. Run C (/memory-feedback advisor section) automates it.
- **Reference**: lib/effort-shift.md § Advisor, BDR-150, LRN-294
## LRN-296 — Simulate contract CHECKs on a scratch copy of the planned edit before dispatch (2026-11-17)
- **Pattern**: before dispatching a prose/doctrine run, apply the planned blocks to a scratch copy (deterministic applier asserting each anchor once) and run every contract CHECK against it. Grepping markers against the block text alone misses cross-block effects.
- **Context**: 2026-11-17 advisor runs A and B1. Markers broke three times: phrase wrapped across two lines (grep per line, count 0); awk `/X/{a=NR}` kept LAST match after a later block mentioned "X"; census extractor read word after `§ Label` as part of heading ("§ Workflow names"). Each would have cost a floor loop. Also `Nb.` criterion label absorbed by gates.sh (LRN-284). Simulation of B1 (apply.py on mktemp copy) passed 5/5 CHECKs; executor then got MET first run.
- **Apply**: any /feat or /bugfix whose oracles are grep/awk markers on prose: write blocks to files, applier script with exact-once asserts, run CHECKs with `cd` swapped to the scratch copy; anchor awk on line start (`/^\*\*Label/`); keep each marker and each `§ Label` citation on one line followed by `)`/`;`. Give the executor the applier.
- **Reference**: lib/gates.sh, lib/tests/doctrine-citers.test.sh, .claude/tasks/plans/2026-11-17-advisor-points-b1-1500.md, LRN-284
## LRN-297 — Single-source doctrine holds only where acting step loads cited lib (2026-11-17)
- **Pattern**: rule kept once in lib + skills citing it works only if step that acts loads that lib. Citation alone not read at act time.
- **Context**: 2026-11-17 run B2 STEP 6, 2 reviewers (sonnet SDD final, opus craft). Stuck lines fine: gate step loads `lib/verify-secure-loop.md`. End-of-run lines cited `lib/effort-shift.md` § Advisor, loaded only via ROUTING line, never at end step → diff stat + fix path (item 3) unseen; 3 of 9 lines already restated own path, 6 silent read as "report only". Parked ruling withdrawn, clause restated at 6 sites (6022b9d).
- **Apply**: before keeping a procedure only in a lib, check acting step reads that lib (include it loads, not ROUTING line); else one clause at site, lib keeps full rule. Uneven restatement across sibling sites = misread by contrast.
- **Reference**: lib/effort-shift.md § Advisor item 3, lib/verify-secure-loop.md, BDR-150, LRN-296
## LRN-298 — Marker oracles prove presence, not placement semantics (2026-11-17)
- **Pattern**: marker oracles prove text present at position, not placement semantics. Need read of flow's own sequence: who executes site, when run is declared done, can condition be false.
- **Context**: 2026-11-17 run B2: scratch-clone simulation 15/15 MET, yet challengers found end call after FEAT COMPLETE (done already printed), tour runners (sub-agents) execute STEP 3 holding main-loop call, skip "fixed or committed anything" always true (tour commits report each run). Fixed in plan r2/r3 before dispatch.
- **Apply**: anchor position oracles on flow's done/merge moment (summary or finish line), not nearby heading; per site list executor (main loop vs runner/sub-agent) and falsifiable condition. Non-idempotent applier fix after commit: delta group from HEAD + byte-compare with fresh apply from base (review1 == fresh).
- **Reference**: docs plan 2026-11-17-advisor-points-b2 (purged at finish, git keeps), LRN-296, LRN-284
## LRN-299 — Cursor parser: refuse the overwrite at the sink, not the label shapes at the source (2026-11-18)
**Context**: gates.sh hotfix c25a7ea (2026-11-17). LRN-284 named `1b.` label: parser drops it as prose, cursor `_CUR` still on previous criterion, stray CHECK/EXPECT overwrite its oracle → false MET. First plan: reject `^[0-9]` non-`N. text` lines. Advisor + scratch fixtures: indented ` 2.`, `- `, `**2.**` labels gave same false MET.
**Pattern**: line parser with current-record cursor → close overwrite at sink: refuse second write of already-set field (`_set_attr` guard), not enumerate bad label shapes at source. Source-side rule only names the common shape (better error message).
**Apply**: any cursor parser (contract ledger, registry, config sections). Before fixing a reported bad input shape, fixture sibling shapes (indent, bullet, bold) against the same sink; scan existing data for repeated fields first so guard changes no past verdict.
## LRN-300 — Rule keyed on a gate verdict names the line its qualifier prints on (2026-11-18)
**Context**: advisor run B3 (2b7aeb8, 51f343f). feat/bugfix skip end-of-run advisor call when security PASS "(not DEGRADED)". security-auditor prints `SECURITY — VERDICT: PASS` on DEGRADED scan; DEGRADED only on `TOOL:` line (agents/security-auditor.md OUTPUT), while lib/verify-secure-loop.md teaches reading DEGRADED off VERDICT line → reader checks wrong line, wrong skip. 3 lenses + re-challenge missed it; opus STEP 6 caught it.
**Pattern**: rule keyed on gate verdict must name the line its qualifier prints on. Agent OUTPUT format = source of truth, not the doctrine paraphrasing it.
**Apply**: before writing a condition on an agent's verdict, grep that agent's OUTPUT block for where each qualifier prints; state the line at the site.
## LRN-301 — Advisor call = served advisor_message iteration, not request block; reconcile usage table vs independent probe (2026-11-19)
- **Pattern**: advisor call = served `advisor_message` iteration in `message.usage.iterations[]`, not `server_tool_use` block named `advisor`. Block without iteration = request never run (sent beside client tool_use, re-issued next message) or `advisor_tool_result_error`. Count iterations, dedupe by `message.id`. Usage table built from transcripts: reconcile row by row against independent probe (other language, same window, same instant) before calling it right; gates re-running same code prove nothing about real numbers.
- **Context**: 2026-11-19 Run C (/memory-feedback advisor usage, c6f2dad). Real transcripts: 147 blocks vs 141 iterations (5 unrun, 1 error). Python probe vs bun table: 8 rows identical, 156 calls 21.7M input tok. First table exposed leak: general-purpose sub-agents 30 calls / 7.1M (16 after 6ef3069 rule), doc-syncer 4.
- **Apply**: any advisor cost/usage count: iterations not blocks; corrects LRN-295 call definition. Report generator on real data: independent probe + timing before FEAT COMPLETE.
- **Reference**: lib/memory-feedback/advisor.ts, LRN-295, BDR-150, TODO advisor doctrine leak
## LRN-302 — Scratch clone -b lacks local develop: create ref before simulating develop-based oracles (2026-11-19)
- **Pattern**: `git clone -q -b <branch> . <scratch>` scratch copy has no local `develop` (only `origin/develop`): oracles naming `develop` (`git diff --quiet develop -- …`, floor-guard) fail `fatal: bad revision 'develop'` on scratch, pass in real repo. Before simulating contract CHECKs on clone: `git -C <scratch> branch develop origin/develop`.
- **Context**: 2026-11-19 merge-reuse run 2 simulation (LRN-296 method): criterion 3 SKIP-INTACT failed only on scratch clone; fixed by creating ref.
- **Apply**: every LRN-296 scratch simulation from a non-develop branch: create local develop ref first, else false red.
- **Reference**: LRN-296, .claude/tasks/contracts/2026-11-19-merge-reuse-feat-bugfix-1450.md
+25 -3
View File
@@ -3,6 +3,23 @@
## Open (reconciled 2026-11-12 before 3.0.0, /reconcile on the BDR-125 phases; full pass 2026-10-23)
Done history before 2026-10-08 removed 2026-10-23 (git keeps it: `git log -p -- .claude/tasks/TODO.md`); decisions live in `.claude/memory/`.
### Advisor call points (user 2026-11-17: "oui 1 et 2, et le 3 aussi"; amends BDR-150)
- [x] Run A DONE 6ef3069, merged fc2d84d (docs 09277f5, audits c1a0c32, memory 78a6942) /feat feature/advisor-call-points: CLAUDE.global § Workflow + lib/effort-shift.md § Advisor + plan-challenger/verifier/security-auditor one-call rule (contract .claude/tasks/contracts/2026-11-17-advisor-call-points-1130.md)
- [x] Run B1 DONE 58a5273, merged eb1f594 (docs 47e5ee8, audits 9033b4a, memory d55f491) /feat feature/advisor-points-b1 (user 2026-11-17 "oui a, b et c"): (a) main-loop plan point in lib/challenge-plan.md (before first dispatch), (b) analyzer joins judgment agents (CLAUDE.global, effort-shift, agents/analyzer.md), (c) trigger "before recommending a change to the doctrine, the architecture or a public interface", stuck call lines in lib/verify-secure-loop.md (contract .claude/tasks/contracts/2026-11-17-advisor-points-b1-1500.md)
- [x] Run B2 DONE f48343e + 24354d9 + 6022b9d, merged 6c4d24f (docs 5bc64f4, audits bfcf21a 0ceaa58, memory 9917ade) /ship-feature feature/advisor-points-b2 (user 2026-11-17): stuck line in the 6 gate skills; end-of-run call at each flow's own end step (feat, bugfix, ship-feature, init-project, a11y, guardrails, audit-delta + tour when a fix was applied, release-candidate STEP 4), lib/capitalize-commit.md untouched; verifier/security-auditor/plan-challenger advise only when dispatched; auditor raise upward only; plan-challenger protocol mirror; effort-shift item 3 + blank line (contract .claude/tasks/contracts/2026-11-17-advisor-points-b2-1634.md; BUGS-FOUND :109-111 fixed, B2 review residuals logged)
- [x] DONE 2b7aeb8, merged 366f1f6 (docs 575408c, audits 8733669 8f23683, memory 49cc13c) (run B3, /ship-feature feature/advisor-points-b3): route line now "send it with the first tool call of lib/challenge-plan.md, the advisor call when one is due" in the 12 callers. Was: The 12 skills send their reflect route with the challenger dispatch, after the advisor call now (low; moved out of B2 by the user 2026-11-17)
- [x] DECIDED user 2026-11-18 "skip when gates clean" (strict), DONE 2b7aeb8 + 51f343f (run B3). Was: Decide: feat/bugfix end-of-run advisor call has no skip (audit-delta/tour skip when no fix was applied); nominal /feat or /bugfix = 2 main-loop advisor calls (plan + end), ~0.6-1.4M uncached tokens late in a session; ship-feature STEP 6 opus review and the end call review the same branch back to back (B2 STEP 6 review, user decision)
- [x] After B1 DONE (doc commit + BDR-150 status + LRN-296): README/USAGE/CHANGELOG say "before writing a skill's plan (/feat, /bugfix, /ship-feature)" and list 3 agents → doc-sync; BDR-150 status line
- [x] DONE 9814720, merged 4a8dffb (docs 4bb0a95, audits b120ba5, memory 9f8cf97) (/bugfix degraded-tool-line, with BUGS-FOUND:134). Was: loops-light lock on the feat/bugfix skip sentence ("each on its first attempt", "(not DEGRADED)"): B3 contract CHECKs are one-shot (robustness challenger, run B3)
- [x] DONE af846d6 + 87566e2, merged 82dee85 (audits 17a60fd, memory 1ec72d9) (/feat x2, feature/advisor-merge-reuse; user 2026-11-19 "all 6": feat/bugfix too). Was: a11y:201, guardrails:278, ship-feature:325, init-project:361 end lines: restate item 3's merge-reuse clause ("reuses the last run's answer, or its skip, and names any code commit made after it"); item 3 loads only via the lib (B3 final review, low)
- [ ] lib/effort-shift.md § Advisor item 3 reuse clause has no fallback: end-of-run answer absent (advisor absent/error) or out of view at the merge signal → candidate "answer absent or out of view → the merge proposal runs the call" (source, not the sites); the merge happens at the gitflow finish gate (skills/gitflow/SKILL.md:68-89, 0 advisor mentions) where the rule is not loaded (merge-reuse challengers, low)
- [ ] item 3 "names any code commit made after it" has no anchor: ADVISOR field records no HEAD SHA, commits made outside the session are invisible; candidate: record the short SHA with the answer (visible format change, user decision) (merge-reuse robustness challenger, low)
- [ ] end-of-run sites restate the call but not "one end-of-run call per skill run": a fix that goes back through the gates re-enters the end step and may call again (merge-reuse robustness challenger, low)
- [x] DONE c6f2dad + 63f5fa4, merged 6e45536 (docs 7d09837, audits 77aac4b, memory 3ffd81f) (/feat feature/advisor-usage; user 2026-11-19: FEEDBACK.md section, per agentType, all projects no repo, since last run, retention + drift lines). Was: Run C /feat: advisor usage section in /memory-feedback (main loop vs sub-agents, model served, input tokens; dedupe usage rows by message.id, model from the `advisor_message` iteration)
- [ ] Advisor doctrine leak: general-purpose sub-agents called the advisor 30× (7.1M input tok, the largest line of the first advisor usage table; 16 on 2026-11-18/19, after 6ef3069 2026-11-17 12:59 limited sub-agents to plan-challenger/verifier/security-auditor/analyzer), doc-syncer 4× (2026-11-16/17). Likely SDD implementers/reviewers dispatched as general-purpose: find why the "executors and every other sub-agent do not" rule does not reach them (brief, agent prompt or tool listing) (Run C first table, medium)
- [ ] lib/tests/mods.test.sh model-router plugin test runs ~121 s alone vs CLI_TIMEOUT=120 (load avg 26-31 on 2026-11-19): flaky red in make test, probable cause of run 1 feater's unexplained red; raise the bound or speed the test (Run C GATE 0, low)
- [x] Stale citers after A: README/USAGE/CHANGELOG patched, BUGS-FOUND residual superseded + LOW logged, BDR-150 status, LRN-295 (LRN-294 kept: its lesson holds)
### BDR-125 close-out run (user 2026-11-12): no phase 0/0b/4a/1/5/2/4b/4c/4d line left in TODO or BUGS-FOUND
Decisions at start (asked once): faunosteo memory v2 on `chore/memory-v2` off develop in a fresh worktree (split already on develop 7a75974, 11 rules); settings.json `npm -g` deny lines removed on the block E branch, classifier test = `npm install -g --dry-run cowsay`; 3.0.0 cut right after block A (/release-candidate), later blocks land under the next Unreleased; LRN-270 bisect = user-run interactive sessions, one `--settings` file per pack. Merge prompts (`gitflow finish` ask) = the human signal per block once gates are green.
- [x] A merged 1b82a25 (routing `confirmed` row a2f352e)
@@ -75,8 +92,11 @@ Open children of the shipped phases (History 2026-11-12), text verbatim.
- [ ] 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.
- [x] D3 add-ons (done 9b12b12) 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: ~<N>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)
- [x] D6 project rule (done c69ce9c; lead paragraph fixed too, follow-ups in BUGS-FOUND): .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
- [ ] gates.sh: warn or reject a criterion row labelled `^[0-9]+[a-z]\.` (LRN-284: `1b.` absorbed into criterion 1, its CHECK/EXPECT overwritten, false MET)
- [ ] gates.sh default `GATES_TIMEOUT=120` < full `make test` (~135 s on 2026-11-16): a "Full make test green" criterion goes NOT-MET on timeout alone (A6 run, re-run with GATES_TIMEOUT=400). Raise the default or have contract-interview write the timeout for full-suite criteria.
- [x] DONE c25a7ea, merged 2d8e457 (docs 15c6d09, memory 44dc0b3 482fd37 LRN-299) (bugfix/gates-label-timeout, user 2026-11-17 "reject"; also rejects a 2nd CHECK/EXPECT/EVIDENCE on one criterion: indented ` 2.`, `- `, `**2.**` gave the same false MET) gates.sh: warn or reject a criterion row labelled `^[0-9]+[a-z]\.` (LRN-284: `1b.` absorbed into criterion 1, its CHECK/EXPECT overwritten, false MET)
- [x] DONE c25a7ea (user 2026-11-17: default 600 s, env override kept) gates.sh default `GATES_TIMEOUT=120` < full `make test` (~135 s on 2026-11-16): a "Full make test green" criterion goes NOT-MET on timeout alone (A6 run, re-run with GATES_TIMEOUT=400). Raise the default or have contract-interview write the timeout for full-suite criteria.
- [ ] gates.sh:93 ABANDON regex `([0-9]+)?` reads `ABANDON: 1b …` / `1.1` as id 1: after a renumber (LRN-284) criterion 1 is masked ABANDONED (rc 3) instead of "unknown criterion" ERROR. Anchor the id `([0-9]+)([[:space:]]|$)` + test (robustness challenger, gates hotfix 2026-11-17)
- [ ] gates.sh residual: a stray oracle (indented ` 2.`, `- `, `**2.**` label) after a MANUAL criterion still attaches to it, row MANUAL → MET/NOT-MET on an unrelated oracle (no red oracle overwritten; accepted 2026-11-17)
- [ ] lib/verify-secure-loop.md:46-47 ERROR(n) cause list is examples, incomplete: missing "no numbered criteria", "ABANDON names unknown criterion", malformed label, second attribute (c25a7ea)
- [ ] lib/design-tool-gate.sh:70 `perl -e 'alarm shift; exec @ARGV' 15 21st whoami` kills one process only (same limit as the old session-start runner, fixed 490ad83): reuse the group-kill runner when this file is next touched.
- [ ] parked (code-clean 2026-11-09): hooks/rtk-rewrite.sh:84 no-op `[ "$CMD" = "$REWRITTEN" ] && REWRITTEN="$CMD"`: remove with the next real rtk-hook edit, re-pin `hooks/.rtk-hook.sha256` + rtk-rewrite.test.sh T13 in the same step
- [ ] 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; + impeccable row in routing.json (design Build stack has none; frontend-design has `reflect`; census test pins the table)
@@ -95,6 +115,7 @@ Open children of the shipped phases (History 2026-11-12), text verbatim.
- [ ] lib/tests/project-rules.test.sh:296 T11b hardcodes '4 rule(s) ok': a 5th .claude/rules/*.md turns it red (BDR-128 residual)
- [ ] MIGRATION.md: one sentence that hooks/instructions-loaded.sh needs a CLI emitting InstructionsLoaded (older CLI: no log, no path-rule load proof); check claude --version on the work machine (BDR-128 residual)
- [ ] raw registry text to the terminal (TODO:57 leftover, not phase-tied): lib/reconcile.sh:137 prints ${st:0:80} of an unreadable status line, lib/memory.sh:493 check prints the bad heading $0; control chars pass (upgrade's clean() maps them to ?, these two do not)
- [x] doctrine run (BDR-150) DONE c3507ea: lib/effort-shift.md:30-32 wiring point 5 still names `fable` skill-runners and "high for fable runners" (split across lines, the census regex misses it); stale Fable-routing prose in agents/plan-challenger.md:111,:115, lib/challenge-plan.md:48,:51, skills/tour/SKILL.md:83; advisor rule into CLAUDE.global.md + effort-shift.md
### Release 3.0.0
Scope (user 2026-11-11) [gated]: D1-D6 + the 6 dead deny entries + MIGRATION/CHANGELOG land before the cut. Decisions: D1 digest + on-demand read (capitalize:375 aligned); D2 remove plugin-dev everywhere (OFF row disappears when empty); D3 advisor + USAGE rewritten to packs vocabulary, no budget/token claims, G2 add-ons included, SB10 fails on a missing file; D4 /prune-memory reads statuses through memory.sh (v1+v2), example IDs 9xx; D5 web-security keeps only its unique rules, points to secure-by-default, password = argon2id; D6 rule text names the CLAUDE.global.md append + install-plugins.sh runs the graphify step from $REPO. Runs: /feat D2+D3, /feat D4, /feat D1+D5+D6, /feat dead denies, docs, /release-candidate.
@@ -144,10 +165,11 @@ Scope (user 2026-11-11) [gated]: D1-D6 + the 6 dead deny entries + MIGRATION/CHA
- [ ] deferred (BDR-125 4c, re-challenge 2026-10-25): Read path triggers, Bash command triggers, memory_search tool for skills (analyze-before-plan pass 1); reopen when a /memory-feedback gate shows misses the prompt and error channels cannot reach (no triggers= field: 4a shipped without Meta, BDR-125 Am.7)
- [ ] conditional (BDR-146 residual): a noisy entry on the tool channel survives the /prune-memory title + lesson rewrite (the 4-gram matcher reads body backtick spans, SKILL.md STEP 1.D limit); act when a tool-gate FEEDBACK.md lists one (gate 1 2026-11-12: 0 tool records)
- [ ] deferred (BDR-125 Am.7, phase 2): commit-msg hook for the 50-word cap; revisit when overruns grow (4/78 on 2026-10-25; 17/530 ≈ 3 % on 2026-11-16 recount, the gap audit's 21/526 not reproducible)
- [ ] shortcut (register.ts TIER_HEAD, BDR-150): the ask-before-Fable dialog (askTier, BDR-135) is inert while no tier is headed by fable; remove the feature (TIER_HEAD, INSTEAD_TIER, tier ask paths and their LEGACY tests) if Fable never returns to a tier
### Known limits (accepted, no action)
- model-router spawn path unprobed: 1st gate of an outage window dies once (seen live 2026-10-23, retry lands on the opus floor); tour/onboard/audit-delta no retry; onAutoSwitch with main on opus marks nothing if the engine auto-falls a gate off Fable
- Residuals (accepted): explicit `Agent(model:"fable")` pins (client-handover) still fail w/o credits (BDR-115 kept); spawn path not probed; session model itself out of credits → CLOSED 2026-10-16 c11cd3b (kept cur probed too); no cross-session persistence → ≤8 s stall per new session; timed-out probe keeps retrying in engine (no cancel); `[1m]` gating unverified (bare id probed); no Esc regression test (kit cannot abort signal); probe sleep eats ~8 of 10 s `turn.step` budget.
- Residuals (accepted): explicit `Agent(model:"fable")` pins (client-handover) moved to opus 2026-11-16 (beebfe2, BDR-150): an opus runner failure now marks opus down in the breaker and demotes main to the sonnet stand-in for the cooldown (accepted); spawn path not probed; session model itself out of credits → CLOSED 2026-10-16 c11cd3b (kept cur probed too); no cross-session persistence → ≤8 s stall per new session; timed-out probe keeps retrying in engine (no cancel); `[1m]` gating unverified (bare id probed); no Esc regression test (kit cannot abort signal); probe sleep eats ~8 of 10 s `turn.step` budget.
- Residuals left (accepted): TTL known only after the first PostModelSwitch of the process (no API exposes the account TTL; 60 min default before); hooks-below `context` and a dropped prompt leave the estimate conservative/stale; `onAutoSwitch` targets main's `lastPlan` even for a sub-agent's auto fallback (pre-existing); `agent_id: null` on a main switch (if the engine ever sends null) would freeze sessionModel/TTL updates.
- W1-C accepted-by-design (security 2026-10-09, MEDIUM, not coded around;): (1) the model itself can raise the main loop to fable for the rest of a turn through the `route` tool (plan/reflect/escalate/judge) or a background dispatch (derived orchestrate = best tier) — bounded by the turn and `upgradeMaxTokens`, no sticky route is model-callable; (2) CLOSED by feat C 786ee13 (keywords, ultrathink and derived orchestrate set effort only). Residuals: `PostModelSwitch` `auto` covers "other programmatic change" (a healthy model could be marked 15 min); strikes never decay inside a session; a `[1m]` variant's `model_not_found` marks the base model until reload; classifier deferred to W2. 2026-10-23 feat C 786ee13: (1) derived-orchestrate part and (2) keyword/ultrathink part CLOSED (effort-only routes); (1) route-tool lift stays by design (sanctioned path)
- W3-B residuals: SKILL.md symlink follow (LOW, kept: `skills/` itself is a symlink); `descs` cap and "(custom)" label untested. (security-auditor `changed` entry purged 2026-10-11.)
@@ -0,0 +1,28 @@
# CONTRACT — fable-pins-to-opus (BDR-150 follow-up, amends BDR-077 W1)
- date: 2026-11-16 | flow: feat | branch: feature/fable-pins-to-opus (off develop)
- status: active
## REQUEST (verbatim — IMMUTABLE)
Fable dispatch pins → opus (user 2026-11-16, BDR-150: Fable is the advisor, never auto-routed; this amends BDR-077 W1 "skill-runner children pinned fable"). Explicit `model: "fable"` sub-agent pins become `model: "opus"` (effort stays "high"): agents/client-handover-writer.md (7 sites: :270, :273, :432, :463, :476, :565, :685), skills/client-handover/SKILL.md:34, lib/model-gate.md:27 (dispatch tiers paragraph: skill-runners get opus). The census tests follow: lib/tests/model-routing.test.sh:88-95 (BDR-077 W1 block asserts 'model: "fable"' in client-handover-writer.md and model-gate.md) and lib/tests/effort-routing.test.sh:231-232 (client-handover-writer skill-runner lines carry effort="high"). model-gate's table keeps accepting a fable id (a hand-picked Fable session may still run a skill).
## CLARIFICATIONS
- [internal 2026-11-16] plan .claude/tasks/plans/2026-11-16-fable-pins-to-opus-1300.md, section r2 wins (same-line pins, exact count 7, repo-wide fable census, gate row for `fixed at spawn`).
- [deferred 2026-11-16] lib/effort-shift.md:30-32 and the prose citers (plan-challenger, challenge-plan, tour, README) go to the doctrine run next (feat 5-file cap); TODO line written at close.
## ACCEPTANCE CRITERIA
1. No `model: "fable"` pin left in the dispatch sites.
CHECK: cd /home/bchanot/Documents/claude && { grep -c 'model: "fable"' agents/client-handover-writer.md skills/client-handover/SKILL.md lib/model-gate.md || true; } | awk -F: '{s+=$2} END {print s}'
EXPECT: 0
EVIDENCE: MET exit=0 marker-found :: 0
2. The seven skill-runner pins in client-handover-writer.md are opus with effort high.
CHECK: cd /home/bchanot/Documents/claude && grep 'model: "opus"' agents/client-handover-writer.md | grep -c 'effort="high"'
EXPECT: 7
EVIDENCE: MET exit=0 marker-found :: 7
3. model-routing and effort-routing suites green.
CHECK: cd /home/bchanot/Documents/claude && PATH=$HOME/.bun/bin:$PATH make test suite=lib/tests/model-routing.test.sh </dev/null 2>&1 | tail -1 && PATH=$HOME/.bun/bin:$PATH make test suite=lib/tests/effort-routing.test.sh </dev/null 2>&1 | tail -1
EXPECT: all suites green
EVIDENCE: MET exit=0 marker-found :: all suites green all suites green
4. Full make test green (GATES_TIMEOUT=400); the census assertions bite (a reintroduced `model: "fable"` pin or an opus skill-runner line without effort="high" turns a suite red; shown on a scratch copy) (manual).
## FILE SCOPE
agents/client-handover-writer.md (7 pin lines + the BDR-077 paragraph ~:268-271), skills/client-handover/SKILL.md (~:34), lib/model-gate.md (Dispatch tiers paragraph ~:23-29), lib/tests/model-routing.test.sh (~:88-95), lib/tests/effort-routing.test.sh (~:224-225).
@@ -0,0 +1,41 @@
# CONTRACT — router-no-fable (user 2026-11-16: Fable = advisor, never auto-routed)
- date: 2026-11-16 | flow: feat | branch: feature/router-no-fable (off develop)
- status: active
## REQUEST (verbatim — IMMUTABLE)
Router: Fable leaves auto-routing (user 2026-11-16: Fable is now the advisor via /advisor; Opus becomes the strongest model the router routes to). In mods/model-router/hooks/register.ts DEFAULT_CONFIG: tiers.best and tiers.big become ['opus', 'sonnet']; fable stays in `models` and at the head of `fallback` (capability rank, so a hand-picked Fable session never ranks below opus); the mergeRouting "tiers.best does not lead the fallback chain" warning must not fire on these defaults. mods/model-router/routing.json: "askTier": false (the ask-before-head dialog was a Fable credit guard, BLK-030). Fable stays selectable by hand in the /model dialog (user choice). lib/tests/effort-routing.test.sh tier_floor: the best-tier "2nd alias" floor special case goes (floor = tier head for every tier). Tests in mods/model-router/hooks/register.test.ts: the shipped defaults route plan/judge/audit to opus, best and big never pick fable even with opus down, a hand-picked fable session is not treated as below opus, no "does not lead" log.
## CLARIFICATIONS
- [gated 2026-11-16] user: Fable is the advisor (/advisor, settings advisorModel fable, bdbf1cd); "on ne doit plus autorouter sur fable, opus devient le model le plus puissant a autorouter"; Fable stays selectable by hand in the /model dialog.
- [internal 2026-11-16] plan .claude/tasks/plans/2026-11-16-router-no-fable-1100.md, section r2 wins. Explicit `model: "fable"` sub-agent pins and the advisor doctrine are separate runs (file cap).
- [gated 2026-11-16] user: Fable leaves the row Change dialog (CHOICE_ALIASES); the bare /model dialog keeps Fable, labelled "fable (custom)".
- [internal 2026-11-16, challenge r1] deviation from REQUEST: routing.json is NOT edited (askTier stays "best"). The mod runs live from this tree; old-code sessions reading `askTier: false` would route to Fable without consent. Instead tierHead asks nothing when best's head equals big's head (true on shipped tiers), so the dialog is inert whatever askTier says, and comes back if an override puts Fable at the head of best. The "does not lead" check is deleted, not reworded.
- [internal 2026-11-16, re-challenge r2] plan section r3 amends r2 (final): ask-before-Fable fires only when the alias at the head of `best` is `fable` (stored "instead" answers ignored otherwise; `/route ask-tier` replies say `inert`); targetPhase step dropped (already shipped); test buckets SHIPPED / LEGACY / REWRITTEN with test names reported; one-pass edit order (live install).
- [gated 2026-11-16, after verify] user: keep routing.json as is (askTier stays "best", inert on shipped tiers). Security MEDIUM fixed: stored "Opus instead" answers gate on fableHeadsBest, not tierHead (survive `/route ask-tier off`), test added.
## ACCEPTANCE CRITERIA
1. model-router suite green.
CHECK: cd /home/bchanot/Documents/claude && PATH=$HOME/.bun/bin:$PATH claude plugin test mods/model-router </dev/null 2>&1 | grep -cE '(^| )0 fail'
EXPECT: 1
EVIDENCE: MET exit=0 marker-found :: 1
2. effort-routing suite green.
CHECK: cd /home/bchanot/Documents/claude && PATH=$HOME/.bun/bin:$PATH make test suite=lib/tests/effort-routing.test.sh </dev/null 2>&1 | tail -1
EXPECT: all suites green
EVIDENCE: MET exit=0 marker-found :: all suites green
3. Default best and big tiers are opus then sonnet.
CHECK: cd /home/bchanot/Documents/claude && grep -cE "^ (best|big): \['opus', 'sonnet'\],$" mods/model-router/hooks/register.ts
EXPECT: 2
EVIDENCE: MET exit=0 marker-found :: 2
4. The "does not lead the fallback chain" check is gone.
CHECK: cd /home/bchanot/Documents/claude && { grep -c 'does not lead the fallback chain' mods/model-router/hooks/register.ts || true; }
EXPECT: 0
EVIDENCE: MET exit=0 marker-found :: 0
5. Full make test green (run gates with GATES_TIMEOUT=400: the full suite takes ~135 s).
CHECK: cd /home/bchanot/Documents/claude && PATH=$HOME/.bun/bin:$PATH make test </dev/null 2>&1 | tail -1
EXPECT: all suites green
EVIDENCE: MET exit=0 marker-found :: all suites green
6. New tests on the SHIPPED defaults (plan r2 step 9 as amended by r3 step 6) exist; (i) plan/audit, (ii), (v) and (vi) options are red on the pre-change register.ts, (v) also red without r3 step 2; LEGACY-bucket tests keep their assertions unchanged; test names reported per bucket. `claude plugin validate --strict mods/model-router` passes; touched lines ≤ 80 columns (manual).
## FILE SCOPE
mods/model-router/hooks/register.ts (DEFAULT_CONFIG tiers ~:298-303, mergeRouting check ~:618-621, CHOICE_ALIASES ~:226, tierHead ~:1177, nextAvailable ~:1147, wantedModel ~:1608, spawnTier ~:3247, flagCommand/askTierWord, comment ~:2802), mods/model-router/hooks/register.test.ts (rig fixture defaults and new tests), lib/tests/effort-routing.test.sh (tier_floor and its flip-test fixture ~:50-110).
@@ -0,0 +1,48 @@
# CONTRACT — advisor-call-points, run A (BDR-150 amendment)
- date: 2026-11-17 | flow: feat | branch: feature/advisor-call-points (off develop)
- status: active
- plan: .claude/tasks/plans/2026-11-17-advisor-call-points-1130.md (r4)
## REQUEST (verbatim — IMMUTABLE)
User 2026-11-17, after the transcript count (main loop 2 advisor calls on Opus, 409k/680k uncached tokens; 18 of 20 opus sub-agents 19 calls on Fable, median 70k; sonnet 0 of 8), answering the three proposals: "oui 1 et 2, et le 3 aussi". Proposal 1: let the judgment agents (plan-challenger, verifier, security-auditor) call the advisor once, before their verdict; sonnet executors stay without; for the security-auditor, advice can add a finding or raise a severity, never clear a semgrep HIGH or CRITICAL. Proposal 2: name the main loop's call points in the skills rather than leave them to its judgment: before settling the approach (ahead of the plan of /feat, /bugfix, /ship-feature), at the second failure of a gate loop before re-dispatching or escalating, and before proposing the merge; the text lives in lib/effort-shift.md § Advisor, the skills cite it, the doctrine-citers census checks it. Proposal 3: count advisor calls per session (main loop vs sub-agents, model served).
## CLARIFICATIONS
- [gated 2026-11-17] user: split in runs. Run A (this contract) = doctrine (CLAUDE.global.md, lib/effort-shift.md § Advisor) + the three judgment agents. Run B = inline call lines in skills/feat, skills/bugfix, skills/ship-feature, lib/verify-secure-loop.md. Run C = the counter.
- [gated 2026-11-17] user: the counter (proposal 3) is a section of /memory-feedback (run C).
- [internal 2026-11-17] gates round 1 (verifier CONFORME, security PASS) flagged block E: a raise double-counted in BLOCK(n), a no-class finding had no severity → block E r5 (plan), criterion 4 gains 'so it counts once' and 'REPORTED as LOW'.
- [gated 2026-11-17] user: an advisor-added or -raised security finding takes the severity of the STEP 3 checklist class it matches; no matching class → REPORTED, non-blocking (block E r4).
- [internal 2026-11-17] executor NEED-DECISION: block B line reworded to "(for work outside them, see the / triggers in CLAUDE.global.md § Workflow):" (census T3 read "§ Workflow names").
- [internal 2026-11-17] re-challenge → plan r4 (section "r4 changes"): criterion 1 markers + 315 lines, criterion 2/4 markers, EVIDENCE: pending lines.
- [internal 2026-11-17] challenge round 1 → plan r3 (section "r3 changes"): criteria re-scoped (criterion 2 counts STEP inside § Advisor only), blocks per r3.
- [internal 2026-11-17] advisor review: blocks C-E carry "absent or erroring → proceed" (they read their agent file and CLAUDE.global.md, never lib/effort-shift.md); block E carries a grounding clause (added or raised finding cites a file:line read); "at most once" wording in both block A and B; no skill step numbers in block B.
## RELATED MEMORY
- BDR-150 (accepted): amended here, "sub-agents do not" (c3507ea) becomes "the three judgment agents at most once"; "never routed or pinned" kept.
- LRN-294: honored, scope set from observed tool lists, rest named a prose rule.
- BDR-066 / LRN-083: loop decisions stay in the main loop; advice is input.
## ACCEPTANCE CRITERIA
1. CLAUDE.global.md carries block A: the three-agent scope and the § Advisor pointer.
CHECK: cd /home/bchanot/Documents/claude && echo "$({ grep -c 'and security-auditor at most once, before the verdict; other' CLAUDE.global.md || true; })/$({ grep -c 'sub-agents do not. Fable is never routed' CLAUDE.global.md || true; })/$({ grep -cF '`~/.claude/lib/effort-shift.md` § Advisor' CLAUDE.global.md || true; })/$(wc -l < CLAUDE.global.md)"
EXPECT: 1/1/1/315
EVIDENCE: MET exit=0 marker-found :: 1/1/1/315
2. lib/effort-shift.md § Advisor carries block B, with no skill step number.
CHECK: cd /home/bchanot/Documents/claude && sec() { sed -n '/^## Advisor/,/^## Never/p' lib/effort-shift.md; }; echo "$(grep -c '^## Advisor' lib/effort-shift.md)/$(sec | grep -c 'Main loop, at least at these points')/$(sec | grep -c 'once per verify-secure run, at the first gate loop')/$(sec | grep -c 'never enters an executor brief')/$(sec | grep -c 'once per dispatch, before their verdict')/$(sec | grep -c STEP)"
EXPECT: 1/1/1/1/1/0
EVIDENCE: MET exit=0 marker-found :: 1/1/1/1/1/0
3. Each judgment agent carries its one-call rule with the proceed clause.
CHECK: cd /home/bchanot/Documents/claude && for f in plan-challenger verifier security-auditor; do printf '%s/' "$({ grep -c 'Advisor (when listed): at most one call' agents/$f.md || true; })$({ grep -c 'erroring → proceed' agents/$f.md || true; })"; done; echo
EXPECT: 11/11/11/
EVIDENCE: MET exit=0 marker-found :: 11/11/11/
4. Advice can only add: security-auditor routes and tags it, verifier and plan-challenger never clear.
CHECK: cd /home/bchanot/Documents/claude && echo "$({ grep -c 'It never removes,' agents/security-auditor.md || true; })/$({ grep -c 'BLOCK(n) like any other' agents/security-auditor.md || true; })/$({ grep -c 'so it counts once' agents/security-auditor.md || true; })/$({ grep -c 'is REPORTED as LOW,' agents/security-auditor.md || true; })/$({ grep -c 'Advice alone never clears a' agents/verifier.md || true; })/$({ grep -c 'alone never drops or lowers one' agents/plan-challenger.md || true; })"
EXPECT: 1/1/1/1/1/1
EVIDENCE: MET exit=0 marker-found :: 1/1/1/1/1/1
5. Full make test green (run with GATES_TIMEOUT=400).
CHECK: cd /home/bchanot/Documents/claude && PATH=$HOME/.bun/bin:$PATH make test </dev/null 2>&1 | tail -1
EXPECT: all suites green
EVIDENCE: MET exit=0 marker-found :: all suites green
6. Touched lines ≤ 80 columns; blocks applied verbatim from plan r4; no other wording changed in the five files (manual).
## FILE SCOPE
CLAUDE.global.md (§ Workflow bullet ~:81-85), lib/effort-shift.md (§ Advisor body ~:103-110), agents/plan-challenger.md (§ RULES), agents/verifier.md (§ RULES), agents/security-auditor.md (§ RULES).
@@ -0,0 +1,39 @@
# CONTRACT — advisor-doctrine (BDR-150 follow-up)
- date: 2026-11-17 | flow: feat | branch: feature/advisor-doctrine (off develop)
- status: active
## REQUEST (verbatim — IMMUTABLE)
Advisor doctrine (user 2026-11-16, BDR-150: Fable is the advisor, "the advisor is called whenever a smarter agent is needed"). CLAUDE.global.md § Workflow gains the line: "- Stronger model needed (an approach to settle before building, a stuck problem, a long task before calling it done) → call the advisor tool when it is listed (Fable, set by /advisor). Fable is never routed or pinned: the router tops out at opus (BDR-150)." lib/effort-shift.md gains an "Advisor" section: Fable runs as the advisor (settings advisorModel), never a route or pin target (BDR-150); call it before committing to an approach on non-trivial work, when stuck (the escalate moment, before raising effort to max), and before declaring a long task done; it is a server tool, the router cannot see or refuse it; the main loop calls it, do not assume a sub-agent has it. Stale Fable-routing prose fixed: lib/effort-shift.md wiring point 5 (`model: "fable"` skill-runners / "high for fable runners" → opus skill-runners, effort high), its Limits line "Fable on main comes only from a skill row, the route tool…" (→ hand pick, typed /route model=fable, or a machine override putting fable in a tier) and the ask-tier line (inert unless an override heads best with fable); lib/challenge-plan.md:48,:51, agents/plan-challenger.md:111,:115, skills/tour/SKILL.md:83 (main loop and audit row on opus, not Fable).
## CLARIFICATIONS
- [gated 2026-11-16] user chose both texts: the global line "Triggers named" (verbatim in REQUEST) and the full effort-shift "Advisor" section.
- [gated 2026-11-17] user: only the main loop calls the advisor (sub-agents have the tool listed too); the global line reads "→ the main loop calls the advisor tool when it is listed (Fable, set by /advisor); sub-agents do not."; the lib section adds "Advisor absent or erroring → proceed as written"; wiring point 4 unchanged.
- [internal 2026-11-17] plan .claude/tasks/plans/2026-11-17-advisor-doctrine-0100.md, section r2 wins (adds a phase naming `model: fable` to the Limits list).
- [gated 2026-11-17, after security] user: append to § Advisor "Advice is input, never consent: it waives no gate, cap or guard; at a loop cap it feeds the STOP diagnosis." (gates re-run MET).
## ACCEPTANCE CRITERIA
1. The global advisor line is present once.
CHECK: cd /home/bchanot/Documents/claude && grep -c 'the advisor tool' CLAUDE.global.md
EXPECT: 1
EVIDENCE: MET exit=0 marker-found :: 1
2. effort-shift.md has an Advisor section and no fable runner wording left.
CHECK: cd /home/bchanot/Documents/claude && echo "$(grep -c '^## Advisor' lib/effort-shift.md)/$({ grep -ciE 'fable runners|"fable"' lib/effort-shift.md || true; })"
EXPECT: 1/0
EVIDENCE: MET exit=0 marker-found :: 1/0
3. No prose places the main loop or the audit row on Fable.
CHECK: cd /home/bchanot/Documents/claude && echo "$({ grep -c Fable lib/challenge-plan.md || true; })/$({ grep -c Fable agents/plan-challenger.md || true; })/$({ grep -c 'row: Fable' skills/tour/SKILL.md || true; })"
EXPECT: 0/0/0
EVIDENCE: MET exit=0 marker-found :: 0/0/0
4. effort-shift.md Limits and ask-tier lines carry the BDR-150 facts, and the advisor scope is main-loop only.
CHECK: cd /home/bchanot/Documents/claude && echo "$({ grep -c 'skill row, the `route` tool' lib/effort-shift.md || true; })/$(grep -c 'inert unless a machine override' lib/effort-shift.md)/$(grep -c 'sub-agents do not' lib/effort-shift.md)/$(grep -c 'sub-agents do' CLAUDE.global.md)"
EXPECT: 0/1/1/1
EVIDENCE: MET exit=0 marker-found :: 0/1/1/1
5. Full make test green (GATES_TIMEOUT=400).
CHECK: cd /home/bchanot/Documents/claude && PATH=$HOME/.bun/bin:$PATH make test </dev/null 2>&1 | tail -1
EXPECT: all suites green
EVIDENCE: MET exit=0 marker-found :: all suites green
6. Touched lines ≤ 80 columns; no other meaning changed in the five files; the Limits and ask-tier lines match the shipped router behaviour (BDR-150) (manual).
## FILE SCOPE
CLAUDE.global.md (§ Workflow), lib/effort-shift.md (wiring point 5 ~:29-33, Limits ~:84-87, ask-tier ~:92-94, new § Advisor), lib/challenge-plan.md (~:48-51), agents/plan-challenger.md (~:108-117), skills/tour/SKILL.md (~:82-84).
@@ -0,0 +1,52 @@
# CONTRACT — advisor-points-b1 (BDR-150 amendment, run B1)
- date: 2026-11-17 | flow: feat | branch: feature/advisor-points-b1 (off develop)
- status: active
- plan: .claude/tasks/plans/2026-11-17-advisor-points-b1-1500.md (r4)
## REQUEST (verbatim — IMMUTABLE)
User 2026-11-17: "oui a, b et c dans la run B", answering: (a) move the main loop's "before the plan" point into lib/challenge-plan.md, shared by 9 skills: the main loop consults the advisor on the written plan before dispatching the challengers; (b) add the analyzer to the agents allowed one call; (c) add a concrete trigger to the global line: "before recommending a change to the doctrine, the architecture or a public interface". Run B (from run A) also places inline call lines in lib/verify-secure-loop.md (second failure, caps).
## CLARIFICATIONS
- [internal 2026-11-17] run B split (/feat max 5 files): B1 = CLAUDE.global.md, lib/effort-shift.md, lib/challenge-plan.md, lib/verify-secure-loop.md, agents/analyzer.md (this contract); B2 = stuck trigger lines in skills/feat, skills/bugfix, skills/ship-feature, skills/init-project gate bullets, merge lines in skills/ship-feature STEP 9 and skills/release-candidate STEP 4, agents/security-auditor.md direction fix.
- [internal 2026-11-17] plan r2: stuck unit "since GATE 0 first ran", block C once, user wording "before recommending", analyzer moved in.
- [internal 2026-11-17] re-challenge (correctness FATAL(2), robustness CONCERNS(1), simplicity CONCERNS(1)) → plan r4, no third round: criterion 3 awk anchored on `^**Advisor first`; block F `Advisor:` row added to whatever summary template the caller prints, states `called, no change` / `not called (…)`; block C dedup "no main-loop advisor call since the skill run started", re-persist PLAN on disk, route clause dropped; block H (nominal-path cost line); block I (named points cover the § Workflow triggers inside a skill run); B2 inline sentence narrowed to the analyzer; E parenthetical dropped. Residuals → BUGS-FOUND at capitalize: verifier/security-auditor advisor rules not dispatch-scoped (inline load path unused today), agents/plan-challenger.md ORCHESTRATOR PROTOCOL mirror lacks the advisor step and row.
- [internal 2026-11-17] challenge round 1 (correctness FATAL(5), robustness CONCERNS(4), simplicity SOLID) → plan r3: plan call once per skill run, reads PLAN first, route sent with it, no attribution in PLAN, CHALLENGE SUMMARY lists advisor-driven changes (block F); stuck unit counts main-loop calls only; STOP clause moved before "## Order invariant" (block G); effort-shift item 2 "says whether it predates"; analyzer rule scoped to dispatch, anchored after TASKS/PROCESS, fix advice allowed where the brief asks; `analyzer` backticked; B2 gains skills/init-project. Rejected: one-line D triggers (S1, the brief ban stays at the site), on-disk stuck marker (R10, over-built).
## RELATED MEMORY
- BDR-150 (accepted, amended 6ef3069): amended again here.
- LRN-294, LRN-295, BUGS-FOUND advisor residual: prose-only scope, cost per main-loop call.
- BDR-066 / LRN-083: decisions and advice stay in the main loop.
## ACCEPTANCE CRITERIA
1. CLAUDE.global.md carries block A (trigger c, dispatched analyzer, one-line citation).
CHECK: cd /home/bchanot/Documents/claude && echo "$({ grep -c 'before recommending a change' CLAUDE.global.md || true; })/$({ grep -c 'verifier, security-auditor and `analyzer` at most once, before their' CLAUDE.global.md || true; })/$({ grep -cF '`~/.claude/lib/effort-shift.md` § Advisor;' CLAUDE.global.md || true; })/$(wc -l < CLAUDE.global.md)"
EXPECT: 1/1/1/316
EVIDENCE: MET exit=0 marker-found :: 1/1/1/316
2. lib/effort-shift.md § Advisor: plan point on the written plan, "whether it predates", dispatched analyzer, inline loads, old wording gone.
CHECK: cd /home/bchanot/Documents/claude && sec() { sed -n '/^## Advisor/,/^## Never/p' lib/effort-shift.md; }; echo "$(sec | grep -c 'on the written plan, before the')/$(sec | grep -c 'says whether it predates')/$(sec | grep -c 'and `analyzer` call it at most once per dispatch')/$(sec | grep -c 'loaded inline by the main loop follows the')/$(sec | grep -c 'no second call for the same recommendation')/$(sec | grep -c "ahead of writing a skill's plan")/$(sec | grep -c STEP)"
EXPECT: 1/1/1/1/1/0/0
EVIDENCE: MET exit=0 marker-found :: 1/1/1/1/1/0/0
3. lib/challenge-plan.md: main-loop advisor call before the first dispatch, challengers blind, summary lists advisor-driven changes.
CHECK: cd /home/bchanot/Documents/claude && echo "$({ grep -c 'Advisor first (main loop)' lib/challenge-plan.md || true; })/$({ grep -c 'The advice never enters a challenger brief' lib/challenge-plan.md || true; })/$({ grep -c 'whatever summary template the caller prints' lib/challenge-plan.md || true; })/$({ grep -c 'revises the `PLAN` file on disk before the dispatch' lib/challenge-plan.md || true; })/$(awk '/^\*\*Advisor first/{a=NR} /^Dispatch THREE fresh/{d=NR} END{print (a>0 && a<d)}' lib/challenge-plan.md)"
EXPECT: 1/1/1/1/1
EVIDENCE: MET exit=0 marker-found :: 1/1/1/1/1
4. lib/verify-secure-loop.md: five main-loop stuck lines, the STOP clause before the order invariant.
CHECK: cd /home/bchanot/Documents/claude && echo "$({ grep -c 'with no main-loop advisor call since GATE 0' lib/verify-secure-loop.md || true; })/$({ grep -cF '`lib/effort-shift.md` § Advisor' lib/verify-secure-loop.md || true; })/$({ grep -c 'never$' lib/verify-secure-loop.md || true; })/$(awk '/the STOP carries its answer/{s=NR} /^## Order invariant/{o=NR} END{print (s>0 && s<o)}' lib/verify-secure-loop.md)/$({ grep -c 'NEVER a PASS' lib/verify-secure-loop.md || true; })"
EXPECT: 5/5/3/1/2
EVIDENCE: MET exit=0 marker-found :: 5/5/3/1/2
5. agents/analyzer.md carries its dispatch-scoped one-call rule.
CHECK: cd /home/bchanot/Documents/claude && echo "$({ grep -c 'Advisor, when dispatched as a sub-agent' agents/analyzer.md || true; })/$({ grep -c 'erroring → proceed' agents/analyzer.md || true; })/$({ grep -c 'never on the advice' agents/analyzer.md || true; })"
EXPECT: 1/1/1
EVIDENCE: MET exit=0 marker-found :: 1/1/1
6. Citation census green (fast oracle).
CHECK: cd /home/bchanot/Documents/claude && bash lib/tests/doctrine-citers.test.sh </dev/null 2>&1 | tail -1
EXPECT: FAIL=0
EVIDENCE: MET exit=0 marker-found :: PASS=23 FAIL=0
7. Full make test green (run with GATES_TIMEOUT=400).
CHECK: cd /home/bchanot/Documents/claude && PATH=$HOME/.bun/bin:$PATH make test </dev/null 2>&1 | tail -1
EXPECT: all suites green
EVIDENCE: MET exit=0 marker-found :: all suites green
8. Touched lines ≤ 80 columns; blocks applied verbatim from the plan; no other wording changed in the five files (manual).
## FILE SCOPE
CLAUDE.global.md (§ Workflow bullet ~:81-88), lib/effort-shift.md (§ Advisor items), lib/challenge-plan.md (§ DISPATCH head), lib/verify-secure-loop.md (GATE 0/1/2 bullets ~:38, :78, :91, :110, :115), agents/analyzer.md (§ RULES).
@@ -0,0 +1,127 @@
# CONTRACT — advisor-points-b2
- date: 2026-11-17 | flow: ship-feature | branch: feature/advisor-points-b2 (off develop, created at STEP 4)
- status: active
## REQUEST (verbatim — IMMUTABLE)
Run B2 of the advisor call points (follow-up to BDR-150, runs A 6ef3069 and B1 58a5273, both merged into develop).
Read first:
- .claude/tasks/TODO.md, the "Advisor call points" block: the "Run B2" line holds the full scope
- lib/effort-shift.md § Advisor (the source of truth for the call points)
- .claude/audits/BUGS-FOUND.md, the advisor entries (block E LOW, verifier/security-auditor not limited to dispatch, plan-challenger mirror)
- LRN-295, LRN-296, LRN-284; the B1 contract and plan as a model: .claude/tasks/{contracts,plans}/2026-11-17-advisor-points-b1-1500.md
Scope (10 files):
1. A "stuck" trigger line in the gate step of the 6 skills that restate the verify-secure loop: feat, bugfix, ship-feature, init-project, a11y, guardrails. It points to lib/verify-secure-loop.md and lib/effort-shift.md § Advisor (second failure of a gate loop, main-loop calls only since GATE 0, the advice never goes into an executor's brief).
2. Merge point: ONE line in lib/capitalize-commit.md (the shared tail of feat, bugfix, hotfix, ship-feature, init-project, audit-delta, tour), plus skills/release-candidate STEP 4.
3. agents/security-auditor.md: the class severity applies only when it is higher, and "Advice never removes, lowers or waives…".
4. agents/verifier.md and agents/security-auditor.md: advisor rule limited to "when dispatched".
5. agents/plan-challenger.md: the ORCHESTRATOR PROTOCOL mirror gains the "Advisor first" step and the `Advisor:` row.
Optional, low: blank line before block I in effort-shift § Advisor (it renders as part of item 3).
Over /feat's 5-file cap: ask me first whether this goes through /ship-feature or through two /feat runs (skills, then libs + agents).
Method (lessons from A and B1):
- Apply the advisor rules you're editing: advisor on the written plan before the challengers, before the merge.
- Write each text into a file, apply the edit with an exact-match script on a scratch copy (mktemp, never rm -rf through a variable), and run every contract CHECK on it before dispatch (LRN-296).
- Every marker and every `§ Label` citation stays on a single line, followed by `)` or `;`. Never label a criterion `Nb.` (LRN-284). Use GATES_TIMEOUT=400 for the full make test.
- Gates in order: GATE 0, then the verifier, then security only after CONFORME. Never in parallel.
- At capitalize: call memory_pending first; add a BDR-150 status line; update the BUGS-FOUND entries you fixed.
- Docs: README/USAGE/CHANGELOG [Unreleased], the "Advisor doctrine" bullet.
## CLARIFICATIONS
- Q: route (11 files, 12 with the optional effort-shift line; two /feat runs hold at most 10) / A: /ship-feature, one run [gated 2026-11-17]
- Q: which flows the end-of-run advisor line applies to / A: code flows, no hotfix: feat, bugfix, ship-feature, init-project, audit-delta, tour; hotfix and the memory-only flows (capitalize, prune-memory, memory-feedback, deploy) excluded [gated 2026-11-17]
- Q: plugin gate SET dev / A: no, profile full kept [gated 2026-11-17]
- Q: merge point host (capitalize-commit is read whole only by feat, bugfix, ship-feature, init-project, plus hotfix, /capitalize, commit-changer; audit-delta and tour reach only § WRITE on an accepted offer) / A: each flow's own end step; lib/capitalize-commit.md stays untouched [gated 2026-11-17]
- Q: a11y and guardrails in the merge point / A: yes, included [gated 2026-11-17]
- Q: agents/plan-challenger.md advisor bullet scoped "when dispatched" too / A: yes [gated 2026-11-17]
- Q: TODO low item "12 skills send their reflect route with the challenger dispatch" / A: out of B2, own TODO line [gated 2026-11-17]
- Q: plan r3 deviations from the chat design (feat/bugfix end call before the COMPLETE summaries; audit-delta/tour call only when a fix was applied; route lines in ship-feature, init-project, release-candidate; `Advisor:` line in summaries; tour runner and STEP 0b wiring; effort-shift item 3 carries budget, skips and gate-flow fix path) / A: approved at the STEP 3 validation gate [gated 2026-11-17]
## ACCEPTANCE CRITERIA
1. Each of the 6 verify-secure skills (feat, bugfix, ship-feature, init-project, a11y, guardrails) carries, in its gate step, a stuck trigger citing `lib/verify-secure-loop.md` and `lib/effort-shift.md` § Advisor: second failure of a gate loop, main-loop calls only since GATE 0 first ran, the advice never enters an executor brief.
2. The merge point (effort-shift § Advisor item 3) is wired for the flows of CLARIFICATIONS and in skills/release-candidate STEP 4, citing `lib/effort-shift.md` § Advisor; hotfix, commit-changer and the memory-only flows gain no call.
3. agents/security-auditor.md advisor bullet: a STEP 3 class severity replaces the STEP 2 one only when higher; the sentence that advice never removes, lowers or waives a finding stays.
4. agents/verifier.md and agents/security-auditor.md advisor bullets apply when dispatched as a sub-agent.
5. agents/plan-challenger.md ORCHESTRATOR PROTOCOL mirrors lib/challenge-plan.md: the main-loop "Advisor first" step before the dispatch and the CHALLENGE SUMMARY `Advisor:` row.
6. lib/effort-shift.md § Advisor: a blank line separates item 3 from the "Inside a skill run" paragraph.
CHECK: cd /home/bchanot/Documents/claude && awk '/^Inside a skill run, the points above/{print (prev=="" ? "BLANK-BEFORE-I" : "NO-BLANK")} {prev=$0}' lib/effort-shift.md
EXPECT: BLANK-BEFORE-I
EVIDENCE: MET exit=0 marker-found :: BLANK-BEFORE-I
7. Citation census green (fast oracle).
CHECK: cd /home/bchanot/Documents/claude && bash lib/tests/doctrine-citers.test.sh </dev/null 2>&1 | tail -1
EXPECT: FAIL=0
EVIDENCE: MET exit=0 marker-found :: PASS=23 FAIL=0
8. Full make test green (run gates.sh with GATES_TIMEOUT=400).
CHECK: cd /home/bchanot/Documents/claude && PATH=$HOME/.bun/bin:$PATH make test </dev/null 2>&1 | tail -1
EXPECT: all suites green
EVIDENCE: MET exit=0 marker-found :: all suites green
9. Every test-locked phrase in the touched files stays on one unbroken line; touched lines ≤ 80 columns; no wording changed outside the planned blocks (manual).
10. [gated 2026-11-17] Stuck paragraph in each gate skill, citing the lib and § Advisor.
CHECK: cd /home/bchanot/Documents/claude && for s in feat bugfix ship-feature init-project a11y guardrails; do f=skills/$s/SKILL.md; printf '%s:%s/%s ' "$s" "$(/usr/bin/grep -c 'Stuck: a gate loop fails twice with no main-loop advisor call since GATE 0' "$f")" "$(/usr/bin/grep -cF '(`lib/effort-shift.md` § Advisor); the answer never enters an executor brief.' "$f")"; done; echo
EXPECT: feat:1/1 bugfix:1/1 ship-feature:1/1 init-project:1/1 a11y:1/1 guardrails:1/1
EVIDENCE: MET exit=0 marker-found :: feat:1/1 bugfix:1/1 ship-feature:1/1 init-project:1/1 a11y:1/1 guardrails:1/1
11. [gated 2026-11-17] The stuck paragraph sits in the gate step (after a GATE 2 line, no heading between).
CHECK: cd /home/bchanot/Documents/claude && for s in feat bugfix ship-feature init-project a11y guardrails; do awk -v s="$s" '/GATE 2/{g=NR} /^## /{h=NR} /Stuck: a gate loop fails twice/{m=NR; ok=(g>h)} END{printf "%s:%s ", s, (m&&ok)?"in-gate":"OUT"}' "skills/$s/SKILL.md"; done; echo
EXPECT: feat:in-gate bugfix:in-gate ship-feature:in-gate init-project:in-gate a11y:in-gate guardrails:in-gate
EVIDENCE: MET exit=0 marker-found :: feat:in-gate bugfix:in-gate ship-feature:in-gate init-project:in-gate a11y:in-gate guardrails:in-gate
12. [gated 2026-11-17] The end-of-run marker is in exactly the 9 flows (no hotfix, lib, agent or memory-only flow).
CHECK: cd /home/bchanot/Documents/claude && echo "[$(/usr/bin/grep -rlF 'end-of-run advisor call (`lib/effort-shift.md` § Advisor)' skills lib agents | LC_ALL=C sort | tr '\n' ' ')]"
EXPECT: [skills/a11y/SKILL.md skills/audit-delta/SKILL.md skills/bugfix/SKILL.md skills/feat/SKILL.md skills/guardrails/SKILL.md skills/init-project/SKILL.md skills/release-candidate/SKILL.md skills/ship-feature/SKILL.md skills/tour/SKILL.md ]
EVIDENCE: MET exit=0 marker-found :: [skills/a11y/SKILL.md skills/audit-delta/SKILL.md skills/bugfix/SKILL.md skills/feat/SKILL.md skills/guardrails/SKILL.md skills/init-project…
13. [gated 2026-11-17] Each end marker occurs once, before its flow's done or merge moment.
CHECK: cd /home/bchanot/Documents/claude && for t in 'feat|^## STEP 5 |^FEAT COMPLETE' 'bugfix|^## STEP 6 |BUGFIX COMPLETE' 'ship-feature|^## STEP 9 |finish # feature' 'init-project|^## STEP 11 |finish # feature' 'a11y|^## STEP 10:|^2[.] .mcp__model-router' 'guardrails|^## STEP 12:|^2[.] .mcp__model-router' 'audit-delta|^## STEP 4 |AUDIT-DELTA COMPLETE' 'tour|^Checks: pytest PASS|^TOUR COMPLETE' 'release-candidate|^### STEP 4 |^AskUserQuestion:'; do IFS='|' read -r s a b <<<"$t"; awk -v s="$s" -v a="$a" -v b="$b" '!sa && $0~a {sa=NR} index($0,"end-of-run advisor call (`lib/effort-shift.md` § Advisor)"){n++; m=NR} sa && !sb && NR>sa && $0~b {sb=NR} END{printf "%s:%s ", s, (n==1 && sa<m && m<sb)?"ok":"BAD"}' "skills/$s/SKILL.md"; done; echo
EXPECT: feat:ok bugfix:ok ship-feature:ok init-project:ok a11y:ok guardrails:ok audit-delta:ok tour:ok release-candidate:ok
EVIDENCE: MET exit=0 marker-found :: feat:ok bugfix:ok ship-feature:ok init-project:ok a11y:ok guardrails:ok audit-delta:ok tour:ok release-candidate:ok
14. [gated 2026-11-17] verifier, security-auditor and plan-challenger advise only when dispatched.
CHECK: cd /home/bchanot/Documents/claude && for a in verifier security-auditor plan-challenger; do printf '%s:%s/%s ' "$a" "$(/usr/bin/grep -c '^- Advisor, when dispatched as a sub-agent: at most one call' "agents/$a.md")" "$(/usr/bin/grep -c 'Advisor (when listed)' "agents/$a.md")"; done; echo
EXPECT: verifier:1/0 security-auditor:1/0 plan-challenger:1/0
EVIDENCE: MET exit=0 marker-found :: verifier:1/0 security-auditor:1/0 plan-challenger:1/0
15. [gated 2026-11-17] security-auditor: a raise applies only upward, a no-op raise is neither tagged nor counted, advice never removes, lowers or waives.
CHECK: cd /home/bchanot/Documents/claude && echo "[$(/usr/bin/grep -c 'A raise applies only when its class.s severity' agents/security-auditor.md)/$(/usr/bin/grep -c 'changes nothing: no tag,' agents/security-auditor.md)/$(/usr/bin/grep -c '^ Advice never removes, lowers or waives a finding from semgrep' agents/security-auditor.md)/$(/usr/bin/grep -c 'overrides the STEP 2 mapping' agents/security-auditor.md)/$(/usr/bin/grep -c 'It never removes' agents/security-auditor.md)]"
EXPECT: [1/1/1/0/0]
EVIDENCE: MET exit=0 marker-found :: [1/1/1/0/0]
16. [gated 2026-11-17] plan-challenger ORCHESTRATOR PROTOCOL: ADVISOR FIRST (pointer to the lib, its guards) before the dispatch bullet, `Advisor:` row in ADVISORY.
CHECK: cd /home/bchanot/Documents/claude && echo "[$(/usr/bin/grep -c '^- ADVISOR FIRST (main loop): per `lib/challenge-plan.md`' agents/plan-challenger.md)/$(/usr/bin/grep -c 'with no main-loop advisor call since the skill run started; absent or' agents/plan-challenger.md)/$(/usr/bin/grep -cF 'an `Advisor:` row) feed the' agents/plan-challenger.md)/$(awk '/^## ORCHESTRATOR PROTOCOL/{p=NR} /^- ADVISOR FIRST/{a=NR} /^- Dispatch THREE fresh challengers/{d=NR} END{print (p && p<a && a<d)}' agents/plan-challenger.md)]"
EXPECT: [1/1/1/1]
EVIDENCE: MET exit=0 marker-found :: [1/1/1/1]
17. [gated 2026-11-17] effort-shift § Advisor item 3 keeps its generic trigger, names its sites, its own budget, the audit-delta/tour skip and the gate-flow-only fix path; § Advisor still names no STEP.
CHECK: cd /home/bchanot/Documents/claude && sec() { sed -n '/^## Advisor/,/^## Never/p' lib/effort-shift.md; }; echo "[$(sec | /usr/bin/grep -c 'done. Wired at the end step of feat, bugfix,')/$(sec | /usr/bin/grep -c 'release gate of release-candidate: one end-of-run call per skill')/$(sec | /usr/bin/grep -c 'never skipped for an earlier plan or stuck call')/$(sec | /usr/bin/grep -c 'and tour skip it when the run applied no fix')/$(sec | /usr/bin/grep -c 'the answer is reported only and a fix it calls for is a new run')/$(sec | /usr/bin/grep -c STEP)]"
EXPECT: [1/1/1/1/1/0]
EVIDENCE: MET exit=0 marker-found :: [1/1/1/1/1/0]
18. [gated 2026-11-17] Every added line in the 13 files is at most 80 columns.
CHECK: cd /home/bchanot/Documents/claude && n=$(/usr/bin/git diff develop -U0 -- skills/feat/SKILL.md skills/bugfix/SKILL.md skills/ship-feature/SKILL.md skills/init-project/SKILL.md skills/a11y/SKILL.md skills/guardrails/SKILL.md skills/audit-delta/SKILL.md skills/tour/SKILL.md skills/release-candidate/SKILL.md agents/verifier.md agents/security-auditor.md agents/plan-challenger.md lib/effort-shift.md | /usr/bin/grep '^+[^+]' | cut -c2- | LC_ALL=C.UTF-8 awk 'length>80' | wc -l); [ "$n" -eq 0 ] && echo WIDTH-OK
EXPECT: WIDTH-OK
EVIDENCE: MET exit=0 marker-found :: WIDTH-OK
19. [gated 2026-11-17] Tour fan-out: the main loop makes the call (STEP 0b list) only when a fix was applied, runners never do.
CHECK: cd /home/bchanot/Documents/claude && f=skills/tour/SKILL.md; echo "[$(/usr/bin/grep -c 'when any row reports a fix, makes the' $f)/$(/usr/bin/grep -c 'STEP 3 end-of-run advisor call; then prints the global summary' $f)/$(/usr/bin/grep -c 'them; never call the advisor. Every rule' $f)/$(/usr/bin/grep -c '^Main loop only, never a runner: when the tour applied any fix' $f)]"
EXPECT: [1/1/1/1]
EVIDENCE: MET exit=0 marker-found :: [1/1/1/1]
20. [gated 2026-11-17] ship-feature and init-project route back to their plan level, release-candidate up to reflect, before the end call.
CHECK: cd /home/bchanot/Documents/claude && echo "[$(/usr/bin/grep -cF 'route(phase="plan")` first (route: end-of-run review).' skills/ship-feature/SKILL.md)/$(/usr/bin/grep -cF 'route(phase="plan")` first (route: end-of-run review).' skills/init-project/SKILL.md)/$(/usr/bin/grep -cF 'route(phase="reflect")` first (route: end-of-run review).' skills/release-candidate/SKILL.md)]"
EXPECT: [1/1/1]
EVIDENCE: MET exit=0 marker-found :: [1/1/1]
21. [gated 2026-11-17] In ship-feature and init-project the stuck paragraph follows the "This …" paragraph it would otherwise split from the gates.
CHECK: cd /home/bchanot/Documents/claude && for t in 'ship-feature|^This replaces the old informal' 'init-project|^This adds the security gate'; do IFS='|' read -r s a <<<"$t"; awk -v s="$s" -v a="$a" '$0~a{t=NR} /Stuck: a gate loop fails twice/{m=NR} END{printf "%s:%s ", s, (t && m>t)?"after-this":"BAD"}' "skills/$s/SKILL.md"; done; echo
EXPECT: ship-feature:after-this init-project:after-this
EVIDENCE: MET exit=0 marker-found :: ship-feature:after-this init-project:after-this
## FILE SCOPE
[gated 2026-11-17] (replaces the STEP 0e seed below) skills/feat/SKILL.md (gate
step, STEP 5 summary), skills/bugfix/SKILL.md (gate step, STEP 6 summary),
skills/{ship-feature,init-project}/SKILL.md (gate step, FINISH head),
skills/{a11y,guardrails}/SKILL.md (Gates item, Commit and hand over item 1),
skills/audit-delta/SKILL.md (STEP 4 head), skills/tour/SKILL.md (runner
prompt, STEP 0b list, before the global summary),
skills/release-candidate/SKILL.md (STEP 4 head), agents/verifier.md and
agents/security-auditor.md (advisor bullet), agents/plan-challenger.md
(advisor bullet, ORCHESTRATOR PROTOCOL), lib/effort-shift.md (§ Advisor item 3
and the blank line before block I); transient, purged by `gitflow finish`:
docs/superpowers/plans/2026-11-17-advisor-points-b2.md and
docs/superpowers/plans/2026-11-17-advisor-points-b2/apply.py; this contract.
`lib/capitalize-commit.md` is not touched. Seed criterion 2's "flows of
CLARIFICATIONS" = the end steps of feat, bugfix, ship-feature, init-project,
a11y, guardrails, audit-delta and tour.
Seed (STEP 0e, superseded): skills/{feat,bugfix,ship-feature,init-project,a11y,guardrails}/SKILL.md (gate step), lib/capitalize-commit.md, skills/release-candidate/SKILL.md (STEP 4), agents/security-auditor.md, agents/verifier.md, agents/plan-challenger.md (advisor bullet, ORCHESTRATOR PROTOCOL), lib/effort-shift.md (§ Advisor blank line). Final list settled at STEP 3.
@@ -0,0 +1,41 @@
# CONTRACT — gates-label-timeout
- date: 2026-11-17 | flow: hotfix | branch: bugfix/gates-label-timeout
- status: active
## REQUEST (verbatim — IMMUTABLE)
corrige les deux bugs mis dans le todos puis passe a C
Bug description (TODO:88-89): (1) gates.sh: warn or reject a criterion row labelled `^[0-9]+[a-z]\.` (LRN-284: `1b.` absorbed into criterion 1, its CHECK/EXPECT overwritten, false MET). (2) gates.sh default `GATES_TIMEOUT=120` < full `make test` (~135 s on 2026-11-16): a "Full make test green" criterion goes NOT-MET on timeout alone (A6 run, re-run with GATES_TIMEOUT=400). Raise the default or have contract-interview write the timeout for full-suite criteria.
## CLARIFICATIONS
Q: the two bugs? / A: inferred, not asked: TODO:88-89, the two gates.sh items (TODO:90 design-tool-gate is deferred to its next touch by its own text); the user's answers to the two questions below approve both fixes
Deviation 2026-11-17 (advisor, reported to the user): the same false MET reproduces with an indented ` 2. sub`, `- sub` or `**2.** sub` label, so `_set_attr` also rejects a second CHECK/EXPECT/EVIDENCE on one criterion (no past contract has one; every past verdict unchanged)
Q: bad label handling? / A: reject: an unindented ACCEPTANCE CRITERIA line starting with a digit that is not `N. text` (`1b.`, `1.1`, `2)`) is a parse error naming the line, its attributes belong to no criterion, verdict ERROR [gated 2026-11-17]
Q: timeout fix? / A: default 600 s, the GATES_TIMEOUT env override kept [gated 2026-11-17]
## ACCEPTANCE CRITERIA
1. A `1b.` label after a failing criterion makes `gates.sh run` return ERROR rc 2 naming line 6 (before the fix this fixture is a false MET).
CHECK: cd /home/bchanot/Documents/claude && f=$(mktemp) && printf '## ACCEPTANCE CRITERIA\n1. real\n CHECK: exit 1\n EXPECT: x\n EVIDENCE: pending\n1b. sub\n CHECK: echo y\n EXPECT: y\n EVIDENCE: pending\n' > "$f"; out=$(bash lib/gates.sh run "$f" 2>&1); rc=$?; rm -f "$f"; [ "$rc" -eq 2 ] && printf '%s' "$out" | grep -q 'malformed criterion label at line 6' && printf '%s' "$out" | grep -q 'VERDICT: ERROR' && echo LABEL-REJECTED
EXPECT: LABEL-REJECTED
EVIDENCE: MET exit=0 marker-found :: LABEL-REJECTED
2. With GATES_TIMEOUT unset, gates.sh reports a 600 s timeout; with GATES_TIMEOUT=7 it reports 7 s.
CHECK: cd /home/bchanot/Documents/claude && f=$(mktemp) && printf '## ACCEPTANCE CRITERIA\n1. manual\n' > "$f"; a=$(env -u GATES_TIMEOUT bash lib/gates.sh status "$f" 2>&1); b=$(GATES_TIMEOUT=7 bash lib/gates.sh status "$f" 2>&1); rm -f "$f"; printf '%s' "$a" | grep -q 'timeout 600s' && printf '%s' "$b" | grep -q 'timeout 7s' && echo DEFAULT-600
EXPECT: DEFAULT-600
EVIDENCE: MET exit=0 marker-found :: DEFAULT-600
3. lib/tests/gates.test.sh carries the regression cases and is green; shellcheck clean on both files.
CHECK: cd /home/bchanot/Documents/claude && grep -q '1b\. sub' lib/tests/gates.test.sh && grep -q '1\.1 dotted' lib/tests/gates.test.sh && grep -q 'timeout 600s' lib/tests/gates.test.sh && shellcheck -S warning lib/gates.sh lib/tests/gates.test.sh && bash lib/tests/gates.test.sh 2>&1 | tail -1 | grep -q ', 0 fail' && echo SUITE-GREEN
EXPECT: SUITE-GREEN
EVIDENCE: MET exit=0 marker-found :: SUITE-GREEN
4. An indented ` 2. sub` label with a passing oracle after a failing criterion 1 makes `gates.sh run` return ERROR naming the second CHECK (before the fix: false MET).
CHECK: cd /home/bchanot/Documents/claude && f=$(mktemp) && printf '## ACCEPTANCE CRITERIA\n1. real\n CHECK: exit 1\n EXPECT: x\n EVIDENCE: pending\n 2. sub\n CHECK: echo y\n EXPECT: y\n EVIDENCE: pending\n' > "$f"; out=$(bash lib/gates.sh run "$f" 2>&1); rc=$?; rm -f "$f"; [ "$rc" -eq 2 ] && printf '%s' "$out" | grep -q 'second CHECK: at line 7' && printf '%s' "$out" | grep -q 'VERDICT: ERROR' && echo STRAY-REJECTED
EXPECT: STRAY-REJECTED
EVIDENCE: MET exit=0 marker-found :: STRAY-REJECTED
5. Full make test green, run by gates.sh with no GATES_TIMEOUT set (proves the new default covers the suite).
CHECK: cd /home/bchanot/Documents/claude && PATH=$HOME/.bun/bin:$PATH make test </dev/null 2>&1 | tail -1
EXPECT: all suites green
EVIDENCE: MET exit=0 marker-found :: all suites green
## FILE SCOPE
lib/gates.sh
lib/tests/gates.test.sh
(bookkeeping: .claude/tasks/TODO.md, .claude/memory via memory.sh, this contract, the challenge plan .claude/tasks/plans/2026-11-17-gates-label-timeout-2342.md)
@@ -0,0 +1,60 @@
# CONTRACT — advisor-points-b3
- date: 2026-11-18 | flow: ship-feature | branch: feature/advisor-points-b3
- status: active
## REQUEST (verbatim — IMMUTABLE)
corrige les deux bugs mis dans le todos puis passe a C
Answers 2026-11-18 that scope this run: "Did 'les deux bugs' also mean TODO:10-11?" → "Yes, do 10-11 first". Route line wording → "First challenge call (Recommended)": "(route: own level before the challenge; send it with the first tool call of lib/challenge-plan.md, the advisor call when one is due)". BUGS-FOUND :114 Advisor row → "Yes, same run (Recommended)". Flow → "/ship-feature (Recommended)". TODO:11 → "Skip when gates clean": feat/bugfix skip the end-of-run call when GATE 0, verifier and security passed first try and no stuck call ran; doctrine edit in effort-shift item 3 + 2 skills.
Skill args (/ship-feature): Advisor run B3 (TODO:10-11 + BUGS-FOUND :114 residual; user 2026-11-18). (1) The challenge route line in 12 skills (feat, bugfix, hotfix, ship-feature, init-project, audit-delta, code-clean, onboard, harden, pack-seo seo + geo, pack-web-validate web-validate) reads "(route: own level before the challenge; send it with the challenger dispatch)"; lib/challenge-plan.md now puts the main-loop advisor call (and a plan read) before the dispatch. User wording: "(route: own level before the challenge; send it with the first tool call of lib/challenge-plan.md, the advisor call when one is due)". (2) Same 12 skills: each CHALLENGE SUMMARY template gains the `Advisor:` row lib/challenge-plan.md OUTPUT requires; BUGS-FOUND :114 residual → FIXED. (3) TODO:11 user decision "skip when gates clean": /feat and /bugfix skip the end-of-run advisor call when GATE 0, the verifier and security all passed on their first run and no stuck call ran; doctrine in lib/effort-shift.md § Advisor item 3 + skills/feat + skills/bugfix end lines; TODO:11 closed, BDR-150 status line. Method as B2: blocks in files + exact-once applier, simulated on a mktemp scratch copy with every contract CHECK before dispatch (LRN-296); markers and `§ Label` citations on one line followed by `)` or `;`; criteria plain `N.` labels (gates.sh now rejects others); full make test at the gates.sh default timeout; gates in order GATE 0 → verifier → security after CONFORME; at capitalize memory_pending first; docs CHANGELOG [Unreleased] Advisor doctrine bullet, README/USAGE only if they cite the changed lines.
## CLARIFICATIONS
Q: route line wording / A: user wording above [gated 2026-11-18]
Q: fold BUGS-FOUND :114 Advisor row into the run / A: yes [gated 2026-11-18]
Q: flow / A: /ship-feature [gated 2026-11-18]
Q: TODO:11 decision / A: skip when gates clean, feat and bugfix only [gated 2026-11-18]
Q: route wording vs a PLAN Read first / A: keep verbatim [gated 2026-11-18]
Q: Advisor row format / A: row with its three values inline; one-line summaries gain "/ advisor" [gated 2026-11-18]
Q: "gates clean" / A: strict: GATE 0 MET, verifier CONFORME, security PASS (not DEGRADED), each first attempt; anything else runs the call [gated 2026-11-18]
Q: add-ons / A: ADVISOR field in FEAT/BUGFIX COMPLETE; item 3 "end step" wording (BUGS-FOUND :118 wording part) [gated 2026-11-18]
Q: STEP 3 dispositions (plan "Dispositions shown at the STEP 3 gate": verdict out of view runs the call; all-manual GATE 0 MET counts; NEED-DECISION / deferred BLOCKER / REPORTED findings count as clean; a skip discharges its point and trigger; bugfix end route kept; reuse clause names later code commits) / A: approved as listed [gated 2026-11-18]
## ACCEPTANCE CRITERIA
1. No skill keeps the old route annotation "send it with the challenger dispatch". [gated 2026-11-18]
CHECK: cd /home/bchanot/Documents/claude && n=$(git grep -c 'send it with the challenger dispatch' -- skills | wc -l); [ "$n" -eq 0 ] && echo OLD-ROUTE-GONE
EXPECT: OLD-ROUTE-GONE
EVIDENCE: MET exit=0 marker-found :: OLD-ROUTE-GONE
2. Each of the 12 challenge callers carries the new route annotation exactly once, on its `mcp__model-router__route(phase=…)` line. [gated 2026-11-18]
CHECK: cd /home/bchanot/Documents/claude && n=0; for f in skills/feat/SKILL.md skills/bugfix/SKILL.md skills/hotfix/SKILL.md skills/ship-feature/SKILL.md skills/init-project/SKILL.md skills/audit-delta/SKILL.md skills/code-clean/SKILL.md skills/onboard/SKILL.md skills/harden/SKILL.md skills/pack-seo/skills/seo/SKILL.md skills/pack-seo/skills/geo/SKILL.md skills/pack-web-validate/skills/web-validate/SKILL.md; do c=$(grep -F 'mcp__model-router__route(phase=' "$f" | grep -cF '(route: own level before the challenge; send it with the first tool call of lib/challenge-plan.md, the advisor call when one is due).'); [ "$c" -eq 1 ] && n=$((n+1)); done; [ "$n" -eq 12 ] && echo ROUTE-12
EXPECT: ROUTE-12
EVIDENCE: MET exit=0 marker-found :: ROUTE-12
3. In the 9 block-form CHALLENGE SUMMARY templates, the line right after `Lenses returned` is the `Advisor:` row, its noun equal to the noun of the block's own `BLOCKERs addressed` row. [gated 2026-11-18]
CHECK: cd /home/bchanot/Documents/claude && n=0; for f in skills/ship-feature/SKILL.md skills/init-project/SKILL.md skills/audit-delta/SKILL.md skills/code-clean/SKILL.md skills/onboard/SKILL.md skills/harden/SKILL.md skills/pack-seo/skills/seo/SKILL.md skills/pack-seo/skills/geo/SKILL.md skills/pack-web-validate/skills/web-validate/SKILL.md; do awk 'BEGIN{ok=0} /BLOCKERs addressed : <n>/{if (match($0,/named [a-z-]+ change/)) x=substr($0,RSTART+6,RLENGTH-13)} p{if (x!="" && index($0,"Advisor : <the " x " change it drove | called, no change | not called (absent | error | already called this run)>")) ok=1; p=0} /Lenses returned : correctness/{p=1} END{exit !ok}' "$f" && n=$((n+1)); done; [ "$n" -eq 9 ] && echo ROWS-9
EXPECT: ROWS-9
EVIDENCE: MET exit=0 marker-found :: ROWS-9
4. feat, bugfix and hotfix name the advisor in their one-line CHALLENGE SUMMARY. [gated 2026-11-18]
CHECK: cd /home/bchanot/Documents/claude && n=0; for f in feat bugfix hotfix; do grep -qF 'lenses returned / advisor)' skills/$f/SKILL.md && grep -qF 'CHALLENGE SUMMARY' skills/$f/SKILL.md && n=$((n+1)); done; [ "$n" -eq 3 ] && echo SENTENCES-3
EXPECT: SENTENCES-3
EVIDENCE: MET exit=0 marker-found :: SENTENCES-3
5. lib/effort-shift.md § Advisor item 3 keeps "never skipped for an earlier plan or stuck call" and names its two skips (audit-delta/tour with no fix; feat/bugfix on the strict rule, "(not DEGRADED)" and the verdict-out-of-view clause included); a skipped call discharges its point; feat/bugfix sit at their commit step; for the six gate flows a later merge proposal reuses the last run's answer or skip and names any later code commit (doc and memory commits excepted); "end step of feat" and "predates the newer commits" are gone. [gated 2026-11-18]
CHECK: cd /home/bchanot/Documents/claude && t=$(awk '/^3\. Before proposing a merge/{p=1} p&&/^$/{exit} p' lib/effort-shift.md | tr '\n' ' ' | tr -s ' '); for s in 'Wired at the commit step of feat and bugfix, at the end step of ship-feature' 'never skipped for an earlier plan or stuck call. Two skips only:' 'feat and bugfix when GATE 0 said MET, the verifier CONFORME and security PASS (not DEGRADED), each on its first attempt (any other verdict, a retry, a loop iteration or a verdict no longer in view runs the call)' '`skipped (gates clean on first pass)`' 'A skipped call discharges its point and the trigger it covers.' 'a later merge proposal reuses the last run' 'and names any code commit made after it (doc and memory commits excepted).'; do printf '%s' "$t" | grep -qF -- "$s" || exit 1; done; printf '%s' "$t" | grep -qF 'end step of feat' && exit 1; printf '%s' "$t" | grep -qF 'predates the newer commits' && exit 1; echo ITEM3-OK
EXPECT: ITEM3-OK
EVIDENCE: MET exit=0 marker-found :: ITEM3-OK
6. skills/feat and skills/bugfix restate the skip condition ("(not DEGRADED)" and the verdict-out-of-view clause included) at their end-of-run line, before the COMPLETE summary, and the summary template carries the `ADVISOR` field with its three values; the old "as an `Advisor:` line" wording is gone. [gated 2026-11-18]
CHECK: cd /home/bchanot/Documents/claude && for f in skills/feat/SKILL.md skills/bugfix/SKILL.md; do t=$(tr '\n' ' ' < "$f" | tr -s ' '); for s in 'end-of-run advisor call (`lib/effort-shift.md` § Advisor), skipped when GATE 0 said MET, the verifier CONFORME and security PASS (not DEGRADED), each on its first attempt; any other verdict, a retry, a loop iteration or a verdict no longer in view runs the call.' '`ADVISOR` field, and a fix it drives goes back through the gates.' ': <one-line answer | skipped (gates clean on first pass) | not called (absent | error)>'; do printf '%s' "$t" | grep -qF -- "$s" || exit 1; done; printf '%s' "$t" | grep -qF 'goes into the summary as an `Advisor:` line' && exit 1; a=$(grep -n '§ Advisor), skipped when' "$f" | cut -d: -f1); c=$(grep -nE '^ *(FEAT|BUGFIX) COMPLETE$' "$f" | tail -1 | cut -d: -f1); d=$(grep -n 'ADVISOR .*: <one-line answer' "$f" | cut -d: -f1); [ -n "$a" ] && [ -n "$c" ] && [ -n "$d" ] && [ "$a" -lt "$c" ] && [ "$c" -lt "$d" ] || exit 1; done; echo FEAT-BUGFIX-SKIP
EXPECT: FEAT-BUGFIX-SKIP
EVIDENCE: MET exit=0 marker-found :: FEAT-BUGFIX-SKIP
7. CHANGELOG [Unreleased] "Advisor doctrine" bullet names the new callers, the summary row and route, the feat/bugfix skip (not DEGRADED), their commit step, the `ADVISOR` field and the reuse clause that names later code commits; "It sits at the end step of feat, bugfix" and "the answer goes into the reply, summary or finish proposal" are gone. [gated 2026-11-18]
CHECK: cd /home/bchanot/Documents/claude && u=$(awk '/^## \[Unreleased\]/{p=1;next} /^## \[/{p=0} p' CHANGELOG.md); for s in 'skills/{feat,bugfix,hotfix,ship-feature,init-project,onboard,code-clean,harden,a11y,guardrails,audit-delta,tour,release-candidate}/SKILL.md' 'the CHALLENGE SUMMARY of every caller gains an `Advisor:` row' 'with the first tool call of `lib/challenge-plan.md`' 'feat and bugfix skip it when GATE 0 said MET, the verifier CONFORME and security PASS (not DEGRADED), each on its first attempt' 'It sits at the commit step of feat and bugfix and at the end step of ship-feature' 'and a later merge proposal reuses the last run' 'names any code commit made after it (doc and memory commits excepted).' 'or into the feat/bugfix summary'; do printf '%s' "$u" | grep -qF -- "$s" || exit 1; done; printf '%s' "$u" | grep -qF 'It sits at the end step of feat, bugfix' && exit 1; printf '%s' "$u" | grep -qF 'the answer goes into the reply, summary or finish proposal' && exit 1; echo CHANGELOG-OK
EXPECT: CHANGELOG-OK
EVIDENCE: MET exit=0 marker-found :: CHANGELOG-OK
8. Full make test green. [gated 2026-11-18]
CHECK: cd /home/bchanot/Documents/claude && PATH=$HOME/.bun/bin:$PATH make test </dev/null 2>&1 | tail -1
EXPECT: all suites green
EVIDENCE: MET exit=0 marker-found :: all suites green
9. No wording changed outside the planned edits; every marker and `§ Label` citation stays on one line followed by `)` or `;`; new prose lines ≤ 80 columns, except by name the 12 route lines and the template rows (`Advisor` row, `ADVISOR` field), which run as wide as the rows beside them, and the CHANGELOG bullet (one unwrapped line, like every bullet in that file) (manual). [gated 2026-11-18]
## FILE SCOPE
skills/feat/SKILL.md, skills/bugfix/SKILL.md, skills/hotfix/SKILL.md, skills/ship-feature/SKILL.md, skills/init-project/SKILL.md, skills/audit-delta/SKILL.md, skills/code-clean/SKILL.md, skills/onboard/SKILL.md, skills/harden/SKILL.md, skills/pack-seo/skills/seo/SKILL.md, skills/pack-seo/skills/geo/SKILL.md, skills/pack-web-validate/skills/web-validate/SKILL.md, lib/effort-shift.md, CHANGELOG.md
(bookkeeping: .claude/tasks/TODO.md, .claude/audits/BUGS-FOUND.md, .claude/memory via memory.sh, this contract; transient plan under docs/superpowers/plans/)
@@ -0,0 +1,49 @@
# CONTRACT — advisor-usage (Run C)
- date: 2026-11-19 | flow: feat | branch: feature/advisor-usage
- status: active
## REQUEST (verbatim — IMMUTABLE)
Merge et corrige le bug et fais les todo
Scope of this run (main loop): TODO:18 Run C — advisor usage section in /memory-feedback (main loop vs sub-agents, model served, input tokens; dedupe usage rows by message.id, model from the `advisor_message` iteration).
## CLARIFICATIONS
Q: placement / A: a "## Advisor usage (<from> → <to>)" section appended to FEEDBACK.md by `reader.ts apply`, printed with the gates, even at 0 records [gated 2026-11-19]
Q: sub-agent breakdown / A: per agent type from subagents/agent-<id>.meta.json `agentType`; unknown → "sub-agent (unknown)"; main thread = "main loop" [gated 2026-11-19]
Q: scope / A: every project under ~/.claude/projects summed, no repo name or tag in the table [gated 2026-11-19]
Q: window / A: since the last /memory-feedback run (state.json lastRun) to now; first run (lastRun 0) = everything on disk [gated 2026-11-19]
Q: retention note / A: when the window exceeds 7 days, "Transcripts kept 7 d: calls before <date> may be missing." under the heading [gated 2026-11-19]
Q: shape drift / A: 0 calls but usage rows mention advisor_message → "N transcript lines mention advisor_message, none parsed: check the transcript shape." in place of the plain zero [gated 2026-11-19]
Q: challenge (3 lenses) changes: call = served advisor iteration (block without iteration not counted), per-dir skip, dated Unavailable heading, no 6th local in commit(), compact 999950 → 1.0M / A: main loop, internal [2026-11-19]
Q: GATE 0 run 1 criterion 1 oracle broken (bun prints file names only on failure) / A: main loop, oracle corrected to run advisor.test.ts directly; criterion 4 red = mods.test.sh model-router plugin test timeout at load avg ~30 (121 s alone vs CLI_TIMEOUT 120), unrelated to the diff [2026-11-19]
Q: retention note fires every weekly run (window just over 7 d, cut day = start day) / A: print it only when the cut day is later than the heading's start day [gated 2026-11-19]
Q: privacy wording / A: skills/memory-feedback/SKILL.md:12 "keeps IDs, enums and repo tags only" → also names advisor call counts [gated 2026-11-19]
## ACCEPTANCE CRITERIA
1. The memory-feedback bun suite is green and advisor.test.ts runs at least 17 passing tests.
CHECK: cd /home/bchanot/Documents/claude/lib/memory-feedback && PATH=$HOME/.bun/bin:$PATH bun test advisor.test.ts 2>&1 | grep -qE '^ *(1[7-9]|[2-9][0-9]) pass' && cd /home/bchanot/Documents/claude && PATH=$HOME/.bun/bin:$PATH bash lib/tests/memory-feedback.test.sh 2>&1 | grep -qE '^ *0 fail' && echo MF-GREEN
EXPECT: MF-GREEN
EVIDENCE: MET exit=0 marker-found :: MF-GREEN
2. On real transcripts, advisorUsage + renderAdvisor read this machine's advisor calls: the section heading, a "main loop" row, a Fable-served row and the total row appear (total arithmetic: advisor.test.ts).
CHECK: cd /home/bchanot/Documents/claude/lib/memory-feedback && PATH=$HOME/.bun/bin:$PATH bun -e 'import {advisorUsage,renderAdvisor} from "./advisor.ts"; const p=require("os").homedir()+"/.claude/projects"; const t=advisorUsage(p,0,Date.now()); const u=t.uses; const s=renderAdvisor(t,0,Date.now()); const ok=s.startsWith("## Advisor usage (all on disk → ")&&u.some(x=>x.caller==="main loop")&&u.some(x=>x.model.startsWith("claude-fable"))&&s.includes("| total |"); console.log(ok?"ADV-SMOKE":"bad")'
EXPECT: ADV-SMOKE
EVIDENCE: MET exit=0 marker-found :: ADV-SMOKE
3. `reader.ts apply` writes the section into FEEDBACK.md (reader.test.ts locks it) and the skill's STEP 5 tells the user to show it.
CHECK: cd /home/bchanot/Documents/claude && grep -qF '## Advisor usage' lib/memory-feedback/reader.test.ts && grep -qF '`## Advisor usage`' skills/memory-feedback/SKILL.md && echo WIRED
EXPECT: WIRED
EVIDENCE: MET exit=0 marker-found :: WIRED
4. Full make test green (code-limits and the citers census included).
CHECK: cd /home/bchanot/Documents/claude && PATH=$HOME/.bun/bin:$PATH make test </dev/null 2>&1 | tail -1
EXPECT: all suites green
EVIDENCE: MET exit=0 marker-found :: all suites green
5. Manual: the table carries no repo name, slug, path or prompt text (callers are agent types or the two fixed labels, models are id-shaped); rows are deduped by message.id; an unreadable transcript is skipped, a failure of the whole section never fails `apply`; new code within the global limits (25 logic lines/function, 80 cols, 5 params, 5 locals).
6. The retention note prints only when its cut day is later than the heading's start day (advisor.test.ts test 13 covers a 7-day-plus-hours window with no note), and SKILL.md's data line names the advisor counts.
CHECK: cd /home/bchanot/Documents/claude/lib/memory-feedback && PATH=$HOME/.bun/bin:$PATH bun -e 'import {renderAdvisor} from "./advisor.ts"; const D=86400000, to=Date.UTC(2026,10,19,17); const t={uses:[],unparsed:0,files:1}; const wk=renderAdvisor(t,to-7*D-5*3600000,to), two=renderAdvisor(t,to-14*D,to); console.log(!wk.includes("Transcripts kept")&&two.includes("calls before 2026-11-12 may be missing.")?"RET-OK":"bad")' | grep -qF RET-OK && grep -qF 'advisor call counts' /home/bchanot/Documents/claude/skills/memory-feedback/SKILL.md && echo RET-OK
EXPECT: RET-OK
EVIDENCE: MET exit=0 marker-found :: RET-OK
## FILE SCOPE
lib/memory-feedback/advisor.ts (new), lib/memory-feedback/advisor.test.ts (new), lib/memory-feedback/reader.ts, lib/memory-feedback/reader.test.ts, skills/memory-feedback/SKILL.md
@@ -0,0 +1,41 @@
# CONTRACT — degraded-tool-line
- date: 2026-11-19 | flow: bugfix | branch: bugfix/degraded-tool-line
- status: active
## REQUEST (verbatim — IMMUTABLE)
Merge et corrige le bug et fais les todo
Scope of this run (main loop, from the previous turn's report): "le bug" = BUGS-FOUND.md:134 (security-auditor prints `VERDICT: PASS` on a DEGRADED scan, DEGRADED only on its `TOOL:` line; lib/verify-secure-loop.md, agents/security-auditor.md and skills/hotfix/SKILL.md teach DEGRADED as a VERDICT-line value); TODO:13 (loops-light lock on the feat/bugfix skip sentence) folds in as the regression test. TODO:14 and Run C are separate runs.
## CLARIFICATIONS
Q: fix plan (.claude/tasks/plans/2026-11-19-degraded-tool-line-0930.md, STEP 3 gate with challenge summary) / A: yes [gated 2026-11-19]
## ACCEPTANCE CRITERIA
1. loops-light carries the new locks and is green: 78 pass, 0 fail.
CHECK: cd /home/bchanot/Documents/claude && bash lib/tests/loops-light.test.sh 2>&1 | tail -1 | grep -qF '78 pass, 0 fail' && echo LOCKS-78
EXPECT: LOCKS-78
EVIDENCE: MET exit=0 marker-found :: LOCKS-78
2. No reader lists DEGRADED as a VERDICT value: the backticked token `DEGRADED` is gone from the three readers.
CHECK: cd /home/bchanot/Documents/claude && ! grep -qF '`DEGRADED`' lib/verify-secure-loop.md agents/security-auditor.md skills/hotfix/SKILL.md && echo OLD-VALUE-GONE
EXPECT: OLD-VALUE-GONE
EVIDENCE: MET exit=0 marker-found :: OLD-VALUE-GONE
3. Each of the three readers' PASS branch reads the TOOL line first and makes a PASS without it a structural failure (joined text).
CHECK: cd /home/bchanot/Documents/claude && n=0; for f in lib/verify-secure-loop.md agents/security-auditor.md skills/hotfix/SKILL.md; do tr '\n' ' ' < "$f" | tr -s ' ' | grep -qF '`PASS` → read the `TOOL:` line first: DEGRADED (semgrep absent) shows there, never on the VERDICT line; a PASS with no `TOOL:` line is a structural failure (below).' && n=$((n+1)); done; [ "$n" -eq 3 ] && echo READERS-3
EXPECT: READERS-3
EVIDENCE: MET exit=0 marker-found :: READERS-3
4. The auditor's and hotfix's structural-failure lists name a PASS with no TOOL line (joined text).
CHECK: cd /home/bchanot/Documents/claude && tr '\n' ' ' < agents/security-auditor.md | tr -s ' ' | grep -qF 'PASS without PROOF or without `TOOL:` line) → retry ONCE fresh' && tr '\n' ' ' < skills/hotfix/SKILL.md | tr -s ' ' | grep -qF 'Structural failure (mute / unparsable / no VERDICT line / PASS with no `TOOL:` line) → treat as a failed gate' && echo STRUCT-2
EXPECT: STRUCT-2
EVIDENCE: MET exit=0 marker-found :: STRUCT-2
5. lib/effort-shift.md § Advisor item 3 names the line DEGRADED prints on, and hotfix's DEGRADED PASS sets its SECURITY field.
CHECK: cd /home/bchanot/Documents/claude && tr '\n' ' ' < lib/effort-shift.md | tr -s ' ' | grep -qF '`skipped (gates clean on first pass)`; DEGRADED shows on the auditor'"'"'s `TOOL:` line. A skipped call discharges' && tr '\n' ' ' < skills/hotfix/SKILL.md | tr -s ' ' | grep -qF 'a DEGRADED PASS sets the summary'"'"'s SECURITY field to `DEGRADED (checklist only)`' && echo EFF-HOT-OK
EXPECT: EFF-HOT-OK
EVIDENCE: MET exit=0 marker-found :: EFF-HOT-OK
6. Full make test green.
CHECK: cd /home/bchanot/Documents/claude && PATH=$HOME/.bun/bin:$PATH make test </dev/null 2>&1 | tail -1
EXPECT: all suites green
EVIDENCE: MET exit=0 marker-found :: all suites green
7. The new locks are red on develop's readers (16 FAIL simulated on a scratch clone before dispatch); no wording changed outside the plan's blocks; new prose lines ≤ 80 columns (manual).
## FILE SCOPE
lib/verify-secure-loop.md, agents/security-auditor.md, skills/hotfix/SKILL.md, lib/effort-shift.md, lib/tests/loops-light.test.sh
@@ -0,0 +1,34 @@
# CONTRACT — merge-reuse-clause (run 1 of 2)
- date: 2026-11-19 | flow: feat | branch: feature/advisor-merge-reuse
- status: active
## REQUEST (verbatim — IMMUTABLE)
Merge et corrige le bug et fais les todo
Scope of this run (main loop): TODO:14 — the end-of-run advisor lines in skills/a11y, skills/guardrails, skills/ship-feature, skills/init-project restate lib/effort-shift.md § Advisor item 3's merge-reuse clause, plus a regression lock in lib/tests/loops-light.test.sh. Run 2 (same branch) does feat + bugfix.
## CLARIFICATIONS
Q: challenge MINORs (lock 1 anchored on "the gates.", lock 3 "commits excepted)." with si re-wrap, $EFF source lock → 91) / A: main loop, internal (no visible wording change) [2026-11-19]
Q: which sites get the clause / A: all 6 (the 4 named + feat + bugfix); /feat 5-file cap → two /feat runs on one branch, this run = the 4 named sites [gated 2026-11-19]
## ACCEPTANCE CRITERIA
1. loops-light carries 13 new locks (3 per site + the lib source) and is green: 91 pass, 0 fail.
CHECK: cd /home/bchanot/Documents/claude && bash lib/tests/loops-light.test.sh 2>&1 | tail -1 | grep -qF '91 pass, 0 fail' && echo LOCKS-91
EXPECT: LOCKS-91
EVIDENCE: MET exit=0 marker-found :: LOCKS-91
2. Each of the four sites carries the full clause right after its "a fix it drives goes back through the gates." (joined text).
CHECK: cd /home/bchanot/Documents/claude && n=0; for f in a11y guardrails ship-feature init-project; do tr '\n' ' ' < skills/$f/SKILL.md | tr -s ' ' | grep -qF 'goes back through the gates. A later merge proposal reuses this answer and names any code commit made after it (doc and memory commits excepted).' && n=$((n+1)); done; [ "$n" -eq 4 ] && echo SITES-4
EXPECT: SITES-4
EVIDENCE: MET exit=0 marker-found :: SITES-4
3. lib/effort-shift.md item 3 is unchanged (the clause stays single-sourced there).
CHECK: cd /home/bchanot/Documents/claude && git diff --quiet develop -- lib/effort-shift.md && echo EFF-UNCHANGED
EXPECT: EFF-UNCHANGED
EVIDENCE: MET exit=0 marker-found :: EFF-UNCHANGED
4. Full make test green.
CHECK: cd /home/bchanot/Documents/claude && PATH=$HOME/.bun/bin:$PATH make test </dev/null 2>&1 | tail -1
EXPECT: all suites green
EVIDENCE: MET exit=0 marker-found :: all suites green
5. The new site locks are red on develop's skills (12 FAIL; the lib lock passes on develop simulated on a scratch clone before dispatch); no wording changed outside the plan's blocks; new prose lines ≤ 80 columns (manual).
## FILE SCOPE
skills/a11y/SKILL.md, skills/guardrails/SKILL.md, skills/ship-feature/SKILL.md, skills/init-project/SKILL.md, lib/tests/loops-light.test.sh
@@ -0,0 +1,33 @@
# CONTRACT — merge-reuse-feat-bugfix (run 2 of 2)
- date: 2026-11-19 | flow: feat | branch: feature/advisor-merge-reuse
- status: active
## REQUEST (verbatim — IMMUTABLE)
Merge et corrige le bug et fais les todo
Scope of this run (main loop): TODO:14 run 2 — the feat and bugfix end-of-run lines restate lib/effort-shift.md § Advisor item 3's merge-reuse clause with the skip ("reuses the last run's answer, or its skip"), plus loops-light locks. Run 1 = af846d6 (a11y, guardrails, ship-feature, init-project).
## CLARIFICATIONS
Q: which sites get the clause / A: all 6; feat/bugfix get "reuses the last run's answer, or its skip" (scope question option text) [gated 2026-11-19]
## ACCEPTANCE CRITERIA
1. loops-light carries 6 new locks (3 per site) and is green: 97 pass, 0 fail.
CHECK: cd /home/bchanot/Documents/claude && bash lib/tests/loops-light.test.sh 2>&1 | tail -1 | grep -qF '97 pass, 0 fail' && echo LOCKS-97
EXPECT: LOCKS-97
EVIDENCE: MET exit=0 marker-found :: LOCKS-97
2. feat and bugfix carry the full clause right after their "a fix it drives goes back through the gates." (joined text).
CHECK: cd /home/bchanot/Documents/claude && n=0; for f in feat bugfix; do tr '\n' ' ' < skills/$f/SKILL.md | tr -s ' ' | grep -qF 'goes back through the gates. A later merge proposal reuses the last run'"'"'s answer, or its skip, and names any code commit made after it (doc and memory commits excepted).' && n=$((n+1)); done; [ "$n" -eq 2 ] && echo SITES-2
EXPECT: SITES-2
EVIDENCE: MET exit=0 marker-found :: SITES-2
3. The 9814720 skip locks and lib/effort-shift.md stay intact: lib unchanged vs develop, and the skip sentence's locked fragments still present in both skills.
CHECK: cd /home/bchanot/Documents/claude && git diff --quiet develop -- lib/effort-shift.md && for f in skills/feat/SKILL.md skills/bugfix/SKILL.md; do grep -qF 'a verdict no longer in view runs the call.' "$f" && grep -qF "auditor's \`TOOL:\` line, beside a PASS." "$f" || exit 1; done && echo SKIP-INTACT
EXPECT: SKIP-INTACT
EVIDENCE: MET exit=0 marker-found :: SKIP-INTACT
4. Full make test green.
CHECK: cd /home/bchanot/Documents/claude && PATH=$HOME/.bun/bin:$PATH make test </dev/null 2>&1 | tail -1
EXPECT: all suites green
EVIDENCE: MET exit=0 marker-found :: all suites green
5. The 6 new locks are red before the edit (simulated on a scratch clone before dispatch); no wording changed outside the plan's blocks; new prose lines ≤ 80 columns (manual).
## FILE SCOPE
skills/feat/SKILL.md, skills/bugfix/SKILL.md, lib/tests/loops-light.test.sh
@@ -0,0 +1,75 @@
# PLAN — fable-pins-to-opus (BDR-150 follow-up)
## APPROACH
1. agents/client-handover-writer.md: the 7 `model: "fable"` occurrences
become `model: "opus"`, `effort="high"` kept on each. In the BDR-077
paragraph (~:268-271) the sentence keeps its meaning: skill-runners carry
`model: "opus"` and `effort="high"`, never inherit the session model; add
"(BDR-150: Fable is the advisor, never a dispatch target)".
2. skills/client-handover/SKILL.md ~:34: "skill-runner children dispatched
`model: "fable"`" → `model: "opus"`.
3. lib/model-gate.md Dispatch tiers paragraph: "`model: "fable"` when the
child reflects/orchestrates for the main loop (skill-runners), else its
tier (opus = dispatched judgment, ...)" → "`model: "opus"` for
skill-runners (the child reflects/orchestrates for the main loop) and
for dispatched judgment, sonnet = execution, haiku = mechanical probes;
Fable is never a dispatch target, it is the advisor (BDR-150)". The
gate's answer table stays (a fable id still proceeds: a hand-picked
Fable session may run a skill); its STOP text stays "require Fable or
Opus".
4. lib/tests/model-routing.test.sh block 12 (~:88-95): comment says
skill-runner children are pinned opus since BDR-150 (Fable = advisor);
`has client-handover-writer.md 'model: "opus"'`, `has model-gate.md
'model: "opus" for skill-runners'` (the new phrase), plus `lacks` on
'model: "fable"' in client-handover-writer.md, skills/client-handover/
SKILL.md and model-gate.md.
5. lib/tests/effort-routing.test.sh ~:224-225: count the `model: "opus"`
lines of client-handover-writer.md (must be ≥ 1, else ko: a vacuous
pass) and require every one to carry `effort="high"`.
## EDGE CASES
- lib/effort-shift.md ("`high` for fable runners", wiring point 5) is the
doctrine run's file, out of scope here; it stays stale until that run
(next, same session).
- README.md:107 and :132 citers → doc-sync step.
## DISPOSITION
Amends BDR-077 W1 (skill-runner pins fable → opus) per BDR-150. Honors
BDR-108 (pins stay tier aliases).
## FILES
agents/client-handover-writer.md, skills/client-handover/SKILL.md,
lib/model-gate.md, lib/tests/model-routing.test.sh,
lib/tests/effort-routing.test.sh.
## r2 (challenge r1: correctness CONCERNS(1), robustness CONCERNS(1), simplicity SOLID) — amends APPROACH 1-5
1. client-handover-writer.md: swap the 7 `model: "fable"` for `model: "opus"`
only; `model: "opus"` and `effort="high"` stay on the SAME physical line
at each site; no BDR-150 parenthetical in this file.
2. model-gate.md Dispatch tiers paragraph: one tier list, e.g. "its tier:
`model: "opus"` = skill-runners (the child reflects/orchestrates for the
main loop) and dispatched judgment, sonnet = execution, haiku =
mechanical probes; never fable (BDR-150, the advisor)." Keep the file
short (≤ 31 lines). Gate table: add one row: the answer says the model
is `fixed at spawn` (the route tool called inside a sub-agent, e.g. a
pinned skill-runner running a gated skill) → proceed, SILENT.
3. model-routing.test.sh block 12: replace the whole block comment (spike
lines included) with: skill-runner children pinned opus since BDR-150
(Fable is the advisor, never a dispatch target). Assertions: `has
client-handover-writer.md 'model: "opus"'`, `has lib/model-gate.md
'model: "opus"'` (no backtick in the needle; the string is absent from
model-gate.md today), `has lib/model-gate.md 'fixed at spawn'`, and ONE
repo-wide census: `git -C "$R" grep -nE 'model ?[:=] ?"fable"' --
agents skills lib ':!lib/tests'` must print nothing (ko with the hits).
4. effort-routing.test.sh ~:224-225: following the onboard idiom
(:220-222): count the lines of client-handover-writer.md holding
`model: "opus"`; require `-eq 7` and that the same 7 carry
`effort="high"` (equal counts).
5. Tracking (closing step, not the executor): TODO.md Actionable line for
lib/effort-shift.md:30-32 (wiring point 5 still names fable runners) +
README.md:109, :134, plan-challenger.md:111,:115, challenge-plan.md:48,
:51, skills/tour/SKILL.md:83 → the doctrine run (next); TODO.md:151
residual ("explicit Agent(model:"fable") pins … fail w/o credits")
rewritten: now an opus runner failure marks opus down in the breaker
and demotes main to the sonnet stand-in for the cooldown (accepted
residual, BDR-150).
@@ -0,0 +1,280 @@
# PLAN — router-no-fable (Fable = advisor, Opus = strongest auto-route)
## CONTEXT
- register.ts DEFAULT_CONFIG (~:290-305): models {haiku, sonnet, opus,
fable}; tiers best ['fable','opus','sonnet'], big ['opus','fable',
'sonnet'], work ['sonnet','opus'], cheap ['haiku','sonnet']; fallback
['fable','opus','sonnet','haiku'] (rank = index, best first).
- Tiers and fallback are machine keys: the tracked routing.json contributes
only phases, skills and agents (routingTables ~:887); the override
`~/.claude/model-router.json` is absent on this machine. So the shipped
policy lives in DEFAULT_CONFIG.
- mergeRouting (~:608-625) logs "tiers.best does not lead the fallback
chain; rank comes from the fallback list alone" when tiers.best[0] !==
fallback[0].
- pickFallback/withEveryAlias (~:473-502): every `models` alias ends up
ranked; one missing from the chain is appended LAST with a log. So fable
must stay in `fallback`, at its head (true capability rank).
- askTier (BDR-135): tierHead = head of `best`; with best headed by opus
the dialog ("Fable" / "Opus instead" / stop, TIER_HEAD hardcoded) would
ask before every opus route. routing.json sets askTier.
- inTier (~:3857): an agent moves UP from its frontmatter alias to the
first available model of its tier only if that model is the head or ranks
above it; else frontmatter kept + "tier … down" log. With best/big =
[opus, sonnet] and opus down: sonnet ranks below opus → frontmatter
(opus) kept. Today big-tier agents with opus down move UP to fable; after
this change they stay on opus frontmatter (by design: never below the
floor; the engine's own fallback applies). Main loop with opus down:
breaker fallback goes down the chain to sonnet (unchanged mechanism).
- effort-routing.test.sh tier_floor (~:56-60): for `best` it reads the
tier's 2nd alias as the agents' frontmatter floor (LRN-224, Fable credit
outage); for other tiers the head. Its flip-test fixture (~:94-110)
carries the old fable tiers.
- Test rig (register.test.ts): synthetic routing.json from baseRouting()
(phases only, ~:87); tiers come from DEFAULT_CONFIG; the machine override
comes only from `fx.home` (HOME_FILE). 381 FABLE references; many tests
assume best is headed by fable.
## APPROACH
1. register.ts DEFAULT_CONFIG: `best: ['opus', 'sonnet']`, `big: ['opus',
'sonnet']`; models unchanged (fable kept); fallback unchanged
(['fable', 'opus', 'sonnet', 'haiku']). Comment on the tiers block: Fable
is ranked (hand picks, the advisor model) but never an auto-route target
(user 2026-11-16); a machine override may add it back to a tier.
2. register.ts mergeRouting warning: fire only when the head of `best`
ranks BELOW the head of another tier in the fallback chain (a tier
"better" than best: a real misconfiguration), not merely when it is not
fallback[0]. Wording: `model-router: tiers.best head <alias> ranks below
tiers.<name> head <alias> in the fallback chain`. Use keyWord() for the
names. Defaults: best opus, big opus, work sonnet, cheap haiku → no log.
3. routing.json: `"askTier": false` (replaces "best"). The askTier code
stays (a machine override with `askTier: "best"` and fable back in best
still works); TIER_HEAD 'Fable' label hardcoded = residual (dormant).
4. effort-routing.test.sh: tier_floor drops the best-tier special case
(floor = tier head for every tier); its comment says why (best is headed
by opus since 2026-11-16, LRN-224's credit floor no longer applies). The
flip-test fixture moves to the new defaults (best ['opus','sonnet'], big
['opus','sonnet']) and still proves the readers reject the wrong
verdicts.
5. register.test.ts:
a. Measure first: apply 1-3, run `claude plugin test mods/model-router`,
count red tests.
b. If more than 25 are red: add a rig default so existing mechanics
tests keep a 3-deep tier set: when a fixture gives no `home` and does
not set `shippedTiers: true`, newWorld writes HOME_FILE with
`{ tiers: { best: ['fable','opus','sonnet'], big: ['opus','fable',
'sonnet'] } }` (machine override; nothing else in it). Tests that
assert the override's absence (source word, askTier machine value,
`fx.home` users) get `shippedTiers: true` or merge their `home` with
these tiers, case by case, without changing what they assert. If 25
or fewer are red: update each red test's expectation to the new
defaults directly.
c. New tests, all on the SHIPPED defaults (`shippedTiers: true`, no
override): (i) typed plan, judge and audit rows route to opus (main
and spawn); (ii) with opus marked down, a best-tier and a big-tier
route never choose fable (main falls to sonnet via the breaker; a
big-tier rowed agent keeps its opus frontmatter, "tier … down" log);
(iii) a /model hand pick of fable, then a rate limit on fable → main
moves to opus (fable ranks above opus); (iv) boot logs no "does not
lead" / "ranks below" line; (v) the warning still fires on a machine
override whose best head ranks below big's head (e.g. best
['sonnet'], big ['opus']).
d. Red-first: (i), (ii) and (iv) fail on the pre-change register.ts.
## EDGE CASES
- Machine override re-adding fable to a tier: honored (validated by
acceptTier against models).
- Hand pick of fable through the /model dialog: unchanged (BARE_ALIASES and
CHOICE_ALIASES keep fable).
- Sessions already on fable (settings model fable): breaker and probe
unchanged; phases route down to opus only per existing downgrade rules.
- askTier absent in a foreign routing.json: code default "best" now means
asking before opus routes; acceptable (only this repo's routing.json ships
the mod) and noted as residual.
## DISPOSITION
Amends BDR-123 (Fable via best-tier rows → no Fable auto-route; session
opus), BDR-135 (askTier off by config; code kept dormant), LRN-224 (2nd-alias
floor no longer applies: head = floor = opus). BDR-077 W1 Fable dispatch
pins handled by the next run (pins). Honors BDR-129-style single source:
the policy lives in DEFAULT_CONFIG, tracked.
## FILES
mods/model-router/hooks/register.ts, mods/model-router/hooks/register.test.ts,
mods/model-router/routing.json, lib/tests/effort-routing.test.sh.
## r2 (challenge r1: correctness CONCERNS(3), robustness CONCERNS(3), simplicity CONCERNS(2)) — SUPERSEDES APPROACH 2-5, EDGE CASES and DISPOSITION above
Landed: (a) the row Change dialog and /model labels change on shipped tiers
(fable heads no phase → dead option; opus heads best AND big → "opus
(best)", and targetPhase maps opus/xhigh to `plan`, judge unreachable)
(corr 1, rob 2, simp 2); (b) askTier is not dormant: `/route ask-tier on`,
a machine `askTier: "best"` or an absent key ask "Run it on fable?" and
"Opus instead" runs SONNET, gates included (corr 2, rob 1, simp 6); (c) the
mod runs live from this working tree: a routing.json `askTier: false` read
by OLD-code sessions on /clear or reload removes the Fable consent guard
while their old tiers still route to Fable (rob 4); (d) a rig default of
legacy tiers would test a config nobody ships and mask (a)/(b) (rob 3,
simp 3); (e) the warning reword is new scope (simp 1); (f) test (iv) is not
red-first, judge in (i) already opus (corr 3, simp 5); (g) flip fixture
must keep distinct heads (corr 8, rob 7, simp 4); (h) unranked `after` in
nextAvailable can display fable (corr 10).
User answers 2026-11-16: Fable leaves the row Change dialog
(CHOICE_ALIASES); /model keeps Fable, label stays "fable (custom)" (no
label code).
1. register.ts DEFAULT_CONFIG: tiers best ['opus','sonnet'], big
['opus','sonnet']; models and fallback unchanged (fable kept, fallback[0],
capability rank). Comment on the tiers block: Fable is ranked (hand
picks, advisor model) but never an auto-route target (user 2026-11-16);
a machine override may put it back in a tier.
2. register.ts mergeRouting: DELETE the "tiers.best does not lead the
fallback chain" check (log only, no consumer). No replacement warning.
3. register.ts CHOICE_ALIASES: ['opus', 'sonnet', 'haiku'] (fable out of
the row Change dialog). BARE_ALIASES unchanged (fable stays in /model).
4. register.ts targetPhase (~:2834-2841, row Change dialog: model+effort →
phase): tie-break when several phases match the picked model and effort
= the row's CURRENT phase first if it matches, else the first match as
today. So an agent row on `judge` answered "opus, xhigh" stays `judge`.
5. register.ts tierHead (~:1177-1181): return undefined (no tier ask) also
when the head of `best` equals the head of `big` (the "instead" option
would not be a different model). So on shipped tiers no ask fires
whatever askTier says (routing.json, machine override, `/route ask-tier
on`); a machine override putting fable back at the head of best brings
the consent dialog back unchanged. routing.json is NOT edited (askTier
stays "best"): old-code sessions keep their Fable consent guard until
/reload-plugins. `shortcut:` comment at TIER_HEAD: the ask-tier feature
is inert on shipped tiers (Fable credit guard, BLK-030); remove it if
Fable never returns to a tier; harvested into TODO.md by the closing
step.
6. register.ts nextAvailable (~:1147-1151): when `after` is given and not
ranked (findIndex -1), return undefined instead of walking from the
chain's head (display-only fable leak).
7. effort-routing.test.sh: delete tier_floor; field_of (~:64) uses
tier_head; drop the duplicate assertion (~:123) and make the best-tier
floor assertion (~:122) expect the fixture's best head. KEEP the
synthetic flip fixture's distinct heads (fable-headed best, opus-headed
big) so a wrong-tier read still fails. Comment: best is headed by opus
since 2026-11-16, the agents' floor is the tier head for every tier.
8. register.test.ts rig: shipped tiers stay the default (DEFAULT_CONFIG).
New fixture flag `legacyTiers: true` → newWorld merges `{ tiers: {
best: ['fable','opus','sonnet'], big: ['opus','fable','sonnet'] } }`
UNDER fx.home (`{ tiers: LEGACY, ...fx.home }`) into HOME_FILE. Measure
the red tests after steps 1-6; for each red test:
- the test is about a 3-deep chain or Fable mechanics (breaker or
stand-in with fable, ask-tier dialog, hand pick of fable, Fable [1m],
fable efforts) → add `legacyTiers: true`, assertion unchanged;
- the test is about shipped behavior (row labels, Change dialog options,
/model labels, rows routed on defaults, noHome / env-less routing) →
update the expected value to the shipped tiers.
Tests that set HOME_FILE directly mid-test (:705, :1812, :1835, :2328,
:2791, :3392, :3735, :4410) keep what they assert: if they need legacy
tiers, include them in the HOME_FILE they write. Report the count per
bucket.
9. New tests on the SHIPPED defaults (no legacyTiers), main booted on OPUS:
(i) typed plan and audit rows route to opus (red-first: plan and audit
went to fable); (ii) with opus marked down (switchTo(OPUS, SONNET,
'auto') or the breaker), best and big routes never choose fable: main
on sonnet, a big-tier rowed agent keeps its opus frontmatter with the
"tier … down" log (assert the model only; the stand-in effort notch is
expected) (red-first); (iii) hand pick fable via the /model dialog, then
a rate limit on fable → main moves to opus; (iv) boot logs no "does not
lead" line (regression guard, not red-first); (v) askTier "best" in the
machine override on shipped tiers → no tier question, the audit gates
are not sent to sonnet (red-first); (vi) row Change dialog options are
opus/sonnet/haiku labels without fable, and an agent row on `judge`
answered opus + xhigh stays `judge` (red-first); (vii) bare /model
dialog still offers fable, labelled "fable (custom)".
EDGE CASES (real behavior):
- Opus outage: best/big agents keep their opus frontmatter and spawn on the
held opus (the gates fail, verify-secure-loop retries and escalates);
today they moved up to Fable. Accepted residual (no engine fallback key
in settings.json; LRN-224 hazard moves from fable to opus).
- A single opus outage now makes sonnet stand in for the head of best and
big (standInEffort notches the row's effort up).
- A session whose baseline is fable (native /model Everywhere, not a hand
pick) is routed by the tiers: best phases go to opus, or to sonnet with
opus held. Accepted (Fable is not an auto-route target).
- Rollout: the working tree is the live install. Open sessions keep old
code until /reload-plugins; routing.json is untouched so they keep the
Fable consent dialog meanwhile. Tell the user to /reload-plugins after
the merge.
DISPOSITION: amends BDR-123 (no Fable via rows; session opus), BDR-135
(ask-tier inert on shipped tiers by rule, kept for overrides), LRN-224
(floor = tier head for every tier). BDR-077 W1 Fable pins: next run.
FILES: register.ts, register.test.ts, lib/tests/effort-routing.test.sh
(routing.json dropped from scope).
## r3 (re-challenge r2: correctness CONCERNS(3 MAJOR), robustness CONCERNS(1 MAJOR)) — amends r2; final
1. r2 step 4 DROPPED: targetPhase already prefers the row's current phase
(register.ts:2836-2843). Residual: on shipped tiers a SKILL row that
answers opus + xhigh in the Change dialog lands on `plan` (run-holding)
rather than `judge`; agents unaffected in effect (plan/judge/audit all
route opus xhigh).
2. r2 step 5 REPLACED: `tierHead` returns undefined unless the alias at
the head of `best` is `fable` (the dialog text is fable-specific:
TIER_HEAD, "Run it on fable?"). So the ask-before-Fable dialog fires
only when an override puts Fable at the head of best, whatever `big`
says. Stored answers: `wantedModel` (slot tierChoice ~:1608) and
`spawnTier` (tierSpawn ~:3247) ignore a stored "instead" answer while
tierHead(st) is undefined. `/route ask-tier on|off` keeps writing the
flag; when tierHead is undefined its reply appends ` (inert: best is not
headed by fable)` and `/route show`'s ask-tier word reads `inert` in that
case. `shortcut:` comment at TIER_HEAD: the ask-before-Fable dialog only
runs when an override heads best with fable (BLK-030 credit guard);
remove the feature if Fable never returns to a tier.
3. register.ts doc comment example at ~:2802 ("fable (best)") updated to a
shipped label ("opus (best)").
4. Edit order: apply r2 steps 1, 2, 3, 6 and r3 step 2 in ONE pass on
register.ts before running anything (the tree is the live install: a
session started mid-edit must never see opus-headed best with the old
ask armed).
5. Test buckets (replaces r2 step 8's rule), for each red test after the
code change; report test NAMES per bucket:
a. SHIPPED (default): update the expected value to the shipped tiers.
Wins unless the assertion cannot hold on shipped tiers.
b. LEGACY: `legacyTiers: true`, assertion unchanged, ONLY when the
assertion needs a tier holding fable or a 3-deep chain (fable
breaker/stand-in, ask-before-Fable dialog, fable [1m] routing).
c. REWRITTEN: a test that answers the row Change dialog with
'fable (best)' (fable efforts loop ~:3058, upgrade toasts ~:3164,
~:3173, fableEfforts ~:4527 used at ~:4538, ~:4544): answer
'opus (best)' on shipped tiers (same [medium, high, xhigh, max]),
keep the test's intent (residual f: null phase ignored, file
without phases).
Shared constants used by both buckets (ROUTED ~:2814, STEP1 ~:6440,
TO_JUDGE ~:31) are split per bucket (e.g. ROUTED_LEGACY) rather than
moving a whole group. TO_JUDGE ('opus (big)') users go LEGACY.
newWorld throws when `legacyTiers` is combined with `noHome`, an empty
env, `home: 'broken'` or kinds that turn the router off (the override
cannot be read there; a silent shipped run would lie).
6. New tests (replace r2 step 9 (i) and (v); others stand):
(i) typed plan, judge and audit rows route to opus on shipped tiers,
main booted on OPUS (plan and audit red-first; judge a guard).
(v) two cases on shipped tiers with the machine override's askTier
"best": (v-a) an audit-row spawn (auditVerifier edit, ~:7162) with an
"Opus instead" answer queued → no ask, the answer left unconsumed, the
spawn on OPUS; (v-b) main booted on SONNET types a best row → no ask,
main on OPUS. Prove (v) red against the change WITHOUT r3 step 2 (a
scratch copy with steps 1-3, 6 only), not only against the pre-change
file. (viii) override heading best AND big with fable: the dialog asks
(fable alias at the head of best).
7. Residuals restated:
- Rollout: live from the FIRST edit on the checked-out branch (new
sessions load the tree); open old-code sessions keep their dialog for
interactive best-tier routes only (old big = [opus, fable, sonnet]
still sends judge spawns to Fable unasked while opus is held;
headless runs too). After the merge: /reload-plugins in every open
session.
- Fable-baseline session: best phases now demote it to opus (or sonnet
with opus held) only through downgradeCall, so `mainModelSwitch` and
the 120k cold-read cap apply (past either, main stays on Fable); on a
demotion, sessionPin pins general-purpose spawns to the Fable session
model.
- Opus outage: best/big agents spawn on the held opus (frontmatter
floor), the gates fail, verify-secure-loop retries once then
escalates. Main: sonnet stands in with the effort notch.
FILES (final): mods/model-router/hooks/register.ts,
mods/model-router/hooks/register.test.ts, lib/tests/effort-routing.test.sh.
README.md, USAGE.md and CHANGELOG through the doc-sync step.
@@ -0,0 +1,198 @@
# PLAN — advisor call points, run A (r4 after re-challenge)
Contract: .claude/tasks/contracts/2026-11-17-advisor-call-points-1130.md
Branch: feature/advisor-call-points (off develop)
## Why
User 2026-11-17 approved points 1 and 2 after transcript data: since /advisor
(2026-11-16 16:19Z) the main loop called the advisor 2 times in 3 skill runs
(served by Opus, 409k and 680k uncached input tokens each); 18 of 20 opus
sub-agents called it (19 calls, Fable, median 70k tokens, 1.46M total); 0 of 8
sonnet sub-agents. The doctrine of c3507ea ("main loop only") is inverted by the
data on both use and cost. Reverses BDR-150's "sub-agents do not" for the three
judgment agents.
## Files (5)
1. CLAUDE.global.md § Workflow, lines 81-85: replace the whole "- Stronger model
needed …" bullet with block A (verbatim; 8 lines, file 312 → 315, guard 320).
2. lib/effort-shift.md § Advisor (lines 101-110): replace the section body
(heading kept) with block B (verbatim). Nothing else in the file changes.
3. agents/plan-challenger.md § RULES: append block C as the last bullet of the
RULES list (before `## ORCHESTRATOR PROTOCOL`).
4. agents/verifier.md § RULES: append block D as the last bullet of the RULES
list (before `## ORCHESTRATOR PROTOCOL`).
5. agents/security-auditor.md § RULES: append block E as the last bullet of the
RULES list (before the next `## ` heading).
### Block A (CLAUDE.global.md)
```
- Stronger model needed (an approach to settle before building, a stuck
problem, a long task before calling it done) → the main loop calls
the advisor tool when it is listed (settings `advisorModel`, Fable,
set by /advisor), at least at the points of
`~/.claude/lib/effort-shift.md` § Advisor; plan-challenger, verifier
and security-auditor at most once, before the verdict; other
sub-agents do not. Fable is never routed or pinned: the router tops
out at opus (BDR-150).
```
### Block B (lib/effort-shift.md § Advisor body)
```
Fable runs as the advisor (settings `advisorModel`), never a route or pin
target (BDR-150). It is a server tool: the router cannot see or refuse it.
Main loop, at least at these points (for work outside them, see the
triggers in CLAUDE.global.md § Workflow):
1. Before settling an approach: ahead of writing a skill's plan (`/feat`,
`/bugfix`, `/ship-feature`).
2. When stuck: once per verify-secure run, at the first gate loop to fail
twice (floor, conformity, security, or a second structural failure),
before re-dispatching or escalating. At a cap the STOP diagnosis
reuses that advice and says it predates the last iteration. The
advice stays in the main loop: it feeds the main loop's own decision
(a contract micro-gate, an early escalation, the STOP diagnosis) and
never enters an executor brief.
3. Before proposing a merge (`gitflow finish`) or calling a long task
done.
Sub-agents: plan-challenger, verifier and security-auditor call it at most
once per dispatch, before their verdict; executors and every other
sub-agent do not, even when the tool is listed.
Advisor absent or erroring (Fable out of credits, for example) → proceed
as written. Advice is input, never consent: it waives no gate, cap or
guard; at a loop cap it feeds the STOP diagnosis.
```
### Block C (agents/plan-challenger.md)
```
- Advisor (when listed): at most one call, after drafting your findings
and before the verdict, whatever the harness prompt schedules; absent
or erroring → proceed. Advice may add or sharpen a finding. Advice
alone never drops or lowers one: a change rests on your own re-read,
cited at file:line.
```
### Block D (agents/verifier.md)
```
- Advisor (when listed): at most one call, after STEP 4 and before
STEP 5, whatever the harness prompt schedules; absent or
erroring → proceed. Advice may send you back to a criterion: a
resulting NOT-MET cites the file:line you read, ends with
`(advisor-prompted)` and counts in STEP 5 like any other. Advice adds
no gap outside the contract's criteria. Advice alone never clears a
gap and is never evidence for a MET: any change rests on your own
re-read or run (STEP 2).
```
### Block E (agents/security-auditor.md)
```
- Advisor (when listed): at most one call, after STEP 4 and before
STEP 5 and any REPORT write, whatever the harness prompt schedules;
absent or erroring → proceed. Advice may add a finding or raise a
severity, cited at a file:line you read. An added finding's rule/check
is `advisor:<STEP 3 class>`; a raised one keeps its own line, its
rule/check becoming `<rule>+advisor`, so it counts once. The severity
is that STEP 3 class's, which overrides the STEP 2 mapping for that
finding only; an added finding matching no class is REPORTED as LOW,
and a raise matching no class changes nothing. It enters STEP 5's
dedup and BLOCK(n) like any other, and PROOF ends with `; advisor <n>
added/raised`. It never removes, lowers or waives a finding from
semgrep, the checklist or STEP 4.
```
## Edge cases
- Each block's lines ≤ 80 columns (block A keeps the 2-space bullet indent).
- Blocks C-E sit inside the RULES list, keeping its blank-line-between-bullets
style if the list uses one.
- No other wording in the five files changes (wiring points, Limits, ask-tier,
`## Never` untouched).
## Tests
No hermetic test asserts this prose (grep lib/tests: none). Oracles are the
contract's grep criteria + full `make test`. The doctrine-citers census (T6,
lib/tests/doctrine-citers.test.sh:213-214) also scans CLAUDE.global.md, so block
A's `~/.claude/lib/effort-shift.md` § Advisor citation is checked once it sits
on one line (the extractor is per line; r4 keeps it on one line), and block
B's `CLAUDE.global.md § Workflow` citation too.
## Split (user 2026-11-17)
- Run A (this plan): doctrine + three judgment agents, 5 files.
- Run B: inline advisor call lines at the step sites (plan step of skills/feat,
skills/bugfix, skills/ship-feature; second-failure and cap sites in
lib/verify-secure-loop.md; the merge proposal), citing
`lib/effort-shift.md § Advisor`.
- Run C (point 3): advisor usage counter as a section of /memory-feedback
(user choice); dedupe usage rows by message.id, model from the
`advisor_message` iteration, main transcript vs subagents/*.jsonl.
- Stale citers for doc-sync / capitalize: README, USAGE, CHANGELOG
[Unreleased] advisor bullet, BUGS-FOUND d292911 residual, BDR-150 status,
LRN-294.
## Disposition
- amends BDR-150 (its "sub-agents do not" clause, c3507ea) by allowing the three
judgment agents one call; keeps "never routed or pinned".
- applies LRN-294 only partly: sub-agents get the tool, CLAUDE.global.md and a
harness prompt asking for "at least once before … and once before declaring
done"; blocks C-E say the one-call rule overrides it, but that is prose
against a harness instruction: logged as a BUGS-FOUND residual at capitalize.
- honors BDR-066/LRN-083: loop decisions stay in the main loop; advice is input.
## r3 changes (challenge round 1: correctness FATAL(2), robustness CONCERNS(3), simplicity CONCERNS(1))
- C1 BLOCKER oracle: contract criterion 2 counts STEP inside § Advisor only.
- C2 BLOCKER + R5: block E routes an advisor-added/raised finding into STEP 5's
merge and BLOCK(n), tagged `advisor-added` / `advisor-raised from <sev>` in
<why>; REPORT written after the advisor call (R6).
- R3: block D mirrors E (never clears NOT-MET, UNVERIFIABLE, FLOOR, out-of-scope;
may add a gap at file:line); C5: MET evidence defers to STEP 2.
- R4: block C "may add or sharpen, never drop or lower".
- S1 + C4: block A minimal: keeps its generic triggers, points to
`~/.claude/lib/effort-shift.md` § Advisor, no copied list.
- S4 + R1 + C8: block B = the approved points only. One stuck call per loop at
its second failure (structural failures included), the cap reuses it; "any
non-trivial change" dropped; done + merge one point.
- R2: second-failure advice stays in the main loop, never enters an executor
brief (verify-secure-loop "nothing else" briefs kept).
- S2: cost sentence and sub-agent evidence sentence moved out of block B (the
rationale goes to the BDR-150 amendment).
- R6 + C7: blocks C-E say "whatever the harness prompt schedules"; block B names
the residual.
- C6: main-loop calls served by Opus are explained by the /advisor output in
this conversation ("keeps Opus until /clear"); doctrine names the advisor by
`advisorModel`.
- S3 rejected in part: the advice-specific clauses in C and D stay, because
R3/R4 need them (they now carry new rules, not repeats).
## r4 changes (re-challenge: correctness CONCERNS(3), robustness CONCERNS(3), simplicity CONCERNS(1); no third round, these go to the CHALLENGE SUMMARY)
- RC1/RR1: block A keeps "`~/.claude/lib/effort-shift.md` § Advisor" on one
line so the per-line census extractor sees it; criterion 1 greps it.
- RC2: contract criteria 1-5 carry `EVIDENCE: pending` (gates.sh ERROR otherwise).
- RC3/RR2/RS2: block D: advice can only send the verifier back to a criterion;
a resulting NOT-MET is tagged `(advisor-prompted)` and counts in STEP 5; no
gap outside the criteria; advice alone never clears; no copied gap list.
- RR3/RC5/RC6/RS3/RR8: block E: rule/check `advisor:<STEP 3 class>` or
`<rule>+advisor`; severity = the matching STEP 3 class (overrides the STEP 2
mapping for that finding only); no matching class → REPORTED, non-blocking
(so one opinion cannot BLOCK, hence no /hotfix revert on opinion alone);
PROOF gets `; advisor <n> added/raised`.
- RR4: calls placed late: verifier/auditor after STEP 4 before STEP 5;
challenger after drafting findings.
- RS1/RR5/RC4: "advice alone never drops/lowers/clears": a change rests on the
agent's own re-read, cited.
- RR6: main loop stuck call once per verify-secure run; the STOP says the
advice predates the last iteration.
- RC7: block B points are a floor ("at least"), CLAUDE.global.md § Workflow
triggers cover work outside them.
- RS4: block B residual sentence dropped (BUGS-FOUND carries it); "whatever the
harness prompt schedules" kept (one verifier made 2 calls on 2026-11-16).
- RR7: live-install note: ~/.claude/CLAUDE.md and ~/.claude/agents are symlinks
into this repo, so the edits apply to every session as soon as written,
including this run's own verifier and security-auditor. Rollback:
`git restore` of the five files on the branch.
- Execution NEED-DECISION (internal, 2026-11-17): census read "§ Workflow
names" as heading "Workflow names" (T3 DANGLING). Block B line reworded so the
citation ends at "§ Workflow)". Agent RULES bullets sit tight under the
previous bullet (the lists are tight), accepted.
- Gate findings (security PASS + verifier CONFORME, 2026-11-17): block E r5.
A raise keeps its own line (rule/check `<rule>+advisor`) so STEP 5 dedup counts
it once; an added no-class finding is REPORTED as LOW; a raise with no class
changes nothing.
@@ -0,0 +1,84 @@
# PLAN — advisor-doctrine (BDR-150 follow-up)
## APPROACH
1. CLAUDE.global.md § Workflow: insert as a new bullet right after the
"Sub-agents: one task each…" bullet, wrapped ≤ 80 columns, the user's
text verbatim: "- Stronger model needed (an approach to settle before
building, a stuck problem, a long task before calling it done) → call
the advisor tool when it is listed (Fable, set by /advisor). Fable is
never routed or pinned: the router tops out at opus (BDR-150)."
2. lib/effort-shift.md:
a. wiring point 5: "(`general-purpose` `model="opus"`, `model: "opus"`
skill-runners) → explicit `effort=` on the Agent call (`xhigh` for
opus reviewers, `high` for skill-runners)." Rest unchanged.
b. Limits bullet: "…set the turn's effort only, never a model above the
session model: Fable on main comes only from a hand pick (`/model`,
picker), a typed `/route model=fable` or a machine override that puts
fable in a tier (no shipped tier holds it, BDR-150)."
c. ask-tier mention (~:92-94): "`/route ask-tier off|on` the ask before
a route lifts main or a rowed agent onto Fable (inert unless a
machine override heads `best` with fable)".
d. new section "## Advisor" placed before "## Never" (or before
"## Limits" if "## Never" is absent), ≤ 8 lines: Fable runs as the
advisor (settings `advisorModel`), never a route or pin target
(BDR-150). Call it before committing to an approach on non-trivial
work, when stuck (the `escalate` moment, before raising effort to
max), and before declaring a long task done. It is a server tool:
the router cannot see or refuse it. The main loop calls it; do not
assume a sub-agent has it.
3. lib/challenge-plan.md ~:48 "(Fable through its best-tier row)" → "(opus
through its best-tier row)"; ~:51 "the two merge gates sit on the
`audit` row, Fable with an opus floor" → "… on the `audit` row, opus".
4. agents/plan-challenger.md ~:111 "on Fable through its best-tier row" →
"on opus through its best-tier row"; ~:115 "sit on the `audit` row,
Fable with an opus floor" → "sit on the `audit` row, opus".
5. skills/tour/SKILL.md ~:83 "security-auditor (`audit` row: Fable, opus
floor)" → "security-auditor (`audit` row: opus)".
## EDGE CASES
- Do not touch lib/effort-shift.md's /model dialog paragraph (fable is
still offered there by hand, true).
- doctrine-citers census in make test: headings cited elsewhere must stay
intact; adding "## Advisor" changes no existing heading.
## DISPOSITION
Honors BDR-150 (Fable = advisor, never routed or pinned) and the user's
2026-11-16 wording choices. Amends nothing else.
## FILES
CLAUDE.global.md, lib/effort-shift.md, lib/challenge-plan.md,
agents/plan-challenger.md, skills/tour/SKILL.md.
## r2 (challenge r1: correctness CONCERNS(1), robustness CONCERNS(1), simplicity CONCERNS(1)) — amends APPROACH; final
User answers 2026-11-17: only the main loop calls the advisor (sub-agents
have the tool listed too: every challenger, gate and executor would send
its whole transcript to Fable outside the router's caps); add the fallback
"advisor absent or erroring → proceed as written"; wiring point 4 unchanged.
1. CLAUDE.global.md § Workflow, new bullet right after the "Sub-agents: one
task each…" bullet, text (user line, amended by the main-loop answer):
"- Stronger model needed (an approach to settle before building, a stuck
problem, a long task before calling it done) → the main loop calls the
advisor tool when it is listed (Fable, set by /advisor); sub-agents do
not. Fable is never routed or pinned: the router tops out at opus
(BDR-150)." Wrap ≤ 80 columns like the neighbouring bullets (2-space
continuation); the phrase "the advisor tool" stays on one line.
2. lib/effort-shift.md:
a. wiring point 5 as in APPROACH 2a.
b. Limits: "Fable on main comes only from a hand pick (`/model`,
picker), a typed `/route model=fable`, a phase naming `model: fable`
or a machine override that puts fable in a tier (no shipped tier or
phase holds it, BDR-150)." Keep "a typed `/route model=fable`" on one
line.
c. ask-tier as in APPROACH 2c; keep "inert unless a machine override"
on one line.
d. "## Advisor" placed right before "## Never": the APPROACH 2d text,
with "The main loop calls it; sub-agents do not, even when the tool
is listed. Advisor absent or erroring (Fable out of credits, for
example) → proceed as written."
3-5. As APPROACH 3-5. agents/plan-challenger.md: the second target spans
lines 115-116 ("…sit on the `audit` row, Fable with an" / "opus
floor.)"): replace across both lines → "…sit on the `audit` row,
opus.)".
6. Rollback: the five files are live machine-wide from the working tree;
if anything misbehaves, `git checkout develop -- <the 5 files>`. Do not
run gates mid-edit.
@@ -0,0 +1,176 @@
# PLAN — advisor call points, run B1 (r4)
Contract: .claude/tasks/contracts/2026-11-17-advisor-points-b1-1500.md
Branch: feature/advisor-points-b1 (off develop)
## Why
User 2026-11-17 "oui a, b et c dans la run B": outside the named points,
advisor use rested on judgment and under-fired. (a) the main loop's plan point
moves into lib/challenge-plan.md, wired into 12 skills (9 core + seo, geo,
web-validate packs), once per skill run; (b) the dispatched `analyzer` joins the
judgment agents; (c) trigger "before recommending a change to the doctrine, the
architecture or a public interface". Stuck point: inline at the verify-secure
loop sites, counting main-loop calls only. B2 (separate run): stuck trigger in
the gate bullets of skills/feat, bugfix, ship-feature, init-project; merge lines
(ship-feature STEP 9, release-candidate STEP 4); security-auditor severity
direction; file count settled there.
## Exact edit (deterministic)
The edits are the blocks below, applied by
/tmp/claude-1000/-home-bchanot-Documents-claude/4ba4524e-88fb-4f6c-a31d-fedd261f8925/scratchpad/b1/apply.py
(`python3 apply.py <blocks dir> <repo root>`; blocks dir = .../scratchpad/b1).
It asserts every anchor occurs exactly once and fails loudly otherwise.
Summary of what it does, by file:
1. CLAUDE.global.md § Workflow: the whole "- Stronger model needed … (BDR-150)."
bullet → block A (file 315 → 316 lines, guard 320).
2. lib/effort-shift.md § Advisor: item 1 (2 lines) → B1; the line " reuses that
advice and says it predates the last iteration. The" → B1b; after item 3
("…calling a long task\n done.") insert I; the "Sub-agents: …listed."
paragraph → B2.
3. lib/challenge-plan.md: after "— which is the point." insert H; before
"Dispatch THREE fresh" insert C; the 2-line CHALLENGE SUMMARY bullet in
§ OUTPUT → F.
4. lib/verify-secure-loop.md (inserts only): Dfloor after "then STOP + human
escalation with the rows."; Dconf after " CRITERIA table (the
contract-vs-realized diff)."; Dstruct after " A mute verifier is NEVER a
PASS."; Dsec after " `/route effort=max` (sticky, `/route clear` after).";
Dstruct after " auditor is NEVER a PASS."; G before "## Order invariant".
5. agents/analyzer.md § RULES: E after "- Do not modify files".
### Block A
```
- Stronger model needed (an approach to settle before building, a stuck
problem, a long task before calling it done, before recommending a change
to the doctrine, the architecture or a public interface) → the main loop
calls the advisor tool when it is listed (settings `advisorModel`,
Fable, set by /advisor), at least at the points of
`~/.claude/lib/effort-shift.md` § Advisor; dispatched plan-challenger,
verifier, security-auditor and `analyzer` at most once, before their
verdict or report; other sub-agents do not. Fable is never routed or
pinned: the router tops out at opus (BDR-150).
```
### Block B1
```
1. Before settling an approach: on the written plan, before the
challengers see it (`lib/challenge-plan.md`), at most once per skill run.
```
### Block B1b
```
reuses that advice and says whether it predates the last iteration. The
```
### Block I
```
Inside a skill run, the points above also cover the triggers of
CLAUDE.global.md § Workflow; no second call for the same recommendation.
```
### Block B2
```
Sub-agents, when dispatched: plan-challenger, verifier, security-auditor
and `analyzer` call it at most once per dispatch, before their verdict or
report; executors and every other sub-agent do not, even when the tool is
listed. The analyzer file loaded inline by the main loop follows the
main-loop points.
```
### Block H
```
The main loop's advisor call before the dispatch (below) is the costliest
single item: once per skill run.
```
### Block C
```
**Advisor first (main loop).** Before the first dispatch, with no main-loop
advisor call since the skill run started (so at most once per skill run, not
before a re-challenge), the main loop reads the `PLAN` file unless its full
text is already in this conversation, then calls the advisor when the tool
is listed (`lib/effort-shift.md` § Advisor). An answer that lands a real
flaw revises the `PLAN` file on disk before the dispatch, as plain plan
text: no advisor attribution, no "changes after review" section; the
summary's `Advisor:` row carries it (OUTPUT below). Absent or erroring →
dispatch as written.
The advice never enters a challenger brief: they stay blind.
```
### Block F
```
- a CHALLENGE SUMMARY: each BLOCKER raised → the named change that closed it;
anything `[deferred]`; any lens that failed to return; and an `Advisor:`
row, added to whatever summary template the caller prints: each plan
change an advisor answer drove, `called, no change`, or
`not called (absent | error | already called this run)`.
```
### Block Dfloor
```
A second UNMET with no main-loop advisor call since GATE 0 first ran →
the main loop calls it before the re-dispatch
(`lib/effort-shift.md` § Advisor); the answer stays here, never
in the dev brief.
```
### Block Dconf
```
A second ECARTS with no main-loop advisor call since GATE 0 first ran →
the main loop calls it before the re-dispatch
(`lib/effort-shift.md` § Advisor); the answer stays here, never
in the dev brief.
```
### Block Dsec
```
A second BLOCK with no main-loop advisor call since GATE 0 first ran →
the main loop calls it before the re-dispatch
(`lib/effort-shift.md` § Advisor); the answer stays here, never
in the dev brief.
```
### Block Dstruct
```
A 2nd structural failure with no main-loop advisor call since GATE 0
first ran → the main loop calls it before escalating
(`lib/effort-shift.md` § Advisor).
```
### Block G
```
Every cap or escalation STOP above: when the main loop consulted the advisor
since GATE 0 first ran, the STOP carries its answer and says whether it
predates the last iteration.
```
### Block E
```
- Advisor, when dispatched as a sub-agent: at most one call, after the last
TASKS or PROCESS step and before the OUTPUT, whatever the harness prompt
schedules; absent or erroring → proceed. Advice may point you back to
the code; every OUTPUT line rests on what you read, never on the advice
alone. Advice proposing a design or a fix counts only where the brief
asks for a fix.
```
## Edge cases
- Every new line ≤ 80 columns; every `§ Label` citation on one line followed by
`)` or `;` (census extractor: 6 × effort-shift § Advisor, 2 × CLAUDE.global.md
§ Workflow) — checked by script.
- Contract CHECKs 1-5 simulated on a scratch copy with apply.py: all equal EXPECT.
- Stuck-call unit counts main-loop calls only; plan point skipped when the main
loop already consulted the advisor in this skill run.
- lib/tests pin "NEVER a PASS" lines: unchanged.
## Tests
None added (prose). Oracles: contract greps; fast census
`bash lib/tests/doctrine-citers.test.sh`; full `make test`.
## Disposition
- amends BDR-150 (6ef3069): plan point in challenge-plan; analyzer joins; (c).
- honors LRN-294 / BUGS-FOUND residual: prose; run C measures.
- honors BDR-066 / LRN-083: advice stays in the main loop, never in an executor
or challenger brief, never attributed in the plan file.
- applies LRN-295 cost: at most one plan call per skill run, at most one stuck
call per verify-secure run, no second call for the same recommendation.
@@ -0,0 +1,173 @@
# Fix plan — gates.sh stray oracle + default timeout (hotfix)
Contract: .claude/tasks/contracts/2026-11-17-gates-label-timeout-2342.md
Branch: bugfix/gates-label-timeout. Files: lib/gates.sh, lib/tests/gates.test.sh.
## Root causes
1. `_absorb` (lib/gates.sh:86-98) opens a criterion only on
`^([0-9]+)\.[[:space:]]+(.*)$`. Any other label (`1b. sub`, `1.1 dotted`,
`2) paren`, an indented ` 2. sub`, `- sub`, `**2.** sub`) matches no
branch and is dropped as prose, but `_CUR` still points at the previous
criterion, so `_set_attr` lets the CHECK/EXPECT/EVIDENCE under it
overwrite that criterion's oracle. Criterion 1 with `CHECK: exit 1`
followed by a stray passing oracle yields VERDICT: MET (LRN-284; all six
shapes reproduced on a scratch copy).
2. `TIMEOUT="${GATES_TIMEOUT:-120}"` (lib/gates.sh:32) is per CHECK; the full
`make test` takes ~135 s, so a "full suite green" criterion goes NOT-MET
on timeout unless the caller exports GATES_TIMEOUT (contracts used
400/600/1200).
## Edit — lib/gates.sh (exact)
A. Line 32: `TIMEOUT="${GATES_TIMEOUT:-600}"`, with three comment lines
right above it:
```bash
# TIMEOUT is per CHECK and a run lasts their sum: the caller's own limit (a
# foreground tool call stops at 600 s) must cover it, else run it in the
# background. A killed run writes nothing back; the floor stays PENDING.
```
B. `_set_attr`: a comment line above the function, then a guard between the
`_CUR -lt 0` block and the assigning `case`:
```bash
# A second attribute on one criterion is an error, never an overwrite: it
# is what an oracle under a label the parser missed looks like (LRN-284).
_set_attr() { # _set_attr <CHECK|EXPECT|EVIDENCE> <value> <lineno>
if [ "$_CUR" -lt 0 ]; then
_err "$1 at line $3 belongs to no criterion"
return 0
fi
local seen=""
case "$1" in
CHECK) seen="${_CHECK[_CUR]}" ;;
EXPECT) seen="${_EXPECT[_CUR]}" ;;
EVIDENCE) [ "${_EVLINE[_CUR]}" = 0 ] || seen=yes ;;
esac
if [ -n "$seen" ]; then
_err "second $1: at line $3 in criterion ${_ID[_CUR]}"
return 0
fi
case "$1" in
```
C. `_absorb`: new branch right after the criterion branch, before ABANDON:
```bash
elif [[ "$1" =~ ^[0-9] ]]; then
_err "malformed criterion label at line $2 (want \`N. text\`)"
_CUR=-1
```
It covers the case B cannot: a digit label after a MANUAL criterion
(no attribute yet) would otherwise lend it the stray oracle. The comment
above `_absorb` gains: "A digit-led line that is not `N. text` (`1b.`,
`1.1`, `2)`) is rejected and orphans what follows, like a duplicate id."
D. `main`: when no criterion parsed, the die message carries the first
parse error, so an all-malformed block (`1) a`, `2) b`) still names its
line:
`main`'s locals become `local mode="$1" file="$2" first`, and the
two-line `[ "${#_ID[@]}" -gt 0 ] || _die "no numbered criteria …"`
becomes:
```bash
if [ "${#_ID[@]}" -eq 0 ]; then
first="${_ERRORS[0]:+; ${_ERRORS[0]}}"
_die "no numbered criteria under ## ACCEPTANCE CRITERIA$first"
fi
```
Any `_ERRORS` entry already makes the verdict ERROR rc 2 and executes
nothing (existing "malformed ledger executes nothing" case).
Scans done on all 90+ .claude/tasks/contracts/*.md: no unindented digit-led
non-criterion line and no criterion with a repeated attribute; `gates.sh
status` verdicts identical before/after on every contract (scratch copy).
## Edit — lib/tests/gates.test.sh (exact)
1. Section "fail-closed execution", right after
`has "timeout recorded" "NOT-MET timeout=1s"`:
```bash
# The default must outlast the full suite (~135 s on 2026-11-16): at 120 s
# a "full make test green" criterion went NOT-MET on the timeout alone.
LAST="$WORK/default-timeout.md"
printf '## ACCEPTANCE CRITERIA\n1. manual\n' > "$LAST"
out="$(env -u GATES_TIMEOUT bash "$GATES" status "$LAST" 2>&1)"
if [[ "$out" == *"timeout 600s"* ]]; then
ok "default timeout 600s"
else
bad "default timeout 600s" "status did not print timeout 600s"
fi
```
2. Section "parse strictness", right after the "duplicate orphans what
follows" case (its closing `EOF`):
```bash
# An oracle under a label the parser does not read as `N. text` must never
# overwrite the previous criterion's: criterion 1 fails, the stray oracle
# passes, a false MET (LRN-284). A digit-led label is rejected by name;
# any other shape trips the second-attribute guard when the previous
# criterion already has that attribute (after a manual one it does not).
gate "1b. label rejected" run "malformed criterion label at line 6" 2 <<'EOF'
## ACCEPTANCE CRITERIA
1. real
CHECK: exit 1
EXPECT: x
EVIDENCE: pending
1b. sub
CHECK: echo y
EXPECT: y
EVIDENCE: pending
EOF
gate "1.1 label rejected" run "malformed criterion label at line 3" 2 <<'EOF'
## ACCEPTANCE CRITERIA
1. first
1.1 dotted
EVIDENCE: pending
EOF
gate "no valid label" run "malformed criterion label at line 2" 2 <<'EOF'
## ACCEPTANCE CRITERIA
2) paren
EOF
gate "indented label: second CHECK" run "second CHECK: at line 7" 2 <<'EOF'
## ACCEPTANCE CRITERIA
1. real
CHECK: exit 1
EXPECT: x
EVIDENCE: pending
2. sub
CHECK: echo y
EXPECT: y
EVIDENCE: pending
EOF
gate "bullet label: second EVIDENCE" run "second EVIDENCE: at line 9" 2 <<'EOF'
## ACCEPTANCE CRITERIA
1. real
CHECK: exit 1
EXPECT: x
EVIDENCE: pending
- sub
CHECK: echo y
EXPECT: y
EVIDENCE: pending
EOF
```
(Plan text is indented 3 for the list; in the file every heredoc body
line starts at column 0 exactly as in the existing cases, the oracle
attributes indented 3 spaces.)
## Residual (accepted)
- Any label branch C misses (indented ` 2.`, `- `, `**2.**`) after a MANUAL
criterion still lends it the stray oracle: that row turns MANUAL into
MET/NOT-MET on an unrelated oracle. No failing oracle is overwritten.
- `ABANDON: 1b …` parses as id 1 (gates.sh:90 regex): pre-existing, same
class, logged to TODO, not fixed here.
- lib/verify-secure-loop.md:46-47 lists ERROR causes as examples; it already
omits "no numbered criteria" and "ABANDON names unknown criterion", so the
two new causes do not make it newly stale. Logged to TODO (complete the
list), not a third file here.
- ~/.claude/lib is a symlink to this repo's lib: an in-flight contract in
another repo with a repeated attribute or a digit-led prose line now goes
ERROR (fail-closed, names the line).
## Out of scope
lib/design-tool-gate.sh:70 (TODO:90, deferred by its own text). The test
helper's own `${GATES_TIMEOUT:-120}` stays (fast fixtures only).
@@ -0,0 +1,178 @@
# Feat plan: advisor usage section in /memory-feedback (Run C, TODO:18)
## Why
LRN-295 measured advisor use by hand (per caller, model, uncached input) and named Run C to
automate it. User choices 2026-11-19 [gated]: a section of FEEDBACK.md written by `reader.ts
apply`; sub-agents per agent type; all projects summed, no repo in the table; window = since
the last run; a retention note when the window exceeds 7 days; a shape-drift line in place of
a false zero.
## Disposition
- honors LRN-295 (the method), with one correction: a call = one served advisor iteration, i.e.
one `message.usage.iterations[]` entry with `type == "advisor_message"` (model from that entry's
`model`, tokens = its `input_tokens`). A `server_tool_use` block named `advisor` with no
iteration is NOT a call: on real transcripts 147 blocks vs 141 iterations; the 6 gaps are
requests that never ran (re-issued next message) or an `advisor_tool_result_error`. Usage rows
repeat once per content block → dedupe by `message.id`.
- probe 2026-11-19 over all 1095 transcripts (136 calls then): 0 advisor iterations with
cache_read/cache_creation tokens, so `input_tokens` is the whole input; rows sharing an id
always carry identical advisor iterations, so first-seen is exact; no `isSidechain` row in a
main transcript; no advisor row outside the two path shapes; every meta `agentType` today is a
global or built-in agent name (general-purpose, plan-challenger, verifier, …).
- honors LRN-267: only `type == "assistant"` records count (blob replays and tool results never
do); sub-agent transcripts = `<session>/subagents/agent-<id>.jsonl`, meta beside it
(`agent-<id>.meta.json`, field `agentType`).
- honors BDR-140: FEEDBACK.md stays local (~/.claude/memory-feedback, never git); the section
adds no repo name, slug, path or prompt text: callers are validated agent type strings or two
fixed labels, models validated id strings. A project-scoped agent's own name would appear
verbatim (none exists today).
- honors BDR-100: thresholds.ts untouched; no new gate.
- global code limits (our code): ≤ 25 logic lines/function, ≤ 80 cols, ≤ 5 params, ≤ 5 locals
(a destructured name counts as a local). Unexported helpers are allowed and expected; the
exported names below are final.
## Files
1. lib/memory-feedback/advisor.ts (new)
2. lib/memory-feedback/advisor.test.ts (new)
3. lib/memory-feedback/reader.ts — `commit()` appends the section
4. lib/memory-feedback/reader.test.ts — the apply test asserts the section
5. skills/memory-feedback/SKILL.md — STEP 5 shows it
## advisor.ts — exported API (names final)
```ts
// lib/memory-feedback/advisor.ts: advisor usage read from Claude Code
// transcripts (Run C, LRN-295): served calls and input tokens per caller
// and model, deduped by message.id, for the FEEDBACK.md section.
export type Use = { caller: string; model: string; calls: number; input: number }
export type Tally = { uses: Use[]; unparsed: number; files: number }
export type Source = { file: string; caller: string }
export const MAIN = 'main loop'
export const UNKNOWN_AGENT = 'sub-agent (unknown)'
export const RETENTION_DAYS = 7
export function transcriptsOf(projects: string, from: number): Source[]
export function callerOf(jsonl: string): string
export function advisorUsage(projects: string, from: number, to: number): Tally
export function compact(n: number): string
export function renderAdvisor(t: Tally, from: number, to: number): string
export function advisorSection(projects: string, from: number, to: number): string
```
Suggested private split (names free): a directory lister that never throws, a per-file line
reader that returns the counted records, a tally step for one record, the sort comparator.
Behaviour:
- `transcriptsOf`: every directory read is wrapped (`readdirSync`/`lstatSync` in a try; an
unreadable or vanished directory or file is skipped, never thrown). `projects` missing → `[]`.
For each entry of `projects` that is a real directory (`lstat`, symlinks skipped): every
regular `*.jsonl` file directly inside → caller `MAIN`; for each real sub-directory `<session>`,
its `subagents` entry when it is a real directory (lstat), every regular `agent-*.jsonl` inside
→ caller `callerOf(file)`. A file whose `mtimeMs <= from` is skipped (a small saving: it can
hold no row in the window; the substring pre-filter below is what keeps the scan cheap).
- `callerOf`: lstats the sibling `<name without .jsonl>.meta.json` first: not a regular file
(symlink, FIFO, dir) or larger than 64 KiB → `UNKNOWN_AGENT`; else reads it; its `agentType` when a string
matching `/^[A-Za-z0-9_.:-]{1,64}$/`, else `UNKNOWN_AGENT` (missing file, unparsable JSON,
non-object, bad type: never throws).
- `advisorUsage`: one `seen: Set<string>` of message ids across all files, one tally
`Map<string, Use>` keyed `caller + '\t' + model`, one `unparsed` counter, `files` = the number
of sources `transcriptsOf` returned. Per source file
(read in a try: an unreadable file is skipped): split lines; a line is parsed only when it
contains `advisor_message` (pre-filter); JSON errors and non-objects skipped. A record is
considered when `type === 'assistant'`, `Date.parse(timestamp)` is in `(from, to]`, and
`message.id` is a non-empty string not yet in `seen` (then added). For each element of
`message.usage.iterations` (array, else none) with `type === 'advisor_message'`: model = its
`model` when a string matching `/^[A-Za-z0-9._:-]{1,80}$/`, else `'unknown'`; calls += 1;
input += `input_tokens` when a non-negative safe integer, else 0. A considered record whose
`JSON.stringify(message.usage ?? null)` contains `advisor_message` but which yielded no call
→ `unparsed += 1` (shape drift; text that merely mentions the word is not in `usage`).
`uses` sorted: `MAIN` first, then calls descending, then caller, then model ascending.
- `compact(n)`: `n < 1000` → `String(n)`; `n < 999950` → `(n / 1e3).toFixed(1) + 'k'`; else
`(n / 1e6).toFixed(1) + 'M'` (so `999950` prints `1.0M`, never `1000.0k`).
- `renderAdvisor(t, from, to)`: lines, joined with `\n`, ending with `\n`:
1. `## Advisor usage (<from> → <to>)`, `<from>` = `all on disk` when `from === 0`, else the
UTC day `YYYY-MM-DD` (`new Date(ms).toISOString().slice(0, 10)`, as metrics.ts `day`);
`<to>` = that day of `to`.
2. blank line.
3. only when `from > 0` and `to - from > RETENTION_DAYS * 86400000`: the line
`Transcripts kept 7 d: calls before <day(to - 7 d)> may be missing.` then a blank line.
4. body: when `t.uses` is empty: `t.files === 0` → `No transcript modified since <from>
under the projects dir: check the path.` (`<from>` as in the heading); else `t.unparsed > 0`
→ the drift line `<t.unparsed> transcript lines mention advisor_message, none parsed: check
the transcript shape.`; else `No advisor call in the window.`. Otherwise the table,
followed (blank line between) by the same drift line when `t.unparsed > 0`:
```
| caller | model | calls | input tok |
|---|---|---|---|
| main loop | claude-fable-5-2 | 14 | 3.4M |
| total | | 41 | 5.1M |
```
(`input tok` via `compact`; the total row sums calls and input).
- `advisorSection(projects, from, to)`: first normalises `from` (outside the try, pure
arithmetic): a finite number in `[0, to]`, else `0` (state.json is hand-editable: `1e999`,
`1e17` or `NaN` must not reach `toISOString`). Then `renderAdvisor(advisorUsage(projects, f,
to), f, to)` in a try; on any throw returns `## Advisor usage (<from> → <to>)` (same dates), a blank
line and `Unavailable: transcripts unreadable.` (fixed text: an error message could carry a
path), ending with `\n`. Never throws.
## reader.ts
`commit()` gains no local (it has 5: `fresh, m, v, next, feedback`): the section call reads the
old `lastRun` inline, before any write:
```ts
const feedback = renderFeedback(m, v, now) + '\n' +
advisorSection(p.projects, readState(stateOf(p)).lastRun, now)
```
(import `advisorSection` from `./advisor.ts`). The order stays as today: the scan runs while
`feedback` is built, before `appendRows`/`writeState`/`writeSafe`; a throw inside is caught by
`advisorSection`; a kill during the scan leaves nothing written, so a rerun is clean. The
section goes into FEEDBACK.md and the printed output (NEW lines still follow it).
## SKILL.md STEP 5
The sentence "It prints FEEDBACK.md: show the gate lines (`Post-fix prompt asks: k/20` included:
actions wait for 20 post-fix asks) and the Actions list to the user." becomes "It prints
FEEDBACK.md: show the gate lines (`Post-fix prompt asks: k/20` included: actions wait for 20
post-fix asks), the Actions list and the `## Advisor usage` table (advisor calls since the last
run per caller and served model) to the user." Wrapped ≤ 80 cols like the file, with the
backticked span `` `## Advisor usage` `` kept whole on one line (contract CHECK 3 greps it).
## Tests
advisor.test.ts (bun:test, fixtures in `fs.mkdtempSync(path.join(os.tmpdir(), 'mf-adv-'))`,
removed in afterAll, like reader.test.ts):
1. main transcript: two assistant rows sharing one `message.id`, one advisor iteration
(model claude-fable-5-2, input_tokens 1500) → one `main loop` row, calls 1, input 1500.
2. a row outside the window (timestamp ≤ from) and one after `to` → not counted.
3. a `user` record and a torn line, both containing `advisor_message` → ignored.
4. one message with two advisor iterations → calls 2.
5. iteration without `model` → model `unknown`.
6. sub-agent `agent-a1.jsonl` + meta `{"agentType":"verifier"}` → caller `verifier`;
`agent-a2.jsonl` without meta and `agent-a3.jsonl` with `agentType: "../x"` →
`sub-agent (unknown)`.
7. a transcript whose mtime ≤ from (`fs.utimesSync`) → skipped even with in-window rows.
8. missing projects dir → `{ uses: [], unparsed: 0, files: 0 }`; `advisorSection` on it →
heading + the `No transcript modified since … check the path.` line; a projects dir with one
in-window transcript holding no advisor row → `No advisor call in the window.`
9. render: `from 0` → `all on disk`; `compact` 999 → `999`, 1500 → `1.5k`, 999950 → `1.0M`,
2500000 → `2.5M`; total row sums calls and input; sort order (main loop first, then calls
desc).
10. the rendered section never contains the fixture's project slug or its path.
11. a message with a `server_tool_use` block named `advisor` and no `advisor_message` iteration
(and no usage mention) → 0 calls, `unparsed` 0.
12. shape drift: an in-window assistant record whose `usage` holds `advisor_message` in a shape
the reader does not parse (e.g. `usage.advisor_message: {...}` with no `iterations`) →
`unparsed` 1, and the render prints the `none parsed` line instead of the plain zero.
13. retention: `from = to - 10 d` → the `Transcripts kept 7 d: calls before <day> may be
missing.` line; `from = to - 3 d` and `from = 0` → no such line.
14. an unreadable sub-directory (`chmod 000` on a fixture dir, mode restored in a try/finally
inside the test itself; skip the assertion when running as root) → still returns the other
files' calls, no throw.
15. `advisorSection` with `from = Infinity`, `from = 1e17` and `from = NaN` → heading `all on
disk`, never throws.
16. drift under a table: one parsed call plus one drift record → the table, then the drift line.
17. `callerOf` with a meta that is a symlink (to a valid meta elsewhere) → `sub-agent (unknown)`.
reader.test.ts: the existing apply test (or one new apply test on the same fixture) asserts the
output and FEEDBACK.md contain `## Advisor usage`.
## Edge cases
- `from` = state.lastRun = 0 on a first run → everything still on disk, heading `all on disk`.
- Huge files (largest 63 MB, 1.1 GB total): substring pre-filter before `JSON.parse`.
- A message id seen in two files (never seen in the probe) counts once.
RISK: low — read-only reporting added after the existing FEEDBACK body; the labelling path and
its write order are unchanged.
@@ -0,0 +1,190 @@
# Bugfix plan: DEGRADED read off the wrong line (BUGS-FOUND:134 + TODO:13)
## DIAGNOSIS
BUG: three gate readers teach DEGRADED as a value of the `SECURITY — VERDICT:` line.
ROOT CAUSE: agents/security-auditor.md OUTPUT (:133-134) prints
`SECURITY — VERDICT: PASS | BLOCK(n) | ERROR(<reason>)`; DEGRADED appears only on the
`TOOL:` line (`ABSENT (DEGRADED — checklist only; install: make plugin)`). The parse
lists in lib/verify-secure-loop.md:111-128, agents/security-auditor.md:184-192 and
skills/hotfix/SKILL.md:182-183 end their parse at a terminal `PASS` bullet and list
`DEGRADED` as a sibling value of the VERDICT line. A reader parsing the VERDICT line
never sees it: a DEGRADED scan reads as a clean PASS (the hotfix SECURITY summary field,
the feat/bugfix end-of-run skip, the "surface the checklist + recommend make plugin"
step never fires). A PASS with no `TOOL:` line is not named a structural failure, so it
also reads as non-DEGRADED.
EVIDENCE: OUTPUT template vs the three parse lists; B3 STEP 6 opus review.
PRIOR: LRN-300 (a rule keyed on a gate verdict names the line its qualifier prints on) —
applied to the three readers and to lib/effort-shift.md item 3, the canonical skip rule.
The auditor's output format stays unchanged (no parser contract change).
BLAST RADIUS: the three readers + lib/effort-shift.md:124 ("security PASS (not
DEGRADED)" names no line). agents/security-auditor.md STEP 1 (:44-48) already puts
DEGRADED on the `TOOL:` line: untouched. feat/bugfix already name the TOOL line
(51f343f): untouched, now locked. README:84 / USAGE / CHANGELOG cite no parse list:
untouched (doc-sync re-checks). audit-delta:271, tour:156, onboard:549 say "semgrep
ABSENT → DEGRADED" (audit mode, non-blocking): untouched. a11y/guardrails/ship-feature/
init-project inherit lib/verify-secure-loop.md (their "PASS → STEP n" lines point at it).
Rejected alternative: change the auditor to print `VERDICT: DEGRADED` — breaks every
`PASS | BLOCK(n)` parser and the PROOF rule; the logged fix direction is the reader side.
A DEGRADED BLOCK needs no own sentence: the BLOCK bullet handles every BLOCK.
## FIX PLAN (exact text; each `old` occurs exactly once in its file)
1. lib/verify-secure-loop.md — the PASS bullet reads the TOOL line; the old
DEGRADED bullet is deleted.
### Block vsl-pass-old
```
- `PASS` → done, proceed to commit.
```
### Block vsl-pass-new
```
- `PASS` → read the `TOOL:` line first: DEGRADED (semgrep absent) shows
there, never on the VERDICT line; a PASS with no `TOOL:` line is a
structural failure (below). Then done, proceed to commit; a DEGRADED
PASS also surfaces the checklist result + recommends `make plugin`
(the tool's absence never blocks).
```
### Block vsl-degraded-old
```
- `DEGRADED` (semgrep absent) → does NOT block on the tool's absence; surface
the checklist result + recommend `make plugin`. A DEGRADED run that still
BLOCKs (grep-caught secret/injection) blocks like any other.
```
(replaced by nothing: the three lines are removed)
2. agents/security-auditor.md — same shape.
### Block aud-pass-old
```
- `PASS` → proceed (to commit / next step).
```
### Block aud-pass-new
```
- `PASS` → read the `TOOL:` line first: DEGRADED (semgrep absent)
shows there, never on the VERDICT line; a PASS with no `TOOL:` line
is a structural failure (below). Then proceed (to commit / next
step); a DEGRADED PASS also surfaces the checklist result +
recommends `make plugin` (the tool's absence never blocks).
```
### Block aud-degraded-old
```
- `DEGRADED` (semgrep absent) → does NOT block; surface the checklist
result + recommend `make plugin`. A DEGRADED BLOCK (grep-caught
hardcoded secret etc.) blocks like any other.
```
(removed)
### Block aud-struct-old
```
unparsable, crash, PASS without PROOF) → retry ONCE fresh; 2nd
structural failure → human escalation. A mute auditor is never a PASS.
```
### Block aud-struct-new
```
unparsable, crash, PASS without PROOF or without `TOOL:` line) →
retry ONCE fresh; 2nd structural failure → human escalation. A mute
auditor is never a PASS.
```
3. skills/hotfix/SKILL.md
### Block hot-pass-old
```
- `PASS` (or `DEGRADED` with no BLOCK) → proceed to commit.
```
### Block hot-pass-new
```
- `PASS` → read the `TOOL:` line first: DEGRADED (semgrep absent)
shows there, never on the VERDICT line; a PASS with no `TOOL:` line
is a structural failure (below). Then proceed to commit; a DEGRADED
PASS sets the summary's SECURITY field to `DEGRADED (checklist only)`.
```
### Block hot-struct-old
```
- Structural failure (mute / unparsable / no VERDICT line) → treat as a
failed gate: retry ONCE fresh; a 2nd structural failure → revert +
escalate. A mute auditor is never a PASS.
```
### Block hot-struct-new
```
- Structural failure (mute / unparsable / no VERDICT line / PASS with
no `TOOL:` line) → treat as a failed gate: retry ONCE fresh; a 2nd
structural failure → revert + escalate. A mute auditor is never a
PASS.
```
4. lib/effort-shift.md § Advisor item 3 — name the line (LRN-300).
### Block eff-old
```
`skipped (gates clean on first pass)`. A skipped call discharges
```
### Block eff-new
```
`skipped (gates clean on first pass)`; DEGRADED shows on the
auditor's `TOOL:` line. A skipped call discharges
```
5. lib/tests/loops-light.test.sh — regression locks. Single-line fragments with the
file's own `tf`/`tn` (LRN-093: a clause spanning lines → lock a distinctive single-line
fragment), double quotes with escaped backticks (the file's idiom). The section lives
here, not in security-auditor.test.sh, so one section locks this bug across its five
files (that file's `tn` is ERE: the parenthesised strings would match vacuously there).
### Block t-vars-old
```
HSKL="$REPO/skills/hotfix/SKILL.md"
```
### Block t-vars-new
```
HSKL="$REPO/skills/hotfix/SKILL.md"
AUD="$REPO/agents/security-auditor.md"
EFF="$REPO/lib/effort-shift.md"
```
### Block t-locks-old
```
echo ""
echo "loops-light structure locks: $PASS pass, $FAIL fail"
```
### Block t-locks-new
```
echo "── DEGRADED on the TOOL line, feat/bugfix skip (BUGS-FOUND:134) ──"
for f in "$FSK" "$BSK"; do
n=$(basename "$(dirname "$f")")
tf "$n skip not DEGRADED" "$f" "security PASS (not DEGRADED),"
tf "$n skip first attempt" "$f" "each on its first attempt;"
tf "$n skip out of view" "$f" "a verdict no longer in view runs the call."
tf "$n skip names TOOL" "$f" "auditor's \`TOOL:\` line, beside a PASS."
done
tf "effort-shift names TOOL" "$EFF" "auditor's \`TOOL:\` line. A skipped call"
for f in "$INC" "$AUD" "$HSKL"; do
n=$(basename "$(dirname "$f")")/$(basename "$f")
tf "$n PASS reads TOOL" "$f" "\`PASS\` → read the \`TOOL:\` line first"
tf "$n DEGRADED off VERDICT" "$f" "never on the VERDICT line;"
tf "$n no TOOL structural" "$f" "a PASS with no \`TOOL:\` line"
tf "$n structural (below)" "$f" "structural failure (below)"
tn "$n DEGRADED no verdict" "$f" "\`DEGRADED\`"
tn "$n DEGRADED no branch" "$f" "DEGRADED (semgrep absent) →"
done
echo ""
echo "loops-light structure locks: $PASS pass, $FAIL fail"
```
The two `tn` catch the old shapes coming back: the backticked `DEGRADED` value and a
`DEGRADED (semgrep absent) →` branch (none of the three files keeps that token after the fix; hotfix's
`DEGRADED (checklist only)` does not match). The paired `tf` on the same file fails on
an unreadable file, which `tn` alone would pass.
Simulated on a scratch clone (locks first, fix second): develop = 16 FAIL (effort-shift
lock + 3 files × 4 reader `tf` + 3 backticked `tn`), the 8 feat/bugfix locks PASS, the
3 `DEGRADED (semgrep absent) →` `tn` PASS (they guard the un-backticked variant, absent
on both sides); fix applied = 78/78 PASS.
Deferred (confirmation pass, logged to BUGS-FOUND at bookkeeping): a DEGRADED BLOCK's
cap STOP does not name the missing semgrep / `make plugin`; DEGRADED is read by word
presence, a garbled `TOOL:` line reads as a full scan (allowlist `semgrep <ver>` would
close it). Both were already true before this fix (the old bullet keyed on the wrong
line).
6. Bookkeeping (main loop, not executor): BUGS-FOUND:134 FIXED, TODO:13 done.
RISK: low — prose only, no output format change. New prose lines ≤ 80 cols; the lock
lines follow the test file's existing width (it already has lines past 80).
@@ -0,0 +1,103 @@
# Feat plan: merge-reuse clause at the end-of-run sites (TODO:14, run 1 of 2)
## Why
lib/effort-shift.md § Advisor item 3 (:131-134): "In the six flows that run the gates (...), a later
merge proposal reuses the last run's answer, or its skip, and names any code commit made after it
(doc and memory commits excepted)." The end steps of a11y, guardrails, ship-feature, init-project
cite `lib/effort-shift.md` § Advisor but do not load it (LRN-297): at merge time the reuse rule is
not in front of the main loop, so a merge proposal either re-calls the advisor or reuses a stale
answer without naming the commits made since. User 2026-11-19: all 6 sites; this run = the 4
TODO:14 names (feat/bugfix next run, same branch; /feat 5-file cap).
## Disposition
- honors LRN-297 by restating one clause at the acting site, the lib keeps the full rule.
- honors LRN-268 / user "verbatim where it fits": item 3 wording, "the last run's answer, or its
skip" → "this answer" (these four flows have no skip; "this" = the answer just named on the line).
- honors LRN-093: locks are single-line fragments; LRN-296: simulated on a scratch clone.
- honors BDR-100: grep "merge proposal" across skills/lib/agents/README/USAGE/CLAUDE.global → only
lib/effort-shift.md:132 (unchanged, the source); no other citer to patch.
- BDR-150 unchanged (no new call point, no skip).
## FIX PLAN (exact text; each `old` occurs exactly once in its file)
1. skills/a11y/SKILL.md and 2. skills/guardrails/SKILL.md — same block in both.
### Block ag-old
```
goes into the reply as an `Advisor:` line, and a fix it drives goes
back through the gates.
```
### Block ag-new
```
goes into the reply as an `Advisor:` line, and a fix it drives goes
back through the gates. A later merge proposal reuses this answer and
names any code commit made after it (doc and memory commits excepted).
```
3. skills/ship-feature/SKILL.md and 4. skills/init-project/SKILL.md — same block in both.
### Block si-old
```
its answer goes with the proposal as an `Advisor:` line, and a fix it
drives goes back through the gates.
```
### Block si-new
```
its answer goes with the proposal as an `Advisor:` line, and a fix it
drives goes back through the gates. A later merge proposal reuses this
answer and names any code commit made after it (doc and memory
commits excepted).
```
5. lib/tests/loops-light.test.sh
### Block t-vars-old
```
EFF="$REPO/lib/effort-shift.md"
```
### Block t-vars-new
```
EFF="$REPO/lib/effort-shift.md"
SFK="$REPO/skills/ship-feature/SKILL.md"
ISK="$REPO/skills/init-project/SKILL.md"
```
### Block t-locks-old
```
echo ""
echo "loops-light structure locks: $PASS pass, $FAIL fail"
```
### Block t-locks-new
```
echo "── end-of-run merge reuse at the site (TODO:14, LRN-297) ──"
tf "effort-shift merge reuse" "$EFF" "reuses the last run's answer, or its skip, and names any code commit"
for f in "$ASK" "$GSK" "$SFK" "$ISK"; do
n=$(basename "$(dirname "$f")")
tf "$n merge reuses answer" "$f" "the gates. A later merge proposal reuses this"
tf "$n names later commits" "$f" "names any code commit made after it"
tf "$n doc/memory excepted" "$f" "commits excepted)."
done
echo ""
echo "loops-light structure locks: $PASS pass, $FAIL fail"
```
Each fragment sits on one line in both wrap shapes (ag: 3-space indent; si: column 0); lock 1 anchors
the clause right after the gates sentence, lock 3 pins the polarity word, the `$EFF` lock pins the
source (lib/effort-shift.md:133). 78 → 91 pass.
## Edge cases
- ship-feature/init-project: the finish proposal follows the call in the same step; "later" covers a
finish proposed after more commits land (user defers the go). Same sentence everywhere, no
per-flow variant.
- Prose lines ≤ 80 cols (ag 72/73, si 70/70/62/18).
## Tests
lib/tests/loops-light.test.sh section above; full make test.
RISK: low — prose only, no rule change (item 3 already binds; the site now restates it).
## Deferred (challenge MINORs, logged at bookkeeping, not this run)
- item 3 reuse clause has no fallback when the end-of-run answer is absent (advisor absent/error) or out
of view at the merge signal → candidate: "answer absent or out of view → the merge proposal runs the
call" in lib/effort-shift.md item 3 (source, not the sites).
- end sites restate the call but not "one end-of-run call per skill run": a fix that goes back
through the gates may re-enter the end step and call again.
- one branch can carry two end-of-run answers (a11y then guardrails): "this answer" = the latest run's;
"names any code commit made after it" keeps the proposal truthful.
- run 2 (feat:210, bugfix:236) gets its own TODO line when TODO:14 is ticked; the branch is not
merge-ready before run 2 lands.
@@ -0,0 +1,97 @@
# Feat plan: merge-reuse clause at the feat/bugfix end lines (TODO:14, run 2 of 2)
## Why
Run 1 (af846d6) restated lib/effort-shift.md § Advisor item 3's merge-reuse clause at the a11y,
guardrails, ship-feature and init-project end steps. User 2026-11-19: all 6 sites; feat and bugfix
are the other two gate flows. Their end lines cite `lib/effort-shift.md` § Advisor without loading
it (LRN-297), and leaving them bare is the uneven restatement LRN-297 warns about. Same branch
feature/advisor-merge-reuse (/feat 5-file cap split the 6 sites in two runs).
## Disposition
- honors LRN-297: one clause read ahead at the run's end (feat/bugfix never propose the merge
themselves; it comes at the user's later "merge it"), the lib keeps the full rule.
- honors LRN-268 / user wording: the scope question offered feat/bugfix "reuses the last run's
answer, or its skip" (they can skip, unlike the four run-1 flows); text = item 3 verbatim.
- honors LRN-093 (single-line lock fragments), LRN-296 (scratch simulation), LRN-298 (lock 1
anchored on "the gates." = placement after the gates sentence).
- 9814720's eight feat/bugfix skip locks sit on lines this run does not touch: the clause is
appended after the final "through the gates." of each end line.
- BDR-100: "merge proposal" cited only by lib/effort-shift.md:132 and the run-1 sites.
## FIX PLAN (exact text; each `old` occurs exactly once in its file)
1. skills/feat/SKILL.md
### Block feat-old
```
goes into the summary's `ADVISOR` field, and a fix it drives goes back
through the gates.
Print summary:
```
### Block feat-new
```
goes into the summary's `ADVISOR` field, and a fix it drives goes back
through the gates. A later merge proposal reuses the last run's answer,
or its skip, and names any code commit made after it (doc and memory
commits excepted).
Print summary:
```
2. skills/bugfix/SKILL.md
### Block bug-old
```
goes into the summary's `ADVISOR` field, and a fix it drives goes back
through the gates.
4. Print summary:
```
### Block bug-new
```
goes into the summary's `ADVISOR` field, and a fix it drives goes back
through the gates. A later merge proposal reuses the last run's answer,
or its skip, and names any code commit made after it (doc and memory
commits excepted).
4. Print summary:
```
3. lib/tests/loops-light.test.sh — extend run 1's section (its loop's lock 1 ends "reuses this",
which does not match the feat/bugfix wording, so the two sites get their own loop).
### Block t-old
```
tf "$n names later commits" "$f" "names any code commit made after it"
tf "$n doc/memory excepted" "$f" "commits excepted)."
done
```
### Block t-new
```
tf "$n names later commits" "$f" "names any code commit made after it (doc and memory"
tf "$n doc/memory excepted" "$f" "commits excepted)."
done
for f in "$FSK" "$BSK"; do
n=$(basename "$(dirname "$f")")
tf "$n merge reuses answer" "$f" "the gates. A later merge proposal reuses the last run's answer,"
tf "$n reuse covers skip" "$f" "or its skip, and names any code commit made after it (doc and memory"
tf "$n doc/memory excepted" "$f" "commits excepted)."
done
```
91 → 97 pass. Each fragment sits on one line in both indents. Lock 2 now reaches "(doc and memory" in
both loops (run 1's loop widened in place, same file, count unchanged) so the exception is pinned.
Each skill block runs through the next line ("Print summary:"), so a second apply finds no `old`
and fails loudly instead of doubling the clause.
## Edge cases
- New prose widths: feat 71/68/18, bugfix 74/71/21 (≤ 80).
- "the last run's answer" at a feat/bugfix site = this run's answer unless a later gate flow ran on
the same branch; "names any code commit made after it" keeps the proposal truthful either way.
## Tests
lib/tests/loops-light.test.sh; full make test.
RISK: low — prose only, rule unchanged; behavior changes: a merge after a clean-first-pass feat/bugfix
run reuses the skip instead of re-calling the advisor (the gated trade-off, item 3).
## Deferred (challenge MINORs, logged at bookkeeping, not this run)
- merge-time gap: the merge proposal happens at the gitflow finish gate (skills/gitflow/SKILL.md
:68-89, 0 advisor mentions); if compaction drops the skill body the reuse rule is not in view.
- "names any code commit made after it" has no anchor: the ADVISOR field records no HEAD SHA, so
commits made outside the session are invisible; candidate: record short SHA with the answer
(visible format change, user's call).
+7 -1
View File
@@ -10,15 +10,19 @@ The BDR-125 context queue is delivered: phases 0, 0b, 4a, 1, 5, 2 and 4b-4d ship
### Added
- **/prune-memory feedback step (D)**: reads this repo's `Noisy:` and `Promotion candidates:` lines from `~/.claude/memory-feedback/FEEDBACK.md` (written by `/memory-feedback`). A noisy entry gets an inline rewrite of its title and lesson sentence, narrowed to its concrete trigger, committed as `chore(memory): noisy-rewrite <ID>`. A promotion candidate gets a mechanism proposal (rule line, hook, guard, test); on accept, a `<current status word>, promoted to <mechanism>` status line is recorded (a closed entry stays closed) and the mechanism is built in a separate `/feat`. Rows already rewritten or promoted are dropped. Cutoffs stay in `lib/memory-feedback/thresholds.ts`.
- **/memory-feedback advisor usage**: each run appends `## Advisor usage (<from> → <to>)` to `~/.claude/memory-feedback/FEEDBACK.md`: advisor calls served since the last run (first run: every transcript on disk), per caller (`main loop`, or the sub-agent type from its `.meta.json`, `sub-agent (unknown)` when absent or malformed) and model, with input tokens, deduped by `message.id`, all projects summed with no repo name. When the window starts before the 7-day transcript retention, a line says older calls may be missing. No transcript found, or messages that mention `advisor_message` but no longer parse, print a line in place of a false zero; a read failure prints `Unavailable: transcripts unreadable.`. `/memory-feedback` STEP 5 shows the table. New module `lib/memory-feedback/advisor.ts`; tests `lib/memory-feedback/advisor.test.ts`.
### Changed
- **memory recall**: a prompt after 30 minutes idle now needs 8 content words, up from 5 (a context's first prompt or a design/analysis prompt still needs 5), and the haiku rerank keeps at most 2 entries, down from 3. Measured on the first feedback gate: idle precision 44 %, third pick 35 %.
- **memory digest TODO lines**: with no `## Actionable` (or `### Actionable`) section, the digest now shows the TODO file's first 3 unchecked top-level items instead of none, and items inside HTML comments are ignored. When the 800-character cap drops TODO lines, a `- todo: +N not shown, read .claude/tasks/TODO.md` line counts them. `/init-project`, `/onboard` and `/capitalize` seed new TODO files with a `## Actionable` section. The session-start doctrine (`CLAUDE.global.md`) now trusts the digest and reads `.claude/tasks/TODO.md` only when no digest prints or the task needs it.
- **Skill routing (`CLAUDE.global.md`)**: routing lines a skill's own description already covers move there (bugfix, feat/hotfix split, ship-feature, tour, reconcile, capitalize, close); the section keeps the gstack cases (investigate on explicit ask, gstack ship retired per BDR-105), the pack-off SEO/GEO/W3C line (`profile.sh enable seo|web-validate`), `cso` and media. `/bugfix` triggers gain "error", "500", "stack trace + fix"; `/ship-feature` gains "ship this feature".
- **model-router**: the `fable` alias, head of the best tier, resolves to `claude-fable-5-2` (was `claude-fable-5-1`); every best-tier phase, row and skill pin naming `fable` follows. Kit tests updated.
- **model-router**: the `fable` alias resolves to `claude-fable-5-2` (was `claude-fable-5-1`); the alias table follows. Kit tests updated.
- **memory feedback**: precision, trigger precision and the miss share count only rows after the gate-1 fix (merge 2026-11-12T19:53:59Z); their actions wait for 20 post-fix asks (`Post-fix prompt asks: k/20` in FEEDBACK.md, one `NEW: post-fix prompt sample reached` line) and the session reminder keeps prompting until then. The third-pick signal is retired (recall keeps 2 picks). The reader holds one parsed transcript at a time; `labels.tsv` rows and `state.json` are validated on read.
- **memory commit chokepoint**: `lib/memory.sh check --staged`, run by `lib/memory-commit.sh commit` before every memory commit (rc 6, registry unstaged), also refuses a staged v2 registry whose new `## ` entry does not carry the next free ID: the highest ID seen at any heading level, fenced or not, in HEAD and above the entry in the staged file, plus one, the same reading `add` uses. stderr: `memory: <file>:<line>: new entry <ID> is not the next free ID <PREFIX>-NNN`. A committed ID is never renamed: fix the uncommitted heading and every uncommitted mention of its ID (the `superseded by` line from `add --supersedes`, the journal line), or drop the new entry and re-add it with `memory.sh add`. Skipped when the registry is absent from HEAD, HEAD is v1 (an `upgrade` commit), HEAD has an open code fence, or HEAD has no well-formed `## ` entry. Tests: `lib/tests/memory.test.sh`.
- **model-router write guard fails closed**: when the guard's own check throws or times out, a main-loop Edit, Write or NotebookEdit of a code file outside a skill run is held with `model-router: the write guard failed (<kind>), so this write is held. Enter /hotfix, /feat, /bugfix or /ship-feature, or re-enter the skill you were running, then make this edit.` One log line per session: `model-router: write guard failed (<kind>): main-loop code writes are held until a skill runs`. Sub-agents, skill runs (typed, model-declared phase, typed `/route`) and `.md` / `.txt` files still pass; an error raised by a downstream tool is replayed as before. The guard used to let the write through on its own failure. Tests: `mods/model-router/hooks/register.test.ts` (GUARD: a failing guard …).
- **model-router: Fable leaves auto-routing**: the `best` and `big` tiers default to opus then sonnet (were fable>opus>sonnet and opus>fable>sonnet), so Opus is the strongest model the router routes to and Fable is the advisor (`advisorModel` in settings.json). Fable stays in the model table and first in the fallback rank, so a hand pick of fable ranks above opus. The first-use Change dialog offers opus, sonnet and haiku; the bare `/model` dialog still offers fable, labelled `fable (custom)`. The ask before Fable only fires when a machine override puts fable at the head of `best`: otherwise `/route ask-tier on` answers `(inert: best is not headed by fable)` and `/route show` prints `ask-tier: inert`. An agent on a best or big row keeps its opus frontmatter when Opus is down. The `tiers.best does not lead the fallback chain` log is gone; `routing.json` is unchanged. Tests: `mods/model-router/hooks/register.test.ts`; `lib/tests/effort-routing.test.sh` floors every row on its tier's head. The `/client-handover` skill-runner children and the `lib/model-gate.md` dispatch doctrine pin `model: "opus"` instead of `"fable"` (BDR-150: Fable is the advisor, never a dispatch target), and the model gate lets a sub-agent pass when the route answer says its model is `fixed at spawn`. Tests: `lib/tests/model-routing.test.sh` refuses any fable dispatch pin under agents/, skills/ and lib/; `lib/tests/effort-routing.test.sh` checks the 7 opus/effort="high" client-handover dispatches.
- **Advisor doctrine (`CLAUDE.global.md` § Workflow, `lib/effort-shift.md` § Advisor, `lib/challenge-plan.md`, `lib/verify-secure-loop.md`, `agents/plan-challenger.md`, `agents/verifier.md`, `agents/security-auditor.md`, `agents/analyzer.md`, `skills/{feat,bugfix,hotfix,ship-feature,init-project,onboard,code-clean,harden,a11y,guardrails,audit-delta,tour,release-candidate}/SKILL.md`, `skills/pack-seo/skills/{seo,geo}/SKILL.md`, `skills/pack-web-validate/skills/web-validate/SKILL.md`)**: when a stronger model is needed (an approach to settle before building, a stuck problem, a long task before calling it done, a change to recommend to the doctrine, the architecture or a public interface), the main loop calls the advisor tool (Fable, settings `advisorModel`, set by `/advisor`), at least on the written plan before the plan challengers are dispatched (`lib/challenge-plan.md`, every skill that challenges a plan, once per skill run, not before a re-challenge: an answer that lands a real flaw revises the plan file as plain plan text with no advisor attribution, the advice never enters a challenger brief, and the CHALLENGE SUMMARY of every caller gains an `Advisor:` row (the plan change it drove, `called, no change` or `not called (absent | error | already called this run)`), each caller sending its route before the challenge with the first tool call of `lib/challenge-plan.md`; the ORCHESTRATOR PROTOCOL in `agents/plan-challenger.md` mirrors this advisor-first step and the row), once per verify-secure run at the first gate loop to fail twice (floor, conformity, security, or a second structural failure, counting main-loop calls since GATE 0 first ran; the advice stays in the main loop and never enters an executor brief; every cap or escalation STOP carries it and says whether it predates the last iteration), and before proposing a merge (`gitflow finish`) or calling a long task done: one end-of-run call per skill run, never skipped for an earlier plan or stuck call, except that audit-delta and tour skip it when the run applied no fix and feat and bugfix skip it when GATE 0 said MET, the verifier CONFORME and security PASS (not DEGRADED), each on its first attempt, their summary's `ADVISOR` field then reading `skipped (gates clean on first pass)`. It sits at the commit step of feat and bugfix and at the end step of ship-feature, init-project, a11y and guardrails: the main loop first prints the run's diff stat, the answer goes into the reply or finish proposal as an `Advisor:` line, or into the feat/bugfix summary's `ADVISOR` field, a fix it drives goes back through the gates, and a later merge proposal reuses the last run's answer, or its skip, and names any code commit made after it (doc and memory commits excepted). It also sits at the end of audit-delta and tour when the run applied a fix (tour: main loop only, never a runner), and at release-candidate STEP 4 before the go / hold ask. In those three the answer is reported only: a fix it calls for waits for a new run, and at the release gate it makes hold the recommended answer. The same six gate skills carry a `Stuck:` line that points at the verify-secure rule. Inside a skill run these points cover the triggers: no second call for the same recommendation. `plan-challenger`, `verifier`, `security-auditor` and `analyzer` may call it only when dispatched as a sub-agent, at most once per dispatch, late, before their verdict or report; the analyzer's output rests on the code it read, never on the advice alone, and advice proposing a design or a fix counts only where the brief asks for one. For the three gates advice only adds: the verifier may go back to a contract criterion and tags a resulting NOT-MET `(advisor-prompted)`, never clearing a gap on advice; the challenger never drops or lowers a finding on advice alone; the security-auditor tags an added finding `advisor:<STEP 3 class>` at that class's severity (REPORTED LOW when it matches no class), and tags a raised one `<rule>+advisor` only when the class's severity is higher than the finding's own; a raise that does not apply, or matches no class, changes nothing (no tag, no PROOF count). Its PROOF ends with `; advisor <n> added/raised`. Executors and every other sub-agent do not call it, even when the tool is listed. Advisor absent or erroring → proceed as written; advice waives no gate, cap or guard and, at a loop cap, feeds the STOP diagnosis. Fable on main comes only from a hand pick, a typed `/route model=fable`, a phase naming `model: fable` or a machine override that puts fable in a tier (BDR-150). Prose that still named Fable as the `audit` row head or a skill-runner pin (`agents/plan-challenger.md`, `lib/challenge-plan.md`, `lib/effort-shift.md`, `skills/tour/SKILL.md`) now says opus.
- **gates.sh timeout**: the default per-CHECK timeout (`GATES_TIMEOUT`) is 600 s, up from 120 s. A full `make test` (about 135 s) went NOT-MET on the timeout alone. A run lasts the sum of its CHECKs: a caller with a shorter limit (a foreground tool call stops at 600 s) runs it in the background, and a killed run writes nothing back, so the floor stays PENDING.
### Removed
- `hooks/design-toolchain-reminder.sh`, its `UserPromptSubmit` entry in `settings.json` (`ctx7-reminder` stays the only one) and its suite `lib/tests/design-toolchain-reminder.test.sh`. Measured 2026-10-31: 59 fires, 0 Reads of `rules/web-building.md`. Design routing stays with the `rules/web-building.md` path rule and the `CLAUDE.global.md` pointer. The fire log `~/.claude/logs/design-toolchain-fires.log` is left in place.
@@ -39,6 +43,8 @@ The BDR-125 context queue is delivered: phases 0, 0b, 4a, 1, 5, 2 and 4b-4d ship
- `mods/` type-check under `claude plugin validate --strict` (CLI 2.1.323 started type-checking mods): 17 sites narrowed, failure behaviour unchanged (6433e4d, BLK-049); the write guard has since moved to fail-closed (see Changed).
- model-router: a Skill call whose answer carries `isError` (refused or unknown skill) no longer opens the write guard for the rest of the session. Test: `mods/model-router/hooks/register.test.ts` (GUARD: an isError Skill answer leaves the latch closed).
- `settings.json`: the `autoMode.hard_deny` entry "Disarming the guardrails" now names turning a mod off as disarming: `"enabled": false` in `~/.claude/<mod>.json`, a mod's `enabledPlugins` entry set to false, or `profile.sh disable` of a mod. These switches turn off the model-router write guard and the memory mod; the user still sets them by hand.
- `lib/gates.sh` (GATE 0 floor): an unindented line under `## ACCEPTANCE CRITERIA` that starts with a digit but is not `N. text` (`1b.`, `1.1`, `2)`) is now a parse error, `malformed criterion label at line N`, and a second `CHECK:`, `EXPECT:` or `EVIDENCE:` on one criterion is one too, `second CHECK: at line N in criterion M`. Either gives `VERDICT: ERROR(n)` (rc 2) and no CHECK runs. An oracle under a label the parser missed used to overwrite the previous criterion's, so a failing criterion could read MET. A label that is not digit-led (indented, bullet) is caught only when the criterion before it already has that attribute; after a manual criterion its oracle is still absorbed. With no criterion parsed, the `no numbered criteria` error now ends with the first parse error. Test: `lib/tests/gates.test.sh`.
- Security gate readers (`lib/verify-secure-loop.md`, `agents/security-auditor.md` ORCHESTRATOR PROTOCOL, `skills/hotfix/SKILL.md` STEP 4) no longer read `DEGRADED` as a value of the `SECURITY — VERDICT:` line. The auditor prints `VERDICT: PASS` on a scan without semgrep and reports DEGRADED on its `TOOL:` line, so the old `DEGRADED` branch never fired: a degraded scan read as a clean PASS, the checklist result and the `make plugin` hint were never surfaced, and hotfix's `SECURITY: DEGRADED (checklist only)` summary could not be reached. The `PASS` branch now reads the `TOOL:` line first, and a PASS with no `TOOL:` line is a structural failure (one fresh retry, then escalation). `lib/effort-shift.md` § Advisor names the `TOOL:` line in the feat/bugfix skip condition. The auditor's output format is unchanged. Test: `lib/tests/loops-light.test.sh` (DEGRADED on the TOOL line).
## [3.0.0] — 2026-11-12
+9
View File
@@ -78,6 +78,15 @@ code" wins. Repo-specific instructions override both.
command is reported with its rule (a guard redirect naming a skill is
followed instead), never rerun through a wrapper, alias, env
file or other shell. Hermetic tests run through `make test [suite=…]` only.
- Stronger model needed (an approach to settle before building, a stuck
problem, a long task before calling it done, before recommending a change
to the doctrine, the architecture or a public interface) → the main loop
calls the advisor tool when it is listed (settings `advisorModel`,
Fable, set by /advisor), at least at the points of
`~/.claude/lib/effort-shift.md` § Advisor; dispatched plan-challenger,
verifier, security-auditor and `analyzer` at most once, before their
verdict or report; other sub-agents do not. Fable is never routed or
pinned: the router tops out at opus (BDR-150).
- Ask rather than guess. A choice visible in the result (placement,
wording, order, behavior), a name that becomes public (command, flag,
endpoint, file), or a scope the request leaves open → ask, even mid-task;
+47 -28
View File
@@ -14,7 +14,7 @@ Not a collection of prompts — an operating layer on top of Claude Code:
full feature pipeline with validation gates.
- **Agents** are the execution units skills dispatch to — each pinned to
the cheapest model that can do the job (haiku collects, sonnet executes,
opus judges and runs the session, Fable plans and runs the merge gates).
opus judges, plans and runs the session and the merge gates; Fable is the advisor).
- **Hooks and permissions** are deterministic guardrails: gitflow enforced
by a pre-commit hook in every repo (`make link` points git's global
`core.hooksPath` at `~/.claude/githooks`), every commit pushed by
@@ -71,24 +71,43 @@ commands, settings, secrets, maintenance.
## Agent model routing (model-tiering v2)
Doctrine: the main loop runs on the `opus` session model; the model-router rows
lift it to Fable for main-loop reflection ONLY: brainstorm, plan, contract,
audit judgment, loop decisions. The main loop writes no code outside a skill run (the router's guard
redirects it to a skill); the fresh gates run as dispatched agents on the `audit` row. The
Fable/Opus model floor is enforced by a blocking gate (`lib/model-gate.md`) at
the entry of the 17 reflection skills (the orchestrators, `/analyze`,
`/guardrails` and `/a11y`): the skill calls the model-router `route` tool and
its answer, which names the model id the main loop runs on, is the witness. A
non-Fable/Opus id or the mod off stops the skill (`/route on` resumes the
mod). Nothing dispatched inherits silently: typed agents run on their
model-router row, their
`model:` frontmatter being the off-state floor; built-ins get an explicit
`model=` at every call site.
route main-loop reflection (brainstorm, plan, contract, audit judgment, loop
decisions) to the `best` tier, opus at the phase's effort. Fable is never
auto-routed: it is the advisor (`advisorModel` in settings.json) and a hand
pick. The main loop calls the advisor at least on the written plan before the
plan challengers see it (`lib/challenge-plan.md`, once per skill run; the
CHALLENGE SUMMARY's `Advisor:` row records what it changed), once per
verify-secure run at the first gate loop to fail twice (the advice stays in
the main loop, never in an executor brief; a cap or escalation STOP carries
it), before proposing a merge or calling a long task done (two skips:
`/feat` and `/bugfix` when GATE 0 said MET, the verifier CONFORME and
security PASS, not DEGRADED, each on its first attempt, their summary's
`ADVISOR` field then reading `skipped (gates clean on first pass)`;
`/audit-delta` and `/tour` when the run applied no fix), and before
recommending a change to the doctrine, the architecture or a public interface.
plan-challenger, verifier, security-auditor and `analyzer` may call it once
when dispatched as a sub-agent, before their verdict or report: advice can
add a finding or raise its severity, never drop, lower or clear one. Other
sub-agents do not, even when the tool is listed. An absent or
failing advisor changes nothing, and its advice waives no gate, cap or guard
(`lib/effort-shift.md` § Advisor). The main loop writes no
code outside a skill run (the router's guard redirects it to a skill); the fresh
gates run as dispatched agents on the `audit` row. The Fable/Opus model floor is
enforced by a blocking gate (`lib/model-gate.md`) at the entry of the 17
reflection skills (the orchestrators, `/analyze`, `/guardrails` and `/a11y`):
the skill calls the model-router `route` tool and its answer, which names the
model id the main loop runs on, is the witness. A non-Fable/Opus id or the mod
off stops the skill (`/route on` resumes the mod). Inside a sub-agent the answer
says the model is `fixed at spawn`, and the skill proceeds. Nothing dispatched
inherits silently: typed agents run on their model-router row, their `model:`
frontmatter being the off-state floor; built-ins get an explicit `model=` at
every call site.
| Agent | Model | Tier |
|---|---|---|
| feater, hotfixer, bugfixer | sonnet (pinned) | executors — code from a closed plan (feat), fix from a closed diagnosis (bugfix), fix-bundle appliers |
| verifier | Fable (`audit` row: best/xhigh, opus frontmatter floor) | fresh gate (≤3×/loop) |
| security-auditor | Fable (`audit` row: best/xhigh, opus frontmatter floor) | fresh gate (≤3×/loop) |
| verifier | opus (`audit` row: best/xhigh, opus frontmatter floor) | fresh gate (≤3×/loop) |
| security-auditor | opus (`audit` row: best/xhigh, opus frontmatter floor) | fresh gate (≤3×/loop) |
| commit-changer, release-executor, code-cleaner | sonnet (pinned) | dispatched execution — grouping+commit / release prep span / approved cleanup (audit + approval gates stay in the dispatcher) |
| onboarder, scaffolder, refactorer, validator-analyzer, plugin-probe | sonnet (pinned) | workers — config generation, scaffold, refactor, deterministic W3C/WCAG runner, mechanical plugin probe |
| status-reporter | haiku (pinned) | mechanical collector |
@@ -104,7 +123,7 @@ The pure-execution skills `/doc`, `/status`, `/commit-change`,
so the pin takes effect and the work leaves the big session model; `/hotfix`
was split like `/feat` (reflection inline + gate, `hotfixer` executor) and so
joins the gated group; `/client-handover`'s nested skill-runner
children are dispatched `model:"fable"` (they carry reflection).
children are dispatched `model:"opus"` (they carry reflection).
## Effort routing (BDR-107, BDR-108)
@@ -117,8 +136,8 @@ and agent, each phase naming a tier and an effort level
work/high, `verify` work/xhigh, `explore` work/medium, `apply` work/low,
`mechanical` cheap/low). The `model:` and `effort:` frontmatter of every
typed agent and user-invoked skill stays as the off-state floor, kept equal
to the rows by the census `lib/tests/effort-routing.test.sh` (a best-tier
row floors on the tier's second alias, opus, since Fable is credit-gated; a
to the rows by the census `lib/tests/effort-routing.test.sh` (a row's model
floor is its tier's head, opus for `best` and `big`; a
row changed through the first-use dialog passes with a `WARN floor drift` line
until its frontmatter follows): low
appliers, medium executors, high writers, xhigh judgment and gates;
@@ -129,7 +148,7 @@ Orchestrators declare each phase through the `mcp__model-router__route`
tool (`lib/effort-shift.md`): `orchestrate` at a dispatch span, `reflect`
or `plan` when reflection resumes, `apply` at the bookkeeping tail,
`escalate` at the verify-secure caps. Model pins stay tier aliases
(`sonnet`, `opus`, `haiku`, `fable`): the latest version of a tier is also
(`sonnet`, `opus`, `haiku`): the latest version of a tier is also
the cheapest or same-priced, so the quality/price trade-off is tier ×
effort, never version. Transcript audit `python3 lib/effort-audit.py`.
@@ -137,19 +156,19 @@ effort, never version. Transcript audit `python3 lib/effort-audit.py`.
`mods/model-router/` is a Claude Code mod (a function-hooks plugin) that applies this table per request. It loads in every session through the tracked symlink `skills/model-router`, as `model-router@skills-dir`.
- Main loop: every request gets the route in force. A typed skill with a row routes the main loop to it; a best-tier row (`plan`, `reflect`, `orchestrate`, `escalate`; `audit` is an agent row, never typed) holds across turns in a run slot until `/route clear`, `/route off`, a user `/model` (typed with a name, bare, or picked in the `/model` picker, it asks the scope: this project, this conversation, everywhere) or a typed skill on a non-best row. A skill without a row leaves the route as it is. A rowed skill the model loads inside a best-tier run moves effort only when its row ranks below the run's model. Main routed onto a model whose context window the conversation outgrew returns to the session model. Before main runs on a model, the one it moves to or the one it keeps (the session's own model included), the mod probes it with one small completion bounded to 8 seconds; the step (and `/route show`, the route tool's answer) waits for it. A timeout or an error marks the model down (reason `probe`, held for `cooldownMinutes` like any breaker hold) and the decision is taken again once. A model already marked down is never probed, and a model that answered is not probed again, `/clear` included, until it is marked down. When a lower model stands in for its tier's head held down (Opus for Fable on a best-tier phase), the phase's own effort goes one notch up: `reflect` xhigh, `plan` max, `orchestrate` high, `escalate` stays max. An effort asked explicitly (`/route ... effort=`, the `route` tool's `effort`) or set by a floor is never raised. `/route show` and the route tool's answer print the level with `(opus stands in for fable)`; the verbose transition line names `stand-in` as a cause.
- Main loop: every request gets the route in force. A typed skill with a row routes the main loop to it; a best-tier row (`plan`, `reflect`, `orchestrate`, `escalate`; `audit` is an agent row, never typed) holds across turns in a run slot until `/route clear`, `/route off`, a user `/model` (typed with a name, bare, or picked in the `/model` picker, it asks the scope: this project, this conversation, everywhere) or a typed skill on a non-best row. A skill without a row leaves the route as it is. A rowed skill the model loads inside a best-tier run moves effort only when its row ranks below the run's model. Main routed onto a model whose context window the conversation outgrew returns to the session model. Before main runs on a model, the one it moves to or the one it keeps (the session's own model included), the mod probes it with one small completion bounded to 8 seconds; the step (and `/route show`, the route tool's answer) waits for it. A timeout or an error marks the model down (reason `probe`, held for `cooldownMinutes` like any breaker hold) and the decision is taken again once. A model already marked down is never probed, and a model that answered is not probed again, `/clear` included, until it is marked down. When a lower model stands in for its tier's head held down (Sonnet for Opus on a best-tier phase; Opus for Fable when a machine override heads `best` with fable), the phase's own effort goes one notch up: `reflect` xhigh, `plan` max, `orchestrate` high, `escalate` stays max. An effort asked explicitly (`/route ... effort=`, the `route` tool's `effort`) or set by a floor is never raised. `/route show` and the route tool's answer print the level with `(<model> stands in for <head>)`, `(sonnet stands in for opus)` with the shipped tiers; the verbose transition line names `stand-in` as a cause.
- Sub-agents: a routed agent gets its row's model at spawn, within its tier and only upward from its frontmatter model, and the row's effort on every step. Explicit `model` / `effort` params on the Agent call win; a project-defined agent of the same name keeps its own definition. Built-ins: Explore runs on sonnet/medium, Plan on opus/xhigh. A built-in `general-purpose` agent that main spawns with no `model` param, while main runs below the session model (a downgrade or a breaker fallback), starts on the session model instead of inheriting the lower one; it is not pinned when the session model is marked down, for a fork, a workflow or a nested spawn, or when a project or user definition shadows the built-in. Other agent types are never pinned this way: the hook cannot see their frontmatter model.
- Write guard: a main-loop Edit, Write or NotebookEdit of a code file is redirected with "model-router: code is written inside a skill run…" until a skill ran on the main loop in the session (typed or loaded by the model; a refused or unknown skill does not count), a phase was declared this turn, or a typed `/route` holds. Free paths: `.md`, `.txt`, the project's `.claude/` except `worktrees/`, and `docs/`. Sub-agents write freely. If the guard's own check fails (throw or timeout), it holds such a write instead of letting it through, with "model-router: the write guard failed (<kind>), so this write is held…", logged once per session; sub-agents, a skill run, a declared phase or a typed `/route`, and `.md` / `.txt` files still pass, and an error raised by the tool itself is passed on unchanged. `/route clear`, `/route off` and `/clear` re-arm the guard; `/route off` also turns it off, and `"enabled": false` in `~/.claude/model-router.json` turns the router and the guard off. A `/model` hand pick does not open it, and a `register.ts` reload resets it.
- Levers inside a run: `ultrathink` in a prompt sets the turn's minimum effort; `/route effort=max` holds until `/route clear`. Keyword prompt rules (`plan`, `design`, `architecture`… take plan's effort; `why`, `review`, `audit`… reflect's), `ultrathink` and a main Agent dispatch (the derived `orchestrate` route, held until its background agents end) set the turn's effort only, never a model: they never lift main above the session model, and a held best-tier run keeps its model. Fable on main comes only from a skill row, the `route` tool, a typed `/route` or a hand pick (`/model`, picker). The built-in `/effort` is not a lever inside a run, rows and routes outrank it.
- `/model` scope: a pick in the `/model` picker is held first (the engine prints that a hook blocked it), then the same question as `/model <name>` comes. A bare `/model` opens the router's model, variant and scope dialog: fable, opus or sonnet, then Standard or `[1m]`, then the scope, the current model included; `Other model (native picker)` opens the native picker (haiku goes through it or `/model haiku`) and Esc changes nothing. A pick while another dialog is open is refused with `answer the open dialog first`. The picker's Default, an unknown name or a headless run go native, no question. A model chosen in that dialog (a hand pick) always switches: no cold-read cap, no `mainUpgrade` or `mainModelSwitch` flag. A hand pick marked down keeps main where it is until it is back. A native switch (the `/config` Model row included) or `/clear` drops a hand pick; a typed `/route model=` keeps the caps.
- Levers inside a run: `ultrathink` in a prompt sets the turn's minimum effort; `/route effort=max` holds until `/route clear`. Keyword prompt rules (`plan`, `design`, `architecture`… take plan's effort; `why`, `review`, `audit`… reflect's), `ultrathink` and a main Agent dispatch (the derived `orchestrate` route, held until its background agents end) set the turn's effort only, never a model: they never lift main above the session model, and a held best-tier run keeps its model. Fable on main comes only from a hand pick (`/model`, picker), a typed `/route model=fable`, a phase naming `model: fable` or a machine override that puts fable in a tier: no shipped tier or phase holds it. The built-in `/effort` is not a lever inside a run, rows and routes outrank it.
- `/model` scope: a pick in the `/model` picker is held first (the engine prints that a hook blocked it), then the same question as `/model <name>` comes. A bare `/model` opens the router's model, variant and scope dialog: fable (labelled `fable (custom)`, it heads no shipped tier), opus or sonnet, then Standard or `[1m]`, then the scope, the current model included; `Other model (native picker)` opens the native picker (haiku goes through it or `/model haiku`) and Esc changes nothing. A pick while another dialog is open is refused with `answer the open dialog first`. The picker's Default, an unknown name or a headless run go native, no question. A model chosen in that dialog (a hand pick) always switches: no cold-read cap, no `mainUpgrade` or `mainModelSwitch` flag. A hand pick marked down keeps main where it is until it is back. A native switch (the `/config` Model row included) or `/clear` drops a hand pick; a typed `/route model=` keeps the caps.
- Prompt classifier: a plain prompt typed in the composer (12 characters or more, not a slash command) that no keyword rule, skill, run slot, `/route` or floor covers is sent to the engine's small fast model, one call, bounded to 3 seconds (the prompt waits for it, typically under a second). The label (`design`, `analysis`, `coding`, `bookkeeping`, `chat`) maps to plan, reflect, implement or apply (`chat` routes nothing), and the turn takes that phase's route: its effort becomes the turn's default, and its model may move the main loop, never above the session model. A `coding` or `bookkeeping` guess moves main down only when `mainModelSwitch` is on and the cold read fits `downgradeMaxTokens`; an `ultrathink` floor in the same turn raises the effort only, the guess's model holds. No dialog opens and no file is written. The route is gone at the end of the turn, a later route call or typed skill replaces it, and a `/effort` you type between turns drops the guess for that turn only. A typed best-tier skill holds its run slot across turns, so nothing is classified there until `/route clear`. Long prompts are sampled (first 500 and last 1500 code points), so pasted text at the end can steer one turn's route. Three failures in a row pause it for `cooldownMinutes` (one toast, `classifier: paused` in the status line). Never in a sub-agent, mid-turn or under `-p`. Off per session with `/route classify off`, per machine with `"classify": false`. The status line reads `route: classifier <phase>`; `/route verbose on` adds the transition line.
- `/route` (user command) shows or sets the route: `show`, `clear`, `off`, `on`, `reload`, `pending` (rows and phases not confirmed yet), `ask on|off` (first-use dialog on or off), `ask-tier on|off` (the ask before Fable, below), `forget <name|all|projects>` (takes decisions back: a changed row returns to its shipped phase; `all` and `projects` ask first), a phase name, `model=<alias|id> effort=<level>`, `switch on|off`, `classify on|off` (the prompt classifier, below), `verbose on|off` (logs transitions only: each change of model or effort, with a few words of cause). `/route show` names the run slot when one holds (`main: run <phase>`) and prints the switch with its cap and the prompt-cache TTL (`switch: on (downgrade, cap 120000 tokens cold, ttl 60 min)`) and `ask-tier:` (`best`, `best (paused this session)` or `off`). The model sets routes through a `route` tool.
- First use: the first time a rowed skill is typed, a rowed agent is spawned or a phase is declared on the main loop through the `route` tool, the mod asks once whether the route is right. The question gives context: the skill's description (first sentence of its `SKILL.md` frontmatter) or the agent's, the phase with its `about` line, and the model id and effort the next step really runs on; a declared phase also says what uses it (rows, prompt rules). A row offers Later, Keep or Change; a declared phase offers Later or Keep. Change asks the model (fable, opus, sonnet, haiku, each shown with the tier it heads), then the effort among those the phases on that model use (shipped table: fable medium, high, xhigh or max; sonnet low, medium, high or xhigh; opus and haiku have one level each, so no question), then Everywhere or This project only. Rows stay phase names, so the pair maps to an existing phase: the row's current phase wins a tie and the same phase counts as Keep; a pair no phase offers needs a new phase added by hand in routing.json. Everywhere moves the row and records the shipped phase under `changed`; This project only stores an exception under `projects`, keyed by the origin remote reduced to `host/path` (no credentials, no local paths; a remote that cannot be read that way offers no project choice). Keep lands under `confirmed`; Later, a dismissed dialog or a free-text answer asks again next session. After a skill row changes, a toast names the model and effort that skill now runs on, plus a hint when the main loop holds back a downgrade: `/route switch on` when the switch is off, the cap hold (`held: downgrade skipped: cold read <n> tokens over <cap>`) when the cold read is over `downgradeMaxTokens`. One dialog at a time, never in a headless (`-p`) run, never inside a sub-agent.
- Ask before Fable: before a route lifts the main loop, or sends a rowed agent, onto Fable from another model, the mod asks once per span. The question names the origin (a skill, typed or loaded by the model, an agent, the `route` tool or `/route`), the phase with its `about` line, and the model and effort the step would run on. `Fable` runs it; `Opus instead (big tier)` runs the span through the `big` tier at the phase's own effort, offered only while Opus is up so the label stays true; `Stop asking this session` pauses the question until `/clear`. A best-tier skill the model loads counts as a skill row, and an agent type gets one answer per session. Nothing is asked in a headless (`-p`) run or inside a sub-agent, a dismissed dialog runs Fable, and no answer is written (`confirmed` included). No question comes when the decision would not land on Fable (`mainUpgrade` off, a cold-read cap, the context window, Fable marked down); when such a Fable hold or cap lapses later, main upgrades without asking, as the breaker already does. `askTier` in routing.json (`best`, or `false` to turn it off) is set by `/route ask-tier on|off`, and the machine config wins.
- `/route` (user command) shows or sets the route: `show`, `clear`, `off`, `on`, `reload`, `pending` (rows and phases not confirmed yet), `ask on|off` (first-use dialog on or off), `ask-tier on|off` (the ask before Fable, below), `forget <name|all|projects>` (takes decisions back: a changed row returns to its shipped phase; `all` and `projects` ask first), a phase name, `model=<alias|id> effort=<level>`, `switch on|off`, `classify on|off` (the prompt classifier, below), `verbose on|off` (logs transitions only: each change of model or effort, with a few words of cause). `/route show` names the run slot when one holds (`main: run <phase>`) and prints the switch with its cap and the prompt-cache TTL (`switch: on (downgrade, cap 120000 tokens cold, ttl 60 min)`) and `ask-tier:` (`best`, `best (paused this session)`, `off`, or `inert` while `best` is not headed by fable). The model sets routes through a `route` tool.
- First use: the first time a rowed skill is typed, a rowed agent is spawned or a phase is declared on the main loop through the `route` tool, the mod asks once whether the route is right. The question gives context: the skill's description (first sentence of its `SKILL.md` frontmatter) or the agent's, the phase with its `about` line, and the model id and effort the next step really runs on; a declared phase also says what uses it (rows, prompt rules). A row offers Later, Keep or Change; a declared phase offers Later or Keep. Change asks the model (opus, sonnet, haiku, each shown with the tier it heads; fable is not offered), then the effort among those the phases on that model use (shipped table: opus medium, high, xhigh or max; sonnet low, medium, high or xhigh; haiku has one level, so no question), then Everywhere or This project only. Rows stay phase names, so the pair maps to an existing phase: the row's current phase wins a tie and the same phase counts as Keep; a pair no phase offers needs a new phase added by hand in routing.json. Everywhere moves the row and records the shipped phase under `changed`; This project only stores an exception under `projects`, keyed by the origin remote reduced to `host/path` (no credentials, no local paths; a remote that cannot be read that way offers no project choice). Keep lands under `confirmed`; Later, a dismissed dialog or a free-text answer asks again next session. After a skill row changes, a toast names the model and effort that skill now runs on, plus a hint when the main loop holds back a downgrade: `/route switch on` when the switch is off, the cap hold (`held: downgrade skipped: cold read <n> tokens over <cap>`) when the cold read is over `downgradeMaxTokens`. One dialog at a time, never in a headless (`-p`) run, never inside a sub-agent.
- Ask before Fable: inert by default, since no shipped tier holds fable. When a machine override puts fable at the head of `best`, before a route lifts the main loop, or sends a rowed agent, onto Fable from another model, the mod asks once per span. The question names the origin (a skill, typed or loaded by the model, an agent, the `route` tool or `/route`), the phase with its `about` line, and the model and effort the step would run on. `Fable` runs it; `Opus instead (big tier)` runs the span through the `big` tier at the phase's own effort, offered only while Opus is up so the label stays true; `Stop asking this session` pauses the question until `/clear`. A best-tier skill the model loads counts as a skill row, and an agent type gets one answer per session. Nothing is asked in a headless (`-p`) run or inside a sub-agent, a dismissed dialog runs Fable, and no answer is written (`confirmed` included). No question comes when the decision would not land on Fable (`mainUpgrade` off, a cold-read cap, the context window, Fable marked down); when such a Fable hold or cap lapses later, main upgrades without asking, as the breaker already does. `askTier` in routing.json (`best`, or `false` to turn it off) is set by `/route ask-tier on|off`, and the machine config wins. While `best` is not headed by fable, `/route ask-tier on` answers `ask-tier on (inert: best is not headed by fable)` and `/route show` prints `ask-tier: inert`.
- Only a first-use dialog answer, `/route ask on|off`, `/route ask-tier on|off` or `/route forget` writes `routing.json`, never the model. Writes are serialized, capped at 64 KiB, and refused when the file is missing (it is never created). Each write leaves the config repo dirty; a toast reminds you to commit it from there. The one other write: `/model <name>`, the bare `/model` dialog or a `/model` picker pick → This project writes the full id as `model` into the session root's `.claude/settings.local.json` (created if absent, keep it gitignored; refused when `.claude` or the file is a link, or the file is over 64 KiB or not a JSON object). Remove its `model` key to undo.
- The spinner suffix and the status line under the prompt show the route in force; the status line adds ` · switch off` when the downgrade switch is off.
Config layers: `mods/model-router/routing.json` (tracked: phases with their tier, effort and `about` line, rows, decisions, `ask`, `askTier`), then the optional per-machine `~/.claude/model-router.json`, which wins. A `.claude/model-router.json` inside a project is never read. Machine keys: `models` (alias → full id), `windows` (context window per full id), `tiers` (ordered alias lists per tier: `best` fable>opus>sonnet, `big` opus>fable>sonnet, `work` sonnet>opus, `cheap` haiku>sonnet; the first alias not down is used), `fallback` (the rank order of the aliases, best first, used by the breaker), `cooldownMinutes` (how long a model stays marked down after an availability error, 15 by default, doubling per episode up to 300), `mainUpgrade` (default `true`: the main loop may move up to a phase's tier), `upgradeMaxTokens` (default 200000: the largest cold read a main-loop upgrade may cost), `downgradeMaxTokens` (default 120000: the same cap for a downgrade; the cold read is the context minus what the target model's prompt cache already holds, taken from main's last step on that model within the prompt-cache TTL, forgotten by `/clear` and `/route reload`. The TTL follows the engine's `cache_ttl` (5 or 60 minutes) carried by main's model-switch events, is 60 minutes until the first one and survives `/clear`. The context also counts the prompt just submitted, which the engine's usage may not include yet: code points / 3 of its text, its context entries and a typed skill's body, summed and added at the turn's first main step unless usage already grew by half of it. A `document` attachment makes the size unknown, and an unknown context size blocks the switch; the step, `/route show`, the first-use dialog and the toast read the same adjusted size), `phases`, `agents`, `skills`, `prompt` (rules), `mainModelSwitch` (default `true`: the main loop may move down to a cheaper model; a value that is not a boolean turns it off and says so), `classify` (default `true`; `false` stops the prompt classifier on that machine), `probe` (default `true`: the model main runs on, moved to or kept, is tried once, 8 seconds at most, before main is sent to it; `false` skips the probe on that machine; a non-boolean value is ignored and said; `/route show` prints `probe:`), `verbose` (default `false`; `true` logs transitions only, a non-boolean value falls back to `false`), `spinner` (default `true`), `enabled` (default `true`; `false` turns the mod off on that machine), `ask` (overrides routing.json's `ask` on that machine), `askTier` (overrides routing.json's `askTier` on that machine; `best` or `false`, any other value reads `best` and is said once). A `null` value in `agents` or `skills` drops a row. Edit phases and rows by hand in routing.json (a phase's `about`, 120 characters at most, is read from there only and shown in the dialog; a model and effort pair no phase offers needs a new phase there); without it the mod runs the code's default phases, with no rows and no dialog. `/route reload` re-reads both files.
Config layers: `mods/model-router/routing.json` (tracked: phases with their tier, effort and `about` line, rows, decisions, `ask`, `askTier`), then the optional per-machine `~/.claude/model-router.json`, which wins. A `.claude/model-router.json` inside a project is never read. Machine keys: `models` (alias → full id), `windows` (context window per full id), `tiers` (ordered alias lists per tier: `best` opus>sonnet, `big` opus>sonnet, `work` sonnet>opus, `cheap` haiku>sonnet; the first alias not down is used), `fallback` (the rank order of the aliases, best first, used by the breaker; shipped fable>opus>sonnet>haiku, so a hand pick of fable ranks above opus though no shipped tier names it), `cooldownMinutes` (how long a model stays marked down after an availability error, 15 by default, doubling per episode up to 300), `mainUpgrade` (default `true`: the main loop may move up to a phase's tier), `upgradeMaxTokens` (default 200000: the largest cold read a main-loop upgrade may cost), `downgradeMaxTokens` (default 120000: the same cap for a downgrade; the cold read is the context minus what the target model's prompt cache already holds, taken from main's last step on that model within the prompt-cache TTL, forgotten by `/clear` and `/route reload`. The TTL follows the engine's `cache_ttl` (5 or 60 minutes) carried by main's model-switch events, is 60 minutes until the first one and survives `/clear`. The context also counts the prompt just submitted, which the engine's usage may not include yet: code points / 3 of its text, its context entries and a typed skill's body, summed and added at the turn's first main step unless usage already grew by half of it. A `document` attachment makes the size unknown, and an unknown context size blocks the switch; the step, `/route show`, the first-use dialog and the toast read the same adjusted size), `phases`, `agents`, `skills`, `prompt` (rules), `mainModelSwitch` (default `true`: the main loop may move down to a cheaper model; a value that is not a boolean turns it off and says so), `classify` (default `true`; `false` stops the prompt classifier on that machine), `probe` (default `true`: the model main runs on, moved to or kept, is tried once, 8 seconds at most, before main is sent to it; `false` skips the probe on that machine; a non-boolean value is ignored and said; `/route show` prints `probe:`), `verbose` (default `false`; `true` logs transitions only, a non-boolean value falls back to `false`), `spinner` (default `true`), `enabled` (default `true`; `false` turns the mod off on that machine), `ask` (overrides routing.json's `ask` on that machine), `askTier` (overrides routing.json's `askTier` on that machine; `best` or `false`, any other value reads `best` and is said once). A `null` value in `agents` or `skills` drops a row. Edit phases and rows by hand in routing.json (a phase's `about`, 120 characters at most, is read from there only and shown in the dialog; a model and effort pair no phase offers needs a new phase there); without it the mod runs the code's default phases, with no rows and no dialog. `/route reload` re-reads both files.
Limits: a main-loop switch re-reads cold the part of the context the target model's cache does not hold; a switch whose cold read is over its cap (`upgradeMaxTokens` up, `downgradeMaxTokens` down) is skipped (a `/model` hand pick is exempt) and main keeps its model, and a downgrade also needs `mainModelSwitch`. The prompt estimate is conservative (3 code points per token), so a long pasted prompt can hold back a switch that would have fit. The `/config` Model row still writes user `settings.json` with no scope question; a hand pick is dropped at `/clear`; a scope dialog never answered has no timeout. The hooks send full model ids, so the `models` table has to follow new model versions. A probe costs one small completion per model main runs on, the session's own model included, repeated only after that model is marked down, and holds that step up to 8 seconds when the model does not answer.
@@ -167,7 +186,7 @@ Limits: a main-loop switch re-reads cold the part of the context the target mode
- 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`.
- 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`. Each run also appends `## Advisor usage (<from> → <to>)` to FEEDBACK.md: advisor calls served since the last run (first run: every transcript on disk), per caller (main loop or sub-agent type) and model, with input tokens, all projects summed with no repo name. When the window starts before the 7-day transcript retention, a line warns that older calls may be missing. 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, repo tags and advisor call counts 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`.
- Off switch: `{"enabled": false}` in `~/.claude/memory.json`, read at the first event of a session, so it applies at the next session or after `/reload-plugins`. Off, the tool answers `memory capture is off (~/.claude/memory.json)`. A switch file that cannot be read, or whose `enabled` is not a boolean, keeps capture on and logs one line.
- Residuals: cross-process writes are unverified (two concurrent sessions: last writer wins). Non-Bash failures are not captured. `-b` counts as curl's cookie flag only when `curl` opens its command segment, after optional env assignments, `sudo`, `rtk` or `$(`: `time curl -b …` keeps its cookies. 40-hex Gitea tokens are kept by design: they look like commit SHAs. A session root that moves with `/cd` or a worktree move hides earlier captures of the same repo from /capitalize. A bare `gitflow.sh finish` on a chore branch counts as a milestone. Measured at 83 % noise before the error-shaped filter over 14 days of this repo's transcripts; the filter keeps every useful sample and cuts captures by two thirds (`.claude/tasks/plans/2026-11-03-memory-capture-spike/NOISE.md`).
@@ -251,7 +270,7 @@ a different package, ships its own conflicting `graphify` bin) — see
| `/audit-delta` | Recurring audit of changes since last run (norms, bugs, dead code, security) |
| `/capitalize` | Flush uncapitalized context + reconcile TODO before /clear or /compact (`--ritual` adds the end-of-session reflection) |
| `/prune-memory` | Curate and compress the .claude/memory/ registries; rewrite noisy recall entries and propose promotions from `/memory-feedback` |
| `/memory-feedback` | Label the memory mod's recall injections relevant or irrelevant from the transcripts, spot-check 5 labels with you, report precision and the phase 4d gates in ~/.claude/memory-feedback/FEEDBACK.md. Run it weekly: transcripts live 7 days |
| `/memory-feedback` | Label the memory mod's recall injections relevant or irrelevant from the transcripts, spot-check 5 labels with you, report precision, the phase 4d gates and advisor usage in ~/.claude/memory-feedback/FEEDBACK.md. Run it weekly: transcripts live 7 days |
| `/reconcile` | Confront declared status (TODO, registries) against real git/fs state — surface stale items |
| `/pdf-translate` | Translate a PDF to another language, output as HTML (via Vision) |
| `/explain-diff` | Explain a diff, commit, branch or PR as one self-contained HTML page (background, intuition, code walkthrough, 5-question quiz), saved outside the repo |
+3 -3
View File
@@ -161,7 +161,7 @@ Tu veux...
| `/audit-delta` | Audit récurrent du delta depuis le dernier run | Axes : conformité / bugs / dead code / sécurité |
| `/capitalize` | Avant /clear ou /compact | Flush contexte non capitalisé + réconcilie .claude/tasks/TODO.md |
| `/prune-memory` | Registres trop longs / bruyants | Curation : merge, superseded, compression ; réécriture des entrées bruyantes et propositions de promotion en mécanisme (règle, hook, garde, test) lues dans `~/.claude/memory-feedback/FEEDBACK.md` |
| `/memory-feedback` | Chaque semaine, ou quand la bannière le rappelle | Étiquette les injections du rappel mémoire depuis les transcripts, contrôle de 5 étiquettes avec toi, précision et gates de la phase 4d dans `~/.claude/memory-feedback/FEEDBACK.md` |
| `/memory-feedback` | Chaque semaine, ou quand la bannière le rappelle | Étiquette les injections du rappel mémoire depuis les transcripts, contrôle de 5 étiquettes avec toi, précision, gates de la phase 4d et usage de l'advisor dans `~/.claude/memory-feedback/FEEDBACK.md` |
| `/reconcile` | Connaître l'état réel du travail ouvert (TODO/registres douteux) | Confronte statut déclaré vs git/fs réel |
| `/close` | Fin de session | Alias de /capitalize --ritual — dedup + TODO + réflexion 3 questions |
| `/harden` | Audit sécurité web (SSL, CSP, HSTS) | Projet web avec config HTTP |
@@ -200,7 +200,7 @@ l'outil `mcp__model-router__route` (`lib/effort-shift.md`). Les skills
externes vendorés (pile design, superpowers, agent-skills, skills scroll
MengTo, 21st) ont aussi leur ligne.
Taper un skill qui a une ligne route la boucle principale dessus. Une ligne du tier best (plan, reflect, orchestrate, escalate ; `audit` est une ligne d'agent, jamais tapée) tient d'un tour à l'autre pendant tout le run, jusqu'à `/route clear`, `/route off`, un `/model` tapé ou choisi dans le sélecteur, ou un skill d'un autre tier tapé. Un `/model <nom>` tapé, ou un choix dans le sélecteur `/model`, avec un modèle de la table demande sa portée (Échap ne change rien). Le changement du sélecteur est d'abord retenu (le moteur affiche qu'un hook l'a bloqué), puis la question vient ; un choix fait pendant qu'un autre dialogue est ouvert est refusé (`answer the open dialog first`) : This project écrit l'id complet dans `model` du `.claude/settings.local.json` du projet (créé s'il manque, à garder dans le `.gitignore`) et pose une route de modèle tenue ; This conversation pose la route seule, sans rien écrire ; Everywhere lance le `/model` natif (`settings.json` utilisateur, tous les projets). Default dans le sélecteur, sans argument, avec un nom inconnu, en headless (`-p`) ou mod coupé, le `/model` natif passe sans question. Un modèle choisi dans ce dialogue change toujours : ni plafond de relecture à froid, ni `mainUpgrade` ni `mainModelSwitch`. S'il est en panne, la boucle principale reste où elle est jusqu'à son retour. Un changement natif (ligne Model de `/config` comprise) ou `/clear` l'abandonne ; un `/route model=` tapé garde les plafonds. La ligne Model de `/config` écrit toujours le `settings.json` utilisateur, et un dialogue jamais répondu n'a pas de délai. Pour relancer un tour bloqué : `ultrathink` dans le prompt (plancher d'effort du tour) ou `/route effort=max` (tient jusqu'à `/route clear`). Le `/effort` intégré n'a pas d'effet dans un run : les lignes et les routes passent devant. Les règles de mots-clés du prompt (`plan`, `design`, `architecture`… prennent l'effort de plan ; `pourquoi`, `review`, `audit`… celui de reflect), `ultrathink` et un lancement d'agent par la boucle principale (route `orchestrate` dérivée, tenue jusqu'à la fin de ses agents en arrière-plan) ne fixent que le niveau d'effort du tour, jamais le modèle : ils ne font jamais monter la boucle principale au-dessus du modèle de la session, et un run best tenu garde son modèle. Fable n'arrive sur la boucle principale que par une ligne de skill, l'outil `route`, un `/route` tapé ou un choix à la main (`/model`, sélecteur). Un prompt tapé sans règle, skill ni route en cours passe par un classifieur (un appel au petit modèle, 3 secondes au plus) : le tour prend la route de la phase devinée : son niveau d'effort, et son modèle, jamais au-dessus de celui de la session. Une devinette `coding` ou `bookkeeping` fait descendre la boucle principale vers un modèle moins cher quand `mainModelSwitch` est actif (par défaut) et que la relecture à froid tient sous `downgradeMaxTokens` (120000 tokens par défaut). Cette relecture compte aussi le prompt qui vient d'être envoyé (un token pour 3 caractères), et un document joint bloque la descente pour cette étape. Le cache compte comme chaud pendant le TTL du moteur (`cache_ttl`, 5 ou 60 minutes), 60 minutes par défaut. `/route classify off` ou `"classify": false` dans la config machine le coupe, et un `/effort` tapé entre deux tours annule la devinette pour ce tour seulement. Avant d'envoyer la boucle principale sur un modèle, celui vers lequel elle se déplace comme celui qu'elle garde (le modèle de la session compris), le mod l'essaie une fois (un appel minimal, 8 secondes au plus) : sans réponse, ce modèle est marqué en panne (raison `probe`) et la décision est reprise une fois ; `"probe": false` dans la config machine coupe cet essai, et `/route show` affiche `probe:`. Quand un modèle inférieur remplace la tête de son tier en panne (Opus pour Fable), le niveau propre de la phase monte d'un cran (reflect xhigh, plan max, orchestrate high) ; un niveau demandé explicitement ou un plancher ne bouge jamais. Les sous-agents reçoivent le modèle de leur ligne au lancement (dans leur tier, jamais en dessous de leur frontmatter) et son niveau à chaque étape ; un `model` ou `effort` explicite sur l'appel gagne. Explore tourne en sonnet/medium, Plan en opus/xhigh. Un agent intégré `general-purpose` lancé par la boucle principale sans `model`, pendant que celle-ci tourne sous le modèle de la session (descente, ou repli quand un modèle est en panne), part sur le modèle de la session au lieu d'hériter du modèle inférieur ; les autres types d'agents ne sont jamais épinglés ainsi. `/route show` affiche la route en cours, slot de run compris (`main: run <phase>`), et le switch avec son plafond et ce TTL (`switch: on (downgrade, cap 120000 tokens cold, ttl 60 min)`). Première utilisation : la première fois qu'un skill avec ligne est tapé, qu'un agent avec ligne est lancé ou qu'une phase est déclarée sur la boucle princiLine truncated
Taper un skill qui a une ligne route la boucle principale dessus. Une ligne du tier best (plan, reflect, orchestrate, escalate ; `audit` est une ligne d'agent, jamais tapée) tient d'un tour à l'autre pendant tout le run, jusqu'à `/route clear`, `/route off`, un `/model` tapé ou choisi dans le sélecteur, ou un skill d'un autre tier tapé. Un `/model <nom>` tapé, ou un choix dans le sélecteur `/model`, avec un modèle de la table demande sa portée (Échap ne change rien). Le changement du sélecteur est d'abord retenu (le moteur affiche qu'un hook l'a bloqué), puis la question vient ; un choix fait pendant qu'un autre dialogue est ouvert est refusé (`answer the open dialog first`) : This project écrit l'id complet dans `model` du `.claude/settings.local.json` du projet (créé s'il manque, à garder dans le `.gitignore`) et pose une route de modèle tenue ; This conversation pose la route seule, sans rien écrire ; Everywhere lance le `/model` natif (`settings.json` utilisateur, tous les projets). Default dans le sélecteur, sans argument, avec un nom inconnu, en headless (`-p`) ou mod coupé, le `/model` natif passe sans question. Un modèle choisi dans ce dialogue change toujours : ni plafond de relecture à froid, ni `mainUpgrade` ni `mainModelSwitch`. S'il est en panne, la boucle principale reste où elle est jusqu'à son retour. Un changement natif (ligne Model de `/config` comprise) ou `/clear` l'abandonne ; un `/route model=` tapé garde les plafonds. La ligne Model de `/config` écrit toujours le `settings.json` utilisateur, et un dialogue jamais répondu n'a pas de délai. Pour relancer un tour bloqué : `ultrathink` dans le prompt (plancher d'effort du tour) ou `/route effort=max` (tient jusqu'à `/route clear`). Le `/effort` intégré n'a pas d'effet dans un run : les lignes et les routes passent devant. Les règles de mots-clés du prompt (`plan`, `design`, `architecture`… prennent l'effort de plan ; `pourquoi`, `review`, `audit`… celui de reflect), `ultrathink` et un lancement d'agent par la boucle principale (route `orchestrate` dérivée, tenue jusqu'à la fin de ses agents en arrière-plan) ne fixent que le niveau d'effort du tour, jamais le modèle : ils ne font jamais monter la boucle principale au-dessus du modèle de la session, et un run best tenu garde son modèle. Fable n'arrive sur la boucle principale que par un choix à la main (`/model`, sélecteur), un `/route model=fable` tapé, une phase qui nomme `model: fable` ou une config machine qui le place dans un tier : aucun tier ni aucune phase livrés ne le contiennent. Fable sert de conseiller (outil advisor, `advisorModel` dans settings.json, réglé par `/advisor`) : la boucle principale l'appelle au moins sur le plan écrit, avant que les challengers du plan le voient (`lib/challenge-plan.md`, une fois par run de skill ; la ligne `Advisor:` du CHALLENGE SUMMARY dit ce qu'il a changé), une fois par run verify-secure à la première boucle de porte qui échoue deux fois (le conseil reste dans la boucle principale, jamais dans le brief d'un exécutant ; un STOP au plafond ou en escalade le reprend), avant de proposer un merge ou de déclarer finie une longue tâche (deux exceptions : `/feat` et `/bugfix` le sautent quand GATE 0 a dit MET, le verifier CONFORME et la sécurité PASS, pas DEGRADED, chacun au premier essai, et leur champ `ADVISOR` affiche alors `skipped (gates clean on first pass)` ; `/audit-delta` et `/tour` le sautent quand le run n'a appliqué aucun fix), et avant de recommander un changement de la doctrine, de l'architecture ou d'une interface publique ; plan-challenger, verifier, security-auditor et `analyzer` peuvent l'appeler une fois, seulement quand ils sont lancés comme sous-agents, avant leur verdict ou leur rapport : un conseil peut ajouter un constat ou relever sa sévérité, jamais le retirer, l'abaisser ni l'effacer ; les autres sous-agents ne l'appellent pas, même quand l'outil est listé. Conseiller absent ou en erreur : on continue ; un conseil ne lève aucune porte, aucun plafond ni aucune garde. Un prompt tapé sans règle, skill ni route en cours passe par un classifieur (un appel au petit modèle, 3 secondes au plus) : le tour prend la route de la phase devinée : son niveau d'effort, et son modèle, jamais au-dessus de celui de la session. Une devinette `coding` ou `bookkeeping` fait descendre la boucle principale vers un modèle moins cher quand `mainModelSwitch` est actif (par défaut) et que la relecture à froid tient sous `downgradeMaxTokens` (120000 tokens par défaut). Cette relecture compte aussi le prompt qui vient d'être envoyé (un token pour 3 caractères), et un document joint bloque la descente pour cette étape. Le cache compte comme chaud pendant le TTL du moteur (`cache_ttl`, 5 ou 60 minutes), 60 minutes par défaut. `/route classify off` ou `"classify": false` dans la config machine le coupe, et un `/effort` tapé entre deux tours annule la devinette pour ce toLine truncated
Garde d'écriture : un Edit, Write ou NotebookEdit d'un fichier de code par la boucle principale est redirigé avec « model-router: code is written inside a skill run… » tant qu'aucun skill n'a tourné sur la boucle principale dans la session (tapé ou chargé par le modèle ; un skill refusé ou inconnu ne compte pas), qu'aucune phase n'a été déclarée ce tour, et qu'aucun `/route` tapé ne tient. Chemins libres : `.md`, `.txt`, le `.claude/` du projet sauf `worktrees/`, et `docs/`. Les sous-agents écrivent librement. Si la vérification du garde échoue elle-même (exception ou délai dépassé), l'écriture est retenue au lieu de passer, avec « model-router: the write guard failed (<kind>), so this write is held… », journalisé une fois par session ; les sous-agents, un skill en cours, une phase déclarée ou un `/route` tapé, et les fichiers `.md` / `.txt` passent toujours, et une erreur levée par l'outil lui-même est transmise telle quelle. `/route clear`, `/route off` et `/clear` réarment le garde ; `/route off` le coupe aussi, et `"enabled": false` dans `~/.claude/model-router.json` coupe le routeur et le garde. Un choix à la main avec `/model` ne l'ouvre pas, et un rechargement de `register.ts` le remet à zéro.
@@ -220,7 +220,7 @@ Le mod `mods/memory/` note les échecs Bash et les jalons de la session pour que
- 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`.
- 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`. Chaque passage ajoute aussi `## Advisor usage (<from> → <to>)` à FEEDBACK.md : les appels à l'advisor servis depuis le passage précédent (premier passage : tous les transcripts présents), par appelant (boucle principale ou type de sous-agent) et par modèle, avec les tokens d'entrée, tous projets confondus, sans nom de dépôt. Quand la fenêtre commence avant la rétention de 7 jours des transcripts, une ligne prévient que des appels plus anciens peuvent manquer. 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, étiquettes de dépôt et compteurs d'appels advisor 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`.
- Interrupteur : `{"enabled": false}` dans `~/.claude/memory.json`, lu au premier événement d'une session : effet à la session suivante ou après `/reload-plugins`. Coupé, l'outil répond `memory capture is off (~/.claude/memory.json)`. Un fichier illisible, ou dont `enabled` n'est pas un booléen, laisse la capture active et journalise une ligne.
- Limites connues : les écritures entre processus ne sont pas vérifiées (deux sessions simultanées : la dernière écrit). Les échecs hors Bash ne sont pas captés. `-b` ne vaut drapeau de cookies de curl que si `curl` ouvre son segment de commande, après d'éventuelles affectations de variables, `sudo`, `rtk` ou `$(` : `time curl -b …` garde ses cookies. Un jeton de 40 hexadécimaux nu est gardé à dessein : il ressemble à un SHA de commit (expurgé seulement comme utilisateur d'URL). Une racine de session qui bouge avec `/cd` ou un changement de worktree cache à /capitalize les captures précédentes du même dépôt. Un `gitflow.sh finish` nu sur une branche chore compte comme un jalon. Bruit mesuré à 83 % avant le filtre de forme d'erreur sur 14 jours de transcripts de ce dépôt ; le filtre garde tous les échantillons utiles et réduit les captures des deux tiers (`.claude/tasks/plans/2026-11-03-memory-capture-spike/NOISE.md`).
+6
View File
@@ -43,6 +43,12 @@ Produce a clear analysis without proposing solutions.
- No solutions
- Stay factual
- Do not modify files
- Advisor, when dispatched as a sub-agent: at most one call, after the last
TASKS or PROCESS step and before the OUTPUT, whatever the harness prompt
schedules; absent or erroring → proceed. Advice may point you back to
the code; every OUTPUT line rests on what you read, never on the advice
alone. Advice proposing a design or a fix counts only where the brief
asks for a fix.
---
+7 -7
View File
@@ -267,10 +267,10 @@ the gate.
**Model routing (BDR-077):** EVERY `general-purpose` skill-runner dispatch in
this pipeline (initial audits, fix-loop re-dispatches, commit-change,
web-validate) carries `model: "fable"` and `effort="high"` — the child hosts gated
web-validate) carries `model: "opus"` and `effort="high"` — the child hosts gated
orchestration on the pipeline's behalf; it must never inherit the session model.
For web projects, dispatch in **a single message with two parallel Agent calls** (each with `model: "fable"`, `effort="high"`):
For web projects, dispatch in **a single message with two parallel Agent calls** (each with `model: "opus"`, `effort="high"`):
| Audit (web) | Subagent | Prompt template |
|---------------|-------------------|-----------------|
@@ -429,7 +429,7 @@ for CSO) in the format
### Re-dispatch prompt template (SEO + GEO loop)
Send to `general-purpose` subagent (`model: "fable"`, `effort="high"`):
Send to `general-purpose` subagent (`model: "opus"`, `effort="high"`):
> Read `~/.claude/skills/pack-seo/skills/seo/SKILL.md` and re-run it on this project in
> **conservative (audit-only) intervention mode**: re-score and leave both
@@ -460,7 +460,7 @@ Send to `general-purpose` subagent (`model: "fable"`, `effort="high"`):
### Re-dispatch prompt template (HARDEN loop)
Send to `general-purpose` subagent (`model: "fable"`, `effort="high"`):
Send to `general-purpose` subagent (`model: "opus"`, `effort="high"`):
> Read `~/.claude/skills/harden/SKILL.md` and re-run it with `--fix` ONLY
> up to the bundle: stop at `READY TO APPLY — awaiting dispatcher
@@ -473,7 +473,7 @@ Send to `general-purpose` subagent (`model: "fable"`, `effort="high"`):
### Re-dispatch prompt template (CSO loop — non-web only)
Send to `general-purpose` subagent (`model: "fable"`, `effort="high"`):
Send to `general-purpose` subagent (`model: "opus"`, `effort="high"`):
> Read `~/.claude/skills/pack-gstack-dev/skills/cso/SKILL.md` and re-run it in **daily mode**.
> Previous score: **`<SCORE_CSO_PREVIOUS>`/20** — below threshold.
@@ -562,7 +562,7 @@ listed changes by hand before deploy." Continue to STEP 6.
If `PENDING_CHANGES` non-empty → invoke /commit-change skill via subagent:
> Dispatch `general-purpose` subagent (`model: "fable"`, `effort="high"`). Prompt:
> Dispatch `general-purpose` subagent (`model: "opus"`, `effort="high"`). Prompt:
>
> "Read `~/.claude/skills/commit-change/SKILL.md` and execute. All pending
> changes were produced by the client-handover ship pipeline during the
@@ -682,7 +682,7 @@ Skip if `VALIDATE_SKIPPED=true` or `PROJECT_TYPE != web` (in either case
ensure `VALIDATE_SKIPPED=true` is set so the gate logic in STEP 8 treats
VALIDATE as not-applicable rather than failed).
Dispatch `general-purpose` subagent (`model: "fable"`, `effort="high"`):
Dispatch `general-purpose` subagent (`model: "opus"`, `effort="high"`):
> Read `~/.claude/skills/pack-web-validate/skills/web-validate/SKILL.md` and execute against the
> deployed URL: `<DEPLOYED_URL>`. Audit W3C HTML validity (validator.nu),
+14 -5
View File
@@ -97,23 +97,31 @@ PROOF: read <n> files, inspected <what>, checked plan §<…>
(STEP 1's missing/unreadable-plan verdict) is part of the grammar: it
carries only the `PLAN:` line — no FINDINGS, no PROOF — and the
orchestrator treats it as a dispatcher-side failure, not a challenge result.
- Advisor, when dispatched as a sub-agent: at most one call, after
drafting your findings and before the verdict, whatever the harness
prompt schedules; absent or erroring → proceed. Advice may add or
sharpen a finding. Advice alone never drops or lowers one: a change
rests on your own re-read, cited at file:line.
## ORCHESTRATOR PROTOCOL (consumer contract — wiring reference)
How an orchestrator runs the plan-challenge phase (the loop + synthesis live in
the MAIN loop, never here):
- ADVISOR FIRST (main loop): per `lib/challenge-plan.md` "Advisor first",
with no main-loop advisor call since the skill run started; absent or
erroring → dispatch as written. The advice never enters a challenger
brief: they stay blind.
- Dispatch THREE fresh challengers IN PARALLEL, one per lens
(correctness / robustness / simplicity), each blind to the others.
- MODEL (BDR-076, supersedes the BDR-066 inherit): plan critique is AUDIT
JUDGMENT, not a procedural gate — the challenger is routed to the `judge`
row (opus) by the model-router, the `model: opus` frontmatter being the
off-state floor (big tier; the main loop, on Fable through its best-tier
off-state floor (big tier; the main loop, on opus through its best-tier
row, stays inline).
Never `model: "sonnet"` — a silent judgment downgrade. (Contrast the
executors on their `implement` row, sonnet, oracle-anchored to a contract;
the verifier and security-auditor sit on the `audit` row, Fable with an
opus floor.)
the verifier and security-auditor sit on the `audit` row, opus.)
- FAIL-SAFE — never fail open: a malformed/empty verdict, a missing `PROOF`, or
a dead challenger → retry ONCE fresh; a 2nd failure → escalate to the human and
NAME the lens. Never report "plan challenged" on a silently dropped lens (same
@@ -127,5 +135,6 @@ the MAIN loop, never here):
- RE-CHALLENGE ONCE if synthesis materially changed the plan (a fix can open a
new flaw); max 1 extra pass, then the human gate.
- ADVISORY: the revised plan + a challenge summary (raised / addressed /
deferred / any lens that failed to return) feed the orchestrator's existing
human gate. The human decides — this is not a hard block.
deferred / any lens that failed to return / an `Advisor:` row) feed the
orchestrator's existing human gate. The human decides — this is not a
hard block.
+23 -6
View File
@@ -157,6 +157,21 @@ In audit mode, ALSO write this same block (plus per-finding detail) to
- Blocks on HIGH/CRITICAL only. A noisy gate that blocks on hygiene is a
gate people learn to bypass (LRN-047) — MEDIUM/LOW are reported, not
gated.
- Advisor, when dispatched as a sub-agent: at most one call, after
STEP 4 and before STEP 5 and any REPORT write, whatever the harness
prompt schedules; absent or erroring → proceed. Advice may add a
finding or raise a severity, cited at a file:line you read. An added
finding's rule/check is `advisor:<STEP 3 class>`; it takes that
class's severity, for that finding only, and is REPORTED as LOW when
it matches no class. A raise applies only when its class's severity
is higher than the finding's own: it keeps the finding's line, its
rule/check becoming `<rule>+advisor`, so it counts once. A raise
that does not apply, or matches no class, changes nothing: no tag,
no PROOF count. An added or applied finding enters STEP 5's dedup and
BLOCK(n) like any other, and PROOF ends with
`; advisor <n> added/raised`.
Advice never removes, lowers or waives a finding from semgrep, the
checklist or STEP 4.
## ORCHESTRATOR PROTOCOL (consumer contract — wiring reference)
@@ -167,14 +182,16 @@ In audit mode, ALSO write this same block (plus per-finding detail) to
- Dispatch a FRESH auditor each iteration — no context reuse. Input = mode +
scope + (report) + (context), nothing else.
- Parse the `SECURITY — VERDICT:` line:
- `PASS` → proceed (to commit / next step).
- `PASS` → read the `TOOL:` line first: DEGRADED (semgrep absent)
shows there, never on the VERDICT line; a PASS with no `TOOL:` line
is a structural failure (below). Then proceed (to commit / next
step); a DEGRADED PASS also surfaces the checklist result +
recommends `make plugin` (the tool's absence never blocks).
- `BLOCK(n)` → the dev subagent receives the BLOCKING list + the contract
path. After the fix: re-verify the REQUEST first (verifier), THEN re-run
this gate — in that order. Max 3 security iterations → STOP + human
escalation with the BLOCKING table.
- `DEGRADED` (semgrep absent) → does NOT block; surface the checklist
result + recommend `make plugin`. A DEGRADED BLOCK (grep-caught
hardcoded secret etc.) blocks like any other.
- Structural failure (`ERROR(…)`, missing/duplicated VERDICT line,
unparsable, crash, PASS without PROOF) → retry ONCE fresh; 2nd
structural failure → human escalation. A mute auditor is never a PASS.
unparsable, crash, PASS without PROOF or without `TOOL:` line) →
retry ONCE fresh; 2nd structural failure → human escalation. A mute
auditor is never a PASS.
+8
View File
@@ -158,6 +158,14 @@ PROOF: read <n> files, ran <cmd → result | nothing>, checked <n>/<n> criteria
missing `PROOF` — the run was skipped, not the diff clean.
- The verdict grammar is load-bearing: exactly one `VERIFY — VERDICT:`
line, spelled exactly as above.
- Advisor, when dispatched as a sub-agent: at most one call, after STEP 4
and before STEP 5, whatever the harness prompt schedules; absent or
erroring → proceed. Advice may send you back to a criterion: a
resulting NOT-MET cites the file:line you read, ends with
`(advisor-prompted)` and counts in STEP 5 like any other. Advice adds
no gap outside the contract's criteria. Advice alone never clears a
gap and is never evidence for a MET: any change rests on your own
re-read or run (STEP 2).
## ORCHESTRATOR PROTOCOL (consumer contract — wiring reference)
+19 -3
View File
@@ -27,9 +27,22 @@ explicitly deferred for the human.
Nominal path is cheap for a small, clean plan: three parallel challengers return
SOLID, synthesis is a no-op. It only costs more when a lens lands a real finding
— which is the point.
The main loop's advisor call before the dispatch (below) is the costliest
single item: once per skill run.
## DISPATCH — three fresh challengers, in parallel, blind
**Advisor first (main loop).** Before the first dispatch, with no main-loop
advisor call since the skill run started (so at most once per skill run, not
before a re-challenge), the main loop reads the `PLAN` file unless its full
text is already in this conversation, then calls the advisor when the tool
is listed (`lib/effort-shift.md` § Advisor). An answer that lands a real
flaw revises the `PLAN` file on disk before the dispatch, as plain plan
text: no advisor attribution, no "changes after review" section; the
summary's `Advisor:` row carries it (OUTPUT below). Absent or erroring →
dispatch as written.
The advice never enters a challenger brief: they stay blind.
Dispatch THREE fresh `plan-challenger` subagents IN PARALLEL, one per LENS, each
blind to the others and to this conversation:
@@ -45,10 +58,10 @@ Agent(subagent_type="plan-challenger", description="challenge:<lens>", prompt=""
**MODEL (BDR-076, supersedes the BDR-066 inherit):** plan critique is AUDIT
JUDGMENT — the challengers are routed to the `judge` row (opus) by the model-router,
the `model: opus` frontmatter being the off-state floor: a big tier, off
the main loop. The main loop (Fable through its best-tier row)
the main loop. The main loop (opus through its best-tier row)
keeps only this loop — synthesis, RE-THINK, gate. Never sonnet: that would
silently downgrade the judgment. (The executors stay sonnet; the two merge
gates sit on the `audit` row, Fable with an opus floor.)
gates sit on the `audit` row, opus.)
**Lens framing by `KIND`** (the agent's three lenses, read against the artifact):
- `build-plan` — will it WORK / will it BREAK / is it needlessly COMPLEX.
@@ -87,6 +100,9 @@ Parse each `CHALLENGE — LENS: … — VERDICT:` line and merge the FINDINGS:
Feed the orchestrator's gate:
- the REVISED plan, and
- a CHALLENGE SUMMARY: each BLOCKER raised → the named change that closed it;
anything `[deferred]`; and any lens that failed to return.
anything `[deferred]`; any lens that failed to return; and an `Advisor:`
row, added to whatever summary template the caller prints: each plan
change an advisor answer drove, `called, no change`, or
`not called (absent | error | already called this run)`.
The human remains the decider.
+57 -6
View File
@@ -28,8 +28,8 @@ load; a skill without one changes nothing, the last ROWED skill wins.
ship-feature STEP 4b. Not automatic: the challenge fail-safe and "gone
WRONG → STOP"; their STOP text names the levers below.
5. Built-in judgment dispatch (`general-purpose` `model="opus"`, `model:
"fable"` skill-runners) → explicit `effort=` on the Agent call (`xhigh`
for opus reviewers, `high` for fable runners). A main route never
"opus"` skill-runners) → explicit `effort=` on the Agent call (`xhigh`
for opus reviewers, `high` for skill-runners). A main route never
reaches a child. Typed agents run on their row, never on a shift.
6. After a prose gate that ends the turn, the resumed reflection phase
starts with its own route call.
@@ -82,20 +82,71 @@ back; the window guard needs a `windows` entry (none shipped). A typed
- Keyword prompt rules (`plan|design|architecture…`,
`why|review|audit…`), `ultrathink` and a background agent
dispatch (derived `orchestrate`) set the turn's effort only, never
a model above the session model: Fable on main comes only from a
skill row, the `route` tool, a typed `/route` or a hand pick (`/model`,
picker).
a model above the session model: Fable on main comes only from a hand
pick (`/model`, picker), a typed `/route model=fable`, a phase naming
`model: fable` or a machine override that puts fable in a tier (no
shipped tier or phase holds it, BDR-150).
- Mod off: typed agents fall back to their `model:`/`effort:` frontmatter.
- First use of a row asks once, with context (Later, Keep or Change: model,
then effort, then Everywhere or this project only); the answer is kept in
`mods/model-router/routing.json`. `/route pending` lists what is still
unconfirmed, `/route ask off|on` toggles the dialog, `/route ask-tier
off|on` the ask before a route lifts main or a rowed agent onto Fable,
off|on` the ask before a route lifts main or a rowed agent onto Fable
(inert unless a machine override heads `best` with fable),
`/route forget <name|all|projects>` takes a decision back.
Measure the split any time: `python3 ~/.claude/lib/effort-audit.py`
(thinking/output/cache tokens per scope, model and effort).
## Advisor
Fable runs as the advisor (settings `advisorModel`), never a route or pin
target (BDR-150). It is a server tool: the router cannot see or refuse it.
Main loop, at least at these points (for work outside them, see the
triggers in CLAUDE.global.md § Workflow):
1. Before settling an approach: on the written plan, before the
challengers see it (`lib/challenge-plan.md`), at most once per skill run.
2. When stuck: once per verify-secure run, at the first gate loop to fail
twice (floor, conformity, security, or a second structural failure),
before re-dispatching or escalating. At a cap the STOP diagnosis
reuses that advice and says whether it predates the last iteration. The
advice stays in the main loop: it feeds the main loop's own decision
(a contract micro-gate, an early escalation, the STOP diagnosis) and
never enters an executor brief.
3. Before proposing a merge (`gitflow finish`) or calling a long task
done. Wired at the commit step of feat and bugfix, at the end step
of ship-feature, init-project, a11y, guardrails, audit-delta and
tour, and at the release gate of release-candidate: one end-of-run
call per skill run, never skipped for an earlier plan or stuck call.
Two skips only: audit-delta and tour when the run applied no fix;
feat and bugfix when GATE 0 said MET, the verifier CONFORME and
security PASS (not DEGRADED), each on its first attempt (any other
verdict, a retry, a loop iteration or a verdict no longer in view
runs the call), their summary then reading
`skipped (gates clean on first pass)`; DEGRADED shows on the
auditor's `TOOL:` line. A skipped call discharges
its point and the trigger it covers. In the six flows that run the
gates (feat, bugfix, ship-feature, init-project, a11y, guardrails),
the main loop first prints the run's diff stat, a fix the answer
drives goes back through the gates, and a later merge proposal
reuses the last run's answer, or its skip, and names any code commit
made after it (doc and memory commits excepted). Elsewhere the
answer is reported only and a fix it calls for is a new run.
Inside a skill run, the points above also cover the triggers of
CLAUDE.global.md § Workflow; no second call for the same recommendation.
Sub-agents, when dispatched: plan-challenger, verifier, security-auditor
and `analyzer` call it at most once per dispatch, before their verdict or
report; executors and every other sub-agent do not, even when the tool is
listed. The analyzer file loaded inline by the main loop follows the
main-loop points.
Advisor absent or erroring (Fable out of credits, for example) → proceed
as written. Advice is input, never consent: it waives no gate, cap or
guard; at a loop cap it feeds the STOP diagnosis.
## Never
- A route inside a dispatched agent: its row rules there.
+27 -5
View File
@@ -29,7 +29,10 @@
# lib/url-guard.sh first.
set -uo pipefail
TIMEOUT="${GATES_TIMEOUT:-120}"
# TIMEOUT is per CHECK and a run lasts their sum: the caller's own limit (a
# foreground tool call stops at 600 s) must cover it, else run it in the
# background. A killed run writes nothing back; the floor stays PENDING.
TIMEOUT="${GATES_TIMEOUT:-600}"
EVIDENCE_CAP=140
# Module-level parse tables, index-aligned. Bash has no record type; threading
@@ -68,11 +71,23 @@ _new_crit() { # _new_crit <id> <text>
_CUR=$((${#_ID[@]} - 1))
}
# A second attribute on one criterion is an error, never an overwrite: it
# is what an oracle under a label the parser missed looks like (LRN-284).
_set_attr() { # _set_attr <CHECK|EXPECT|EVIDENCE> <value> <lineno>
if [ "$_CUR" -lt 0 ]; then
_err "$1 at line $3 belongs to no criterion"
return 0
fi
local seen=""
case "$1" in
CHECK) seen="${_CHECK[_CUR]}" ;;
EXPECT) seen="${_EXPECT[_CUR]}" ;;
EVIDENCE) [ "${_EVLINE[_CUR]}" = 0 ] || seen=yes ;;
esac
if [ -n "$seen" ]; then
_err "second $1: at line $3 in criterion ${_ID[_CUR]}"
return 0
fi
case "$1" in
CHECK) _CHECK[_CUR]="$2" ;;
EXPECT) _EXPECT[_CUR]="$2" ;;
@@ -82,11 +97,16 @@ _set_attr() { # _set_attr <CHECK|EXPECT|EVIDENCE> <value> <lineno>
# An UNINDENTED attribute is diagnosed, never absorbed: silently ignoring it
# would demote a runnable criterion to a manual one, which is the one parse
# bug that turns this checker into a rubber stamp.
# bug that turns this checker into a rubber stamp. A digit-led line that is
# not `N. text` (`1b.`, `1.1`, `2)`) is rejected and orphans what follows, like
# a duplicate id.
_absorb() { # _absorb <raw-line> <lineno>
local body
if [[ "$1" =~ ^([0-9]+)\.[[:space:]]+(.*)$ ]]; then
_new_crit "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}"
elif [[ "$1" =~ ^[0-9] ]]; then
_err "malformed criterion label at line $2 (want \`N. text\`)"
_CUR=-1
elif [[ "$1" =~ ^ABANDON:[[:space:]]*([0-9]+)?[[:space:]]*(.*)$ ]]; then
_ABANDON_ID+=("${BASH_REMATCH[1]}"); _ABANDON_WHY+=("${BASH_REMATCH[2]}")
elif [[ "$1" =~ ^(CHECK|EXPECT|EVIDENCE): ]]; then
@@ -300,11 +320,13 @@ _runnable_count() {
# ── entry point ─────────────────────────────────────────────────────────────
main() { # main <status|run> <contract>
local mode="$1" file="$2"
local mode="$1" file="$2" first
[ -r "$file" ] || _die "contract unreadable: $file"
_parse "$file"
[ "${#_ID[@]}" -gt 0 ] ||
_die "no numbered criteria under ## ACCEPTANCE CRITERIA"
if [ "${#_ID[@]}" -eq 0 ]; then
first="${_ERRORS[0]:+; ${_ERRORS[0]}}"
_die "no numbered criteria under ## ACCEPTANCE CRITERIA$first"
fi
_validate_oracles
_validate_abandons
if [ "$mode" = "run" ] && [ "${#_ERRORS[@]}" -eq 0 ]; then
+242
View File
@@ -0,0 +1,242 @@
import { afterAll, expect, test } from 'bun:test'
import * as fs from 'node:fs'
import * as os from 'node:os'
import * as path from 'node:path'
import {
MAIN, UNKNOWN_AGENT, advisorSection, advisorUsage, callerOf, compact,
renderAdvisor, type Tally,
} from './advisor.ts'
const dirs: string[] = []
afterAll(() => dirs.forEach(d => fs.rmSync(d, { recursive: true })))
const mk = () => {
const d = fs.mkdtempSync(path.join(os.tmpdir(), 'mf-adv-'))
dirs.push(d)
return d
}
const DAY = 86400000
const FROM = Date.parse('2026-01-01T00:00:00Z')
const TO = FROM + 10 * DAY
const SLUG = '-home-secret-slug'
const iso = (ms: number) => new Date(FROM + ms).toISOString()
const adv = (input: number, model = 'claude-fable-5-2') =>
({ type: 'advisor_message', model, input_tokens: input })
const row = (ms: number, id: string, its: object[], type = 'assistant') =>
({ type, timestamp: iso(ms), message: { id, usage: { iterations: its } } })
const lines = (recs: object[]) =>
recs.map(r => JSON.stringify(r)).join('\n') + '\n'
/** A projects dir with one project dir; returns both paths. */
function fixture() {
const projects = mk()
const proj = path.join(projects, SLUG)
fs.mkdirSync(proj)
return { projects, proj }
}
const put = (file: string, recs: object[]) =>
fs.writeFileSync(file, lines(recs))
const subDir = (proj: string, session = 's1') => {
const d = path.join(proj, session, 'subagents')
fs.mkdirSync(d, { recursive: true })
return d
}
const only = (t: Tally) => t.uses.map(u =>
[u.caller, u.model, u.calls, u.input])
test('1: one main row, duplicate rows deduped by message.id', () => {
const { projects, proj } = fixture()
put(path.join(proj, 's1.jsonl'), [
row(10, 'm1', [adv(1500)]), row(10, 'm1', [adv(1500)])])
expect(only(advisorUsage(projects, FROM, TO)))
.toEqual([[MAIN, 'claude-fable-5-2', 1, 1500]])
})
test('2: rows outside (from, to] are not counted', () => {
const { projects, proj } = fixture()
put(path.join(proj, 's1.jsonl'), [row(0, 'a', [adv(1)]),
row(-5, 'b', [adv(1)]), row(11 * DAY, 'c', [adv(1)]),
row(1000, 'd', [adv(7)])])
expect(only(advisorUsage(projects, FROM, TO))[0]?.[3]).toBe(7)
})
test('3: a user record and a torn line are ignored', () => {
const { projects, proj } = fixture()
fs.writeFileSync(path.join(proj, 's1.jsonl'),
lines([row(10, 'u', [adv(5)], 'user')]) + '{"torn advisor_message\n')
const t = advisorUsage(projects, FROM, TO)
expect(t.uses).toEqual([])
expect(t.unparsed).toBe(0)
})
test('4: two advisor iterations in one message are two calls', () => {
const { projects, proj } = fixture()
put(path.join(proj, 's1.jsonl'), [row(10, 'm', [adv(1), adv(2)])])
expect(only(advisorUsage(projects, FROM, TO)))
.toEqual([[MAIN, 'claude-fable-5-2', 2, 3]])
})
test('5: an iteration without model is `unknown`', () => {
const { projects, proj } = fixture()
const bare = { type: 'advisor_message', input_tokens: 4 }
put(path.join(proj, 's1.jsonl'), [row(10, 'm', [bare])])
expect(advisorUsage(projects, FROM, TO).uses[0]?.model).toBe('unknown')
})
/** One sub-agent transcript per entry; its meta file only when given. */
function putAgents(sub: string, metas: Record<string, string | undefined>) {
for (const [id, meta] of Object.entries(metas)) {
put(path.join(sub, `agent-${id}.jsonl`), [row(10, id, [adv(1)])])
if (meta) fs.writeFileSync(path.join(sub, `agent-${id}.meta.json`), meta)
}
}
test('6: sub-agent callers come from the meta agentType', () => {
const { projects, proj } = fixture()
putAgents(subDir(proj), {
a1: '{"agentType":"verifier"}', a2: undefined,
a3: '{"agentType":"../x"}' })
const t = advisorUsage(projects, FROM, TO)
expect(t.uses.map(u => [u.caller, u.calls]).sort())
.toEqual([['verifier', 1], [UNKNOWN_AGENT, 2]].sort())
})
test('7: a transcript with mtime <= from is skipped', () => {
const { projects, proj } = fixture()
const f = path.join(proj, 's1.jsonl')
put(f, [row(10, 'm', [adv(1)])])
fs.utimesSync(f, new Date(FROM - 1000), new Date(FROM - 1000))
const t = advisorUsage(projects, FROM, TO)
expect(t.uses).toEqual([])
expect(t.files).toBe(0)
})
test('8: missing projects dir, and a window with no advisor row', () => {
const none = path.join(mk(), 'absent')
expect(advisorUsage(none, FROM, TO))
.toEqual({ uses: [], unparsed: 0, files: 0 })
const s = advisorSection(none, FROM, TO)
expect(s).toContain('## Advisor usage (2026-01-01 → 2026-01-11)')
expect(s).toContain('No transcript modified since 2026-01-01')
expect(s).toContain('check the path.')
const { projects, proj } = fixture()
put(path.join(proj, 's1.jsonl'), [row(10, 'm', [])])
expect(advisorSection(projects, FROM, TO))
.toContain('No advisor call in the window.')
})
test('9: render: all on disk, compact, total row, sort order', () => {
expect([999, 1500, 999950, 2500000].map(compact))
.toEqual(['999', '1.5k', '1.0M', '2.5M'])
const uses = [
{ caller: 'verifier', model: 'm', calls: 9, input: 1000 },
{ caller: MAIN, model: 'm', calls: 2, input: 1500 },
{ caller: 'planner', model: 'm', calls: 3, input: 500 }]
const t = { uses: [...uses].sort((a, b) =>
Number(b.caller === MAIN) - Number(a.caller === MAIN) ||
b.calls - a.calls), unparsed: 0, files: 3 }
const s = renderAdvisor(t, 0, TO)
expect(s.startsWith('## Advisor usage (all on disk → 2026-01-11)\n'))
.toBe(true)
expect(s).toContain('| total | | 14 | 3.0k |')
expect(s.indexOf('| main loop')).toBeLessThan(s.indexOf('| verifier'))
expect(s.indexOf('| verifier')).toBeLessThan(s.indexOf('| planner'))
expect(s.endsWith('\n')).toBe(true)
})
test('9b: advisorUsage sorts main loop first, then calls desc', () => {
const { projects, proj } = fixture()
put(path.join(proj, 's1.jsonl'), [row(10, 'm', [adv(1)])])
const sub = subDir(proj)
put(path.join(sub, 'agent-a.jsonl'),
[row(10, 'x', [adv(1)]), row(20, 'y', [adv(1)])])
fs.writeFileSync(path.join(sub, 'agent-a.meta.json'),
'{"agentType":"verifier"}')
expect(advisorUsage(projects, FROM, TO).uses.map(u => u.caller))
.toEqual([MAIN, 'verifier'])
})
test('10: the section holds no project slug or path', () => {
const { projects, proj } = fixture()
put(path.join(proj, 's1.jsonl'), [row(10, 'm', [adv(1)])])
const s = advisorSection(projects, FROM, TO)
expect(s).toContain('| main loop |')
expect(s).not.toContain('secret-slug')
expect(s).not.toContain(projects)
})
test('11: an advisor block with no iteration is not a call', () => {
const { projects, proj } = fixture()
const blockOnly = { type: 'assistant', timestamp: iso(10), message: {
id: 'm', content: [{ type: 'server_tool_use', name: 'advisor' }],
usage: { iterations: [] } } }
fs.writeFileSync(path.join(proj, 's1.jsonl'), lines([blockOnly]) +
'{"type":"assistant","note":"advisor_message"}\n')
const t = advisorUsage(projects, FROM, TO)
expect(t.uses).toEqual([])
expect(t.unparsed).toBe(0)
})
const drift = { type: 'assistant', timestamp: iso(10), message: {
id: 'd', usage: { advisor_message: { input_tokens: 1 } } } }
test('12: shape drift is counted and replaces the plain zero', () => {
const { projects, proj } = fixture()
put(path.join(proj, 's1.jsonl'), [drift])
const t = advisorUsage(projects, FROM, TO)
expect(t.unparsed).toBe(1)
const s = renderAdvisor(t, FROM, TO)
expect(s).toContain('1 transcript lines mention advisor_message, none ' +
'parsed: check the transcript shape.')
expect(s).not.toContain('No advisor call')
})
test('13: the retention note appears past 7 calendar days only', () => {
const t: Tally = { uses: [], unparsed: 0, files: 1 }
expect(renderAdvisor(t, TO - 10 * DAY, TO)).toContain(
'Transcripts kept 7 d: calls before 2026-01-04 may be missing.')
expect(renderAdvisor(t, TO - 3 * DAY, TO)).not.toContain('Transcripts kept')
expect(renderAdvisor(t, 0, TO)).not.toContain('Transcripts kept')
const to = TO + 17 * 3600000 // a weekly run lands mid-day, not at 00:00
expect(renderAdvisor(t, to - 7 * DAY - 5 * 3600000, to))
.not.toContain('Transcripts kept')
})
test('14: an unreadable sub-directory is skipped, the rest counts', () => {
const { projects, proj } = fixture()
put(path.join(proj, 's1.jsonl'), [row(10, 'm', [adv(1)])])
const sub = subDir(proj, 's2')
put(path.join(sub, 'agent-a.jsonl'), [row(10, 'z', [adv(1)])])
const locked = path.join(proj, 's2')
fs.chmodSync(locked, 0o000)
try {
const t = advisorUsage(projects, FROM, TO)
if (process.getuid?.() !== 0) expect(only(t))
.toEqual([[MAIN, 'claude-fable-5-2', 1, 1]])
} finally {
fs.chmodSync(locked, 0o700)
}
})
test('15: a hand-edited from never throws', () => {
const none = path.join(mk(), 'absent')
for (const bad of [Infinity, 1e17, NaN]) {
expect(advisorSection(none, bad, TO)).toContain('(all on disk → ')
}
})
test('16: drift under a table prints the table then the drift line', () => {
const { projects, proj } = fixture()
put(path.join(proj, 's1.jsonl'), [row(10, 'm', [adv(1)]), drift])
const s = advisorSection(projects, FROM, TO)
expect(s.indexOf('| total |')).toBeGreaterThan(0)
expect(s.indexOf('none parsed')).toBeGreaterThan(s.indexOf('| total |'))
})
test('17: a symlinked meta file is not trusted', () => {
const { proj } = fixture()
const sub = subDir(proj)
const real = path.join(mk(), 'meta.json')
fs.writeFileSync(real, '{"agentType":"verifier"}')
fs.symlinkSync(real, path.join(sub, 'agent-a.meta.json'))
expect(callerOf(path.join(sub, 'agent-a.jsonl'))).toBe(UNKNOWN_AGENT)
})
+211
View File
@@ -0,0 +1,211 @@
// lib/memory-feedback/advisor.ts: advisor usage read from Claude Code
// transcripts (Run C, LRN-295): served calls and input tokens per caller
// and model, deduped by message.id, for the FEEDBACK.md section.
import * as fs from 'node:fs'
import * as path from 'node:path'
export type Use = {
caller: string; model: string; calls: number; input: number
}
export type Tally = { uses: Use[]; unparsed: number; files: number }
export type Source = { file: string; caller: string }
type Obj = Record<string, unknown>
type Acc = { seen: Set<string>; uses: Map<string, Use>; unparsed: number }
export const MAIN = 'main loop'
export const UNKNOWN_AGENT = 'sub-agent (unknown)'
export const RETENTION_DAYS = 7
const DAY_MS = 86400000
const META_MAX = 65536
const MARK = 'advisor_message'
const AGENT_RE = /^[A-Za-z0-9_.:-]{1,64}$/
const MODEL_RE = /^[A-Za-z0-9._:-]{1,80}$/
const UNAVAILABLE = 'Unavailable: transcripts unreadable.'
const day = (ms: number) => new Date(ms).toISOString().slice(0, 10)
const since = (from: number) => from === 0 ? 'all on disk' : day(from)
const heading = (from: number, to: number) =>
`## Advisor usage (${since(from)} → ${day(to)})`
const obj = (v: unknown): Obj | undefined =>
typeof v === 'object' && v !== null && !Array.isArray(v)
? v as Obj : undefined
function lstatOf(p: string): fs.Stats | undefined {
try {
return fs.lstatSync(p)
} catch {
return undefined
}
}
/** Directory entries; [] when unreadable or gone, never throws. */
function listDir(dir: string): string[] {
try {
return fs.readdirSync(dir)
} catch {
return []
}
}
const isRealDir = (p: string) => lstatOf(p)?.isDirectory() === true
/** Regular `<prefix>*.jsonl` files of `dir` newer than `from`. */
function jsonlIn(
dir: string, prefix: string, from: number, callerOf: (f: string) => string,
): Source[] {
return listDir(dir)
.filter(n => n.startsWith(prefix) && n.endsWith('.jsonl'))
.map(n => path.join(dir, n))
.flatMap(file => {
const st = lstatOf(file)
return st?.isFile() && st.mtimeMs > from
? [{ file, caller: callerOf(file) }] : []
})
}
/** Every transcript under `projects` modified after `from`, with its
* caller: main threads and `<session>/subagents/agent-*.jsonl`. */
export function transcriptsOf(projects: string, from: number): Source[] {
return listDir(projects).map(n => path.join(projects, n))
.filter(isRealDir).flatMap(proj => {
const subs = listDir(proj).map(n => path.join(proj, n))
.filter(isRealDir).map(s => path.join(s, 'subagents'))
.filter(isRealDir)
return [...jsonlIn(proj, '', from, () => MAIN),
...subs.flatMap(s => jsonlIn(s, 'agent-', from, callerOf))]
})
}
/** The agent type of a sub-agent transcript, from its sibling meta file;
* UNKNOWN_AGENT for anything missing, odd or oversized. */
export function callerOf(jsonl: string): string {
const meta = jsonl.replace(/\.jsonl$/, '') + '.meta.json'
const st = lstatOf(meta)
if (!st?.isFile() || st.size > META_MAX) return UNKNOWN_AGENT
try {
const type = obj(JSON.parse(fs.readFileSync(meta, 'utf8')))?.agentType
return typeof type === 'string' && AGENT_RE.test(type)
? type : UNKNOWN_AGENT
} catch {
return UNKNOWN_AGENT
}
}
/** The assistant messages of a file that mention advisor_message and
* fall in (from, to]; [] for an unreadable file. */
function windowed(file: string, from: number, to: number): Obj[] {
let text: string
try {
text = fs.readFileSync(file, 'utf8')
} catch {
return []
}
return text.split('\n').filter(l => l.includes(MARK)).flatMap(line => {
try {
const rec = obj(JSON.parse(line))
const at = Date.parse(String(rec?.timestamp))
const msg = obj(rec?.message)
return rec?.type === 'assistant' && msg !== undefined &&
at > from && at <= to ? [msg] : []
} catch {
return []
}
})
}
function bump(uses: Map<string, Use>, caller: string, it: Obj): void {
const model = typeof it.model === 'string' && MODEL_RE.test(it.model)
? it.model : 'unknown'
const key = `${caller}\t${model}`
const use = uses.get(key) ?? { caller, model, calls: 0, input: 0 }
use.calls += 1
use.input += Number.isSafeInteger(it.input_tokens) &&
(it.input_tokens as number) >= 0 ? it.input_tokens as number : 0
uses.set(key, use)
}
/** Counts one message once: its served advisor iterations, or a drift. */
function tallyOne(msg: Obj, caller: string, acc: Acc): void {
const id = msg.id
if (typeof id !== 'string' || id === '' || acc.seen.has(id)) return
acc.seen.add(id)
const its = obj(msg.usage)?.iterations
const calls = (Array.isArray(its) ? its : []).map(obj)
.filter((i): i is Obj => i?.type === MARK)
calls.forEach(it => bump(acc.uses, caller, it))
if (calls.length === 0 &&
JSON.stringify(msg.usage ?? null).includes(MARK)) acc.unparsed += 1
}
const byUse = (a: Use, b: Use) =>
Number(b.caller === MAIN) - Number(a.caller === MAIN) ||
b.calls - a.calls || a.caller.localeCompare(b.caller) ||
a.model.localeCompare(b.model)
/** Served advisor calls and input tokens in (from, to], per caller and
* model, over every transcript under `projects`. */
export function advisorUsage(
projects: string, from: number, to: number,
): Tally {
const sources = transcriptsOf(projects, from)
const acc: Acc = { seen: new Set(), uses: new Map(), unparsed: 0 }
for (const s of sources) {
windowed(s.file, from, to).forEach(m => tallyOne(m, s.caller, acc))
}
return { uses: [...acc.uses.values()].sort(byUse),
unparsed: acc.unparsed, files: sources.length }
}
/** 999 → `999`, 1500 → `1.5k`, 2500000 → `2.5M`. */
export function compact(n: number): string {
if (n < 1000) return String(n)
return n < 999950 ? `${(n / 1e3).toFixed(1)}k` : `${(n / 1e6).toFixed(1)}M`
}
function table(uses: Use[]): string {
const sum = (f: (u: Use) => number) => uses.reduce((a, u) => a + f(u), 0)
const rows = uses.map(u =>
`| ${u.caller} | ${u.model} | ${u.calls} | ${compact(u.input)} |`)
return ['| caller | model | calls | input tok |', '|---|---|---|---|',
...rows, `| total | | ${sum(u => u.calls)} | ` +
`${compact(sum(u => u.input))} |`].join('\n')
}
function bodyOf(t: Tally, from: number): string {
const drift = `${t.unparsed} transcript lines mention ${MARK}, none ` +
'parsed: check the transcript shape.'
if (t.uses.length > 0) {
return t.unparsed > 0 ? `${table(t.uses)}\n\n${drift}` : table(t.uses)
}
if (t.files === 0) {
return `No transcript modified since ${since(from)} under the ` +
'projects dir: check the path.'
}
return t.unparsed > 0 ? drift : 'No advisor call in the window.'
}
/** The `## Advisor usage` markdown section, ending with a newline. */
export function renderAdvisor(t: Tally, from: number, to: number): string {
const blocks = [heading(from, to)]
const cut = day(to - RETENTION_DAYS * DAY_MS)
if (from > 0 && cut > day(from)) {
blocks.push(`Transcripts kept ${RETENTION_DAYS} d: calls before ` +
`${cut} may be missing.`)
}
blocks.push(bodyOf(t, from))
return blocks.join('\n\n') + '\n'
}
/** The section for FEEDBACK.md; a fixed Unavailable text on any failure
* (an error message could carry a path). Never throws. */
export function advisorSection(
projects: string, from: number, to: number,
): string {
const f = Number.isFinite(from) && from >= 0 && from <= to ? from : 0
try {
return renderAdvisor(advisorUsage(projects, f, to), f, to)
} catch {
return `${heading(f, to)}\n\n${UNAVAILABLE}\n`
}
}
+3
View File
@@ -109,6 +109,9 @@ test('R5: apply writes labels, state, FEEDBACK; a second apply refuses',
const fb = apply(work, p, NOW)
expect(fb).toContain('Prompt gate: open (1/20)')
expect(fb).toContain('Lost records: 1')
expect(fb).toContain('## Advisor usage')
expect(fs.readFileSync(path.join(p.out, 'FEEDBACK.md'), 'utf8'))
.toContain('## Advisor usage')
expect(fb).not.toContain('design the reader gate')
const labels = fs.readFileSync(path.join(p.out, 'labels.tsv'), 'utf8')
expect(labels).not.toContain('design')
+3 -1
View File
@@ -16,6 +16,7 @@ import {
tagOf, writeSafe, writeState, type Draft, type Item, type Row,
type State,
} from './labels.ts'
import { advisorSection } from './advisor.ts'
import { PROMPT_GATE_N } from './thresholds.ts'
import {
clockStart, gateVerdict, metricsOf, renderFeedback, type Metrics,
@@ -301,7 +302,8 @@ function commit(
assertFresh(items, labelsOf(p))
const { fresh, m, v } = projected(items, drafts, p, now)
const next = nextState(readState(stateOf(p)), m, v, now)
const feedback = renderFeedback(m, v, now)
const feedback = renderFeedback(m, v, now) + '\n' +
advisorSection(p.projects, readState(stateOf(p)).lastRun, now)
if (fresh.length > 0) appendRows(labelsOf(p), fresh)
writeState(stateOf(p), next.state)
writeSafe(path.join(p.out, 'FEEDBACK.md'), feedback)
+5 -4
View File
@@ -12,6 +12,7 @@ call. The answer names the id main runs on next.
| answer | action |
|---|---|
| names a fable or opus id | proceed, SILENT |
| says the model is `fixed at spawn` (sub-agent) | proceed, SILENT |
| names sonnet, haiku, anything else; "is off"; tool absent | **STOP** |
**STOP means**: print exactly `⛔ MODEL GATE — session on <model>.
@@ -24,7 +25,7 @@ the turn. No later step runs, no agent is dispatched, nothing is edited.
The gate guards the MAIN loop only. Typed agents are routed by their
model-router row (`model:` frontmatter = off-state floor). Built-ins
(general-purpose / Explore / Plan) carry an explicit `model=` at every call
site: `model: "fable"` when the child reflects/orchestrates for the main
loop (skill-runners), else its tier (opus = dispatched judgment, sonnet =
execution, haiku = mechanical probes). A built-in judgment dispatch also
carries an explicit `effort=` (`lib/effort-shift.md`).
site, its tier: `model: "opus"` = skill-runners (the child reflects or
orchestrates for the main loop) and dispatched judgment, sonnet = execution,
haiku = mechanical probes; never fable (BDR-150, the advisor). A built-in
judgment dispatch also carries an explicit `effort=` (`lib/effort-shift.md`).
+7 -12
View File
@@ -53,19 +53,13 @@ code_phase() {
awk '/^ phases: \{/{f=1;next} f&&/^ \},?$/{f=0} f' "$REG" \
| sed -nE "s/^ *$1: \{ tier: '([a-z]+)', effort: '([a-z]+)' \},?$/\1 \2/p"
}
# tier_floor <file> <tier> -> the model: floor of a tier's agents
# a best-tier row floors on its 2nd alias: inTier keeps the frontmatter when the head is down (Fable credits, BLK-030); a fable floor would spawn the gates on a dead model
tier_floor() {
if [ "$2" != best ]; then tier_head "$1" "$2"; return; fi
awk '/^ tiers: \{/{f=1;next} f&&/^ \},?$/{f=0} f' "$1" \
| sed -nE "s/^ *best: \['[a-z]+', '([a-z]+)'.*$/\1/p"
}
# field_of <dump> <phase> <effort|model> -> that phase's frontmatter value
# best is headed by opus since 2026-11-16: the floor is the tier head
field_of() {
local pe tier
pe="$(phase_effort "$1" "$2")"
if [ "$3" = effort ]; then printf '%s\n' "${pe#* }"; return; fi
tier="${pe% *}"; tier_floor "$REG" "$tier"
tier="${pe% *}"; tier_head "$REG" "$tier"
}
# verdict <dump> <kind> <name> <effort|model> <got> <phase>: ok when the
# frontmatter equals the row's phase; warn when the row was changed through
@@ -119,8 +113,7 @@ FD="$(dump "$FIX/routing.json")"
[ "$(phase_effort "$FD" judge)" = "big xhigh" ] && ok || ko "flip: phase"
[ -z "$(phase_effort "$FD" nothere)" ] && ok || ko "flip: ghost phase"
[ "$(tier_head "$FIX/reg.ts" big)" = "opus" ] && ok || ko "flip: tier head"
[ "$(tier_floor "$FIX/reg.ts" best)" = opus ] && ok || ko "flip: best floors on its 2nd alias"
[ "$(tier_floor "$FIX/reg.ts" big)" = opus ] && ok || ko "flip: big floors on its head"
[ "$(tier_head "$FIX/reg.ts" best)" = fable ] && ok || ko "flip: best head"
[ "$(changed_of "$FD" skills feat)" = "reflect implement" ] && ok || ko "flip: changed entry"
[ -z "$(changed_of "$FD" skills doc)" ] && ok || ko "flip: ghost changed entry"
# the drift verdicts (high = reflect's effort, medium = implement's)
@@ -228,8 +221,10 @@ n_opus="$(grep -c 'model="opus",$' "$R/skills/onboard/SKILL.md")"
n_eff="$(grep -c 'effort="xhigh",$' "$R/skills/onboard/SKILL.md")"
[ "$n_opus" -ge 7 ] && [ "$n_opus" -eq "$n_eff" ] && ok \
|| ko "onboard: $n_opus model=\"opus\" dispatches vs $n_eff effort=\"xhigh\""
bad="$(grep 'model: "fable"' "$R/agents/client-handover-writer.md" | grep -vc 'effort="high"')"
[ "$bad" -eq 0 ] && ok || ko "client-handover-writer: $bad model: \"fable\" line(s) without effort=\"high\""
n_opus="$(grep -c 'model: "opus"' "$R/agents/client-handover-writer.md")"
n_eff="$(grep 'model: "opus"' "$R/agents/client-handover-writer.md" | grep -c 'effort="high"')"
[ "$n_opus" -eq 7 ] && [ "$n_opus" -eq "$n_eff" ] && ok \
|| ko "client-handover-writer: $n_opus model: \"opus\" lines vs $n_eff with effort=\"high\" (want 7/7)"
for s in ship-feature init-project feat bugfix web-validate seo hotfix geo harden code-clean audit-delta tour onboard; do
has "$(skdir "$s")/SKILL.md" 'ROUTING: follow $HOME/.claude/lib/effort-shift.md'
done
+64
View File
@@ -89,6 +89,17 @@ GATES_TIMEOUT=1 gate "timeout = UNMET" run "GATES — VERDICT: UNMET(1)" 2 <<'EO
EOF
has "timeout recorded" "NOT-MET timeout=1s"
# The default must outlast the full suite (~135 s on 2026-11-16): at 120 s
# a "full make test green" criterion went NOT-MET on the timeout alone.
LAST="$WORK/default-timeout.md"
printf '## ACCEPTANCE CRITERIA\n1. manual\n' > "$LAST"
out="$(env -u GATES_TIMEOUT bash "$GATES" status "$LAST" 2>&1)"
if [[ "$out" == *"timeout 600s"* ]]; then
ok "default timeout 600s"
else
bad "default timeout 600s" "status did not print timeout 600s"
fi
gate "manual-only contract passes through" run "RUNNABLE: 0 of 2" 0 <<'EOF'
## ACCEPTANCE CRITERIA
1. a human reads the copy
@@ -203,6 +214,59 @@ gate "duplicate orphans what follows" run "belongs to no criterion" 2 <<'EOF'
EVIDENCE: pending
EOF
# An oracle under a label the parser does not read as `N. text` must never
# overwrite the previous criterion's: criterion 1 fails, the stray oracle
# passes, a false MET (LRN-284). A digit-led label is rejected by name;
# any other shape trips the second-attribute guard when the previous
# criterion already has that attribute (after a manual one it does not).
gate "1b. label rejected" run "malformed criterion label at line 6" 2 <<'EOF'
## ACCEPTANCE CRITERIA
1. real
CHECK: exit 1
EXPECT: x
EVIDENCE: pending
1b. sub
CHECK: echo y
EXPECT: y
EVIDENCE: pending
EOF
gate "1.1 label rejected" run "malformed criterion label at line 3" 2 <<'EOF'
## ACCEPTANCE CRITERIA
1. first
1.1 dotted
EVIDENCE: pending
EOF
gate "no valid label" run "malformed criterion label at line 2" 2 <<'EOF'
## ACCEPTANCE CRITERIA
2) paren
EOF
gate "indented label: second CHECK" run "second CHECK: at line 7" 2 <<'EOF'
## ACCEPTANCE CRITERIA
1. real
CHECK: exit 1
EXPECT: x
EVIDENCE: pending
2. sub
CHECK: echo y
EXPECT: y
EVIDENCE: pending
EOF
gate "bullet label: second EVIDENCE" run "second EVIDENCE: at line 9" 2 <<'EOF'
## ACCEPTANCE CRITERIA
1. real
CHECK: exit 1
EXPECT: x
EVIDENCE: pending
- sub
CHECK: echo y
EXPECT: y
EVIDENCE: pending
EOF
gate "no numbered criteria" run "no numbered criteria" 2 <<'EOF'
## ACCEPTANCE CRITERIA
nothing numbered here
+38
View File
@@ -17,6 +17,10 @@ HSK="$REPO/skills/hotfix/SKILL.md"
GSK="$REPO/skills/guardrails/SKILL.md"
ASK="$REPO/skills/a11y/SKILL.md"
HSKL="$REPO/skills/hotfix/SKILL.md"
AUD="$REPO/agents/security-auditor.md"
EFF="$REPO/lib/effort-shift.md"
SFK="$REPO/skills/ship-feature/SKILL.md"
ISK="$REPO/skills/init-project/SKILL.md"
PASS=0; FAIL=0
tf() { # tf <label> <file> <fixed-string>
@@ -108,6 +112,40 @@ tf "hotfix no verifier" "$HSKL" "No verifier is dispatched at hotfix wei
tf "hotfix skill has Agent" "$HSK" " - Agent"
tf "hotfix dispatches hotfixer" "$HSKL" 'subagent_type="hotfixer"'
echo "── DEGRADED on the TOOL line, feat/bugfix skip (BUGS-FOUND:134) ──"
for f in "$FSK" "$BSK"; do
n=$(basename "$(dirname "$f")")
tf "$n skip not DEGRADED" "$f" "security PASS (not DEGRADED),"
tf "$n skip first attempt" "$f" "each on its first attempt;"
tf "$n skip out of view" "$f" "a verdict no longer in view runs the call."
tf "$n skip names TOOL" "$f" "auditor's \`TOOL:\` line, beside a PASS."
done
tf "effort-shift names TOOL" "$EFF" "auditor's \`TOOL:\` line. A skipped call"
for f in "$INC" "$AUD" "$HSKL"; do
n=$(basename "$(dirname "$f")")/$(basename "$f")
tf "$n PASS reads TOOL" "$f" "\`PASS\` → read the \`TOOL:\` line first"
tf "$n DEGRADED off VERDICT" "$f" "never on the VERDICT line;"
tf "$n no TOOL structural" "$f" "a PASS with no \`TOOL:\` line"
tf "$n structural (below)" "$f" "structural failure (below)"
tn "$n DEGRADED no verdict" "$f" "\`DEGRADED\`"
tn "$n DEGRADED no branch" "$f" "DEGRADED (semgrep absent) →"
done
echo "── end-of-run merge reuse at the site (TODO:14, LRN-297) ──"
tf "effort-shift merge reuse" "$EFF" "reuses the last run's answer, or its skip, and names any code commit"
for f in "$ASK" "$GSK" "$SFK" "$ISK"; do
n=$(basename "$(dirname "$f")")
tf "$n merge reuses answer" "$f" "the gates. A later merge proposal reuses this"
tf "$n names later commits" "$f" "names any code commit made after it (doc and memory"
tf "$n doc/memory excepted" "$f" "commits excepted)."
done
for f in "$FSK" "$BSK"; do
n=$(basename "$(dirname "$f")")
tf "$n merge reuses answer" "$f" "the gates. A later merge proposal reuses the last run's answer,"
tf "$n reuse covers skip" "$f" "or its skip, and names any code commit made after it (doc and memory"
tf "$n doc/memory excepted" "$f" "commits excepted)."
done
echo ""
echo "loops-light structure locks: $PASS pass, $FAIL fail"
[ "$FAIL" -eq 0 ]
+8 -6
View File
@@ -85,14 +85,16 @@ lacks "skills/tour/SKILL.md" 'description="tour runner", model='
has "skills/onboard/SKILL.md" 'model="opus"'
has "skills/tour/SKILL.md" 'model="opus"'
has "lib/challenge-plan.md" 'BDR-076'
# 12) BDR-077 W1 — no-inherit: skill-runner children pinned fable at every
# call site; code-review dispatches carry opus; doctrine in model-gate.
# (fable dispatch alias spike-verified 2026-07-19: resolves
# claude-fable-5, enum-validated, loud failure — never silent fallback)
has "agents/client-handover-writer.md" 'model: "fable"'
# 12) BDR-077 W1 — no-inherit: skill-runner children pinned opus since
# BDR-150 (Fable is the advisor, never a dispatch target); code-review
# dispatches carry opus; doctrine in model-gate.
has "agents/client-handover-writer.md" 'model: "opus"'
has "skills/ship-feature/SKILL.md" 'model: "opus"'
has "skills/init-project/SKILL.md" 'model: "opus"'
has "lib/model-gate.md" 'model: "fable"'
has "lib/model-gate.md" 'model: "opus"'
has "lib/model-gate.md" 'fixed at spawn'
hits="$(git -C "$R" grep -nE 'model ?[:=] ?"fable"' -- agents skills lib ':!lib/tests')"
[ -z "$hits" ] && ok || ko "fable dispatch pin left: $hits"
lacks "lib/model-gate.md" 'model: "sonnet" in the Agent call'
# 13) BDR-077 W2 — plugin split: probe (sonnet, facts only) + advisor
# reasoner (opus, PROBE REPORT is ground truth, fail-closed); gate
+27 -4
View File
@@ -36,6 +36,10 @@ single `GATES — VERDICT:` line:
nothing else; re-run GATE 0. **No verifier is dispatched** — a red build or
a red suite is not a judgement call, and paying an LLM to discover it is
waste. **Max 3 floor iterations** → `mcp__model-router__route(phase="escalate")` (route: cap reached, diagnose at max before escalating; send it with the first tool call that gathers the escalation evidence), then STOP + human escalation with the rows.
A second UNMET with no main-loop advisor call since GATE 0 first ran →
the main loop calls it before the re-dispatch
(`lib/effort-shift.md` § Advisor); the answer stays here, never
in the dev brief.
- `ABANDONED(n)` → floor green but a handoff stands. Continue to GATE 1; the
verifier surfaces it and its `ABANDONED(n)` verdict routes to the human
gate.
@@ -76,6 +80,10 @@ Parse its single `VERIFY — VERDICT:` line:
re-dispatch a FRESH verifier. Repeat.
**Max 3 conformity iterations** → `mcp__model-router__route(phase="escalate")` (route: cap reached, diagnose at max before escalating; send it with the first tool call that gathers the escalation evidence), then STOP + human escalation with the
CRITERIA table (the contract-vs-realized diff).
A second ECARTS with no main-loop advisor call since GATE 0 first ran →
the main loop calls it before the re-dispatch
(`lib/effort-shift.md` § Advisor); the answer stays here, never
in the dev brief.
- `ABANDONED(n)` → direct human gate, never a dev loop (a dev cannot close
what was proven impossible). The human lifts the abandonment or accepts
the partial delivery; either way the run is never reported as fully
@@ -89,6 +97,9 @@ Parse its single `VERIFY — VERDICT:` line:
unparsable, crash, `CONFORME` without `PROOF` or without `FLOOR`) → retry
ONCE with a fresh verifier; a 2nd structural failure → human escalation.
A mute verifier is NEVER a PASS.
A 2nd structural failure with no main-loop advisor call since GATE 0
first ran → the main loop calls it before escalating
(`lib/effort-shift.md` § Advisor).
## GATE 2 — SECURITY (fresh security-auditor)
@@ -99,7 +110,11 @@ stdout-only, no Write).
Parse its single `SECURITY — VERDICT:` line:
- `PASS` → done, proceed to commit.
- `PASS` → read the `TOOL:` line first: DEGRADED (semgrep absent) shows
there, never on the VERDICT line; a PASS with no `TOOL:` line is a
structural failure (below). Then done, proceed to commit; a DEGRADED
PASS also surfaces the checklist result + recommends `make plugin`
(the tool's absence never blocks).
- `BLOCK(n)` → hand the dev the `BLOCKING` list + the CONTRACT path
(re-dispatch a FRESH executor, never fix by hand). Then re-run GATE 0, then
**re-verify the REQUEST first** (GATE 1, fresh verifier) — a security fix
@@ -108,11 +123,19 @@ Parse its single `SECURITY — VERDICT:` line:
BLOCKING table. Every STOP text names the level reached (`$CLAUDE_EFFORT`)
and suggests relaunching with `ultrathink` in the prompt (turn floor) or
`/route effort=max` (sticky, `/route clear` after).
- `DEGRADED` (semgrep absent) → does NOT block on the tool's absence; surface
the checklist result + recommend `make plugin`. A DEGRADED run that still
BLOCKs (grep-caught secret/injection) blocks like any other.
A second BLOCK with no main-loop advisor call since GATE 0 first ran →
the main loop calls it before the re-dispatch
(`lib/effort-shift.md` § Advisor); the answer stays here, never
in the dev brief.
- Structural failure → retry ONCE fresh; 2nd → human escalation. A mute
auditor is NEVER a PASS.
A 2nd structural failure with no main-loop advisor call since GATE 0
first ran → the main loop calls it before escalating
(`lib/effort-shift.md` § Advisor).
Every cap or escalation STOP above: when the main loop consulted the advisor
since GATE 0 first ran, the STOP carries its answer and says whether it
predates the last iteration.
## Order invariant
+249 -81
View File
@@ -75,6 +75,7 @@ type Fixture = {
answers?: string[]
repo?: World['repo']
noHome?: boolean // HOME unset: env.get answers undefined
legacyTiers?: boolean // machine override puts fable back in best and big
surfaces?: readonly string[] // default ['terminal']
clockFailsAfterAsk?: boolean // see World; the rig gets no MockClock
sleepFails?: boolean // see World; the rig gets no MockClock
@@ -118,6 +119,21 @@ const baseRouting = (): Rec => ({
askTier: false,
})
// The tiers shipped before 2026-11-16: fable heads best, opus heads big.
const LEGACY_TIERS = {
best: ['fable', 'opus', 'sonnet'],
big: ['opus', 'fable', 'sonnet'],
}
/** The fixture's home file, with the legacy tiers merged under it. */
function homeOf(fx: Fixture): Fixture['home'] {
if (!fx.legacyTiers) return fx.home
if (fx.noHome || fx.home === 'broken') {
throw new Error('legacyTiers needs a readable machine override')
}
return { tiers: LEGACY_TIERS, ...fx.home }
}
function newWorld(fx: Fixture = {}): World {
const file = baseRouting()
file.ask = fx.ask ?? false
@@ -128,9 +144,9 @@ function newWorld(fx: Fixture = {}): World {
else if (fx.routing !== 'absent') {
files.set('routing', JSON.stringify(file, null, 2))
}
if (fx.home !== undefined) {
files.set(HOME_FILE,
fx.home === 'broken' ? '{nope' : JSON.stringify(fx.home))
const home = homeOf(fx)
if (home !== undefined) {
files.set(HOME_FILE, home === 'broken' ? '{nope' : JSON.stringify(home))
}
return {
files,
@@ -489,7 +505,7 @@ test('the main step carries the routed effort, model untouched', async (
await boot($, on)
await $.tool.call({ tool: 'mcp__model-router__route', phase: 'plan' })
await runStep($, stepInput())
expect(seen).toEqual([{ model: 'claude-fable-5-2', effort: 'xhigh' }])
expect(seen).toEqual([{ model: 'claude-opus-5-5', effort: 'xhigh' }])
})
test('a tabled agent steps at its table effort', async ($, on) => {
@@ -809,12 +825,12 @@ async function bootRigVar(
return { rig: await bootRig($, on, model, null, world), usage }
}
test('tier: a plan route upgrades a haiku session to fable xhigh', async (
test('tier: a plan route upgrades a haiku session to opus xhigh', async (
$, on) => {
const rig = await bootRig($, on, HAIKU)
await planRoute($)
expect(await stepOn($, rig, HAIKU)).toEqual({
model: FABLE,
model: OPUS,
effort: 'xhigh',
})
})
@@ -823,7 +839,7 @@ test('tier: show prints the resolved id of each phase and a down line', async (
$, on) => {
await bootRig($, on)
const text = await route($, 'show')
expect(text).toContain('plan=best→claude-fable-5-2/xhigh')
expect(text).toContain('plan=best→claude-opus-5-5/xhigh')
expect(text).toContain('judge=big→claude-opus-5-5/xhigh')
expect(text).toContain('down: none')
})
@@ -925,7 +941,7 @@ test('haiku 5: a plan keyword on a haiku session is xhigh', async (
test('fallback: a rate limit on fable moves plan to opus max', async (
$, on) => {
const rig = await bootRig($, on)
const rig = await bootRig($, on, FABLE, 1000, legacyWorld())
await planRoute($)
expect((await stepOn($, rig, FABLE)).model).toBe(FABLE)
await failWith($, 'rate_limit')
@@ -955,7 +971,7 @@ test('breaker: an invalid_request or a turn error never marks down', async (
test('breaker: the hold lapses with the clock, a second one doubles', async (
$, on) => {
const rig = await bootRig($, on)
const rig = await bootRig($, on, FABLE, 1000, legacyWorld())
await planRoute($)
await stepOn($, rig, FABLE)
await failWith($, 'overloaded')
@@ -970,7 +986,7 @@ test('breaker: the hold lapses with the clock, a second one doubles', async (
test('breaker: a /model command clears the mark of its target', async (
$, on) => {
const rig = await bootRig($, on)
const rig = await bootRig($, on, FABLE, 1000, legacyWorld())
await planRoute($)
await stepOn($, rig, FABLE)
await failWith($, 'rate_limit')
@@ -1014,7 +1030,7 @@ test('unknown: the haiku alias id is in the table, a route moves it', async (
const logs = recordLogs(on)
const rig = await bootRig($, on, HAIKU)
await planRoute($)
expect((await stepOn($, rig, HAIKU)).model).toBe(FABLE)
expect((await stepOn($, rig, HAIKU)).model).toBe(OPUS)
expect(logsWith(logs, 'unknown to the models table')).toBe(0)
})
@@ -1090,7 +1106,7 @@ test('per axis: a model-less sticky never hides a turn route tier', async (
const rig = await bootRig($, on, HAIKU)
await route($, 'effort=low')
await planRoute($)
expect(await stepOn($, rig, HAIKU)).toEqual({ model: FABLE, effort: 'low' })
expect(await stepOn($, rig, HAIKU)).toEqual({ model: OPUS, effort: 'low' })
})
// ---- texts follow the decision, from the turn's model ------------------
@@ -1117,12 +1133,12 @@ test('text: show names the session model after the turn ended', async (
$, on) => {
const rig = await bootRig($, on, HAIKU)
await planRoute($)
expect((await stepOn($, rig, HAIKU)).model).toBe(FABLE)
expect((await stepOn($, rig, HAIKU)).model).toBe(OPUS)
await endTurn($)
await route($, 'mechanical')
const line = mainLine(await route($, 'show'))
expect(line).toContain(`model ${HAIKU}`)
expect(line).not.toContain(FABLE)
expect(line).not.toContain(OPUS)
})
test('text: show reflects a /model command to opus', async ($, on) => {
@@ -1180,6 +1196,10 @@ async function bootRun(
return bootRig($, on, model, tokens, world)
}
/** A world on the pre-2026-11-16 tiers: fable heads best (LEGACY tests). */
const legacyWorld = (fx: Fixture = {}): World =>
newWorld({ legacyTiers: true, ...fx })
const spawnOf = (agent: string, extra: object = {}) =>
({ ...spawnInput(), subagentType: agent, ...extra })
@@ -1308,7 +1328,7 @@ test('run slot: a model-loaded helper skill moves effort only', async (
await loadSkill($, 'feat')
await loadSkill($, 'using-git-worktrees')
expect(mainLine(await route($, 'show'))).toContain('skill mechanical')
expect(await stepOn($, rig, FABLE)).toEqual({ model: FABLE, effort: 'low' })
expect(await stepOn($, rig, FABLE)).toEqual({ model: OPUS, effort: 'low' })
await endTurn($)
expect(mainLine(await route($, 'show'))).toContain('run reflect')
})
@@ -1369,7 +1389,7 @@ test('route answer names the id even with a floor in force', async (
await ultrathink($)
const out = await $.tool.call({ tool: ROUTE_TOOL, phase: 'plan' })
const text = JSON.stringify(out)
expect(text).toContain(`model ${FABLE}`)
expect(text).toContain(`model ${OPUS}`)
expect(text).toContain('user floor max')
})
@@ -1403,12 +1423,12 @@ test('agent skill: a rowed one writes the loop effort', async ($, on) => {
expect(await effortAfterSkill($, on, 'status')).toBe('low')
})
test('agent row: judge moves up to fable when opus is down', async (
test('agent row: judge keeps its frontmatter when opus is down', async (
$, on) => {
const rig = await bootRun($, on)
await switchTo($, OPUS, SONNET, 'auto')
await $.agent.spawn(spawnOf('plan-challenger'))
expect(rig.specs).toEqual([FABLE])
expect(rig.specs).toEqual([undefined])
})
test('agent row: opus and fable down, no write and one log line', async (
@@ -1426,14 +1446,15 @@ test('agent row: opus and fable down, no write and one log line', async (
])
})
const auditWorld = () => newWorld({
const auditWorld = (fx: Fixture = {}) => newWorld({
...fx,
edit: f => { (f.agents as Rec)['security-auditor'] = 'audit' },
})
test('audit row: fable down, no write, frontmatter runs', async (
$, on) => {
const logs = recordLogs(on)
const rig = await bootRun($, on, FABLE, auditWorld())
const rig = await bootRun($, on, FABLE, auditWorld({ legacyTiers: true }))
await switchTo($, FABLE, SONNET, 'auto')
await $.agent.spawn(spawnOf('security-auditor'))
expect(rig.specs).toEqual([undefined])
@@ -1445,7 +1466,7 @@ test('audit row: fable down, no write, frontmatter runs', async (
test('audit row: first spawn dies on fable, the retry lands on the floor',
async ($, on) => {
const rig = await bootRun($, on, FABLE, auditWorld())
const rig = await bootRun($, on, FABLE, auditWorld({ legacyTiers: true }))
await $.agent.spawn(spawnOf('security-auditor'))
await failWith($, 'rate_limit', 'a1')
await $.agent.spawn(spawnOf('security-auditor'))
@@ -1738,7 +1759,7 @@ test('layers: an invalid routing.json phase falls back by name', async (
})
await bootRun($, on, FABLE, w)
const text = await route($, 'show')
expect(text).toContain('reflect=best→claude-fable-5-2/high')
expect(text).toContain('reflect=best→claude-opus-5-5/high')
expect(logs.join('\n')).toContain('config phases.reflect ignored')
})
@@ -1757,7 +1778,7 @@ test('layers: a routing.json phase gone missing falls back, logged', async (
const logs = recordLogs(on)
const w = newWorld({ edit: f => { delete (f.phases as Rec).reflect } })
await bootRun($, on, FABLE, w)
expect(await route($, 'show')).toContain('reflect=best→claude-fable-5-2/high')
expect(await route($, 'show')).toContain('reflect=best→claude-opus-5-5/high')
expect(logs.filter(l => l.includes('lacks phases'))).toEqual([
'model-router: routing.json lacks phases reflect; code defaults kept',
])
@@ -1852,7 +1873,7 @@ test('layers: routing.json unreadable at start means defaults, no rows', async (
const w = newWorld({ routing: 'broken', ask: true })
const rig = await bootRun($, on, FABLE, w)
expect(await featerModel($, rig)).toBeUndefined()
expect(await route($, 'show')).toContain('plan=best→claude-fable-5-2/xhigh')
expect(await route($, 'show')).toContain('plan=best→claude-opus-5-5/xhigh')
const said = logs.filter(l => l.includes('routing.json unreadable'))
expect(said).toHaveLength(1)
})
@@ -2026,7 +2047,7 @@ test('T1: a typed skill asks once, with the real id and effort', async (
expect(w.asked).toHaveLength(1)
const first = w.asked[0] as Asked
expect(first.text).toContain('/feat')
expect(first.text).toContain('claude-fable-5-2 at high')
expect(first.text).toContain('claude-opus-5-5 at high')
expect(first.options).toEqual(['Later', 'Keep', 'Change'])
expect(first.header).toBe('model-router')
})
@@ -2036,7 +2057,7 @@ test('T1: the question follows the model main will really run on', async (
const w = asks(['Later'])
await bootRun($, on, SONNET, w)
await typeFeat($)
expect(w.asked[0]?.text).toContain('claude-fable-5-2 at high')
expect(w.asked[0]?.text).toContain('claude-opus-5-5 at high')
})
test('T1: Keep writes the row and its phase, then the skill never asks', async (
@@ -2561,7 +2582,7 @@ test('T2: Keep writes the agent row and the spawn goes on', async ($, on) => {
test('T2: a change routes this very spawn with the new row', async (
$, on) => {
const w = asks([...TO_JUDGE, 'Everywhere'])
const w = asks([...TO_JUDGE, 'Everywhere'], { legacyTiers: true })
const rig = await bootRun($, on, FABLE, w)
await $.agent.spawn(spawnOf('feater'))
expect(rig.specs).toEqual([OPUS])
@@ -2657,7 +2678,7 @@ test('T3: a phase declared through the route tool asks Keep or Later', async (
await $.tool.call({ tool: ROUTE_TOOL, phase: 'orchestrate' })
const q = w.asked[0] as Asked
expect(q.text).toContain('First use of orchestrate on the main loop')
expect(q.text).toContain('claude-fable-5-2 at medium')
expect(q.text).toContain('claude-opus-5-5 at medium')
expect(q.options).toEqual(['Later', 'Keep'])
})
@@ -2811,7 +2832,7 @@ test('layers: enabled:false in the override survives /clear', async (
const skillPath = (name: string) => `${HOME}/.claude/skills/${name}/SKILL.md`
const skillMd = (front: string, body = '# body') =>
`---\nname: feat\n${front}\nallowed-tools: Read\n---\n${body}\n`
const ROUTED = 'Routed to reflect: claude-fable-5-2 at high. OK?'
const ROUTED = 'Routed to reflect: claude-opus-5-5 at high. OK?'
/** A typed /feat with `md` served as its SKILL.md; the world after. */
async function featWith(
@@ -2947,7 +2968,7 @@ test('text: the phase about shows in the skill question', async ($, on) => {
const w = await featWith($, on, undefined,
{ edit: setPhase('reflect', { about: 'deep thinking' }) })
expect(w.asked[0]?.text).toBe('First route for /feat. Routed to reflect ' +
'(deep thinking): claude-fable-5-2 at high. OK?')
'(deep thinking): claude-opus-5-5 at high. OK?')
})
test('text: the about is cleaned before it enters a question', async (
@@ -3014,7 +3035,7 @@ test('text: a phase question names its about and its consumers', async (
await $.tool.call({ tool: ROUTE_TOOL, phase: 'orchestrate' })
expect(w.asked[0]?.text).toBe('First use of orchestrate on the main loop — ' +
'dispatch work; used by 0 rows, the derived route of dispatches: ' +
'claude-fable-5-2 at medium. OK?')
'claude-opus-5-5 at medium. OK?')
})
test('text: a phase question counts rows and prompt rules', async ($, on) => {
@@ -3022,7 +3043,7 @@ test('text: a phase question counts rows and prompt rules', async ($, on) => {
await bootRun($, on, FABLE, w)
await $.tool.call({ tool: ROUTE_TOOL, phase: 'reflect' })
expect(w.asked[0]?.text).toBe('First use of reflect on the main loop — ' +
'used by 1 row, 1 prompt rule: claude-fable-5-2 at high. OK?')
'used by 1 row, 1 prompt rule: claude-opus-5-5 at high. OK?')
})
test('text: a phase question names its floor rule', async ($, on) => {
@@ -3030,7 +3051,7 @@ test('text: a phase question names its floor rule', async ($, on) => {
await bootRun($, on, FABLE, w)
await $.tool.call({ tool: ROUTE_TOOL, phase: 'escalate' })
expect(w.asked[0]?.text).toBe('First use of escalate on the main loop — ' +
'used by 0 rows, 1 floor rule: claude-fable-5-2 at max. OK?')
'used by 0 rows, 1 floor rule: claude-opus-5-5 at max. OK?')
})
test('T3: a Change answer changes nothing and is said', async ($, on) => {
@@ -3043,19 +3064,19 @@ test('T3: a Change answer changes nothing and is said', async ($, on) => {
expect(toasts).toContain('answer not recognised, default kept')
})
test('change: the model question offers the four tiered aliases', async (
test('change: the model question offers the three tiered aliases', async (
$, on) => {
const w = asks(['Change', 'Later'])
await bootRun($, on, FABLE, w)
await typeFeat($)
expect(w.asked[1]?.text).toBe('Which model for feat?')
expect(w.asked[1]?.options).toEqual([
'fable (best)', 'opus (big)', 'sonnet (work)', 'haiku (cheap)',
'opus (best)', 'sonnet (work)', 'haiku (cheap)',
])
})
for (const [label, alias, efforts] of [
['fable (best)', 'fable', ['medium', 'high', 'xhigh', 'max']],
['opus (best)', 'opus', ['medium', 'high', 'xhigh', 'max']],
['sonnet (work)', 'sonnet', ['low', 'medium', 'high', 'xhigh']],
] as const) {
test(`change: ${alias} offers the efforts of its phases, ascending`, async (
@@ -3074,7 +3095,8 @@ for (const [label, phase] of [
] as const) {
test(`change: ${label} has one effort, the question is skipped`, async (
$, on) => {
const w = asks(['Change', label, 'Later'])
const w = asks(['Change', label, 'Later'],
{ legacyTiers: label === 'opus (big)' })
await bootRun($, on, FABLE, w)
await typeFeat($)
expect(w.asked).toHaveLength(3)
@@ -3161,16 +3183,16 @@ test('change: with the switch on the toast carries no hint', async (
test('change: an upgrade toast carries no hint', async ($, on) => {
const toasts = recordToasts(on)
const w = asks(['Change', 'fable (best)', 'xhigh', 'Everywhere'])
const w = asks(['Change', 'opus (best)', 'xhigh', 'Everywhere'])
await bootRun($, on, SONNET, w)
await typeFeat($)
expect(toasts).toContain('/feat now runs claude-fable-5-2 at xhigh')
expect(toasts).toContain('/feat now runs claude-opus-5-5 at xhigh')
})
test('change: an upgrade the config holds back carries no hint', async (
$, on) => {
const toasts = recordToasts(on)
const w = asks(['Change', 'fable (best)', 'xhigh', 'Everywhere'],
const w = asks(['Change', 'opus (best)', 'xhigh', 'Everywhere'],
{ home: { mainUpgrade: false } })
await bootRun($, on, SONNET, w)
await typeFeat($)
@@ -3190,6 +3212,7 @@ test('change: a project scope stores the derived phase, keeps the row', async (
test('change: a security auditor moves to opus at xhigh, at once', async (
$, on) => {
const w = asks([...TO_JUDGE, 'Everywhere'], {
legacyTiers: true,
edit: f => { (f.agents as Rec)['security-auditor'] = 'verify' },
})
const rig = await bootRun($, on, FABLE, w)
@@ -3876,7 +3899,7 @@ test('logs: a route-tool plan logs one line, not one per step', async (
await runStep($, highStep())
await runStep($, highStep())
expect(logs).toEqual([
mainWord('fable/high', 'fable/xhigh', 'plan: route tool'),
mainWord('fable/high', 'opus/xhigh', 'plan: route tool, switch'),
])
})
@@ -3885,7 +3908,8 @@ test('logs: a typed skill names itself as the cause', async ($, on) => {
await typeFeat($)
await runStep($, stepInput())
expect(logs).toEqual([
mainWord('fable/low', 'fable/high', 'reflect: skill /feat'),
mainWord('fable/low', 'opus/high',
'reflect: skill /feat, switch'),
])
})
@@ -3894,7 +3918,7 @@ test('logs: an upgrade rides on the same line', async ($, on) => {
await typeFeat($)
await runStep($, { ...highStep(), model: SONNET })
expect(logs).toEqual([
mainWord('sonnet/high', 'fable/high', 'reflect: skill /feat, upgrade'),
mainWord('sonnet/high', 'opus/high', 'reflect: skill /feat, upgrade'),
])
})
@@ -4007,7 +4031,7 @@ test('logs: the transition line precedes the step below it', async (
await planRoute($)
await runStep($, highStep())
expect(logs).toEqual([
mainWord('fable/high', 'fable/xhigh', 'plan: route tool'),
mainWord('fable/high', 'opus/xhigh', 'plan: route tool, switch'),
'STEP',
])
})
@@ -4053,7 +4077,9 @@ for (const [name, text, act] of LEGACY) {
const { logs } = await bootLogged($, on)
await act($)
await runStep($, highStep())
expect(logs.filter(l => l.includes(text))).toEqual([])
// the session on fable moves to opus: its transition line is the new one
expect(logs.filter(l => !l.startsWith('main:') && l.includes(text)))
.toEqual([])
})
}
@@ -4169,7 +4195,7 @@ test('logs: one agent type to two models is two hand-offs', async (
test('logs: a tier moved up in-tier names the alias that was down', async (
$, on) => {
const { logs } = await bootLogged($, on)
const { logs } = await bootLogged($, on, { world: legacyWorld() })
await switchTo($, OPUS, SONNET, 'auto')
await $.agent.spawn(spawnOf('plan-challenger'))
expect(handoffs(logs)).toEqual([
@@ -4522,26 +4548,26 @@ test('residual e: a changed.phases entry is never restored', async ($, on) => {
expect(w.written).toEqual([])
})
/** The efforts the Change chain offers for fable, from the second question. */
async function fableEfforts($: Engine, on: On, fx: Fixture) {
const w = asks(['Change', 'fable (best)', 'Later'], fx)
/** The efforts the Change chain offers for opus, from the second question. */
async function opusEfforts($: Engine, on: On, fx: Fixture) {
const w = asks(['Change', 'opus (best)', 'Later'], fx)
await bootRun($, on, FABLE, w)
await typeFeat($)
return w.asked[2]?.options
}
const FABLE_EFFORTS = ['medium', 'high', 'xhigh', 'max']
const OPUS_EFFORTS = ['medium', 'high', 'xhigh', 'max']
test('residual f: a null phase in the file is ignored, no crash', async (
$, on) => {
const edit = (f: Rec): void => { (f.phases as Rec).plan = null }
expect(await fableEfforts($, on, { edit })).toEqual(FABLE_EFFORTS)
expect(await opusEfforts($, on, { edit })).toEqual(OPUS_EFFORTS)
})
test('residual f: a file without phases offers the code defaults', async (
$, on) => {
const edit = (f: Rec): void => { delete f.phases }
expect(await fableEfforts($, on, { edit })).toEqual(FABLE_EFFORTS)
expect(await opusEfforts($, on, { edit })).toEqual(OPUS_EFFORTS)
})
const CUSTOM_CHEAP = { phases: { custom: { tier: 'cheap', effort: 'high' } } }
@@ -4618,7 +4644,7 @@ test('logs: a hostile skill name is cleaned in the main line', async (
await loadSkill($, HOSTILE_SKILL)
await runStep($, { ...highStep(), effort: 'low' as const })
const line = logs.find(l => l.includes('skill /')) ?? ''
const name = nameAfter(line, 'skill /', ')')
const name = nameAfter(line, 'skill /', ')').replace(', switch', '')
expect(name).not.toBe('')
expect(hasCtrl(line)).toBe(false)
expect([...name].length).toBeLessThanOrEqual(40)
@@ -5249,7 +5275,7 @@ test('classify visibility: verbose says (reflect: classifier)', async (
await typed($, PLAIN)
await runStep($, { ...highStep(), effort: 'low' as const })
expect(c.logs).toContain(
mainWord('fable/low', 'fable/high', 'reflect: classifier'))
mainWord('fable/low', 'opus/high', 'reflect: classifier, switch'))
})
test('classify: a repeated undefined label never pauses', async ($, on) => {
@@ -5550,8 +5576,8 @@ test('spawn: an upgraded main never pins general-purpose', async ($, on) => {
const { rig } = await bootRigVar($, on, HAIKU, 1000)
await offerOf($, GP, 'built-in')
await planRoute($)
expect((await stepOn($, rig, HAIKU)).model).toBe(FABLE)
await $.agent.spawn(spawnOf(GP, { parentModel: FABLE }))
expect((await stepOn($, rig, HAIKU)).model).toBe(OPUS)
await $.agent.spawn(spawnOf(GP, { parentModel: OPUS }))
expect(rig.specs).toEqual([undefined])
})
@@ -5731,7 +5757,7 @@ const downLine = (text: string): string =>
test('probe: a fable that never answers lands the plan step on opus', async (
$, on) => {
const world = probeWorld(hangsOn(FABLE))
const world = probeWorld(hangsOn(FABLE), { legacyTiers: true })
const rig = await bootRig($, on, OPUS, 1000, world)
// a keyword no longer lifts: the route tool carries the plan tier
await pastProbe(rig, planRoute($))
@@ -5756,7 +5782,7 @@ test('probe: the route tool answers an opus id, never fable', async (
})
test('probe: an answered probe is cached across turns', async ($, on) => {
const world = newWorld()
const world = legacyWorld()
const rig = await bootRig($, on, OPUS, 1000, world)
await planRoute($)
expect((await stepOn($, rig, OPUS)).model).toBe(FABLE)
@@ -5767,7 +5793,7 @@ test('probe: an answered probe is cached across turns', async ($, on) => {
})
test('probe: a lapsed hold probes again and holds longer', async ($, on) => {
const world = probeWorld(hangsOn(FABLE))
const world = probeWorld(hangsOn(FABLE), { legacyTiers: true })
const rig = await bootRig($, on, OPUS, 1000, world)
for (const wait of [15, 30]) {
// the route tool lifts, a keyword no longer does
@@ -5784,7 +5810,7 @@ test('probe: a lapsed hold probes again and holds longer', async ($, on) => {
test('probe: a rejection marks the target down like a timeout', async (
$, on) => {
const world = probeWorld(rejectsOn(FABLE))
const world = probeWorld(rejectsOn(FABLE), { legacyTiers: true })
const rig = await bootRig($, on, OPUS, 1000, world)
await planRoute($)
expect((await stepOn($, rig, OPUS)).model).toBe(OPUS)
@@ -5796,7 +5822,7 @@ for (const [shape, answer] of [
['a string', 'ok'], ['an object', PROBE_OK], ['nothing', undefined],
] as const) {
test(`probe: ${shape} as the answer lets the move go`, async ($, on) => {
const world = probeWorld(() => answer)
const world = probeWorld(() => answer, { legacyTiers: true })
const rig = await bootRig($, on, OPUS, 1000, world)
await planRoute($)
expect((await stepOn($, rig, OPUS)).model).toBe(FABLE)
@@ -5808,7 +5834,8 @@ test('probe: a failure during the flight keeps the target unverified', async (
$, on) => {
let open: () => void = () => undefined
const gate = new Promise<void>(resolve => { open = resolve })
const world = probeWorld(async () => { await gate; return PROBE_OK })
const world = probeWorld(async () => { await gate; return PROBE_OK },
{ legacyTiers: true })
const rig = await bootRig($, on, OPUS, 1000, world)
// the route tool's probe is the one in flight (a keyword no longer lifts)
const call = planRoute($)
@@ -5876,7 +5903,7 @@ test('probe: a session model that never answers leaves for opus on the first ste
test('probe: a healthy session model is probed once and kept', async (
$, on) => {
const world = newWorld()
const world = legacyWorld()
const rig = await bootRig($, on, FABLE, 1000, world)
await planRoute($)
expect((await stepOn($, rig, FABLE)).model).toBe(FABLE)
@@ -5904,7 +5931,8 @@ test('probe: a lapsed hold on the session model probes it again', async (
test('probe: false in the override makes no completion at all', async (
$, on) => {
const world = probeWorld(hangsOn(FABLE), { home: { probe: false } })
const world = probeWorld(hangsOn(FABLE),
{ legacyTiers: true, home: { probe: false } })
const rig = await bootRig($, on, OPUS, 1000, world)
await planRoute($)
expect((await stepOn($, rig, OPUS)).model).toBe(FABLE)
@@ -5915,7 +5943,7 @@ test('probe: false in the override makes no completion at all', async (
test('probe: a non-boolean setting is ignored, logged, probe stays on', async (
$, on) => {
const logs = recordLogs(on)
const world = newWorld({ home: { probe: 'no' } })
const world = legacyWorld({ home: { probe: 'no' } })
const rig = await bootRig($, on, OPUS, 1000, world)
await planRoute($)
await stepOn($, rig, OPUS)
@@ -5926,7 +5954,7 @@ test('probe: a non-boolean setting is ignored, logged, probe stays on', async (
test('probe: /clear keeps the verified models', async ($, on) => {
on('session.end', ($, e) => ({ sessionId: e.sessionId }))
const world = newWorld()
const world = legacyWorld()
const rig = await bootRig($, on, OPUS, 1000, world)
await planRoute($)
await stepOn($, rig, OPUS)
@@ -5946,7 +5974,7 @@ async function fableHeld($: Engine, rig: Rig): Promise<void> {
test('stand-in: reflect on opus runs xhigh, and the answer says so', async (
$, on) => {
const rig = await bootRig($, on)
const rig = await bootRig($, on, FABLE, 1000, legacyWorld())
await fableHeld($, rig)
const out = await $.tool.call({ tool: ROUTE_TOOL, phase: 'reflect' })
expect(JSON.stringify(out)).toContain(
@@ -5956,7 +5984,7 @@ test('stand-in: reflect on opus runs xhigh, and the answer says so', async (
test('stand-in: orchestrate goes medium to high, escalate stays max', async (
$, on) => {
const rig = await bootRig($, on)
const rig = await bootRig($, on, FABLE, 1000, legacyWorld())
await fableHeld($, rig)
await $.tool.call({ tool: ROUTE_TOOL, phase: 'orchestrate' })
expect((await stepOn($, rig, FABLE)).effort).toBe('high')
@@ -5972,7 +6000,7 @@ test('stand-in: an explicit effort is never bumped', async ($, on) => {
})
test('stand-in: fable available, no bump', async ($, on) => {
const rig = await bootRig($, on, OPUS)
const rig = await bootRig($, on, OPUS, 1000, legacyWorld())
await $.tool.call({ tool: ROUTE_TOOL, phase: 'reflect' })
expect(await stepOn($, rig, OPUS)).toEqual({ model: FABLE, effort: 'high' })
})
@@ -6014,7 +6042,7 @@ test('stand-in: an ultrathink floor ends at max, not past it', async (
test('stand-in: the verbose line names it as a cause', async ($, on) => {
const logs = recordLogs(on)
const rig = await bootRig($, on)
const rig = await bootRig($, on, FABLE, 1000, legacyWorld())
await route($, 'verbose on')
await fableHeld($, rig)
await $.tool.call({ tool: ROUTE_TOOL, phase: 'reflect' })
@@ -6048,7 +6076,7 @@ test('keyword cap: ultrathink on an opus session stays on opus at max', async (
test('keyword cap: a route tool call after a keyword still lifts to fable', async (
$, on) => {
const rig = await bootRig($, on, OPUS)
const rig = await bootRig($, on, OPUS, 1000, legacyWorld())
await typed($, 'plan the billing migration')
await planRoute($)
expect((await stepOn($, rig, OPUS)).model).toBe(FABLE)
@@ -6066,7 +6094,7 @@ test('keyword cap: a held fable gives no stand-in notch to a capped keyword', as
test('keyword cap: a keyword inside a held best-tier run keeps the run on fable', async (
$, on) => {
const rig = await bootRun($, on, OPUS)
const rig = await bootRun($, on, OPUS, legacyWorld())
await loadSkill($, 'feat')
await endTurn($)
await typed($, 'plan the next step')
@@ -6437,7 +6465,7 @@ for (const scope of ['This conversation', 'This project']) {
// ---- bare /model: the router's own dialog ---------------------------------
const STEP1 = ['fable (best)', 'opus (big)', 'sonnet (work)',
const STEP1 = ['fable (custom)', 'opus (best)', 'sonnet (work)',
'Other model (native picker)']
const VARIANTS = ['Standard', '[1m]']
const NO_MODEL = 'model: no model chosen, nothing changed'
@@ -6458,7 +6486,7 @@ test('bare model: step 1 lists the table and the native picker', async (
test('bare model: opus, [1m], This project writes the full id', async (
$, on) => {
const m = await bootModel($, on,
['opus (big)', '[1m]', 'This project'])
['opus (best)', '[1m]', 'This project'])
await modelCmd($, '')
expect(m.w.asked.map(q => q.options)).toEqual([STEP1, VARIANTS, SCOPES])
const variant = m.w.asked[1] as Asked
@@ -6469,7 +6497,7 @@ test('bare model: opus, [1m], This project writes the full id', async (
test('bare model: the current model asks its scope too', async ($, on) => {
const m = await bootModel($, on,
['opus (big)', 'Standard', 'This conversation'])
['opus (best)', 'Standard', 'This conversation'])
expect(await modelCmd($, '')).toContain(`sticky route ${OPUS}`)
expect(m.w.asked).toHaveLength(3)
expect(m.ran).toEqual([])
@@ -6525,7 +6553,7 @@ test('bare model: Everywhere runs native with the token', async ($, on) => {
test('bare model: [1m] with This conversation carries the note', async (
$, on) => {
await bootModel($, on, ['fable (best)', '[1m]', 'This conversation'])
await bootModel($, on, ['fable (custom)', '[1m]', 'This conversation'])
expect(await modelCmd($, '')).toContain("[1m] follows the session's variant")
})
@@ -6951,9 +6979,12 @@ const INSTEAD = 'Opus instead (big tier)'
const STOP = 'Stop asking this session'
const TIER_OPTIONS = ['Fable', INSTEAD, STOP]
/** A world with the tier ask on; the first-use `ask` stays off. */
/**
* A world with the tier ask on; the first-use `ask` stays off. The ask only
* runs when fable heads best: an override puts it back (LEGACY tiers).
*/
const asksTier = (answers: string[], fx: Fixture = {}) =>
newWorld({ answers, askTier: 'best', ...fx })
newWorld({ answers, askTier: 'best', legacyTiers: true, ...fx })
/** An extra skill row, for the tests that need a second typed skill. */
const withRows = (rows: Table) => (file: Rec): void => {
@@ -7178,6 +7209,18 @@ test('TIER: a rowed spawn asks once per type; Opus instead sticks', async (
expect(rig.specs).toEqual([OPUS, OPUS])
})
test('TIER: ask-tier off keeps an Opus instead answer on opus', async (
$, on) => {
const w = asksTier([INSTEAD, INSTEAD], { edit: auditVerifier })
const rig = await bootRun($, on, OPUS, w)
await typeFeat($)
await $.agent.spawn(spawnOf('verifier'))
expect(await route($, 'ask-tier off')).toBe('ask-tier off')
expect(await lastStep($, rig)).toEqual({ model: OPUS, effort: 'high' })
await $.agent.spawn(spawnOf('verifier'))
expect(rig.specs).toEqual([OPUS, OPUS])
})
test('TIER: Fable on a spawn runs the head', async ($, on) => {
const rig = await bootRun($, on, OPUS, asksTier(['Fable'], {
edit: auditVerifier,
@@ -7199,7 +7242,7 @@ test('TIER: an explicit model, a nested spawn and a work row never ask', async (
test('TIER: the first-use dialog runs first, then the tier ask', async (
$, on) => {
const w = asks(['Keep', INSTEAD], { askTier: 'best' })
const w = asks(['Keep', INSTEAD], { legacyTiers: true, askTier: 'best' })
const rig = await bootRun($, on, OPUS, w)
await typeFeat($)
expect(w.asked).toHaveLength(2)
@@ -7210,7 +7253,8 @@ test('TIER: the first-use dialog runs first, then the tier ask', async (
test('TIER: a stored spawn answer holds while another dialog is open', async (
$, on) => {
const w = asks(['Keep', INSTEAD], { askTier: 'best', edit: auditVerifier })
const w = asks(['Keep', INSTEAD],
{ legacyTiers: true, askTier: 'best', edit: auditVerifier })
const rig = await bootRun($, on, OPUS, w)
await $.agent.spawn(spawnOf('verifier'))
const hold = deferred()
@@ -7228,7 +7272,7 @@ test('TIER: a stored spawn answer holds while another dialog is open', async (
})
test('TIER: a dialog in flight routes a typed skill unasked', async ($, on) => {
const w = asks(['Keep'], { askTier: 'best' })
const w = asks(['Keep'], { legacyTiers: true, askTier: 'best' })
const hold = deferred()
const open = deferred()
w.gate = hold.gate
@@ -7290,6 +7334,130 @@ test('TIER: no routing.json means no ask; the route is set', async ($, on) => {
expect(mainLine(await route($, 'show'))).toContain('model plan')
})
// ---- SHIPPED tiers: fable is ranked, never an auto-route target ----------
// No override here: best and big are [opus, sonnet]. A machine override can
// put fable back (the TIER section above runs on those LEGACY tiers).
const routeTo = (phase: string) => (file: Rec): void => {
(file.skills as Table).feat = phase
;(file.agents as Table).feater = phase
}
for (const phase of ['plan', 'judge', 'audit']) {
test(`shipped: a typed ${phase} row routes main to opus`, async (
$, on) => {
const rig = await bootRun($, on, OPUS, newWorld({ edit: routeTo(phase) }))
await typeFeat($)
expect((await lastStep($, rig)).model).toBe(OPUS)
})
test(`shipped: a ${phase} agent row spawns on opus`, async ($, on) => {
const rig = await bootRun($, on, OPUS, newWorld({ edit: routeTo(phase) }))
await $.agent.spawn(spawnOf('feater'))
expect(rig.specs).toEqual([OPUS])
})
}
test('shipped: with opus down best and big never choose fable', async (
$, on) => {
const logs = recordLogs(on)
const w = newWorld({ edit: auditVerifier })
const rig = await bootRun($, on, OPUS, w)
await switchTo($, OPUS, SONNET, 'auto')
await planRoute($)
expect((await stepOn($, rig, SONNET)).model).toBe(SONNET)
await $.agent.spawn(spawnOf('plan-challenger'))
await $.agent.spawn(spawnOf('verifier'))
// the frontmatter floor runs: no model is chosen, fable least of all
expect(rig.specs).toEqual([undefined, undefined])
expect(logs).toContain(
'model-router: plan-challenger tier big down, frontmatter model kept')
expect(logs).toContain(
'model-router: verifier tier best down, frontmatter model kept')
})
test('shipped: a hand-picked fable ranks above opus, a limit leaves it', async (
$, on) => {
const h = await bootHand($, on, ['This conversation'])
await modelCmd($, 'fable')
expect((await stepOn($, h.rig, OPUS)).model).toBe(FABLE)
await failWith($, 'rate_limit')
expect((await stepOn($, h.rig, FABLE)).model).toBe(OPUS)
})
test('shipped: boot and reload log no "does not lead" line', async (
$, on) => {
const logs = recordLogs(on)
await bootRun($, on, OPUS)
await route($, 'reload')
expect(logs.filter(l => l.includes('does not lead'))).toEqual([])
})
/** The machine override turns the tier ask on: best is still not fable's. */
const askOn = (answers: string[], edit?: (file: Rec) => void): World =>
newWorld({ answers, home: { askTier: 'best' }, ...(edit ? { edit } : {}) })
test('shipped: an audit spawn asks no tier question, the answer stays', async (
$, on) => {
const w = askOn([INSTEAD], auditVerifier)
const rig = await bootRun($, on, OPUS, w)
await $.agent.spawn(spawnOf('verifier'))
expect(w.asked).toEqual([])
expect(w.answers).toEqual([INSTEAD])
expect(rig.specs).toEqual([OPUS])
})
test('shipped: a best row typed from sonnet asks nothing, main on opus', async (
$, on) => {
const w = askOn([INSTEAD])
const rig = await bootRun($, on, SONNET, w)
await typeFeat($)
expect(w.asked).toEqual([])
expect((await lastStep($, rig, SONNET)).model).toBe(OPUS)
})
test('shipped: /route ask-tier on says inert, show says inert', async (
$, on) => {
await bootRun($, on, OPUS, newWorld())
expect(await route($, 'show')).toContain('ask-tier: off')
expect(await route($, 'ask-tier on'))
.toBe('ask-tier on (inert: best is not headed by fable)')
expect(await route($, 'show')).toContain('ask-tier: inert')
expect(await route($, 'ask-tier off')).toBe('ask-tier off')
})
test('legacy: an override heading best and big with fable asks', async (
$, on) => {
const both = ['fable', 'opus', 'sonnet']
const w = asksTier([INSTEAD], {
home: { tiers: { best: both, big: both } },
})
await bootRun($, on, OPUS, w)
await typeFeat($)
expect(w.asked).toHaveLength(1)
expect(w.asked[0]?.text).toContain('Run it on fable?')
})
test('shipped: the Change dialog offers no fable, judge stays judge', async (
$, on) => {
const w = asks(['Change', 'opus (best)', 'xhigh', 'Everywhere'])
await bootRun($, on, OPUS, w)
await $.agent.spawn(spawnOf('plan-challenger'))
expect(w.asked[1]?.text).toBe('Which model for plan-challenger?')
expect(w.asked[1]?.options).toEqual([
'opus (best)', 'sonnet (work)', 'haiku (cheap)',
])
expect((routingOf(w).agents as Rec)['plan-challenger']).toBe('judge')
})
test('shipped: the bare model dialog still offers fable, as custom', async (
$, on) => {
const m = await bootModel($, on, [])
await modelCmd($, '')
expect(m.w.asked[0]?.options).toContain('fable (custom)')
expect(m.w.asked[0]?.options).toEqual(STEP1)
})
// ---- GUARD: main-loop code writes go through a skill --------------------
const GUARD = 'model-router: code is written inside a skill run.'
+36 -15
View File
@@ -204,7 +204,11 @@ const KEEP = 'Keep'
const CHANGE = 'Change'
const EVERYWHERE = 'Everywhere'
// Tier ask: the answers; INSTEAD_TIER is the tier "Opus instead" resolves by.
// shortcut: the ask-before-Fable dialog only runs when an override heads
// `best` with fable (BLK-030 credit guard), hence the hardcoded label; remove
// the feature if Fable never returns to a tier.
const TIER_HEAD = 'Fable'
const TIER_HEAD_ALIAS = 'fable'
const TIER_INSTEAD = 'Opus instead (big tier)'
const TIER_STOP = 'Stop asking this session'
const INSTEAD_TIER = 'big'
@@ -223,7 +227,7 @@ const BARE_ALIASES: readonly string[] = ['fable', 'opus', 'sonnet']
const STANDARD = 'Standard'
const LONG = '[1m]'
const LOCAL_SETTINGS = '.claude/settings.local.json'
const CHOICE_ALIASES: readonly string[] = ['fable', 'opus', 'sonnet', 'haiku']
const CHOICE_ALIASES: readonly string[] = ['opus', 'sonnet', 'haiku']
const MAX_DESC = 140 // chars of a skill or agent description in a question
const MAX_ABOUT = 120 // chars of a phase `about`
const MAX_DESCS = 256 // agent descriptions kept (oldest dropped)
@@ -294,10 +298,12 @@ const DEFAULT_CONFIG: Config = {
fable: 'claude-fable-5-2',
},
windows: {},
// A tier is an ordered alias list: the first one not down is used.
// A tier is an ordered alias list: the first one not down is used. Fable is
// ranked (hand picks, the advisor model) but never an auto-route target
// (user 2026-11-16); a machine override may put it back in a tier.
tiers: {
best: ['fable', 'opus', 'sonnet'],
big: ['opus', 'fable', 'sonnet'],
best: ['opus', 'sonnet'],
big: ['opus', 'sonnet'],
work: ['sonnet', 'opus'],
cheap: ['haiku', 'sonnet'],
},
@@ -615,10 +621,6 @@ function mergeRouting(
const tiers = mergeTable(
base.tiers, user.tiers, 'tiers', acceptTier(models, log), log)
const fallback = pickFallback(user.fallback, base.fallback, models, log)
if (tiers.best?.[0] !== fallback[0]) {
log('model-router: tiers.best does not lead the fallback chain; rank ' +
'comes from the fallback list alone')
}
return {
tiers,
fallback,
@@ -1148,7 +1150,7 @@ function availableIn(st: State, aliases: readonly string[]) {
function nextAvailable(st: State, after: string | undefined) {
const { fallback, models } = st.cfg
const at = fallback.findIndex(alias => models[alias] === after)
return availableIn(st, fallback.slice(at + 1))
return at < 0 ? undefined : availableIn(st, fallback.slice(at + 1))
}
/**
@@ -1171,14 +1173,27 @@ function headId(st: State): string | undefined {
return alias === undefined ? undefined : st.cfg.models[alias]
}
/** The ask-before-Fable dialog is fable-specific: best must be headed by it. */
function fableHeadsBest(st: State): boolean {
const list = hasKey(st.cfg.tiers, BEST) ? st.cfg.tiers[BEST] : undefined
return list?.[0] === TIER_HEAD_ALIAS
}
/**
* The head a route is asked about before it applies; undefined = off. The
* machine override wins; an absent key reads best, so does any other value
* (asking is the safe side, `warnAskTier` says so once).
* (asking is the safe side, `warnAskTier` says so once). Inert (undefined)
* unless the head of `best` is fable.
*/
function tierHead(st: State): string | undefined {
const value = st.mem.askTierLocal ?? st.mem.askTier
return value === false ? undefined : headId(st)
return value === false || !fableHeadsBest(st) ? undefined : headId(st)
}
/** The ask is on by config but best is not headed by fable: nothing asks. */
function tierInert(st: State): boolean {
const value = st.mem.askTierLocal ?? st.mem.askTier
return value !== false && !fableHeadsBest(st)
}
/** The `big` tier's models, the head left out, in order. */
@@ -1605,7 +1620,8 @@ type Verdict = {
*/
function wantedModel(st: State, cur: string): string | undefined {
const slot = mainModelSlot(st)
const instead = slot?.tierChoice === 'big' && slot.route.tier === BEST
const instead = slot?.tierChoice === 'big' && slot.route.tier === BEST &&
fableHeadsBest(st)
const name = instead ? insteadName(st) ?? routeName(slot.route)
: routeName(slot?.route)
if (name === undefined) return undefined
@@ -1992,6 +2008,7 @@ async function snapshot($: Api, st: State) {
/** `/route show`: the tier ask's state, a Stop answer included. */
function askTierWord(st: State): string {
if (tierInert(st)) return 'inert'
if (tierHead(st) === undefined) return 'off'
return st.tierPaused ? 'best (paused this session)' : BEST
}
@@ -2799,7 +2816,7 @@ function headAlias(cfg: Config, route: Route): string | undefined {
: aliasOf(cfg, canonical(cfg, route.model))
}
/** "fable (best)": the alias and the tier it heads ("custom" if none). */
/** "opus (best)": the alias and the tier it heads ("custom" if none). */
function modelLabel(cfg: Config, alias: string): string {
const tier = Object.keys(cfg.tiers).find(t => cfg.tiers[t]?.[0] === alias)
return `${alias} (${tier ?? 'custom'})`
@@ -3244,7 +3261,9 @@ async function spawnTier(
) {
if (route === undefined || route.tier !== BEST) return route
if (!st.tierSpawn.has(e.subagentType)) await spawnTierAsk($, st, e, route)
return st.tierSpawn.get(e.subagentType) === 'big'
const instead = st.tierSpawn.get(e.subagentType) === 'big' &&
fableHeadsBest(st)
return instead
? insteadRoute(st, route)
: route
}
@@ -3309,7 +3328,9 @@ async function flagCommand(
const local = flag.local(st.mem)
const note = local === undefined ? '' : `; ~/${OVERRIDE} sets ${key} ${
local === false ? 'off' : 'on'} and wins here`
return `${word} ${arg}${note}`
const inert = flag === ASK_TIER_FLAG && arg === 'on' && tierInert(st)
return `${word} ${arg}${note}${
inert ? ' (inert: best is not headed by fable)' : ''}`
}
// ---- /route forget: the user takes decisions back -------------------------
+8
View File
@@ -162,6 +162,9 @@ file before anything else. Accepted set empty → stop.
GATE 0 runs every scanner oracle (the per-fix proof), GATE 1 a fresh
verifier, GATE 2 a fresh security-auditor. Loop caps and escalation are
the include's; loop decisions stay in this main loop.
Stuck: a gate loop fails twice with no main-loop advisor call since GATE 0
first ran → the main loop calls the advisor per `lib/verify-secure-loop.md`
(`lib/effort-shift.md` § Advisor); the answer never enters an executor brief.
## STEP 9: Re-pass (prove it all)
@@ -194,6 +197,11 @@ open and say so plainly. Never report a fix the re-pass did not prove.
```
Then `git add <files touched>` (never `-A`, never the baseline file) and
commit, project convention else 50 words at most.
Before the reply, the main loop prints the run's diff stat, then makes its
end-of-run advisor call (`lib/effort-shift.md` § Advisor); its answer
goes into the reply as an `Advisor:` line, and a fix it drives goes
back through the gates. A later merge proposal reuses this answer and
names any code commit made after it (doc and memory commits excepted).
2. `mcp__model-router__route(phase="apply")` for the tail. Reply with: fixed
and proven (proposal, rule, file), still open and why, the walk's result,
the branch name. Merge waits for the user's explicit signal.
+7 -1
View File
@@ -170,7 +170,7 @@ Then show the user the same compact table inline.
### 3b-bis. CHALLENGE THE PROPOSALS (before the gate)
`mcp__model-router__route(phase="plan")` first (route: own level before the challenge; send it with the challenger dispatch).
`mcp__model-router__route(phase="plan")` first (route: own level before the challenge; send it with the first tool call of lib/challenge-plan.md, the advisor call when one is due).
This axis' findings + proposed fixes are a proposal set worth attacking before
the human gate. Persist THIS axis' finding list (not the whole append-only
report) to `.claude/tasks/plans/<date>-<axis>-<HHMM>.md`, then run
@@ -192,6 +192,7 @@ CHALLENGE SUMMARY (3b-bis — 3 lenses):
BLOCKERs addressed : <n> — <finding → the named finding-set change that closes it>
Deferred (human-ack): <list | none>
Lenses returned : correctness / robustness / simplicity (NAME any that failed to return)
Advisor : <the finding-set change it drove | called, no change | not called (absent | error | already called this run)>
```
- "Fix what you find" said **in the invocation** does NOT skip this gate:
@@ -237,6 +238,11 @@ fix commits land inside it and get re-audited — safe overlap, by design.
## STEP 4 — FINAL SUMMARY
When the run applied a fix, before the summary, the main loop makes its
end-of-run advisor call (`lib/effort-shift.md` § Advisor); its answer
goes into the summary as an `Advisor:` line, and a fix it calls for
waits for a new run.
```
AUDIT-DELTA COMPLETE — 2026-06-11
security : 3 findings → 2 fixed, 1 declined | marker → fbf3e26
+20 -3
View File
@@ -127,7 +127,7 @@ RISK: <low/medium — what could go wrong>
fast-path is not exempt: a 1-line fix with a visible choice still asks.
## STEP 3b — CHALLENGE THE FIX PLAN (before the contract)
`mcp__model-router__route(phase="reflect")` first (route: own level before the challenge; send it with the challenger dispatch).
`mcp__model-router__route(phase="reflect")` first (route: own level before the challenge; send it with the first tool call of lib/challenge-plan.md, the advisor call when one is due).
Unless the fix is the trivial 1-2 line case STEP 3 already fast-paths, the
DIAGNOSIS + FIX PLAN is a reflection worth attacking before it hardens into a
contract. Persist it to `.claude/tasks/plans/<date>-<slug>-<HHMM>.md`, then run
@@ -137,8 +137,8 @@ dispositions. Three blind challengers attack it (correctness = is the root cause
right; robustness = blast radius / regressions; simplicity = is the fix minimal);
RE-THINK every aspect a BLOCKER lands, re-challenge once if the plan materially
changed. STEP 3.5 writes the contract from the REVISED plan. Print a CHALLENGE SUMMARY
(BLOCKERs addressed / deferred / lenses returned), folding any deferred BLOCKER into
the STEP 3 approval gate.
(BLOCKERs addressed / deferred / lenses returned / advisor), folding any
deferred BLOCKER into the STEP 3 approval gate.
## STEP 3.5 — CONTRACT
@@ -200,6 +200,10 @@ Parse the `BUGFIX-EXEC REPORT`:
re-dispatch a FRESH bugfixer with the BLOCKING list + the CONTRACT
path; re-verify the request THEN re-scan, max 3 → escalate.
Stuck: a gate loop fails twice with no main-loop advisor call since GATE 0
first ran → the main loop calls the advisor per `lib/verify-secure-loop.md`
(`lib/effort-shift.md` § Advisor); the answer never enters an executor brief.
Loop decisions stay HERE, in the main loop (LRN-083). Nominal = one
executor + a free floor run + one verifier + one security dispatch.
@@ -227,6 +231,18 @@ Parse the `BUGFIX-EXEC REPORT`:
3. Commit after approval, message per `$HOME/.claude/lib/commit-message.md`
(project convention first, else short: root cause in the subject, at most
two sentences of body).
`mcp__model-router__route(phase="reflect")` first (route: end-of-run review).
Before the summary, the main loop prints the run's diff stat, then makes its
end-of-run advisor call (`lib/effort-shift.md` § Advisor), skipped when
GATE 0 said MET, the verifier CONFORME and security PASS (not DEGRADED),
each on its first attempt; any other verdict, a retry, a loop iteration or
a verdict no longer in view runs the call. DEGRADED shows on the
auditor's `TOOL:` line, beside a PASS. A skip also settles the global
"long task before calling it done" trigger. The answer, or the skip,
goes into the summary's `ADVISOR` field, and a fix it drives goes back
through the gates. A later merge proposal reuses the last run's answer,
or its skip, and names any code commit made after it (doc and memory
commits excepted).
4. Print summary:
```
BUGFIX COMPLETE
@@ -235,6 +251,7 @@ Parse the `BUGFIX-EXEC REPORT`:
FILE(S) : <changed files>
TEST(S) : <added/updated tests, or "none — verified manually">
REGRESSION : <checked areas>
ADVISOR : <one-line answer | skipped (gates clean on first pass) | not called (absent | error)>
```
## STEP 7 — DOC SYNC (automatic)
+1 -1
View File
@@ -31,7 +31,7 @@ Load and follow strictly:
Execute the CLIENT HANDOVER WRITER agent on this project. It runs the
audit/fix/gate pipeline INLINE on the big session model (gated above), its
skill-runner children dispatched `model: "fable"`, then delegates the
skill-runner children dispatched `model: "opus"`, then delegates the
client deliverable to the two-mode `handover-doc-writer` subagent —
synthesize on opus, render (Markdown + branded HTML + PDF) on the sonnet
pin (BDR-077).
+2 -1
View File
@@ -122,7 +122,7 @@ TOTALS: <N blocking, N warn, N info>
If no issues found: report clean state and stop.
## STEP 3b — CHALLENGE THE SCOPE (before approval)
`mcp__model-router__route(phase="plan")` first (route: own level before the challenge; send it with the challenger dispatch).
`mcp__model-router__route(phase="plan")` first (route: own level before the challenge; send it with the first tool call of lib/challenge-plan.md, the advisor call when one is due).
The STEP 3 report is the proposed cleanup scope — worth attacking before the
human approves it. It is still inline, so FIRST persist it to
`.claude/tasks/plans/<date>-<slug>-<HHMM>.md` (STEP 3 report format, one item
@@ -144,6 +144,7 @@ CHALLENGE SUMMARY (STEP 3b — 3 lenses):
BLOCKERs addressed : <n> — <finding → the named scope change that closes it>
Deferred (human-ack): <list | none>
Lenses returned : correctness / robustness / simplicity (NAME any that failed to return)
Advisor : <the scope change it drove | called, no change | not called (absent | error | already called this run)>
AskUserQuestion:
Approve which items for execution? (all / <item numbers> / clarify <item>)
+20 -3
View File
@@ -124,7 +124,7 @@ in the contract's CLARIFICATIONS `[gated]` and in the plan. A choice that
surfaces only during execution comes back as `NEED-DECISION` (STEP 3).
## STEP 1b — CHALLENGE THE PLAN (before branching)
`mcp__model-router__route(phase="reflect")` first (route: own level before the challenge; send it with the challenger dispatch).
`mcp__model-router__route(phase="reflect")` first (route: own level before the challenge; send it with the first tool call of lib/challenge-plan.md, the advisor call when one is due).
The STEP 1 plan is a reflection worth attacking before a branch is spent on it.
Persist it to `.claude/tasks/plans/<date>-<slug>-<HHMM>.md`, then run
`$HOME/.claude/lib/challenge-plan.md` with `PLAN` = that file, `KIND` = `build-plan`,
@@ -132,8 +132,8 @@ Persist it to `.claude/tasks/plans/<date>-<slug>-<HHMM>.md`, then run
Three blind challengers attack it; RE-THINK every aspect a BLOCKER lands (a named
plan change, or `[deferred]`), re-challenge once if the plan materially changed. The
STEP 3 executor receives the REVISED plan. Before dispatch, print a CHALLENGE SUMMARY
(BLOCKERs addressed / deferred / lenses returned), surfacing any deferred BLOCKER in
the STEP 1 pass B batch.
(BLOCKERs addressed / deferred / lenses returned / advisor), surfacing any
deferred BLOCKER in the STEP 1 pass B batch.
## STEP 2 — BRANCH
@@ -185,6 +185,10 @@ produced, `TEST` = the suite named in its report:
STEP 5. BLOCK → re-dispatch a FRESH feater with the BLOCKING list + the
CONTRACT path; re-verify the request THEN re-scan, max 3 → escalate.
Stuck: a gate loop fails twice with no main-loop advisor call since GATE 0
first ran → the main loop calls the advisor per `lib/verify-secure-loop.md`
(`lib/effort-shift.md` § Advisor); the answer never enters an executor brief.
Loop decisions stay HERE, in the main loop (LRN-083). Nominal (clear
request, conform first pass, clean diff) = one executor + a free floor
run + one verifier + one security dispatch.
@@ -202,6 +206,18 @@ commit-changer (propose opus / apply sonnet, BDR-077); never inline-load the bar
propose/apply executor).
Then `mcp__model-router__route(phase="reflect")` (route: nested commit-change loaded at apply; reload feat's level).
Before the summary, the main loop prints the run's diff stat, then makes its
end-of-run advisor call (`lib/effort-shift.md` § Advisor), skipped when
GATE 0 said MET, the verifier CONFORME and security PASS (not DEGRADED),
each on its first attempt; any other verdict, a retry, a loop iteration or
a verdict no longer in view runs the call. DEGRADED shows on the
auditor's `TOOL:` line, beside a PASS. A skip also settles the global
"long task before calling it done" trigger. The answer, or the skip,
goes into the summary's `ADVISOR` field, and a fix it drives goes back
through the gates. A later merge proposal reuses the last run's answer,
or its skip, and names any code commit made after it (doc and memory
commits excepted).
Print summary:
```
FEAT COMPLETE
@@ -209,6 +225,7 @@ FEATURE : <name>
FILE(S) : <created/modified files>
TEST(S) : <added tests>
VERIFIED : <what was checked>
ADVISOR : <one-line answer | skipped (gates clean on first pass) | not called (absent | error)>
```
## STEP 6 — DOC SYNC (automatic)
+8
View File
@@ -236,6 +236,9 @@ file before anything else. Accepted set empty → stop.
GATE 0 runs every scanner oracle (the per-fix proof), GATE 1 a fresh
verifier, GATE 2 a fresh security-auditor. Loop caps and escalation are
the include's; loop decisions stay in this main loop.
Stuck: a gate loop fails twice with no main-loop advisor call since GATE 0
first ran → the main loop calls the advisor per `lib/verify-secure-loop.md`
(`lib/effort-shift.md` § Advisor); the answer never enters an executor brief.
## STEP 11: Re-pass (prove it all)
@@ -271,6 +274,11 @@ open and say so plainly. Never report a fix the re-pass did not prove.
```
Then `git add <files touched>` (never `-A`, never the baseline file) and
commit, project convention else 50 words at most.
Before the reply, the main loop prints the run's diff stat, then makes its
end-of-run advisor call (`lib/effort-shift.md` § Advisor); its answer
goes into the reply as an `Advisor:` line, and a fix it drives goes
back through the gates. A later merge proposal reuses this answer and
names any code commit made after it (doc and memory commits excepted).
2. `mcp__model-router__route(phase="apply")` for the tail. Reply with: fixed
and proven (proposal, rule, file), still open and why, MANUAL steps left
for the user, the branch name. Merge waits for the user's explicit signal.
+2 -1
View File
@@ -522,7 +522,7 @@ Extract the score and critical-alert count from `.claude/audits/HARDEN.md` for t
---
## STEP 2b — CHALLENGE THE FIX BUNDLE (MODE=fix only, advisory)
`mcp__model-router__route(phase="reflect")` first (route: own level before the challenge; send it with the challenger dispatch).
`mcp__model-router__route(phase="reflect")` first (route: own level before the challenge; send it with the first tool call of lib/challenge-plan.md, the advisor call when one is due).
Skip if MODE=audit (no bundle exists). Else, before the STEP 3 gate, harden the bundle:
extract the `## 8. Fix bundle` section from HARDEN.md to
`.claude/tasks/plans/<date>-<slug>-<HHMM>.md` (a clean, blind-judgeable artifact), then run
@@ -557,6 +557,7 @@ If MODE=fix and `.claude/audits/HARDEN.md` ends with `READY TO APPLY — awaitin
BLOCKERs addressed : <n> — <finding → the named bundle change that closes it>
Deferred (human-ack): <list | none>
Lenses returned : correctness / robustness / simplicity (NAME any that failed to return)
Advisor : <the bundle change it drove | called, no change | not called (absent | error | already called this run)>
Options :
A) Apply all
+11 -7
View File
@@ -94,7 +94,7 @@ point. Run it ONLY when the settled fix touches control flow or behaviour — an
off-by-one, a wrong operator/variable, a behaviour-changing config value, or a
missing import that alters execution. In doubt → it is probably a `/bugfix`.
`mcp__model-router__route(phase="reflect")` first (route: own level before the challenge; send it with the challenger dispatch).
`mcp__model-router__route(phase="reflect")` first (route: own level before the challenge; send it with the first tool call of lib/challenge-plan.md, the advisor call when one is due).
For a logic fix: persist the STEP 1 located fix (root cause + the exact edit) to
`.claude/tasks/plans/<date>-<slug>-<HHMM>.md`, then run
`$HOME/.claude/lib/challenge-plan.md` with `PLAN` = that file, `KIND` =
@@ -102,8 +102,8 @@ For a logic fix: persist the STEP 1 located fix (root cause + the exact edit) to
contract's acceptance criteria. Three blind challengers attack the fix; the main
loop RE-THINKS any aspect a BLOCKER lands (a named change to the fix, or
`[deferred]`) and re-challenges once if it materially changed. Print a
CHALLENGE SUMMARY (BLOCKERs addressed / deferred / lenses returned). A BLOCKER
that shows the fix is wrong or incomplete means this was never
CHALLENGE SUMMARY (BLOCKERs addressed / deferred / lenses returned / advisor).
A BLOCKER that shows the fix is wrong or incomplete means this was never
a hotfix — escalate to `/bugfix` (its STEP 3b runs the same phase under the full
verify+secure loop).
@@ -180,16 +180,20 @@ Parse the `HOTFIX-EXEC REPORT`:
fresh dispatch, never inline-load: the repo convention and the FRESH
requirement both forbid it) with `MODE: gate`, `SCOPE:` the working-tree
diff vs `$PRE`. Parse its `SECURITY — VERDICT:` line:
- `PASS` (or `DEGRADED` with no BLOCK) → proceed to commit.
- `PASS` → read the `TOOL:` line first: DEGRADED (semgrep absent)
shows there, never on the VERDICT line; a PASS with no `TOOL:` line
is a structural failure (below). Then proceed to commit; a DEGRADED
PASS sets the summary's SECURITY field to `DEGRADED (checklist only)`.
- `BLOCK(n)` → this is hotfix: do NOT loop. Revert ONLY the executor's
files (`git restore --source=$PRE -- <FILE(S)>` + delete report-listed
NEW files), print the `BLOCKING` list, and STOP:
`"Hotfix introduced a security finding. Reverted. Escalate to /bugfix
for a fix under the full verify+security loop."` The hotfix model is
one attempt; any gate failure (smoke OR security) reverts and escalates.
- Structural failure (mute / unparsable / no VERDICT line) → treat as a
failed gate: retry ONCE fresh; a 2nd structural failure → revert +
escalate. A mute auditor is never a PASS.
- Structural failure (mute / unparsable / no VERDICT line / PASS with
no `TOOL:` line) → treat as a failed gate: retry ONCE fresh; a 2nd
structural failure → revert + escalate. A mute auditor is never a
PASS.
3. Commit only after smoke AND security pass, message per
`$HOME/.claude/lib/commit-message.md` (no convention: one subject line,
`fix(<scope>): <what was wrong>`).
+14 -1
View File
@@ -192,7 +192,7 @@ Invoke `writing-plans` (vendored superpowers skill) with BRIEF + skeleton.
Granular tasks (2-5 min each), exact file paths, TDD: tests before code.
## STEP 6b — CHALLENGE THE PLAN (before the gate)
`mcp__model-router__route(phase="plan")` first (route: own level before the challenge; send it with the challenger dispatch).
`mcp__model-router__route(phase="plan")` first (route: own level before the challenge; send it with the first tool call of lib/challenge-plan.md, the advisor call when one is due).
Before the human sees the implementation plan, harden it. Run
`$HOME/.claude/lib/challenge-plan.md` with `PLAN` = the plan STEP 6 wrote under
`docs/superpowers/plans/`, `KIND` = `build-plan`, `SCOPE` = the skeleton + task file
@@ -213,6 +213,7 @@ CHALLENGE SUMMARY (STEP 6b — 3 lenses):
BLOCKERs addressed : <n> — <finding → the named plan change that closes it>
Deferred (human-ack): <list | none>
Lenses returned : correctness / robustness / simplicity (NAME any that failed to return)
Advisor : <the plan change it drove | called, no change | not called (absent | error | already called this run)>
Approve and start? (yes / request changes)
```
Changes → back to STEP 6. Approved → continue.
@@ -267,6 +268,10 @@ deferred to a later /onboard) and turns the informal analyze into a verdict
against the founding contract. Distinct axis from STEP 10 code review
([[LRN-095]]) — both run.
Stuck: a gate loop fails twice with no main-loop advisor call since GATE 0
first ran → the main loop calls the advisor per `lib/verify-secure-loop.md`
(`lib/effort-shift.md` § Advisor); the answer never enters an executor brief.
## STEP 10 — CODE REVIEW
Invoke `requesting-code-review` (vendored superpowers skill). **Model routing (BDR-077):** the
review subagent it dispatches MUST carry `model: "opus"` and `effort="xhigh"` in the Agent call —
@@ -351,6 +356,14 @@ patched. Report per its rc table — rc 4 = a LOUD upstream BDR-022 anomaly, not
> patched docs on the MVP feature branch so they reach the merge.
## STEP 11 — FINISH
`mcp__model-router__route(phase="plan")` first (route: end-of-run review).
Before proposing the finish, the main loop prints the run's diff stat,
then makes its end-of-run advisor call (`lib/effort-shift.md` § Advisor);
its answer goes with the proposal as an `Advisor:` line, and a fix it
drives goes back through the gates. A later merge proposal reuses this
answer and names any code commit made after it (doc and memory
commits excepted).
Tests pass, build clean, no placeholders. Integrate the MVP feature into develop
— **only on the user's explicit go** (the `gitflow` finish gate):
```bash
+5 -3
View File
@@ -8,8 +8,8 @@ description: Run only when the user asks for it ("memory feedback", "label recal
Phase 4d (BDR-125). The memory mod logs every recall ask; transcripts live
7 days, so this runs weekly. Claude labels, the user spot-checks. Redacted
text stays in the scratchpad; `~/.claude/memory-feedback/` keeps IDs, enums
and repo tags only, never in git.
text stays in the scratchpad; `~/.claude/memory-feedback/` keeps IDs, enums,
repo tags and advisor call counts only, never in git.
## STEP 1 — WORKSHEET
@@ -73,7 +73,9 @@ MFD="$(cd -P "$HOME/.claude/lib" && pwd)/memory-feedback"
rc 1 `draft refused: <reason>` → fix the draft, rerun. It prints
FEEDBACK.md: show the gate lines (`Post-fix prompt asks: k/20` included:
actions wait for 20 post-fix asks) and the Actions list to the user.
actions wait for 20 post-fix asks), the Actions list and the
`## Advisor usage` table (advisor calls since the last run per caller and
served model) to the user.
## STEP 6 — A GATE REACHED FOR THE FIRST TIME
+2 -1
View File
@@ -917,7 +917,7 @@ Vérifier que les 4 fichiers `.claude/audits/ONBOARD_REPORT.md`, `.claude/audits
---
## STEP 7b — CHALLENGE THE PROPOSALS (before the human gate)
`mcp__model-router__route(phase="plan")` first (route: own level before the challenge; send it with the challenger dispatch).
`mcp__model-router__route(phase="plan")` first (route: own level before the challenge; send it with the first tool call of lib/challenge-plan.md, the advisor call when one is due).
The 4 audit files are on disk; `AUDIT_PROPOSALS.md` is the artifact worth
attacking before the human spends a gate on it. Run
`$HOME/.claude/lib/challenge-plan.md` with `PLAN` =
@@ -961,6 +961,7 @@ CHALLENGE SUMMARY (STEP 7b — 3 lenses):
BLOCKERs addressed : <n> — <finding → the named proposals change that closes it>
Deferred (human-ack): <list | none>
Lenses returned : correctness / robustness / simplicity (NAME any that failed to return)
Advisor : <the proposals change it drove | called, no change | not called (absent | error | already called this run)>
Prochaine étape : générer .claude/tasks/TODO.md depuis .claude/audits/AUDIT_PROPOSALS.md approuvé.
+2 -1
View File
@@ -86,7 +86,7 @@ your bundle."
```
## STEP 1b — CHALLENGE THE FIX BUNDLE (advisory, before apply)
`mcp__model-router__route(phase="reflect")` first (route: own level before the challenge; send it with the challenger dispatch).
`mcp__model-router__route(phase="reflect")` first (route: own level before the challenge; send it with the first tool call of lib/challenge-plan.md, the advisor call when one is due).
The analyzer returned a `## FIX BUNDLE` — worth attacking before any edit lands.
**Skip if intervention mode = conservative** (nothing is applied). Else persist the
bundle verbatim to `.claude/tasks/plans/<date>-<slug>-<HHMM>.md`, then run
@@ -138,6 +138,7 @@ CHALLENGE SUMMARY (STEP 1b — 3 lenses):
BLOCKERs addressed : <n> — <finding → the named bundle change that closes it>
Deferred (human-ack): <list | none>
Lenses returned : correctness / robustness / simplicity (NAME any that failed to return)
Advisor : <the bundle change it drove | called, no change | not called (absent | error | already called this run)>
Approve all / select (ids) / skip all?
```
+2 -1
View File
@@ -511,7 +511,7 @@ the reports."
```
## STEP 1b — CHALLENGE THE FIX BUNDLE (advisory, before apply)
`mcp__model-router__route(phase="reflect")` first (route: own level before the challenge; send it with the challenger dispatch).
`mcp__model-router__route(phase="reflect")` first (route: own level before the challenge; send it with the first tool call of lib/challenge-plan.md, the advisor call when one is due).
Both envelopes now carry a `## FIX BUNDLE` — worth attacking before any edit lands.
**Skip if intervention mode = conservative** (nothing is applied). Else persist both
bundles (seo + geo, verbatim) to `.claude/tasks/plans/<date>-<slug>-<HHMM>.md`, then run
@@ -583,6 +583,7 @@ CHALLENGE SUMMARY (STEP 1b — 3 lenses):
BLOCKERs addressed : <n> — <finding → the named bundle change that closes it>
Deferred (human-ack): <list | none>
Lenses returned : correctness / robustness / simplicity (NAME any that failed to return)
Advisor : <the bundle change it drove | called, no change | not called (absent | error | already called this run)>
Approve all / select (ids) / skip all?
```
@@ -256,7 +256,7 @@ grep -c '^### \[Critique\]' .claude/audits/VALIDATE.md
---
## STEP 2b — CHALLENGE THE FIX BUNDLE (MODE=fix only, advisory)
`mcp__model-router__route(phase="reflect")` first (route: own level before the challenge; send it with the challenger dispatch).
`mcp__model-router__route(phase="reflect")` first (route: own level before the challenge; send it with the first tool call of lib/challenge-plan.md, the advisor call when one is due).
Skip if MODE=audit (no bundle exists). Else, before the STEP 3 gate, harden the bundle:
extract the `## 5. Fix bundle` section from VALIDATE.md to
`.claude/tasks/plans/<date>-<slug>-<HHMM>.md` (a clean, blind-judgeable artifact), then run
@@ -296,6 +296,7 @@ CHALLENGE SUMMARY (STEP 2b — 3 lenses) :
BLOCKERs addressed : <n> — <finding → the named bundle change that closes it>
Deferred (human-ack): <list | none>
Lenses returned : correctness / robustness / simplicity (NAME any that failed to return)
Advisor : <the bundle change it drove | called, no change | not called (absent | error | already called this run)>
Options :
A) Apply all
+6
View File
@@ -76,6 +76,12 @@ Parse the `RELEASE-EXEC REPORT`:
- `STATUS: BLOCKED` → surface the blocker verbatim, STOP.
### STEP 4 — HUMAN GATE: when to release
`mcp__model-router__route(phase="reflect")` first (route: end-of-run review).
Before the ask, the main loop makes its
end-of-run advisor call (`lib/effort-shift.md` § Advisor); its answer
goes with the ask as an `Advisor:` line, and a fix it calls for makes
hold the recommended answer.
STOP. Show the prep report's `TESTS` result, then:
```
AskUserQuestion:
+14 -1
View File
@@ -133,7 +133,7 @@ request nor the STEP 1 brainstorm settled (check the contract's CLARIFICATIONS
first) → one batch before STEP 2b; answers append to the contract `[gated]`.
## STEP 2b — CHALLENGE THE PLAN (adversarial, before the gate)
`mcp__model-router__route(phase="plan")` first (route: own level before the challenge; send it with the challenger dispatch).
`mcp__model-router__route(phase="plan")` first (route: own level before the challenge; send it with the first tool call of lib/challenge-plan.md, the advisor call when one is due).
Before the human sees the plan, harden it. Run `$HOME/.claude/lib/challenge-plan.md`:
- `PLAN` = the plan STEP 2 wrote under `docs/superpowers/plans/`
- `KIND` = `build-plan`
@@ -163,6 +163,7 @@ CHALLENGE SUMMARY (STEP 2b — 3 lenses):
BLOCKERs addressed : <n> — <finding → the named plan change that closes it>
Deferred (human-ack): <list | none>
Lenses returned : correctness / robustness / simplicity (NAME any that failed to return)
Advisor : <the plan change it drove | called, no change | not called (absent | error | already called this run)>
Approve and execute? (yes / request changes)
```
This block EXPOSES each in-force item with the plan's CLAIMED disposition, for human
@@ -249,6 +250,10 @@ against the contract. It is a DISTINCT axis from STEP 6 code review (contract
conformity + security vs. craft/design) — both run, neither subsumes the
other ([[LRN-095]]).
Stuck: a gate loop fails twice with no main-loop advisor call since GATE 0
first ran → the main loop calls the advisor per `lib/verify-secure-loop.md`
(`lib/effort-shift.md` § Advisor); the answer never enters an executor brief.
## STEP 6 — CODE REVIEW
Invoke `requesting-code-review` (vendored superpowers skill). **Model routing (BDR-077):** the
review subagent it dispatches MUST carry `model: "opus"` and `effort="xhigh"` in the Agent call —
@@ -315,6 +320,14 @@ surfaced a forbidden path), not a silent skip. It runs BEFORE FINISH so the doc
on the branch FINISH integrates.
## STEP 9 — FINISH
`mcp__model-router__route(phase="plan")` first (route: end-of-run review).
Before proposing the finish, the main loop prints the run's diff stat,
then makes its end-of-run advisor call (`lib/effort-shift.md` § Advisor);
its answer goes with the proposal as an `Advisor:` line, and a fix it
drives goes back through the gates. A later merge proposal reuses this
answer and names any code commit made after it (doc and memory
commits excepted).
Tests pass, build clean. Integrate the feature into develop — **only on the
user's explicit go** (the `gitflow` finish gate):
```bash
+12 -3
View File
@@ -80,7 +80,7 @@ Model discipline (the user-fixed invariant behind this mode):
carries this skill's reflection (fix decisions, convergence calls); it
must never be pinned down to an executor tier.
- Inside a runner, every dispatched agent keeps the tier this skill
already defines: security-auditor (`audit` row: Fable, opus floor), the
already defines: security-auditor (`audit` row: opus), the
Phase B audit (analyzer opus pin or `model="opus"`), doc-syncer (audit on
`model="opus"`, patch on its sonnet frontmatter — BDR-077).
@@ -92,7 +92,8 @@ Agent(subagent_type="general-purpose",
prompt="Read ~/.claude/skills/tour/SKILL.md and execute STEP 1 → STEP 3
for EXACTLY ONE project: <absolute path>. Flags: <--report-only|none>.
Skip STEP 0/0b (routing) and the global summary — the dispatcher owns
them. Every rule of the skill applies unchanged: max 3 iterations,
them; never call the advisor. Every rule of the skill applies
unchanged: max 3 iterations,
never merge/finish/push main|develop, scoped commits, report appended to that
project's own .claude/audits/TOUR.md. Return EXACTLY: the project's
one-line global-summary row (STEP 3 format), then BRANCH: <name|no
@@ -104,7 +105,9 @@ The main loop then:
1. Collects each runner's summary row. A dead or mute runner becomes the
row `<path> : RUNNER FAILED — <reason> | no report` — never a silent
absence (a mute runner is NEVER a pass).
2. Prints the global summary (STEP 3 format) once ALL runners returned.
2. Once ALL runners returned: when any row reports a fix, makes the
STEP 3 end-of-run advisor call; then prints the global summary (STEP 3
format).
3. Runs the gated capitalize offer — MAIN LOOP ONLY, never inside a
runner: registries are shared state, and gate decisions stay here
(LRN-083).
@@ -261,6 +264,12 @@ order:
Checks: pytest PASS, ruff PASS. Residuals: SEC-2 (needs decision). Commits: 4. BREAKING: 1 (SEC-2).
```
Main loop only, never a runner: when the tour applied any fix, before
the global summary, the main loop makes its
end-of-run advisor call (`lib/effort-shift.md` § Advisor); its answer
goes into the summary as an `Advisor:` line, and a fix it calls for
waits for a new run.
Global summary inline, one line per project (append `BREAKING: n` to
any project line with contract-changing fixes left open for decision):