fix(codex): keep Spark five-hour quota model-scoped - #4018
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review Please review the Spark-specific five-hour quota parsing and visibility regression on the current head. Focus on keeping account-level five-hour windows distinct from the model-scoped Spark five-hour window. |
|
⏳ DRAFT
What to do
Review readiness checklist
1/4 boxes ticked. This pull request was already a draft. Its draft status will be preserved after every issue above is resolved. Hygiene
|
|
The hygiene check flagged |
🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '=== PR metadata ==='
gh pr view 4018 --repo lidge-jun/opencodex --json baseRefName,headRefName,files,title
echo '=== Changed files ==='
git diff --name-only HEAD^ HEAD
echo '=== Diff ==='
git diff --no-ext-diff --unified=80 HEAD^ HEAD
echo '=== Candidate source/test outlines ==='
fd -t f . | rg -i '(codex|quota|spark|locale|i18n)' | head -200 | while IFS= read -r file; do
echo "--- $file"
ast-grep outline "$file" --items all 2>/dev/null || true
doneLength of output: 169161 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '=== Pull request files ==='
gh pr view 4018 --repo lidge-jun/opencodex --json files --jq '.files[] | "\(.path)\t+\(.additions)\t-\(.deletions)"'
echo '=== Pull request diff ==='
gh pr diff 4018 --repo lidge-jun/opencodex --patch -- \
| sed -n '1,1800p'
echo '=== Spark parser and projection definitions/call sites ==='
rg -n -C 12 \
'CODEX_SPARK_WINDOW_LABELS|withSparkVisibility|GPT-5\.3-Codex-Spark|custom.*[Qq]uota|five.hour|fiveHour|five_hour' \
src tests \
-g '*.ts' \
-g '*.json' \
| head -2200
echo '=== Relevant file outlines ==='
for file in \
src/codex/auth.ts \
src/codex/quota.ts \
tests/codex-integration/codex-routing.test.ts \
tests/codex-integration/codex-spark-visibility.test.ts \
tests/gui/quota-bars-rows.test.ts
do
if [ -f "$file" ]; then
echo "--- $file"
ast-grep outline "$file" --items all | sed -n '1,500p'
fi
doneLength of output: 217090 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '=== Quota parser helpers and implementation ==='
nl -ba src/codex/quota.ts | sed -n '120,245p;680,850p'
echo '=== Quota data contracts ==='
nl -ba src/codex/quota-types.ts | sed -n '1,240p'
echo '=== Auth API Spark filter and all use sites ==='
nl -ba src/codex/auth-api.ts | sed -n '225,310p'
rg -n -C 8 '\bquotaForPlan\s*\(|\bwithSparkVisibility\s*\(' src tests -g '*.ts'
echo '=== Complete changed test blocks ==='
nl -ba tests/codex-integration/codex-routing.test.ts | sed -n '1660,1810p'
nl -ba tests/codex-integration/codex-spark-visibility.test.ts | sed -n '1,190p'
echo '=== All parser regression cases ==='
rg -n -C 10 '\bparseUsageQuota\s*\(' tests src -g '*.ts'
echo '=== Routing and auto-refresh consumers of custom windows ==='
rg -n -C 8 'customWindows|shortPercent|shortWindowSeconds' \
src/codex src/usage gui/src \
-g '*.ts' \
| head -1800Length of output: 1298 🏁 Script executed: #!/bin/bash
set -euo pipefail
show_range() {
local file="$1" start="$2" end="$3"
cat -n "$file" | sed -n "${start},${end}p"
}
echo '=== Quota parser helpers and implementation ==='
show_range src/codex/quota.ts 120 245
show_range src/codex/quota.ts 680 850
echo '=== Quota data contracts ==='
show_range src/codex/quota-types.ts 1 240
echo '=== Auth API Spark filter ==='
show_range src/codex/auth-api.ts 225 310
echo '=== Projection call sites ==='
rg -n -C 8 '\bquotaForPlan\s*\(|\bwithSparkVisibility\s*\(' src tests -g '*.ts' | head -700
echo '=== Changed test blocks ==='
show_range tests/codex-integration/codex-routing.test.ts 1660 1810
show_range tests/codex-integration/codex-spark-visibility.test.ts 1 190
echo '=== Parser test cases ==='
rg -n -C 10 '\bparseUsageQuota\s*\(' tests -g '*.ts' | head -1500
echo '=== Codex quota consumers ==='
rg -n -C 6 'customWindows|shortPercent|shortWindowSeconds' src/codex src/usage gui/src -g '*.ts' | head -1400Length of output: 146384
I could not run the test suite in this inspection sandbox. The static review supports the stated regression coverage.
|
632b85a to
d738747
Compare
|
@coderabbitai review The PR head was force-updated after removing unrelated locale churn. Please review commit d738747, focusing on the Spark-specific five-hour parser regression and the projection-boundary filter. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
commit="d7387478be"
echo '=== Commit identity and changed files ==='
git show --no-ext-diff --format=fuller --name-status "$commit"
echo
echo '=== Commit diff ==='
git diff --no-ext-diff --unified=100 "${commit}^" "$commit" -- \
src/codex/quota.ts \
src/codex/auth-api.ts \
tests/codex-integration/codex-routing.test.ts \
tests/codex-integration/codex-spark-visibility.test.ts \
tests/gui/quota-bars-rows.test.ts
echo '=== Relevant file outlines ==='
for file in src/codex/quota.ts src/codex/auth-api.ts tests/codex-integration/codex-routing.test.ts tests/codex-integration/codex-spark-visibility.test.ts tests/gui/quota-bars-rows.test.ts; do
if [ -f "$file" ]; then
echo "--- $file"
ast-grep outline "$file" --items all 2>/dev/null || true
fi
done
echo '=== Parser and projection definitions, call sites, and labels ==='
rg -n -C 14 \
'CODEX_SPARK_WINDOW_LABELS|withSparkVisibility|GPT-5\.3-Codex-Spark|parseUsageQuota|customWindows|shortPercent|shortResetAt|five.hour|fiveHour|five_hour' \
src tests \
-g '*.ts' \
-g '*.json' \
| head -2600
echo '=== Exact source regions ==='
nl -ba src/codex/quota.ts | sed -n '700,860p'
nl -ba src/codex/auth-api.ts | sed -n '220,305p'
echo '=== Focused test regions ==='
nl -ba tests/codex-integration/codex-routing.test.ts | sed -n '1640,1830p'
nl -ba tests/codex-integration/codex-spark-visibility.test.ts | sed -n '1,180p'
nl -ba tests/gui/quota-bars-rows.test.ts | sed -n '1,280p'Length of output: 198562 🏁 Script executed: #!/bin/bash
set -euo pipefail
commit="d7387478be"
numbered() {
local file="$1" start="$2" end="$3"
echo "--- ${file}:${start}-${end}"
sed -n "${start},${end}p" "$file" | awk -v n="$start" '{ printf "%6d\t%s\n", n++, $0 }'
}
echo '=== Commit and changed paths ==='
git show --format='commit %H%nparent %P%nsubject %s' --name-status "$commit"
echo '=== Exact commit patch ==='
git diff --no-ext-diff --unified=40 "${commit}^" "$commit" -- \
src/codex/quota.ts \
src/codex/auth-api.ts \
tests/codex-integration/codex-routing.test.ts \
tests/codex-integration/codex-spark-visibility.test.ts \
tests/gui/quota-bars-rows.test.ts
echo '=== Symbol locations ==='
rg -n \
'CODEX_SPARK_WINDOW_LABELS|withSparkVisibility|function parseUsageQuota|export function parseUsageQuota|GPT-5\.3-Codex-Spark' \
src/codex/quota.ts src/codex/auth-api.ts \
tests/codex-integration/codex-routing.test.ts \
tests/codex-integration/codex-spark-visibility.test.ts \
tests/gui/quota-bars-rows.test.ts
echo '=== Parser implementation ==='
numbered src/codex/quota.ts 720 840
echo '=== Spark visibility projection ==='
numbered src/codex/auth-api.ts 225 300
echo '=== Parser regression test ==='
numbered tests/codex-integration/codex-routing.test.ts 1680 1805
echo '=== Projection regression tests ==='
numbered tests/codex-integration/codex-spark-visibility.test.ts 1 170
echo '=== Custom quota row rendering tests ==='
numbered tests/gui/quota-bars-rows.test.ts 1 260Length of output: 59545 🏁 Script executed: #!/bin/bash
set -euo pipefail
commit="d7387478be"
numbered() {
local file="$1" start="$2" end="$3"
echo "--- ${file}:${start}-${end}"
sed -n "${start},${end}p" "$file" | awk -v n="$start" '{ printf "%6d\t%s\n", n++, $0 }'
}
echo '=== Full patch for the configuration type change ==='
git diff --no-ext-diff --unified=50 "${commit}^" "$commit" -- src/types/config.ts
echo '=== Window types and classification helpers ==='
rg -n -C 10 \
'interface WhamUsageWindow|type WhamUsageWindow|function isExplicitShortWindow|function isExplicitMonthlyWindow|WEEKLY_WINDOW_MIN_SECONDS|SHORT_WINDOW' \
src/codex/quota.ts
numbered src/codex/quota.ts 1 155
numbered src/codex/quota.ts 650 725
echo '=== Every production projection call site ==='
rg -n -C 12 '\bwithSparkVisibility\s*\(' src -g '*.ts'
echo '=== Auth DTO paths that return quota data ==='
rg -n -C 8 'quotaForPlan\s*\(|customWindows|listCodexAuthAccountsSnapshot|fetchMainAccountInfoSnapshot' \
src/codex/auth-api.ts src/providers/quota.ts \
-g '*.ts'
echo '=== Current commit diff statistics ==='
git diff --no-ext-diff --stat "${commit}^" "$commit"Length of output: 82660
Use the seconds-domain threshold: function isExplicitMonthlyWindow(window: WhamUsageWindow | null | undefined): boolean {
const seconds = window?.limit_window_seconds;
return typeof seconds === "number"
&& Number.isFinite(seconds)
&& seconds >= MONTHLY_WINDOW_MIN_SECONDS;
}The projection filter is otherwise correct. You are interacting with an AI system. |
|
CodeRabbit's latest note appears stale for the current head. |
리뷰 · 우선순위 61 / 80이 PR은 핵심 변경은 세 곳이다. 다만 아직 draft이고 테스트는 Pro plan_type + Spark primary 5h / secondary weekly 합성으로 일반 창과 Spark 창이 섞이지 않음을 단언하고, visibility on/off·타 provider custom window 보존도 갱신했다. types/config 대분할에 무효화될 대형 리팩터는 아니다. 라인 src/codex/quota.ts Spark 라벨 메인테이너의 판단이 필요한 지점
너의 추천 이 댓글은 grok-bot이 작성했습니다 |
…rage, history) (#4051) * fix(codex): keep Spark five-hour quota model-scoped Carried from #4018 (author cb8010d6) for maintainer-side CI and sequential integration. Closes #4017 Co-authored-by: cb8010d6 <53855466+cb8010d6@users.noreply.github.com> * fix(codex): retain Spark quota on partial header updates Carried from #4008 (author cb8010d6) for maintainer-side CI and sequential integration. Closes #4007 Co-authored-by: cb8010d6 <53855466+cb8010d6@users.noreply.github.com> * fix(codex): invalidate app-server observations at catalog boundaries Carried from #3981 (author yansigit) for maintainer-side CI and sequential integration. Co-authored-by: yansigit <44089734+yansigit@users.noreply.github.com> * fix(web-search): stop inactivity timing after terminal events Carried from #3979 (author yansigit) for maintainer-side CI and sequential integration. Co-authored-by: yansigit <44089734+yansigit@users.noreply.github.com> * fix(responses): strip Muse web_search fields on direct Meta Carried from #3964 (author ildunari) for maintainer-side CI and sequential integration. Co-authored-by: ildunari <95185577+ildunari@users.noreply.github.com> * fix: preserve combo capabilities and skip referenced archives Carried from #3863 (author x3M3x) for maintainer-side CI and sequential integration. Co-authored-by: x3M3x <98298256+x3M3x@users.noreply.github.com> * fix(codex): recover ocx1-compacted threads for native replay Carried from #3920 (author cb8010d6) for maintainer-side CI and sequential integration. Closes #3916 Co-authored-by: cb8010d6 <53855466+cb8010d6@users.noreply.github.com> --------- Co-authored-by: t <a@b.com> Co-authored-by: cb8010d6 <53855466+cb8010d6@users.noreply.github.com> Co-authored-by: yansigit <44089734+yansigit@users.noreply.github.com> Co-authored-by: ildunari <95185577+ildunari@users.noreply.github.com> Co-authored-by: x3M3x <98298256+x3M3x@users.noreply.github.com>
|
Landed on Verification at the merged head Closing this PR because the change is already on |
Summary
Closes #4017.
The Codex WHAM payload can report account-level windows separately from the additional
GPT-5.3-Codex-Sparklimit. A Spark-specific five-hour primary window was previously discarded while the Spark weekly window was retained, so Pro account cards could show the wrong generic five-hour row or omit the Spark five-hour usage.This change keeps Spark's five-hour and weekly windows as model-scoped custom quota rows:
GPT-5.3-Codex-Spark 5hGPT-5.3-Codex-Spark WeeklyAccount-level five-hour parsing is unchanged for plans that explicitly report that window. The existing Spark visibility setting now hides or reveals both Spark rows, while custom windows from other providers remain untouched.
Verification
bun test tests/codex-integration/codex-routing.test.ts -t "WHAM keeps general and Spark windows separate": passed.bun test tests/codex-integration/codex-spark-visibility.test.ts: 6 passed.bun test tests/gui/quota-bars-rows.test.ts: 26 passed.bun run typecheck: passed.bun run privacy:scan: passed.bun run build:gui: passed.git diff --check: passed.The change is intentionally limited to quota parsing, the existing Spark projection filter, configuration copy, and regression coverage. No credentials, provider URLs, or local configuration are included.
Checklist
Review readiness checklist
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met: