@@ -293,9 +293,11 @@ describe("Codex supervision catalog", () => {
293293 tempDirs . push ( root ) ;
294294 const alphaAgentDir = path . join ( root , "agents" , "alpha" , "agent" ) ;
295295 const betaAgentDir = path . join ( root , "agents" , "beta" , "agent" ) ;
296+ const fileAgentDir = path . join ( root , "agents" , "file" , "agent" ) ;
296297 const processCodexHome = path . join ( root , "process-codex-home" ) ;
297298 const alphaCodexHome = resolveCodexAppServerHomeDir ( alphaAgentDir ) ;
298299 const betaCodexHome = resolveCodexAppServerHomeDir ( betaAgentDir ) ;
300+ const fileAgentCodexHome = resolveCodexAppServerHomeDir ( fileAgentDir ) ;
299301 const configuredCodexHomes = Array . from ( { length : MAX_HOST_COUNT } , ( _ , index ) =>
300302 path . join ( root , "configured-codex-home" , String ( index ) ) ,
301303 ) ;
@@ -310,13 +312,17 @@ describe("Codex supervision catalog", () => {
310312 await Promise . all ( [
311313 fs . symlink ( configuredCodexHome , configuredCodexHomeAlias , "dir" ) ,
312314 fs . writeFile ( configuredFile , "not a directory" ) ,
315+ fs
316+ . mkdir ( fileAgentDir , { recursive : true } )
317+ . then ( ( ) => fs . writeFile ( fileAgentCodexHome , "not a directory" ) ) ,
313318 ] ) ;
314319 const runtimeConfig = {
315320 agents : {
316321 ownership : "explicit" ,
317322 list : [
318323 { id : "alpha" , agentDir : alphaAgentDir } ,
319324 { id : "beta" , agentDir : betaAgentDir } ,
325+ { id : "file" , agentDir : fileAgentDir } ,
320326 ] ,
321327 } ,
322328 } as OpenClawConfig ;
@@ -331,11 +337,13 @@ describe("Codex supervision catalog", () => {
331337 sessionCatalog : {
332338 homes : [
333339 configuredCodexHome ,
334- configuredCodexHomeAlias ,
340+ { path : configuredCodexHomeAlias , label : "Duplicate alias" } ,
341+ { path : configuredCodexHomes [ 1 ] ! , label : "Named store" } ,
342+ { path : configuredCodexHomes [ 2 ] ! } ,
335343 alphaCodexHome ,
336344 path . join ( root , "missing-codex-home" ) ,
337345 configuredFile ,
338- ...configuredCodexHomes . slice ( 1 ) ,
346+ ...configuredCodexHomes . slice ( 3 ) ,
339347 ] ,
340348 } ,
341349 } ) ,
@@ -350,6 +358,11 @@ describe("Codex supervision catalog", () => {
350358 expect ( resolvedHomes . filter ( ( home ) => configuredCodexHomes . includes ( home ) ) ) . toHaveLength (
351359 MAX_HOST_COUNT - 3 ,
352360 ) ;
361+ expect ( homes . slice ( 3 , 6 ) . map ( ( home ) => home . label ) ) . toEqual ( [
362+ "Local Codex · 0" ,
363+ "Local Codex · Named store" ,
364+ "Local Codex · 2" ,
365+ ] ) ;
353366 expect ( homes . map ( ( home ) => home . agentDir ) ) . toEqual ( Array ( MAX_HOST_COUNT ) . fill ( betaAgentDir ) ) ;
354367 expect ( homes [ 0 ] ?. hostId ) . toBe ( CODEX_LOCAL_SESSION_HOST_ID ) ;
355368 expect ( homes . slice ( 1 ) . every ( ( home ) => home . hostId . startsWith ( "gateway:local:" ) ) ) . toBe ( true ) ;
@@ -423,19 +436,19 @@ describe("Codex supervision catalog", () => {
423436 } ,
424437 } as OpenClawConfig ;
425438 let runtimeConfig = configA ;
426- const existsSync = vi . spyOn ( fsSync , "existsSync " ) ;
439+ const statSync = vi . spyOn ( fsSync , "statSync " ) ;
427440 try {
428441 const resolver = createCodexCatalogHomeResolver ( {
429442 config : configA ,
430443 getRuntimeConfig : ( ) => runtimeConfig ,
431444 getPluginConfig : ( ) => ( { supervision : { enabled : true } } ) ,
432445 env : { ...process . env , CODEX_HOME : processCodexHome } ,
433446 } ) ;
434- const seedDiscoveryCount = existsSync . mock . calls . length ;
447+ const seedDiscoveryCount = statSync . mock . calls . length ;
435448
436449 expect ( resolver . forAgent ( "alpha" ) ) . not . toHaveLength ( 0 ) ;
437450 expect ( resolver . forAgent ( "alpha" ) ) . not . toHaveLength ( 0 ) ;
438- expect ( existsSync ) . toHaveBeenCalledTimes ( seedDiscoveryCount ) ;
451+ expect ( statSync ) . toHaveBeenCalledTimes ( seedDiscoveryCount ) ;
439452
440453 runtimeConfig = configB ;
441454 const betaHomes = resolver . forAgent ( "beta" ) ;
@@ -446,12 +459,12 @@ describe("Codex supervision catalog", () => {
446459 betaCodexHome ,
447460 ) ,
448461 ) . toBe ( true ) ;
449- const reloadedDiscoveryCount = existsSync . mock . calls . length ;
462+ const reloadedDiscoveryCount = statSync . mock . calls . length ;
450463
451464 expect ( resolver . forAgent ( "beta" ) ) . toEqual ( betaHomes ) ;
452- expect ( existsSync ) . toHaveBeenCalledTimes ( reloadedDiscoveryCount ) ;
465+ expect ( statSync ) . toHaveBeenCalledTimes ( reloadedDiscoveryCount ) ;
453466 } finally {
454- existsSync . mockRestore ( ) ;
467+ statSync . mockRestore ( ) ;
455468 }
456469 } ) ;
457470
0 commit comments