feat(codex): classify reset-eligible quota rejection - #866
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)
📝 WalkthroughWalkthroughCodex pre-stream responses now receive strict structured rejection classification. The classifier fails closed for invalid, unavailable, oversized, consumed, or cancelled bodies. The existing 402/429 pool-account retry predicate is now exported. Tests cover schemas, status categories, malformed bodies, cancellation, and response preservation. ChangesCodex quota retry handling
Estimated code review effort: 3 (Moderate) | ~25 minutes Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant CodexResponse
participant QuotaClassifier
participant RejectionResult
CodexResponse->>QuotaClassifier: status and response body
QuotaClassifier->>RejectionResult: classified rejection and eligibility
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Pre-merge review result: not merge-ready yet. CI is green and the bounded body handling, privacy posture, and Bun compatibility all check out — but the classifier does not hold the fail-closed boundary the PR description promises:
Please: exact-match allowlisted values within explicitly supported response schemas, reject on conflict, and add the negative tests. This is the semantic foundation for the #657 recovery family, so it is worth getting airtight — happy to re-review quickly once updated. |
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/server/responses/core.ts`:
- Around line 250-255: Update shouldRetryCodexPoolAccountQuota to be synchronous
and return true only when response.status is 402 or 429, avoiding
classifyCodexPreStreamRejection and any response-body read. Remove the
now-unused classifier import while preserving the existing boolean retry
contract.
In `@tests/codex-quota-rejection.test.ts`:
- Around line 12-13: Extend the test suite in “Codex pre-stream quota rejection
classification” with handleResponses integration coverage for Codex pool
retries. Exercise the reset-eligible 429 and 402 paths in handleResponses,
asserting each retries on an alternate account, and add a non-retryable-status
case asserting the original status and response body are preserved.
🪄 Autofix (Beta)
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: 3d172e90-de04-4759-a458-eb24d70ac61a
📒 Files selected for processing (3)
src/codex/quota-rejection.tssrc/server/responses/core.tstests/codex-quota-rejection.test.ts
aef44bd to
cfe9bd0
Compare
|
All previously requested changes have been applied to the current head (fe44ece), all checks are green, and no review threads remain. When convenient, could you please re-review this revision? Thank you. |
[shipping-github] Verdict: changes-requestedPR: Semantic propagation
Linked: refs UsefulnessUseful and correctly scoped groundwork: this is the maintainer-requested first slice of #657 (semantic classification only, no credit spending, no waiting, no policy), and the classifier is deliberately strict - exact structured codes on 429/402 only, fail-closed on ambiguity, malformed, oversized, consumed, or cancelled bodies. The earlier maintainer findings (case/whitespace normalization, root/nested ambiguity, missing negatives) are all addressed on this head. Bugs / correctness
Security
Spec / standards
Reviews
Base / CI
GateShip gate: Bottom lineThe code is sound, well-tested, and security-clean: the classifier is fail-closed, #584 behavior is provably unchanged, and CI is green on the head. Three items stand between this PR and merge-ready: (1) @lidge-jun re-review to clear the gate (the author already asked), (2) a one-bullet PR-description correction so the summary matches the unwired classifier on the head, (3) optional but cheap - classifier-level negatives for oversized/truncated/consumed bodies, plus an update from |
Summary
usage_limit_exceededandinsufficient_quotacodes on HTTP 429/402 as reset-credit eligibleSafety boundary
Explicit non-goals
This PR deliberately does not implement:
Those remain separate follow-up slices under the maintainer direction in #657.
Compatibility
The existing #584 behavior is preserved: pre-stream 429/402 still permits one bounded alternate-account attempt even when the rejection is generic or unverified. This PR only establishes the semantic boundary future irreversible recovery must require.
Verification
1.4.0-canary.1: 69 focused classifier and server-auth tests passed1.3.14: the same 69 tests passedRefs #657
Summary by CodeRabbit