Repository navigation
fix(codex): preserve short-window observation provenance for routing - #3605
Conversation
…set timestamp An exhausted Codex account kept serving 118 consecutive 502s over 23 minutes while a healthy account sat at 3% (#3425). Two mechanisms reinforce each other: isTerminalShortWindow requires a FUTURE shortResetAt, so a 100% snapshot with no timestamp scores unknown and stays selectable; and 502 is classified transient, so the failures produce no quota signal to correct it. Gate on snapshot FRESHNESS instead of reset presence. StoredAccountQuota.updatedAt already exists, and a 100% window observed seconds ago is a measured refusal while a stale one still falls back to unknown. That preserves #3029 in both directions: the existing assertion that a bare {shortPercent: 100} stays unknown passes no updatedAt and is untouched and still green. 502 stays classified transient - demoting every gateway blip would strand accounts on ordinary upstream noise, so the exclusion comes from the snapshot instead. Closes #3425
Record shortObservedAt only for newly observed shortPercent. Preserve it across credits-only and unrelated window updates; old disk rows without provenance remain unknown. Reject future timestamps. Addresses both independent review findings on the #3425 candidate.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Team Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe change records when finite short-window quota usage was observed. Routing uses observations from the last five minutes to classify 100% usage as terminal when no valid reset timestamp exists. Tests cover metadata preservation and thread routing. ChangesShort-window quota routing
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant QuotaUpdate
participant StoredAccountQuota
participant CodexRouting
participant ThreadSelection
QuotaUpdate->>StoredAccountQuota: Store shortPercent with shortObservedAt
StoredAccountQuota->>CodexRouting: Provide short-window quota metadata
CodexRouting->>CodexRouting: Validate observation freshness
CodexRouting->>ThreadSelection: Exclude freshly exhausted account
Suggested reviewers: ✨ Finishing Touches📝 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 |
|
✅ Deterministic PR hygiene checks passed. |
…idge-jun#3605) Owner-authorized admin squash. Typecheck/static verification completed; no local suite. Final dev Linux CI is the batch gate. Contributor credit is preserved in commits. Container execution, where applicable, remains unverified locally.
Summary
Addresses the missing-reset short-window selection case reported in #3425. A recent terminal short-window reading can exclude an account even without a reset timestamp. Plain 502 remains transient.
The initial candidate used the whole snapshot's updatedAt, which credits-only updates also refresh. Independent inspection caught that regression before merge. This revision records shortObservedAt only when shortPercent is actually observed, preserves its age through unrelated updates and disk serialization, and rejects future timestamps. Old snapshots without provenance remain unknown.
Refs #3425. This targets a demonstrated selection mechanism; it does not claim every cause of the reporter's 502s is proven.
Verification
Checklist
Summary by CodeRabbit