refactor(server): normalize provider settings before use #10121
main fromt3code/debt-gzuf-8-compatibility·opened View on GitHubRuntime code still interprets both provider settings formats. The text-generation fallback can select a default instance that was explicitly disabled.
Normalize old settings into one instance map before runtime code reads them. Keep old file and client formats at the settings boundary. Preserve explicit disables, unknown driver configs, and sparse defaults when clients save the full map. Registry, terminal, installation, session scan, and usage reads now use instance IDs. The provider Reset action compares values with defaults instead of treating every normalized entry as an edit. Omitted config fields count as defaults for this comparison. Unknown keys, invalid config, and instance edits still show Reset.
Verification#
- 525 focused tests across 15 server, shared, and web suites pass.
- Server and web typechecks pass. Changed-file lint passes with warnings in unchanged code. Formatting passes.
- Read-only source review is clear after fixes for old-client saves, unknown driver defaults, and usage config validation.
- The sparse-config Reset fix passed 56 focused tests, web typecheck, lint, and formatting.
- Disposable browser checks pass: default settings hide Reset, an edited display name shows it, and Reset restores the default. No live state or provider session was used.
Browser check#
| Before | After |
|---|---|
![]() | ![]() |
After editing the display name:

Sparse default config#
Both disposable builds received the same valid server-config input: {"providerInstances":{"codex":{"driver":"codex","enabled":true}}}.
Before dd1e088f54 shows Reset. After 7b62fb288b, which includes fix 56ccf1b5d6, hides it. The actual client ran in both checks. All non-read application requests were blocked. No real settings change or provider command ran.
| Before | After |
|---|---|
![]() | ![]() |
Note
Normalize provider settings into RuntimeServerSettings before use#
- Introduces
resolveServerSettingsin serverSettings.ts, which converts persisted settings toRuntimeServerSettingsby folding legacy enabled flags, synthesizing default provider instances from legacyprovidersentries, and dropping the legacy map from the runtime shape.providerInstancesbecomes the single source of truth for runtime consumers. - Updates
ServerSettingsServicecontract and all consumers — usage scanner, terminal manager, provider registry hydration, provider installation, agent session scanner, and text-generation fallback — to read provider configuration fromproviderInstancesdirectly instead of legacyprovidersfields. - Reconstructs a legacy
providersmap vialegacyProvidersForClientonly for client-facing redaction responses, preserving backward compatibility without making it a runtime source of truth. applySettingsPatchfilters out synthesized default instances that merely match legacy defaults, so saving unchanged settings does not persist them as explicit overrides.- Risk:
RuntimeServerSettingsreplacesServerSettingsacrossServerSettingsServicemethods (getSettings,updateSettings,streamChanges,subscribeChanges) and downstream parameter types in UsageService.ts, Manager.ts, ProviderInstanceRegistryHydration.ts, and providerInstallation.ts; any out-of-tree consumers of these signatures must update. Invalid known-driver instance configs now surface asscanFailedin usage instead of silently using defaults.
Model#
Created with GPT-6 Astra in Codex. Sparse-default correction, browser verification, and evidence upload in Codex.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
Approvability#
Verdict: Not approved
Macroscope's review found this PR not approvable — This PR changes the authoritative provider-settings representation across server routing, fallback selection, persistence, registry hydration, terminal environments, usage scanning, and web reset behavior. The cross-cutting runtime and shared-infrastructure impact is broader than an auto-approvable refactor.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).github-actions[bot](GitHub profile, opens in a new tab) added labels📱 Native Change
Note
🤖 Claude Fable 5.1 responding on behalf of Theo
Closing in favor of #10346, which fixes #7533 in about 15 lines. The full normalization changes the type ServerSettingsService hands to every consumer, changes what clients receive for providers (a config decode failure now flips a provider to disabled on old clients), and makes UsageService fail the whole scan on one invalid homePath where main used defaults. Also, this PR did not fix #5805: UsageService on the branch still scans only the default claudeAgent and codex instance ids. #8470 is the real fix for that.
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.




Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Baseline:
761d4ba· PR result:56ccf1b· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.