refactor(codex,providers): split routing and quota behind facades - #4645
Conversation
Pure move. routing.ts 3507 -> 1475 with six leaves, quota.ts 3313 -> 558 with five leaves. Dispatchers that would close a cycle stay on the facade. Retry budget scope is unchanged; no new attempt counter exists in any leaf.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (2)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
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. |
리뷰 · 우선순위 52 / 80이 PR은 제품 기능을 바꾸려는 것이 아니라, godfile round2 사이클 4에서 이미 약속한 대로 지금 나눈 모양은 040 계획과 대체로 맞다. routing 쪽은 본문을 텍스트로 읽는 오라클도 같이 고쳤다. 형제 #4643과 같은 약점도 있다. 경로 메인테이너의 판단이 필요한 지점
너의 추천 이 댓글은 grok-bot이 작성했습니다 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 35969857f2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -0,0 +1,194 @@ | |||
| import { saveConfigPreservingClaudeCode } from "../config"; | |||
There was a problem hiding this comment.
Fix the config import from the nested routing module
Building the changed src/codex/routing.ts entry with Bun fails immediately because this path resolves to nonexistent src/codex/config.ts; the new leaf is one directory deeper than the old facade, so it must import ../../config. Since the facade statically imports this leaf, every proxy startup that loads Codex routing fails before serving requests.
AGENTS.md reference: src/AGENTS.md:L7-L8
Useful? React with 👍 / 👎.
| let oldestIsDetour = false; | ||
| for (const [threadId, affinities] of threadAccountMap) { | ||
| for (const [scope, entry] of affinities) { | ||
| const candidateIsDetour = isModelDetourAffinityScope(scope); |
There was a problem hiding this comment.
Restore the model-detour scope predicate
When the affinity cache exceeds CODEX_THREAD_AFFINITY_MAX_ENTRIES (2,048 entries), pruneLruThreadAffinities executes this call, but the split omitted the previous isModelDetourAffinityScope definition. Bun therefore throws a ReferenceError during the bind that crosses the limit, leaving every subsequent new affinity bind liable to fail instead of evicting an entry; restore the predicate in this leaf.
AGENTS.md reference: src/AGENTS.md:L7-L8
Useful? React with 👍 / 👎.
…ta split Fifteen symbols lost their binding: leaves that defined a symbol never exported it, quota type imports pointed at src/types instead of providers/quota-types, and isModelDetourAffinityScope lost its definition entirely while its call site survived. Imports and exports only; no declaration was moved or rewritten.
The leaf sits one directory deeper than routing.ts, so ../config resolved to src/codex/config, which does not exist. Every test shard that loaded the routing graph failed at import time.
Summary
src/codex/routing.ts와src/providers/quota.ts를 파사드로 남기고 리프로 나눈다. 순수 이동이며 공개 export 표면은 이동 전과 같다.src/codex/routing.tsrouting/cooldown-math.ts274,routing/health-store.ts402,routing/probe-lease.ts358,routing/thread-affinity.ts415,routing/selection.ts698,routing/active-account.ts194src/providers/quota.tsquota/report-cache.ts319,quota/account-cache.ts440,quota/vendor-probes-key.ts1,243,quota/vendor-probes-oauth.ts589,quota/antigravity.ts295두 파일 모두 계획보다 파사드가 두껍게 남았고 이유는 같다. 계획이 리프로 보낸 함수 일부가 그 리프를 다시 호출해서 순환이 생긴다.
routing에서는clearCodexUpstreamHealth계열과reconcileCodexActiveAfterExclusion,releaseDrainedCodexAccountPin이 그렇고,quota에서는fetchAccountQuota와 explicit 계정 디스패처들이 oauth/key/antigravity 프로브를 호출하면서 그 프로브들이 다시account-cache상태를 기록한다. 그래서 디스패처는 파사드에 남기고 리프에서 상태 소유 모듈로 가는 단방향만 남겼다.재시도 예산 범위는 건드리지 않았다. 새 모듈 어디에도 시도 카운터를 만들지 않았고, 링 전진과 active 커서 승격은 그대로 한 곳에 있다.
quota의 WeakMap 세 개(nativeMainReportGenerations,accountReportCurrent,routingEvidence)는report-cache가 단독 소유한다. report 객체를 키로 쓰기 때문에 만드는 모듈과 읽는 모듈이 갈라지면 증거가 조용히 사라진다.본문을 텍스트로 읽는 오라클 세 곳을 같이 고쳤다.
config-save-boundary.test.ts의GUARDED_FILES에codex/routing/active-account.ts를 더했고(setActiveCodexAccount가 그리로 갔다),provider-quota.test.ts의.json(금지 검사는 프로브가 옮겨간 리프 셋까지 읽게 했다. 파사드만 읽으면 프로브가 없는 파일을 검사하는 빈 가드가 된다.Verification
bun scripts/structure-ssot.ts→structure/ SSOT checks passed(openai-tiers.md451·518,runtime.md342,gui-and-management-api.md502의 백틱 경로를 새 소유 모듈로 교체한 뒤)bun scripts/file-size-ratchet.ts→file-size ratchet passedorigin/dev기준):routing.ts54 → 54,quota.ts30 → 30, 누락 0작업 중 이 스택의 래칫 게이트가 실제로 한 번 막았다.
provider-quota.test.ts의 오라클을 넓히면서 파일이 3,763 → 3,772줄이 되자GREW로 실패했고,ratchet:update는 캡을 올리지 못하므로 우회할 수 없어 같은 줄 수로 다시 썼다.Checklist