You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Split the large config modules without creating another pile of synchronized provider lookup tables.
This is an implementation slice of #2608. The purpose is to move config code toward the same provider/model/offering/route boundaries used by the rest of v0.8.65, not to centralize every provider-specific branch into one bigger table.
Architecture Contract
Config should store user intent and overrides. It should not own provider behavior or model behavior.
new provider/model compatibility match tables in config;
naked global model strings detached from provider scope;
model routing logic in TOML migration code;
prompt or docs files as a source of route truth.
Current Problem
The TUI config layer and shared config crate have large provider/config monoliths:
crates/tui/src/config.rs
crates/config/src/lib.rs
Provider defaults, env vars, model aliases, validation, base URL cleanup, completion names, capability reporting, and migration compatibility are interleaved. Adding or fixing a provider currently risks touching unrelated surfaces.
Proposed Module Split
For crates/tui/src/config.rs, split only where the boundary is real:
config/types.rs: user config schema and serde compatibility.
config/loading.rs: load, merge, and migration flow.
config/credentials.rs: credential references and env/auth preference resolution, without storing secrets in logs or prompts.
config/paths.rs: config/cache/workspace paths.
config/env_override.rs: environment overrides.
config/workspace_trust.rs: trust/sandbox config.
config/provider_user_config.rs: per-provider user intent and overrides.
legacy wrappers that delegate to catalog/route modules until callers migrate.
Provider descriptors, model profiles, provider model offerings, capability profiles, and pricing should live in catalog/routing modules or crates, not in config migration code.
Migration Strategy
Add focused modules and move schema/loading code first.
Delete obsolete wrappers only after all call sites use the catalog/route APIs.
When editing becomes more confusing than replacing a file, remake the file/module around the new contract and migrate callers/tests. Preserve behavior, migrations, tests, and contributor credit; do not preserve accidental file shape.
Acceptance Criteria
Config modules separate schema/loading/credentials/paths/user intent from provider/model catalog facts.
Existing TOML compatibility and env override behavior remain compatible.
Provider-scoped selections are preserved; no new naked global model state is introduced.
Existing helper functions either delegate to catalog/route APIs or are marked as temporary legacy wrappers with migration targets.
Config serde round-trip and migration tests cover all provider variants and custom providers/endpoints.
No provider route/model compatibility regression.
Verification
cargo test -p codewhale-tui config --locked
cargo test -p codewhale-config --locked
cargo test -p codewhale-tui route_resolver --locked
python3 scripts/check-provider-registry.py
Required tests:
Config round-trip for direct, hosted aggregator, local runtime, and custom endpoint providers.
Saved provider-scoped model survives load/save without becoming a global default.
Custom base URL and custom model id remain provider-scoped.
Legacy config migrates into the new structures without mutating provider/model semantics.
Goal
Split the large config modules without creating another pile of synchronized provider lookup tables.
This is an implementation slice of #2608. The purpose is to move config code toward the same provider/model/offering/route boundaries used by the rest of v0.8.65, not to centralize every provider-specific branch into one bigger table.
Architecture Contract
Config should store user intent and overrides. It should not own provider behavior or model behavior.
Use this ownership split:
Do not add:
Current Problem
The TUI config layer and shared config crate have large provider/config monoliths:
crates/tui/src/config.rscrates/config/src/lib.rsProvider defaults, env vars, model aliases, validation, base URL cleanup, completion names, capability reporting, and migration compatibility are interleaved. Adding or fixing a provider currently risks touching unrelated surfaces.
Proposed Module Split
For
crates/tui/src/config.rs, split only where the boundary is real:config/types.rs: user config schema and serde compatibility.config/loading.rs: load, merge, and migration flow.config/credentials.rs: credential references and env/auth preference resolution, without storing secrets in logs or prompts.config/paths.rs: config/cache/workspace paths.config/env_override.rs: environment overrides.config/workspace_trust.rs: trust/sandbox config.config/provider_user_config.rs: per-provider user intent and overrides.Provider descriptors, model profiles, provider model offerings, capability profiles, and pricing should live in catalog/routing modules or crates, not in config migration code.
Migration Strategy
When editing becomes more confusing than replacing a file, remake the file/module around the new contract and migrate callers/tests. Preserve behavior, migrations, tests, and contributor credit; do not preserve accidental file shape.
Acceptance Criteria
Verification
Required tests:
Related