Repository navigation
fix(gfx): the white-allocation bound clamp is unsound as an interval - #4197
Conversation
#4188 clamped the bound quotient to full drive and argued that was decision-preserving: a bound outside +/-1.0 either does not bind or means infeasible, so the min and max that follow reach the same verdict either way. That argument does not hold. Clamping turns a lower bound of "w >= 6.64", which no drive can satisfy, into "w >= 1.0" -- and an upper bound of exactly 1.0 then meets it, so the interval collapses to a single point instead of being empty. Worth being precise about the impact, because I first measured it wrong. The drives are `at_zero - level * per_white`, which reproduce the target for *any* level; that is an identity, not a property of the level. So the real feasibility test is the range check on the drives at the end, and it rejects those targets whether or not the bound was clamped. A sweep of 300 000 random targets finds no difference in what the function returns. My first reading of that sweep -- 2 745 flipped verdicts -- was of the interval computation alone, not of the function, and overstated it. Latent, then, not live. Still worth removing: the bound is consumed as an interval, and a caller that uses the interval for anything other than picking one of its two ends inherits the collapse. That is how it surfaced, in work on a two-white allocation that bisects over totals rather than reading off an end. No test accompanies this, deliberately. There is no observable difference to assert, and a test that passes with the clamp restored would be decoration. The reasoning is in the comment instead. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthrough
ChangesWhite allocation precision
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change preserves infeasible white-allocation intervals instead of collapsing them through a full-drive clamp, while retaining the existing final output range check. No current merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Small, and the interesting part is the measurement I got wrong first.
#4188 clamped the bound quotient in
divideWhiteQ16to full drive, with this reasoning: a bound outside ±1.0 either doesn't bind or means infeasible, so themin/maxthat follow reach the same verdict either way — "decision-preserving rather than a fudge".That argument doesn't hold. Clamping turns a lower bound of
w >= 6.64— which no drive can satisfy, so the target is out of reach — intow >= 1.0, which an upper bound of exactly 1.0 then meets. The interval collapses to a single point instead of being empty.Being precise about the impact
I first measured this as 2,745 verdict flips in 300,000 random targets and was about to ship it as a live bug with a regression test. Then the mutation test didn't fail, which was the useful signal.
The drives are
at_zero − level · per_white, which reproduce the target for any level — that's an identity, not a property of the level. So the real feasibility test is the range check on the drives at the end, and it rejects those targets whether or not the bound was clamped. Re-measured through the actual API: no difference in what the function returns across the same sweep.So my figure described the interval computation in isolation, not the function. Corrected in the comment.
Why fix it anyway
It's latent, not harmless. The bound is consumed as an interval, and any caller that uses the interval for something other than reading off one of its two ends inherits the collapse. That's exactly how it surfaced — in work on a two-white (RGBWW) allocation that bisects over totals, where the clamped bound reported a bright target reachable and then produced a red drive of −0.21.
No test
Deliberately. There's no observable difference to assert, and a test that passes with the clamp restored would be decoration. The reasoning lives in the comment.
The RGBWW allocation that found this is not in this PR. Its design needs more work than I could validate honestly — details in the issue I'm filing alongside.
🤖 Generated with Claude Code
https://claude.ai/code/session_01MLhWkMfzLjrnLTDMBE6Fj9
Summary by CodeRabbit