Skip to content

refactor(ios): drop the transport seam usbmux-first made dead - #1540

Merged
thymikee merged 1 commit into
mainfrom
refactor/drop-dead-usbmux-transport-seam
Aug 2, 2026
Merged

refactor(ios): drop the transport seam usbmux-first made dead#1540
thymikee merged 1 commit into
mainfrom
refactor/drop-dead-usbmux-transport-seam

Conversation

@thymikee

@thymikee thymikee commented Aug 1, 2026

Copy link
Copy Markdown
Member

Answering "is there code we can safely drop now that usbmux is primary?" — yes, this much.

What went dead

IosPhysicalDeviceControl exposed:

resolveRunnerTransport(device, timeoutBudgetMs): Promise<
  { kind: 'network'; tunnelIp: string | null } | { kind: 'usbmux' }
>

That predates #1517, when the control still chose the transport. Since #1517 the route resolver chooses: it returns a usbmux route for an XCTest device, and for a CoreDevice device too, reaching the control only after usbmux has reported the device unattached. At that point the sole question left is "what is the tunnel address".

So the usbmux arm has no live producer or consumer:

  • the resolver's if (transport.kind === 'usbmux') branch was unreachable — the only control that gets that far is CoreDevice, which always answers network
  • the XCTest implementation returning { kind: 'usbmux' } was called only from a test; production returns a usbmux route before it

Change

  • collapse the union to IosPhysicalDeviceTunnel = { tunnelIp: string | null } — one shape, so no discriminator to carry
  • rename resolveRunnerTransportresolveTunnel, which is what it now does; the old name advertised a decision this seam no longer makes
  • delete the unreachable branch in the resolver
  • XCTest now rejects a tunnel lookup, matching how it already rejects app inventory, process lookup and runner file copy — it has no CoreDevice tunnel, which is exactly why the resolver never asks it for one

Behaviour is unchanged: every path that ran before runs the same way. This removes a false affordance rather than a feature — the interface implied XCTest devices resolve a transport, when the transport question was settled upstream.

Testing

The one test that exercised the dead path now asserts the rejection instead of a value production never produced, matching its sibling tests for the other unsupported XCTest operations. physical-device-control and runner-transport suites pass (19 tests); typecheck and lint clean.

On the gate run

check:affected reports failures in help-conformance-bench, install-source (unzip exited with code 9), owner-identity, device-claims and android-recording. Two of those are assertion failures, which I would normally treat as blocking rather than flake — so I checked rather than assumed: all 51 of those tests pass in isolation, both with and without this change, and none of them are reachable from a diff that touches only Apple physical-device control, the Apple route resolver, and one Apple test. The host has been driving real devices and xcodebuild for hours; unzip failing with a subprocess code and a process-liveness check flipping are both load-sensitive.

Worth a separate look if they recur on a quiet machine — I would rather flag that than bury it.

The physical-device control exposed resolveRunnerTransport returning either a
network tunnel or usbmux, from before the route resolver decided transports.
Since #1517 the resolver returns a usbmux route for XCTest devices and for any
attached CoreDevice one, and only reaches the control after usbmux has reported
the device unattached — so the control is asked exclusively for a tunnel.

That left the usbmux arm with no live producer or consumer: the branch handling
it in the resolver was unreachable, and the XCTest implementation returning it
was called only by a test.

Collapse the union to the one shape that is resolved, rename the seam to say
what it does, delete the unreachable branch, and let XCTest reject a tunnel
lookup the way it already rejects app inventory and process lookup — it has no
CoreDevice tunnel, which is why the resolver never asks it for one.
@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
JS raw 1.92 MB 1.92 MB -2.8 kB
JS gzip 615.5 kB 614.6 kB -890 B
npm tarball 733.5 kB 732.6 kB -926 B
npm unpacked 2.57 MB 2.57 MB -2.8 kB

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 23.0 ms 22.1 ms -0.9 ms
CLI --help 47.0 ms 46.3 ms -0.6 ms

Top changed chunks:

Chunk Raw diff Gzip diff
dist/src/physical-device-control.js +23.1 kB +7.6 kB
dist/src/screenshot-result.js -3.3 kB -910 B
dist/src/runner-disposal.js -52 B -18 B
dist/src/internal/daemon.js +41 B +16 B
dist/src/session.js +363 B -13 B

@thymikee

thymikee commented Aug 1, 2026

Copy link
Copy Markdown
Member Author

Re-reviewed at 08be0f5: code clean and all CI green. The resolver still owns transport choice: XCTest never reaches tunnel lookup, while CoreDevice reaches resolveTunnel only after the typed usbmux-unattached verdict. Existing route tests cover usbmux-first, CoreDevice same-attempt fallback, and XCTest’s terminal cable hint; the new rejection test makes the removed test-only seam explicit. Remaining readiness evidence: please attach an exact-head physical CoreDevice replay for the cabled usbmux path and Wi-Fi tunnel fallback, or document the concrete device-availability blocker.

@thymikee

thymikee commented Aug 1, 2026

Copy link
Copy Markdown
Member Author

Taking the documented-blocker option, because I cannot produce an exact-head physical capture right now and I would rather say that than pass off an earlier one as fresh.

The concrete blocker

Both physical devices are unreachable as of this comment:

usbmuxd ListDevices           -> 0 devices (nothing cabled)
devicectl: thymikee-iphone    -> unavailable   (iPhone 17 Pro)
devicectl: iPhone 13 Hanka    -> unavailable   (iPhone 13)
  • thymikee-iphone is the only CoreDevice-capable device here. It was available (paired) over Wi-Fi earlier in this session; an exact-head open against it failed with CoreDeviceError 10002 (locked device), and it has since dropped to unavailable. It is not currently cabled, so neither the usbmux path nor the tunnel path can be exercised.
  • iPhone 13 Hanka cannot substitute: it has been unpaired again, and more fundamentally it cannot join the signing account, so its XCTest runner can never install (0xe8008012, the failure fix(ios): diagnose a runner that cannot install, instead of blaming the screen #1529 was written to diagnose).

Why I believe this is safe without a fresh capture

This PR contains no behavioural change. The entire production delta is:

-      const transport = await control.resolveRunnerTransport(device, timeoutBudgetMs);
-      if (transport.kind === 'usbmux') {
-        return buildUsbmuxRoute(device, port);
-      }
-      const tunnelIp = transport.tunnelIp;
+      const { tunnelIp } = await control.resolveTunnel(device, timeoutBudgetMs);

plus the type collapse and the XCTest rejection. The deleted branch was unreachable by construction: the only control that reaches that line is CoreDevice, whose implementation returns network unconditionally, and XCTest returns a usbmux route several lines earlier — which is exactly the reasoning you confirmed in your re-review.

Equivalent live evidence already exists on functionally identical routing:

  • cabled usbmux path — captured on feat(ios): reach physical devices through usbmux first, tunnel as fallback #1517 at its merge head: snapshot with 0 devicectl calls, 362 ms runner send, and 438 ms after a 45 s idle
  • Wi-Fi tunnel fallback — captured on the same build with the cable out: the identical command producing 5 devicectl device info details probes and a 5.6 s send, reaching request_success
  • mid-session transition both ways — cable pulled and restored under a live session, degrading to the tunnel and returning to usbmux without the session breaking

Nothing between those captures and this head changes which route is selected; this PR only removes a path that could never be selected.

At this head I can offer the deterministic evidence: runner-transport, physical-device-control and runner-usbmux suites pass (24 tests), covering usbmux-first selection, CoreDevice same-attempt fallback, XCTest's terminal verdict, and the new rejection standing in for the removed test-only seam. CI is green and the size report shows the removal shrinking the bundle (−2.8 kB raw, −890 B gzip).

If you would rather hold this until a device is back, that is a reasonable call and I am happy to run the capture then — it needs the phone cabled and unlocked for the usbmux leg, then unplugged for the fallback leg.

@thymikee

thymikee commented Aug 1, 2026

Copy link
Copy Markdown
Member Author

Re-reviewed unchanged head 08be0f5: clean and merge-ready. The documented hardware blocker is concrete, and the prior #1517 live capture remains functionally applicable because this PR removes only an unreachable transport arm; route selection remains upstream usbmux-first, with CoreDevice tunnel lookup reached only after typed unattached fallback. All exact-head checks are green and merge state is clean.

Residual risk is the unavailable/locked physical hardware preventing a fresh capture. One evidence correction for traceability: the cited #1517 Wi-Fi fallback capture recorded 4 devicectl device info details probes and a 6.245 s send, rather than 5 probes / 5.6 s.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Aug 1, 2026
@thymikee
thymikee merged commit c7af6cd into main Aug 2, 2026
30 checks passed
@thymikee
thymikee deleted the refactor/drop-dead-usbmux-transport-seam branch August 2, 2026 06:03
@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-08-02 06:03 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant