Repository navigation
Description
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
Rules in play
- ADR 0092 §1 and §3: tags on the enrolled record, set any time, applied from the next grant;
requiresmet by the worker or the device. - ADR 0091 §1 and §3: the name rules;
requiresstays 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
Registrywrites the registry tables, insideSerializedDecision.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--tagskeeps them; re-enrol with--tagsreplaces 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 ofrequires, as the feature's Decisions say (decided in delivery, pending the maintainer); two waiters differing only inrequiresrefused 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 addand the console tile; a phone with none; an emulator
Done when
pnpm test:changedandpnpm typecheckpass, andpnpm exec vitest run --project ui-dom ui/src/screens/fleet/worker-page.dom.test.tsxpasses.- The CLI, HTTP API, errors, events, console and physical devices pages describe
device add --tags,device tag,PUT /v1/devices/{id}/tags,device.tags-changedand how a phone's tags meetrequires; the website build andnode website/scripts/check-openapi.mjspass.
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
test: a re-enrolment keeps a phone's tags unless it names tags, which…
test: simlock device add --tags sends the names in order (#1901)
feat(device): a re-enrolment keeps a phone's tags unless it names tag…
test: device tag replaces a phone's tags with the names given, and no…
feat(device): device.tag replaces a phone's tags (#1901)
test: device tag and device add refuse bad tags, and device tag refus…
feat(device): bad tags are refused with the config messages, and an e…
test: device.tags-changed is emitted after the commit only when a pho…
feat(core): a phone's tag change emits device.tags-changed after the …
test: simlock device tag prints the phone's tags (#1901)
17 remaining items
feat(gateway): a physical claim on a worker is keyed by the names the…
test: status.get lists a phone's tags (#1901)
docs: the CLI, HTTP API, errors, console and physical devices pages d…
docs: the CLI, HTTP API, errors, console and physical devices pages d…
test: device tag tests prove the claims their titles make: empty tags…
test: a worker serving every required name with no fitting phone is U…
test: device tag changes an absent phone, and an auto-enrolled phone'…
fix: list.get carries a phone's tags, a worker's own tag is no module…
fix: a grant that finds the phone's tags changed keeps it a candidate…
test: a waiter whose phone had its tags cleared at the grant check an…
docs(adr): 0092 to Accepted (#1901)
test: device add --json prints the phone's tags (#1901)
docs(adr): 0092 an enrolled device and a platform's virtual devices c…
feat(devices): operator tags on enrolled phones a lease can require (#…