Repository navigation
Description
Part of #1636.
Scope
simlock files push <name> --app <id> --to <path> copies a stored file or folder into the data container of an app on the lease's iOS simulator, Android emulator or Android phone, on a worker and through a gateway.
If it goes wrong, files land outside the app's container or in another app, the app can no longer be reached by run-as, or a lease's end hangs on a copy.
Technical spec
Commit d95c152.
Rows
- Behaviours: B11, B12, B13, B14, B15, B16
- Stored state: S4
- Interfaces: I6, I7, I12, I13
- Existing code: X3, X5, X7, X10, X12, X13, X14
Facts
| # | Fact | Source |
|---|---|---|
| F1 | With a debuggable app on the Android 15 default and the Android 16 Play image, the commands of I6 and I9 exit 0 and every byte comes back, path with a space and a quote included | the rows' own command lines through adb -s emulator-5690, 2026-11-30, both images: untar 0, tar 0, equal shasum |
| F2 | An archive with a ./ entry of mode 755 unarchived into . makes run-as refuse the app; one with entries for files, links and empty folders only, under umask 022, leaves the modes of . and files, twice in a row |
the same emulators: run-as: /data/user/0/dev.t1636dbg readable or writable by others: 40755 before, drwx------ . and drwxrwx--x files after |
| F3 | run-as exits 1 with package not debuggable: X, unknown package: X or package not an application: X on stderr |
the same emulators, adb shell "run-as <app> sh -c :" |
| F4 | simctl get_app_container <udid> <app> data exits 2 for an unknown app, and prints (null) with exit 0 for a system app |
xcrun simctl get_app_container on iOS 27.2, 2026-11-30 |
| F5 | A relay waits 330 s for an answer | src/gateway/relay.ts:42 |
| F6 | The Android fixture app is debuggable, and the iOS one is a simulator build | aapt2 dump badging e2e/fixtures/appduct/android/AppductPlayground.apk: application-debuggable |
| F7 | DeviceTcp is the capability to model on: the driver member, the catalog call, the fake |
src/core/driver.ts:408, src/core/driver-catalog.ts:141, src/core/fake-device-tcp.ts |
Modules touched
core (app-files.ts, driver.ts, driver-catalog.ts, fake-driver.ts, testing.ts), drivers/ios (app-files.ts, index.ts), drivers/android (app-files.ts, index.ts, passthrough-rules.ts, physical-handler.ts), lease-files, http (lease-declarations.ts, app.ts), contract (errors.ts, the protocol bump), daemon (worker-composition.ts, gateway-lease-files.ts), ports (http-stream.ts), cli (commands/files.ts, the help in src/cli/index.ts), website (copy-files, cli, errors, the OpenAPI document), e2e/slow-remote-cli.test.ts. Searches: rg -l DeviceTcp src, rg "runAdbOn|runAdb\b" src, rg "HttpStreamRequest" src.
flowchart LR
C[cli files push] --> H[http route]
H --> L[lease-files]
L --> W[daemon worker-composition]
W --> K[core driver catalog]
K --> I[drivers/ios app-files]
K --> A[drivers/android app-files]
Rules in play
- ADR 0100 §3, §4: an archive on the worker's disk,
adb push, no file throughadb shell, no change of the device's state. src/drivers/AGENTS.md: the capability takes core's shapes; no driver imports lease-files or the contract.- ADR 0048 and
src/drivers/ios/AGENTS.md:simctlruns on the device set the driver is scoped to. .dependency-cruiser.mjslease-files-imports-little: lease-files takesappFilesas a dependency and never sees a driver.- Safety rule 10:
app,toand the body are bounded before they reach a command line. src/contract/AGENTS.mdProtocol version: one bump for the three new codes.- Documentation rule 9: the pages above and the codes in the errors reference; the docs say to stop the app before a push.
Tests
Seams: createLeaseFiles with FakeAppFiles (model: src/daemon/lease-files.test.ts), the drivers with ScriptedProcessRunner (src/drivers/android/index-device-tcp.test.ts, src/drivers/ios/device-tcp.test.ts), runCli (src/cli/index-files.test.ts), the gateway pair (src/daemon/relay-gateway-files.e2e.test.ts).
- B11: An HTTP caller pushes a stored file or folder through I7; sees 200, the driver was handed an archive of it, and no archive is left: folder's contents; empty folder; one file; link out left out; each refused path of Examples;
Documents/echoed asDocuments; a bad app id; a body that is no JSON, too long or without a field; unknown stored name; no driver capability or an iPhone (APP_FILES_UNSUPPORTED);UNKNOWN_APP;APP_FILES_FAILED; a file that shrinks while it is archived; disk low; 300 s (answered though the driver has not returned); caller goes away (runs on); lease ends during it - B12: The iOS driver writes the archive into the simulator's data container: new and existing folders; a file replaced; others kept; app unknown (exit 2);
(null)printed; another simctl failure; link in the path that leads out;.; aborted; physical device unsupported - B13: The Android driver pushes the archive and has the device unarchive it, on an emulator and a phone, and removes its temporary folder after a success and after a failure: emulator; phone; path with a space and a quote; an archive with no entry (the folder is made, nothing is pushed); what an earlier copy left is removed first; unknown package; package that is no application; not debuggable;
adb pushfails; unarchiving fails; the removal fails (the copy still succeeds); emulator without a serial; phone behind a closed gate; a step that times out; aborted; two copies on one device run one after the other, on two devices together - B14:
simlock files pushprints the reply of How it works: success; an answer after 200 s; none after 360 s (REMOTE_UNREACHABLE); missing--appor--to(exit 2); a name that is no file name (exit 2, nothing sent);BAD_REQUESTexits 2, each other error of I7 keeps its code and exits 1 - B15: A gateway relays a push, and its refusals carry the caller's lease id: success;
UNKNOWN_APP; worker not connected - B16:
simlock files pushthen a read in the container, on a real simulator and a real emulator with a debuggable app: iOS; Android; on Android a folder withfiles/in it to., twice, after which the container andfileshave the modes they had
Done when
- The Android driver spawns no streaming child for a copy:
rg spawnStreaming src/drivers/android/app-files.tsprints nothing. website/scripts/check-openapi.mjspasses withPOST /v1/leases/{id}/files/{name}/push.- Slow lane (real simulator and real emulator): new cases in
e2e/slow-remote-cli.test.tspush a folder into the container of the Appduct fixture app and read it back withsimctl get_app_containerandadb shell run-as; the emulator's also pushes a folder holdingfiles/to.twice and compares the modes of the container andfiles.
Out of scope
Real iPhones and iPads, release Android apps, stopping the app, app groups. Pulling (#2007).
Depends on
- Lease files: put a folder on the worker, list it and remove it #2004 because:
TreeArchiveand the route action ofLeaseFiles.handle - Lease files: get a folder back #2005 because:
PROTOCOL_VERSION_RANGEandopenFileinsrc/lease-files/store.ts
Written by an agent.
Activity