fix: address code review feedback for maxUtilizationPercent#2
Merged
gwyntel-git merged 1 commit intomainfrom Apr 19, 2026
Merged
Conversation
Based on subagent code review, fixes:
1. CRITICAL: Multi-checker cooldown clearing bug — a lenient checker
(threshold=99) could clear a cooldown set by a strict checker
(threshold=30). Fixed by only allowing the strictest checker for
a provider to clear the provider-wide cooldown. Others are blocked.
2. HIGH: min(0) → min(1) in Zod schema. maxUtilizationPercent=0 was
a footgun (always triggers cooldown). Use enabled:false instead.
3. HIGH: Refactor exhaustionThreshold from unsafe options cast to a
proper getter on QuotaChecker base class. SyntheticQuotaChecker
overrides it via getOption('maxUtilizationPercent', 99). Scheduler
reads checker.exhaustionThreshold — type-safe, no casts.
4. MEDIUM: Update stale '≥99%' comment in cooldown-manager.ts.
5. MEDIUM: Add 3 new test cases:
- Cooldown clearing when utilization drops below threshold
- Multiple windows where only one exceeds threshold
- Lenient checker cannot clear strict checker's cooldown
gwyntel-git
added a commit
that referenced
this pull request
Apr 19, 2026
Based on subagent code review, fixes:
1. CRITICAL: Multi-checker cooldown clearing bug — a lenient checker
(threshold=99) could clear a cooldown set by a strict checker
(threshold=30). Fixed by only allowing the strictest checker for
a provider to clear the provider-wide cooldown. Others are blocked.
2. HIGH: min(0) → min(1) in Zod schema. maxUtilizationPercent=0 was
a footgun (always triggers cooldown). Use enabled:false instead.
3. HIGH: Refactor exhaustionThreshold from unsafe options cast to a
proper getter on QuotaChecker base class. SyntheticQuotaChecker
overrides it via getOption('maxUtilizationPercent', 99). Scheduler
reads checker.exhaustionThreshold — type-safe, no casts.
4. MEDIUM: Update stale '≥99%' comment in cooldown-manager.ts.
5. MEDIUM: Add 3 new test cases:
- Cooldown clearing when utilization drops below threshold
- Multiple windows where only one exceeds threshold
- Lenient checker cannot clear strict checker's cooldown
Co-authored-by: Gwyn <gwyn@gwyn.tel>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses code review feedback from PR #1 for the
maxUtilizationPercentfeature.Fixes
CRITICAL: Multi-checker cooldown clearing bug — A lenient checker (threshold=99) could clear a cooldown set by a strict checker (threshold=30). Fixed by only allowing the strictest checker for a provider to clear the provider-wide cooldown. Others are blocked with a debug log.
HIGH:
min(0)→min(1)in Zod schema —maxUtilizationPercent=0was a footgun (always triggers permanent cooldown). Useenabled: falseto fully disable a provider instead.HIGH: Refactor
exhaustionThresholdfrom unsafe cast to getter — AddedexhaustionThresholdgetter toQuotaCheckerbase class (default 99).SyntheticQuotaCheckeroverrides it viagetOption('maxUtilizationPercent', 99). Scheduler readschecker.exhaustionThreshold— type-safe, noas number | undefinedcasts.MEDIUM: Update stale
≥99%comment incooldown-manager.tsto reflect configurable threshold.MEDIUM: Add 3 new test cases:
Test Results