Move the foundational provider and token modules into codex-auth while keeping codex-core as the facade. Also move the corresponding unit tests and record the 3-PR migration checkpoints. Co-authored-by: Codex <noreply@openai.com>
5.5 KiB
Codex Auth Migration Plan
Goal
Move auth and model-provider ownership into a new codex-auth crate while keeping codex-core as the thin public surface for the rest of the workspace.
Non-core crates should not end up in a state where they need to import codex-auth directly.
Invariants
codex-authis the implementation owner for auth and provider concepts.codex-coreis the public facade for normal consumers.- Normal consumers keep importing auth/provider concepts from
codex-core. - Only boundary crates may depend on
codex-authdirectly.- Allowed:
codex-core,codex-login,codex-auth - Not allowed:
tui,exec,app-server,chatgpt,cli
- Allowed:
- Avoid duplicating logic between
codex-coreandcodex-auth. - Prefer moving code first and redesigning APIs later.
Ownership Boundary
codex-auth owns
- auth state and persistence
- token parsing and refresh
- auth manager lifecycle
- auth storage backends
- model provider definitions
- built-in provider registry
- auth/provider request glue
- provider-aware remote model catalog behavior if it is truly auth/provider infrastructure
codex-core owns
- config loading and orchestration
- app/session/thread behavior
- product policy
- model presentation and presets
- thin re-exports over
codex-auth
PR 1
Scope
Create codex-auth, move foundational auth/provider code into it, and add codex-core re-exports in the same PR.
Expected moves
core/src/token_data.rscore/src/model_provider_info.rs
These should become codex-auth modules with minimal behavioral change.
Note:
auth/storage and the heavier auth manager implementation may stay in codex-core for PR 1 if moving them would drag Config or other core-only seams into codex-auth too early.
Required facade work in the same PR
- Re-export moved items from
codex-core - Preserve existing import paths where practical
- Keep module-path compatibility for callers that currently use:
codex_core::auth::...codex_core::model_provider_info::...
Acceptance criteria
codex-authexists and owns the moved implementationcodex-corestill exposes the same public auth/provider concepts- No normal consumer crate imports
codex-auth - No behavior change intended
Checkpoints
core/src/lib.rsre-exports moved auth/provider symbols- compatibility module exists for
codex_core::model_provider_info::* core/Cargo.tomldepends oncodex-auth- no direct
codex-authdependency added totui,exec,app-server,chatgpt, orcli - moved code does not pull
codex-coreback intocodex-auth
PR 2
Scope
Move implementation-boundary consumers and auth/provider glue to the new owner while keeping codex-core as the facade.
Expected changes
- move
codex-loginto depend oncodex-authdirectly - move auth/provider request glue that belongs with auth ownership
- update
codex-coreinternals to consumecodex-authdirectly under the facade
Likely files to review
login/src/lib.rslogin/Cargo.tomlcore/src/api_bridge.rscore/src/client.rscore/src/thread_manager.rs
Acceptance criteria
codex-loginno longer depends oncodex-corefor auth ownership- auth/provider glue lives with
codex-auth - public consumption for normal crates still goes through
codex-core
Checkpoints
logindepends oncodex-auth, notcodex-core, for auth conceptscorestill re-exports the same public surface- no normal consumer crate was switched to importing
codex-auth - auth header/account-id/provider glue no longer has split ownership
- dependency direction is improved, not inverted again
PR 3
Scope
Move the auth/provider-owned model-management pieces and finish cleanup without dragging product policy out of codex-core.
Expected changes
- move only the provider/auth-coupled parts of model management
- keep model presentation, presets, and app policy in
codex-core - remove leftover shims that are no longer needed, while keeping the public
codex-corefacade stable
Likely files to review
core/src/models_manager/manager.rscore/src/models_manager/mod.rscore/src/models_manager/model_info.rs
Acceptance criteria
- provider/auth infrastructure no longer lives in
codex-core codex-corestill owns product policy and presentation- normal consumer crates still do not need
codex-auth
Checkpoints
- only provider/auth infrastructure moved out of
models_manager - model presets and presentation remain in
codex-core codex-corefacade still covers auth/provider concepts for consumers- no duplicate provider/auth logic remains across crates
Watchlist
These are the highest-risk seams to review during the migration:
core/src/api_bridge.rscore/src/client.rscore/src/thread_manager.rscore/src/config/mod.rscore/src/models_manager/manager.rslogin/src/lib.rs- any
codex_core::auth::...imports in non-corecrates
Quick Rule For Future Work
If code answers one of these questions, it likely belongs in codex-auth:
- Who am I authenticated as?
- How are credentials stored or refreshed?
- What provider am I configured to use?
- How does auth interact with provider request construction?
If code answers one of these questions, it likely stays in codex-core:
- How should the app behave?
- How should models be presented to users?
- How should config be orchestrated for the product?
- How should threads, sessions, and UI flows be managed?