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
122 changes: 97 additions & 25 deletions docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -716,9 +716,10 @@ the `admin` role (see [Admin credential
resolution](#admin-credential-resolution)). A worker has no workers of its
own, so it does not implement these operations at all and answers
`UNKNOWN_REQUEST` — they are not a gateway-mode refusal of something a worker
could otherwise do, they are simply not part of a worker's surface. Output is
JSON on stdout, unconditionally — `--json` is a usage error (exit 2), as
everywhere except `status`/`catalog`/`daemon`.
could otherwise do, they are simply not part of a worker's surface. `list`
prints one line per worker, or the views as JSON with `--json`; `drain`,
`undrain` and `remove` print JSON on stdout, unconditionally — `--json` is a
usage error (exit 2) for those three.

```
simlock worker list
Expand All @@ -727,26 +728,87 @@ simlock worker undrain <worker-id>
simlock worker remove <worker-id>
```

`list` prints one worker view per connected-or-remembered worker:
`list --json` prints one worker view per connected-or-remembered worker. This
one is a real answer from a test fleet whose drivers are simulated, which is
why its Android catalog looks thin, trimmed to one worker:

```json
{"workers":[{"id":"3f81a2c4","label":"mac-studio-2","state":"connected","drained":false,
"daemonVersion":"0.4.0","protocol":{"min":7,"max":7},
"connectedAt":1735689600000,"lastSeenAt":1735689930000,
"capacity":{"ios":{"running":2,"limit":4},"android":{"running":0,"limit":2}},
"downloads":{"policy":"on-request"},
"queueDepth":0,"leases":3,"devices":5}]}
{
"workers": [
{
"id": "2b026432-7743-4a08-98fc-ce494d11866f",
"label": "worker-a",
"connection": "connected",
"drained": false,
"lastSeenAt": 1790864080506,
"health": "running",
"version": "1.0.0",
"capacity": {
"ios": {
"running": 0,
"maxRunning": 8,
"reserved": 0,
"overLimit": false,
"limit": 8,
"warm": 0,
"used": 0
},
"android": {
"running": 0,
"maxRunning": 8,
"reserved": 0,
"overLimit": false,
"limit": 8,
"warm": 0,
"used": 0
},
"global": {"running": 0, "maxRunning": 8, "reserved": 0, "overLimit": false, "warm": 0}
},
"downloads": {"policy": "on-request"},
"lease": {"maxTtlMs": 14400000},
"queueDepth": 0,
"leases": [],
"devices": [],
"catalog": [
{
"platform": "ios",
"models": ["iPhone 16"],
"runtimes": ["18.4", "26.0"],
"defaultRuntime": "26.0",
"modelRuntimes": {"iPhone 16": ["18.4"]}
},
{
"platform": "android",
"models": [],
"runtimes": ["18.0"],
"defaultRuntime": "18.0",
"modelRuntimes": {}
}
],
"host": {
"os": "macOS",
"osVersion": "26.6.1",
"arch": "arm64",
"tools": [{"platform": "ios", "name": "xcode", "version": "16.4", "build": "16F6"}]
}
}
]
}
```

`downloads.policy` is that worker's own effective policy, read once with
`config.get` when its uplink connects — routing needs it to know whether a
machine may install a missing runtime before sending it a request that needs
one. `protocol` is the range that worker negotiated; the wire moves
to `{min: 7, max: 7}` with no shim, so a worker older than it does not
overlap and shows as `incompatible`. Worker ids are UUIDs — the examples here
abbreviate them to their first segment.

`state` is `connected`, `disconnected`, or `incompatible`. A **disconnected**
`downloads.policy` and `lease.maxTtlMs` are that worker's own effective
config, read when its uplink connects and again on every periodic refresh —
routing needs the policy to know whether a machine may install a missing
runtime before sending it a request that needs one. `catalog` is what that
worker can lease, each model with the runtimes it pairs with. `host` is the
machine: operating system, its version, CPU architecture, and the version of
each platform tool its drivers use (`xcode` with its build; the Android
`emulator`, `platform-tools` and `cmdline-tools`). A tool the worker does not
have is left out. `protocol` appears only on an `incompatible` worker and
names both ranges, the worker's and the gateway's, so you can see which side
to upgrade. Worker ids are UUIDs; the console example below shortens them to fit.

`connection` is `connected`, `disconnected`, or `incompatible`. A **disconnected**
worker keeps its last-known view (nothing is dispatched to it) until an
operator removes it or `gateway.disconnectedRetentionMs` (24 hours) elapses.
The retention clock is held while the gateway still knows of gateway-issued
Expand Down Expand Up @@ -889,7 +951,8 @@ A device currently `provisioning` or `reclaiming` carries a derived
and `list --devices` well before it crosses the threshold that would make
`doctor` flag it as stalled.

Human-oriented overview: daemon health *and mode*, managed capacity
Human-oriented overview: daemon health *and mode*, the host it runs on
(`Host: macOS 15.5 arm64; xcode 16.4 (16F6), emulator 35.4.9`), managed capacity
(used/limit per platform), running and reserved capacity (globally and per
platform), every managed device with its state and device mode
(`Device dev_7: ready, mode slim`), current leases (who — the agent
Expand All @@ -907,7 +970,15 @@ lives on (`Device dev_7 on wrk_a: leased, mode full`). `--json` gains a `workers
device and lease; `daemon.mode` says which kind of daemon answered.

The daemon block carries `mode` (`"worker"` or `"gateway"`) — the one field
that tells a client which kind of daemon answered. Do not confuse it with each
that tells a client which kind of daemon answered. Beside it, `host` says
what machine the daemon runs on: `os`, `osVersion`, `arch`, and `tools`, one
entry per platform tool its drivers use with the `platform`, `name`,
`version` and, for Xcode, `build`. Tool versions are read when the daemon
starts and again in the background once a minute has passed, so `status`
never waits for them. Right after a start, or for a tool that is not
installed, `tools` has no entry; if a later read fails, the last version read
stays. A gateway runs no drivers, so its own `host` has no
tools; each worker's is on its worker view. Do not confuse it with each
device's own `mode`, the device mode (`"slim"` or `"full"`). Against a **gateway** the
same view is the fleet's: capacity summed over the connected workers, every
lease and device tagged with the `workerId` it lives on, the gateway queue's
Expand Down Expand Up @@ -1166,8 +1237,9 @@ operation **on a gateway**; against a worker they answer `UNKNOWN_REQUEST`

- `list [--json]` — one line per worker: its id (the worker's own instance
identity — stable across restarts, and not its label or host name), its
label if it set one, connection state, capacity, and how many leases it
holds. A worker the gateway cannot speak to shows `incompatible` with both
label if it set one, connection state, capacity, how many leases it
holds, and its host: operating system, version, architecture, and tool
versions. A worker the gateway cannot speak to shows `incompatible` with both
protocol ranges, which is what version skew looks like from here. `--json`
prints the raw worker views, which is what the console renders.
- `drain <worker-id>` / `undrain <worker-id>` — a drained worker keeps its
Expand All @@ -1187,8 +1259,8 @@ operation **on a gateway**; against a worker they answer `UNKNOWN_REQUEST`

```console
$ simlock worker list
wrk_9f2c (mac-mini-1): connected -- ios 1/2, android 0/1, 1 lease(s)
wrk_4a10 (ci-runner-3): disconnected, drained -- ios 0/4, android 0/2, 0 lease(s)
wrk_9f2c (mac-mini-1): connected -- ios 1/2, android 0/1, 1 lease(s) -- macOS 15.5 arm64; xcode 16.4 (16F6), emulator 35.4.9
wrk_4a10 (ci-runner-3): disconnected, drained -- ios 0/4, android 0/2, 0 lease(s) -- macOS 14.7 x64; xcode 16.2 (16C5032a)
```

## `simlock config [get <key>|set <key> <value>]`
Expand Down
21 changes: 21 additions & 0 deletions docs/CLIENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,27 @@ runtime. The gateway does not yet use the pairings to pick a worker, so a
pair it lists can still go to a worker that has the model and the runtime
but cannot pair them, and that request fails there.

## What machine answered: `getStatus().host`

`getStatus()` carries a `host` block beside `daemon`: the machine the daemon
runs on, worked out from the machine itself.

```ts
const { host } = await client.getStatus();
// { os: "macOS", osVersion: "15.5", arch: "arm64",
// tools: [{ platform: "ios", name: "xcode", version: "16.4", build: "16F6" },
// { platform: "android", name: "emulator", version: "35.4.9" }] }
```

- `tools` has one entry per platform tool the daemon's drivers use. A tool
that is not installed is left out. Versions are read in the background, so
`getStatus` never waits for them, and right after a daemon starts the list
can be empty for a moment. They are read again once a minute has passed;
if a read fails, the version from the last good read stays.
- A gateway reports its own machine with no tools, since it runs no
drivers. Each worker's `host` is on its entry in `workers`, and on
`listWorkers()` from the admin client.

## One connection, no reconnect, no retry

This is the one thing to internalize before building anything on top of this
Expand Down
121 changes: 101 additions & 20 deletions docs/HTTP-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,24 @@ daemon answered:
{ "daemon": { "health": "running", "mode": "worker" } }
```

Beside it, **`host`** says what machine the daemon runs on: the operating
system, its version, the CPU architecture, and the version of each platform
tool its drivers use:

```json
"host": { "os": "macOS", "osVersion": "15.5", "arch": "arm64",
"tools": [ { "platform": "ios", "name": "xcode", "version": "16.4", "build": "16F6" },
{ "platform": "android", "name": "emulator", "version": "35.4.9" },
{ "platform": "android", "name": "platform-tools", "version": "36.0.0" },
{ "platform": "android", "name": "cmdline-tools", "version": "19.0" } ] }
```

The daemon works these out from the machine; no config key changes them. Tool
versions are read at start and again in the background once a minute has
passed, so this endpoint never waits for them. Right after a start, or for a
tool that is not installed, `tools` has no entry for it; if a later read
fails, the last version read stays.

On a **gateway** the numbers are the fleet's — capacity summed across connected
workers, every gateway-issued and local lease, every device, the gateway
queue's depth — every lease and device carries the **`workerId`** it lives
Expand All @@ -147,10 +165,13 @@ on, and an additive **`workers`** array carries one

```json
{ "daemon": { "health": "running", "mode": "gateway" },
"workers": [ { "id": "3f81a2c4", "label": "mac-studio-2", "state": "connected", "drained": false } ] }
"host": { "os": "Linux", "osVersion": "6.8.0", "arch": "x64", "tools": [] },
"workers": [ { "id": "3f81a2c4", "label": "mac-studio-2", "connection": "connected", "drained": false } ] }
```

On a worker, `workers` is absent and `workerId` never appears. A client that
A gateway's own `host` is the gateway's machine and has no tools, since it
runs no drivers; each worker's is on its worker view. On a worker, `workers`
is absent and `workerId` never appears. A client that
reads neither cannot tell the difference, which is the point.

### `GET /v1/catalog?platform=ios|android`
Expand Down Expand Up @@ -585,30 +606,90 @@ workers of its own and does not implement the underlying operations at all.
- `DELETE /v1/workers/{id}/drain` — undrain it, putting it back in rotation.
- `DELETE /v1/workers/{id}` — forget a worker's view.

`GET /v1/workers`, a real answer from a test fleet whose drivers are
simulated (hence the thin Android catalog), trimmed to one worker:

```json
{ "workers": [ {
"id": "3f81a2c4", "label": "mac-studio-2",
"state": "connected", "drained": false,
"daemonVersion": "0.4.0", "protocol": { "min": 7, "max": 7 },
"connectedAt": "2026-09-01T09:00:00Z", "lastSeenAt": "2026-09-01T09:14:30Z",
"capacity": { "ios": { "running": 2, "limit": 4 }, "android": { "running": 0, "limit": 2 } },
"downloads": { "policy": "on-request" },
"queueDepth": 0, "leases": 3, "devices": 5
} ] }
{
"workers": [
{
"id": "2b026432-7743-4a08-98fc-ce494d11866f",
"label": "worker-a",
"connection": "connected",
"drained": false,
"lastSeenAt": 1790864080506,
"health": "running",
"version": "1.0.0",
"capacity": {
"ios": {
"running": 0,
"maxRunning": 8,
"reserved": 0,
"overLimit": false,
"limit": 8,
"warm": 0,
"used": 0
},
"android": {
"running": 0,
"maxRunning": 8,
"reserved": 0,
"overLimit": false,
"limit": 8,
"warm": 0,
"used": 0
},
"global": {"running": 0, "maxRunning": 8, "reserved": 0, "overLimit": false, "warm": 0}
},
"downloads": {"policy": "on-request"},
"lease": {"maxTtlMs": 14400000},
"queueDepth": 0,
"leases": [],
"devices": [],
"catalog": [
{
"platform": "ios",
"models": ["iPhone 16"],
"runtimes": ["18.4", "26.0"],
"defaultRuntime": "26.0",
"modelRuntimes": {"iPhone 16": ["18.4"]}
},
{
"platform": "android",
"models": [],
"runtimes": ["18.0"],
"defaultRuntime": "18.0",
"modelRuntimes": {}
}
],
"host": {
"os": "macOS",
"osVersion": "26.6.1",
"arch": "arm64",
"tools": [{"platform": "ios", "name": "xcode", "version": "16.4", "build": "16F6"}]
}
}
]
}
```

`downloads.policy` is that worker's own effective policy, read once with
`config.get` when its uplink connects. Routing needs it to know whether a
worker may install a missing runtime at all before sending it a request that
depends on one; it is never an override, since the worker clamps
`downloads.policy` is that worker's own effective policy, read when its
uplink connects and again on every periodic refresh. Routing needs it to know
whether a worker may install a missing runtime at all before sending it a
request that depends on one; it is never an override, since the worker clamps
`allowDownload` through the same policy regardless.

`protocol` is the range that worker negotiated. The wire moves to
`{min: 7, max: 7}` with no compatibility shim, so a worker from before it
does not overlap and shows as `incompatible` — the ordinary upgrade path, not
a fault.
`catalog` is what that worker can lease, each model with the runtimes it
pairs with. `host` is the worker's machine, the same block its own
`GET /v1/status` reports, as of the gateway's last refresh: a tool installed
or upgraded on the worker shows here without a restart of either side.

`protocol` appears only on an `incompatible` worker: it names both ranges,
the worker's and the gateway's, so you can see which side to upgrade. A worker
too old to overlap is the ordinary upgrade path, not a fault, and its view
carries no `host`, since the gateway asks it nothing.

`state` is `connected`, `disconnected`, or `incompatible`. A worker view is
`connection` is `connected`, `disconnected`, or `incompatible`. A worker view is
rebuilt over the uplink and never persisted, so these are current facts, not
a registry: a worker appears by connecting, and there is deliberately no
route that *adds* one.
Expand Down
Loading
Loading