Repository navigation
Description
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]
Rules in play
src/contract/AGENTS.mdAdding an operation: steps 1 to 8, the role and effect matrices,max+ 1.src/leasing/AGENTS.md: every ending goes throughLeaseReleaseCoordinator; cancel and reject under the lock, wake the queue after.src/gateway/AGENTS.md: the gateway never decides a lease is gone; a worker'sUNKNOWN_LEASEdrops the entry; a non-admin reaches only what its principal owns.src/daemon/AGENTS.mdConnections:lease-lostskips 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-runon 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-lostto 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-runon 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_LEASEfrom a worker; one worker unreachable - B8:
simlock release --run: leases freed; nothing left; a bad id; with a lease id or--all;FORBIDDENorWORKER_UNREACHABLE; no confirmation
Done when
pnpm test:changedpasses, with every Tests line above as a test, and the existingrelease,release --alland gateway release tests pass unchanged.pnpm checkpasses, the protocol-bump check included:maxis one above the valuemainholds when this lands.- The website build passes:
pnpm --dir website install && pnpm --dir website build && node website/scripts/check-openapi.mjs.
Out of scope
- The agent-device front and
@simlock/e2e(CI runs: release every lease of a run in one call #1633's last task).
Depends on
Written by an agent.
Activity
test: lease.release-run cancels the caller's queued requests of a run (…
feat(leasing): lease.release-run cancels the caller's queued requests…
test: lease.release-run releases a booting virtual request at its gra…
feat(leasing): lease.release-run releases a booting virtual request a…
test: lease.release-run reaches the owner's leases, a physical reques…
test: the asking connection gets no lease-lost for the leases its lea…
feat(daemon): the connection that asks for lease.release-run gets no …
test: simlock release --run prints what a run release freed (#1667)
feat(cli): simlock release --run frees a run's leases and waiting req…
test: lease.release-run on a gateway releases a run's index entries o…
1 remaining item
test: lease.release-run on a gateway counts UNKNOWN_LEASE released, f…
test: lease.release-run on a gateway cancels the run's queued fleet r…
feat(gateway): lease.release-run cancels the run's queued fleet reque…
test: lease.release-run on a gateway cancels the run's requests still…
feat(gateway): lease.release-run cancels the run's requests still on …
test: lease.release-run on a gateway marks a request already dispatch…
feat(gateway): lease.release-run releases a dispatched fleet request …
test: on a gateway the asking connection gets no lease-lost for the l…
docs: simlock release --run, the CI cleanup step and the events it en…
chore: leaseReleaseRun is imported now, so its Fallow ignore goes (#1667
test: the uplink protocol-range refusal asks for a range one above th…
fix: a gateway lists the id of a dispatched request it marks to relea…
test: a gateway release-run lists the exact dispatched request id, an…
feat: simlock release --run frees a run's leases and waiting requests (…