Skip to content

feat(codex): opt-in pool-only policy keeps automatic Pool routing off native main - #8536

Merged
lidge-jun merged 2 commits into
devfrom
feat/7410-codex-pool-only
Nov 11, 2026
Merged

lidge-jun merged 2 commits into
devfrom
feat/7410-codex-pool-only

Conversation

@lidge-jun

Copy link
Copy Markdown
Owner

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}}
  • One shared decision: codexAccountUnusableReason (src/codex/account-usability.ts) returns pool_only for __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 passes explicitAccountSelector and stays outside the policy.
  • Paths that never reach selection (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.
  • Outside the policy: exact account selectors (including __main__), Reserve models and Direct mode. Paused, duplicate-main, entitlement and cooldown checks are unchanged, and no ineligible account becomes usable.
  • Config: src/types/config.ts and the strict codexPoolSchema; written through the existing validated config path. No migration; the default keeps today's behavior.
  • Docs: guides/codex-integration.md (next to the pin-vs-fallback paragraph) and reference/configuration/routing.md; owner doc structure/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, base dev 5cc64aeb.

  • RED first: tests/codex-integration/codex-pool-only-policy.test.ts on dev source failed 6 of 7 (main served via exclusion and cooldown fallback, main pin, stored-main ordering; no pool_only reason). Only the explicit-selector/Direct case passed, as intended.
  • GREEN: the new file passes 7/7. The 4 default-mode controls in codex-pool-caller-fallback-policy.test.ts pass unchanged. Each pool-only case runs next to its default-mode control.
  • 32 auth-context, routing, pin, subagent-fallback and codexPool schema files: 798 pass, 0 fail.
  • bun run typecheck 0 errors; structure:check, privacy:scan, test-layout guards pass.
  • NOT RUN: full bun run test; macOS/Windows lanes (batch dev dispatch policy); live Codex accounts.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults. Opt-in, default off; it only removes candidates. Separate security review recorded on the PR.

… 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.
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner November 11, 2026 09:56
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T09:58:31.313726Z df8e173 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added the enhancement New feature or request label Nov 11, 2026
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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.
@lidge-jun

Copy link
Copy Markdown
Owner Author

Maintainer judgment (combo/pool bundle lane), head 02da23cb.

  • Value: Clarify manual pool pin versus caller-main fallback and consider pool-only policy #7410. Operators can now make Pool routing actually protect native-main quota. A manual pin stays a preference; the new opt-in codexPool.poolOnly is the hard guarantee for automatic Pool resolution.
  • UX change scope: a new optional config key, default off, with no dashboard toggle. Existing configs are unchanged and need no migration. Explicit __main__ and account-qualified models, Reserve and Direct still reach main by design.
  • Existing-user regression evidence: every new branch requires poolOnly === true. The four default-mode caller-fallback cases pass unchanged, each pool-only case runs next to its default control, and 32 auth-context, routing, pin, subagent-fallback and schema files pass (801 tests).
  • Windows impact: none; routing logic only.
  • Reviews: round 1 code FAIL + security PASS. Both found explicit __main__ and Reserve wrongly refused; fixed in 02da23cb with stored-main exact, dispatch-reuse and preview cases. Fresh final code PASS and final security PASS on 02da23cb; the security reviewer confirmed a client cannot reach the explicit opt-out. Remaining low and info notes are recorded (Reserve rides the tested fixed path; the generic refusal message matches today's exhausted-pool error).
  • NOT RUN: full bun run test; macOS/Windows lanes (batch dev dispatch policy); live Codex accounts.

@lidge-jun
lidge-jun merged commit 9323c32 into dev Nov 11, 2026
29 of 30 checks passed
@lidge-jun
lidge-jun deleted the feat/7410-codex-pool-only branch November 11, 2026 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clarify manual pool pin versus caller-main fallback and consider pool-only policy

1 participant