Repository navigation
Description
Part of #1131.
Scope
An admin on a worker can list the phones plugged into it that Simlock has no record of, with simlock device attached, GET /v1/attached-phones or the admin client, and see which platform could not be read. A gateway refuses the call. This is what the console's Enrol phone… dialog (#1133) reads.
If this goes wrong, a user would notice a plugged-in phone missing from the list, an enrolled one listed, or one slow platform hiding the other's phones.
Technical spec
Commit 4b39322.
Rows
- Behaviours: B1, B2, B3, B4, B5
- Interfaces: I1, I2, I3, I4, I5, I6
- Existing code: X1, X2, X4, X5, X6, X7, X8, X15, X17
Facts
| # | Fact | Source |
|---|---|---|
| F1 | The dispatcher's device tests build a real core over FakeDriver in "Dispatcher: device.add and device.remove" |
src/daemon/dispatcher-exec.test.ts:780 |
| F2 | FakeDriver answers listAttachedPhysical and can be made to fail or wait through #beforeCall |
src/core/fake-driver.ts:62, :640-641 |
| F3 | The gateway's by-design refusals are tested under "UNSUPPORTED_IN_GATEWAY_MODE" | src/gateway/dispatcher-alerts-and-refusals.test.ts:293 |
| F4 | The /v1/devices route tests sit in app.test.ts |
src/http/app.test.ts:251 |
| F5 | The CLI's device tests, usage lines included, sit in "CLI: device add and device remove" | src/cli/index-device-config.test.ts:9, :63 |
| F6 | Adding an operation also needs rows in the role and effect matrices | src/contract/operations.test.ts (an operation missing from either fails, src/contract/AGENTS.md Operations) |
| F7 | PhysicalEnrollment reads drivers and the registry snapshot under decisions.run |
src/core/physical-enrollment.ts:152-159, :244-249 |
| F8 | A socket request reaches the dispatcher only when its operation is in PASSTHROUGH_OPERATIONS; anything else answers Unknown request type |
src/daemon/server-requests.ts:24, :60-61 |
Modules touched
Searches: device.remove, deviceRemove, removeDevice, listAttachedPhysical, wakingQueueAfter, CORE_ROUTE_SEGMENTS, DEVICE_USAGE, "device remove" in src/ and website/.
src/contract/:operations-fleet.ts(deviceAttached),operations.ts(OPERATIONS),protocol.ts(+1,attached-phonessegment),operations.test.ts.src/core/physical-enrollment.ts:attached().src/daemon/:server-requests.ts(device.attachedjoinsPASSTHROUGH_OPERATIONS),dispatcher-devices.ts(handler),dispatcher-options.ts(port),enrollment-wake.ts(pass-through),worker-composition.ts, the dispatcher's handler table.src/gateway/dispatcher.ts: the refusal.src/http/:route-declarations.ts,app.ts.src/simlock-client/:client-api.ts,client-impl.ts,client-degraded.ts,types.ts; re-exported fromsrc/admin/index.ts.src/cli/:commands/device.ts, the root help inindex.ts, the fake client intest-index.ts.website/src/content/docs/docs/reference/cli.mdx,errors.mdx(the gateway refusal),using-devices/http-api.mdx,worker/enrol-phones.mdx.
flowchart LR
cli["cli device attached *"] --> client["simlock-client *"]
http["http route *"] --> disp
client --> disp["daemon device handlers *"]
disp --> enr["core PhysicalEnrollment.attached *"]
enr --> drv[drivers listAttachedPhysical]
gw["gateway dispatcher *"] -.refuses.-> client
Rules in play
- ADR 0095 §1: its own operation and route, apart from
GET /v1/devices; a gateway refuses it. src/contract/AGENTS.mdAdding an operation: every step, the protocol +1 included.src/core/AGENTS.md: no driver I/O insideSerializedDecision; the lists run outside it, the record filter inside.src/cli/AGENTS.mdOutput: remote text throughescapeControl; an error is one JSON line on stderr.src/http/AGENTS.mdRoute declarations: the route is declared and its segment is inCORE_ROUTE_SEGMENTS.- documentation rule 9: the CLI, HTTP and phone pages change in this PR.
Tests
Seam: Dispatcher.dispatch("device.attached") over a real core and FakeDriver, modelled on src/daemon/dispatcher-exec.test.ts (F1); the gateway, HTTP and CLI seams on F3, F4 and F5.
- B1: an admin lists the phones plugged into a worker and sees each one with no live record: an iOS and an Android phone with no record, sorted; a phone with a
ready,leased,absentorquarantinedrecord left out; adeletedrecord's phone listed; a serial equal to a live record's hardware serial left out; nothing plugged in; every case runs withdevices.autoEnrollat its default, off, and the list never reads the key (decided in delivery, pending the maintainer). - B2: a platform cannot be read and the other's phones still come: a throwing list (
unreadablewith its message); a list answering after 8 s (did not answer within 8 seconds); no driver for a platform (in neither list). - B3: a gateway refuses
device.attachedwithUNSUPPORTED_IN_GATEWAY_MODEand I6's message. - B4:
GET /v1/attached-phoneswith an admin token answers I1's shape; an agent token gets 403; a gateway 501. - B5:
simlock device attachedprints two phones, the empty line, an unreadable platform's line, and--json; and over the daemon socket a worker answersdevice.attached, notUnknown request type(src/daemon/server-requests.test.ts).
Done when
pnpm exec vitest run --project unit src/daemon/dispatcher-exec.test.ts src/gateway/dispatcher-alerts-and-refusals.test.ts src/http/app.test.ts src/cli/index-device-config.test.ts src/contract/operations.test.ts src/daemon/server-requests.test.tspasses with the Tests lines above.- The protocol range is one higher than on the base branch.
cli.mdx,errors.mdx,http-api.mdxandenrol-phones.mdxdescribedevice attachedand its route.- The website build and its HTTP API check pass.
Out of scope
- The console (Console: enrol a phone from the plugged-in list or by id, and remove an enrolled one #1133).
- A phone's model or OS in the list.
- Deleting a simulator or emulator.
- A gateway relay of the call.
Depends on
- Operator tags on enrolled phones a lease can require #1901 (it also changes the device handlers, the enrolment port and its wake wrapper, the
deviceusage lines and the protocol range)
Written by an agent.
Activity
V3RON commentedon Nov 2, 2026
Related: under #327 (Named baselines, ADR 0061) every simulator and emulator serves one lease and is destroyed at release, and baselines have their own
simlock baseline remove(task #1206).device removeof an idle copy is a normal destroy; seeds and baselines are never devices, so it never removes them.Written by an agent.
[-]device remove deletes an idle simulator or emulator[/-][+]device attached lists the phones plugged into a worker that have no record[/+]test: a platform that cannot be read leaves the other's phones listed (…
feat(core): an unreadable platform is reported and the other's phones…
test: a gateway refuses device.attached with UNSUPPORTED_IN_GATEWAY_M…
test: an admin reads GET /v1/attached-phones and an agent is refused (#…
feat(http): GET /v1/attached-phones answers device.attached (#1134)
test: simlock device attached prints the phones, the empty line, an u…
feat(cli): simlock device attached lists the phones a worker could en…
test: a worker answers device.attached over the daemon socket (#1134)
3 remaining items
test: the enrollment wake passes attached through and wakes nothing (#…
docs(website): the device attached sample lists android before ios, a…
test: device attached pins its list order, escaping, help, extra-argu…
V3RON commentedon Nov 30, 2026
Handoff
Done
PR #1971 passed review and is ready, in stack #1903, #1971, #1975. main's #1977 took protocol 109, so this takes 110.
Not done
The merge. The stack merges together, from the top, #1975.
Findings
If another PR that raises the protocol merges first (#1895), run
stack-sync.sh 1975, and #1971 takes the next number.Blocked on
fast-track: #1134 held: its reporter leonardoxr cannot write to the repo, so the maintainer merges PR #1971.#1133 has the same reporter. The maintainer merges the stack by hand.Written by an agent.
feat(devices): device attached lists the phones plugged into a worker…