Skip to content

Commit e58be7a

Browse files
t3dotggclaude
andcommitted
fix(server): stop provider checks from joining the manifest fetch
Drivers now fork the TTL-gated refresh into their instance scope and classify with the in-memory manifest, so a slow or hung GitHub fetch never delays a provider check. A refresh that lands mid-probe applies on the next check. Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent 1c6bad3 commit e58be7a

3 files changed

Lines changed: 37 additions & 24 deletions

File tree

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

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv> = {
128128
const serverSettings = yield* ServerSettingsService;
129129
const eventLoggers = yield* ProviderEventLoggers;
130130
const modelManifest = yield* ModelManifest.ModelManifest;
131+
const instanceScope = yield* Effect.scope;
131132
const processEnv = mergeProviderInstanceEnvironment(environment);
132133
const fallbackContinuationIdentity = defaultProviderContinuationIdentity({
133134
driverKind: DRIVER_KIND,
@@ -166,20 +167,24 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv> = {
166167
});
167168
const capabilitiesCacheKey = yield* makeClaudeCapabilitiesCacheKey(effectiveConfig, cwd);
168169

169-
// The manifest refresh runs concurrently with the CLI probe, so a
170-
// TTL-expired fetch adds no wall-clock to the provider check.
171-
const checkProvider = Effect.zipWith(
172-
checkClaudeProviderStatus(
173-
effectiveConfig,
174-
() => Cache.get(capabilitiesProbeCache, capabilitiesCacheKey),
175-
processEnv,
176-
cwd,
170+
// Kick the TTL-gated manifest refresh in the background and classify
171+
// with the in-memory manifest, so a slow or hung fetch never delays the
172+
// provider check. A refresh that lands mid-probe applies on the next one.
173+
const checkProvider = Effect.forkIn(modelManifest.refreshed, instanceScope).pipe(
174+
Effect.andThen(
175+
Effect.zipWith(
176+
checkClaudeProviderStatus(
177+
effectiveConfig,
178+
() => Cache.get(capabilitiesProbeCache, capabilitiesCacheKey),
179+
processEnv,
180+
cwd,
181+
),
182+
modelManifest.current,
183+
(draft, manifest) =>
184+
stampIdentity(ModelManifest.applyModelManifest(draft, manifest, DRIVER_KIND)),
185+
{ concurrent: true },
186+
),
177187
),
178-
modelManifest.refreshed,
179-
(draft, manifest) =>
180-
stampIdentity(ModelManifest.applyModelManifest(draft, manifest, DRIVER_KIND)),
181-
{ concurrent: true },
182-
).pipe(
183188
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
184189
Effect.provideService(FileSystem.FileSystem, fileSystem),
185190
Effect.provideService(Path.Path, path),

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

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export const CodexDriver: ProviderDriver<CodexSettings, CodexDriverEnv> = {
122122
const serverSettings = yield* ServerSettingsService;
123123
const eventLoggers = yield* ProviderEventLoggers;
124124
const modelManifest = yield* ModelManifest.ModelManifest;
125+
const instanceScope = yield* Effect.scope;
125126
const processEnv = mergeProviderInstanceEnvironment(environment);
126127
const homeLayout = yield* resolveCodexHomeLayout(config);
127128
const continuationIdentity = codexContinuationIdentity(homeLayout);
@@ -169,15 +170,21 @@ export const CodexDriver: ProviderDriver<CodexSettings, CodexDriverEnv> = {
169170
// in as instance rebuilds from the registry rather than in-place
170171
// updates. Pre-provide `ChildProcessSpawner` so the check fits
171172
// `makeManagedServerProvider.checkProvider`'s `R = never`.
172-
// The manifest refresh runs concurrently with the CLI probe, so a
173-
// TTL-expired fetch adds no wall-clock to the provider check.
174-
const checkProvider = Effect.zipWith(
175-
checkCodexProviderStatus(effectiveConfig, undefined, processEnv),
176-
modelManifest.refreshed,
177-
(draft, manifest) =>
178-
stampIdentity(ModelManifest.applyModelManifest(draft, manifest, DRIVER_KIND)),
179-
{ concurrent: true },
180-
).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner));
173+
// Kick the TTL-gated manifest refresh in the background and classify
174+
// with the in-memory manifest, so a slow or hung fetch never delays the
175+
// provider check. A refresh that lands mid-probe applies on the next one.
176+
const checkProvider = Effect.forkIn(modelManifest.refreshed, instanceScope).pipe(
177+
Effect.andThen(
178+
Effect.zipWith(
179+
checkCodexProviderStatus(effectiveConfig, undefined, processEnv),
180+
modelManifest.current,
181+
(draft, manifest) =>
182+
stampIdentity(ModelManifest.applyModelManifest(draft, manifest, DRIVER_KIND)),
183+
{ concurrent: true },
184+
),
185+
),
186+
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
187+
);
181188
const snapshotSettings = makeProviderSnapshotSettingsSource(effectiveConfig, serverSettings);
182189
const snapshot = yield* makeManagedServerProvider<ProviderSnapshotSettings<CodexSettings>>({
183190
maintenanceCapabilities,

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ export class ModelManifest extends Context.Service<
121121
/** Manifest already in memory (disk cache or bundle); never fetches.
122122
* For pending snapshots, which must publish instantly. */
123123
readonly current: Effect.Effect<ModelManifestData>;
124-
/** Manifest after a TTL-gated remote refresh; never fails.
125-
* For provider checks, which already tolerate multi-second probes. */
124+
/** Manifest after a TTL-gated remote refresh; never fails. Drivers fork
125+
* this into their instance scope and classify with `current`, so a slow
126+
* fetch delays nothing and the next check applies the update. */
126127
readonly refreshed: Effect.Effect<ModelManifestData>;
127128
}
128129
>()("t3/provider/ModelManifest") {}

0 commit comments

Comments
 (0)