chore(memory): BDR-155 advisor per-run note, LRN-306, journal

This commit is contained in:
bchanot committed 2026-11-24 14:50:39 +01:00
1 parent 1d69fce92f
commit d0ca9dbd88
5 files changed
+178

No files matched your search

+6
View File
@@ -1639,3 +1639,9 @@ Supersedes [[BDR-030]].
- **Why**: machine pulled before fetch → chrome-extensions SKILL.md missing = doctor FAIL → `make update` (ends on doctor.sh) exits 1. User chose warn only 2026-11-22. - **Why**: machine pulled before fetch → chrome-extensions SKILL.md missing = doctor FAIL → `make update` (ends on doctor.sh) exits 1. User chose warn only 2026-11-22.
- **Alternatives rejected**: keep FAIL (update red until `make plugin`). - **Alternatives rejected**: keep FAIL (update red until `make plugin`).
- **Reference**: 14bee52; tests TREE_OWNED_* + TREE_NAMES_ERREXIT_BROKEN_LOCK in lib/tests/doctor-vendored.test.sh; open LOW: lock key unvalidated in `_dv_tree_expectations` (TODO, 7e29279). - **Reference**: 14bee52; tests TREE_OWNED_* + TREE_NAMES_ERREXIT_BROKEN_LOCK in lib/tests/doctor-vendored.test.sh; open LOW: lock key unvalidated in `_dv_tree_expectations` (TODO, 7e29279).
## BDR-155 — Advisor once per main-loop run of plan/reflect-row skills; model-router prepends rule to skill body [accepted] (2026-11-24)
**Context**: User 2026-11-23: advisor called too rarely; wants it wherever main used to route to Fable (pre-BDR-150 best tier = plan/reflect rows). 7-day tally: 96 main runs of those skills, 65 advisor calls.
**Decision**: Main-loop run of skill whose model-router row = `plan`|`reflect` makes one advisor call on settled plan/diagnosis/fix, before execute or report. Call at point 1/2/3 counts. Only challenge-plan § SKIP + point 3 skips waive; other challenge guards (cosmetic /hotfix, audit/conservative modes, clean stop) still get call. Nested under plan/reflect run: none. Carrier: model-router mod prepends ADVISOR_NOTE to skill body (skill.prompt) on main loads (Skill call w/o agentId, typed slash), never sub-agent/preload. Rule text = `lib/effort-shift.md` § Advisor point 4 "Per run". Amends BDR-150: call point, never route.
**Alternatives**: Skill-result `context` (attachment channel, ignored per LRN-303); CLAUDE.global.md line (320/320 budget); per-skill body edits (55 rows, drift).
**Consequences**: ~140k input tokens per main call; harden/seo/geo/web-validate audit modes + cosmetic hotfix gain a call. Accepted gaps (shortcut comments register.ts): same-name sub-agent load mid main Skill call steals note; typed slash during in-flight Skill call loses it; concurrent main calls keep last marker. Behavioural tally deferred to 1-week re-measure. Commits d9f0f42, 1d69fce.
+3
View File
@@ -808,3 +808,6 @@ rules:
## 2026-11-23 ## 2026-11-23
- prompt-audit Opus 5.5: always-on ~14k tok (doctor), 5 small edits CLAUDE.global merged 38be889; olmind not found; slim gitflow/memory text = BDR-125 candidate. - prompt-audit Opus 5.5: always-on ~14k tok (doctor), 5 small edits CLAUDE.global merged 38be889; olmind not found; slim gitflow/memory text = BDR-125 candidate.
- advisor trigger before root-cause diagnosis / user-run commands (7b63507). Measured: unserved advisor blocks beside tool_use all re-served next msg, no lost calls; lever dropped. - advisor trigger before root-cause diagnosis / user-run commands (7b63507). Measured: unserved advisor blocks beside tool_use all re-served next msg, no lost calls; lever dropped.
## 2026-11-24
- advisor per-run note (d9f0f42, docs 1d69fce): mod prepends one-call rule on main plan/reflect skill loads; gates MET, sec PASS, verifier ECARTS(1)=AC6 live check pending /reload-plugins. BDR-155, LRN-306.
+5
View File
@@ -2192,3 +2192,8 @@ Rule: when editing a doctrine file under structure locks, grep the test's lock s
- **Context**: 2026-11-21/22 ship-feature modern-web-guidance. Dry run overlapped running executor → false reds; re-run after report = MET. Separate real red same run: row 10 `FAIL bun not on PATH` (see learnings line ~2009, fixed by `PATH="$HOME/.bun/bin:$PATH"` in oracle). - **Context**: 2026-11-21/22 ship-feature modern-web-guidance. Dry run overlapped running executor → false reds; re-run after report = MET. Separate real red same run: row 10 `FAIL bun not on PATH` (see learnings line ~2009, fixed by `PATH="$HOME/.bun/bin:$PATH"` in oracle).
- **Apply**: dry run only with no live executor (before first dispatch, or after its report). Red dry run during a dispatch → re-run after report before acting on it. - **Apply**: dry run only with no live executor (before first dispatch, or after its report). Red dry run during a dispatch → re-run after report before acting on it.
- **Reference**: lib/verify-secure-loop.md § BEFORE THE FIRST DISPATCH; BDR-151 lever 4 (contract dry run). - **Reference**: lib/verify-secure-loop.md § BEFORE THE FIRST DISPATCH; BDR-151 lever 4 (contract dry run).
## LRN-306 — doctrine-citers captures unquoted section label over following words; close label with paren (2026-11-24)
**Pattern**: doctrine-citers T6 (lib/tests/doctrine-citers.test.sh:78) captures unquoted `§ <Label>` greedily over following words: "`lib/challenge-plan.md` § SKIP and point 3's skips" → label "SKIP and point", no heading starts with it → dangling cite, suite red.
**Context**: /feat advisor per-run note 2026-11-24, effort-shift point 4; executor reworded.
**Apply**: in .md doctrine, end a § label at clause end or close it with ")": "(`lib/challenge-plan.md` § SKIP)". Dry-run planned prose through doctrine-citers before dispatch (LRN-296 scratch-copy pattern).
@@ -0,0 +1,61 @@
# CONTRACT — advisor note per former-Fable skill run
- run-base: 4b8ed29736d0975544c0348f00204eb7bae7f92f
## REQUEST (verbatim)
User 2026-11-23: "il faut appeler l'adviser partout ou initialement on avait
le routage ver fable aussi." Answers (same day): scope = "Un appel par run";
skips = "Les garder"; sub-agents = "Rien ne change".
## CLARIFICATIONS
- [gated] One main-loop advisor call per run of a skill whose routing.json
row phase is `plan` or `reflect` (the rows that lifted main to Fable before
BDR-150; rows unchanged since 24b0f35^). A call the skill already places
counts. Existing skips stay. Sub-agent advisor scope unchanged.
- [gated] Plan r4 § Rule 1-4: one call on the settled plan/diagnosis/fix;
a point 1-3 call counts; only challenge-plan § SKIP and point 3 skips
waive it (other challenge guards get the call: cosmetic /hotfix gains
one, as told to the user); nested under a plan/reflect run: no call.
Row phase read from the merged config.
- [internal] Carrier: the model-router mod prepends one note line to the
skill body (skill.prompt) for main-loop loads only (main Skill tool call or
user-typed slash), never sub-agent loads or preloads.
- [gated 2026-11-24] Deferred point "behavioural tally (calls per run
counted in transcripts)": keep. Not a criterion of this run; done at the
one-week re-measure with the same transcript count. User: "tu peux lancer".
## ACCEPTANCE CRITERIA
1. A main-loop load of a plan/reflect row (Skill tool call without agentId,
or a user-typed slash) gets ADVISOR_NOTE prepended to the skill text;
prefixed rows (`pack-design:frontend-design`) too. Mod suite green.
CHECK: cd /home/bchanot/Documents/claude && timeout 300 claude plugin test mods/model-router 2>&1 | grep -cE '^ *0 fail$'
EXPECT: 1
EVIDENCE: MET exit=0 marker-found :: 1
2. No note for: a sub-agent Skill load (agentId set), a preload (no Skill
call, not typed), a row of another phase (capitalize), an unrowed skill,
the mod off. Each case has a test whose name starts "advisor note".
CHECK: n=$(grep -c "test('advisor note:" /home/bchanot/Documents/claude/mods/model-router/hooks/register.test.ts); [ "$n" -ge 11 ] && echo enough || echo "only $n"
EXPECT: enough
EVIDENCE: MET exit=0 marker-found :: enough
3. lib/effort-shift.md § Advisor gains point 4 `**Per run.**`.
CHECK: grep -c '^4\. \*\*Per run\.\*\*' /home/bchanot/Documents/claude/lib/effort-shift.md
EXPECT: 1
EVIDENCE: MET exit=0 marker-found :: 1
4. `make test` green except the baseline memory-feedback suite (bun not on PATH).
CHECK: cd /home/bchanot/Documents/claude && make test 2>&1 | grep 'suite(s) red'
EXPECT: 1 suite(s) red: lib/tests/memory-feedback.test.sh
EVIDENCE: MET exit=0 marker-found :: 1 suite(s) red: lib/tests/memory-feedback.test.sh
5. CLAUDE.global.md and routing.json untouched by this run (routing.json's
working-tree `"close": "apply"` predates the run: live mod dialog).
CHECK: cd /home/bchanot/Documents/claude && git diff --quiet 4b8ed29..HEAD -- CLAUDE.global.md mods/model-router/routing.json && git diff --quiet -- CLAUDE.global.md && echo untouched
EXPECT: untouched
EVIDENCE: MET exit=0 marker-found :: untouched
6. Live precondition before any merge proposal (not a test): after the user
runs /reload-plugins, with a background sub-agent live (typed fallback
off), a main-loop Skill load of one reflect row and one pack row shows
the note; until then reported "not verified live".
## FILE SCOPE
- mods/model-router/hooks/register.ts
- mods/model-router/hooks/register.test.ts
- lib/effort-shift.md
@@ -0,0 +1,103 @@
# PLAN — advisor note per former-Fable skill run (r4)
CONTRACT: .claude/tasks/contracts/2026-11-23-advisor-skill-note-1840.md
## Rule (the same words in the note and in point 4)
1. A main-loop run of a skill whose row phase (merged config `st.cfg`) is
`plan` or `reflect` makes one advisor call on its settled plan,
diagnosis or fix, before it executes or reports (at load when the run
starts from a settled plan).
2. A call made this run at point 1, 2 or 3 of § Advisor counts as this one.
3. Only two kinds of skip waive it: `lib/challenge-plan.md` § SKIP (placed
decision) and point 3's named skips. Any other skip of a challenge step
(hotfix's cosmetic guard, harden or web-validate MODE=audit, seo or geo
conservative mode, code-clean's clean stop) does not waive it: the call
is made where that step would have run.
4. A skill loaded inside a plan/reflect skill's run makes no call of its
own (the outer run owns it); under a skill of another row or no row, it
calls.
## Note text (exact, one source line, then "\n\n", prepended)
"Advisor (`~/.claude/lib/effort-shift.md` § Advisor, **Per run**): when the
`advisor` tool is listed, this skill run makes one main-loop advisor call on
its settled plan, diagnosis or fix, before it executes or reports. A call
this run already made at an advisor point counts. Only
`~/.claude/lib/challenge-plan.md` § SKIP and the end-of-run skips waive it;
any other skipped challenge step still gets the call where it would have
run. Loaded inside another plan/reflect skill's run: no call of its own."
## Files
- [ ] mods/model-router/hooks/register.ts
- Consts near REFERENCE_SKILLS: `ADVISOR_NOTE` (text above + "\n\n"),
`ADVISOR_PHASES = new Set(['plan', 'reflect'])`.
- State field `advisorSkill: string | null`, init null in the state
factory (~line 1028), comment "main-loop Skill load awaiting its note".
- Helper `advisorDue(st, skill): boolean` = `skillRow(st, skill)?.phase`
in ADVISOR_PHASES (row-phase test only; `st.off` is handled by the
existing early returns).
- registerSkills tool.call (~4627): decide due-ness with the SAME name
`onSkillLoad` routes by. Immediately before `const out = await next(e)`
(after tierAsk), if `e.agentId === undefined && advisorDue(st, skill)`
set `st.advisorSkill = skill`. In `finally`: `if (e.agentId ===
undefined) st.advisorSkill = null`. No name normalization (no
skillKey): AC6 live check decides whether names ever differ.
- registerSkills skill.prompt (~4650):
- In-call branch (`st.skillCalls > 0`, mod on): `const out = await
next(e)`; if `st.advisorSkill === e.skill` → set `st.advisorSkill =
null` and return `{ text: ADVISOR_NOTE + out.text }`; else `out`.
- Typed branch: evaluate `typed && advisorDue(st, e.skill)` AFTER
`confirmSkill` returns (a first-use move counts), then wrap the
`next(e)` result the same way.
- Accepted gaps (state them in a code comment at the marker): a same-name
sub-agent load while a main Skill call is in flight takes the note (and
the main load loses it); a typed slash whose prompt lands while any
Skill call is in flight loses its note; two concurrent main Skill calls
keep only the last marker. skill.prompt carries no agentId.
- [ ] mods/model-router/hooks/register.test.ts — `describe('advisor note')`
with tests titled `test('advisor note: …'`. Local rig: a world built with
`newWorld({ edit: f => Object.assign(f.skills, { 'writing-plans': 'plan',
'pack-design:frontend-design': 'reflect', capitalize: 'apply' }) })`
(adapt to the fixture API), and a bottom Skill tool modeled on the test
at ~line 1613 that calls `$.skill.prompt({ skill: e.skill, text: 'BODY' })`
and returns its text in the result so the test can read it. Assert with a
literal prefix duplicated in the test: `'Advisor (`~/.claude/lib/effort-
shift.md` § Advisor, **Per run**)'` (no export from register.ts).
Cases (11): main `feat` → note; main `writing-plans` → note; main
`pack-design:frontend-design` → note; agentId set → no note; preload
(skill.prompt, no Skill call, not typed, a sub-agent spawned so the typed
fallback is off) → no note; `capitalize` (apply) → no note; `status`
(mechanical) → no note; unrowed skill → no note; `/route off` → no note;
typed `/feat` → note; sub-agent Skill call ending during a main call does
not clear the main marker (note still on the main load).
- [ ] lib/effort-shift.md § Advisor — after item 3 (ends "…a new run."):
"4. **Per run.** A main-loop run of a skill whose model-router row is
`plan` or `reflect` (the rows that put main on Fable before BDR-150)
makes one call on its settled plan, diagnosis or fix, before it
executes or reports (at load when it starts from a settled plan). A
call this run made at point 1, 2 or 3 counts as this one. Only
`lib/challenge-plan.md` § SKIP and point 3's skips waive it; any other
skipped challenge step (hotfix's cosmetic guard, an audit-only or
conservative mode, a clean stop) gets the call where that step would
have run. A skill loaded inside a plan/reflect skill's run makes none;
under another row or none, it calls. The model-router mod prepends
this rule to the skill body on a main-loop load, never on a
sub-agent's."
## Edge cases
- Mod off → no note (existing early returns). Hook failure → passthrough.
- Nested loads under a plan/reflect run still carry the note; its last
sentence says no call.
- routing.json dirty before the run: never edited or staged by this run.
## Disposition
- honors BDR-150 (a call point, not a route); LRN-303 (body carrier over
Skill-result `context`, an attachment channel LRN-303 found ignored;
price = the marker and its accepted gaps).
- honors user picks 2026-11-23: one call per run; the advisor-section skips
kept (§ SKIP, point 3); sub-agent scope unchanged; cosmetic /hotfix gains
its call. Challenge-step guards that never were advisor skips now get the
call (that is what "one per run" buys).
- CLAUDE.global.md untouched. README/USAGE/CHANGELOG via STEP 6.
- [deferred] behavioural tally (calls per run counted in transcripts):
needs real runs after reload; proposed = the one-week re-measure already
promised to the user, run with the same transcript count.