Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,11 @@ component installs waiting or running on that worker, whoever started them,
in the shape [`simlock status`](#simlock-status) describes. It is re-read
when an install on that worker starts, finishes or fails, and on every
periodic refresh, so an install queued behind another may appear only then.
A disconnected or incompatible worker lists none. `catalog` is what that
A disconnected or incompatible worker lists none. `waiting` lists the
requests waiting in that worker's own queue, the same ones
[`simlock list --requests`](#simlock-list---devices--leases--rules--requests)
run on that worker prints. It is re-read on every lease event on that worker,
and a disconnected or incompatible worker lists none. `catalog` is what that
worker can lease, each model with the runtimes it pairs with, and lists a
newly installed component as soon as its install ends. `host` is the
machine: operating system, its version, CPU architecture, and the version of
Expand Down Expand Up @@ -1127,10 +1131,10 @@ depth, plus a `workers` array of worker views (the same records
[`simlock worker list`](#simlock-worker-listdrainundrainremove) prints). See
[Against a gateway](#against-a-gateway).

## `simlock list [--devices|--leases|--rules]`
## `simlock list [--devices|--leases|--rules|--requests]`

Scriptable listings of managed devices, active leases, or registered cleanup
rules. Defaults to `--devices`. Against a gateway, `--devices` and `--leases`
rules, and the requests waiting for a device. Defaults to `--devices`. Against a gateway, `--devices` and `--leases`
are the fleet's (each record naming its `workerId`) while `--rules` lists
nothing at all: cleanup rules run where the devices and the reaper are, and a
gateway has neither. Each lease record's `requesterId` is the
Expand All @@ -1146,6 +1150,30 @@ a device's driver address or a driver's private data, and does not invent one.
`--rules` lists nothing on a gateway — cleanup rules are a machine's own
configuration, and a gateway runs no reaper.

`--requests` prints one line per request waiting for a device, oldest first,
rather than JSON:

```
Request req_7: agent-b, ios iPhone 16 18.4 mode slim, queued at 2, waiting 12s
Request req_9: local-agent on 2b026432-7743-4a08-98fc-ce494d11866f, ios iPhone 16, starting, waiting 3s
```

Each line names the request, the agent that sent it, the device it asked for
(only the fields it named), where it stands, and how long it has waited.
`queued at 2` is its place in the queue, counting from 1, the requests ahead
of it that are already starting included. `starting` means the daemon is working
on it: placing it as it arrives, or finding, creating, booting or downloading
a device for it. With nothing waiting it prints
`No requests are waiting.` A granted, failed or cancelled request is not
listed.

Against a gateway, `--requests` lists the gateway's own queue first, then
the requests waiting in each worker's own queue, from that worker's local
agents, with ` on <workerId>`. A request the gateway has sent to a worker is
listed once, as the gateway's. A disconnected worker's requests are not
listed. A worker's request is stamped by that worker's clock, so if that
clock is off, its time waited is off by as much.

## `simlock catalog [--platform <ios|android>] [--json]`

Lists what can actually be leased, so an agent can pick a valid `--device`
Expand Down
23 changes: 23 additions & 0 deletions docs/CLIENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,29 @@ const { installs = [] } = await client.getStatus();
its entry in `workers` and on `listWorkers()`, beside its
`downloads.timeoutMs`.

## What is waiting: `getStatus().waiting`

`getStatus()` lists the requests waiting for a device in the daemon's own
queue, oldest first:

```ts
const { waiting = [] } = await client.getStatus();
// [{ id: "req_7", requesterId: "agent-b", spec: { platform: "ios", model: "iPhone 16" },
// createdAt: 1790864071200, stage: "queued", queuePosition: 1 }]
```

- `stage` is `queued` while the request holds a place in the queue, with
`queuePosition` counting from 1, and `starting` while the daemon is
working on it: placing it as it arrives, or finding, creating, booting or
downloading a device for it. `spec` has only the fields the
request named.
- A request leaves the list as soon as it is granted, fails or is cancelled.
The field is absent only from an older daemon.
- On a gateway the list is the gateway's own queue. Each worker's own is on
its entry in `workers` and on `listWorkers()`. The admin client's
`list({ kind: "requests" })` lists both, each worker's entries with their
`workerId`, the same list as `GET /v1/lease-requests`.

## One connection, no reconnect, no retry

This is the one thing to internalize before building anything on top of this
Expand Down
30 changes: 26 additions & 4 deletions docs/CONSOLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ The console is for people who operate Simlock. It needs an operator token.
Coding agents keep using the CLI, the MCP server, the client and the HTTP API.

This version has sign-in, the console's navigation (Workers, Leases, Waiting,
Attention and Events), and the Workers pages. The other pages say "Coming
soon" until their views are built.
Attention and Events), the Workers pages and the Waiting page. The other
pages say "Coming soon" until their views are built.

## Turn it on

Expand Down Expand Up @@ -125,14 +125,36 @@ Select a worker to open its page. It adds:
A page the daemon cannot answer on a single host says "Not available on a
single host" in place of its content.

## Waiting

**Waiting** lists every request waiting for a device, oldest first, as
`simlock list --requests` does. Each shows:

| Fact | What it says |
| --- | --- |
| Requester | The agent that asked |
| Device | The platform and model it asked for, and the runtime, mode and image tag when it named them |
| Worker | The worker whose own queue it waits in, or `—` for a request in a gateway's queue |
| Stage | `queued` while it waits its turn, `starting` while the daemon is working on it: placing it as it arrives, or finding, creating, booting or downloading a device for it |
| Place in queue | Where it stands, counting from 1, the requests ahead of it that are already starting included; `—` while starting |
| Waiting for | How long since the daemon received it |

On a gateway the list has the gateway's own queue and, for each connected
worker, the requests its own agents sent to it directly. A request the
gateway has passed to a worker shows once, as the gateway's. On a single
host every request shows that host as its worker.

A request leaves the list as soon as it gets its device, fails, or is
cancelled.

## Live updates

Every page keeps itself current. A change on the daemon, such as a lease
being granted or a worker disconnecting, shows within about a second, with
no reload. Durations count up every second on their own. They are measured
by the clock of the daemon the console talks to, so a browser whose clock is
wrong still shows them right. On a gateway, a worker's lease and install times
come from that worker's clock: if it is far from the gateway's, its durations
wrong still shows them right. On a gateway, a worker's lease, install and
waiting times come from that worker's clock: if it is far from the gateway's, its durations
are off by as much.

A hidden tab stops asking the daemon for anything. When you come back to it,
Expand Down
66 changes: 58 additions & 8 deletions docs/HTTP-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,18 @@ An install leaves the list as soon as it ends, whether it succeeded, failed
or timed out. A worker always sends the field, empty when nothing is
installing; an older daemon leaves it out.

**`waiting`** lists the requests waiting in this daemon's own queue for a
device, oldest first, in the shape
[`GET /v1/lease-requests`](#get-v1lease-requests) answers. A worker always
sends it, empty when nothing waits; an older daemon leaves it out.

On a **gateway** the numbers are the fleet's — capacity summed across connected
workers (`ramBudget` over the workers that report one, `overLimit` when any of
them is, absent when none does), every gateway-issued and local lease, every device, the
connected workers' installs (the 16 oldest across the fleet), the gateway
queue's depth — every lease, device and install carries the **`workerId`** it lives
on, and an additive **`workers`** array carries one
queue's depth and the requests waiting in it — every lease, device and install
carries the **`workerId`** it lives on, and an additive **`workers`** array
carries one
[worker view](#worker-routes) per worker:

```json
Expand Down Expand Up @@ -1035,6 +1041,12 @@ install queued behind another may appear only then. A worker that does not
send one shows an empty list; a disconnected or incompatible worker shows
none.

`waiting` is the worker's own `waiting` list from its
[`GET /v1/status`](#get-v1status): the requests waiting in that worker's
queue. It is re-read on every lease event on that worker. A worker that does
not send one shows an empty list; a disconnected or incompatible worker shows
none.

`catalog` is what that worker can lease, each model with the runtimes it
pairs with, and lists a newly installed component as soon as its install
ends. Its `customModels` are that worker's own, so this is where you see
Expand Down Expand Up @@ -1094,7 +1106,7 @@ take the host out of rotation or forget it.

### Operator routes

Role: `operator` for all four.
Role: `operator` for all five.

`DELETE /v1/leases/{id}` with an `operator` token already releases any single
lease, on a gateway as anywhere else. The fleet-wide form of that — the CLI's
Expand All @@ -1108,6 +1120,8 @@ could reach are still released — a partial result, said plainly, rather than
an all-or-nothing that leaves the operator guessing.

- `GET /v1/leases` — every active lease (`simlock list --leases`).
- `GET /v1/lease-requests` — every request waiting for a device
(`simlock list --requests`); see below.
- `GET /v1/devices` — every managed device, with state and
`transitionAgeMs` (`simlock list --devices`).
- `GET /v1/events?since=<duration>` — replay business events newer than
Expand All @@ -1119,12 +1133,48 @@ an all-or-nothing that leaves the operator guessing.
- `GET /v1/events/stream` — Server-Sent Events follow of the event bus
(`simlock events --follow`).

On a **gateway** all four are fleet-wide, which is what makes a single
On a **gateway** all five are fleet-wide, which is what makes a single
console possible: `/v1/leases` and `/v1/devices` return every connected
worker's, each record carrying the `workerId` it lives on, and the two event
routes carry the workers' republished events (also `workerId`-tagged)
interleaved with the gateway's own `worker.*` and `request.dispatched`
facts.
worker's, each record carrying the `workerId` it lives on,
`/v1/lease-requests` returns the gateway's queue and every connected
worker's, and the two event routes carry the workers' republished events
(also `workerId`-tagged) interleaved with the gateway's own `worker.*` and
`request.dispatched` facts.

#### `GET /v1/lease-requests`

Every request still waiting for a device, oldest first, whoever sent it. An
`agent` token gets `403 FORBIDDEN`.

```json
{ "requests": [
{ "id": "req_7", "requesterId": "agent-b",
"spec": { "platform": "ios", "model": "iPhone 16", "osVersion": "18.4", "mode": "slim" },
"createdAt": 1790864071200, "stage": "queued", "queuePosition": 1 },
{ "id": "req_9", "requesterId": "local-agent",
"spec": { "platform": "android", "model": "Pixel 8" },
"createdAt": 1790864075000, "stage": "starting", "workerId": "3f81a2c4" }
] }
```

- `spec` is the device as the request named it: `platform` and `model`, and
`osVersion`, `mode` and `imageTag` only when the request named them.
- `createdAt` is when the daemon holding the request received it, in
milliseconds since the epoch.
- `stage` is `queued` while the request holds a place in the queue, and
`starting` while the daemon is working on it: placing it as it arrives, or
finding, creating, booting or downloading a device for it.
- `queuePosition` is set only while `queued`: its place in the queue counting
from 1, the requests ahead of it that are already starting included. It is
the request's place now, not the one its `queued` progress first reported.
- A request leaves the list as soon as it is granted, fails or is cancelled.
The request's idempotency key and owner are never listed.

On a **gateway** the list is the gateway's own queue first, without
`workerId`, then the requests waiting in each connected worker's own queue,
from that worker's local agents, each with the **`workerId`** whose queue it
is in. A request the gateway has sent to a worker is listed once, as the
gateway's own. A worker's `createdAt` comes from that worker's clock.

## Errors

Expand Down
Loading
Loading