fix(device-selection): keep host env out of the request device cache key

Merged
TH
5d ago
+37-1

Summary

A fresh open without --platform read the device inventory twice per request (simctl, devicectl, xctrace, adb): once for the request lock, once in the handler. Android SDK discovery adds ANDROID_HOME/PATH to the host env during the first read, and the request cache key serialized that env, so the second lookup missed. The key now omits env; its request part already holds every env-derived value. 2 files.

It hits the first unscoped open after prepare ios-runner --platform ios; in recorded agent runs those took 4.4–4.8 s for a ~0.9 s launch.

Validation

validation: CI. Head e92c0ce373; focused dispatch-resolve.test.ts 41/41. The new positive test fails on main (second resolution re-reads inventory); the new negative test fails if the allowlist leaves the key.

Simulator exec trace, warm open --udid without --platform, CLI and MCP alike: main 2 inventory reads (38 adb, 6 xcrun); fix 1 read plus a cache hit (19 adb, 5 xcrun).

Interleaved main/fix ratio (fix ÷ main, median of 3 pairs), measured under host load ~250–950 on 12 cores:

ScenarioCLIMCP
warm open, no --platform0.74–0.800.94–1.02
warm open after prepare0.830.80
cold first tap0.701.17
open --relaunch, live runner0.981.10
2nd session after close1.410.75

Only the first row's path changed; the others show load noise. A quiet-host re-measure is pending.

🤖 Generated with Claude Code