Skip to content

lease --label: a lease carries its label on every surface #1755

Closed

Description

@V3RON

Part of #1745.

Scope

An agent names its lease when it asks for it: simlock lease --label feature-x, MCP lease_simulator with label, or label in the POST /v1/lease-requests body, directly or through a gateway. The label is stored with the request and the lease, kept across a restart, answered by every lease read, and printed by simlock status on the lease line. A bad label is refused with the same BAD_REQUEST words on every transport. Devices are not renamed yet, and the console does not show it yet.

If this goes wrong, a user would see a label they sent missing from simlock status or a lease read (dropped at one of the copy sites), or a lease without a label printing differently than today.

Technical spec

Commit fb42676.

Rows

  • Behaviours: B1, B2, B3, B4, B5, B6, B7
  • Stored state: S1, S2, S3
  • Interfaces: I1, I2, I3, I4, I5, I6
  • Existing code: X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X18, X19, X20

Facts

# Fact Source
F1 Today simlock lease --platform ios --label feature-x fails before connecting: {"error":{"code":"USAGE","message":"Unknown option '--label'. ..."}}, exit 2 node dist/cli/main.js lease --platform ios --label feature-x on fb42676
F2 The protocol range is { min: 100, max: 100 } src/contract/protocol.ts:13
F3 runId's end-to-end path through the daemon has its own test file, the model for B2 and B4 src/daemon/dispatcher-leases-run-id.test.ts:12-25

Modules touched

Searches: runId, run_id, refuseBadRunId, leaseRecordSchema, leaseSimulatorInputSchema in src, website/src/content/docs.

  • src/contract/ (operations-lease-request.ts, lease-schemas.ts, protocol.ts, tests)
  • src/core/ (registry-schema.ts, registry-rows.ts, registry.ts, lease-request-store.ts, domain.ts (Lease, LeaseRequest), registry-types.ts (CreateLeaseInput), tests)
  • src/leasing/ (wait-queue.ts, lease-request-book.ts, lease-lifecycle.ts, waiter-outcomes.ts, tests)
  • src/daemon/ (dispatcher-leases.ts, tests)
  • src/gateway/ (dispatcher.ts, fleet-dispatch.ts, tests)
  • src/http/ (lease-declarations.ts, app-helpers.ts, tracker.ts, tests)
  • src/mcp/ (contracts.ts, tests)
  • src/cli/ (commands/lease.ts, format.ts, tests)
  • website/src/content/docs/docs/reference/cli.mdx, website/src/content/docs/docs/getting-started/connect-your-agent.mdx, website/src/content/docs/docs/using-devices/remote-agents.mdx
flowchart LR
  CLI[cli] --> C[contract]
  MCP[mcp] --> C
  HTTP[http] --> D[daemon dispatcher]
  GW[gateway] --> D
  D --> L[leasing]
  L --> R[core registry, state.db]
Loading

Rules in play

  • src/contract/AGENTS.md "Protocol version": the new field bumps PROTOCOL_VERSION_RANGE by one in this PR; min moves too.
  • src/contract/AGENTS.md "Shapes": label is held by one object-level refinement with no path, like runId, so every transport answers the same words (I1, I2).
  • src/core/AGENTS.md "Lock, claims and commits": the label is written in the same grant commit as the lease (S1).
  • src/cli/AGENTS.md "Output": the status line passes the label through escapeControl.
  • src/gateway/AGENTS.md: a gateway forwards the label as sent; its reads come from the worker's lease record (I6).
  • Documentation rule 9: the CLI reference, the MCP tool page and the remote agents page describe label in this PR.

Tests

The seam is the daemon dispatcher with fake drivers (model: src/daemon/dispatcher-leases-run-id.test.ts), runCli with a fake client (model: src/cli/index-lease-run-id.test.ts), the MCP server (model: src/mcp/server.test.ts), the HTTP app (model: src/http/app.test.ts) and the gateway dispatcher (model: src/gateway/dispatcher.test.ts).

  • B1: a bad label is refused BAD_REQUEST with I1's message, nothing queued: ""; 65 characters; a\nb; \t; NUL; U+2028; U+2029; through HTTP the same message
  • B2: the grant, lease.get, lease.list and status.get carry the label: iOS simulator; Android emulator; physical phone; no label (no field); 64 characters; café 🚀; fix/login sheet
  • B3: a labelled lease keeps its label after state.db is reopened; an unlabelled one has none; a store at registry version 8 migrates and loads with no labels
  • B4: an idempotent repeat: same label replays; other label, label on one only → IDEMPOTENCY_CONFLICT; neither replays
  • B5: simlock lease --label feature-x sends it; no --label sends none; --label "" is sent and the daemon's BAD_REQUEST printed, never a local USAGE; simlock status prints , label feature-x after , run <run>
  • B6: MCP lease_simulator with and without label; POST /v1/lease-requests with and without label; GET /v1/leases/{id} and GET /v1/leases answer it
  • B7: a gateway forwards the label to the worker; none forwarded as none; the gateway's lease.get, lease.list and status.get carry it after a worker snapshot

Done when

  • pnpm test:changed passes, with the B1 to B7 cases above.
  • pnpm typecheck and pnpm lint pass.
  • pnpm --dir website install && pnpm --dir website build && node website/scripts/check-openapi.mjs passes, and the OpenAPI document shows label on the lease request body and the lease view.
  • website/src/content/docs/docs/reference/cli.mdx documents simlock lease --label and the status line; connect-your-agent.mdx lists label on lease_simulator; remote-agents.mdx lists label on the request body. Each says the label is display-only, and that on Android and physical devices it shows on the lease only.

Out of scope

Renaming an iOS simulator (#1756), the console (#1757), and the feature's Non-goals.

Depends on

Written by an agent.

Activity

  1. added
    task:draft
    on Nov 19, 2026
  2. added
    task:ready
    and removed
    task:draft
    on Nov 19, 2026
  3. self-assigned this
    on Nov 19, 2026
  4. added 20 commits that reference this issue on Nov 19, 2026
  5. added a commit that references this issue on Nov 19, 2026
    c9c0d6a
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