@@ -63,6 +63,7 @@ import * as Orchestrator from "../Orchestrator.ts";
6363import * as ProviderReplayHarness from "../testkit/ProviderReplayHarness.ts" ;
6464import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter" ;
6565import type * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests" ;
66+ import { symlinksSupported } from "@t3tools/shared/testing/symlinks" ;
6667import * as CodexAdapterV2 from "./CodexAdapterV2.ts" ;
6768import { makeReplayServerConfig , withCodexReplayChildMetadata } from "./CodexAdapterV2.testkit.ts" ;
6869import * as CodexAdapterV2Testkit from "./CodexAdapterV2.testkit.ts" ;
@@ -784,6 +785,68 @@ describe("CodexAdapterV2 process spawning", () => {
784785 } ) . pipe ( Effect . provideService ( HostProcess . Platform , "linux" ) ) ,
785786 ) ;
786787
788+ it . effect . each ( [ undefined , "/explicit/sqlite" ] ) (
789+ "keeps shadow app-server SQLite together, honoring an explicit home: %s" ,
790+ ( sqliteHome ) =>
791+ Effect . gen ( function * ( ) {
792+ const fs = yield * FileSystem . FileSystem ;
793+ const path = yield * Path . Path ;
794+ const root = yield * fs . makeTempDirectoryScoped ( { prefix : "t3-codex-sqlite-launch-" } ) ;
795+ const sharedHome = path . join ( root , "shared" ) ;
796+ const shadowHome = path . join ( root , "shadow" ) ;
797+ const environments : Array < NodeJS . ProcessEnv > = [ ] ;
798+ const spawner = ChildProcessSpawner . make ( ( command ) => {
799+ if ( ChildProcess . isStandardCommand ( command ) ) environments . push ( command . options . env ?? { } ) ;
800+ return Effect . fail (
801+ PlatformError . systemError ( {
802+ _tag : "NotFound" ,
803+ module : "ChildProcess" ,
804+ method : "spawn" ,
805+ } ) ,
806+ ) ;
807+ } ) ;
808+ const adapter = yield * CodexAdapterV2 . createCodexAdapterV2 ( {
809+ instanceId : CodexAdapterV2 . CODEX_DEFAULT_INSTANCE_ID ,
810+ displayName : undefined ,
811+ environment :
812+ sqliteHome === undefined
813+ ? [ ]
814+ : [ { name : "CODEX_SQLITE_HOME" , value : sqliteHome , sensitive : false } ] ,
815+ enabled : true ,
816+ config : { ...DEFAULT_CODEX_SETTINGS , homePath : sharedHome , shadowHomePath : shadowHome } ,
817+ } ) . pipe (
818+ Effect . provide (
819+ Layer . mergeAll (
820+ CodexAdapterV2 . layerAppServerClientFactory ,
821+ ServerConfig . layerTest ( process . cwd ( ) , { prefix : "t3-codex-sqlite-" } ) ,
822+ ) ,
823+ ) ,
824+ Effect . provideService ( ChildProcessSpawner . ChildProcessSpawner , spawner ) ,
825+ Effect . provideService (
826+ ProviderEventLoggers . ProviderEventLoggers ,
827+ ProviderEventLoggers . NoOpProviderEventLoggers ,
828+ ) ,
829+ ) ;
830+ yield * adapter
831+ . openSession ( {
832+ threadId : ThreadId . make ( "thread-sqlite" ) ,
833+ providerSessionId : ProviderSessionId . make ( "provider-session-sqlite" ) ,
834+ modelSelection : CODEX_TEST_MODEL_SELECTION ,
835+ runtimePolicy : CODEX_TEST_RUNTIME_POLICY ,
836+ } )
837+ . pipe ( Effect . scoped , Effect . exit ) ;
838+ assert . lengthOf ( environments , 1 ) ;
839+ assert . equal ( environments [ 0 ] ?. CODEX_HOME , shadowHome ) ;
840+ assert . equal ( environments [ 0 ] ?. CODEX_SQLITE_HOME , sqliteHome ?? sharedHome ) ;
841+ } ) . pipe (
842+ Effect . provide (
843+ Layer . mergeAll ( IdAllocator . layer , McpProviderSessions . layer , NodeServices . layer ) ,
844+ ) ,
845+ Effect . provideService ( HostProcess . Environment , { } ) ,
846+ ) ,
847+ { skip : ! symlinksSupported } ,
848+ ) ;
849+
787850 it . effect ( "expands ~ in the configured binary path before spawning" , ( ) =>
788851 Effect . gen ( function * ( ) {
789852 const spawnedCommands : Array < string > = [ ] ;
0 commit comments