Repository navigation
feat(codex): opt-in pool-only policy keeps automatic Pool routing off native main - #8536
Conversation
… native main (#7410) codexPool.poolOnly (default off) makes automatic Pool resolution serve only registered, eligible non-main accounts. One decision in codexAccountUnusableReason (reason pool_only) keeps selection, preserve paths, subagent fallback and previews in agreement; resolveCodexAuthContext additionally skips request-owned main pin preservation, stored-main discovery, both caller-main fallbacks and the no-candidate main policy check, and refuses if any selector still names main. Explicit selectors, Reserve and Direct stay outside the policy.
|
✅ Deterministic PR hygiene checks passed. |
Codex Review Summary: ✅ CompletedThis 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. |
|
Caution Review failedThe pull request is closed.
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: df8e1735f4
ℹ️ 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".
| return "model_not_entitled"; | ||
| } | ||
| if (accountId === MAIN_CODEX_ACCOUNT_ID) { | ||
| if (codexPoolOnlyExcludesMain(config) && options.explicitAccountSelector !== true) return "pool_only"; |
There was a problem hiding this comment.
Preserve the explicit-selector exemption for stored main auth
With codexPool.poolOnly: true, an explicit __main__ route without a caller-owned Codex bearer (for example, a proxy API-key request using stored main credentials) is rejected despite the documented exemption. resolveCodexAuthContextUnannotated bypasses automatic selection for fixedAccountId, but its fixed-account validation calls codexAccountUnusableReason without explicitAccountSelector, so this new branch returns pool_only and authentication throws. The added explicit-main test only exercises the caller-owned early return and misses this path. Propagate the explicit-selector exemption through fixed-account validation and the subsequent isCodexAuthContextUsable recheck, which otherwise also rejects a main-pool context.
Useful? React with 👍 / 👎.
…pool-only policy The fixed-account check and dispatch revalidation consulted usability without the explicit opt-out, so an exact stored __main__ selector and every Reserve request were refused under codexPool.poolOnly. Fixed selectors now pass explicitAccountSelector, and isCodexAuthContextUsable does for a fixedAccount main-pool context. Adds exact stored-main, automatic-context reuse and pinned-main preview cases; documents the sidecar login rule.
|
Maintainer judgment (combo/pool bundle lane), head
|
Summary
A manual Pool pin is a preference, so a Pool request can still reach the native main login: through the caller-main fallback when the stored account is excluded or cooling, by ordering, by keeping main as the active account, or by a main pin. Operators who want Pool to protect native-main quota had no way to say so (#7410).
This adds an opt-in
codexPool.poolOnly(default off). With it on, automatic Pool resolution serves only registered, eligible added accounts and refuses when none can serve:{"codexPool":{"poolOnly":true}}codexAccountUnusableReason(src/codex/account-usability.ts) returnspool_onlyfor__main__while the policy is on. Selection, the routing preserve paths, subagent fallback and the request-prepare preview already consult it, so they agree without separate branches. An account-qualified subagent route passesexplicitAccountSelectorand stays outside the policy.src/codex/auth-context.ts): request-owned main pin preservation, stored-main discovery and main entitlement reads, the no-candidate and cooldown caller-main fallbacks, and the no-candidate main policy check are skipped. If any selector still names main, the request is refused with the existing Pool error.__main__), Reserve models and Direct mode. Paused, duplicate-main, entitlement and cooldown checks are unchanged, and no ineligible account becomes usable.src/types/config.tsand the strictcodexPoolSchema; written through the existing validated config path. No migration; the default keeps today's behavior.guides/codex-integration.md(next to the pin-vs-fallback paragraph) andreference/configuration/routing.md; owner docstructure/codex-account-controls.md.Implements the owner-recommended contract recorded on #7410 (alternate-pool-only, off by default; explicit routes documented as outside the policy). No dashboard toggle is added; the setting is config-only.
Closes #7410
Verification
Head
df8e1735, macOS, Bun 1.4.4, basedev5cc64aeb.tests/codex-integration/codex-pool-only-policy.test.tson dev source failed 6 of 7 (main served via exclusion and cooldown fallback, main pin, stored-main ordering; nopool_onlyreason). Only the explicit-selector/Direct case passed, as intended.codex-pool-caller-fallback-policy.test.tspass unchanged. Each pool-only case runs next to its default-mode control.codexPoolschema files: 798 pass, 0 fail.bun run typecheck0 errors;structure:check,privacy:scan,test-layoutguards pass.bun run test; macOS/Windows lanes (batchdevdispatch policy); live Codex accounts.Checklist