A pick in the picker is held (PreModelSwitch deny), then the same project / conversation / everywhere question runs; only Everywhere reaches the native write to user settings.json. A model chosen in that dialog bypasses the cold-read caps but waits while held down.
7.7 KiB
7.7 KiB
CONTRACT — picker-scope
- date: 2026-10-25 | flow: feat | branch: feature/model-scope-dialog (in place)
- status: active
REQUEST (verbatim — IMMUTABLE)
"oui commence par la feat sélecteur. j'ai pris un nouveau dossier j'ai mis haiku, et j'ai mis un autre dossier encore et c'etait haiku de base alors que ca devrait etre opus par defaut si on a pas de pin par projet on pin opus. Et dans tout les cas, on utilise les dernieres verison de chaque model. bref corrige tout cela"
- earlier: "je voulais effectivement qu'on puisse dnas le selecteur, dire le model qu'on veut, puis que cela propose si on le veut project scope ou user scope"
- "Donc la, si je fais /model sur un projet, ce dit projet pin le model choisi, et il peut etre different pour chaque projet / conversation et a par defaut opus. On est ok la dessu ? fait le /feat si tu veux"
CLARIFICATIONS
- [gated 2026-10-25] Picker answers = This project / This conversation / Everywhere (same as
/model <name>, BDR-126). - [gated 2026-10-25] Project pin = full id (
claude-fable-5-1,[1m]kept); "latest version" = the router table carries the latest ids (2c39524). - [gated 2026-10-25] A model chosen by hand through the dialog (picker or
/model <name>, scopes This project / This conversation) ALWAYS switches: it bypassesmainUpgrade/mainModelSwitchand the cold-read caps; the breaker (model down) and the context window (fits) stay in force. - [gated 2026-10-25] Picker "Default" (requested_model null) → native, no question.
- Default with no project pin = opus: user settings.json is written only by Everywhere (native). Restored to opus 2026-10-25 after the picker leaks (BLK-036).
- [after the challenge 2026-10-25] Plan r2: hand pick = own early branch in decideMain (breaker on the TARGET checked every turn); slot held → deny + toast (no native leak); a native user switch drops a hand pick; stale-conversation guard. Plan r3 (confirmation FATAL(1) folded inline): unusable hand pick falls through to the existing chain; Everywhere thunk returns {}; clock fixtures named; conv read before the slot check; hand-pick drop skipped while a picker dialog is open; hand pick clears its target's mark; effort-shift l.70 amended. Residuals:
/configModel row still native (sourcecommand), hand pick dropped at/clear, no timeout on a never-settling dialog. - SPIKE PROVEN 2026-10-25 (dev mod picker-spike, user-run in a live session):
on('classic.PreModelSwitch')fires forsource: 'picker'withrequested_model;$.ui.askawaited INSIDE the hook never renders (UI frozen on "Running PreModelSwitch hooks…"); returning{ permissionDecision: 'deny', permissionDecisionReason }at once blocks the switch and the user settings.json write; a continuation launched before return and run after it (await $.clock.sleep(300)then$.ui.ask) renders;$.command.run({ command: 'model', args })from that continuation runs the native switch + user settings write.
ACCEPTANCE CRITERIA
- A
classic.PreModelSwitchhook:source: 'picker', router on,requested_modela string the table knows (knownModel), a surface present, no dialog in flight → returns{ permissionDecision: 'deny', permissionDecisionReason }WITHOUT awaiting any dialog, and holds the single-dialog slot (st.asking) from before the return until the deferred dialog ends. - Passthrough (
next(e), no dialog, no deny) for:sourcecommandorsdk(a first-line source filter, ahead ofensureConfig);requested_modelnull or unknown to the table; router off; no surface.ensureConfigruns before those gates.st.askingalready held → deny + toastanswer the open dialog first, never native. The hook's.catchpasses through with its own warnOnce key. - The deferred dialog (after a short sleep) asks the same question and options as
/model <name>(This project / This conversation / Everywhere, headermodel-router, pin note when the project already pins a model) for the picked model's full id. - Picker → This project: same effects as
/model <name>→ This project (project settings.local.json written with the full id under the same refusal rules, sticky model route, run slot dropped, sticky effort kept); the outcome text reaches the transcript ($.ui.log); user settings.json never written (native never runs). - Picker → This conversation: sticky route only, nothing written, native never runs; outcome logged.
- Picker → Everywhere: prior sticky model/tier dropped, then
$.command.run({ command: 'model', args: <requested_model> })(native switch + user settings write); its PreModelSwitch (source: 'command') and itscommand.run(origin plugin) both pass through, no second dialog. - Picker dialog dismissed or free text → nothing written, nothing routed, native never runs, the NO_SCOPE text logged. A throw inside the deferred dialog (before or after the answer) is logged under the picker's own warn key and always releases
st.asking. If the conversation changed ($.session.id()) between the deny and the answer, nothing is applied and that is logged. - Hand choice always switches: with a sticky model route set by a dialog answer (picker or
/model <name>, This project / This conversation), every main step, in later turns too, moves to that model even when the cold read exceedsupgradeMaxTokens/downgradeMaxTokens,mainUpgrade/mainModelSwitchis off, the current model is down or the session model is outside the table. When the hand-picked model is marked down or does not fit its known window, the hand pick waits (one log) and the EXISTING automatic chain decides as if no model were wanted (a down current model, even when it IS the hand pick, falls back to the next available model; windowReturn still applies), on every turn until the hand-picked model is usable again. A hand pick clears its target's breaker mark at the time of the pick, like a native user switch. A sticky route set by a typed/route model=keeps today's caps. A native user switch (PostModelSwitch source command/picker/sdk) drops a hand pick. - Tests in register.test.ts cover criteria 1-8 as listed in the plan r2 §Tests (deny without awaiting, each passthrough, slot-held deny, the three answers, dismiss, sleep throw, post-answer throw, stale conversation, hand pick down ACROSS a turn boundary, cur down, unranked session, cap bypass up and down,
/route model=still capped, native switch drops the hand pick). - lib/effort-shift.md documents the picker (deny then scope question; Everywhere = native write) and the hand-choice cap bypass; lines ≤ 80 cols. CHECK: a=$(grep -c 'picker' lib/effort-shift.md); b=$(awk 'length($0)>80' lib/effort-shift.md | wc -l); echo "doc=$([ "$a" -ge 1 ] && echo ok)/$b" EXPECT: doc=ok/0 EVIDENCE: MET exit=0 marker-found :: doc=ok/0
- 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
- Full suite green. CHECK: make test 2>&1 | tail -1 EXPECT: all suites green EVIDENCE: MET exit=0 marker-found :: all suites green
- Diff since
48778aftouches only the FILE SCOPE. CHECK: git diff --name-only48778af-- . ':!.claude' | grep -vcE '^(mods/model-router/hooks/register.ts|mods/model-router/hooks/register.test.ts|lib/effort-shift.md)$' | sed 's/^/n=/' EXPECT: n=0 EVIDENCE: MET exit=0 marker-found :: n=0 - No new lint or test suppression.
CHECK: git diff -U0
48778af-- . ':!.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/effort-shift.md (README.md, USAGE.md, CHANGELOG.md: doc-sync step, not the executor)