Avoid duplicate Codex quota windows - #882
Conversation
|
CI follow-up: the formatting gate now passes. The remaining Quality Guardrails failure is the repository-wide code-size baseline, which reports the same pre-existing growth across unrelated files on all three branches; this PR does not update that baseline. Platform build/test jobs are still queued. — Jcode agent (automated triage), on behalf of @1jehuang |
Greptile SummaryThe quota classifier can show a weekly Codex limit in the five-hour slot when two weekly limits are returned without an explicit five-hour limit. This gives users an incorrect hourly utilization and reset time. T-Rex validation blockedThe focused Cargo test executed successfully and reproduced the behavior, but the Greptile artifact-upload tool was unavailable, so the required uploaded evidence references could not be attached. Confidence Score: 4/5The change is not safe to merge until weekly quota windows are excluded from the five-hour fallback. One non-security correctness failure remains: the fallback can classify a second weekly limit as the five-hour quota. Files Needing Attention: crates/jcode-base/src/usage/openai_helpers.rs
What T-Rex did
Prompt To Fix All With AI### Issue 1
crates/jcode-base/src/usage/openai_helpers.rs:109-114
**Weekly window fills hourly slot**
The fallback excludes only the selected seven-day item rather than every weekly-named limit. When `Weekly standard` and `Weekly premium` are returned without a five-hour limit, the first becomes `seven_day` and the second is selected as `five_hour`. Exclude all weekly limits from the five-hour fallback so clients do not display weekly utilization and reset data as an hourly quota.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (3): Last reviewed commit: "chore(release): prepare v0.75.2" | Re-trigger Greptile |
|
Ubuntu follow-up: the suite reached 2,170 passing TUI tests and failed only — Jcode agent (automated triage), on behalf of @1jehuang |
|
CI dependency update: this PR is now stacked on #880 so Ubuntu validates this change with the independently verified pinned-todos isolation fix present. After #880 merges, the base can return to — Jcode agent (automated triage), on behalf of @1jehuang |
…i-quota-window-dedup
|
Integration validation update: the base is temporarily set to — Jcode agent (automated triage), on behalf of @1jehuang |
| .find(|w| { | ||
| seven_day | ||
| .as_ref() | ||
| .map(|weekly| weekly.name != w.name || weekly.resets_at != w.resets_at) | ||
| .unwrap_or(true) | ||
| }) |
There was a problem hiding this comment.
Weekly window fills hourly slot
The fallback excludes only the selected seven-day item rather than every weekly-named limit. When Weekly standard and Weekly premium are returned without a five-hour limit, the first becomes seven_day and the second is selected as five_hour. Exclude all weekly limits from the five-hour fallback so clients do not display weekly utilization and reset data as an hourly quota.
Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/jcode-base/src/usage/openai_helpers.rs
Line: 109-114
Comment:
**Weekly window fills hourly slot**
The fallback excludes only the selected seven-day item rather than every weekly-named limit. When `Weekly standard` and `Weekly premium` are returned without a five-hour limit, the first becomes `seven_day` and the second is selected as `five_hour`. Exclude all weekly limits from the five-hour fallback so clients do not display weekly utilization and reset data as an hourly quota.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| @@ -104,7 +104,15 @@ pub(super) fn classify_openai_limits(limits: &[UsageLimit]) -> OpenAIUsageData { | |||
| } | |||
|
|
|||
| if five_hour.is_none() { | |||
There was a problem hiding this comment.
Weekly fallback becomes a five-hour limit
- Bug
- With two differently named weekly limits and no five-hour limit, the fallback selects the second weekly limit as
five_hour; the test observedWeekly premium(0.5, 2026-01-14) infive_hourandWeekly standard(0.25, 2026-01-07) inseven_day.
- With two differently named weekly limits and no five-hour limit, the fallback selects the second weekly limit as
- Cause
- After assigning the first weekly item to
seven_day, the fallback searches generic non-spark items for one with different name or reset timestamp and assigns it tofive_hour, without excluding weekly items.
- After assigning the first weekly item to
- Fix
- Exclude limits identified as weekly from the five-hour fallback, or leave five_hour unset when no five-hour limit is present.
Summary
Verification
cargo test -p jcode-base --lib test_classify_openai_limitsFixes #869
— Jcode agent (automated triage), on behalf of @1jehuang