Repository navigation
Description
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]
Rules in play
src/contract/AGENTS.md"Protocol version": the new field bumpsPROTOCOL_VERSION_RANGEby one in this PR;minmoves too.src/contract/AGENTS.md"Shapes":labelis held by one object-level refinement with no path, likerunId, 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 throughescapeControl.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
labelin 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
labelis refusedBAD_REQUESTwith 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.listandstatus.getcarry 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.dbis 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-xsends it; no--labelsends none;--label ""is sent and the daemon'sBAD_REQUESTprinted, never a localUSAGE;simlock statusprints, label feature-xafter, run <run> - B6: MCP
lease_simulatorwith and withoutlabel;POST /v1/lease-requestswith and withoutlabel;GET /v1/leases/{id}andGET /v1/leasesanswer it - B7: a gateway forwards the label to the worker; none forwarded as none; the gateway's
lease.get,lease.listandstatus.getcarry it after a worker snapshot
Done when
pnpm test:changedpasses, with the B1 to B7 cases above.pnpm typecheckandpnpm lintpass.pnpm --dir website install && pnpm --dir website build && node website/scripts/check-openapi.mjspasses, and the OpenAPI document showslabelon the lease request body and the lease view.website/src/content/docs/docs/reference/cli.mdxdocumentssimlock lease --labeland the status line;connect-your-agent.mdxlistslabelonlease_simulator;remote-agents.mdxlistslabelon 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
test: a lease requested with a label carries it in the grant and ever…
feat(leasing): a lease carries the label it was requested with (#1755)
test: a bad label is refused BAD_REQUEST with the same words (#1755)
feat(contract): lease.request refuses a bad label (#1755)
test: an idempotent repeat conflicts when the label differs (#1755)
feat(leasing): a repeat with another label is an idempotency conflict (…
test: a label reaches the grant and reads on every device kind (#1755)
test: a labelled lease keeps its label after state.db is reopened and…
test: simlock status prints a lease's label after its run id (#1755)
feat(cli): simlock status prints a lease's label (#1755)
test: simlock lease --label sends the label and the daemon checks it (#…
feat(cli): simlock lease --label names the lease (#1755)
test: MCP lease_simulator sends the label it is given (#1755)
test: POST /v1/lease-requests carries a label to the lease and refuse…
feat(http): POST /v1/lease-requests accepts a label and the lease vie…
test: a gateway forwards the label and its reads carry the worker's l…
feat(gateway): a gateway forwards a lease request's label to the work…
docs: simlock lease --label and the label field on the lease request (#…
test: the lease usage text lists --label (#1755)
refactor(core): lease and request records share one presentFields hel…
fix(leasing): the idempotency-conflict message and docs name the label (
feat(leasing): an agent names its lease with a label (#1768)