@@ -576,18 +576,20 @@ describe.concurrent("fresh compiled subprocess invocation", () => {
576576 expect ( fs . existsSync ( owner . descriptor . directory ) ) . toBe ( false ) ;
577577 } ) ) ;
578578
579- it ( "preserves scoped and prepared provider hooks in source and compiled TUI payloads" , ( {
580- workerArtifacts,
581- } ) =>
582- workerArtifacts . fixtureLifetime . run ( async ( ) => {
583- const { node, prepareWorkers } = workerArtifacts . createFixtureCommands ( ) ;
584- const owner = createVitestWorkerRun ( ) ;
585- try {
586- const manifest = await prepareWorkers ( owner ) ;
587- console . log (
588- JSON . stringify ( { preparationMs : manifest . durationMs , identity : manifest . identity } ) ,
589- ) ;
590- for ( const mode of [ "source" , "compiled" ] as const ) {
579+ it . for ( [ "source" , "compiled" ] as const ) (
580+ "preserves scoped and prepared provider hooks in %s TUI payloads" ,
581+ ( mode , { workerArtifacts } ) =>
582+ workerArtifacts . fixtureLifetime . run ( async ( ) => {
583+ const { node, prepareWorkers } = workerArtifacts . createFixtureCommands ( ) ;
584+ // Each mode owns its cold-process budget; source probes need no compiled generation.
585+ const owner = mode === "compiled" ? createVitestWorkerRun ( ) : undefined ;
586+ try {
587+ if ( owner ) {
588+ const manifest = await prepareWorkers ( owner ) ;
589+ console . log (
590+ JSON . stringify ( { preparationMs : manifest . durationMs , identity : manifest . identity } ) ,
591+ ) ;
592+ }
591593 for ( const scope of [ "scoped" , "prepared" ] as const ) {
592594 const directory = workerArtifacts . fixtureDirectory ( ) ;
593595 const events = path . join ( directory , "provider-events.jsonl" ) ;
@@ -712,24 +714,21 @@ describe.concurrent("fresh compiled subprocess invocation", () => {
712714 ` ,
713715 ) ;
714716 const url = pathToFileURL (
715- mode === "source"
716- ? path . join ( root , "src/agents/embedded-agent-runner/run/payloads.ts" )
717- : path . join (
717+ owner
718+ ? path . join (
718719 owner . descriptor . directory ,
719720 "dist/agents/embedded-agent-runner/run/payloads.js" ,
720- ) ,
721+ )
722+ : path . join ( root , "src/agents/embedded-agent-runner/run/payloads.ts" ) ,
721723 ) ;
722724 const result = await node (
723725 [
724726 ...resolveRuntimeWorkerArgv ( pathToFileURL ( probe ) ) ,
725727 url . href ,
726728 pathToFileURL (
727- mode === "source"
728- ? path . join ( root , "src/plugins/provider-hook-runtime.ts" )
729- : path . join (
730- owner . descriptor . directory ,
731- "dist/plugins/provider-hook-runtime.js" ,
732- ) ,
729+ owner
730+ ? path . join ( owner . descriptor . directory , "dist/plugins/provider-hook-runtime.js" )
731+ : path . join ( root , "src/plugins/provider-hook-runtime.ts" ) ,
733732 ) . href ,
734733 ] ,
735734 root ,
@@ -742,12 +741,14 @@ describe.concurrent("fresh compiled subprocess invocation", () => {
742741 console . log ( result . stdout ) ;
743742 expect ( result . code , result . stderr + result . stdout ) . toBe ( 0 ) ;
744743 }
744+ } finally {
745+ await owner ?. dispose ( ) ;
745746 }
746- } finally {
747- await owner . dispose ( ) ;
748- }
749- expect ( fs . existsSync ( owner . descriptor . directory ) ) . toBe ( false ) ;
750- } ) ) ;
747+ if ( owner ) {
748+ expect ( fs . existsSync ( owner . descriptor . directory ) ) . toBe ( false ) ;
749+ }
750+ } ) ,
751+ ) ;
751752
752753 it . each ( [
753754 { args : [ "run" , "--" , "--help" ] , metadata : false } ,
0 commit comments