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 @@ -133,9 +133,9 @@ a timer and releasing it when it exits.

```
simlock lease --platform <ios|android> --device <model> [--os <version>]
[--agent-id <id>] [--timeout <duration>] [--no-wait] [--detach]
[--ttl <duration>] [--allow-download] [--full] [--export-env]
[--bind-pid <pid>]
[--mode <slim|full>] [--agent-id <id>] [--timeout <duration>]
[--no-wait] [--detach] [--ttl <duration>] [--allow-download]
[--export-env] [--bind-pid <pid>]
```

There is only one kind of lease: every lease has a
Expand Down Expand Up @@ -181,13 +181,16 @@ granted.
`component.install-failed` on the event bus (`simlock events --follow`);
see [EVENTS.md](EVENTS.md#components). The requester's own progress stream
(below) does not yet reflect an in-flight download.
- `--full` — opt this lease out of iOS slim mode (see
[CONFIGURATION.md](CONFIGURATION.md) for what slim mode disables). Only
meaningful when `ios.slim.enabled` is on; ignored otherwise, and ignored
for Android. A `--full` request never matches, and never shares a pool key
with, a slim device, so it can wait for a fresh device to provision or
force a re-provision of one already running, even while slim devices sit
idle in the warm pool.
- `--mode <slim|full>` — the device mode this lease asks for. Without it, the
lease gets the default mode of the worker that serves it (`ios.defaultMode`,
`full` unless configured). `full` is a guarantee: a `full` lease never gets a
slim device. `slim` is best effort: on a runtime that cannot be slimmed (an
iOS runtime older than 18.5, or any Android device) the lease is granted a
full device. A lease only reuses an idle device of the mode it resolved to,
so it can wait for a fresh device even while devices of the other mode sit
idle. Any other value is a `BAD_REQUEST` (exit 2). See
[CONFIGURATION.md](CONFIGURATION.md#device-mode-slim-and-full) for what a
slim device leaves out.
- `--detach` — print the lease result (the same JSON shape as the grant line
below, including `device.mode`) and exit instead of staying
alive. Nothing then renews the lease on your behalf: keep it with
Expand Down Expand Up @@ -281,9 +284,9 @@ 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.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,
`"slim"` when its feature set was reduced, and `"full"` otherwise — always
`"full"` for Android. A `--mode slim` lease can report `"full"` (slim is best
effort); a `--mode full` lease never reports `"slim"`. 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 @@ -1131,14 +1134,13 @@ enters `quarantined` (see [#21](https://github.com/callstackincubator/simlock/is
rather than being re-driven, since it may be mid-erase. As with every other
`--fix` correction, a leased device is never touched.

When `ios.slim.enabled` is on, `doctor` also reports a `driver-advisory`
When `ios.defaultMode` is `slim`, `doctor` also reports a `driver-advisory`
finding (code `slim-runtime-unsupported`) for each installed iOS runtime
older than 18.5 — the version floor `launchctl disable` overrides need to
survive a reboot (see [CONFIGURATION.md](CONFIGURATION.md)). Slim mode
silently does nothing on those runtimes otherwise; this finding is what
makes that visible. It is advisory only — there is no `--fix` for it, since
the fix is either upgrading the runtime or narrowing `ios.slim` to the
runtimes that support it.
survive a reboot (see [CONFIGURATION.md](CONFIGURATION.md#device-mode-slim-and-full)).
A lease on those runtimes that asks for slim, or names no mode, gets a full
device; this finding is what makes that visible. It is advisory only — there
is no `--fix` for it, since the fix is upgrading the runtime.

On macOS, `doctor` also reports a `driver-advisory` finding (code
`runtime-cache-unreclaimable`) for each iOS runtime that was downloaded to
Expand Down
14 changes: 11 additions & 3 deletions docs/CLIENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,24 @@ const client = await connectSimlock({
principal: "agent-1",
});

const grant = await client.requestLease({ platform: "ios", model: "iPhone 17 Pro" });
const grant = await client.requestLease({ platform: "ios", model: "iPhone 17 Pro", mode: "slim" });
// grant: { device, lease, timing } — the contract's LeaseGrant, verbatim

await client.releaseLease({ leaseId: grant.lease.id });
await client.close();
```

`requestLease` takes an optional `mode`, `"slim"` or `"full"`: the device
mode the lease asks for. Without it the lease gets the default mode of the
worker that serves it (`ios.defaultMode`, `full` unless configured). Any
other value, or a field `requestLease` does not know, is a `BAD_REQUEST`.

`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,
`"slim"` when its driver reduced its feature set, `"full"` otherwise. `full`
is a guarantee and `slim` is best effort: a `"slim"` request on a runtime
that cannot be slimmed (an iOS runtime older than 18.5, or any Android
device) is granted `"full"`, and a `"full"` request is never granted
`"slim"`. 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`.
Expand Down
78 changes: 57 additions & 21 deletions docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ a warning. Inspect the effective, merged configuration at any time with
| `drivers.ios.deviceRoot` | The CoreSimulator device set Simlock owns and scopes every `simctl` call to. See [Device roots](#device-roots). | `${SIMLOCK_HOME}/devices/ios` |
| `drivers.android.deviceRoot` | The AVD home Simlock owns; exported as `ANDROID_AVD_HOME` to every `avdmanager`/`emulator` call. See [Device roots](#device-roots). | `${SIMLOCK_HOME}/devices/android` |
| `drivers.android.adbServerPort` | TCP port for Simlock's own adb server. Must not be the shared server's `5037`. Startup fails closed if it is occupied. | `5038` |
| `ios.slim.enabled` | Master switch for slim mode: disables iOS simulator daemon categories to cut RAM and CPU overhead per device. | `false` |
| `ios.slim.categories` | Which daemon categories to disable when slim mode is on. Omitted means every category the driver knows. | every known category |
| `ios.slim.bootTimeoutMs` | Boot deadline used while slim mode is on, in place of the normal boot timeout. | `10 minutes` |
| `ios.defaultMode` | The device mode an iOS lease request gets when it names none: `slim` or `full`. Every worker makes both kinds whatever this says. See [Device mode: slim and full](#device-mode-slim-and-full). | `full` |
| `ios.slim.categories` | Which daemon categories a slim iOS device has disabled. Omitted means every category the driver knows. | every known category |
| `ios.slim.bootTimeoutMs` | Boot deadline for a slim iOS device, in place of the normal boot timeout. | `10 minutes` |
| `android.emulator.headless` | Launch emulators without a window (`-no-window`). Needed on a host with no display, such as a Linux CI runner. See [Android emulator launch options](#android-emulator-launch-options). | `false` |
| `android.emulator.gpu` | The emulator's GPU mode, passed as `-gpu <mode>` (for example `host`, `swiftshader_indirect`, `guest`). `auto` passes nothing and leaves the emulator's own choice. | `auto` |
| `android.emulator.audio` | `false` launches emulators without audio (`-no-audio`). | `true` |
Expand All @@ -77,7 +77,7 @@ integer in `1`-`65535`.
`gateway.label` are strings, and `gateway.disconnectedRetentionMs`,
`gateway.execTimeoutMs`, and `gateway.leaseRequestTimeoutMs` positive
numbers.
`ios.slim.enabled` is a boolean, `ios.slim.categories` an array of
`ios.defaultMode` is `slim` or `full`, `ios.slim.categories` an array of
non-empty strings, and `ios.slim.bootTimeoutMs` a positive number.
`android.emulator.headless`, `android.emulator.audio`, and
`android.emulator.bootAnimation` are booleans, and `android.emulator.gpu` a
Expand Down Expand Up @@ -230,7 +230,7 @@ the mismatch changes on a later refresh) — loud enough to catch the
misconfiguration without silently overriding it.

Everything else — `capacity.*`, `idle.*`, `warmPool.*`, `health.*`,
`stalledTransition.*`, `drivers.*`, `ios.slim.*`, `android.emulator.*`, `diskPressure.*`,
`stalledTransition.*`, `drivers.*`, `ios.*`, `android.emulator.*`, `diskPressure.*`,
`downloads.*`, and the worker-side `gateway.url`/`gateway.token`/
`gateway.label`/`exec.timeoutMs` — is **ignored with a warning**, exactly as
an unknown key is. That is deliberately the softer treatment: a gateway's
Expand Down Expand Up @@ -360,22 +360,58 @@ Running two Simlock instances on one machine now needs distinct
`drivers.android.adbServerPort` values as well as distinct `SIMLOCK_HOME`
values.

Slim mode is opt-in and iOS-only: it disables simulator daemon categories
that most agent workloads never touch, trading some simulator functionality
for a leaner runtime footprint. The categories are widgets, Siri/Apple
Intelligence, Spotlight/search, iCloud, App Store, mail/calendar (PIM),
Safari/web, Family Sharing, Health, Photos, bundled apps (News/Weather/Maps/
Tips/games), messaging, connectivity, telemetry, and a miscellaneous group
(`widgets`, `siri`, `search`, `icloud`, `store`, `pim`, `web`, `family`,
`health`, `photos`, `apps`, `messaging`, `connectivity`, `telemetry`,
`other` -- the valid `ios.slim.categories` strings, defined in
`src/drivers/ios/slim-labels.ts`). Measured on one simulator: ~258 -> ~70
processes, ~4.0 GB -> ~0.9 GB. It requires iOS 18.5 or newer, since the
underlying daemon controls are not available on older runtimes. Turning it
on costs an extra boot per device -- the daemons are disabled between a
first boot and a second, slower one -- which is why
`ios.slim.bootTimeoutMs` defaults higher than the normal boot timeout,
especially on slower CI runners.
## Device mode: slim and full

A lease request can ask for a `slim` or a `full` device (`simlock lease
--mode`, `mode` on MCP, HTTP, and the client). A request that names no mode
gets the default of the worker that serves it, set by `ios.defaultMode`
(default `full`). Every worker makes both kinds of device whatever its
default is, and keeps them apart: a request only ever reuses an idle device
of the mode it resolved to.

```json
{
"ios": {
"defaultMode": "slim",
"slim": { "categories": ["widgets", "siri", "telemetry"] }
}
}
```

A slim iOS device has simulator daemon categories disabled that most agent
workloads never touch, trading some simulator functionality for a leaner
runtime footprint. The categories are widgets, Siri/Apple Intelligence,
Spotlight/search, iCloud, App Store, mail/calendar (PIM), Safari/web, Family
Sharing, Health, Photos, bundled apps (News/Weather/Maps/Tips/games),
messaging, connectivity, telemetry, and a miscellaneous group (`widgets`,
`siri`, `search`, `icloud`, `store`, `pim`, `web`, `family`, `health`,
`photos`, `apps`, `messaging`, `connectivity`, `telemetry`, `other` -- the
valid `ios.slim.categories` strings). Measured on one simulator: ~258 -> ~70
processes, ~4.0 GB -> ~0.9 GB. A slim device costs an extra boot -- the
daemons are disabled between a first boot and a second, slower one -- which
is why `ios.slim.bootTimeoutMs` defaults higher than the normal boot timeout,
especially on slower CI runners. The `ios.slim.*` keys apply to every slim
device the worker makes, whatever its default mode.

**`full` is a guarantee; `slim` is best effort.** A `full` request never
receives a slim device. A `slim` request on a runtime that cannot be slimmed
-- an iOS runtime older than 18.5, or any Android device -- is granted a full
device rather than failing. The lease reports the mode the device actually
has as `mode`, so check it when it matters.

On a worker whose default mode is `slim`, `simlock doctor` reports the
installed iOS runtimes that cannot be slimmed.

**Upgrading a worker that had slim switched on.** The old on/off switch under
`ios.slim` is gone; a config that still sets it gets the usual unknown-key
warning and the default mode `full`. Set `ios.defaultMode: "slim"` to keep slim as the
default. Devices made before the upgrade load as full, including ones that
were slimmed, so such a worker could hand a slimmed device to a `full`
request. Empty it before upgrading:

```bash
simlock nuke --delete-devices
```

## Android emulator launch options

Expand Down
Loading
Loading