@@ -15,9 +15,10 @@ import {
1515 resolveRunnerSandboxBuildArgs ,
1616 resolveExpectedRunnerCacheMetadata ,
1717} from '../runner-cache-metadata.ts' ;
18- // The one owning module for the probe budget: this file's probes reach it
19- // through the runner host port, snapshot-source imports it directly (#2422).
20- import { COLD_TOOLCHAIN_PROBE_TIMEOUT_MS } from '../../core/config.ts' ;
18+ // The one owning module for the probe budget: host-kit's exec layer. The
19+ // snapshot-source prober imports it from there directly; this file's probes read
20+ // the same value through the runner host port (#2422).
21+ import { COLD_TOOLCHAIN_PROBE_TIMEOUT_MS } from '@agent-device/host-kit/command' ;
2122import { appleToolchainProbeResult , stubAppleToolchainProbes } from './apple-toolchain-fixtures.ts' ;
2223
2324const runCmdSync = stubAppleToolchainProbes ( ) ;
@@ -289,19 +290,10 @@ describe('toolchain probe budget', () => {
289290
290291 assert . throws (
291292 ( ) => resolveExpectedRunnerCacheMetadata ( MACOS_DEVICE ) ,
292- ( error : unknown ) => {
293- assert . ok ( error instanceof AppError ) ;
294- assert . equal ( error . code , 'COMMAND_FAILED' ) ;
295- assert . equal ( error . details ?. reason , 'apple_toolchain_probe_unavailable' ) ;
296- assert . equal ( error . details ?. retriable , true ) ;
297- expect ( error . details ?. hint ) . toContain ( 'xcode-select -p' ) ;
298- expect ( error . message ) . toContain ( 'xcodebuild -version' ) ;
299- // The reported failure is the last attempt: 30 s, then the 15 s the
300- // budget still had.
301- expect ( error . message ) . toContain ( 'xcodebuild timed out after 15000ms' ) ;
302- expect ( error . message ) . toContain ( 'request budget' ) ;
303- return true ;
304- } ,
293+ // A budget spent before the remaining probes could start is not an
294+ // unreadable toolchain: nothing probed it, so the error says the budget
295+ // ran out rather than pointing at `xcode-select`.
296+ ( error : unknown ) => expectRunnerPhaseBudgetExhausted ( error ) ,
305297 ) ;
306298 // 30 s + a 15 s retry spends the whole budget on the first probe; the two
307299 // xcrun probes then fail on the budget instead of blocking for 30 s each.
@@ -320,15 +312,11 @@ describe('toolchain probe budget', () => {
320312 assert . throws (
321313 ( ) =>
322314 resolveExpectedRunnerCacheMetadata ( IOS_SIMULATOR , undefined , { deadline : phaseDeadline } ) ,
323- ( error : unknown ) => {
324- assert . ok ( error instanceof AppError ) ;
325- assert . equal ( error . details ?. reason , 'apple_toolchain_probe_unavailable' ) ;
326- expect ( error . message ) . toContain ( 'xcodebuild timed out after 4000ms' ) ;
327- expect ( error . message ) . toContain ( 'request budget' ) ;
328- return true ;
329- } ,
315+ ( error : unknown ) => expectRunnerPhaseBudgetExhausted ( error ) ,
330316 ) ;
331317 assert . equal ( runCmdSync . mock . calls . length , 1 ) ;
318+ // The one attempt was capped by the phase, not by the 30 s per-call ceiling.
319+ assert . equal ( runCmdSync . mock . calls [ 0 ] ?. [ 2 ] ?. timeoutMs , 4_000 ) ;
332320 assert . equal ( clock . nowMs , 4_000 ) ;
333321 } ) ;
334322
@@ -389,6 +377,17 @@ describe('toolchain probe budget', () => {
389377 } ) ;
390378} ) ;
391379
380+ /** The error a runner phase raises when a step is reached with nothing left to spend. */
381+ function expectRunnerPhaseBudgetExhausted ( error : unknown ) : boolean {
382+ assert . ok ( error instanceof AppError ) ;
383+ assert . equal ( error . code , 'COMMAND_FAILED' ) ;
384+ assert . equal ( error . details ?. reason , 'runner_phase_budget_exhausted' ) ;
385+ assert . equal ( error . details ?. phase , 'apple_toolchain_probe' ) ;
386+ assert . equal ( error . details ?. retriable , true ) ;
387+ expect ( error . message ) . toContain ( 'budget ran out' ) ;
388+ return true ;
389+ }
390+
392391/**
393392 * A clock the probes' own budget reads, advanced only by
394393 * {@link blockForWholeTimeout}. Without it a mock that throws immediately
0 commit comments