fix(router): only Haiku 4.x takes no effort; Haiku 5.x gets its route's

The no-effort rule was keyed on every claude-haiku id, so Haiku 5.5 ran at the engine default instead of its phase effort (mechanical: low). The guard now names Haiku 4.x; status-reporter pins effort: low.
This commit is contained in:
bchanot committed 2026-10-25 22:19:55 +01:00
1 parent a6b94a4c46
commit 8e93507b19
7 files changed
+165 -12

No files matched your search

@@ -0,0 +1,51 @@
# CONTRACT — router-haiku-effort
- date: 2026-10-25 | flow: bugfix | branch: bugfix/router-haiku-effort (from develop)
- status: active
## REQUEST (verbatim — IMMUTABLE)
model-router haiku effort strip (BLK-035 residual, TODO "/bugfix model-router haiku effort strip"): Haiku 5.5 takes effort (low–max, default medium, claude-api model table) but the mod still applies the Haiku 4.5 rule "haiku takes no effort": effort omitted on every haiku step (register.ts step plan ~l.3820 `startsWith(HAIKU) → effort: undefined`), `effortWord` prints "- (haiku takes none)" (~l.1824), isHaiku sites (~l.1372, 3550, 3703, 4095, 4267), census skip `lib/tests/effort-routing.test.sh:170`. Symptom: the `mechanical` phase (cheap tier, effort low) runs status-reporter on haiku at the engine default medium, not low.
## CLARIFICATIONS
- [gated 2026-10-25] Fix approved with challenge (user).
- [gated 2026-10-25] Haiku 5.x behaves like any model (user pick): routes, prompt keywords, sticky effort and session effort apply; reverses the 2026-10-23 edge "haiku session → keywords no-op".
- [after the challenge] The no-effort guard is kept, scoped to Haiku 4.x (`claude-haiku-4` prefix after `canonical`): 4.5 is still served and takes no effort, reachable by override or full id.
## ACCEPTANCE CRITERIA
1. On a Haiku 5.x model (`claude-haiku-5-5`), a routed main step and a spawned agent's steps carry the route's effort (`mechanical` → `low`); `/route show` prints that effort, not "takes none"; an unrouted step passes the engine effort unchanged.
2. On Haiku 4.x (`models.haiku` overridden to `claude-haiku-4-5-20251001`), steps still carry no effort and `/route show` says `haiku 4 takes none`.
3. The no-effort rule is keyed on a version-named constant (`claude-haiku-4`), not on the family prefix `claude-haiku`, at every effort site (planStep, handoffOf, the loop.last condition, effortWord).
CHECK: python3 -I -c "import re;s=open('mods/model-router/hooks/register.ts').read();a=s.count(\"'claude-haiku-4'\");b=len(re.findall(r'haiku takes none',s));print('guard=%d/%d'%(min(a,1),b))"
EXPECT: guard=1/0
EVIDENCE: MET exit=0 marker-found :: guard=1/0
4. Tests in register.test.ts: the three former omission assertions now expect the phase effort; new tests for Haiku 4.x keeping the strip, the unrouted passthrough, a `plan` keyword on a haiku-5-5 session → xhigh, an unrowed haiku spawn (hand-off `haiku/-`, first step silent), `/route show` on haiku-5-5.
5. Census: the haiku skip at lib/tests/effort-routing.test.sh is gone and agents/status-reporter.md declares `effort: low`.
CHECK: a=$(grep -c 'field_of "$RD" "$phase" model)" = haiku' lib/tests/effort-routing.test.sh); b=$(awk 'NR==1&&/^---$/{p=1;next} p&&/^---$/{exit} p' agents/status-reporter.md | grep -c '^effort: low$'); echo "census=$a/$b"
EXPECT: census=0/1
EVIDENCE: MET exit=0 marker-found :: census=0/1
6. README.md no longer says haiku takes no effort.
CHECK: echo "readme=$(grep -c 'none on haiku' README.md)"
EXPECT: readme=0
EVIDENCE: MET exit=0 marker-found :: readme=0
7. Mod suite green.
CHECK: make test suite=lib/tests/mods.test.sh 2>&1 | tail -1
EXPECT: all suites green
EVIDENCE: MET exit=0 marker-found :: all suites green
8. Full suite green (census included).
CHECK: make test 2>&1 | tail -1
EXPECT: all suites green
EVIDENCE: MET exit=0 marker-found :: all suites green
9. Diff touches only the FILE SCOPE.
CHECK: git diff --name-only develop -- . ':!.claude' | grep -vcE '^(mods/model-router/hooks/register.ts|mods/model-router/hooks/register.test.ts|lib/tests/effort-routing.test.sh|agents/status-reporter.md|README.md)$' | sed 's/^/n=/'
EXPECT: n=0
EVIDENCE: MET exit=0 marker-found :: n=0
10. No new lint or test suppression.
CHECK: git diff -U0 develop -- . ':!.claude' | grep -E '^\+' | grep -cE 'eslint-disable|@ts-ignore|@ts-expect-error|shellcheck disable' | sed 's/^/n=/'
EXPECT: n=0
EVIDENCE: MET exit=0 marker-found :: n=0
## FILE SCOPE
- mods/model-router/hooks/register.ts
- mods/model-router/hooks/register.test.ts
- lib/tests/effort-routing.test.sh
- agents/status-reporter.md
- README.md (l.124 only)
@@ -0,0 +1,25 @@
# FIX PLAN — router-haiku-effort (bugfix)
## DIAGNOSIS
- BUG: on a haiku model the router never sends an effort: `mechanical` (cheap tier, effort low) runs status-reporter and the 8 mechanical skills (status, profile, plugin-check, skills-perso, using-git-worktrees, 21st-cli-use, 21st-registry, 21st-design-sync) at Haiku 5.5's engine default (medium); `/route show` prints `- (haiku takes none)`.
- ROOT CAUSE: the Haiku 4.5 rule "haiku takes no effort" is hard-coded in 4 places; the `haiku` alias now resolves to `claude-haiku-5-5` (2c39524, BLK-035), which takes effort low–max, default medium (claude-api skill model table, cached 2026-10-06).
- PRIOR: BLK-035 (this is its residual), LRN-230 (per-model facts rot with the alias).
- EVIDENCE: mods/model-router/hooks/register.ts:3948-3953 `planStep` strips `effort` when `step.plan.model.startsWith(HAIKU)` (main AND agent steps); :3833 `handoffOf` sets the spawned agent's effort to undefined on haiku; :4238 `loop.last = hand.to` also when `isHaiku` (the "effort known" case only because it was undefined); :1874-1875 `effortWord` prints `- (haiku takes none)`. Census lib/tests/effort-routing.test.sh:170 skips the agent effort floor check when the phase model is haiku; agents/status-reporter.md frontmatter has `model: haiku` and no `effort:`.
- OUT OF SCOPE (not effort): `moveTo` / `knownModel` / `variantNote` `[1m]` rule (l.1220, 2137, 2273), `windowReturn` refusing a haiku home (l.1373), `smallModelBusy` (l.4410).
## FIX PLAN (r2, after 3 lenses: correctness CONCERNS(1), robustness CONCERNS(2), simplicity SOLID; no BLOCKER)
The guard is KEPT and scoped to the version that takes no effort (C1/R1, LRN-230: name the model version), not deleted.
1. register.ts: new constant beside `HAIKU` (l.213): `const NO_EFFORT = 'claude-haiku-4' // Haiku 4.x takes no effort; 5.x does (low-max)`. New helper next to `isHaiku` (l.3678): `const takesNoEffort = (cfg: Config, id: string): boolean => canonical(cfg, id).startsWith(NO_EFFORT)`.
2. register.ts:3948-3953 `planStep`: the strip tests `takesNoEffort(st.cfg, step.plan.model)` instead of `startsWith(HAIKU)`; comment names Haiku 4.x.
3. register.ts:3833 `handoffOf`: `takesNoEffort(st.cfg, started.model) ? undefined : given ?? route?.effort`.
4. register.ts:4238: `hand.effortCause !== 'engine' || takesNoEffort(st.cfg, hand.to.model)`.
5. register.ts:1873-1875 `effortWord`: `takesNoEffort(st.cfg, v.call.model)` → `'- (haiku 4 takes none)'`; doc sentence names Haiku 4.x.
`HAIKU` / `isHaiku` stay for the out-of-scope sites ([1m], windowReturn, smallModelBusy).
6. register.test.ts (S1/C3/R3): update the existing omission assertions to the phase effort and rename: l.~860 `expect(sent.effort).toBeUndefined()`, l.~3838 `mainWord(..., 'haiku/-', ...)` → `haiku/low`, l.~4038-4048 test "a haiku spawn shows no effort" → asserts `haiku/low` and a new name. New tests: (c) `/route show` main line on a haiku-5-5 session shows the effort, not `takes none`; (d) Haiku 4.x keeps the strip: `models.haiku` overridden to `claude-haiku-4-5-20251001` (home override fixture) → a routed step sends NO effort, `/route show` says `haiku 4 takes none`, a spawn hand-off shows `haiku/-`; (e) unrouted haiku-5-5 step passes the engine effort unchanged (C2); (f) haiku-5-5 session + `plan` keyword prompt → step effort xhigh (R2, the accepted edge reversal pinned by a test); (g) unrowed haiku-5-5 spawn (engine effort cause): hand-off `haiku/-`, first agent step logs nothing (R3).
7. lib/tests/effort-routing.test.sh:170: delete the haiku skip (status-reporter is the only haiku agent; its row `mechanical` = haiku/low).
8. agents/status-reporter.md: add `effort: low` to the frontmatter, placed like other agents' `effort:` line.
9. README.md:124 (S2): drop "(none on haiku, which rejects the parameter)" (now false for Haiku 5.5).
## RISK (r2)
Visible behaviour change on Haiku 5.x (user pick 2026-10-25: "like any model"): routed steps get the phase effort (`mechanical` low); effort-only routes go live on a haiku session (`plan`/`design`/`architecture` → xhigh, `ultrathink` → max, `why`/`review` → high, sticky `/route effort=`, derived orchestrate); an unrouted step passes the engine/session effort (high here) instead of the engine default medium. Reverses the 2026-10-23 accepted edge "haiku session → keywords no-op" → amendment at CAPITALIZE; also the effort-pin BDR line "none on status-reporter (haiku)" (decisions.md:~1350) → amendment. Haiku 4.x unchanged.
Live check (C4, user-run, not a gate): `/status` on a session with `verbose` → hand-off `status-reporter haiku/low`.
+2 -2
View File
@@ -120,8 +120,8 @@ 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
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 (none
on haiku, which rejects the parameter); `/status` low … `/ship-feature`
appliers, medium executors, high writers, xhigh judgment and gates;
`/status` low … `/ship-feature`
xhigh. The vendored externals (design stack, superpowers, agent-skills,
MengTo scroll skills, 21st) get their level from their row only.
Orchestrators declare each phase through the `mcp__model-router__route`
+1
View File
@@ -3,6 +3,7 @@ name: status-reporter
description: Read-only project-status engine — dispatched by /status. Collects plugin roster + passive-cost estimate (doctor.sh constants), git state, build/tests, GSD milestone into one snapshot.
tools: Read, Bash, Glob, Grep
model: haiku
effort: low
---
# STATUS REPORTER
-1
View File
@@ -167,7 +167,6 @@ check_agent() {
phase="$(row_of "$RD" agents "$name")"
[ -n "$phase" ] || { ko "agents/$name: no row in routing.json"; return; }
floor_check "$RD" agents "$name" model "$(fm_val "$R/$f" model)" "$phase" "agents/$name"
[ "$(field_of "$RD" "$phase" model)" = haiku ] && return
floor_check "$RD" agents "$name" effort "$(fm_val "$R/$f" effort)" "$phase" "agents/$name"
}
while IFS= read -r f; do check_agent "$f"; done < <(
+75 -3
View File
@@ -857,7 +857,52 @@ test('cap: a downgrade under the cold-read cap moves main', async (
await $.tool.call({ tool: ROUTE_TOOL, phase: 'mechanical' })
const sent = await stepOn($, rig, FABLE)
expect(sent.model).toBe(HAIKU)
expect(sent.effort).toBe('low')
})
const HAIKU_4 = 'claude-haiku-4-5-20251001'
const HAIKU_4_HOME = { home: { models: { haiku: HAIKU_4 } } }
test('haiku 5: /route show prints the effort, not "takes none"', async (
$, on) => {
await bootRig($, on)
await $.tool.call({ tool: ROUTE_TOOL, phase: 'mechanical' })
const line = mainLine(await route($, 'show'))
expect(line).toContain('effort low')
expect(line).not.toContain('takes none')
})
test('haiku 4: a routed step keeps no effort, show says so', async (
$, on) => {
const rig = await bootRig($, on, FABLE, 1000, newWorld(HAIKU_4_HOME))
await $.tool.call({ tool: ROUTE_TOOL, phase: 'mechanical' })
const sent = await stepOn($, rig, FABLE)
expect(sent.model).toBe(HAIKU_4)
expect(sent.effort).toBeUndefined()
expect(mainLine(await route($, 'show'))).toContain('haiku 4 takes none')
})
test('haiku 5: an unrouted step passes the engine effort', async (
$, on) => {
const rig = await bootRig($, on, HAIKU)
expect(await stepOn($, rig, HAIKU)).toEqual({
model: HAIKU,
effort: 'high',
})
})
test('haiku 5: a plan keyword on a haiku session is xhigh', async (
$, on) => {
const rig = await bootRig($, on, HAIKU)
await $.prompt.submit({
text: 'plan the migration',
wait: false,
origin: { kind: 'composer' },
})
expect(await stepOn($, rig, HAIKU)).toEqual({
model: HAIKU,
effort: 'xhigh',
})
})
test('fallback: a rate limit on fable moves plan to opus max', async (
@@ -3835,7 +3880,8 @@ test('logs: a downgrade is a switch', async ($, on) => {
await route($, 'mechanical')
await runStep($, highStep())
expect(logs).toEqual([
mainWord('fable/high', 'haiku/-', 'mechanical: sticky /route, switch'),
mainWord('fable/high', 'haiku/low',
'mechanical: sticky /route, switch'),
])
})
@@ -4035,13 +4081,14 @@ test('logs: an explicit effort is one line, then silence', async ($, on) => {
expect(logs).toEqual([line])
})
test('logs: a haiku spawn shows no effort, then silence', async ($, on) => {
test('logs: a haiku spawn shows its effort, then silence', async (
$, on) => {
const world = newWorld({
edit: f => { (f.agents as Rec).feater = 'mechanical' },
})
const { logs } = await afterMainStep($, on, { world })
await $.agent.spawn(spawnOf('feater'))
const line = 'main fable/high → agent feater haiku/- ' +
const line = 'main fable/high → agent feater haiku/low ' +
'(row mechanical, row)'
expect(logs).toEqual([line])
await runStep($, { ...highStep('a1'), model: HAIKU })
@@ -4064,6 +4111,31 @@ test('logs: two agent types to one model are two hand-offs', async (
expect(handoffs(logs)).toHaveLength(2)
})
test('logs: a haiku 4 spawn shows no effort, then silence', async (
$, on) => {
const world = newWorld({
...HAIKU_4_HOME,
edit: f => { (f.agents as Rec).feater = 'mechanical' },
})
const { logs } = await afterMainStep($, on, { world })
await $.agent.spawn(spawnOf('feater'))
const line = 'main fable/high → agent feater haiku/- ' +
'(row mechanical, row)'
expect(logs).toEqual([line])
await runStep($, { ...highStep('a1'), model: HAIKU_4 })
expect(logs).toEqual([line])
})
test('logs: an unrowed haiku spawn is silent at its first step', async (
$, on) => {
const { logs } = await afterMainStep($, on)
await $.agent.spawn(spawnOf('unrowed', { model: 'haiku' }))
const line = 'main fable/high → agent unrowed haiku/- (explicit, engine)'
expect(logs).toEqual([line])
await runStep($, { ...highStep('a1'), model: HAIKU })
expect(logs).toEqual([line])
})
test('logs: one agent type to two models is two hand-offs', async (
$, on) => {
const { logs } = await afterMainStep($, on)
+11 -6
View File
@@ -211,6 +211,7 @@ const SKILL_NAME = /^[A-Za-z0-9][A-Za-z0-9._:-]*$/
const ROWS: readonly Row[] = ['skills', 'agents']
const KINDS: readonly Kind[] = ['skills', 'agents', 'phases']
const HAIKU = 'claude-haiku'
const NO_EFFORT = 'claude-haiku-4' // Haiku 4.x takes no effort; 5.x does
const MAX_PATTERN = 200 // chars of a prompt-rule pattern
const MAX_PROMPT_SCAN = 4096 // chars of a prompt a rule is run against
const MAX_CONFIG_BYTES = 65536 // override file size
@@ -1870,9 +1871,9 @@ function standInWord(st: State, v: Verdict): string {
return `${alias} stands in for ${head}`
}
/** Haiku takes no effort: the main line says so when it will run there. */
/** Haiku 4.x takes no effort: the main line says so when it runs there. */
function effortWord(st: State, v: Verdict): string {
if (v.call.model.startsWith(HAIKU)) return '- (haiku takes none)'
if (takesNoEffort(st.cfg, v.call.model)) return '- (haiku 4 takes none)'
const d = standInEffort(st, mainEffort(st, undefined), v)
const word = String(d.effort ?? '-')
return d.standIn ? `${word} (${standInWord(st, v)})` : word
@@ -3678,6 +3679,9 @@ const NAME_CAP = 40 // code points of any name read from outside, in a line
const isHaiku = (cfg: Config, id: string): boolean =>
canonical(cfg, id).startsWith(HAIKU)
const takesNoEffort = (cfg: Config, id: string): boolean =>
canonical(cfg, id).startsWith(NO_EFFORT)
/** The table alias of a model id (a `[1m]` marker kept), else the id. */
function nameOf(cfg: Config, id: string): string {
const bare = canonical(cfg, id)
@@ -3830,7 +3834,7 @@ function handoffOf(
!pinned) {
return undefined
}
const effort = isHaiku(st.cfg, started.model)
const effort = takesNoEffort(st.cfg, started.model)
? undefined
: given ?? route?.effort
return {
@@ -3946,8 +3950,8 @@ async function planStep(
const step: Step = e.agentId === undefined
? await mainPlan($, st, e, signal)
: { plan: agentPlan(st, e) }
// Haiku takes no effort: omit it rather than send a hook-set value.
return step.plan.model.startsWith(HAIKU)
// Haiku 4.x takes no effort: omit it rather than send a hook-set value.
return takesNoEffort(st.cfg, step.plan.model)
? { ...step, plan: { ...step.plan, effort: undefined } }
: step
}
@@ -4235,7 +4239,8 @@ function afterSpawn($: Api, st: State, sp: Spawned): void {
const hand = handoffOf(st, sp, given)
if (hand === undefined) return
// an effort the engine picks is unknown here: the first step tells it
if (hand.effortCause !== 'engine' || isHaiku(st.cfg, hand.to.model)) {
if (hand.effortCause !== 'engine' ||
takesNoEffort(st.cfg, hand.to.model)) {
loop.last = hand.to
}
if (!st.cfg.verbose) return