Repository navigation
fix(codex): pace quota recovery queries - #6154
terrytan95 wants to merge 2 commits into
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 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🧪 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 |
|
✅ Deterministic PR hygiene checks passed. |
⏳ DRAFT
What to do
Review readiness checklist
0/4 boxes ticked. This PR stays in draft until every box above is ticked. |
리뷰 · 우선순위 63 / 80이 PR은 메인 계정이 하드락에 걸린 동안, 리셋 시각을 이미 아는데도 1분마다 사용량 주소를 두드리는 일을 멈춥니다. 리셋 시각이 미래이면 그 시각까지 로컬에서 기다립니다. 시각이 지나도 잠금을 풀지 않고, 사용량을 한 번 더 읽어 확인한 뒤에만 풉니다. 리셋 시각이 없거나 이미 지났는데도 아직 막혀 있으면, 확인 읽기 사이를 5분으로 벌립니다. 메인 계정, 풀 계정, 401 이후 다시 읽기가 같은 실패 간격을 씁니다. 간격은 5분, 10분, 20분, 40분, 그다음 60분입니다. 전송 실패와 인증이 아닌 HTTP 실패에 적용됩니다. 이슈 #6153을 닫습니다. 베이스는 라인 - 라인 - 메인테이너의 판단이 필요한 지점 본문이 깨진 200 응답은 성공으로 보고 실패 간격을 지웁니다. 다음 조회가 바로 다시 나갑니다. 작성자는 이 경우를 새 간격 밖으로 두었습니다. 깨진 본문도 5분부터 기다릴지. 401/403은 간격을 지우고 기존 인증 복구에 맡깁니다. 인증 실패가 반복되면 사용량 조회가 다시 붙을 수 있습니다. 그 반복을 이번 범위 밖에 둘지. 프로세스 재시작이나 256개를 넘는 삭제는 간격을 잊습니다. 작성자도 그렇게 적었습니다. 그 범위를 그대로 둘지. 너의 추천 리셋 전에는 안 읽고, 시간만으로 잠금을 풀지 않으며, 실패 간격을 메인과 풀이 같이 쓰는 방향은 이슈와 같습니다. 응답이 오기 전에는 같은 키를 막지 못하고, 긴 이 댓글은 grok-bot이 작성했습니다 |
Ingwannu
left a comment
There was a problem hiding this comment.
Exact-head review of b3e68de2928ba72b9ffe57c8fbd13034ef5168b6: the accepted reset-window recovery behavior is mostly covered, but the shared pacing boundary still permits the retry storm #6153 reports.
src/codex/quota-query-backoff.ts:21-30 records a per-key marker with after: 0, so another same-key caller always dispatches while the first request is pending and replaces marker ownership. If A then returns 429/Retry-After, A's failed() update is discarded; while B is slow, C/D can continue dispatching. The new tests explicitly admit two concurrent dispatches, so this is not cross-owner pacing at the dispatch boundary.
Use in-flight admission/coalescing (or a pending marker that blocks later callers) while preserving ordered completion and generation semantics. Add A pending → B/C arrive → A reports Retry-After coverage proving only one upstream query and durable backoff.
Also repair/narrow the structure changes: the new WHAM sentence was inserted mid-sentence in structure/dashboard-and-usage.md and structure/providers/openai-accounts.md, leaving both documents grammatically corrupted, with unrelated structure files blanket-edited. After those fixes, rebase onto current dev and obtain executable exact-head CI before undrafting.
|
Thanks @terrytan95. This change landed on |
Summary
Closes #6153.
Main-account hard-lock recovery currently forces usage reads on every minute sweep even before a known reset, and failed ordinary quota reads can be retried by subsequent dashboard/background requests despite an upstream Retry-After. Wait locally for known blocking resets and share credential-scoped HTTP/transport failure pacing at the ordinary WHAM dispatch boundary, preserving fresh-evidence requirements and authentication recovery.
Key Changes
Verification
bun test tests/codex-integration/codex-quota-query-backoff.test.ts tests/codex-integration/main-account-hard-lock-recovery.test.ts tests/codex-integration/codex-auth-api.test.ts tests/codex-integration/codex-quota-auto-refresh.test.ts tests/codex-integration/codex-quota-auto-refresh-main-admission.test.ts tests/codex-integration/codex-quota-auto-refresh-generation.test.ts tests/test-layout.test.ts tests/test-layout-tooling.test.ts tests/lab/core-lab-boundary.test.ts— 462 tests, 2,784 assertions, zero failures.bun run typecheck,bun run structure:check,bun run privacy:scan,git diff --check.cd docs-site && bun install --frozen-lockfile && bun run build— 537 pages; 73,620 internal links checked.bun run testand import-graph-expandedtest:changedwere not run: the earlier change's graph run selected broadly and degraded this host, with protected-home fixture cleanup failures in this managed checkout. This PR stays draft; full-suite/cross-platform validation and independent security review remain outstanding. The targeted final run is green; no broader pass is claimed.Impact & Risk
No configuration migration, dependency, environment variable, or deployment change. Early out-of-band quota recovery is no longer discovered before a known reset unless ordinary traffic or explicit reads observe it. Retry state is process-local and bounded to 256 keys; restart, configuration/credential generation changes, or eviction can permit an earlier retry. Successful HTTP responses with malformed bodies are outside the new transport/status backoff, and 401/403 remain with existing authentication logic. Reserve/login queries are separate. Reduced requests do not establish or guarantee improved account/session lifetime.
Checklist
Author inspection and regression verification are complete; independent security review and review-readiness confirmation are not claimed.
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
Retry-Afterinstructions can extend the wait; successful checks clear it.Maintainer feedback follow-up
Addresses #6153 (comment) in commit b3e68de. The earlier fixed five-minute successful-but-blocked recovery delay now uses the shared capped calculation, and retry admission reconciles the physical bearer first. The PR has been returned to draft. Focused recovery/interleaving tests pass; exact-head upstream test CI and independent review are still required. The author account has read-only upstream repository permission and cannot approve or dispatch maintainer-only CI.