@@ -1944,7 +1944,8 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsModule.layerTest(), Te
19441944 const firstMissing = `t3code_codex_first_` ;
19451945 const secondMissing = `t3code_codex_second_` ;
19461946 const spawnedCommands : Array < string > = [ ] ;
1947- const serverSettings = yield * makeMutableServerSettingsService (
1947+ const allowLazySettingsStream = yield * Deferred . make < void > ( ) ;
1948+ const mutableServerSettings = yield * makeMutableServerSettingsService (
19481949 decodeServerSettings (
19491950 deepMerge ( encodedDefaultServerSettings , {
19501951 providers : {
@@ -1957,6 +1958,14 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsModule.layerTest(), Te
19571958 } ) ,
19581959 ) ,
19591960 ) ;
1961+ const serverSettings = {
1962+ ...mutableServerSettings ,
1963+ streamChanges : Stream . unwrap (
1964+ Deferred . await ( allowLazySettingsStream ) . pipe (
1965+ Effect . as ( mutableServerSettings . streamChanges ) ,
1966+ ) ,
1967+ ) ,
1968+ } satisfies ServerSettingsModule . ServerSettingsService [ "Service" ] ;
19601969 const scope = yield * Scope . make ( ) ;
19611970 yield * Effect . addFinalizer ( ( ) => Scope . close ( scope , Exit . void ) ) ;
19621971 const providerRegistryLayer = ProviderRegistryLive . pipe (
@@ -2016,7 +2025,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsModule.layerTest(), Te
20162025 assert . deepStrictEqual ( spawnedCommands , [ firstMissing ] ) ;
20172026
20182027 // Drive a settings change. The Hydration layer's
2019- // `SettingsWatcherLive` consumes this via `streamChanges `,
2028+ // `SettingsWatcherLive` consumes this via `subscribeChanges `,
20202029 // calls `reconcile`, which rebuilds the codex instance (the
20212030 // envelope changed because `binaryPath` differs → `entryEqual`
20222031 // is false). The registry's `Stream.runForEach(
@@ -2028,6 +2037,9 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsModule.layerTest(), Te
20282037 codex : { enabled : true , binaryPath : secondMissing } ,
20292038 } ,
20302039 } ) ;
2040+ // Start the lazy stream only after publishing. A watcher that did
2041+ // not subscribe before forking has already lost this update.
2042+ yield * Deferred . succeed ( allowLazySettingsStream , undefined ) ;
20312043
20322044 // Poll until the injected process boundary observes the new
20332045 // executable. This verifies the public settings-to-probe behavior
0 commit comments