Skip to content

fix(cluster): apply AlphaFloor in dial calibration sweep#781

Open
rohith500 wants to merge 2 commits into
workweave:mainfrom
rohith500:fix/dial-calibration-alpha-floor
Open

fix(cluster): apply AlphaFloor in dial calibration sweep#781
rohith500 wants to merge 2 commits into
workweave:mainfrom
rohith500:fix/dial-calibration-alpha-floor

Conversation

@rohith500

@rohith500 rohith500 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Bug

computeDialCalibration records QualityBias mix-change breakpoints by sweeping unfloored uniform alpha, but live routing applies alpha[i] = max(dialToAlpha(t), floor[i]) via applyDialAlpha.

On floored bundles (v0.72–v0.74, latest = v0.73), roughly the first half of the dial produces an identical model mix / projected cost — the same “50% looks like 20%” failure #479 fixed, reintroduced when #501/#515 added floors without retargeting the calibration sweep.

CI did not catch it: TestRoutingDistribution_NoDeadZone and mid-vs-low cost guards pin on v0.67, which ships no alpha_floor.

Reproduction (v0.73, 21-point RoutingDistribution)

Metric Before (unfloored calibration)
Breakpoints 30 (9 with α ∈ (0, 0.30))
Cost at dial 0 / 0.2 / 0.5 0.00187 / 0.00187 / 0.00187
Longest identical-mix streak 10 steps

Fix

Extract shared applyAlphaFloor (alpha[i] = max(raw, floor[i]); floor == nil disables) and call it from both:

  • computeDialCalibration — sweep raw uniform alpha through the floor before recording mix breakpoints
  • applyDialAlpha — request-time / distribution path (same policy as before, now shared)

After the fix on v0.73:

Metric After
Breakpoints 14 (none below min floor)
Cost at dial 0 / 0.2 / 0.5 0.00187 / 0.00206 / 0.00269
Longest identical-mix streak 1 step

Bundles without alpha_floor (v0.67) keep the previous calibration behavior.

Tests

  • TestRoutingDistribution_NoDeadZone_FlooredBundle — v0.73: no long consecutive identical-mix run
  • TestRoutingDistribution_MidDialIsPricierThanLowDial_FlooredBundle — v0.73: cost(0.5) ≥ 1.2× cost(0.2) (floored span is tighter than v0.67’s 1.5×)
  • TestComputeDialCalibration_NoBreakpointsBelowMinFloor — no interior breakpoint below min(AlphaFloor)
  • TestComputeDialCalibration_HeterogeneousFloorSynthetic — different per-cluster floors; no breakpoint in (0, minFloor)
  • TestApplyAlphaFloor_NilAndHeterogeneous — nil floor + per-slot floor behavior
  • Existing v0.67 NoDeadZone / mid-vs-low guards unchanged (backward-compat path)

Full package: go test ./internal/router/cluster/ -count=1 green.

Closes #779

computeDialCalibration recorded mix breakpoints on unfloored alpha while
live routing floors via applyDialAlpha, wasting dial travel on unreachable
crossovers and flattening QualityBias on floored bundles (v0.72+).

Signed-off-by: N Rohith Reddy <rohithreddy2202@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@greptile-apps

greptile-apps Bot commented Jul 17, 2026

Copy link
Copy Markdown

PR author is not in the allowed authors list.

@rohith500 rohith500 closed this Jul 17, 2026
@rohith500 rohith500 reopened this Jul 17, 2026
Keep workweave#779 why-comments to ≤2 lines so the advisory comment-length check stays quiet.

Signed-off-by: N Rohith Reddy <rohithreddy2202@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

Thank you so much for this contribution, @rohith500 — the fix itself is exactly right, and the floored-bundle regression coverage is genuinely thorough. 🙏

We've rewritten it to match the repo's internal conventions in #788 (your logic and tests are preserved verbatim, with credit to you). The only change: AGENTS.md's comment rule ("Concise comments, sparingly … never reference current task/PR/caller") — comments like // #779: unfloored calibration left a long consecutive dead zone and pre-fix narrative (pre-fix cost(0.5)==cost(0.2)) reference the issue/PR and the old behavior, which we keep out of the code (that context belongs in the PR description instead). In #788 those comments now describe the code's general behavior only.

Please don't take this as a knock on your work — these conventions are internal, evolving, and honestly not obvious from the outside. The engineering here was great: shared applyAlphaFloor helper, non-tautological floored-bundle guards, heterogeneous-floor synthetic — all spot on. Hope to see more PRs from you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(cluster): computeDialCalibration ignores AlphaFloor — QualityBias dial dead zone on floored bundles

1 participant