-
Notifications
You must be signed in to change notification settings - Fork 860
fix(codex): carry the K12 short-window quota through cache and routing #2062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7979903
1f4e047
286cbd2
c49fed6
879dbb0
0013b23
e2d4621
f60a045
19986ca
110ef57
e97fb26
0bb95ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -122,6 +122,16 @@ describe("codex routing", () => { | |||||||||||||||||||||||||||||||||||||||
| expect(computeCodexUsageScore({ weeklyPercent: 15 })).toBe(15); | ||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| test("usage score counts the burst window on every plan (#2047)", () => { | ||||||||||||||||||||||||||||||||||||||||
| // A long window at 0-1% with the burst window saturated must not score idle. | ||||||||||||||||||||||||||||||||||||||||
| expect(computeCodexUsageScore({ weeklyPercent: 1, shortPercent: 100 })).toBe(100); | ||||||||||||||||||||||||||||||||||||||||
| expect(computeCodexUsageScore({ monthlyPercent: 0, shortPercent: 87 }, "k12")).toBe(87); | ||||||||||||||||||||||||||||||||||||||||
| expect(computeCodexUsageScore({ weeklyPercent: 15, shortPercent: 9 })).toBe(15); | ||||||||||||||||||||||||||||||||||||||||
| // Missing burst data keeps the pre-existing behavior (long windows only). | ||||||||||||||||||||||||||||||||||||||||
| expect(computeCodexUsageScore({ weeklyPercent: 15 })).toBe(15); | ||||||||||||||||||||||||||||||||||||||||
| expect(computeCodexUsageScore(null)).toBe(CODEX_UNKNOWN_USAGE_SCORE); | ||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+125
to
+133
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Cover the thirty-day burst-only fallback. This test does not execute the new Go/Free branch in Proposed test expect(computeCodexUsageScore({ monthlyPercent: 0, shortPercent: 87 }, "k12")).toBe(87);
+ expect(computeCodexUsageScore({ shortPercent: 87 }, "go")).toBe(87);
expect(computeCodexUsageScore({ weeklyPercent: 15, shortPercent: 9 })).toBe(15);As per path instructions, “A behavior change in src/ should come with a focused regression test near the existing tests for that subsystem.” 📝 Committable suggestion
Suggested change
🤖 Prompt for AI AgentsSource: Path instructions |
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| test("exact-account failures record health without rotating the active Pool account", () => { | ||||||||||||||||||||||||||||||||||||||||
| const transient = makeConfig({ upstreamFailoverThreshold: 1, activeCodexAccountId: "a" }); | ||||||||||||||||||||||||||||||||||||||||
| const transientThread = "fixed-transient-thread"; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Count short-window fields when detecting credits-only updates.
Lines 249-251 preserve the existing burst values because
creditsOnlyusessnapshotHasUsage, butsnapshotHasUsageignoresshortPercent,shortResetAt, andshortWindowSeconds. A parsed snapshot that contains burst data andresetCredits, but no long-window data, enters this branch. The cache then drops the incoming burst values or retains stale values.Include short-window fields in the usage check. Add a regression case with a short-only snapshot and
resetCredits.Proposed fix
function snapshotHasUsage(quota: Omit<StoredAccountQuota, "updatedAt">): boolean { - return snapshotHasWeekly(quota) || snapshotHasMonthly(quota); + return snapshotHasWeekly(quota) + || snapshotHasMonthly(quota) + || quota.shortPercent !== undefined + || quota.shortResetAt !== undefined + || quota.shortWindowSeconds !== undefined; }🤖 Prompt for AI Agents