fix(ios): refuse the XCTestDevices redirect while an Xcode shim's first-launch hook is armed
Summary
acquireXcodebuildSimulatorSetRedirect now refuses to redirect ~/Library/Developer/XCTestDevices
to a scoped simulator set when an xcrun shim (simctl/devicectl) has an armed first-launch hook —
its EXPECTED_VERSION differs from the installed CoreSimulator/CoreDevice version. An armed shim
runs xcodebuild -runFirstLaunch on every call, deleting every device in XCTestDevices; with the
redirect installed that wipes the user's scoped set. The probe reads shim text and plist paths
(never hard-coded), failing closed on any unreadable value or a 2 s timeout. The refusal is
COMMAND_FAILED with details.reason: 'xctest_device_set_cleanup_armed', a static hint, and
details.xcrunShims; both the build and session acquire paths refuse before any xcodebuild phase.
Default-set sims and a set already equal to XCTestDevices never probe.
Closes #2935
17 files touched (7 production, 8 test, 2 docs); net production +247 lines. Gross diff is 1,045
lines, 45 over budget — almost entirely the new fail-closed test matrix (318 lines) the issue
requires.
Validation
Tested at 9573ece558 (base 34ab80353c).
pnpm check:affected --run: pass, first run — "all runnable checks passed" (510 vitest files /
3899 tests, command-docs 12/12).pnpm check:fallow --base origin/main: no issues in 22 changed
files.- Review follow-up (4 points, addressed on 34ab80353c): the xcrun shim probe now caps its budget by
the owning phase's remaining deadline (min(30s cold cap, phase remaining)), not just the 30 s
cold budget; a fake that missed an already-fired abort signal now waits on a real abort listener
and asserts the probe started; a new test covers a request canceled while a shim is mid-read
(previously only pre-aborted was covered);probe_canceledis now unrepresentable at the probe
boundary ({ canceled: true } | { canceled: false; xcrunShims }) instead of a deadarmedBy
branch. - Follow-on found while fixing the above: a phase that runs out during the probe was still
misreported as an armed shim (probe_out_of_budget); fixed so a phase-owned stop reports
runner_phase_budget_exhaustedand only the 30 s cold cap can produceprobe_out_of_budget. - Live Leg A (armed host, prior head) unchanged by this delta — still refuses with
xctest_device_set_cleanup_armed, probe ~50 ms, device survives every-runFirstLaunchcleanup. - Leg B (non-armed host, live cold scoped-set open) still not run — remains the maintainer's merge
condition. - Passed a 3-lens adversarial review, a final ship review, and this review round earlier in this
pipeline.