feat(agent-device): the allocate reply reports the granted device mode

Merged
VI
1d ago
+34-16

The agent-device front now reports the granted mode: data.lease.device carries deviceMode, the mode the device has (ADR 0007 §8). Why: callstack/agent-device#4183 can only check a requested mode if the backend reports the grant, as its maintainer asked.

  • withGrantedDevice takes grant.device and adds deviceMode from device.mode. A phone has no mode, so no key.
  • Released agent-device (0.21.36) reads named fields only and ignores it.
  • A slim request can be granted full, and that is not an error (ADR 0007 §4, §8). A client should refuse only slim granted for full.
  • Builds on #1225, now merged, which sends the requested mode; this reports the mode the device has.

Status

  • Simulator and emulator replies carry deviceMode, slim and full, on a worker and through a gateway — edge.test.ts, gateway-front.test.ts, red before the fix
  • A phone's reply has no deviceMode — edge.test.ts, red when a phone is made to report one
  • pnpm exec vitest run --project unit src/agent-device/ src/source-hygiene.test.ts — 518 passed, 1 skipped, at e9e3df9; typecheck clean. Website build and OpenAPI check not repeated on this head
  • Real simulator: full and slim replies carry the granted deviceMode (local slow-lane test, 2026-11-05)

Assumptions

  • Assumption: field name — deviceMode, not simlock's mode, because lease.device is agent-device's reply shape and #4183 reads that key
  • Assumption: no issue — this answers a request on #4183, so the branch has no issue number

Review

Spec review: skipped. Code review: 0 blocking, 0 fixed, 0 notes. Claims review: 0 blocking, 0 fixed, 0 notes.

Rounds: 1. Tokens: 3M.

Spec review skipped: no issue. Code review ran behaviour and tests on Opus; Assessment: complete. Fix-check at 2bc64d6aa: a merge of main that keeps both sides unchanged, verified by the coordinator, no lens.

Hardware: pass. On a real iOS simulator, a local slow-lane test (not committed) allocated with deviceMode "full" and "slim" on a slim-default worker; the reply's data.lease.device.deviceMode matched the granted mode both times (2.5 min).

Review ledger: https://github.com/callstackincubator/simlock/pull/1254#issuecomment-6666908983

Written by an agent.