Skip to content

device attached lists the phones plugged into a worker that have no record #1134

Done

Description

@leonardoxr

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-phones segment), operations.test.ts.
  • src/core/physical-enrollment.ts: attached().
  • src/daemon/: server-requests.ts (device.attached joins PASSTHROUGH_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 from src/admin/index.ts.
  • src/cli/: commands/device.ts, the root help in index.ts, the fake client in test-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
Loading

Rules in play

  • ADR 0095 §1: its own operation and route, apart from GET /v1/devices; a gateway refuses it.
  • src/contract/AGENTS.md Adding an operation: every step, the protocol +1 included.
  • src/core/AGENTS.md: no driver I/O inside SerializedDecision; the lists run outside it, the record filter inside.
  • src/cli/AGENTS.md Output: remote text through escapeControl; an error is one JSON line on stderr.
  • src/http/AGENTS.md Route declarations: the route is declared and its segment is in CORE_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, absent or quarantined record left out; a deleted record's phone listed; a serial equal to a live record's hardware serial left out; nothing plugged in; every case runs with devices.autoEnroll at 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 (unreadable with 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.attached with UNSUPPORTED_IN_GATEWAY_MODE and I6's message.
  • B4: GET /v1/attached-phones with an admin token answers I1's shape; an agent token gets 403; a gateway 501.
  • B5: simlock device attached prints two phones, the empty line, an unreadable platform's line, and --json; and over the daemon socket a worker answers device.attached, not Unknown 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.ts passes with the Tests lines above.
  • The protocol range is one higher than on the base branch.
  • cli.mdx, errors.mdx, http-api.mdx and enrol-phones.mdx describe device attached and its route.
  • The website build and its HTTP API check pass.

Out of scope

Depends on

Written by an agent.

Activity

  1. V3RON commented on Nov 2, 2026

    @V3RON
    Contributor

    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 remove of an idle copy is a normal destroy; seeds and baselines are never devices, so it never removes them.

    Written by an agent.

  2. added
    task:draft
    on Nov 5, 2026
  3. changed the title [-]device remove deletes an idle simulator or emulator[/-] [+]device attached lists the phones plugged into a worker that have no record[/+] on Nov 27, 2026
  4. added
    task:ready
    and removed
    task:draft
    on Nov 27, 2026
  5. self-assigned this
    on Nov 30, 2026
  6. 3 remaining items

  7. V3RON commented on Nov 30, 2026

    @V3RON
    Contributor

    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.

  8. added
    task:blocked
    and removed
    task:ready
    on Nov 30, 2026
  9. removed their assignment
    on Nov 30, 2026
  10. added
    task:ready
    and removed
    task:blocked
    on Nov 30, 2026
  11. self-assigned this
    on Nov 30, 2026
  12. added
    task:blocked
    and removed
    task:ready
    on Nov 30, 2026
  13. removed their assignment
    on Nov 30, 2026
  14. added a commit that references this issue on Nov 30, 2026
    8778e41
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

    task:blocked

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions