Fix Codex quota reading under the app's minimal PATH - #65
Merged
Merged
Conversation
Three defects made Codex report a stale 4% and no 5-hour window: - A .app launched from Finder inherits PATH=/usr/bin:/bin:/usr/sbin:/sbin, so subprocess(["codex", ...]) raised FileNotFoundError and the live app-server fetch never ran. Resolve the CLI through the known install prefixes and pass a merged PATH to the child so a node-shebang wrapper finds its interpreter. - codex reports per-limit-id groups; the account group can carry only a weekly window while a per-model group holds the live 5-hour one. Fold every group together, worst reading per window. - A failed fetch fell back to the cache with no age ceiling, so a permanently broken fetch path served the last good percentage forever. Cap the fallback at six hours and let the UI show 'no data'. Regression tests cover all three (19 of the new assertions fail on the old reader).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Kaji showed Codex at ~4% while ChatGPT reported 9% left (≈91% used), and the 5-hour window showed "no data".
Root causes
.applaunched from Finder inheritsPATH=/usr/bin:/bin:/usr/sbin:/sbin, sosubprocess(["codex", ...])raisedFileNotFoundError. Every reading silently came from the stale session-file scan. Same bug applied tommx.account/rateLimits/readreturnsrateLimitsByLimitId: the account-widecodexgroup (weekly only on this plan) plus e.g.codex_bengalfox(GPT-5.3-Codex-Spark) carrying the live 5-hour window. Only the flatrateLimitsobject was read.Fixes
Verification
swift testcould not run locally (no Xcode toolchain, only Command Line Tools); CI covers it.