@@ -2090,11 +2090,20 @@ test('background reservation exposes one private invocation, which is single-use
20902090 const privateAuth = { executionCapability : capability , jobId : reserved . json . job . id } ;
20912091 const first = await companion ( context , reserved . json . privateInvocation , { } , privateAuth ) ;
20922092 assert . equal ( first . code , 0 , first . stderr ) ; assert . equal ( first . json . job . status , 'succeeded' ) ;
2093+ const terminalResult = first . json . result ;
2094+ assert . deepEqual ( JSON . parse ( terminalResult ) , { findings : [ ] } ) ;
2095+ const storage = await resolveWorkspaceStorage ( context ) ;
2096+ assert . equal ( await readFile ( join ( storage . directory , first . json . job . resultArtifact ) , 'utf8' ) , terminalResult ) ;
20932097 const backgroundLog = await readFile ( first . json . job . logFile , 'utf8' ) ;
2094- assert . match ( backgroundLog , / A s s i s t a n t m e s s a g e \n [ \s \S ] * " f i n d i n g s " : \[ \] / ) ;
2095- assert . match ( backgroundLog , / F i n a l o u t p u t \n [ \s \S ] * " f i n d i n g s " : \[ \] / ) ;
2098+ const assistantBlock = `Assistant message\n${ terminalResult } \n` ;
2099+ const finalBlock = `Final output\n${ terminalResult } \n` ;
2100+ assert . equal ( backgroundLog . split ( assistantBlock ) . length - 1 , 1 ) ;
20962101 assert . equal ( ( backgroundLog . match ( / A s s i s t a n t m e s s a g e / g) ?? [ ] ) . length , 1 ) ;
2097- assert . equal ( ( backgroundLog . match ( / F i n a l o u t p u t / g) ?? [ ] ) . length , 1 ) ;
2102+ // The final block is an observational mirror written after durable success;
2103+ // its bounded append may time out under filesystem load (notably on Windows).
2104+ const finalMirrorCount = backgroundLog . split ( finalBlock ) . length - 1 ;
2105+ assert . ok ( [ 0 , 1 ] . includes ( finalMirrorCount ) ) ;
2106+ assert . equal ( ( backgroundLog . match ( / F i n a l o u t p u t / g) ?? [ ] ) . length , finalMirrorCount ) ;
20982107 assert . doesNotMatch ( backgroundLog , / P R I V A T E _ R E A S O N I N G | R A W _ T O O L _ O U T P U T | C A P A B I L I T Y _ T O K E N / ) ;
20992108 const replay = await companion ( context , reserved . json . privateInvocation , { } , privateAuth ) ;
21002109 assert . notEqual ( replay . code , 0 ) ; assert . equal ( replay . json . error . code , 'EXECUTION_CAPABILITY_CONSUMED' ) ;
0 commit comments