Skip to content

perf(remote): hash staged iOS runner app files once per lease - #5205

Merged
thymikee merged 3 commits into
mainfrom
perf/remote-runner-manifest
Nov 29, 2026
Merged

thymikee merged 3 commits into
mainfrom
perf/remote-runner-manifest

Conversation

@thymikee

@thymikee thymikee commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

Summary

Each remote iOS runner launch rewrote Runner.xctestrun, then walked the staged tree and hashed every file again, although the app files never change there.

Staging now returns the app-file manifest with the staged-products handle. Each upload reuses it and describes only the current configuration. Outgoing manifests stay complete, the full-payload recovery still streams every file, and disposal drops the manifest with the staged tree.

The regular-file check moves from the first upload to staging, so a runner containing a symbolic link fails before any request. Hashing moves with it, under its own 300 s deadline (operation_deadline_expired); caller and lease cancellation still stop it.

Validation

At 60caeed, which adds that deadline, limrun-ios-runner-products.test.ts: 15 passed.

Tested at 91c2109:

  • limrun-ios-runner-products.test.ts and limrun-ios-runner.test.ts: 55 passed.
  • Mutations at the pre-review commit e8a1b1d809: re-hashing app files on upload fails the new count test (8 reads, expected 2); removing the regular-file check fails the symlink test.
  • Typecheck, oxlint and oxfmt on the changed files: clean.

Per-launch selective sync, real simulator runner app (7 files, 5.9 MB), stubbed network, 40 interleaved samples per side, loaded host:

files hashed bytes hashed median p90
base 47e3fbe 8 5,894,971 43.7 ms 93.1 ms
e8a1b1d809 1 1,513 8.7 ms 14.7 ms

91c2109 only adds an abort check. CI checks are pending. No live remote-instance run.

🤖 Generated with Claude Code


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff Turn on auto-fix

Every launch rewrote the runner configuration, then walked and re-hashed the
whole staged products tree before a selective sync. Staging now returns the
app-file manifest with the staged-products handle, and each upload describes
only the current configuration.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.70 MB 6.70 MB +244 B
Package (unpacked) 6.69 MB 6.69 MB +244 B
Package (download) 2.04 MB 2.04 MB +133 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 21.6 ms 22.1 ms +0.5 ms
CLI --help 49.6 ms 49.4 ms -0.2 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 3 files

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

@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Apex Sentinel: 1 new finding on 91c2109. The verdict and the full list are in the summary comment.

Hashing left the 300 s upload budget when it moved into staging, so a stalled
read held preparation open. Staging now waits at most 300 s for it and fails
with operation_deadline_expired.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

Live Limrun evidence is still needed before merge, and no code change is required from the review of 60caeed. The PR changes the route that stages and launches the remote iOS runner, but the PR body says there was no live remote-instance run, and the proof uses only a stubbed fetch or a local fake server. This is device-facing native execution, so the repo requires live evidence, and it is not yet shown that a real instance accepts the first full sync and a later selective sync built from the reused manifest.

Please run this at that commit on one live Limrun iOS lease. Run a command that needs the XCTest runner, such as prepare ios-runner or a click (a snapshot alone may be served by the AX bridge). Retire that runner without releasing the lease, then run another such command. Attach the commands, the SHA and a debug log that shows one staging, two limrun.runner.launch diagnostics (the second after limrun.runner.prepare with cached: true), both commands succeeding, and no limrun_runner_upload_failed.

Not blocking: these can be taken or left, namely exporting CONFIGURATION_FILE from the products module for every site that names Runner.xctestrun, including the payload filter and the xctest/run body, and extending the stall test so that aborting the input signal while staging hashes and readFile never settles expects request_canceled, since only the timeout is driven there and the runner cancellation tests hold /sync, after hashing.

All checks that ran pass, only the Proof check is skipped, and no Limrun live lane is among them.

Not verified here: no tests, mutations or timings were run, and the conclusions come from the diff, the base and head code, and the check results. Not verified here: the server handling of the manifest on /sync is not visible in this repository, so only the client request was traced. Not verified here: the CLI sequence that retires a runner while keeping the same lease.

Name the runner configuration file once and use it for the launch
payload filter and the xctest/run body.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thymikee

Copy link
Copy Markdown
Member Author

Live Limrun iOS evidence for src/core/interactors/limrun-ios-runner.ts:156 at 60caeed: pass.

Setup. Built from a detached checkout of 60caeed with pnpm build, then ran the checkout's dist through the Node client on a private AGENT_DEVICE_STATE_DIR. Version 0.21.x dev builds need a local runner, so AGENT_DEVICE_LIMRUN_IOS_RUNNER_APP pointed to AgentDeviceRunnerUITests-Runner.app from pnpm build:xcuitest:ios (Xcode 27.1, generic/platform=iOS Simulator). I set AGENT_DEVICE_IOS_RUNNER_IDLE_STOP_MS=5000.

How the runner is retired while the lease stays. A plain CLI close releases the CLI lease (session_lease_released … released:true), and that stops the runner with its lease. So I used the documented retained-lease path: client.leases.allocate({ retainOnClose: true }). With that lease, close retains the runner, and the shared idle policy stops it after 5 s. This is the path in the retained runners expire with the shared idle policy and restart from uploaded products test. There is no CLI flag for leaseProvider, so the commands went through the Node client.

Commands (scope { tenant: 'limrun', runId: 'pr5205-proof-run', leaseBackend: 'ios-instance', leaseProvider: 'limrun', sessionIsolation: 'tenant', debug: true }, LIMRUN_API_KEY from env, redacted):

leases.allocate({ ...scope, platform: 'ios', retainOnClose: true })   -> leaseId b898f302…, created:true
apps.open({ app: 'com.apple.Preferences', platform: 'ios', relaunch: true })   ok 12.6 s
interactions.press({ selector: 'label="General"' })                            ok 1.4 s (runner tap)
sessions.close()                                                                ok, lease kept
leases.heartbeat(...) x2 over ~10 s                                             lease alive
apps.open({ app: 'com.apple.Preferences', platform: 'ios', relaunch: true })   ok 11.4 s
interactions.press({ selector: 'label="General"' })                            ok 1.2 s (runner tap)
leases.release(...)                                                             released:true
agent-device daemon stop --clean

Debug log (request ndjson, trimmed; one lease b898f302… throughout):

16:22:33.532 open    limrun.runner.prepare        {"cached":false}            <- the only staging
16:22:34.432 open    limrun.runner.launch         {"path":"/xctest/run","port":29449}
16:22:53.851 press   ios_runner_command_send      {"command":"tap"}           -> request_success
16:22:54.963 close   ios_runner_idle_stop_scheduled
16:22:54.964 close   session_lease_released       {"leaseId":"b898f302…","released":false}
16:22:59.965 close   ios_runner_idle_stop                                     <- runner retired, lease kept
16:23:11.112 open    limrun.runner.prepare        {"cached":true}
16:23:11.305 open    limrun.runner.launch         {"path":"/xctest/run","port":29449}
16:23:23.606 press   ios_runner_command_send      {"command":"tap"}           -> request_success
  • One staging: there is one limrun.runner.prepare with cached:false.
  • There are two limrun.runner.launch events. The second comes 193 ms after limrun.runner.prepare with cached:true. That launch did the selective Runner.xctestrun sync from the reused manifest, and Limrun accepted it.
  • Both opens and both runner tap commands end in request_success.
  • limrun_runner_upload_failed appears 0 times in the request logs and daemon.log. There are no error-level events in this flow.

Follow-up commit 6f68c58 applies the non-blocking notes. It changes only a test and a constant. CONFIGURATION_FILE is now exported and used for the launch payload filter and the xctest/run body. The stall test also covers aborting the input signal while staging hashes and readFile never settles, and expects request_canceled. limrun-ios-runner-products.test.ts and limrun-ios-runner.test.ts pass (57 tests). The live run was not repeated for this commit.

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 6f68c58

Since the review of 60caeed: 0 new · 0 still open · 0 no longer raised

No open findings.

1 finding below minor hidden (user_settings.min_severity).

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

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee

Copy link
Copy Markdown
Member Author

The code at 6f68c58 looks good, and no new regression was found. The earlier 60caeed finding on live remote-instance evidence is closed by the later author comment.

The hashing time limit thread no longer applies: the hashing at this commit is bounded by the input signal and a 300-second timeout, so the thread can be resolved.

All 21 checks pass at 6f68c58. They include no Limrun live lane, so the live proof is the author's trimmed log. That run was at 60caeed, and it carries over only because the production change since then produces identical values. Not verified here: no tests, mutations, timings or live runs were executed. Not verified here: the log cannot show whether the second sync needed the silent full-payload retry, and the server handling of /sync is not visible in this repository. The PR description still says there was no live remote-instance run and cites earlier commits, while the later comment holds the live evidence.

Nothing from this review needs to change before merge.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 29, 2026
@thymikee
thymikee merged commit 2ced738 into main Nov 29, 2026
21 checks passed
@thymikee
thymikee deleted the perf/remote-runner-manifest branch November 29, 2026 17:32
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