fix(codex): retain short-window quota end to end - #2056
Conversation
|
✅ Deterministic PR hygiene checks passed. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan includes up to 10 reviews per rolling hour; 7 remain after this review. 📝 WalkthroughWalkthroughShort-window quota data is now recognized and preserved across account quota updates, cache refreshes, and DTO serialization. Routing scores include short-window usage, and tests cover zero-valued snapshots, partial updates, K12 refreshes, and Go-plan selection. ChangesShort-window quota handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The PR preserves short-window quota data through cache, API, and routing paths so plan-aware routing can use current usage. No actionable merge-blocking risk remains after normal checks and review. Sequence Diagram(s)sequenceDiagram
participant K12Upstream
participant AccountQuotaUpdate
participant QuotaCache
participant RefreshDTO
participant RoutingScore
K12Upstream->>AccountQuotaUpdate: short-window quota fields
AccountQuotaUpdate->>QuotaCache: preserve shortPercent, shortResetAt, shortWindowSeconds
QuotaCache->>RefreshDTO: serialize retained quota fields
QuotaCache->>RoutingScore: provide weekly, monthly, and short percentages
RoutingScore-->>RoutingScore: select maximum applicable usage
Suggested reviewers: 🚥 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 |
|
Independent review before merge found one routing-behavior blocker, so this PR is held as needs-work rather than merged: Fail-open in Suggested fix: keep the short window as an additional pressure signal only when a governing long window is present — include Everything else looked good: detail preservation across cache/API/dashboard, regression coverage, no scope creep, CI green on the exact head. Happy to merge once the routing guard lands. |
|
Update on the hold, with new information: #2062 fixes the same issue (#2047) and carries the same blocker, so this is a shared root cause rather than a reason to prefer one PR. The blocker on both is the short-only fail-open in Where the two differ:
So neither supersedes the other. What either needs to land: include If you two want to combine, this PR's preservation handling plus a gated scorer is the shortest path. |
리뷰 · 우선순위 64 / 80draft 가 아니고 #2047 를 parse → cache → accounts API/DTO → routing 까지 닫으려 합니다. #2062 와 같은 이슈를 고치지만, 이 쪽이
해결방안: 이 댓글은 grok-bot이 작성했습니다 |
parseUsageQuota filled shortPercent and setAccountQuotaFromParsed dropped it, so the 5-hour burst window never reached the cache, the accounts DTO, the dashboard, or routing. A saturated short window was invisible to account selection. Carries @Ingwannu's #2056: shortPercent joins hasKnownQuotaValue, a new snapshotHasShort keeps a short-only snapshot from reading as empty, partial weekly/monthly snapshots no longer clobber a known short window, and updateAccountQuota carries the tuple. Also fixes the blocker raised in review on both #2056 and #2062: the scorer took Math.max over every finite window, so a snapshot carrying only shortPercent: 0 scored a flat 0 and made an account whose long windows were never observed look like the emptiest in the pool - pickLowestUsageAmong would then send every request to it. The burst window now refines a known long-window position instead of standing in for one, and returns CODEX_UNKNOWN_USAGE_SCORE until a governing window is actually observed. The ported test asserted the old behavior directly (computeCodexUsageScore({ shortPercent: 0 }) === 0); it is replaced by a case that pins the corrected contract in both directions. Closes #2047
|
Thanks for this, @Ingwannu — closing as superseded by #2141, which carries your implementation: One thing was added on top: the scorer blocker raised in review on this PR. That required replacing one assertion your branch inherited ( |
Summary
shortPercent: 0distinct from missing quotaFixes #2047.
Verification
taskset -c 0,1 bun test tests/codex-routing.test.ts tests/codex-auth-api.test.ts tests/codex-cooldown-recovery.test.ts tests/routing-policy-pool-quota.test.ts tests/rate-limit-reset-credits.test.ts— 376 passedtaskset -c 0,1 bun run typechecktaskset -c 0,1 bun run privacy:scanChecklist
Summary by CodeRabbit