feat(routing): use pool-aware quota evidence for policy profiles - #1282
Conversation
|
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 (2)
📝 WalkthroughWalkthroughThe quota module adds Codex pool aggregation with plan-specific windows and unknown-state handling. OpenAI candidate evaluation uses pooled evidence for multi-account plans. Tests cover headroom, exhaustion, reset timestamps, and partial unknown data. ChangesCodex pool quota routing
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant CandidateEvaluation
participant CachedAccounts
participant codexPoolQuotaEvidence
CandidateEvaluation->>CachedAccounts: Read cached Codex accounts
CachedAccounts-->>CandidateEvaluation: Return account pool
CandidateEvaluation->>codexPoolQuotaEvidence: Aggregate plan-specific quota
codexPoolQuotaEvidence-->>CandidateEvaluation: Return RouteQuotaEvidence
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/routing/quota.ts`:
- Around line 40-66: Update codexAccountQuotaEvidence so it returns { known:
false } when maxPercent is undefined, before reporting exhaustion or usable
headroom; retain the existing evidence calculation when an applicable percentage
exists. Add a regression test covering a pool with one exhausted account and one
cached account lacking both weeklyPercent and monthlyPercent, ensuring the
latter remains unknown and cannot be treated as usable capacity.
- Around line 121-126: Replace the listAccountQuotas() membership used by the
input.codexAccountPlan evidence path with active CodexPoolQuotaAccount[] from
the shared config/account-pool layer. Populate every active account with its
plan and required current selector state, including deletion, credentials,
pause/avoid, reauth, credential generation, and probe lease data, before calling
codexPoolQuotaEvidence. Preserve the pool-size guard and add a regression
proving a removed high-headroom cached account cannot make the pool usable.
🪄 Autofix
❌ Autofix failed (check again to retry)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 74f567be-1f17-46b9-9901-563feeb58bfa
📒 Files selected for processing (2)
src/routing/quota.tstests/routing-policy-pool-quota.test.ts
|
The branch was updated while autofix was in progress. Please try again. |
|
Review follow-up: the credits-only finding was valid and is fixed in |
Summary
Use Codex pool capacity when scoring an OpenAI policy candidate instead of treating the currently active account as the whole provider.
Expected semantics:
TDD state
The first commit intentionally adds failing tests for the missing pool aggregation helper. Implementation follows after the red state is confirmed.
Scope
devBase inspected:
devat3ad5bb6bd3f76f6879d84b78ea39edd3e01ec296.Summary by CodeRabbit