Skip to content
Source
Sign inSign up
pingdotgg/t3code

refactor(server): normalize provider settings before use #10121

Closedt3dotgg(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromt3code/debt-gzuf-8-compatibilityopened View on GitHub

Runtime 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.

Closes #7533 Closes #5805

Browser check

BeforeAfter
Provider settings beforeProvider settings after

After editing the display name:

Reset available after editing

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.

BeforeAfter
Sparse default shows Reset beforeSparse default hides Reset after

Note

Normalize provider settings into RuntimeServerSettings before use

  • Introduces resolveServerSettings in serverSettings.ts, which converts persisted settings to RuntimeServerSettings by folding legacy enabled flags, synthesizing default provider instances from legacy providers entries, and dropping the legacy map from the runtime shape. providerInstances becomes the single source of truth for runtime consumers.
  • Updates ServerSettingsService contract and all consumers — usage scanner, terminal manager, provider registry hydration, provider installation, agent session scanner, and text-generation fallback — to read provider configuration from providerInstances directly instead of legacy providers fields.
  • Reconstructs a legacy providers map via legacyProvidersForClient only for client-facing redaction responses, preserving backward compatibility without making it a runtime source of truth.
  • applySettingsPatch filters out synthesized default instances that merely match legacy defaults, so saving unchanged settings does not persist them as explicit overrides.
  • Risk: RuntimeServerSettings replaces ServerSettings across ServerSettingsService methods (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 as scanFailed in usage instead of silently using defaults.
Macroscope summarized 56ccf1b.

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

    2. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire13.5 KiB13.5 KiB+13 B (+0.1%)15.1 KiB✅
      CodexThread snapshot wire7.0 KiB7.0 KiB+4 B (+0.1%)7.3 KiB✅
      CodexLive turn WebSocket wire6.5 KiB6.5 KiB+9 B (+0.1%)7.8 KiB✅
      CodexLive turn WebSocket decoded57.0 KiB57.0 KiB0 B (0.0%)66.4 KiB✅
      CodexLive turn messages880 (0.0%)21✅
      ClaudeTotal thread wire13.6 KiB13.6 KiB+3 B (+0.0%)15.1 KiB✅
      ClaudeThread snapshot wire7.0 KiB7.0 KiB−8 B (−0.1%)7.3 KiB✅
      ClaudeLive turn WebSocket wire6.5 KiB6.5 KiB+11 B (+0.2%)7.8 KiB✅
      ClaudeLive turn WebSocket decoded57.8 KiB57.8 KiB0 B (0.0%)66.4 KiB✅
      ClaudeLive turn messages990 (0.0%)21✅

      Baseline: 761d4ba · PR result: 56ccf1b · Source CI: success

      Scenario 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.

      • Codex decoded thread snapshot: 113.8 KiB
      • Claude decoded thread snapshot: 114.5 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      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).
    4. github-actions[bot](GitHub profile, opens in a new tab) added labels📱 Native Change

    5. 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.

Sign in to join this conversation.