Skip to content

Avoid duplicate Codex quota windows - #882

Merged
1jehuang merged 15 commits into
masterfrom
fix/openai-quota-window-dedup
Aug 11, 2026
Merged

Avoid duplicate Codex quota windows#882
1jehuang merged 15 commits into
masterfrom
fix/openai-quota-window-dedup

Conversation

@1jehuang

Copy link
Copy Markdown
Owner

Summary

  • exclude an already-classified weekly quota from the generic fallback
  • preserve both distinct weekly windows when no hourly window is returned
  • add regression coverage for the new response shape

Verification

  • cargo test -p jcode-base --lib test_classify_openai_limits

Fixes #869


— Jcode agent (automated triage), on behalf of @1jehuang

@1jehuang

Copy link
Copy Markdown
Owner Author

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-apps

greptile-apps Bot commented Aug 10, 2026

Copy link
Copy Markdown

Greptile Summary

The 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 blocked

The 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/5

The 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

T-Rex T-Rex Logs

What T-Rex did

  • T-Rex ran a focused Cargo test that reproduced the reported classification.
  • Artifact upload via Greptile was unavailable, so no severity-bearing proof could be attached and the required source and output evidence could not be uploaded.
  • T-Rex produced a proof for a posted P1 finding, with validation details documented in the corresponding review comment.

T-Rex Ran code and verified through T-Rex

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

@1jehuang

Copy link
Copy Markdown
Owner Author

Ubuntu follow-up: the suite reached 2,170 passing TUI tests and failed only pinned_todos_payload_stays_empty_when_config_off, the independently reproduced cache-isolation defect fixed by #880. The focused tests for this PR pass, as do macOS, Windows, formatting, cross-target, SDK, installer, PowerShell, release, linked-issue, and Greptile checks.


— Jcode agent (automated triage), on behalf of @1jehuang

@1jehuang
1jehuang changed the base branch from master to fix/pinned-todos-config-cache-isolation August 10, 2026 21:46
@1jehuang

Copy link
Copy Markdown
Owner Author

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 master without changing this PR’s issue-specific commit.


— Jcode agent (automated triage), on behalf of @1jehuang

@1jehuang
1jehuang changed the base branch from fix/pinned-todos-config-cache-isolation to master August 10, 2026 21:53
@1jehuang

Copy link
Copy Markdown
Owner Author

Integration validation update: the base is temporarily set to master so the repository’s CI workflow runs against the head containing both this fix and prerequisite #880. After terminal results are captured, the PR will be restored to the stacked base so its review diff remains issue-specific.


— Jcode agent (automated triage), on behalf of @1jehuang

Comment thread crates/jcode-base/src/usage/openai_helpers.rs
Comment on lines +109 to +114
.find(|w| {
seven_day
.as_ref()
.map(|weekly| weekly.name != w.name || weekly.resets_at != w.resets_at)
.unwrap_or(true)
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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 observed Weekly premium (0.5, 2026-01-14) in five_hour and Weekly standard (0.25, 2026-01-07) in seven_day.
  • 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 to five_hour, without excluding weekly items.
  • Fix
    • Exclude limits identified as weekly from the five-hour fallback, or leave five_hour unset when no five-hour limit is present.

T-Rex Ran code and verified through T-Rex

@1jehuang
1jehuang merged commit 30ec7b3 into master Aug 11, 2026
48 of 53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codex quota widget shows two weekly bars when the hourly window is absent

1 participant