Skip to content

Enrol physical devices automatically when they are connected (opt-in) #1503

Closed
2 of 2 issues completed
Closed

Description

@V3RON

Request: #1502

Problem

Every phone has to be enrolled by hand on its worker with simlock device add --platform ios|android <id>. On a host where phones are plugged in and swapped often, someone has to log in and run that each time. A phone nobody enrolled stays outside the pool, even though it's plugged in and ready.

Who it is for

An operator who runs a worker with a phone rack or a USB hub and adds, swaps or replaces phones over time. Also the coding agents that ask that worker for --physical devices. Today a request for a model the worker has no phone of fails at once with UNKNOWN_MODEL. A request for a model whose phones are all busy waits, or gets NO_CAPACITY, even with a new phone of that model plugged in.

Outcome

The operator turns on one worker setting, devices.autoEnroll. From then on, a phone plugged into the worker by USB joins the pool within about 30 seconds (one health.probeIntervalMs), with no command typed. It is enrolled exactly as simlock device add would enrol it, and an agent already waiting for a phone of that model (because the worker's other phones of it are busy) gets it. A phone the operator removes stays out until it is unplugged for about a minute (health.stableObservations intervals, 2 × 30 s by default) and plugged in again.

How it works for the user

flowchart TD
  A[Operator: simlock config set devices.autoEnroll true, restart] --> B[Phone plugged in by USB]
  B --> C{Within one interval: can it be enrolled?}
  C -- yes --> D[Enrolled ready, joins the pool; a waiting request is granted it]
  C -- "no: locked, not trusted, dev mode off, iOS < 17" --> E[One log line with the reason, tried again every interval]
  E --> C
  D --> F[Operator: simlock device remove]
  F --> G[Stays out while plugged in]
  G -- unplugged about a minute, plugged in again --> C
Loading

Before:

$ simlock device add --platform android R58M123ABC   # needed for every new phone

After:

$ simlock config set devices.autoEnroll true
Updated devices.autoEnroll in /Users/alex/.simlock/config.json; takes effect on daemon restart.
$ simlock daemon stop && simlock daemon start
# plug the phone in; within about 30 s it is listed in simlock status as ready

A phone that can't be enrolled yet leaves one line in the worker's log each time its reason changes, for example:

auto-enroll: android R58M123ABC not enrolled: USB debugging is not authorized for this host on the device

The text after not enrolled: is the same message simlock device add prints for that refusal.

Examples

A phone on the worker Today After, devices.autoEnroll: true
Android, USB, state device, not enrolled not enrolled enrolled within one interval
iPhone, USB, paired, unlocked, iOS 18 not enrolled enrolled within one interval
iPhone, USB, locked not enrolled one log line (locked); enrolled once unlocked
Android, USB, unauthorized not enrolled one log line (untrusted); enrolled once trusted
iPhone on iOS 16 not enrolled one log line, never enrolled
Apple TV (pairs over the network) not enrolled not listed, nothing logged
Android over the network (192.168.1.5:5555) not enrolled not listed, nothing logged
iPhone paired over Wi-Fi only not enrolled not listed, nothing logged
A phone already enrolled (any state) watcher's watcher's, never enrolled again
A phone removed with device remove, still plugged in not enrolled not enrolled until unplugged about a minute and plugged in again
The same, unplugged and back within one interval not enrolled still held out
The same, after a daemon restart not enrolled enrolled on the first interval
Any phone, devices.autoEnroll: false (the default) not enrolled not enrolled, as today

What could go wrong

  • A personal phone plugged into the worker to charge is enrolled and leased to an agent, and the agent installs and runs apps on it. Likely on a shared Mac, so the docs say it next to the setting.
  • The apps on a phone when it is enrolled are the ones kept. An app an agent left behind (its cleanup failed, then the phone was replugged) becomes a kept app.
  • After a daemon restart, a phone the operator removed but left plugged in comes back.

Words used

  • enrol: make a record for a physical device, so Simlock may lease it. Today only simlock device add does it.
  • kept apps: the apps installed on a phone when it is enrolled. A lease's cleanup uninstalls every other app. Example: Mail, installed at enrolment, stays.
  • live record: a device record in any state but deleted.
  • held out: a phone whose record went away while it stayed plugged in. Auto-enroll skips it until it has been off USB for health.stableObservations intervals in a row, then is plugged in again.
  • interval: health.probeIntervalMs, 30 s by default. The physical-device watcher already checks enrolled phones on it.

Non-goals

Completion conditions

  • With devices.autoEnroll: true, a phone connected to a worker becomes an enrolled ready device within one interval, and device.enrolled says initiator: "auto".
  • A --physical request already waiting for a model the worker has a phone of is granted an auto-enrolled phone of that model without another request.
  • With the setting off, or unset, no phone is enrolled without device add.
  • A phone that cannot be enrolled is retried every interval and logged once per reason. It is enrolled once it passes.
  • An enrolled phone is never enrolled again by this path, so its kept apps don't change.
  • A phone removed while plugged in stays out until it is missing for health.stableObservations intervals and comes back. device add still enrols it.
  • The website's configuration, enrolling and events pages describe the setting and the initiator field.

Open questions

Decisions

  • ADR 0073 — A worker may enrol the phones plugged into it (PR docs(adr): 0073 a worker may enrol the phones plugged into it #1505): the devices.autoEnroll opt-in, polling on the watcher's interval, the in-memory hold-out after a removal, device.enrolled's initiator, and the safety exceptions. It narrows ADR 0022 §3, §5 and §6.
  • One boolean for both platforms (not one key per platform). A platform with no started driver (no Android SDK, iOS on Linux) is not listed and logs nothing.
  • Listing Android phones may start the default adb server on port 5037, as any physical adb command already may (ADR 0022 §5); Simlock never stops it.
  • ADR 0022 is set to Accepted in PR docs(adr): 0073 a worker may enrol the phones plugged into it #1505: it shipped with Lease physical devices, not only simulators and emulators #428 and its status was left at Proposed.
  • No slow-lane line: the drivers' listing is proven against copies of real adb devices -l and devicectl list devices output. The enrolment logic is proven with the fake driver.

Shared values

Value or state Rule Written by Read by Source
Driver.listAttachedPhysical() Answers the canonical IDs of the phones on USB in any adb or pairing state: Android usb: transports on the default server behind its protocol check; iOS devicectl entries with transport wired. Network-only phones and emulators are not listed. Throws when the platform cannot be read. Sends nothing to any phone. #1507 #1508 ADR 0073 §2
Queue wake An auto-enrolment that commits wakes the leasing queue, as device add does (notifyAvailability). #1508 leasing (#1508) src/daemon/enrollment-wake.ts:9-20
devices.autoEnroll Boolean, default false, read at start, worker only. A non-boolean stops the start. #1508 #1508 ADR 0073 §1
device.enrolled.initiator "operator" from device add, "auto" from auto-enroll. #1508 #1508, the website events page ADR 0073 §4
Protocol version The config shape gains devices.autoEnroll: bump by one. #1508 — src/contract/AGENTS.md

Behaviours

Behaviour (invoker, action, what it sees) Seam Cases Task
The Android driver lists the phones on USB src/drivers/android/physical-handler.test.ts usb: in device, unauthorized, offline; a network serial; an emulator; protocol mismatch throws and sends no command #1507
The iOS driver lists the wired phones src/drivers/ios/physical.test.ts wired paired; wired unpaired; network only (localNetwork); sameMachine; devicectl fails or times out (throws) #1507
An operator with devices.autoEnroll: true plugs in a phone and it is enrolled e2e/physical-enrollment.test.ts an iPhone; an Android phone; a phone plugged in before the daemon starts; device.enrolled with initiator: "auto", its installed apps kept #1508
An agent waiting for a phone gets the auto-enrolled one e2e/physical-enrollment.test.ts one Pixel 9 enrolled and leased; a second --physical Pixel 9 request queued; a second Pixel 9 plugged in: the queued request is granted it #1508
An operator without the setting plugs in a phone and nothing happens e2e/physical-enrollment.test.ts unset; false #1508
A phone that can't be enrolled is retried and logged once per reason change e2e/physical-enrollment.test.ts locked, then unlocked: enrolled; untrusted for three intervals: one line; untrusted → locked → untrusted: three lines #1508
An enrolled phone is left alone e2e/physical-enrollment.test.ts ready, absent, quarantined, leased: no device.enrolled, kept apps unchanged #1508
A removed phone stays out until it is replugged e2e/physical-enrollment.test.ts device remove while plugged in; device remove before the next interval after its auto-enrolment; an operator's device add then device remove between two intervals; unenrolled after quarantine retries; missing one interval (still out); missing health.stableObservations intervals, then back (enrolled); device add while held out (enrolled) #1508
A restart forgets which phones are held out e2e/physical-enrollment.test.ts removed, still plugged in, daemon restarted: enrolled on the first interval #1508
Auto-enroll never enrols again an ID that got a record first src/core/physical-enrollment.test.ts an operator's device add commits between the listing and the enrolment: one record, no second device.enrolled #1508
A platform that cannot be listed is skipped for that interval e2e/physical-enrollment.test.ts the Android list throws three intervals: the iPhone is still enrolled, one log line; a held-out Android phone stays held out; no Android driver: nothing listed, nothing logged #1508
An operator's device add reports who enrolled e2e/physical-enrollment.test.ts device.enrolled with initiator: "operator" #1508
An operator sets devices.autoEnroll src/core/config.test.ts true; false; missing (false); "yes" refused #1508

Tasks

flowchart LR
  ADR["ADR 0073 (PR #1505)"] --> T1["#1507 drivers list USB phones"] --> T2["#1508 auto-enroll on the worker"]
Loading

Completion conditions → tasks: every condition is delivered by #1508. #1507 is the driver read it needs.

Open work in the same area:

Written by an agent.

Sub-issues

Sub-issues

2 of 2 Issues completed
Loading 2 sub-issues

Activity

  1. added
    feature:spec
    platform:ios
    platform:android
    on Nov 10, 2026
  2. added
    feature:planned
    and removed
    feature:spec
    on Nov 10, 2026
  3. V3RON commented on Nov 10, 2026

    @V3RON
    ContributorAuthor

    Spec updated: every section is written, and tasks #1507 → #1508 are ready. ADR 0073 (PR #1505) is accepted and not yet implemented.

    Written by an agent.

  4. github-actions commented on Nov 10, 2026

    @github-actions
    Contributor

    Closing: all 2 sub-issues are closed. The PR that closed the last one walks the completion conditions (delivery rule 9); reopen this if one does not hold on main. Flip its ADRs to Accepted if delivery has not.

  5. github-actions commented on Nov 10, 2026

    @github-actions
    Contributor

    Closing: all 2 sub-issues are closed. The PR that closed the last one walks the completion conditions (delivery rule 9); reopen this if one does not hold on main. Flip its ADRs to Accepted if delivery has not.

  6. V3RON commented on Nov 10, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: #1505 (ADR 0073), #1511 (#1507), #1514 (#1508)
    Parked: none
    Waiting: none
    Decided: none

    Written by an agent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature:plannedplatform:androidplatform:ios

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions