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
23 changes: 19 additions & 4 deletions docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,8 @@ why its Android catalog looks thin, trimmed to one worker:
"defaultRuntime": "26.0",
"modelRuntimes": {"iPhone 16": ["18.4"]},
"modelAliases": {},
"modelClasses": {"iPhone 16": "phone"}
"modelClasses": {"iPhone 16": "phone"},
"classDefaults": {"phone": "iPhone 16"}
},
{
"platform": "android",
Expand All @@ -923,6 +924,7 @@ why its Android catalog looks thin, trimmed to one worker:
"modelRuntimes": {},
"modelAliases": {},
"modelClasses": {},
"classDefaults": {},
"images": [{"runtime": "18.0", "tag": "google_apis", "abi": "arm64-v8a"}]
}
],
Expand Down Expand Up @@ -1254,6 +1256,16 @@ is `desktop`, and a profile with no tag, or a custom profile from
`devices.xml`, is `phone`. A model whose tooling reports nothing usable has
no entry, and is still listed and leasable by name.

`classDefaults` says, for a class, which model Simlock would create for it on
this machine: the first name on the class's preference list that the catalog
lists, that is a model of the class, and that pairs with an installed runtime
(or the first of those that are listed and of the class, when none pairs).
The list is the names in `ios.defaultModels.<class>` or
`android.defaultModels.<class>`, then Simlock's own list for the platform;
see [`docs/CONFIGURATION.md`](CONFIGURATION.md#default-models-per-class). A class
in which no listed name counts has no entry. The human-oriented output shows
it beside the class, as `none` when there is none.

`customModels` lists the models that exist because of something on that
machine rather than the platform's tools. The field is absent when there are
none, and iOS never has it. See [Where Android models come
Expand All @@ -1269,14 +1281,14 @@ downloads a runtime or system image, and lists only what is installed,
whatever `downloads.policy` says.

Human-oriented by default, models grouped under a line for their class (in
the order above, then `(no class)`), one line per model with the runtimes it
the order above, then `(no class)`) that shows the class's default model, one line per model with the runtimes it
pairs with, its other names on the line below it, and then each image:

```text
Platform: android
Runtimes: 34, 35 (default: 35)
Models:
phone:
phone (default: Pixel 8):
My Tablet (custom): 34, 35
Pixel 8: 34, 35
Other names: pixel_8
Expand All @@ -1292,14 +1304,17 @@ Platform: android
"modelRuntimes":{"My Tablet":["34","35"],"Pixel 8":["34","35"]},
"modelAliases":{"Pixel 8":["pixel_8"]},
"modelClasses":{"My Tablet":"phone","Pixel 8":"phone"},
"classDefaults":{"phone":"Pixel 8"},
"customModels":["My Tablet"],
"images":[{"runtime":"34","tag":"default","abi":"x86_64"},{"runtime":"35","tag":"google_apis","abi":"arm64-v8a"}]}]}
```

Against a gateway, `modelAliases` is the union of each worker's other names
for a model, `modelClasses` the union of their classes (when two workers
class a model differently, the worker with the smallest id wins), and `images`
the union of their images. A model is in
the union of their images. A class's entry in `classDefaults` is kept only
when every connected worker reports the same model for it; a worker with none
for that class counts as disagreeing. A model is in
`customModels` when any worker that lists it marks it custom;
`simlock worker list --json` shows which worker that is. A gateway accepts any
name a worker lists for a model, in any letter case, and sends that worker its
Expand Down
11 changes: 9 additions & 2 deletions docs/CLIENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ const { platforms } = await client.getCatalog({ platform: "ios" });
// defaultRuntime: "26.0",
// modelRuntimes: { "iPhone 16": ["18.4", "26.0"], "iPhone XS": ["18.4"] },
// modelAliases: {},
// modelClasses: { "iPhone 16": "phone", "iPhone XS": "phone" } }]
// modelClasses: { "iPhone 16": "phone", "iPhone XS": "phone" },
// classDefaults: { phone: "iPhone 16" } }]
```

- `models` and `runtimes` are what is installed. A model and a runtime that
Expand All @@ -259,6 +260,11 @@ const { platforms } = await client.getCatalog({ platform: "ios" });
- `modelClasses` maps a model to its class, one of `"phone"`, `"tablet"`,
`"watch"`, `"tv"`, `"vision"`, `"auto"` or `"desktop"`, when its tooling
reports one. A model with no entry is still listed and leasable by name.
- `classDefaults` maps a class to the model Simlock would create for it on
this machine: the first name on the class's preference list that is listed,
is of the class and pairs with an installed runtime. The list is the names
in `ios.defaultModels.<class>` or `android.defaultModels.<class>`, then
Simlock's own. A class in which no listed name counts has no entry.
- `images` is on Android entries only: every installed system image as
`{ runtime, tag, abi }`, where `runtime` is a value from `runtimes`. An
image whose ABI the host cannot run natively is listed too.
Expand All @@ -280,7 +286,8 @@ model is paired with a runtime when at least one worker pairs them, and
runtime. The gateway sends a request only to a worker that pairs the model
with the runtime. `modelAliases` and `images` are the unions of each
worker's own, and so is `modelClasses`: when two workers class a model
differently, the worker with the smallest id wins. A model is in `customModels` when any worker that lists it
differently, the worker with the smallest id wins. A class has a `classDefaults`
entry only when every connected worker reports the same model for it. A model is in `customModels` when any worker that lists it
marks it custom; each worker's own list is in its catalog on
`listWorkers()` from the admin client. A model may be asked for by any name a worker lists for it, in
any letter case, and the gateway sends that worker its own name for it.
Expand Down
44 changes: 44 additions & 0 deletions docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ edit yourself keeps the mode you give it until the next `config set`; run
| `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` |
| `ios.defaultModels.<class>` | The iOS models to prefer for a device class (`phone`, `tablet`, `watch`, `tv`, `vision`, `auto` or `desktop`): one model name or a list of them, most preferred first. Tried before Simlock's own list. See [Default models per class](#default-models-per-class). | unset (Simlock's own list only) |
| `android.defaultModels.<class>` | The same for Android models. | unset (Simlock's own list only) |
| `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 Down Expand Up @@ -457,6 +459,48 @@ request. Empty it before upgrading:
simlock nuke --delete-devices
```

## Default models per class

For each device class (`phone`, `tablet`, `watch`, `tv`, `vision`, `auto`,
`desktop`) Simlock keeps a preference list of model names, and the default
model for the class on this machine is the first name on it that qualifies.
`simlock catalog` shows the result beside each class, as `classDefaults` in
its JSON. A name qualifies when this machine's catalog lists it (by its name
or another name it answers to, in any letter case), when the catalog says it
is a model of that class, and when it pairs with at least one installed
runtime. When no listed name of the class pairs with a runtime, the first
listed one is shown anyway. A class in which no name qualifies has no default,
and the catalog shows `none`.

The list is the names you set, then Simlock's own list for the platform:

| Class | iOS, newest first | Android, newest first |
| --------- | ----------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
| `phone` | iPhone 17, iPhone 16, iPhone 15, iPhone 14, iPhone 13 | Pixel 9, Pixel 8, Pixel 7, Pixel 6, Medium Phone |
| `tablet` | iPad Pro 11-inch (M5), iPad Pro 11-inch (M4), iPad Air 11-inch (M3), iPad (A16), iPad (10th generation) | none |
| `watch` | Apple Watch Series 11 (46mm), Apple Watch Series 10 (46mm), Apple Watch Series 9 (45mm) | Wear OS Large Round, Wear OS Small Round |
| `tv` | Apple TV 4K (3rd generation), Apple TV | Television (1080p), Television (4K) |
| `vision` | Apple Vision Pro | none |
| `auto` | none | Automotive (1080p landscape), Automotive (1024p landscape) |
| `desktop` | none | Medium Desktop, Large Desktop |

Set `ios.defaultModels.<class>` or `android.defaultModels.<class>` to one
model name, or to a non-empty list of them:

```json
{
"ios": { "defaultModels": { "phone": "iPhone 15", "tablet": ["iPad (A16)", "iPad (10th generation)"] } },
"android": { "defaultModels": { "phone": "Pixel 7" } }
}
```

An empty string, an empty list, a list with an empty string, and a key that is
not a class are refused when the config loads. A name that is not a model of
that class on this machine is skipped, not an error: with `ios.defaultModels.phone`
set to an iPad, the `phone` default is the first of Simlock's own names that
qualifies. Which class a model belongs to is what the platform's tools report;
see `modelClasses` in [`simlock catalog`](CLI.md#simlock-catalog---platform-iosandroid---json).

## Android emulator launch options

`android.emulator` sets how this machine's Android emulators are launched.
Expand Down
18 changes: 16 additions & 2 deletions docs/HTTP-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,16 @@ entry, and is still listed and leasable by name. On a gateway it is the union
over the connected workers; when two workers class a model differently, the
worker with the smallest id wins.

Each entry also carries `classDefaults`: for a class, the model Simlock would
create for it on that machine. It is the first name on the class's preference
list (the names in `ios.defaultModels.<class>` or `android.defaultModels.<class>`,
then Simlock's own list for the platform) that `models` lists, that is a model
of the class, and that pairs with an installed runtime; when none pairs, the
first of those that are listed and of the class. A class in which no listed
name counts has no entry. On a gateway a class's entry is kept only when every
connected worker reports the same model for it, and a worker with none for that
class counts as disagreeing.

An entry may also carry `customModels`: the names from `models` that exist
because of something on that machine rather than the platform's tools. On
Android that is a profile made with Android Studio's device manager, read
Expand All @@ -302,7 +312,8 @@ that lists it marks it custom; each worker's own list is in its catalog in
"defaultRuntime": "26.0",
"modelRuntimes": { "iPhone 16": ["18.4", "26.0"], "iPhone XS": ["18.4"] },
"modelAliases": {},
"modelClasses": { "iPhone 16": "phone", "iPhone XS": "phone" }
"modelClasses": { "iPhone 16": "phone", "iPhone XS": "phone" },
"classDefaults": { "phone": "iPhone 16" }
}, {
"platform": "android",
"models": ["My Tablet", "Pixel 8"],
Expand All @@ -311,6 +322,7 @@ that lists it marks it custom; each worker's own list is in its catalog in
"modelRuntimes": { "My Tablet": ["34", "35"], "Pixel 8": ["34", "35"] },
"modelAliases": { "Pixel 8": ["pixel_8"] },
"modelClasses": { "My Tablet": "phone", "Pixel 8": "phone" },
"classDefaults": { "phone": "Pixel 8" },
"customModels": ["My Tablet"],
"images": [ { "runtime": "34", "tag": "default", "abi": "x86_64" },
{ "runtime": "35", "tag": "google_apis", "abi": "arm64-v8a" } ]
Expand Down Expand Up @@ -1063,7 +1075,8 @@ simulated (hence the thin Android catalog), trimmed to one worker:
"defaultRuntime": "26.0",
"modelRuntimes": {"iPhone 16": ["18.4"]},
"modelAliases": {},
"modelClasses": {"iPhone 16": "phone"}
"modelClasses": {"iPhone 16": "phone"},
"classDefaults": {"phone": "iPhone 16"}
},
{
"platform": "android",
Expand All @@ -1073,6 +1086,7 @@ simulated (hence the thin Android catalog), trimmed to one worker:
"modelRuntimes": {},
"modelAliases": {},
"modelClasses": {},
"classDefaults": {},
"images": [{"runtime": "18.0", "tag": "google_apis", "abi": "arm64-v8a"}]
}
],
Expand Down
12 changes: 8 additions & 4 deletions docs/internal/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,9 @@ relays that operation to workers, so a worker without it must be
`incompatible` rather than fail in the middle of a relay. ADR 0014 gives every
event envelope an `id`, taking it to 10, and ADR 0009 makes `atRamBudget` a
required capacity field, taking it to 11, and ADR 0015 §3 makes
`modelClasses` a required catalog field, taking it to 12. So the range both
sides advertise is `{min: 12, max: 12}`, an older client and a current daemon simply
`modelClasses` a required catalog field, taking it to 12, and ADR 0015 §4 makes
`classDefaults` one too, taking it to 13. So the range both
sides advertise is `{min: 13, max: 13}`, 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 this shows up in a gateway's views as `incompatible`
Expand Down Expand Up @@ -832,7 +833,9 @@ of fleet models and fleet runtimes: one worker with the model and another
with the runtime is not a leasable pair. `modelAliases` is the union per
model, deduplicated ignoring case, `modelClasses` the union over workers
(ADR 0015 §3: when two class a model differently, the first worker in id
order wins), and `images` the union by runtime, tag, and ABI, absent when no
order wins), `classDefaults` a class's model only when every connected worker
reports the same one for it (a worker with none counts as disagreeing, ADR 0015 §4),
and `images` the union by runtime, tag, and ABI, absent when no
worker reports the field. `customModels` lists a
model when any worker that lists it marks it custom; a name a worker marks
but does not list is dropped. Each worker's lists are
Expand Down Expand Up @@ -907,7 +910,8 @@ emits its own facts — `worker.connected`, `worker.disconnected`,
`{min: 9, max: 9}`, because the gateway is to relay `component.install` to workers, and
ADR 0014 to `{min: 10, max: 10}`, because every event envelope has an `id`, and
ADR 0009 to `{min: 11, max: 11}`, because `atRamBudget` is required, and
ADR 0015 to `{min: 12, max: 12}`, because the catalog's `modelClasses` is required; a
ADR 0015 to `{min: 12, max: 12}`, because the catalog's `modelClasses` is required, then
to `{min: 13, max: 13}`, because its `classDefaults` is; 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
Expand Down
18 changes: 17 additions & 1 deletion e2e/fake-driver/fake-driver.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { readFileSync } from "node:fs";
import { appendFile, mkdir, readFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { dirname } from "node:path";
Expand Down Expand Up @@ -27,7 +28,7 @@ import {
PassthroughRefusedError,
removeListedComponent,
} from "../../dist/core/driver.js";
import type { DeviceSpec, Platform } from "../../dist/core/domain.js";
import type { DeviceClass, DeviceSpec, Platform } from "../../dist/core/domain.js";
import type {
FakeDriverErrorSpec,
FakeDriverOperation,
Expand Down Expand Up @@ -217,6 +218,21 @@ export class OutOfProcessFakeDriver implements Driver {
this.#scriptPath = options.scriptPath;
}

/**
* The script's `defaultModels`, `{}` when unset. Read from the file on each access, as every
* operation re-reads it, but synchronously: the port reads this as a property, once at start.
*/
get defaultModels(): Readonly<Partial<Record<DeviceClass, readonly string[]>>> {
if (this.#scriptPath === undefined) return {};
try {
const parsed = JSON.parse(readFileSync(this.#scriptPath, "utf8")) as FakeDriverScript;
return parsed[this.platform]?.defaultModels ?? {};
} catch {
// The same fallback as `readPlatformScript`: a missing or half-written file reads as unset.
return {};
}
}

/**
* Logged like every other call, so a flow can assert the purge re-proved the root before
* it destroyed anything -- and refusable through `failures.revalidateRoot`, which is how
Expand Down
2 changes: 2 additions & 0 deletions e2e/fake-driver/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ export interface FakeDriverPlatformScript {
readonly modelRuntimes?: Readonly<Record<string, readonly string[]>>;
/** What `listCatalog` reports as other names per model; none unless set. */
readonly modelAliases?: Readonly<Record<string, readonly string[]>>;
/** The built-in preference lists the driver carries, per class; none unless set. */
readonly defaultModels?: Readonly<Partial<Record<DeviceClass, readonly string[]>>>;
/** What `listCatalog` reports as each model's class; empty unless set. */
readonly modelClasses?: Readonly<Record<string, DeviceClass>>;
/** What `listCatalog` reports as custom models; the field is absent unless set. */
Expand Down
Loading
Loading