Skip to content

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

Merged
thymikee merged 2 commits into
mainfrom
fix/device-cache-env-key
Nov 12, 2026
Merged

thymikee merged 2 commits into
mainfrom
fix/device-cache-env-key

Conversation

@thymikee

@thymikee thymikee commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

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 e92c0ce; 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:

Scenario CLI MCP
warm open, no --platform 0.74–0.80 0.94–1.02
warm open after prepare 0.83 0.80
cold first tap 0.70 1.17
open --relaunch, live runner 0.98 1.10
2nd session after close 1.41 0.75

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

🤖 Generated with Claude Code

thymikee and others added 2 commits November 12, 2026 09:56
Android SDK discovery adds ANDROID_HOME, ANDROID_SDK_ROOT and PATH to the
host env during the first inventory read. The request-scoped resolution cache
keyed on the serialized env, so the open handler missed the selection the
request lock had just made and read the whole inventory again: simctl,
devicectl, xctrace and adb. The request part of the key already holds every
value selection derives from env.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…entries

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.21 MB 6.21 MB +6 B
Package (unpacked) 6.21 MB 6.21 MB +6 B
Package (download) 1.88 MB 1.88 MB +3 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 21.4 ms 23.0 ms +1.6 ms
CLI --help 44.7 ms 47.7 ms +2.9 ms

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

View guided diff | Turn on auto-fix | Re-trigger cubic

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel

Verdict: approve

No findings.

1 finding below minor not shown (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (799e9c027625).

Feedback goes in the review comment threads, as a reply under the inline comment of a finding:

Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if it is wrong — I will re-check the cited code.

Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.

Comment @apex-sentinel-staging review on this conversation to run a full review.

@thymikee

Copy link
Copy Markdown
Member Author

I found no problems in e92c0ce. The change touches only dispatch-resolve.ts and its unit test, and tracing the request device key before and after shows the host env no longer reaches it. All 20 checks pass, and no conflicts are known. I did not run the two new tests myself, and I did not reproduce the exec counts (38 to 19 adb, 6 to 5 xcrun) or the timing table. The PR already calls the timings load-noisy, so a quiet-host re-measure is still worth posting. I also did not check future callers that might pass a different env to the same request scope. Today the daemon passes one env, so that case does not occur on the audited routes. Nothing from review holds this back, so it can merge when you decide.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 12, 2026
@thymikee
thymikee merged commit 9cbbae2 into main Nov 12, 2026
23 of 25 checks passed
@thymikee
thymikee deleted the fix/device-cache-env-key branch November 12, 2026 10:03
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