Repository navigation
Description
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
Before:
$ simlock device add --platform android R58M123ABC # needed for every new phoneAfter:
$ 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 readyA 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 adddoes 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.stableObservationsintervals 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
- Phones reached over the network (Enrol Android phones reached over the network (adb connect host:port) #1250).
- An allowlist of serials or models: every phone that passes
device add's checks is taken. - Showing phones that cannot be enrolled yet in
simlock status, doctor or the console. The log only. - A lasting "do not enrol" list that survives a restart.
- Turning the setting on or off without a restart.
- Enrolling from the console (Console: enrol and remove phones, and delete idle simulators and emulators #1131, Console: enrol a phone from the plugged-in list or by id, and remove an enrolled one #1133).
- Instant detection: no USB notifications.
- Letting a request wait for a model the worker has no phone of. It still fails at once with
UNKNOWN_MODEL, as today (ADR 0022 §6).
Completion conditions
- With
devices.autoEnroll: true, a phone connected to a worker becomes an enrolledreadydevice within one interval, anddevice.enrolledsaysinitiator: "auto". - A
--physicalrequest 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.stableObservationsintervals and comes back.device addstill enrols it. - The website's configuration, enrolling and events pages describe the setting and the
initiatorfield.
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.autoEnrollopt-in, polling on the watcher's interval, the in-memory hold-out after a removal,device.enrolled'sinitiator, 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
adbcommand 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 -landdevicectl list devicesoutput. 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"]
- Drivers list the phones on USB, enrolled or not #1507 Drivers list the phones on USB — nothing a user sees yet. Each driver can name every phone plugged in, enrolled or not. Risk: a phone missing from the list, or a network phone in it.
- A worker enrols the phones plugged into it under devices.autoEnroll #1508 A worker enrols the phones plugged into it under
devices.autoEnroll— the operator turns the setting on and plugged-in phones join the pool. Risk: a phone enrolled the operator removed, or one enrolled twice.
Completion conditions → tasks: every condition is delivered by #1508. #1507 is the driver read it needs.
Open work in the same area:
- Enrol Android phones reached over the network (adb connect host:port) #1250 (network adb, request:new): it would change what counts as attached. No Depends on: it is not specified. If it lands, network phones stay out of auto-enroll unless that spec says otherwise.
- Console: enrol and remove phones, and delete idle simulators and emulators #1131 / Console: enrol a phone from the plugged-in list or by id, and remove an enrolled one #1133 (enrol from the console, feature:spec / task:draft): they share
PhysicalEnrollment.addbut not its changed lines. No Depends on. - Allow a worker to serve physical Android devices only (never boot emulators) #1181 (Android-only worker, request:new): worker config only, different keys. No Depends on.
- device attached lists the phones plugged into a worker that have no record #1134 (device remove on simulators, task:draft): bumps the protocol and edits the
device.deletedrows of EVENTS.md andevents.mdx, next to thedevice.enrolledrow A worker enrols the phones plugged into it under devices.autoEnroll #1508 changes. No Depends on: different rows, and the PR that merges second bumps again. - Console: enrol a phone from the plugged-in list or by id, and remove an enrolled one #1133 edits
worker/enrolling-physical-devices.mdxin another section. No Depends on. - Runtime warm-pool targets: warm.set and warm.list, kept in state.db #1143 (runtime warm-pool targets, task:draft): bumps the protocol, adds an event to
src/bus/index.tsand edits EVENTS.md andevents.mdx. No Depends on: different entries, and the PR that merges second bumps again. - Settings: read every setting through GET /v1/config #1153 / Settings: change a setting through the daemon, live where it can #1154 (settings through the daemon, task:draft): bump the protocol, and Settings: read every setting through GET /v1/config #1153 lists every config key, so it will list
devices.autoEnrollonce A worker enrols the phones plugged into it under devices.autoEnroll #1508 lands. No Depends on: whichever merges second adds the key or bumps again.
Written by an agent.
Activity
docs(adr): 0073 the queue wake, the 5037 start and the replug timing (#…
docs(adr): 0073 the waiting-request scope and the hold-out after an a…
docs(adr): 0073 the hold-out covers a record made and removed between…
docs(adr): accept 0073 (#1503)
V3RON commentedon Nov 10, 2026
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.
docs(adr): 0073 a worker may enrol the phones plugged into it (#1505)
feat(core): a worker enrols the phones plugged into it under devices.…
github-actions commentedon Nov 10, 2026
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.github-actions commentedon Nov 10, 2026
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.V3RON commentedon Nov 10, 2026
Delivery run
Merged: #1505 (ADR 0073), #1511 (#1507), #1514 (#1508)
Parked: none
Waiting: none
Decided: none
Written by an agent.