Skip to content

Commit 2c11607

Browse files
refactor(settings): drop the legacy per-driver providers map (pingdotgg#17300)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 9eea28b commit 2c11607

32 files changed

Lines changed: 602 additions & 1073 deletions

‎apps/server/src/orchestration-v2/CursorOrchestratorV2.live.test.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import {
77
CommandId,
88
MessageId,
99
ProjectId,
10+
ProviderDriverKind,
11+
ProviderInstanceId,
1012
ThreadId,
1113
type OrchestrationV2ThreadProjection,
1214
} from "@t3tools/contracts";
@@ -60,8 +62,11 @@ const layerVcsDriverRegistry = VcsDriverRegistry.layer.pipe(
6062
const layerCheckpointStore = CheckpointStore.layer.pipe(Layer.provide(layerVcsDriverRegistry));
6163

6264
const layerServerSettings = ServerSettings.layerTest({
63-
providers: {
64-
cursor: { enabled: true },
65+
providerInstances: {
66+
[ProviderInstanceId.make("cursor")]: {
67+
driver: ProviderDriverKind.make("cursor"),
68+
enabled: true,
69+
},
6570
},
6671
});
6772
const layerBackgroundPolicy = BackgroundPolicy.layer.pipe(

‎apps/server/src/orchestration-v2/GrokOrchestratorV2.live.test.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
MessageId,
99
type OrchestrationV2ThreadProjection,
1010
ProjectId,
11+
ProviderDriverKind,
12+
ProviderInstanceId,
1113
ThreadId,
1214
} from "@t3tools/contracts";
1315
import * as Console from "effect/Console";
@@ -59,8 +61,11 @@ const layerVcsDriverRegistry = VcsDriverRegistry.layer.pipe(
5961
const layerCheckpointStore = CheckpointStore.layer.pipe(Layer.provide(layerVcsDriverRegistry));
6062

6163
const layerServerSettings = ServerSettings.layerTest({
62-
providers: {
63-
grok: { enabled: true },
64+
providerInstances: {
65+
[ProviderInstanceId.make("grok")]: {
66+
driver: ProviderDriverKind.make("grok"),
67+
enabled: true,
68+
},
6469
},
6570
});
6671
const layerBackgroundPolicy = BackgroundPolicy.layer.pipe(

‎apps/server/src/project/AgentSessionScanner.test.ts‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,19 @@ const layerScannerTest = (input: ScannerTestInput) =>
5959
Layer.provide(
6060
Layer.mergeAll(
6161
ServerSettings.layerTest({
62-
providers: {
63-
claudeAgent: { homePath: input.claudeHomePath },
64-
codex: { homePath: input.codexHomePath },
62+
// Default slots point at the fixture homes; explicit test instances
63+
// replace a slot with the same id.
64+
providerInstances: {
65+
[ProviderInstanceId.make("claudeAgent")]: {
66+
driver: ProviderDriverKind.make("claudeAgent"),
67+
config: { homePath: input.claudeHomePath },
68+
},
69+
[ProviderInstanceId.make("codex")]: {
70+
driver: ProviderDriverKind.make("codex"),
71+
config: { homePath: input.codexHomePath },
72+
},
73+
...input.providerInstances,
6574
},
66-
...(input.providerInstances === undefined
67-
? {}
68-
: { providerInstances: input.providerInstances }),
6975
}),
7076
ServerConfig.layerTest(
7177
input.claudeHomePath,
@@ -533,7 +539,7 @@ it.layer(NodeServices.layer)("AgentSessionScanner", (it) => {
533539
}),
534540
);
535541

536-
it.effect("uses explicit provider instance homes instead of overridden legacy homes", () =>
542+
it.effect("uses explicit default-slot homes instead of the fixture homes", () =>
537543
Effect.gen(function* () {
538544
const path = yield* Path.Path;
539545
const claudeHomePath = yield* makeTempDir("t3code-claude-legacy-");

‎apps/server/src/project/AgentSessionScanner.ts‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,16 +1102,15 @@ export const make = Effect.gen(function* () {
11021102
instanceId: ProviderInstanceId.make(instanceId),
11031103
config,
11041104
}));
1105+
// The built-in default instance runs with default config when settings
1106+
// have no entry for it.
11051107
if (!Object.hasOwn(settings.providerInstances, source)) {
1106-
const legacyInstance = {
1108+
const defaultInstance = {
11071109
instanceId: ProviderInstanceId.make(source),
1108-
config: {
1109-
driver: ProviderDriverKind.make(source),
1110-
config: settings.providers[source],
1111-
},
1110+
config: { driver: ProviderDriverKind.make(source) },
11121111
};
1113-
if (resolveProviderInstanceEnabled(legacyInstance.config)) {
1114-
instances.push(legacyInstance);
1112+
if (resolveProviderInstanceEnabled(defaultInstance.config)) {
1113+
instances.push(defaultInstance);
11151114
}
11161115
}
11171116

‎apps/server/src/provider/Drivers/AcpRegistryDriver.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ export const AcpRegistryDriver: ProviderDriver<AcpRegistrySettings, AcpRegistryD
467467
metadata: {
468468
displayName: "ACP Registry",
469469
supportsMultipleInstances: true,
470+
hasDefaultInstance: false,
470471
},
471472
configSchema: AcpRegistrySettings,
472473
defaultConfig: () => decodeSettings({}),

‎apps/server/src/provider/ProviderInstanceRegistryHydration.ts‎

Lines changed: 10 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,10 @@
22
* ProviderInstanceRegistryHydration — derive a `ProviderInstanceConfigMap`
33
* from `ServerSettings` and keep `ProviderInstanceRegistry` in sync with it.
44
*
5-
* The server still reads two shapes:
6-
*
7-
* 1. `settings.providerInstances` — the new driver-agnostic map the
8-
* registry expects. Keyed by `ProviderInstanceId`, values are
9-
* `ProviderInstanceConfig` envelopes.
10-
* 2. `settings.providers.<kind>` — the legacy single-instance-per-driver
11-
* fields (`providers.codex`, `providers.claudeAgent`, …). These are
12-
* the source of truth for every deployment that hasn't been migrated
13-
* yet to an explicit `providerInstances` entry.
14-
*
15-
* This module bridges (2) into (1) and wires the resulting map into a
16-
* mutable registry. For every built-in driver whose id is not already
17-
* present in `providerInstances` (keyed on
18-
* `defaultInstanceIdForDriver(driverKind)` — literally the driver kind as a
19-
* routing slug), we synthesize an envelope from the legacy field. The
20-
* registry decodes both flavours through the same `configSchema` and ends
21-
* up with one uniform `ProviderInstance` per entry.
22-
*
23-
* Explicit `providerInstances` entries always win — users can already
24-
* override the legacy `providers.<kind>` blob by authoring a
25-
* `providerInstances.codex` entry with a matching driver, and we don't
26-
* want the synthesized envelope to silently stomp their config.
5+
* `settings.providerInstances` is the source of truth. Every built-in driver
6+
* with a default instance also runs at `defaultInstanceIdForDriver(kind)`
7+
* when that slot has no entry, using the driver's default config, so a fresh
8+
* install shows its built-in providers without writing settings first.
279
*
2810
* Hot-reload
2911
* ----------
@@ -76,46 +58,20 @@ type ProviderInstanceRegistryHydrationEnv =
7658
| ServerConfig.ServerConfig;
7759

7860
/**
79-
* Synthesize a `ProviderInstanceConfigMap` from a `ServerSettings` snapshot.
80-
*
81-
* Strategy:
82-
* 1. Copy all explicit `settings.providerInstances` entries verbatim.
83-
* 2. For each built-in driver whose `defaultInstanceIdForDriver(id)` key
84-
* is *not* already in the explicit map, synthesize an entry from the
85-
* matching legacy `settings.providers.<kind>` blob.
86-
*
87-
* The returned map is the input the registry consumes; pure & exported
88-
* separately so the hydration logic can be exercised by unit tests
89-
* without layering.
61+
* Explicit `providerInstances` entries plus an implicit default instance for
62+
* each built-in driver whose default slot is empty. Pure so the hydration
63+
* rule can be tested without layers.
9064
*/
9165
export const deriveProviderInstanceConfigMap = (
9266
settings: ServerSettings,
9367
): ProviderInstanceConfigMap => {
9468
const merged: Record<string, ProviderInstanceConfig> = { ...settings.providerInstances };
9569

9670
for (const driver of BUILT_IN_DRIVERS) {
71+
if (driver.metadata.hasDefaultInstance === false) continue;
9772
const instanceId = defaultInstanceIdForDriver(driver.driverKind);
98-
if (instanceId in merged) {
99-
// Explicit `providerInstances` entry for this slot — user-authored
100-
// config always wins over the legacy mirror.
101-
continue;
102-
}
103-
104-
// Only built-in drivers have a legacy mirror; the registry's
105-
// `providers` struct is keyed on the same literal slug as
106-
// `driverKind`. Access is dynamic (the driver kind is a branded string),
107-
// but it's constrained to `keyof settings.providers` by the union of
108-
// built-in driver kinds.
109-
const legacyKey = driver.driverKind as keyof ServerSettings["providers"];
110-
const legacyConfig = settings.providers[legacyKey];
111-
if (legacyConfig === undefined) {
112-
continue;
113-
}
114-
115-
merged[instanceId] = {
116-
driver: driver.driverKind,
117-
config: legacyConfig,
118-
};
73+
if (instanceId in merged) continue;
74+
merged[instanceId] = { driver: driver.driverKind };
11975
}
12076

12177
return merged as ProviderInstanceConfigMap;

‎apps/server/src/provider/ProviderRegistry.test.ts‎

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ const decodeServerSettings = Schema.decodeSync(ServerSettings);
6868
const encodeServerSettings = Schema.encodeSync(ServerSettings);
6969
const encodedDefaultServerSettings = encodeServerSettings(DEFAULT_SERVER_SETTINGS);
7070

71+
/** Default slots that settings mark disabled, so their probes never spawn. */
72+
const disabledDefaultSlots = (
73+
...drivers: ReadonlyArray<string>
74+
): ContractServerSettings["providerInstances"] =>
75+
Object.fromEntries(
76+
drivers.map((driver) => [
77+
ProviderInstanceId.make(driver),
78+
{ driver: ProviderDriverKind.make(driver), enabled: false },
79+
]),
80+
);
81+
7182
const defaultClaudeSettings: ClaudeSettings = Schema.decodeSync(ClaudeSettings)({});
7283
const defaultCodexSettings: CodexSettings = Schema.decodeSync(CodexSettings)({});
7384
const decodeCodexSettings = Schema.decodeSync(CodexSettings);
@@ -2663,24 +2674,18 @@ it.layer(
26632674
const serverSettings = yield* makeMutableServerSettingsService(
26642675
decodeServerSettings(
26652676
deepMerge(encodedDefaultServerSettings, {
2666-
providers: {
2667-
// Disable every built-in probe that would otherwise spawn
2668-
// on the CI host. `enabled: false` short-circuits each
2669-
// driver's probe *before* it touches the spawner, so the
2670-
// test environment stays isolated from the dev
2671-
// machine's PATH.
2672-
codex: { enabled: false },
2673-
claudeAgent: { enabled: false },
2674-
cursor: { enabled: false },
2675-
grok: { enabled: false },
2676-
opencode: { enabled: false },
2677-
},
26782677
// `providerInstances` keys are branded `ProviderInstanceId`;
26792678
// the branded index signature rejects plain string literals
26802679
// at the TS level even though the runtime schema happily
26812680
// accepts + decodes them. Cast the patch to `unknown` so
26822681
// the `Schema.decodeSync` below does the real validation.
26832682
providerInstances: {
2683+
// Disable every built-in probe that would otherwise spawn
2684+
// on the CI host. `enabled: false` short-circuits each
2685+
// driver's probe *before* it touches the spawner, so the
2686+
// test environment stays isolated from the dev
2687+
// machine's PATH.
2688+
...disabledDefaultSlots("codex", "claudeAgent", "cursor", "grok", "opencode"),
26842689
// Matches the shape the user had in `.t3/dev/settings.json`
26852690
// when the bug was reported: a custom enabled Codex instance
26862691
// pointing at a binary the server has to actually spawn.
@@ -2781,12 +2786,13 @@ it.layer(
27812786
const mutableServerSettings = yield* makeMutableServerSettingsService(
27822787
decodeServerSettings(
27832788
deepMerge(encodedDefaultServerSettings, {
2784-
providers: {
2785-
codex: { enabled: true, binaryPath: firstMissing },
2786-
claudeAgent: { enabled: false },
2787-
cursor: { enabled: false },
2788-
grok: { enabled: false },
2789-
opencode: { enabled: false },
2789+
providerInstances: {
2790+
...disabledDefaultSlots("claudeAgent", "cursor", "grok", "opencode"),
2791+
[ProviderInstanceId.make("codex")]: {
2792+
driver: ProviderDriverKind.make("codex"),
2793+
enabled: true,
2794+
config: { binaryPath: firstMissing },
2795+
},
27902796
},
27912797
}),
27922798
),
@@ -2871,8 +2877,13 @@ it.layer(
28712877
),
28722878
);
28732879
yield* serverSettings.updateSettings({
2874-
providers: {
2875-
codex: { enabled: true, binaryPath: secondMissing },
2880+
providerInstances: {
2881+
...disabledDefaultSlots("claudeAgent", "cursor", "grok", "opencode"),
2882+
[ProviderInstanceId.make("codex")]: {
2883+
driver: ProviderDriverKind.make("codex"),
2884+
enabled: true,
2885+
config: { binaryPath: secondMissing },
2886+
},
28762887
},
28772888
});
28782889
// Start the lazy stream only after publishing. A watcher that did
@@ -2900,14 +2911,8 @@ it.layer(
29002911
const serverSettings = yield* makeMutableServerSettingsService(
29012912
decodeServerSettings(
29022913
deepMerge(encodedDefaultServerSettings, {
2903-
providers: {
2904-
codex: { enabled: false },
2905-
claudeAgent: { enabled: false },
2906-
cursor: { enabled: false },
2907-
grok: { enabled: false },
2908-
opencode: { enabled: false },
2909-
},
29102914
providerInstances: {
2915+
...disabledDefaultSlots("codex", "claudeAgent", "cursor", "grok", "opencode"),
29112916
ghost_main: {
29122917
driver: "ghostDriver",
29132918
displayName: "A fork-only driver we don't ship",
@@ -2971,14 +2976,7 @@ it.layer(
29712976
const serverSettings = yield* makeMutableServerSettingsService(
29722977
decodeServerSettings(
29732978
deepMerge(encodedDefaultServerSettings, {
2974-
providers: {
2975-
codex: {
2976-
enabled: false,
2977-
},
2978-
grok: {
2979-
enabled: false,
2980-
},
2981-
},
2979+
providerInstances: disabledDefaultSlots("codex", "grok"),
29822980
}),
29832981
),
29842982
);

‎apps/server/src/provider/providerInstallation.test.ts‎

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,14 @@ describe("provider installation routing", () => {
147147
it.effect("keeps external installs manual without hiding shared install status", () =>
148148
Effect.gen(function* () {
149149
const harness = yield* makeHarness({
150-
settings: { providers: { antigravity: { binaryPath: "/external/agy" } } },
150+
settings: {
151+
providerInstances: {
152+
[ProviderInstanceId.make("antigravity")]: {
153+
driver: ProviderDriverKind.make("antigravity"),
154+
config: { binaryPath: "/external/agy" },
155+
},
156+
},
157+
},
151158
});
152159
const start = yield* Effect.flip(harness.router.start({ instanceId }));
153160
const remove = yield* Effect.flip(harness.router.remove({ instanceId }));
@@ -164,7 +171,14 @@ describe("provider installation routing", () => {
164171
const codexId = ProviderInstanceId.make("codex");
165172
const harness = yield* makeHarness({
166173
instance: instance(ProviderDriverKind.make("codex"), codexId),
167-
settings: { providers: { codex: { setupMode: "managed" } } },
174+
settings: {
175+
providerInstances: {
176+
[ProviderInstanceId.make("codex")]: {
177+
driver: ProviderDriverKind.make("codex"),
178+
config: { setupMode: "managed" },
179+
},
180+
},
181+
},
168182
});
169183
assert.equal((yield* harness.router.start({ instanceId: codexId })).driver, "codex");
170184
yield* harness.router.cancel({ instanceId: codexId, operationId: "operation" });
@@ -180,7 +194,14 @@ describe("provider installation routing", () => {
180194
const codexId = ProviderInstanceId.make("codex");
181195
const harness = yield* makeHarness({
182196
instance: instance(ProviderDriverKind.make("codex"), codexId),
183-
settings: { providers: { codex: { setupMode: "existing" } } },
197+
settings: {
198+
providerInstances: {
199+
[ProviderInstanceId.make("codex")]: {
200+
driver: ProviderDriverKind.make("codex"),
201+
config: { setupMode: "existing" },
202+
},
203+
},
204+
},
184205
});
185206
assert.include(
186207
(yield* Effect.flip(harness.router.start({ instanceId: codexId }))).detail,

‎apps/server/src/server.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,7 @@ const layerRuntimeCoreDependenciesBase = Layer.mergeAll(
583583
// The instance registry is the new routing keystone — text generation,
584584
// adapter lookup, and runtime ingestion all resolve `ProviderInstanceId`
585585
// through this layer. Built-in drivers come from `BUILT_IN_DRIVERS`;
586-
// `providerInstances` hydration merges `settings.providers.<kind>`
587-
// with explicit `providerInstances` entries on boot.
586+
// hydration adds their default instances to `providerInstances` on boot.
588587
Layer.provideMerge(ProviderInstanceRegistryHydration.layer),
589588
Layer.provideMerge(
590589
Layer.mergeAll(

0 commit comments

Comments
 (0)