@@ -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,10 @@ 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+ tool : 'simctl ' ,
43+ args : expect . arrayContaining ( [ 'spawn' , 'sim-1' , '--start' , '@1' ] ) ,
4444 timeoutMs : 4_000 ,
4545 } ) ,
4646 expect . any ( AbortSignal ) ,
@@ -50,7 +50,7 @@ test('recovers an empty iOS simulator dump from bounded simctl log history', asy
5050test ( 'preserves the simulator no-HTTP explanation after recovery returns app lines' , async ( ) => {
5151 const result = await dumpAppleNetworkTraffic (
5252 host ( {
53- commandRun : async ( ) => ( {
53+ runSimctl : async ( ) => ( {
5454 stdout : '2026-08-10T10:00:00Z application diagnostic only\n' ,
5555 stderr : '' ,
5656 exitCode : 0 ,
@@ -69,10 +69,10 @@ test('preserves the simulator no-HTTP explanation after recovery returns app lin
6969} ) ;
7070
7171test ( 'parses macOS session app-log traffic without loading simulator recovery' , async ( ) => {
72- const commandRun = vi . fn ( ) ;
72+ const runSimctl = vi . fn ( ) ;
7373 const result = await dumpAppleNetworkTraffic (
7474 host ( {
75- commandRun ,
75+ runSimctl ,
7676 text : '2026-08-10T10:00:00Z GET https://mac.example.test status=204\n' ,
7777 } ) ,
7878 { ...simulator , appleOs : 'macos' , kind : 'device' , target : 'desktop' } ,
@@ -84,7 +84,7 @@ test('parses macOS session app-log traffic without loading simulator recovery',
8484 backend : 'macos' ,
8585 dump : { entries : [ { url : 'https://mac.example.test' , status : 204 } ] } ,
8686 } ) ;
87- expect ( commandRun ) . not . toHaveBeenCalled ( ) ;
87+ expect ( runSimctl ) . not . toHaveBeenCalled ( ) ;
8888} ) ;
8989
9090function input ( overrides : Partial < NetworkDumpInput > = { } ) : NetworkDumpInput {
@@ -101,11 +101,17 @@ function input(overrides: Partial<NetworkDumpInput> = {}): NetworkDumpInput {
101101
102102function host ( options : {
103103 text ?: string ;
104- commandRun : PlatformRuntimeHost [ 'commands ' ] [ 'run' ] ;
104+ runSimctl : PlatformRuntimeHost [ 'appleTools ' ] [ 'run' ] ;
105105} ) : PlatformRuntimeHost {
106106 return {
107107 ...unusedAppLogHost ( ) ,
108- commands : { which : async ( ) => undefined , run : options . commandRun } ,
108+ commands : {
109+ which : async ( ) => undefined ,
110+ run : async ( ) => {
111+ throw new Error ( 'generic command runner must not own Apple network recovery' ) ;
112+ } ,
113+ } ,
114+ appleTools : { isXcrunAvailable : async ( ) => true , run : options . runSimctl } ,
109115 appLogs : {
110116 readRecent : async ( ) => ( {
111117 path : '/sessions/one/app.log' ,
@@ -121,13 +127,9 @@ function host(options: {
121127
122128function unusedAppLogHost ( ) : Omit <
123129 PlatformRuntimeHost ,
124- 'commands' | 'appLogs' | 'networkTransports'
130+ 'appleTools' | ' commands' | 'appLogs' | 'networkTransports'
125131> {
126132 return {
127- appleTools : {
128- isXcrunAvailable : async ( ) => false ,
129- run : async ( ) => ( { stdout : '' , stderr : '' , exitCode : 0 } ) ,
130- } ,
131133 toolchains : { prepare : async ( ) => { } } ,
132134 artifacts : {
133135 resolveSession : ( ) => ( {
0 commit comments