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
40 changes: 21 additions & 19 deletions docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ granted.
force a re-provision of one already running, even while slim devices sit
idle in the warm pool.
- `--detach` — print the lease result (the same JSON shape as the grant line
below, including `device.featureProfile`) and exit instead of staying
below, including `device.mode`) and exit instead of staying
alive. Nothing then renews the lease on your behalf: keep it with
`simlock lease renew` before `ttlDeadline`, and end it with
`simlock release`. From an invocation other than the one granted the
Expand Down Expand Up @@ -226,7 +226,7 @@ default, so a bare `simctl` or `adb` will not find them. See
The full line, with every field the contract defines:

```json
{"device":{"id":"dev_1a2b","driverDeviceId":"ABCD-...","spec":{"platform":"ios","model":"iPhone 17 Pro","osVersion":"26.5"},"address":"...","featureProfile":"reduced"},"lease":{"id":"lse_9f2c","deviceId":"dev_1a2b","requesterId":"agent-1","ownerId":"agent-1","grantedAt":1735689600000,"ttlMs":900000,"lastRenewedAt":1735689600000,"ttlDeadline":1735690500000},"timing":{"estimatedProvisionMs":0,"estimatedBootMs":0,"estimatedReclaimMs":0,"estimatedReadyMs":0},"role":"agent"}
{"device":{"id":"dev_1a2b","driverDeviceId":"ABCD-...","spec":{"platform":"ios","model":"iPhone 17 Pro","osVersion":"26.5"},"address":"...","mode":"slim"},"lease":{"id":"lse_9f2c","deviceId":"dev_1a2b","requesterId":"agent-1","ownerId":"agent-1","grantedAt":1735689600000,"ttlMs":900000,"lastRenewedAt":1735689600000,"ttlDeadline":1735690500000},"timing":{"estimatedProvisionMs":0,"estimatedBootMs":0,"estimatedReclaimMs":0,"estimatedReadyMs":0},"role":"agent"}
```

`lease.ttlDeadline` is the moment the daemon will expire this lease if
Expand Down Expand Up @@ -275,15 +275,15 @@ daemon ended the lease while the connection was alive, which is a different
thing to have to handle.

`device` is a **projection** of the registry's device record — `id`,
`driverDeviceId`, `spec`, `address?`, `featureProfile?` — not the full
`driverDeviceId`, `spec`, `address?`, `mode` — not the full
record `status.get`/`list.get` return to an admin caller. Internal
bookkeeping fields (`driverData`, `quarantine*`, `foreign*`, `recovering*`,
the derived `transitionAgeMs`) never appear on a grant; a caller that wants
those needs the admin-role `list.get`/`status.get`, not `lease.request`'s
output. `device.featureProfile` is `"reduced"` when the granted device had
its feature set reduced (iOS slim mode applied and this request did not pass
`--full`), and `"full"` or absent otherwise — always absent for Android. It
lets an agent explain a feature-loss failure (missing push notification,
output. `device.mode` is the device mode the granted device actually has:
`"slim"` when its feature set was reduced (iOS slim mode applied and this
request did not pass `--full`), and `"full"` otherwise — always `"full"` for
Android. It lets an agent explain a feature-loss failure (missing push notification,
Spotlight result, StoreKit sheet, universal link, or system picker) instead
of misreading it as a bug. See `src/contract/schemas.ts`
(`deviceRecordSchema`, `leaseRecordSchema`, `leaseGrantSchema`) for the full
Expand Down Expand Up @@ -731,7 +731,7 @@ simlock worker remove <worker-id>

```json
{"workers":[{"id":"3f81a2c4","label":"mac-studio-2","state":"connected","drained":false,
"daemonVersion":"0.4.0","protocol":{"min":6,"max":6},
"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"},
Expand All @@ -742,7 +742,7 @@ simlock worker remove <worker-id>
`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: 6, max: 6}` with no shim, so a worker older than it does not
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.

Expand Down Expand Up @@ -860,12 +860,11 @@ caller:
small" unless you know to check the unit. Update every caller's timeout
field name *and* multiply its value by 1000.
- **The top-level `slim: boolean` on a grant is gone; it's now
`device.featureProfile`** (`"full" | "reduced" | undefined`, undefined
meaning "not applicable" — always undefined for Android). A caller
checking `result.slim === true` now silently never sees a feature-loss
signal at all — `result.slim` is simply `undefined` on every response,
which is falsy, not an error. Check `result.device.featureProfile ===
"reduced"` instead.
`device.mode`** (`"slim"` or `"full"`, always `"full"` for Android). A
caller checking `result.slim === true` now silently never sees a
feature-loss signal at all — `result.slim` is simply `undefined` on every
response, which is falsy, not an error. Check `result.device.mode ===
"slim"` instead.

Every other field keeps the contract's own camelCase names it already had
under the pre-0.3.0 hand-written schemas (`leaseId`, `deviceId`,
Expand All @@ -892,7 +891,8 @@ and `list --devices` well before it crosses the threshold that would make

Human-oriented overview: daemon health *and mode*, managed capacity
(used/limit per platform), running and reserved capacity (globally and per
platform), every managed device with its state, current leases (who — the agent
platform), every managed device with its state and device mode
(`Device dev_7: ready, mode slim`), current leases (who — the agent
id, see [Agent identity](#agent-identity) — since when, and when each was last
renewed), and queue depth. `--json` for the structured equivalent. `overLimit`
is true when a lowered limit cannot yet be met, for example because active
Expand All @@ -902,12 +902,13 @@ Against a **gateway** (`config.mode: "gateway"`) the same command
answers for the whole fleet, in the same shape: the daemon line reads
`running (gateway)`, capacity is summed across the connected workers, one line
per worker precedes the devices, and every device and lease names the worker it
lives on (`Device dev_7 on wrk_a: leased`). `--json` gains a `workers` array of
lives on (`Device dev_7 on wrk_a: leased, mode full`). `--json` gains a `workers` array of
[worker views](#simlock-worker-listdrainundrainremove) and a `workerId` on each
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. Against a **gateway** the
that tells a client which kind of daemon answered. 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
depth, plus a `workers` array of worker views (the same records
Expand All @@ -923,7 +924,8 @@ 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
agent id (see [Agent identity](#agent-identity)) that holds it, and its
`lastRenewedAt` is when the lease was last renewed (set at grant, then on
every renew) — the same field `status` renders as "last renewed".
every renew) — the same field `status` renders as "last renewed". Each device
record carries its device mode, `mode`: `"slim"` or `"full"`.

Against a gateway, `--devices` and `--leases` list the whole fleet with a
`workerId` on every row. The device rows are the narrower shape `status`
Expand Down
10 changes: 9 additions & 1 deletion docs/CLIENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ await client.releaseLease({ leaseId: grant.lease.id });
await client.close();
```

`grant.device.mode` is the device mode the granted device actually has:
`"slim"` when its driver reduced its feature set (iOS slim mode), `"full"`
otherwise. A slim device lacks some system features — push notifications,
Spotlight, StoreKit sheets, universal links, system pickers — so check it
before treating such a failure as a bug. Every device in `getStatus()` and in
an admin's `list({ kind: "devices" })` carries the same `mode`.

**Keeping the lease alive is yours to do.** Every lease is TTL-bound: it expires at
`grant.lease.ttlDeadline` unless a `renewLease` call lands first, and the
daemon does nothing on its own to keep it. `requestLease` takes an optional
Expand Down Expand Up @@ -377,7 +384,8 @@ gateway implementing the same contract: nothing in this module knows the
difference, and neither does code written against it.

**The one way to tell is `mode` in `getStatus()`'s daemon block**
(`"worker" | "gateway"`). Everything else you might reach for is a leaky
(`"worker" | "gateway"`) — not each device's own `mode`, which is the device
mode (`"slim" | "full"`). Everything else you might reach for is a leaky
inference rather than an answer: a lease from a gateway carries an additive
`worker: { id, label }` block, but so might a future single-machine daemon's;
a lease id from a gateway names its worker, but ids are opaque and parsing
Expand Down
26 changes: 15 additions & 11 deletions docs/HTTP-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ that machine.
## Endpoints

All routes are under `/v1`, JSON bodies both ways, additive evolution only —
new fields, never removed or repurposed ones. That rule was broken once,
as a deliberate 0.x-only exception, and each break is called out where
it applies below:
new fields, never removed or repurposed ones. That rule has been broken
twice, each time as a deliberate 0.x-only exception, and each break is
called out where it applies below:

- **`mode` is gone** from the lease record the operator routes serialize
(`GET /v1/status`, `GET /v1/leases`), and **`lastRenewedAt` and the stored
Expand All @@ -107,6 +107,9 @@ it applies below:
be accepted.
- **The `ttlMs` a lease reports is the lease's own width**, not a value the
HTTP frontend remembered per request.
- **The lease's `slim` boolean is gone; it carries `mode` instead** —
`"slim"` or `"full"`, the device mode of the granted device. Every device in
`GET /v1/status` carries the same `mode`.

Routes, status codes, and every other field are unchanged.

Expand All @@ -125,8 +128,8 @@ Unauthenticated liveness for tunnels/load balancers. → `200 {"ok":true}`.
### `GET /v1/status`

Role: `agent`. The same view `simlock status --json` reads: a `daemon` block,
managed/running capacity per platform, active leases, managed devices, queue
depth.
managed/running capacity per platform, active leases, managed devices (each
with its device mode, `mode`: `"slim"` or `"full"`), queue depth.

The daemon block carries `health` (`starting`/`running`) and **`mode`**
(`"worker" | "gateway"`), the one field that tells a client which kind of
Expand Down Expand Up @@ -296,7 +299,7 @@ without the `workerId` and `worker` fields:
"workerId": "3f81a2c4", "worker": { "id": "3f81a2c4", "label": "mac-studio-2" },
"createdAt": "2026-09-01T09:14:07Z",
"expiresAt": "2026-09-01T09:29:07Z", "ttlMs": 900000,
"dataPlane": null, "slim": true
"dataPlane": null, "mode": "slim"
} }
```

Expand All @@ -323,9 +326,10 @@ implemented](#not-implemented) below. It is in the schema now so its arrival
is additive rather than a breaking shape change. Running a *command* on the
device is not part of it and does not wait for it: that is `exec`, below.

`slim` is `true` when the granted device had its feature set reduced (iOS
slim mode applied and the request did not carry `full: true`), `false`
otherwise — always `false` for Android. It lets a client explain a
`mode` is the device mode the granted device actually has: `"slim"` when its
feature set was reduced (iOS slim mode applied and the request did not carry
`full: true`), `"full"` otherwise — always `"full"` for Android. It lets a
client explain a
feature-loss failure (missing push notification, Spotlight result,
StoreKit sheet, universal link, or system picker) instead of misreading it
as a bug.
Expand Down Expand Up @@ -585,7 +589,7 @@ workers of its own and does not implement the underlying operations at all.
{ "workers": [ {
"id": "3f81a2c4", "label": "mac-studio-2",
"state": "connected", "drained": false,
"daemonVersion": "0.4.0", "protocol": { "min": 6, "max": 6 },
"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" },
Expand All @@ -600,7 +604,7 @@ 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: 6, max: 6}` with no compatibility shim, so a worker from before it
`{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.

Expand Down
14 changes: 8 additions & 6 deletions docs/internal/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,17 @@ applies to HTTP automatically because there is only one code path to fix.

**Protocol versions are negotiated as `{min, max}` ranges** and honestly:
a range widens only when a compatibility path is actually kept (ADR 0003 §6).
Two changes have moved it since. ADR 0004 removed `lease.heartbeat` and
Four changes have moved it since. ADR 0004 removed `lease.heartbeat` and
`mode` from the contract with no shim behind them, taking the wire to
protocol 4; ADR 0005 adds `device.exec`, its `output` push family, and a
`mode` field `status.get` now always carries, again with no compatibility
path kept, taking it to 5; ADR 0008 makes the catalog's `modelRuntimes`
required, taking it to 6. So the range both sides
advertise is `{min: 6, max: 6}`, an older client and a current daemon simply
required, taking it to 6; ADR 0007 makes every device report its device mode
as a required `mode`, taking it to 7. So the range both sides advertise is
`{min: 7, max: 7}`, an older client and a current daemon simply
do not overlap, and `hello` fails with `PROTOCOL_VERSION_UNSUPPORTED` naming
both ranges. The same negotiation runs over a worker's uplink, which is why a
worker older than ADR 0008 shows up in a gateway's views as `incompatible`
worker older than ADR 0007 shows up in a gateway's views as `incompatible`
rather than as a mystery (see [Gateway and worker
modes](#gateway-and-worker-modes-adr-0005)). `daemon.stop` stays the frozen
exception, accepted at any version the daemon has ever spoken, so the upgrade
Expand Down Expand Up @@ -731,8 +732,9 @@ emits its own facts — `worker.connected`, `worker.disconnected`,
widens only where a compatibility path is actually kept — so **every worker
older than ADR 0005 is `incompatible` by range**, by construction rather
than by accident. ADR 0008 moves it again, to `{min: 6, max: 6}`, because
the catalog's `modelRuntimes` is required; a worker on 5 is `incompatible`
the same way. That is the ordinary upgrade path, not a failure mode:
the catalog's `modelRuntimes` is required, and ADR 0007 to
`{min: 7, max: 7}`, because a device's `mode` is required; a worker on an
older version is `incompatible` the same way. That is the ordinary upgrade path, not a failure mode:
upgrade the worker. An incompatible worker is marked `incompatible` in its
view with both ranges shown and is never dispatched to, and it is not
hidden either — that is the machine an operator has to go and upgrade, and
Expand Down
20 changes: 13 additions & 7 deletions docs/internal/KNOWN-PITFALLS.md
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ the commands and drop them on the post-slim reboot, so slimming would cost a
second boot for no effect. `planSlimBoot` (`src/drivers/ios/index.ts`) gates
on this and skips the apply pass entirely rather than paying that cost —
silently, from the requester's point of view: the lease still grants, just
with `slim: false`. `simlock doctor`'s `driver-advisory` /
with `mode: "full"`. `simlock doctor`'s `driver-advisory` /
`slim-runtime-unsupported` finding is what makes an unsupported runtime
visible to an operator instead of it only ever showing up as an unexpectedly
non-slim lease.
Expand All @@ -733,12 +733,10 @@ universal links, Siri/Apple Intelligence, iCloud sync, and some system
pickers to not work on a slim device — the categories that back them are
exactly the ones slimming disables. Mitigations: `simlock lease --full` (MCP
`full: true`, HTTP `full: true`) opts a single lease out of slimming, and
every lease response carries a feature-profile signal so a caller can tell a
every lease response carries the device mode so a caller can tell a
feature-loss failure apart from an actual bug instead of guessing —
`device.featureProfile === "reduced"` on the CLI/MCP/client contract shape
(`slim` as a top-level boolean grant field is gone as of 0.3.0, ADR 0003
§11), or HTTP's own `lease.slim` boolean, which is still derived from the
same underlying signal.
`device.mode === "slim"` on the CLI/MCP/client contract shape, and
`lease.mode === "slim"` on HTTP (ADR 0007 §9: one word on every surface).

**Mixing slim and full devices under one spec can make `--full` wait or
re-provision.** `full` is part of spec identity (`DeviceSpec.full`, compared by `sameSpec`,
Expand Down Expand Up @@ -779,7 +777,7 @@ gates re-applying the disable pass changes, so an existing device re-applies
the now-narrower set on its next boot — but the `launchctl disable` overrides
already written for the *removed* category are never undone. They live in the
simulator's own launchd database and only disappear on `simctl erase`. The
device keeps reporting `slim: true` and keeps missing that category's
device keeps reporting `mode: "slim"` and keeps missing that category's
functionality, with no error surfaced anywhere. The real consequence is
stronger than the flag alone suggests: the device ends up slimmer than *any*
configuration ever asked for — it carries both the newly-narrower disable set
Expand All @@ -801,6 +799,14 @@ on the same timers as any other idle device, since neither rule cares what a
device's spec matches. Until those timers fire, though, it occupies a pool
slot doing nothing.

**A device slimmed before the upgrade to `mode` reports `full`.** A device
record written before devices carried a `mode` loads as `full`, and nothing
is derived from its old feature-profile field (ADR 0007 §11). A worker that
ran with `ios.slim.enabled` on therefore holds slimmed devices that report
`mode: "full"` on grants, `status`, and `list` until their next boot rewrites
the mode. Empty such a worker with `simlock nuke --delete-devices` before
upgrading it.

## A dispatched request whose uplink drops may have granted a lease anyway

The gateway dispatches a queued request to a worker with `noWait: true` and
Expand Down
Loading
Loading