@@ -14,7 +14,7 @@ const simulator: DeviceInfo = {
1414} ;
1515
1616test ( 'recovers an empty iOS simulator dump from bounded simctl log history' , async ( ) => {
17- const commandRun = vi . fn ( async ( ) => ( {
17+ const runSimctl = vi . fn ( async ( ) => ( {
1818 stdout : [
1919 'Timestamp Ty Process[PID:TID]' ,
2020 '2026-08-10T10:00:00Z GET https://recovered.example.test status=200' ,
@@ -23,7 +23,7 @@ test('recovers an empty iOS simulator dump from bounded simctl log history', asy
2323 exitCode : 0 ,
2424 } ) ) ;
2525 const result = await dumpAppleNetworkTraffic (
26- host ( { commandRun } ) ,
26+ host ( { runSimctl } ) ,
2727 simulator ,
2828 input ( { appLogSnapshot : { state : 'active' , startedAt : 1_000 } } ) ,
2929 new AbortController ( ) . signal ,
@@ -37,10 +37,9 @@ test('recovers an empty iOS simulator dump from bounded simctl log history', asy
3737 expect ( result . source ) . toBe ( 'app-log' ) ;
3838 if ( result . source !== 'app-log' ) throw new Error ( 'expected app-log result' ) ;
3939 expect ( result . notes [ 0 ] ) . toContain ( 'Recovered 1 iOS simulator HTTP entry' ) ;
40- expect ( commandRun ) . toHaveBeenCalledWith (
40+ expect ( runSimctl ) . toHaveBeenCalledWith (
4141 expect . objectContaining ( {
42- executable : 'xcrun' ,
43- args : expect . arrayContaining ( [ 'simctl' , 'spawn' , 'sim-1' , '--start' , '@1' ] ) ,
42+ args : expect . arrayContaining ( [ 'spawn' , 'sim-1' , '--start' , '@1' ] ) ,
4443 timeoutMs : 4_000 ,
4544 } ) ,
4645 expect . any ( AbortSignal ) ,
@@ -50,7 +49,7 @@ test('recovers an empty iOS simulator dump from bounded simctl log history', asy
5049test ( 'preserves the simulator no-HTTP explanation after recovery returns app lines' , async ( ) => {
5150 const result = await dumpAppleNetworkTraffic (
5251 host ( {
53- commandRun : async ( ) => ( {
52+ runSimctl : async ( ) => ( {
5453 stdout : '2026-08-10T10:00:00Z application diagnostic only\n' ,
5554 stderr : '' ,
5655 exitCode : 0 ,
@@ -69,10 +68,10 @@ test('preserves the simulator no-HTTP explanation after recovery returns app lin
6968} ) ;
7069
7170test ( 'parses macOS session app-log traffic without loading simulator recovery' , async ( ) => {
72- const commandRun = vi . fn ( ) ;
71+ const runSimctl = vi . fn ( ) ;
7372 const result = await dumpAppleNetworkTraffic (
7473 host ( {
75- commandRun ,
74+ runSimctl ,
7675 text : '2026-08-10T10:00:00Z GET https://mac.example.test status=204\n' ,
7776 } ) ,
7877 { ...simulator , appleOs : 'macos' , kind : 'device' , target : 'desktop' } ,
@@ -84,7 +83,7 @@ test('parses macOS session app-log traffic without loading simulator recovery',
8483 backend : 'macos' ,
8584 dump : { entries : [ { url : 'https://mac.example.test' , status : 204 } ] } ,
8685 } ) ;
87- expect ( commandRun ) . not . toHaveBeenCalled ( ) ;
86+ expect ( runSimctl ) . not . toHaveBeenCalled ( ) ;
8887} ) ;
8988
9089function input ( overrides : Partial < NetworkDumpInput > = { } ) : NetworkDumpInput {
@@ -101,11 +100,17 @@ function input(overrides: Partial<NetworkDumpInput> = {}): NetworkDumpInput {
101100
102101function host ( options : {
103102 text ?: string ;
104- commandRun : PlatformRuntimeHost [ 'commands ' ] [ 'run ' ] ;
103+ runSimctl : PlatformRuntimeHost [ 'appleTools ' ] [ 'runSimctl ' ] ;
105104} ) : PlatformRuntimeHost {
106105 return {
107106 ...unusedAppLogHost ( ) ,
108- commands : { which : async ( ) => undefined , run : options . commandRun } ,
107+ commands : {
108+ which : async ( ) => undefined ,
109+ run : async ( ) => {
110+ throw new Error ( 'generic command runner must not own Apple network recovery' ) ;
111+ } ,
112+ } ,
113+ appleTools : { runSimctl : options . runSimctl } ,
109114 appLogs : {
110115 readRecent : async ( ) => ( {
111116 path : '/sessions/one/app.log' ,
@@ -121,7 +126,7 @@ function host(options: {
121126
122127function unusedAppLogHost ( ) : Omit <
123128 PlatformRuntimeHost ,
124- 'commands' | 'appLogs' | 'networkTransports'
129+ 'appleTools' | ' commands' | 'appLogs' | 'networkTransports'
125130> {
126131 return {
127132 artifacts : {
0 commit comments