Repository navigation
fix(codex): block the main account when either the 5h or weekly window reaches 98% - #5870
Conversation
…w reaches 98% The hard lock picked one window (5h when present, else weekly), so a weekly reading at 98-100% with 5h headroom kept admitting main-account traffic. Each of 5h and weekly now governs alone; a block holds until every blocking window reads lower, resetAt is the latest blocking reset, and an unreadable 5h reading cannot hide a weekly block. The policy snapshot also keeps a blocking weekly tuple across a reset-only weekly observation.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
✅ Deterministic PR hygiene checks passed. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: lidge-jun/opencodex/.coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (19)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe main-account hard lock now evaluates short and weekly quota windows independently. Monthly usage governs only when neither window is present. A blocking weekly reading is retained across qualifying reset-only observations, and the documentation and translations describe the updated policy. ChangesMain-account hard-lock policy
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The updated descriptions match when the account is blocked and released. No identified issue needs resolution before merge. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change closes a case where a full weekly quota could still receive traffic. No new account-routing or authentication bypass was identified, but the complete source and consumption of quota observations remain unverified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 15 files. (4 skipped: 4 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 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 |
리뷰 · 우선순위 43 / 80이 글은 메인 계정 98% 잠금이 사용량 창을 하나만 보던 구멍을 막아요. 잠금은 기본으로 켜져 있어요. 예전 코드는 5시간 창이 하나라도 있으면 5시간 사용률만 봤어요. 5시간이 97%이고 주간이 98% 이상이어도 상태는 이제는 5시간 창과 주간 창을 따로 봐요. 어느 쪽이든 98% 이상이면 막아요. 5시간이 98%이고 주간이 50%여도 막히고, 5시간이 20%이고 주간이 100%여도 막혀요. 둘 다 98% 미만이면 통과하고, 97.99%도 통과예요. 한 번 막히면, 막은 창이 모두 98% 미만으로 새로 읽혀야 풀려요. 5시간이 0%로 리셋돼도 주간 99%는 그대로예요. 화면에 보여주는 다시 열리는 시각은, 막힌 창들의 리셋 시각 중 가장 늦은 것이에요. 막힌 창 중에 앞으로의 리셋 시각이 없는 것이 있으면 그 시각을 빼요. 더 빨리 풀린다고 말하지 않아요. 월간 숫자만 있는 계정은 월간을 봐요. 5시간이나 주간 기록이 있으면 월간은 잠금에 안 들어가요. 월간 100%와 주간 97%는 여전히 통과예요. 5시간 숫자를 못 읽으면 그 창만으로는 막지 않아요. 그런데 주간이 99%로 읽혀 있으면, 5시간을 못 읽어도 막아요. 못 읽은 5시간이 주간 차단을 숨기던 경우가 이번 고침이에요. 정책 기록에는 가드를 하나 더 넣었어요. 주간 리셋 시각만 오고 주간 퍼센트는 없는 관측은, 이미 98% 이상으로 막아 둔 주간 숫자를 지우지 않아요. 5시간 창에 있던 규칙과 같아요. 월간이 본창인 관측은 그 주간 숫자를 지우고 풀 수 있어요. 작성자는 지금 파서가 그 모양을 안 낸다고 했어요. 나중에 생길 구멍을 미리 닫은 거예요. 설정 문장 열 개 언어, 영어와 한국어 문서, 라인 - 메인테이너의 판단이 필요한 지점 5시간 창이 방금 0%인데 주간이 98% 이상이면, 이번 주 남은 5시간 창도 메인 계정으로는 못 써요. 메인 계정을 끝까지 쓰고 Reserve로 넘기려면 스위치를 꺼야 해요. 문서에 그 문장이 있어요. 이번 요청이 그 동작이면 그대로 두면 돼요. 월간을 5시간·주간과 함께 막을지는 이 글이 범위 밖으로 적어 두었어요. 주간 97%와 월간 100%는 통과로 남아요. 너의 추천 바탕은 이 댓글은 grok-bot이 작성했습니다 |
Summary
The main-account 98% hard lock (#5694) looked at only one usage window: the 5h window when the account had one, otherwise the weekly window. So a main account at 98–100% weekly with 5h headroom stayed
ready, and ocx kept sending it traffic until the weekly window drained. That is exactly the state that disables Codex Desktop's send button.Now the 5h and weekly windows each block on their own:
A block holds until every blocking window reports a fresh reading below 98%. For example, clearing 5h to 0% no longer releases a weekly 99% block. The reported
resetAtis the latest reset among the blocking windows, and it is omitted when any blocking window has no reset time, so the UI never promises an early unlock. Monthly still governs only monthly-only accounts. An unreadable window still admits by itself, but it can no longer hide a block in the other window.The retained policy snapshot also gained a guard that mirrors the existing 5h rule: an observation that carries a weekly reset time but no weekly percentage keeps a blocking weekly reading. A governing monthly-primary observation still replaces it, so that release path is unchanged. Today's parsers never emit that shape, so this closes a latent hole instead of fixing live behavior.
Every consumer (admission fence, pool usability, auto refresh, background recovery, account DTO, and settings) already reads
getMainAccountHardLockStatus, so the change lives in that one evaluator. The settings description, in all 10 locales, the en/ko docs, andstructure/providers/openai-tiers.mdnow describe the any-window rule.Settings → Codex → Multi-auth → Advanced settings, new description text (ko):
Verification
bun test tests/codex-integration/main-account-hard-lock-*.test.ts tests/codex-integration/main-quota-*.test.ts tests/codex-integration/codex-quota-auto-refresh-main-admission.test.ts tests/codex-integration/codex-account-threshold-api.test.ts tests/config/settings-main-account-hard-lock.test.ts→ 476 pass, 0 fail.resetAtselection, unknown 5h with weekly high and low, and the reset-only weekly guard with monthly-primary release. Existing pins that encoded "5h wins over weekly" (inmain-account-hard-lock-policy,main-quota-evidence-validation, andmain-quota-window-observation) were flipped deliberately to the new rule.bun run typecheck→ exit 0.bun run structure:check→ passed.bun run build:gui→ ok.bun run test:changedran about 25k tests locally, but the run is not usable as evidence. This checkout is a Codex-app worktree under~/.codex, and the test home guard refuses to remove fixture directories inside the real Codex home, which produced 943 unrelated cleanup failures (for exampleaccount-pool-management-api). None of them are in hard-lock or quota tests. The full suite is left to hosted CI.Checklist
Summary by CodeRabbit