Skip to content

A lease's label names its device: lease --label #1745

Closed
3 of 3 issues completed
Closed

Description

@V3RON

Request: #1240

Problem

When several leases are open on one machine, every Android emulator window is titled simlock <id>:<port>, and iOS simulators keep Simlock's generated names. With two or more windows open, nothing on screen says which window belongs to which lease, so you match serials by hand.

Who it is for

A developer running parallel coding agents on one Mac, one per git worktree, each with its own leased device and its own app build. They switch between devices all day, in device windows or in the console's Leases page, and need to tell at a glance which one runs which branch.

Outcome

An agent names its lease when it asks for it: simlock lease --platform ios --label feature-x. The name then shows wherever the lease shows: the console's Leases page, simlock status, and the lease as every surface reads it, on iOS and Android, simulators and phones alike. An iOS simulator booted for a labelled lease also carries the label as its own name, so DeviceHub, Simulator.app and simctl list show feature-x. A lease asked for without a label looks as it does today.

How it works for the user

flowchart TD
  A["agent: simlock lease --label feature-x"] --> B{label valid?}
  B -- "empty, over 64, control character" --> R["refused: BAD_REQUEST, nothing queued"]
  B -- yes --> C[request queued as today]
  C --> D{device for it}
  D -- "iOS simulator booted for the lease" --> E["simulator renamed feature-x, then booted"]
  D -- "warm iOS simulator granted as it is, Android, phone" --> F[device keeps its own name]
  E --> G[lease granted, label stored with it]
  F --> G
  G --> H["console Leases, simlock status, lease reads: feature-x"]
  G --> I[lease ends: device deleted or reclaimed, label goes with the lease]
Loading

Before:

$ simlock lease --platform ios --label feature-x
{"error":{"code":"USAGE","message":"Unknown option '--label'. To specify a positional argument starting with a '-', place it at the end of the command after '--', as in '-- \"--label\""}}

After:

$ simlock lease --platform ios --label feature-x
... (the grant, as today)
$ simlock status
...
Lease 7c1e…: agent:claude-1 on mac-mini, label feature-x since 1763542000000, last renewed 1763542000000
$ xcrun simctl list devices        # Xcode's device set, ios.simulator.headless false
    feature-x (5D2F…) (Booted)
$ simlock lease --platform ios --label ""
{"error":{"code":"BAD_REQUEST","message":"label must be 1 to 64 characters"}}

Examples

--label Today After
none granted granted, no label
feature-x usage error granted, label feature-x
fix/login sheet usage error granted, label as given
café 🚀 usage error granted, label as given
64 characters usage error granted
"" usage error BAD_REQUEST: label must be 1 to 64 characters
65 characters usage error BAD_REQUEST: label must be 1 to 64 characters
a⏎b, a tab, NUL, U+2028 usage error BAD_REQUEST: label must not contain control characters
feature-x on --platform android usage error granted, label shown on the lease, emulator window unchanged
feature-x with --physical usage error granted, label shown on the lease, phone not renamed

A character is a UTF-16 unit, as JavaScript counts a string: 🚀 counts as two.

What could go wrong

  • A rename that fails leaves an iOS simulator under its generated name while the lease shows the label. The lease still works; the failure is logged. Rare: simctl rename of a shut-down simulator has no known failure.
  • A warm iOS simulator in Simlock's own device set is granted as it is, so it keeps its generated name; only the lease shows the label there. That set has no window, so nothing on screen disagrees.
  • Two leases may carry the same label. Simlock tells devices apart by UDID, never by name, so nothing breaks, but a person's script that picks a simulator by name (-destination name=feature-x) may pick the wrong one.

Words used

  • label: the name an agent gives its lease, e.g. feature-x. Display only: it never chooses a device.
  • warm simulator: one Simlock booted ahead of any request, e.g. by the warm pool, and grants as it is.
  • Xcode's device set: drivers.ios.deviceSet: "default", where simulators live beside your own and open in DeviceHub; Simlock's own set ("simlock", the default) has no window.
  • prepare boot: a boot that makes a device ready for use (a new device, a shut-down one, a warm one booted again for a lease); a recovery boot is the one the health monitor runs under a lease after a device stopped answering.

Non-goals

  • An Android emulator window titled with the label. The window title is the AVD name, and every copy keeps the seed's name simlock so its boot snapshot loads; a copy under another name cold-boots in ~16 s instead of ~4 s (ADR 0061, measured).
  • Renaming a physical device.
  • Changing a lease's label after the grant.
  • A default label (from the git branch or the folder): no label means no label.
  • Matching or routing on a label, or unique labels.
  • A label from agent-device's Simlock provider: that is an agent-device option, for a later change on that side.
  • The label in events or in history.db.
  • Showing a waiting request's label in the console.

Completion conditions

  • simlock lease --platform ios --label feature-x on a worker with drivers.ios.deviceSet: "default" and ios.simulator.headless: false opens the leased simulator in DeviceHub or Simulator.app titled feature-x, and simlock status prints label feature-x on its lease line.
  • The same lease shows feature-x on its row in the console's Leases page, and a search for feature finds it both in the Leases page filter and in the search dialog.
  • simlock lease --platform android --label feature-x is granted, and its lease shows feature-x in simlock status and the console.
  • MCP lease_simulator with label and POST /v1/lease-requests with label grant a lease whose GET /v1/leases/{id} answer carries the label.
  • simlock lease --label "" fails with BAD_REQUEST and queues nothing.
  • A lease asked for without a label prints and shows exactly what it does today.

Open questions

none

Decisions

  • No ADR: the label is one optional field on an existing request and record, display-only, following runId's path end to end.
  • Decided in the session (maintainer): the label is stored with the lease and shown in the console and simlock status on both platforms, and also names the iOS simulator, because most iOS workers are headless and Android cannot title its window.
  • Decided in the session (maintainer): set only from Simlock's own surfaces (CLI, MCP, HTTP, gateway forwarding); agent-device's provider later.
  • Decided in the session: 1 to 64 characters, no control characters (Unicode Cc, U+2028, U+2029), spaces and / allowed, because a label is display text such as a branch name, and 64 fits a window title; control characters could break a printed line or a simctl argument.
  • Decided in the session: every prepare boot of an iOS simulator renames it, to the lease's label or, without one, back to its stored name, because then a label can never stay on a simulator its lease did not get (a grant that failed after the boot, a crash), with no rename-back step anywhere.
  • Decided in the session: a rename runs before simctl boot, bounded at 5 s; a failure is logged and the boot goes on, because the name is display-only and must never cost a lease. Before the boot, because Simulator.app titles its window once and keeps it (measured on feat(ios): lease --label names the leased simulator #1243: a rename of a booted simulator does not retitle its open window); DeviceHub follows a rename at once, before or after the boot (measured 2026-11-19, Xcode 27.2: a simulator renamed while shut down and DeviceHub open retitled the window feature-x – iOS 27.2 with no reselect, and kept it through simctl boot; a rename of the booted simulator retitled it again).
  • Decided in the session: a warm simulator granted without a boot (Simlock's own set) is not renamed, because that set has no window and a rename there would add driver I/O to every labelled grant for a name nobody sees; on Xcode's set every warm simulator is booted again before its grant, so it takes the label.
  • Decided in the session: an idempotent repeat with another label is a conflict, like a repeat with another runId.
  • Decided in the session: the label is stored with the request and the lease, like runId, so a restart keeps it on a granted lease.
  • Decided in the session: simlock status prints , label <label> after the run on the lease line.
  • Decided in the session (maintainer): the console shows the label as the first line of the Leases table's "Held by" cell, above the holder, so it stays on every width; the side list's second line reads <label> · <model>; the lease drawer shows Label.
  • Decided in the session (maintainer): both console searches match the label: the Leases page filter, and the search dialog, whose lease result reads <label> · <holder> · <model>.
  • Decided in the session: the field is called label, as the request asks; it sits at the top of a lease, apart from worker.label.

Behaviours

Id Behaviour (invoker, action, what it sees) Seam Cases Task
B1 A caller sends lease.request with a bad label and is refused BAD_REQUEST with the message of I1 on every transport; nothing is queued daemon dispatcher (src/daemon/dispatcher.ts), HTTP POST /v1/lease-requests (src/http/app.ts) ""; 65 characters; a\nb; \t; NUL; U+2028; U+2029; through HTTP the same message #1755
B2 A caller's granted lease carries the label it asked with in lease.request's grant, lease.get, lease.list and status.get; a lease without one has no label field daemon dispatcher, with fake drivers label on an iOS simulator; Android emulator; physical phone; no label; 64 characters; café 🚀; fix/login sheet #1755
B3 A granted lease keeps its label across a daemon restart createLeasing over a reopened state.db labelled lease loaded; unlabelled lease loaded; a store from before the migration loads with no labels #1755
B4 An idempotent repeat of a request answers as today when the label matches, and IDEMPOTENCY_CONFLICT when it differs daemon dispatcher same label; other label; label on one only; neither #1755
B5 A user runs simlock lease --label <l>: the request carries it, checked only by the daemon; simlock status prints , label <l> on the lease line CLI (src/cli/index.ts runner with a fake client) --label feature-x; no --label; --label "" sent as is and the daemon's BAD_REQUEST printed (never a local USAGE); --label with --run (both printed, run first) #1755
B6 An agent calls MCP lease_simulator with label, or POSTs /v1/lease-requests with label: the lease carries it, and GET /v1/leases/{id} and GET /v1/leases answer it MCP server (src/mcp/server.ts) with a fake client; HTTP app MCP with label; MCP without; HTTP with label; HTTP without #1755
B7 A caller asks a gateway for a labelled lease: the worker receives the label, and the gateway's lease.get, lease.list and status.get answer it from the worker's lease record gateway dispatcher with a fake worker link label forwarded; no label forwarded as none; gateway reads after a worker snapshot carry it #1755
B8 Leasing hands the request's label to the driver on every prepare boot for that lease, and none on a warm boot or a recovery boot createLeasing with the fake driver recording makeReady options provision; boot of a shut-down device; reboot of a ready device (Xcode's set, and except); warm-pool boot (no label); recoverLeased (no label, purpose recover); unlabelled lease (no label) #1756
B9 The iOS driver renames a simulator before its prepare boot: to the label, or to its stored name without one; a recovery boot renames nothing; a failed or timed-out rename is logged and the boot goes on IosSimctlDriver.makeReady with a fake simctl; the real-simulator case in e2e/slow-ios-window.test.ts label given; no label; purpose recover; rename exits non-zero; rename hangs past 5 s; order: rename before boot; slow lane, a labelled lease on Xcode's set with ios.simulator.headless: false: simctl list names the simulator with the label (DeviceHub's title following the name is measured, under Decisions; the lane has no permission to read a window title) #1756
B10 An operator opens the console's Leases page: a labelled lease's "Held by" cell shows the label above the holder, the side list's second line reads <label> · <model>, the drawer shows Label; the page filter and the search dialog both find it by the label; an unlabelled lease looks as today console DOM test (ui/src/screens/leases/leases.dom.test.tsx), search model unit test (ui/src/model/search.ts) labelled row; unlabelled row; page filter feature; dialog feature (result feature-x · claude-1 · iPhone 17 Pro); long label cut on one line with the whole label in title #1757

Stored state

Id What and where Created, changed, deleted by Listed or swept by A restart mid-step leaves Schema step Task Used by
S1 leases.label TEXT (nullable), state.db written in the grant commit with the lease (createLease); deleted with the lease row read by the registry load at startup and by every lease read the grant commit is one transaction: lease and label together or neither registry +1 #1755 —
S2 lease_requests.label TEXT (nullable) written by admit with the request (LeaseRequestBook.admit); deleted with the request read by the request load; an open request fails at start as daemon-restarted as today as today for a request registry +1 #1755 —
S3 lease_grants.label TEXT (nullable) written with the grant row, as run_id is read back by an idempotent replay as S1 registry +1 #1755 —
S4 An iOS simulator's simctl name renamed before each prepare boot (B9); the stored name in driverData never changes simctl list, DeviceHub a crash after the rename, before the grant: the next prepare boot renames it again; a virtual device is deleted when its lease ends none #1756 —

Interfaces

Id What Shape and bounds Errors and limits Where Task Used by
I1 label on lease.request input optional string, 1 to 64 UTF-16 units, none of Unicode Cc, U+2028, U+2029; checked by one object-level refinement with no path, like runId, so every transport answers the same words. Bumps the protocol by one BAD_REQUEST label must be 1 to 64 characters; BAD_REQUEST label must not contain control characters src/contract/operations-lease-request.ts #1755 #1756
I2 label on the lease record (leaseRecordSchema), the HTTP lease view, and the HTTP request body record and view: optional string, max 64. Request body: a plain optional string held by I1's refinement, like runId, so HTTP refuses with I1's words as I1 on the request body src/contract/lease-schemas.ts, src/http/lease-declarations.ts, src/http/app-helpers.ts #1755 #1757
I3 label on LeaseRequestOptions, the stored request and the grant input optional string, as I1 — src/leasing/wait-queue.ts, src/core/lease-request-store.ts, src/leasing/lease-lifecycle.ts #1755 #1756
I4 CLI simlock lease --label <text>; simlock status lease line gains , label <label> after , run <run>, through escapeControl string flag, checked by I1 at the daemon the daemon's BAD_REQUEST printed as the one JSON error line src/cli/commands/lease.ts, src/cli/format.ts #1755 —
I5 MCP lease_simulator input label as I1 (kept in the tool's input, unlike runId) as I1 src/mcp/contracts.ts #1755 —
I6 label forwarded by a gateway to the worker; the gateway's reads answer the worker's lease record, which carries it; the lease index does not keep it as I1 — src/gateway/dispatcher.ts, src/gateway/fleet-dispatch.ts #1755 —
I7 Driver.makeReady options gain label?: string; passed by ManagedDeviceLifecycle on bootForLease, readyProvisionedForLease (through DeviceProvisioner.provision) and rebootForLease; bootWarm and recoverLeased pass none optional string — src/core/driver.ts, src/core/managed-device-lifecycle.ts, src/core/device-provisioner.ts, src/core/fake-driver.ts #1756 —
I8 iOS simctl rename <udid> <name> before simctl boot on a prepare boot name = label, else driverData name 5 s; a non-zero exit or timeout logs a warning could not rename <udid> to <name>: <reason> and the boot goes on src/drivers/ios/index.ts #1756 —
I9 Console lease row, side list, drawer field label, and the search dialog's lease result text the lease record's label — ui/src/model/leases.ts, ui/src/model/search.ts, ui/src/screens/leases/index.tsx, ui/src/screens/leases/summary.tsx #1757 —

Existing code

Commit fb42676.

Searches: runId in src/ and ui/src (34 files); run_id in src/core (8 hits); makeReady( in src/core and src/leasing (6 hits); "rename" in src/drivers/ios (1 hit, passthrough list); label in src/contract (11 hits, none on a lease request).

Id Code (path:line) Today With this feature Handled by
X1 src/contract/operations-lease-request.ts:67, :244 runId is a plain optional string held to its pattern by refuseBadRunId label beside it, held by its own object-level refinement I1, #1755
X2 src/contract/lease-schemas.ts:46-47 the lease record has runId and worker.label gains top-level label I2, #1755
X3 src/core/registry-schema.ts:147-165 REGISTRY_V8 adds run_id to leases, lease_requests, lease_grants; version 8 REGISTRY_V9 adds label to the same three tables S1-S3, #1755
X4 src/core/registry-rows.ts:331, :382, :414, :611, :652 writes and reads run_id for leases, requests, grants writes and reads label beside it S1-S3, #1755
X5 src/leasing/lease-request-book.ts:225, :250 admit stores runId; a repeat with another runId is a conflict same for label B4, #1755
X6 src/leasing/waiter-outcomes.ts:45, src/core/registry.ts:695 the grant copies runId from the waiter to the lease copies label too B2, #1755
X7 src/gateway/dispatcher.ts:737, src/gateway/fleet-dispatch.ts:386; reads at src/gateway/dispatcher.ts:578-585, :607-611 the gateway handler copies runId into the fleet options and forwards it; reads answer the worker's lease record whole copies and forwards label; reads need no change B7, I6, #1755
X18 src/daemon/dispatcher-leases.ts:64 the worker's lease.request handler copies runId into the leasing options copies label B2, #1755
X19 src/http/app-helpers.ts:30 the HTTP body is turned into lease.request input, runId copied copies label B6, #1755
X20 src/gateway/fleet-grant.ts:65, src/gateway/lease-index.ts:309 the index entry keeps runId unchanged: the label is not kept in the index (I6) B7
X8 src/http/lease-declarations.ts:39, :233; src/http/tracker.ts:84, :125 the HTTP lease view and request body carry runId carry label B6, #1755
X9 src/mcp/contracts.ts:45-51 lease_simulator drops runId, metadata and others from the request fields keeps label B6, #1755
X10 src/cli/commands/lease.ts:85, :104; src/cli/format.ts:321 --run flag; lease line prints , run <run> --label flag; , label <label> after the run B5, #1755
X11 src/leasing/acquisition-workflow.ts:258, :464, :569; src/leasing/acquisition-waiter.ts:50-58 provision, boot-shutdown and reboot-ready pass except to the lifecycle pass the label beside it B8, #1756
X12 src/core/managed-device-lifecycle.ts:76-120, :163 the three lease boot paths call makeReady with purpose: "prepare" and except; recoverLeased uses recover; bootWarm no lease the lease paths add label B8, I7, #1756
X13 src/drivers/ios/index.ts:372-396 makeReady writes slim overrides, then bootAndWait, then runAfterBoot opens the window renames first on prepare B9, I8, #1756
X14 src/drivers/ios/seeds.ts:222-228, src/drivers/ios/simulator-data.ts:7 a clone is named simlock-<id>, "cosmetic, and deliberately so"; the name is stored in driverData the stored name stays; only the simulator's display name changes per lease S4, #1756
X15 src/drivers/ios/boot-courtesies.ts:45, :105 the window opens after the boot, addressed by UDID opens with the new name already set B9, #1756
X16 src/drivers/ios/index.ts:140, src/leasing/acquisition-planner.ts:177 on Xcode's set ready simulators are rebooted before a grant; on Simlock's set granted as they are unchanged; the reboot carries the label B8, #1756
X17 ui/src/model/leases.ts:195-205, :260; ui/src/screens/leases/index.tsx:90-113; ui/src/screens/leases/summary.tsx:63-69 the "Held by" cell shows the holder; the side list shows holder over sub; the page filter matches holder, model, worker, id the label above the holder, <label> · <model> in the side list, the filter matches the label B10, #1757
X21 ui/src/model/search.ts:66-70 the dialog's lease result reads holder · model reads label · holder · model when labelled B10, #1757

Tasks

flowchart LR
  T1["#1755 label on every surface"] --> T2["#1756 iOS rename at boot"]
  T1 --> T3["#1757 console"]
Loading

Completion conditions:

Open work in the same area:

Written by an agent.

Sub-issues

Sub-issues

3 of 3 Issues completed
Loading 3 sub-issues

Activity

  1. added
    feature:spec
    platform:ios
    on Nov 19, 2026
  2. V3RON commented on Nov 19, 2026

    @V3RON
    ContributorAuthor

    Design posted: business sections, Decisions, Behaviours B1-B10, Stored state S1-S4, Interfaces I1-I9, Existing code X1-X17.

    Written by an agent.

  3. V3RON commented on Nov 19, 2026

    @V3RON
    ContributorAuthor

    Spec updated: tasks #1755, #1756, #1757 written; Task cells name them; Tasks section filled.

    Written by an agent.

  4. added
    feature:planned
    and removed
    feature:spec
    on Nov 19, 2026
  5. V3RON commented on Nov 19, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: none (stack #1768 → #1775 → #1776 held, all three reviewed and ready)
    Parked: #1756 — slow lane unavailable: DeviceHub was running on the lane machine; PR #1776 labelled needs-hardware
    Waiting: #1755 (PR #1768), #1757 (PR #1775) — in the stack, on #1756's slow lane
    Decided: #1755 — test the HTTP layer's own label refinement separately? → no, same as runId (PR #1768 comment)

    Written by an agent.

  6. github-actions commented on Nov 19, 2026

    @github-actions
    Contributor

    Closing: all 3 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.

  7. github-actions commented on Nov 19, 2026

    @github-actions
    Contributor

    Closing: all 3 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.

  8. V3RON commented on Nov 19, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: #1768 (#1755), #1775 (#1757), #1776 (#1756) — into main at 865fdb7
    Parked: none
    Waiting: none
    Decided: #1755 — test the HTTP layer's own label refinement separately? → no, same as runId (PR #1768 comment)

    Slow lane for #1756 passed once DeviceHub was quit. The first gate run failed on a timing race in e2e/warm-pool-reserve.test.ts, outside the feature's diff; the test's boot delay was lengthened and the second gate run merged the stack.

    Written by an agent.

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

    feature:plannedplatform:ios

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions