Repository navigation
fix(codex): retire the main account's carried monthly window when WHAM shows none - #8698
Conversation
|
✅ Deterministic PR hygiene checks passed. |
✅ READY
Review readiness checklist
✅ 4/4 boxes ticked. This pull request has been marked Ready for Review. Hygiene✅ Deterministic PR hygiene checks passed. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Maintainer integration (merge manager, owner backlog decision B: contributor bug fixes are reviewed and merged when correct).
|
Summary
The main account kept a stored
monthlyPercent: 100(withmonthlyIsPrimaryWindow: true) forever once a later WHAM read stopped reporting any monthly window. #8120 retired that carried tuple for pool accounts only;parseMainPolicyUsageQuotanever derivedmonthlyWindowAbsent, somergeAccountQuotacarried the tuple into both the main display cache and the identity-boundmainPolicyQuota.isCodexQuotaExhausted()then refused every main request locally with the usage-limit message.This takes Option A from the issue and applies the #8120 proof to the main path:
poolWhamPolicyObservationinto a sharedwithWhamMonthlyWindowAbsence. It marks absence only when the topology already proves short-window absence, no window declares a monthly duration and no tertiary window is present. It never marks absence on an explicitallowed: false, an invalid percentage or an unparseable reading (additional windows included, via the extractedhasMalformedWhamReading).parseMainPolicyUsageQuotaapplies it, so a complete main read retires the tuple in bothquotas.__main__andmainPolicyQuota. Retirement still goes through the existing main gate insetAccountQuotaFromParsed: a live, identity-current main writer. A missing or stale writer, partial WHAM and response headers keep the tuple. The marker is consumed by the merge and never persisted.structure/providers/openai-tiers.mdnow states the main-account rule next to the [Bug]: prolite account withsecondary_window: nullis cached asmonthlyPercent: 100and is never selected #8067 pool rule.The refusal wording from Option B is not changed. With the phantom tuple retired, that refusal no longer fires for this case.
Covering the points from the maintainer follow-up in
tests/codex-integration/pool-monthly-window-retirement.test.ts:Closes #8596
Verification
On dev
8f6d9b64e, Linux, Bun 1.4.4:bun test --timeout 30000 tests/codex-integration/pool-monthly-window-retirement.test.ts: 12 pass, 0 fail. Withsrc/codex/quota.tsfrom dev, the 4 new retirement, persistence, save and stale-writer cases fail.bun run typecheck: no type errors.bun run structure:check: passed.bun run privacy:scan: passed.OCX_TEST_MAIN_TIMEOUT_MS=3600000 bun run test --parallel=3 --timeout 30000over every test file that importssrc/codex/quota(101 files): 3742 pass, 3 skip, 0 fail.Full-suite exception: the shared machine this ran on was heavily loaded (load average 15 to 59 on 16 CPUs). Two
bun run testruns hit the one-hour cap; the next two finished with 24 and 17 failures; twobun run test:changedruns finished with 3 and 8 failures. Every one of those was a timeout or timing assertion outside the quota code, the set differed each run, and each failing file passed when rerun alone on this branch. Rerun alone:server-auth,server-key-failover-e2e,server-xai-chat-reasoning-streaming,model-costs-pricing-cache,sse-untyped-credential-mask,request-history-index, themessages-overflow-*files,claude-messages-endpoint,claude-config-root-stale-updates,cli-message-mcp,cli-codex-cli-update,command-code-project-context,codex-composed-acceptance,update-orchestrated-pnpm-global-store-entryand thetest-runnerfixtures.tests/clients/link-supervisor.test.tsfails here on unmodified dev too (its fixed/tmp/opencodex-link-supervisor-testdirectory belongs to another user on this machine) and was excluded. The full suite is left to CI.Checklist
Screenshots
The issue's sequence through the real quota code: a stored monthly-primary 100% reading for main, then the issue's WHAM payload (Plus, weekly 1%,
secondary_window: null).Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
Required local validation passed; commands, results, and any full-suite exception are documented.
I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.
Summary by CodeRabbit