mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-24 06:06:02 +09:00
#2250 — model-router selectModel() applied an "escalate one tier up" step after Thompson sampling. The `uncertainty` formula (1 - scoreSpread - confidence*0.5) is structurally ~0.6-0.7 for trivial routes, and the `> maxUncertainty=0.15` gate fired on ~every low-complexity task, promoting sonnet→opus and haiku→sonnet even when the bandit had a confidently-suppressed opus prior. Result: opus selected ~40% on trivial tasks; haiku never selected (the confirming signature). Fix: skip escalation when EITHER (a) target mean is meaningfully worse than selected mean by 0.10+, OR (b) selected has confident+decent posterior (α+β≥5 AND mean≥0.45). Cold-start Beta(1,1) priors fail both checks, so unlearned routers preserve original conservative behavior. Plus CLAUDE_FLOW_MAX_UNCERTAINTY env override as reporter requested. #2251 — WorkerDaemon constructor kicked off initHeadlessExecutor() fire-and-forget. On-demand `daemon trigger -w <worker>` constructs a daemon and immediately calls triggerWorker(), racing the init — headlessAvailable still false → falls through to local stub in 2ms. Scheduled fires hit a long-running daemon and never race. Fix: capture init into private headlessInitPromise field, await it at top of triggerWorker(). 3 lines. CI regression guards added at __tests__/issue-2250-2251-regression.test.ts: - #2250: load suppressed-opus prior (α=3.8, β=17.2), route 50 trivial tasks, assert opusRate<0.20 AND haiku>0 - #2250: cold-start preservation test - #2250: env override test - #2251: deferred-promise harness proves executeWorker cannot fire until headlessInitPromise resolves All 12 tests pass (4 new + 8 existing router-bandit). TypeScript clean. Co-Authored-By: RuFlo <ruv@ruv.net>