Skip to content

simlock release --run frees every lease and waiting request of a run, on a worker and through a gateway #1667

Closed

Description

@V3RON

Part of #1633.

Scope

simlock release --run <id> frees a run in one call, on a standalone worker and through a gateway. Every lease of the run this token holds ends at once; an operator token reaches every holder. The run's queued requests are cancelled, and one already booting a virtual device is released the moment it is granted. The answer lists the lease and request ids; a run with nothing left answers empty lists and exits 0. The asking connection gets no lease-lost for what it freed. The CI page shows the if: always() cleanup step and the per-job SIMLOCK_RUN for several jobs or a matrix.

A user would notice: a lease of another token or another run ended, a killed job's booting device held until its TTL, a cleanup step that fails on a run with nothing left, or a cleanup that hangs on a booting device.

Technical spec

Commit c9d82e3.

Rows

Behaviours: B5, B6, B7, B8
Stored state: S5
Interfaces: I4, I5
Existing code: X10, X11, X12, X13, X14, X15, X16, X17, X18 (the #1667 bump), X19, X23 (the cleanup step, per-job SIMLOCK_RUN, simlock as a dev dependency), X24 (reference/cli.mdx release), X25, X28 (the self-push skip reads runId), X33

Facts

# Fact Source
F1 The asking connection's self-push skip is the connection's selfInitiatedReleases set src/daemon/server-connection.ts:58, src/daemon/server-requests.ts:71-97
F2 A queued waiter is rejected with RequestCancelledError and emits lease.rejected cancelled src/leasing/lease-acquisition-coordinator.ts:257, src/leasing/lease-acquisition-coordinator.test.ts:484
F3 A gateway waiting request whose admission command still runs is ended through #endAsking(asking, "cancelled") src/gateway/fleet-admission.ts:363-369

Modules touched

src/contract/ (operations-leases.ts: lease.release-run; operations.ts; operations.test.ts; protocol.ts bump), src/daemon/ (dispatcher-leases.ts, dispatcher.ts handler map, server-requests.ts), src/leasing/ (lease-acquisition-coordinator.ts: reject by run and the release-at-grant mark; waiter-outcomes.ts or the grant path that reads it; lease-release-coordinator.ts; create-leasing.ts, lease-ports.ts), src/gateway/ (dispatcher.ts, fleet-coordinator.ts, fleet-admission.ts, fleet-forwarding.ts, fleet-dispatch.ts, queue.ts), src/simlock-client/ (client-api.ts, client-impl.ts, client-degraded.ts, types.ts), src/simlock-client/client.ts and src/admin/index.ts type re-exports, src/client/index.ts, src/cli/commands/release.ts, src/cli/test-index.ts, docs/internal/EVENTS.md, and the website pages reference/cli.mdx, using-devices/ci.mdx, reference/errors.mdx if a row there names release --all alone. Searches: lease.release-all, releaseAll, releaseAllLeases, cancelPending, findPendingWaiter, selfInitiatedReleases, leaseSnapshot, #ownedFleetLeases, withReleasedDetails.

flowchart LR
  cli[cli: release --run] --> client[simlock-client]
  client --> daemon[daemon: dispatcher + self-push skip]
  daemon --> leasing[leasing: release, cancel, mark]
  daemon --> gw[gateway: index, fleet requests, per-lease release]
Loading

Rules in play

  • src/contract/AGENTS.md Adding an operation: steps 1 to 8, the role and effect matrices, max + 1.
  • src/leasing/AGENTS.md: every ending goes through LeaseReleaseCoordinator; cancel and reject under the lock, wake the queue after.
  • src/gateway/AGENTS.md: the gateway never decides a lease is gone; a worker's UNKNOWN_LEASE drops the entry; a non-admin reaches only what its principal owns.
  • src/daemon/AGENTS.md Connections: lease-lost skips the connection that asked for that release.
  • ADR 0003 §2: one operation, the role check in the dispatcher; ADR 0005: a gateway release goes to the worker the index names.
  • Documentation rule 9: the website pages and EVENTS.md.

Tests

Seam: the daemon dispatcher and createLeasing with fake drivers and the fake clock (models: src/leasing/lease-acquisition-coordinator.test.ts, src/daemon/server-pushes.test.ts), the gateway dispatcher with fake worker links (models: src/gateway/fleet-coordinator-forwarding.test.ts, src/gateway/fleet-admission.test.ts), and runCli with a fake session (model: src/cli/index-lease-requests.test.ts).

  • B5: lease.release-run on a worker: each row of the second Examples table, agent and admin; two leases; a queued request; a booting virtual request (granted, then released); a physical one mid presence read; nothing matches; a bad run id
  • B6: no lease-lost to the asking connection: the asking connection; a second one of the same principal; an admin's release of another owner's lease; the same on a gateway; a lease of another run
  • B7: lease.release-run on a gateway: two workers; an agent and another owner's entry; admin; queued, asking and dispatched fleet requests; a joined worker's own local lease; UNKNOWN_LEASE from a worker; one worker unreachable
  • B8: simlock release --run: leases freed; nothing left; a bad id; with a lease id or --all; FORBIDDEN or WORKER_UNREACHABLE; no confirmation

Done when

  • pnpm test:changed passes, with every Tests line above as a test, and the existing release, release --all and gateway release tests pass unchanged.
  • pnpm check passes, the protocol-bump check included: max is one above the value main holds when this lands.
  • The website build passes: pnpm --dir website install && pnpm --dir website build && node website/scripts/check-openapi.mjs.

Out of scope

Depends on

Written by an agent.

Activity

  1. added
    task:draft
    on Nov 17, 2026
  2. added
    task:ready
    and removed
    task:draft
    on Nov 17, 2026
  3. self-assigned this
    on Nov 18, 2026
  4. 1 remaining item

  5. added a commit that references this issue on Nov 18, 2026
    96a24b2
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