Skip to content

Operator tags on enrolled phones a lease can require #1901

Done

Description

@V3RON

Part of #1894.

Scope

An operator tags an enrolled phone with simlock device add --tags or simlock device tag, with no restart. A lease with --physical --requires <tag> is then granted only a phone that carries the tag (or whose worker does), waits for it while it is busy, and fails CAPABILITY_MISSING when only untagged phones fit. simlock status, device add and the console show a phone's tags.

If it goes wrong, a test lands on an untagged phone, waits for ever on a tag no phone has, or a tag the operator set is lost at a restart.

Technical spec

Commit 4b39322.

Rows

  • Behaviours: B5, B6, B7, B8, B9
  • Stored state: S2
  • Interfaces: I5, I6, I7, I8, I9, I10, I11
  • Existing code: X3, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15, X17

Facts

# Fact Source
F1 The devices table gains columns by ALTER TABLE devices ADD COLUMN in a registry migration src/core/registry-schema.ts:143-145
F2 device.add is refused on a gateway by unsupportedByDesign src/gateway/dispatcher.ts:288
F3 POST /v1/devices takes a strict body { id, platform } src/http/route-declarations.ts:38-47
F4 A device.* event marks the console's worker keys stale ui/src/model/stale-keys.ts:40
F5 Leasing's requires sits in LeaseRequestOptions; physicalRequestOf reads only the device request src/leasing/wait-queue.ts:21, src/leasing/acquisition-requests.ts:14-21
F6 Today's device add line src/cli/commands/device.ts:100

Modules touched

core (registry, enrolment, fitsPhysical), contract (device.add, device.tag, status device, protocol), bus (events), leasing (physical request, older waiters), daemon (handlers, error mapping, wake), gateway (dispatcher refusal, physicalMatch, refusal key), http, simlock-client and admin, cli, ui. Searches: rg fitsPhysical, rg physicalMatch, rg physicalMatchKey, rg "device.add|deviceAdd", rg enrollPhysical, rg "device.enrolled".

flowchart LR
  CLI[cli device add / tag] --> C[contract device.tag]
  HTTP[http PUT tags] --> C
  C --> D[daemon handler]
  D --> E[core enrolment + registry tags]
  D --> L[leasing physical request deviceTags]
  E --> B[bus device.tags-changed]
  G[gateway physicalMatch with tags] --> C
  UI[console tile] --> C
Loading

Rules in play

  • ADR 0092 §1 and §3: tags on the enrolled record, set any time, applied from the next grant; requires met by the worker or the device.
  • ADR 0091 §1 and §3: the name rules; requires stays the stored, replay-compared field.
  • Contract manual, adding an operation: role and effect matrices, protocol + 1, handlers on worker and gateway, client method, errors page.
  • Bus manual, adding an event: EventMap, EVENT_NAMES, both catalogs.
  • Core manual: only Registry writes the registry tables, inside SerializedDecision.run; the event goes out after the commit.

Tests

Seam: the CLI over the admin client with a fake driver, the worker Dispatcher, gateway routing over views, and the console DOM test; model on src/cli/index-device-config.test.ts, src/leasing/physical-leasing.test.ts, src/gateway/routing/request-match.test.ts and ui/src/screens/fleet/worker-page.dom.test.tsx.

  • B5: enrol a phone with --tags: one tag; two in order; none; each bad name of Examples (exit 2); re-enrol without --tags keeps them; re-enrol with --tags replaces them; auto-enrol: none; restart: kept
  • B6: device tag <id> [names]: two names; none clears; same tags again (no event); leased phone; absent phone; bad name (BAD_REQUEST, exit 2); unknown id (UNKNOWN_DEVICE); an emulator's id (BAD_REQUEST); agent role (FORBIDDEN); on a gateway (UNSUPPORTED_IN_GATEWAY_MODE)
  • B7: a physical lease on a worker with requires: every physical row of Examples; an older tagged waiter does not hold an untagged phone; a tag added while waiting is granted without another event; a replay of a waiting request
  • B8: a physical lease through a gateway with requires: A's tagged phone vs B's untagged; A's tagged phone leased (waits); only untagged phones fit (CAPABILITY_MISSING); no phone fits the model (UNKNOWN_MODEL), also on a worker that itself serves every name of requires, as the feature's Decisions say (decided in delivery, pending the maintainer); two waiters differing only in requires refused apart, and two that list the same names in another order share one claim, as X7's sorted key says (decided in delivery, pending the maintainer)
  • B9: tags shown: a phone with two tags in status, device add and the console tile; a phone with none; an emulator

Done when

  • pnpm test:changed and pnpm typecheck pass, and pnpm exec vitest run --project ui-dom ui/src/screens/fleet/worker-page.dom.test.tsx passes.
  • The CLI, HTTP API, errors, events, console and physical devices pages describe device add --tags, device tag, PUT /v1/devices/{id}/tags, device.tags-changed and how a phone's tags meet requires; the website build and node website/scripts/check-openapi.mjs pass.

Out of scope

Editing tags from the console (#1133's area); setting tags through a gateway; an MCP tool for tags.

Depends on

Written by an agent.

Activity

  1. added
    task:draft
    on Nov 27, 2026
  2. added
    task:ready
    and removed
    task:draft
    on Nov 27, 2026
  3. self-assigned this
    on Nov 30, 2026
  4. 17 remaining items

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

Metadata

Metadata

Assignees

Labels

task:ready

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions