Skip to content

feat(agent-device): lease a physical phone through agent-device - #879

Merged
V3RON merged 29 commits into
task/873from
task/874
Oct 22, 2026
Merged

V3RON merged 29 commits into
task/873from
task/874

Conversation

@V3RON

@V3RON V3RON commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Closes #874

Status

Implement: done Review: passed (round 2 + fix-checks, 0 open) Hardware: pass (Android + iOS, 90ae8a9) Gate: waiting for the stack

Done when

  • edge.test.ts, gateway-front.test.ts and pnpm test:changed pass: B6–B14 — audit probed 14/14, covered 15/15; src/agent-device 468/468 after the end-to-end fixes
  • Slow lane, real phone: e2e/slow-agent-device-physical.test.ts — Samsung SM-A165F and iPhone 11 Pro Max (iOS 26.5), 2/2 pass at 90ae8a9
  • toolchain.md slow-lane row for agent-device with a physical phone names the signing variables the lane reads (team ID and bundle ID required; profile and identity only for manual signing)
  • allocate.ts maps physical, strips it before forwarding, and echoes it; host-link.ts routes and drops the simulator daemon's instance pins on phone calls; gateway.ts adopts at driverDeviceId — audit and review round 2
  • Website agent-device.mdx, physical-devices.mdx, configuration reference, src/agent-device/AGENTS.md, ADR 0023 status line and README row — audit and claims lens

Also checked by hand with the real agent-device CLI (0.21.31-dev with --physical): open, screenshot, snapshot, tap and close on both phones; refusals for an unknown model and --image-tag; the phone-daemon-down message.

Assumptions

  • Assumption: the routed link's lease-id order — it uses the leaseId argument and the allocate's own serial/udid; the RPC-body and header fallbacks are left out because the front and the relay always pass the lease id — the smallest change; nothing reaches forward without it.
  • Assumption: removal of a map entry on lease.release through the link — the lease-end hook already forgets every ended lease (release included), so the link does not read release replies.
  • Assumption: instance pins on a phone call — ADRs 0023, 0026 and 0043 do not decide them; the front drops x-agent-device-instance and x-agent-device-upstream-instance on calls routed to the phone daemon, because the client read them from the simulator daemon's health. A phone-daemon restart then ends the lease at the next heartbeat, as a simulator-daemon restart does (manual, Known gaps).
  • Assumption: the imageTag refusal wording — every simlock validation refusal carries its field path (src/contract/errors.ts:465), so the reply reads refused by simlock: imageTag: `imageTag` has no meaning for a physical device; the code keeps that and the spec's shorter wording is the one that is off.

Review

Spec review: 0 blocking, 0 fixed, 0 notes. Code review: 1 blocking, 1 fixed, 0 notes. Claims review: 0 blocking, 0 fixed, 0 notes.
Rounds: 2. Tokens: 13.6M.
Runs: 21. Cost USD: 10.1312. Agent seconds: 7133.

End-to-end on real phones: 4 blocking (R6 instance pins, R7 physical forwarded, R8 refusal wording, R9 signing keys), 3 fixed, R8 kept as an assumption; plus one slow-lane test fix (90ae8a9).

Rejected:

  • spec: the link skips the RPC-body and header lease fallbacks — [nonblocking] the front and relay always pass the lease id; header routing is tested (R2)
  • spec: the link keeps its map entry after a release — [nonblocking] lease end calls forget for every ended lease; removing it fails edge.test.ts:1060 (R3)
  • spec: two tests without a Tests line — [intentional] each is the only proof of a spec invariant (R4, R5)
  • spec: imageTag refusal has a field prefix the spec lacks — [intentional] every validation refusal carries its field path (R8)
  • code: edge.test.ts:827 title "(false for a virtual one)" has no case — [incorrect] the virtual case is at :754 and :770-777

Assessment: complete

Written by an agent.

V3RON added 22 commits October 22, 2026 10:28
@V3RON
V3RON added this pull request to stack #877 October 22, 2026 08:52
V3RON added 3 commits October 22, 2026 10:58
… stays on the simulator daemon; a phone lease's down daemon answers before the rules (#874)
@V3RON

V3RON commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Review ledger

Round 1: 6ca2d20
Round fix-check: f7e9bc2

Runs: 11. Cost USD: 7.0883. Agent seconds: 4856.
Tokens input 544, output 153139, cache read 24734931, cache write 836077.
- build implementer: claude-sonnet-5-5 1556 s $2.8142
- audit implementer: claude-sonnet-5-5 422 s $0.6926
- fix implementer: claude-sonnet-5-5 292 s $0.2508
- review 1 reviewer: claude-sonnet-5-5 993 s $0.3908
- review 1 spec-reviewer spec: claude-sonnet-5-5 48 s $0.2947
- review 1 code-reviewer both: claude-opus-5-5 829 s $1.9845
- review 1 claims-reviewer claims: claude-sonnet-5-5 99 s $0.231
- fix 1 implementer: claude-sonnet-5-5 467 s $0.1771
- fix 1 implementer: claude-sonnet-5-5 54 s $0.0698
- review fix-check reviewer: claude-sonnet-5-5 66 s $0.1186
- hardware hardware-verifier: claude-sonnet-5-5 30 s $0.0642
Finding outcomes: {"fixed":1,"intentional":2,"nonblocking":2}. Classes: {"assumption contradicts spec: entry removal":1,"assumption contradicts spec: lease order":1,"testing 1":1,"testing 7":2}.
{"findings":[
{"id":"R1","role":"code","class":"testing 1","outcome":"fixed","path":"src/agent-device/edge.test.ts","round":"1","fix":"3b9e6667ac32e3d7e80ec0aef27936f96cd45a43"},
{"id":"R2","role":"spec","class":"assumption contradicts spec: lease order","outcome":"nonblocking","path":"src/agent-device/front/host-link.ts","round":"1"},
{"id":"R3","role":"spec","class":"assumption contradicts spec: entry removal","outcome":"nonblocking","path":"src/agent-device/front/host-link.ts","round":"1"},
{"id":"R4","role":"spec","class":"testing 7","outcome":"intentional","path":"src/agent-device/edge.test.ts","round":"1"},
{"id":"R5","role":"spec","class":"testing 7","outcome":"intentional","path":"src/agent-device/edge.test.ts","round":"1"}
]}

Written by an agent.

@V3RON
V3RON marked this pull request as ready for review October 22, 2026 09:37
@V3RON V3RON added the needs-hardware PR parked: a Done when line needs a real simulator or emulator run. label Oct 22, 2026
V3RON added 4 commits October 22, 2026 12:08
… pins and the phone daemon no longer receives physical (#874)
…s: lease scope and device key in meta, the phone's address in flags, an open first (#874)

The raw screenshot carried only the lease id, so agent-device refused it (tenant isolation requires run id, then lease owner scope, no session, ambiguous device). The test was wrong, not Simlock. Also: only a provisioning profile switches agent-device to manual signing.
@V3RON

V3RON commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Review notes

Not blocking, not verified. Each is one reviewer's claim.

  • code: e2e/slow-agent-device-physical.test.ts:26 the comment says a signing identity alone keeps agent-device on automatic signing; that is an agent-device fact (runner-cache-metadata.ts at v0.21.28) the repo does not pin.
  • code: src/agent-device/testing.ts FakeAgentDevice never checks x-agent-device-upstream-instance, so only the slow lane proves that header is dropped on phone calls.

Written by an agent.

@V3RON V3RON removed the needs-hardware PR parked: a Done when line needs a real simulator or emulator run. label Oct 22, 2026
@V3RON

V3RON commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Review ledger

Round 1: 6ca2d20
Round fix-check: f7e9bc2
Round 2: 19ab1ff
Round fix-check: 11de40a
Round fix-check: 90ae8a9

Runs: 21. Cost USD: 10.1312. Agent seconds: 7133.
Tokens input 862, output 226278, cache read 30794504, cache write 1270374.
- build implementer: claude-sonnet-5-5 1556 s $2.8142
- audit implementer: claude-sonnet-5-5 422 s $0.6926
- fix implementer: claude-sonnet-5-5 292 s $0.2508
- review 1 reviewer: claude-sonnet-5-5 993 s $0.3908
- review 1 spec-reviewer spec: claude-sonnet-5-5 48 s $0.2947
- review 1 code-reviewer both: claude-opus-5-5 829 s $1.9845
- review 1 claims-reviewer claims: claude-sonnet-5-5 99 s $0.231
- fix 1 implementer: claude-sonnet-5-5 467 s $0.1771
- fix 1 implementer: claude-sonnet-5-5 54 s $0.0698
- review fix-check reviewer: claude-sonnet-5-5 66 s $0.1186
- hardware hardware-verifier: claude-sonnet-5-5 30 s $0.0642
- fix 2 implementer: claude-sonnet-5-5 350 s $0.3807
- review 2 reviewer: claude-sonnet-5-5 502 s $0.3362
- review 2 code both: claude-opus-5-5 402 s $1.2386
- review 2 claims: claude-sonnet-5-5 20 s $0.0737
- fix fix-check implementer: claude-sonnet-5-5 68 s $0.1196
- review fix-check reviewer: claude-sonnet-5-5 57 s $0.1076
- hardware hardware-verifier: claude-sonnet-5-5 103 s $0.083
- hardware-fix implementer: claude-sonnet-5-5 630 s $0.5029
- hardware hardware-verifier: claude-sonnet-5-5 96 s $0.0787
- review fix-check reviewer: claude-sonnet-5-5 49 s $0.1219
Finding outcomes: {"fixed":4,"intentional":3,"nonblocking":2}. Classes: {"assumption contradicts spec: entry removal":1,"assumption contradicts spec: lease order":1,"imageTag refusal wording vs spec":1,"phone daemon rejects simulator instance pins":1,"physical key forwarded to agent-device":1,"signing keys required that force manual signing":1,"testing 1":1,"testing 7":2}.
{
 "findings": [
  {
   "id": "R1",
   "role": "code",
   "class": "testing 1",
   "outcome": "fixed",
   "path": "src/agent-device/edge.test.ts",
   "round": "1",
   "fix": "3b9e6667"
  },
  {
   "id": "R2",
   "role": "spec",
   "class": "assumption contradicts spec: lease order",
   "outcome": "nonblocking",
   "path": "src/agent-device/front/host-link.ts",
   "round": "1"
  },
  {
   "id": "R3",
   "role": "spec",
   "class": "assumption contradicts spec: entry removal",
   "outcome": "nonblocking",
   "path": "src/agent-device/front/host-link.ts",
   "round": "1"
  },
  {
   "id": "R4",
   "role": "spec",
   "class": "testing 7",
   "outcome": "intentional",
   "path": "src/agent-device/edge.test.ts",
   "round": "1"
  },
  {
   "id": "R5",
   "role": "spec",
   "class": "testing 7",
   "outcome": "intentional",
   "path": "src/agent-device/edge.test.ts",
   "round": "1"
  },
  {
   "id": "R6",
   "role": "e2e",
   "class": "phone daemon rejects simulator instance pins",
   "outcome": "fixed",
   "path": "src/agent-device/front/host-link.ts",
   "round": "2",
   "fix": "19ab1ffe"
  },
  {
   "id": "R7",
   "role": "e2e",
   "class": "physical key forwarded to agent-device",
   "outcome": "fixed",
   "path": "src/agent-device/front/allocate.ts",
   "round": "2",
   "fix": "19ab1ffe"
  },
  {
   "id": "R8",
   "role": "e2e",
   "class": "imageTag refusal wording vs spec",
   "outcome": "intentional",
   "path": "src/contract/errors.ts",
   "round": "2"
  },
  {
   "id": "R9",
   "role": "e2e",
   "class": "signing keys required that force manual signing",
   "outcome": "fixed",
   "path": "e2e/slow-agent-device-physical.test.ts",
   "round": "fix-check",
   "fix": "11de40af"
  }
 ]
}

Supersedes the earlier ledger comment on this PR.

Written by an agent.

@V3RON
V3RON merged commit 73c98f0 into main Oct 22, 2026
52 checks passed
@V3RON
V3RON deleted the task/874 branch October 22, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

agent-device: a physical allocate leases an enrolled phone and every call for that lease reaches the phone daemon

1 participant