Skip to content

CI runs: release every lease of a run in one call #1633

Closed
3 of 3 issues completed
Closed

Description

@V3RON

Request: #1294

Problem

A cancelled CI job never releases its leases, and the devices stay held until the TTL runs out. budgie's e2e suite (budgie-at/budgie#1867) keeps the TTL at 3 minutes, renews every minute, writes every lease id it gets to .e2e/simlock-leases.json, and releases them in an if: always() step. Leases carry no run or group id. lease.release-all is admin-only, takes no filter and has no HTTP route. An agent token can't release "everything from this run".

Device preparation, the other half of #1294, is specified separately in #1634; the two share no decision.

Who it is for

A CI job that leases 5–10 simulators per run on a shared farm. Other jobs wait for the devices a killed run still holds.

Outcome

  • A lease, and a request still waiting for one, can carry a run id. On GitHub Actions simlock lease and the @simlock/e2e provider set it by themselves.
  • A CI cleanup step runs simlock release --run <id> against the farm (with The CLI, simlock/client and simlock mcp reach a remote farm with a URL and a token #1635's SIMLOCK_URL and token): every lease of that run the token holds ends at once, and every request of that run still waiting will not keep a device, so a job that is gone holds nothing.
  • An operator token frees a run's leases whoever holds them.
  • The cleanup step needs no file of lease ids, and it succeeds when the run has nothing left.

How it works for the user

flowchart TD
  A[CI job on GitHub Actions] --> B[simlock lease or @simlock/e2e]
  B --> C[Lease or waiting request carries run 123-1]
  C --> D{Job ends}
  D -- normally --> E[Job releases its own leases]
  D -- cancelled or killed --> F[if: always step]
  E --> F
  F --> G[simlock release --run 123-1]
  G --> H[Leases of run 123-1 this token holds end now]
  G --> I[Its queued requests are cancelled]
  G --> J[Its booting requests are released the moment they are granted]
  G -- nothing left --> K[Empty lists, exit 0]
  G -- a worker unreachable --> L[WORKER_UNREACHABLE, exit 1: those leases run out by TTL]
Loading

Before, a cleanup step needs a file of every lease id the run took:

$ jq -r '.[]' .e2e/simlock-leases.json | xargs -n1 simlock release
$ simlock release --all
{"error":{"code":"FORBIDDEN","message":"…admin…"}}

After, in a GitHub job (GITHUB_RUN_ID=123, GITHUB_RUN_ATTEMPT=1, SIMLOCK_URL and SIMLOCK_TOKEN set):

$ simlock lease --platform ios --detach
{"leaseId":"w1.lse_3b9d…","lease":{…,"runId":"123-1"},…}
$ simlock status
…
Lease w1.lse_3b9d…: ci-job-42 on w1, run 123-1 since …, last renewed …
$ simlock release --run "$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT"
{"leaseIds":["w1.lse_3b9d…","w2.lse_77a0…"],"requestIds":["req_91c2…"]}
$ simlock release --run "$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT"
{"leaseIds":[],"requestIds":[]}
$ simlock release --run 'run 1'
{"error":{"code":"USAGE","message":"--run takes a run id: 1 to 128 letters, digits, `.`, `_` or `-`"}}
$ simlock release --run 123-1 w1.lse_3b9d…
{"error":{"code":"USAGE","message":"release accepts a lease id, --all or --run <id>, only one of them"}}

A workflow with one e2e job (simlock and @simlock/e2e are dev dependencies at the farm's version):

- run: npx e2e test
  env: { SIMLOCK_URL: …, SIMLOCK_TOKEN: … }
- if: always()
  run: npx simlock release --run "$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT"
  env: { SIMLOCK_URL: …, SIMLOCK_TOKEN: … }

Every job of one workflow run, matrix legs included, shares GITHUB_RUN_ID and GITHUB_RUN_ATTEMPT, and GitHub sets no variable that differs per matrix leg (strategy.job-index exists only as an expression). A workflow with several e2e jobs, or a matrix, names each job's run itself:

jobs:
  e2e:
    strategy: { matrix: { shard: [1, 2, 3] } }
    env:
      SIMLOCK_URL: …
      SIMLOCK_TOKEN: …
      SIMLOCK_RUN: ${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }}-${{ strategy.job-index }}
    steps:
      - run: npx e2e test --shard ${{ matrix.shard }}/3
      - if: always()
        run: npx simlock release --run "$SIMLOCK_RUN"

Examples

The run id a simlock lease carries (I3; @simlock/e2e follows the same steps with its runId option in place of --run, and differs only where the second table says):

--run SIMLOCK_RUN GITHUB_ACTIONS / GITHUB_RUN_ID / GITHUB_RUN_ATTEMPT Today After
— — — no run id no run id
nightly-7 — — --run unknown, exit 2 nightly-7
— nightly-7 true / 123 / 2 no run id nightly-7
a b true / 123 / 2 exit 2 a
— empty true / 123 / 2 no run id 123-2 (empty is unset)
— — true / 123 / unset no run id 123-1
— — unset / 123 / 2 no run id no run id (not GitHub Actions)
run 1 — — exit 2 exit 2, the run id message
129 characters — — exit 2 exit 2, the run id message
— ünï — no run id exit 2, the run id message naming SIMLOCK_RUN

Where @simlock/e2e differs (I6):

runId option SIMLOCK_RUN GitHub variables Today After
— — — the runner's run id the runner's run id (as today)
— — unset / 123 / 2 the runner's run id the runner's run id
run 1 — — unknown option, throws throws simlockDevices: runId must be 1 to 128 letters, digits, ., _ or -; got "run 1"
— ünï — the runner's run id throws simlockDevices: SIMLOCK_RUN must be 1 to 128 letters, digits, ., _ or -; got "ünï"

Which leases and requests simlock release --run R reaches:

The lease or request Agent token T Operator token
T's lease, run R released released
T's lease, run R2 or none kept kept
another token's lease, run R kept, not listed released
T's request queued, run R cancelled cancelled
T's request booting a virtual device, run R released at its grant released at its grant
a lease through the agent-device address, allocate runId R released released
a lease made on a standalone worker's own socket with run R, same principal, release sent to that worker released released
a lease made on a joined worker's own socket with run R, release sent to its gateway kept: the gateway never issued it kept
T's gateway request still waiting on the admission command, run R cancelled, not listed (it has no id yet) cancelled, not listed

What could go wrong

  • Two jobs of one workflow run, both on the GitHub default, each with a cleanup step: the first to finish frees the other's devices mid-test. Likely in a matrix or with an iOS and an Android job, unless the workflow sets SIMLOCK_RUN per job as the CI page shows.
  • A cleanup step whose farm cannot reach one worker frees the others and exits 1; that worker's leases run out by their TTL as today.
  • A device booting when the cleanup runs is granted and released straight after, so it is held for one boot's time, not the TTL.
  • A local agent-device user sees run simlock-local on its leases, because agent-device's local profile names that run.

Words used

  • Run id: a name a CI job gives every lease it takes, so it can free them all at once. 1 to 128 letters, digits, ., _ or -. Example: 123-1 (GitHub run 123, attempt 1).
  • Release at grant: a request of the run that is already booting a device cannot be stopped; it is marked, and the moment it is granted the lease is released.
  • agent-device run id: the runId every agent-device lease already carries in agent-device's own protocol; the agent-device address copies it onto the simlock lease.

Non-goals

Completion conditions

  • In a GitHub Actions job, simlock lease --platform ios --detach against a farm gives a lease whose runId is $GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT, and simlock status shows it (with The CLI, simlock/client and simlock mcp reach a remote farm with a URL and a token #1635's remote mode).
  • simlock release --run <id> with an agent token ends that token's leases of the run and leaves another token's lease of the same run; with an operator token it ends both.
  • A request of the run still queued is cancelled by it, and one booting is released as soon as it is granted.
  • A second simlock release --run <id> prints empty lists and exits 0.
  • The same works through a gateway, the leases spread over two workers.
  • A @simlock/e2e run on GitHub Actions leases devices with the GitHub run id, and the cleanup step frees them after the job is cancelled mid-run.

Open questions

none

Decisions

  • ADR 0081 — A remote caller speaks the daemon protocol over one WebSocket path, with its token's identity (#1638): the cleanup step is a remote simlock release --run, with the token's role deciding its reach.
  • ADR 0003 — One typed daemon contract behind every frontend: the run release is one operation, checked by role in the dispatcher.
  • ADR 0005 — Gateway and worker modes: the gateway decides which of its index's leases match and releases each on its worker; it never decides a lease is gone.
  • Decided with the maintainer in the session of 2026-11-17: one call frees only the caller's own leases with that run id; an operator (admin) frees a run's leases whoever holds them. Two CI jobs sharing one token are kept apart by their run ids.
  • Decided with the maintainer in the session of 2026-11-17: the @simlock/e2e provider takes the run id from the CI by default (on GitHub, the run id and attempt; or SIMLOCK_RUN), and an option overrides it.
  • Decided with the maintainer in the session of 2026-11-17: the cleanup step is a simlock release command, not a curl call; it runs remotely through The CLI, simlock/client and simlock mcp reach a remote farm with a URL and a token #1635.
  • Decided with the maintainer in the session of 2026-11-17 (resumed): a run release also stops the run's waiting requests: queued ones are cancelled, booting ones released at their grant.
  • Decided with the maintainer in the session of 2026-11-17 (resumed): the agent-device address copies the allocate's own runId onto the simlock lease, and @simlock/e2e sends the CI run id as that runId; agent-device itself does not change.
  • Decided with the maintainer in the session of 2026-11-17 (resumed): simlock lease picks its run id as the provider does: --run, else SIMLOCK_RUN, else on GitHub Actions $GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT.
  • Decided in the session: a run id is 1 to 128 of A-Za-z0-9._-, because that is agent-device's runId rule (src/agent-device/shared/release-scope.ts:9), so every agent-device run id fits.
  • Decided in the session: a new agent-role operation lease.release-run, not a filter on lease.release-all, because release-all stays admin-only and unfiltered and its event reason stays killed; a run release is the caller's own act, reason explicit.
  • Decided in the session: a run with nothing left answers empty lists, exit 0, because a cleanup step runs after a normal end too.
  • Decided in the session: a booting request is marked to release at its grant instead of the call waiting for it, because a boot can take a minute and the cleanup step should not hang on it.
  • Decided in the session: on a gateway the gateway matches its own lease index and fleet requests and sends lease.release per lease to each worker, never lease.release-run, because a worker sees the gateway as admin and would match every owner.
  • Decided in the session: a lease of an unreachable worker fails the call with WORKER_UNREACHABLE after the others are released, with the released ids in its details, as release-all does on a gateway (src/gateway/fleet-forwarding.ts:105-128); running the command again is safe.
  • Decided in the session: a repeat of a request under the same idempotency key with another run id is IDEMPOTENCY_CONFLICT, as a repeat with another lease id is (src/leasing/lease-request-book.ts:222), because it is a different request.
  • Decided in the session: the HTTP POST /v1/lease-requests body takes runId too, because a curl or Maestro job leases over HTTP and should be able to tag its leases for the same cleanup.
  • Decided in the session: the agent-device address copies an allocate's runId only when it fits the run id rule and leaves the lease without one otherwise, because agent-device's own checks decide what an allocate may carry, not simlock's.
  • Decided in the session: outside CI @simlock/e2e keeps sending the e2e runner's own run id, as today, because agent-device needs a runId on every allocate.
  • Decided in the session: simlock release --run asks no confirmation, unlike --all, because it reaches only one run.
  • Decided in the session: the CLI checks a run id before it sends anything (exit 2), and the daemon checks it again (BAD_REQUEST), because a bad SIMLOCK_RUN should fail the step at once, not after a lease waited.
  • Decided with the maintainer in the session of 2026-11-17 (design check): the GitHub default stays $GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT, one id for the whole workflow run; a workflow with several e2e jobs or a matrix sets SIMLOCK_RUN per job (the CI page shows ${{ github.run_id }}-${{ github.run_attempt }}-${{ github.job }}-${{ strategy.job-index }}), because GitHub sets no environment variable that differs per matrix leg.
  • Decided with the maintainer in the session of 2026-11-17 (design check): simlock release takes the run id only as --run <id>; it picks none by itself.
  • Decided in the session: the run id check is one object-level refinement with no path (refuseBadRunId), as except and metadata are, so every transport answers I1's words without a runId: prefix.
  • Decided in the session: @simlock/e2e keeps its own copy of the run id rule and the I3 order, because the package depends on agent-device and the e2e runner only, not on simlock; a test in each package runs the same Examples rows.
  • Decided in the session: the gateway's admission command sees runId in request, as it sees every other field of the request, because an operator may want to admit or rank by run; the routing page says so.
  • Decided in the session: the HTTP lease reply (leasePayloadSchema) carries runId, because a curl caller must see the run its lease belongs to.
  • Decided in the session: a gateway request still waiting on the admission command is cancelled by a run release but not listed in requestIds, because it has no id until the command answers.
  • Decided in the session: the CI page installs simlock as a dev dependency at the farm's version, as it does @simlock/e2e, so the cleanup step runs a CLI that speaks the farm's protocol.
  • Decided in the session: the tasks depend on Every simlock command runs against a remote farm with --url or SIMLOCK_URL and a token #1641 (every command runs against a remote farm), because the cleanup step and the Completion conditions run the CLI from a CI runner with no daemon.
  • Decided in the session: no ADR, because the feature adds one field and one operation inside ADR 0003's roles and ADR 0005's gateway rules and changes neither.

Behaviours

Id Behaviour (invoker, action, what it sees) Seam Cases Task
B1 A caller sends lease.request with runId (I1) to a worker: the grant's lease and every later read of it (lease.list, lease.get, status.get) carry the run id, also after a daemon restart; a bad run id is refused createLeasing and the daemon dispatcher with fake drivers and a real state.db run id 123-1 (granted, listed with it); no run id (no field); a restart after the grant (still listed with it); a replay by idempotency key with the same run id (same grant); the same key with another run id (IDEMPOTENCY_CONFLICT); run 1, empty, 129 characters (BAD_REQUEST, I1's message) #1666
B2 A caller sends lease.request with runId to a gateway: the worker's lease carries it, the gateway's lease.list and lease.get show it, and its admission command sees it the gateway dispatcher with a fake worker link and a fake admission command (models: src/gateway/dispatcher*.test.ts, src/gateway/fleet-admission*.test.ts) forwarded lease.request holds runId; the index entry made at the grant holds it (not only one rebuilt from a view); the gateway lists it; after a gateway restart the index rebuilt from the worker's view holds it; the admission command's request holds runId; no run id (none forwarded) #1666
B3 A user runs simlock lease (I3): the request carries the run id I3 picks; simlock status prints it on the lease line (I2) runCli with a fake environment and a fake session (models: src/cli/index-lease-requests.test.ts, src/cli/lease-meta.test.ts, src/cli/index-status-daemon-lines.test.ts) each row of the first Examples table; --run on lease --detach; simlock status with a run id (, run 123-1) and without (line as today) #1666
B4 A curl caller sends POST /v1/lease-requests with runId: the lease carries it, and the lease in the reply and in GET /v1/leases/{id} names it createApp with the in-process dispatcher (model: src/http/app-leases.test.ts) runId: "123-1" (the dispatched lease.request holds it; the reply's lease has runId); no runId (no field); runId: "run 1" (400 BAD_REQUEST, I1's message) #1666
B5 A caller sends lease.release-run (I4) to a worker: the matching leases end explicit, the matching queued requests are cancelled, the matching booting requests are released at their grant, and it answers their ids the daemon dispatcher and createLeasing with fake drivers and the fake clock (models: src/leasing/lease-acquisition-coordinator.test.ts, src/daemon/server-roles.test.ts) each row of the second Examples table, agent and admin; two leases of the run (both ended, lease.released explicit each); a queued request (rejected cancelled, lease.rejected cancelled); a booting virtual request (granted, then released at once; its id in requestIds); a physical request mid presence read (cancelled); nothing matches (empty lists); a bad run id (BAD_REQUEST) #1667
B6 The caller's own connection gets no lease-lost for the leases its lease.release-run ends; the owner's other connections do the daemon server over the socket, as a worker and as a gateway (model: src/daemon/server-pushes.test.ts) the asking connection (no push); a second connection of the same principal (push); an admin's run release of another owner's lease (the owner gets the push); the same three on a gateway, whose leaseSnapshot carries the run id; a lease of another run (pushed as for any release) #1667
B7 A caller sends lease.release-run to a gateway: it releases each matching index entry on its worker, cancels matching fleet requests, marks matching dispatched ones to release at grant, and answers their ids; an unreachable worker fails the call after the rest the gateway dispatcher with fake worker links (models: src/gateway/fleet-coordinator-forwarding.test.ts) two workers, one lease each (both released by lease.release on each worker); an agent and another owner's entry (kept); admin (both); a fleet request queued in the gateway (cancelled); one waiting on the admission command (cancelled, not in requestIds); a joined worker's own local lease of the run (kept: not in the index); one dispatched (the worker's grant is released at once, the caller gets the grant then lease-lost); a worker answering UNKNOWN_LEASE (counted released); one worker unreachable (WORKER_UNREACHABLE, details releasedLeaseIds hold the other) #1667
B8 A user runs simlock release --run <id> (I5): it prints I4's answer, or a usage error runCli with a fake session a run with leases (prints both lists, exit 0); nothing left (empty lists, exit 0); --run 'run 1' (exit 2, nothing sent); --run with a lease id or --all (exit 2); FORBIDDEN or WORKER_UNREACHABLE answered (exit 1, one JSON error line); no confirmation asked #1667
B9 An agent-device client allocates through the agent-device address with its runId: the simlock lease carries it, on a worker and on a gateway the agent-device front with the fake agent-device (models: src/agent-device/edge-allocate.test.ts, src/agent-device/gateway-front-lease.test.ts) runId: "123-1" (lease has it); runId: "simlock-local" (lease has it); a runId outside the rule (forwarded to agent-device as today, lease has none); then lease.release-run for 123-1 ends it and the front releases agent-device's lease as on any lease end #1668
B10 @simlock/e2e leases with the run id I6 picks as agent-device's runId createProvider with a fake agent-device client (model: packages/e2e/src/provider.test.ts) and simlockDevices option checks (model: packages/e2e/src/index.test.ts) each row of the first Examples table with runId for --run, except the rows the @simlock/e2e table replaces; each row of that table; allocate, heartbeat and release all send the same runId #1668
B11 An MCP agent lists the tools: lease_simulator's input has no runId, so an agent cannot tag a lease simlock mcp tools/list (model: src/mcp/server.test.ts:160-170) the input schema has no runId; a lease_simulator call naming runId is refused by the tool's schema as an unknown field #1666

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.run_id TEXT (null when none), worker state.db written in the grant commit from the request; deleted with the lease row lease.list, lease.get, status.get, startup's registry load; matched by lease.release-run the lease row with or without it, as the grant commit made it registry +1 #1666 #1667
S2 lease_grants.run_id TEXT, worker state.db written with the grant row, so a replayed grant carries it the idempotency replay as S1 registry +1 #1666 —
S3 lease_requests.run_id TEXT, worker state.db written when the request is stored the idempotency replay (compared, B1); a start fails open requests as today the request row; a start fails it daemon-restarted as today registry +1 #1666 #1667
S4 runId on a gateway lease index entry and on a fleet waiter, gateway memory the entry from the grant and from each worker view's lease (rebuildFromWorker); the waiter from the request (src/gateway/dispatcher.ts lease.request handler) lease.release-run; lease.list; the server's leaseSnapshot (src/daemon/main.ts:595-596) nothing: rebuilt from the workers' views, as every entry is none #1666 #1667
S5 the release-at-grant mark on a booting waiter (worker) and on a dispatched fleet waiter (gateway), memory set by lease.release-run; read once at the grant — nothing: a worker start fails the request; a gateway restart loses the fleet request, and its worker lease runs out by TTL none #1667 —

Interfaces

Id What Shape and bounds Errors and limits Where Task Used by
I1 runId on lease.request input, on the lease record (leaseRecordSchema, so grants, lease.list, lease.get, status.get and worker views) and on the HTTP lease-request body optional plain string, checked by refuseBadRunId against RUN_ID_PATTERN ^[A-Za-z0-9._-]{1,128}$ as one object-level refinement with no path (both in src/contract); absent when none; a gateway hands it to the waiter, its admission command's request and the worker as sent; the HTTP lease reply (leasePayloadSchema) carries it; bumps the protocol by one BAD_REQUEST a run id is 1 to 128 letters, digits, \.`, `_` or `-`, the same words on every transport; same idempotency key, other run id: IDEMPOTENCY_CONFLICT` src/contract (operations-lease-request.ts, lease-schemas.ts), src/leasing (request options, request book, lease-lifecycle.ts), src/core (registry-schema.ts, registry-rows.ts, registry.ts, domain.ts), src/gateway (dispatcher.ts, fleet-dispatch.ts, lease-index.ts), src/daemon/main.ts (leaseSnapshot), src/http (lease-declarations.ts, app-helpers.ts, tracker.ts) #1666 #1667, #1668
I2 simlock status lease line Lease <id>: <requester>[ on <worker>], run <runId> since … when a run id is set; unchanged otherwise — src/cli/format.ts #1666 —
I3 simlock lease --run <id> and the CLI's run id rule --run, else SIMLOCK_RUN (empty is unset), else when GITHUB_ACTIONS is true and GITHUB_RUN_ID is set: <GITHUB_RUN_ID>-<GITHUB_RUN_ATTEMPT, else 1>, else none; checked against RUN_ID_PATTERN before connecting; the --help text gains [--run <id>] exit 2 --run takes a run id: 1 to 128 letters, digits, \.`, `_` or `-`; from the variable: SIMLOCK_RUN takes a run id: …` with the same words; a GitHub value that fails the rule: no run id and no error src/cli/commands/lease.ts, src/cli/environment.ts, src/cli/types.ts #1666 #1667
I4 lease.release-run operation role agent, effect write; input { runId } (a required plain string, strict, checked by I1's refuseBadRunId, so the refusal has I1's words); output { leaseIds: string[], requestIds: string[] }; matches leases and waiting requests whose run id is runId and whose owner is the session's principal, any owner for admin; leases end explicit; queued requests are rejected cancelled; booting ones get S5 and are released explicit at their grant; requestIds holds both kinds; on a gateway a request still waiting on the admission command is cancelled and not listed (it has no id yet); a physical waiter mid presence read is cancelled, only a virtual one booting is marked; the server skips lease-lost to the asking connection for each lease it ends, as for release-all; bumps the protocol by one; client method releaseRunLeases({ runId }) on SimlockClient BAD_REQUEST (I1's message); on a gateway, a worker that cannot be reached: WORKER_UNREACHABLE with details releasedLeaseIds (the ids it did end), after every other match; no time limit of its own: each per-lease release is bounded as lease.release is src/contract/operations-leases.ts, operations.ts, operations.test.ts, protocol.ts; src/daemon/dispatcher-leases.ts, server-requests.ts; src/leasing (release coordinator, acquisition coordinator); src/gateway/dispatcher.ts, fleet-forwarding.ts, fleet-admission.ts, fleet-dispatch.ts; src/simlock-client #1667 #1668
I5 simlock release --run <id> prints I4's output as one JSON line; checks the id by RUN_ID_PATTERN first; usage Usage: simlock release <lease-id> | --all [--yes] | --run <id> exit 2 --run takes a run id: … (I3's words); a lease id or --all with it: exit 2 release accepts a lease id, --all or --run <id>, only one of them; daemon errors with their codes and exit codes src/cli/commands/release.ts #1667 —
I6 @simlock/e2e runId option and its rule runId?: string; I3's order with runId for --run; outside CI, the runner's request.runId as today; sent as agent-device's scope runId on allocate, heartbeat and release a bad runId: throws simlockDevices: runId must be 1 to 128 letters, digits, ., _ or -; got <value>; a bad SIMLOCK_RUN: the same with SIMLOCK_RUN for runId; both at config load, as other options do; the package keeps its own copy of the rule (it does not depend on simlock) packages/e2e/src/options.ts, provider.ts #1668 —
I7 The agent-device front's copy leaseInput adds runId from the allocate's runId when it fits RUN_ID_PATTERN; else none — src/agent-device/front/allocate.ts #1668 —

Existing code

Commit c9d82e3.

Searches: runId in src and packages/e2e (19 hits, all agent-device scope), release-all/releaseAll (38), cancelPending (8), CREATE TABLE in src/core (12), SAME_DEVICE_FIELDS (2), requestedDevice (4), leasesFor/waitingFor (6), GITHUB_RUN_ID/SIMLOCK_RUN (0), leaseRequestBodySchema (3).

Id Code (path:line) Today With this feature Handled by
X1 src/contract/operations-lease-request.ts:43-76 the request input is strict and has no run field gains runId (I1) B1, #1666
X2 src/contract/lease-schemas.ts:36-47 the lease record has no run field gains optional runId, so every lease read carries it B1, B2, #1666
X3 src/core/registry-schema.ts:44-92, :155-158 leases, lease_requests and lease_grants have no run column; registry at version 7 one migration adds run_id to each (S1–S3) B1, #1666
X26 src/core/registry-rows.ts:287-289, :591, :656, :670, src/core/registry.ts:713-724, src/core/domain.ts:437, src/leasing/waiter-outcomes.ts:32-47, src/leasing/lease-lifecycle.ts:17, :90 the column lists, row readers and createLease name each field one by one; the lease record type has no run id; WaiterOutcomes.grant builds the grant input from the waiter's options field by field, and the lifecycle passes it to createLease each carries runId, so S1–S3 are written and read back after a restart B1, #1666
X4 src/leasing/lease-request-book.ts:218-225, :411-428 a replay compares device fields and the lease id also compares the run id B1, #1666
X5 src/contract/operations-lease-request.ts:286-301, src/gateway/dispatcher.ts:711-735, src/gateway/fleet-dispatch.ts:364-391 the gateway's lease.request handler builds the waiter from requestedDevice (device fields only) and options field by field; the worker request is requestedDevice plus the gateway's own fields; no run id the waiter's options carry runId, and the worker request adds it B2, #1666
X27 src/gateway/dispatcher.ts:860-868 withoutCallerIdentity hands the admission command every input field but idempotencyKey, metadata and requesterId runId reaches the command too, as decided; website gateway/routing.mdx names it B2, #1666
X28 src/daemon/main.ts:595-596, src/daemon/server-options.ts:172 a gateway's leaseSnapshot maps index entries to { id, ownerId } adds runId, so the self-push skip can match a run B6, #1666, #1667
X6 src/gateway/lease-index.ts:28-49 an index entry and a reported lease have no run id both carry it (S4) B2, B7, #1666
X7 src/http/lease-declarations.ts:211-235, src/http/app-helpers.ts:14-45, src/http/tracker.ts:9-27, :93-125 the strict body has no run field; toLeaseRequestInput, LeaseRequestInput, leaseRequestDispatchInput and requestOptions copy fields one by one each carries runId to lease.request B4, #1666
X29 src/http/lease-declarations.ts:23-42, src/http/tracker.ts:66 the lease reply leasePayloadSchema names each field, and buildLeasePayload fills it field by field; no run id both add optional runId B4, #1666
X8 src/cli/commands/lease.ts:78-101, src/cli/environment.ts:479 no --run; env values read one by one (SIMLOCK_BASELINE) --run and I3's env reads B3, #1666
X9 src/cli/format.ts:268, :319, src/cli/commands/status.ts:25 simlock status prints formatStatus, whose lease line names requester, worker and times (simlock list prints list.get JSON, admin-only) the line adds , run <id> (I2) B3, #1666
X10 src/contract/operations-leases.ts:223-229, src/daemon/dispatcher-leases.ts:118-125 release-all is admin, unfiltered, reason killed; release is one lease, explicit release-run beside them (I4); both unchanged B5, #1667
X11 src/daemon/server-requests.ts:71-97 release-all adds each lease it will end to selfInitiatedReleases first release-run does the same for its matches B6, #1667
X12 src/daemon/dispatcher-device-views.ts:12-28 leases and waiting requests are filtered by owner or admin release-run matches by the same owner rule B5, #1667
X13 src/leasing/lease-acquisition-coordinator.ts:244-262 cancel finds one waiter by requester; a virtual processing waiter is not-cancellable a run release rejects every matching waiter cancelPending could reject (a physical one mid presence read included) and marks a virtual processing one (S5) B5, #1667
X14 src/gateway/fleet-admission.ts:47-52, :356-381 cancel by requester covers asking and queued fleet waiters; an asking request holds no id or run id; processing is not-cancellable an asking request also holds its runId and its owner; by run: asking and queued cancelled (asking ones not listed), processing marked (S5) B7, #1667
X15 src/gateway/fleet-forwarding.ts:105-145 releaseAll releases each index entry on its worker, counts UNKNOWN_LEASE as released, throws the first failure with released ids a run release walks the matching entries the same way B7, #1667
X16 src/gateway/dispatcher.ts:620-628 #ownedFleetLeases filters index entries by owner the run release filters by owner and run B7, #1667
X17 src/cli/commands/release.ts:16-27 a lease id or --all adds --run (I5) B8, #1667
X18 src/contract/operations.test.ts:27, src/contract/protocol.ts:13 role matrix row for release-all; protocol range a row for release-run; #1666 and #1667 each bump by one B5, #1666, #1667
X19 docs/internal/EVENTS.md:53, :55 lease.released reasons, killed for release --all; lease.rejected cancelled is "an explicit single-request cancel" lease.released names a run release under explicit; lease.rejected cancelled names a run release as a second source #1667
X20 src/agent-device/front/allocate.ts:194-204, src/agent-device/front/context.ts:130 leaseInput sends no run id; the allocate's runId goes only to agent-device leaseInput adds it (I7) B9, #1668
X21 src/agent-device/shared/release-scope.ts:9, src/agent-device/definition.ts:51 agent-device's run id rule; the local profile's runId is simlock-local the same rule is the run id rule; local leases show simlock-local B9, #1668
X22 packages/e2e/src/provider.ts:82-93, packages/e2e/src/options.ts:1-46 the scope's runId is the runner's request.runId; no runId option, no env read I6's rule picks it B10, #1668
X23 website using-devices/ci.mdx:108-114 "a job that is killed cannot release or renew, so its leases run out by themselves within ttlMs" describes the run id, the if: always() cleanup step, the per-job SIMLOCK_RUN for several jobs or a matrix, and simlock as a dev dependency at the farm's version #1667, #1668
X24 website reference/cli.mdx (lease, release, status), reference/cli.mdx environment variables, using-devices/remote-agents.mdx (lease-request body) no run id describe --run, SIMLOCK_RUN, release --run and the body field #1666, #1667
X30 src/mcp/contracts.ts:46-51, src/contract/operations-lease-request.ts:265 lease_simulator's input is the request's field set minus fleetRequestId, metadata, requesterId, requires the omit list adds runId (Non-goals) B11, #1666
X31 src/gateway/fleet-grant.ts:59-68, src/gateway/lease-index.ts:285 the index entry is built field by field at the grant; a later view never changes an entry the index holds the grant-time entry carries the waiter's runId B2, #1666
X32 src/daemon/dispatcher-leases.ts:54-67 the worker's lease.request handler copies each leasing option one by one adds runId B1, #1666
X33 src/daemon/dispatcher.ts:80, src/simlock-client/client.ts:74-76, src/admin/index.ts:64-66 lease.release-all is in the worker's handler map, and its types are re-exported from both client entries lease.release-run and its types join each B5, #1667
X34 src/cli/commands/lease.ts:78-84, src/cli/index-lease-requests.test.ts:859-872 the lease --help text is pinned word for word the text gains [--run <id>]; that test changes by that one item B3, #1666
X25 src/cli/commands/release.ts:19, src/cli/connect.ts the CLI reaches only the local daemon; #1641 (task:ready, not built) adds remote mode #1666 and #1667 build on #1641's connect; the cleanup step needs it #1666, #1667

Tasks

flowchart LR
  P[#1641 CLI remote mode] --> Q[#1642 reconnect]
  Q --> M[#1651 → #1652 iOS modes]
  M --> A[#1666 run id on a lease]
  A --> B[#1667 release --run]
  B --> C[#1668 e2e and agent-device tag the run]
Loading

Completion conditions and the task that delivers each:

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
    on Nov 17, 2026
  2. changed the title [-]CI runs: device settings in the lease request, and release every lease of a run[/-] [+]CI runs: release every lease of a run in one call[/+] on Nov 17, 2026
  3. V3RON commented on Nov 17, 2026

    @V3RON
    ContributorAuthor

    Split from #1294 with #1634: this feature keeps only the run release half; device preparation moved to #1634. Sections moved: Problem, Who it is for, Outcome.

    Written by an agent.

  4. V3RON commented on Nov 17, 2026

    @V3RON
    ContributorAuthor

    Session paused on 2026-11-17, waiting on #945. Sections moved: Open questions (waits on #945's remote CLI design), Decisions (who may free a run; where the e2e provider's run id comes from). It stays feature:spec; the next session starts at its Open questions.

    Written by an agent.

  5. V3RON commented on Nov 17, 2026

    @V3RON
    ContributorAuthor

    Waits on #1635 (the CLI reaches a remote farm with a URL and a token), split from #945. Open questions updated to name it.

    Written by an agent.

  6. V3RON commented on Nov 17, 2026

    @V3RON
    ContributorAuthor

    Design posted: Outcome, How it works, Examples, What could go wrong, Words used, Non-goals and Completion conditions rewritten; Open questions emptied (#1635 is planned: the cleanup is a remote simlock release --run, and the tasks will depend on #1641); Decisions extended; Behaviours B1–B10, Stored state S1–S5, Interfaces I1–I7 and Existing code X1–X24 added.

    Written by an agent.

  7. V3RON commented on Nov 17, 2026

    @V3RON
    ContributorAuthor

    Spec updated: approved on 2026-11-17; tasks #1666 → #1667 → #1668 written (after #1641), each Task and Used by cell names its issue, and the Tasks section is filled. B7's test model is src/gateway/fleet-coordinator-forwarding.test.ts.

    Written by an agent.

  8. V3RON commented on Nov 17, 2026

    @V3RON
    ContributorAuthor

    Spec updated after the tasks check: B11 (MCP lease_simulator offers no runId), B2's grant-time index entry case, I3's help line, and X30–X34 (MCP omit list, gateway grant entry, worker request handler, release-run registration, pinned help test) added; #1666 now also depends on #1642 and #1652 (same requestLease call; protocol bumps in order).

    Written by an agent.

  9. added
    feature:planned
    and removed
    feature:spec
    on Nov 17, 2026
  10. V3RON commented on Nov 17, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: none
    Parked: none
    Waiting: #1666 — on #1641, #1642 (feature #1635) and #1652 (feature #1645); #1667 — on #1666; #1668 — on #1667

    Written by an agent.

  11. github-actions commented on Nov 18, 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.

  12. github-actions commented on Nov 18, 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.

  13. V3RON commented on Nov 18, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: #1704 (#1666), #1713 (#1667), #1716 (#1668)
    Parked: none
    Waiting: none
    Decided: none needing the maintainer; small gaps are Assumption lines in each PR body
    Filed: #1719, #1720 (flaky-test, bug:new) — the two e2e tests that held the gate

    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:planned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions