@@ -386,10 +386,17 @@ export const layer = Layer.effect(
386386 }
387387 fallbackByInstance . set ( source . instanceId , provider ) ;
388388 }
389+ // Read after the snapshots: a snapshot read as awaiting is the pre-check placeholder.
390+ const awaitingBootInstances = new Set < ProviderInstance > ( ) ;
391+ for ( const instance of bootInstances ) {
392+ if ( yield * instance . snapshot . isAwaitingFirstCheck ?? Effect . succeed ( false ) ) {
393+ awaitingBootInstances . add ( instance ) ;
394+ }
395+ }
389396
390- const cachedProviders = yield * Effect . forEach (
397+ const bootProviders = yield * Effect . forEach (
391398 bootSources ,
392- ( source ) =>
399+ ( source , index ) =>
393400 Effect . gen ( function * ( ) {
394401 const filePath = yield * resolveProviderStatusCachePath ( {
395402 cacheDir : config . providerStatusCacheDir ,
@@ -399,11 +406,15 @@ export const layer = Layer.effect(
399406 if ( fallbackProvider === undefined ) {
400407 return undefined ;
401408 }
409+ // A completed check is seeded by the boot upsert instead, which persists it.
410+ const placeholder = awaitingBootInstances . has ( bootInstances [ index ] ! )
411+ ? fallbackProvider
412+ : undefined ;
402413 return yield * readProviderStatusCache ( filePath ) . pipe (
403414 Effect . provideService ( FileSystem . FileSystem , fileSystem ) ,
404415 Effect . flatMap ( ( cachedProvider ) => {
405416 if ( cachedProvider === undefined ) {
406- return Effect . void . pipe ( Effect . as ( undefined as ServerProvider | undefined ) ) ;
417+ return Effect . succeed ( placeholder ) ;
407418 }
408419 const correlation = {
409420 cachedProvider,
@@ -416,7 +427,7 @@ export const layer = Layer.effect(
416427 cachedInstanceId : cachedProvider . instanceId ?? null ,
417428 driver : source . driverKind ,
418429 cachedDriver : cachedProvider . driver ?? null ,
419- } ) . pipe ( Effect . as ( undefined as ServerProvider | undefined ) ) ;
430+ } ) . pipe ( Effect . as ( placeholder ) ) ;
420431 }
421432 return Effect . succeed ( hydrateCachedProvider ( correlation ) ) ;
422433 } ) ,
@@ -441,7 +452,7 @@ export const layer = Layer.effect(
441452 ModelManifest . BUNDLED_MODEL_MANIFEST . compatibility ,
442453 ) ;
443454 const providersRef = yield * Ref . make < ReadonlyArray < ServerProvider > > (
444- cachedProviders . map ( ( provider ) => classifyCompatibility ( provider , initialManifest ) ) ,
455+ bootProviders . map ( ( provider ) => classifyCompatibility ( provider , initialManifest ) ) ,
445456 ) ;
446457 const workspaceRefreshesRef = yield * Ref . make <
447458 ReadonlyMap < ProviderInstance , ReadonlyMap < string , Deferred . Deferred < void > > >
@@ -551,21 +562,24 @@ export const layer = Layer.effect(
551562 } ) ;
552563
553564 const compatibilityRefreshRunning = yield * Ref . make ( false ) ;
554- const syncProvider = Effect . fn ( "syncProvider" ) ( function * (
555- provider : ServerProvider ,
556- options ?: {
557- readonly publish ?: boolean ;
558- } ,
559- ) {
560- const providers = yield * upsertProviders ( [ provider ] , options ) ;
561- // Reclassify the current model after fetch; republishing the old probe could overwrite newer health results.
565+ // Reclassify the current model after fetch; republishing the old probe could overwrite newer health results.
566+ const refreshCompatibility = Effect . gen ( function * ( ) {
562567 if ( ! ( yield * Ref . getAndSet ( compatibilityRefreshRunning , true ) ) ) {
563568 yield * manifestService . refresh . pipe (
564569 Effect . andThen ( upsertProviders ( [ ] , { persist : false } ) ) ,
565570 Effect . ensuring ( Ref . set ( compatibilityRefreshRunning , false ) ) ,
566571 Effect . forkIn ( serviceScope ) ,
567572 ) ;
568573 }
574+ } ) ;
575+ const syncProvider = Effect . fn ( "syncProvider" ) ( function * (
576+ provider : ServerProvider ,
577+ options ?: {
578+ readonly publish ?: boolean ;
579+ } ,
580+ ) {
581+ const providers = yield * upsertProviders ( [ provider ] , options ) ;
582+ yield * refreshCompatibility ;
569583 return providers ;
570584 } ) ;
571585
@@ -861,6 +875,13 @@ export const layer = Layer.effect(
861875 Effect . gen ( function * ( ) {
862876 const source = buildSnapshotSource ( instance ) ;
863877 const provider = yield * source . getSnapshot ;
878+ // Boot shows the cached status until this instance's first check publishes a result.
879+ if (
880+ awaitingBootInstances . has ( instance ) &&
881+ ( yield * instance . snapshot . isAwaitingFirstCheck ?? Effect . succeed ( false ) )
882+ ) {
883+ return yield * refreshCompatibility ;
884+ }
864885 yield * correlateSnapshotWithSource ( source , provider ) . pipe (
865886 Effect . flatMap ( syncProvider ) ,
866887 ) ;
@@ -918,7 +939,10 @@ export const layer = Layer.effect(
918939 Scope . provide ( serviceScope ) ,
919940 ) ;
920941
921- yield * upsertProviders ( fallbackProviders , { publish : false } ) ;
942+ yield * upsertProviders (
943+ fallbackProviders . filter ( ( _ , index ) => ! awaitingBootInstances . has ( bootInstances [ index ] ! ) ) ,
944+ { publish : false } ,
945+ ) ;
922946 const instanceChanges = yield * instanceRegistry . subscribeChanges ;
923947 yield * syncLiveSources ;
924948 yield * Stream . runForEach (
0 commit comments