Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
49182f6
test: the warm pool creates one device per waiter behind the head und…
V3RON Oct 20, 2026
7a15acf
feat(warm-pool): the pool creates a device for each waiter behind the…
V3RON Oct 20, 2026
b951895
test: the pool matches each device to one waiter in queue order (#774)
V3RON Oct 20, 2026
f4020b7
feat(warm-pool): each ready or on-its-way device serves one waiter (#…
V3RON Oct 20, 2026
4d3096a
test: the pool boots a shut-down device for a waiter behind the head …
V3RON Oct 20, 2026
6e05507
test: the pool proposes no boot that the capacity strategy refuses (#…
V3RON Oct 20, 2026
6722e90
test: the pool proposes no boot that the capacity strategy refuses (#…
V3RON Oct 20, 2026
2f84622
feat(warm-pool): a boot the capacity strategy refuses is not proposed…
V3RON Oct 20, 2026
a0d27ca
test: the pool fills a target after the queue's devices within one ca…
V3RON Oct 20, 2026
39ddaab
feat(warm-pool): a target fills after the queue's devices and waits o…
V3RON Oct 20, 2026
af7618e
test: a waiting-request creation runs under a boot claim and a throw …
V3RON Oct 20, 2026
9f767ab
feat(warm-pool): a spec held back after a failed creation is not crea…
V3RON Oct 20, 2026
0032660
test: the pool runs waiting-request boots beside the pass under the b…
V3RON Oct 20, 2026
8b3b7dd
feat(warm-pool): waiting-request boots run beside the pass and count …
V3RON Oct 20, 2026
7d7e9fe
test: the pool tells the policy which devices and creations are on th…
V3RON Oct 20, 2026
3fd9ca7
feat(warm-pool): the pool reports devices and creations on their way …
V3RON Oct 20, 2026
3531a45
test: the pool runs a pass when a request is queued (#774)
V3RON Oct 20, 2026
c425a77
feat(warm-pool): a queued request triggers a pass (#774)
V3RON Oct 20, 2026
1e96f12
test: warmPool.maxConcurrentBoots defaults from the CPU count (#774)
V3RON Oct 20, 2026
24f8943
feat(config): warmPool.maxConcurrentBoots defaults from the CPU count…
V3RON Oct 20, 2026
8f923f0
test: a request behind an in-flight head is granted the device the po…
V3RON Oct 20, 2026
13bdf2c
test: requests behind an in-flight head are each granted the device t…
V3RON Oct 20, 2026
17e64a1
fix(leasing): a request granted a ready device wakes the next one in …
V3RON Oct 20, 2026
2d65893
fix(warm-pool): the pool leaves the waiter the queue reaches at once …
V3RON Oct 20, 2026
9785494
docs(warm-pool): the pool serves the whole queue; the boot cap defaul…
V3RON Oct 20, 2026
628c4e7
test: the stop test pins the boot cap it relies on (#774)
V3RON Oct 20, 2026
062dbe1
refactor(warm-pool): split the queue pass into steps (#774)
V3RON Oct 20, 2026
c3bdc24
refactor(warm-pool): split the queue pass further (#774)
V3RON Oct 20, 2026
ab4a788
test: audit probes pin the in-flight waiter count, an owned claim, a …
V3RON Oct 20, 2026
f3ec4a9
fix(warm-pool): a waiter's boot respects the retry schedule (#774)
V3RON Oct 20, 2026
3aca357
fix(warm-pool): a waiter's boot is held back under the device's spec …
V3RON Oct 20, 2026
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
9 changes: 6 additions & 3 deletions docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,11 @@ A lease names its device in one of three ways:

A class lease is served by the first of these that applies: an idle device
that is already running and fits, then (unless `--no-wait`) a device the warm
pool is already booting that fits, which it waits for, then an idle device that
is shut down and fits (it is booted), then a new device. A device fits when its platform,
pool is already booting or creating that fits, which it waits for, then an idle device that
is shut down and fits (it is booted), then a new device. A request queued behind
another is not left idle meanwhile: the warm pool boots a shut-down device that fits it or
creates a new one for it, within `warmPool.maxConcurrentBoots`, and the request is granted that
device once it is ready and the request is next in line. A device fits when its platform,
class, OS, mode and image tag all satisfy the request: with no `--os` a class
lease fits a device on any installed runtime, with `--os` a device whose OS
satisfies it, `--mode full` and `--image-tag`
Expand Down Expand Up @@ -1520,7 +1523,7 @@ warm pool: enabled, reserve ios 1 android 0
`no-driver`, `runtime-missing`, `unknown-model`, `unresolvable`, `boot-failed`,
`device-limit`, `running-limit`, `reserve` or `ram-budget`; when several apply,
the first of that list is shown. A target that is filling, held back by
`warmPool.maxConcurrentBoots` or waiting behind a queued request is not short.
`warmPool.maxConcurrentBoots` or waiting behind a queued request the pool could not serve is not short.
In `--json` the block is `warmPool`: `enabled`, `reserveRunning` (`ios`,
`android`) and `targets`, each with `platform`, `model`, `osVersion` (the one
the target resolved to, or the one it names when it did not resolve; absent
Expand Down
4 changes: 2 additions & 2 deletions docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ edit yourself keeps the mode you give it until the next `config set`; run
| `idle.deleteAfterMs` | How long a shut-down device sits idle before Simlock deletes it (tier 2, reclaims disk). Idle counts from the end of the device's last lease, or, for a device that never served one (one the pool created for a `warmPool.targets` entry that was later lowered or removed, say), from when it was shut down. | `1 hour` |
| `warmPool.enabled` | Whether released devices are kept warm. `true` keeps a released device running or boots it back when the running limit has room, and shuts down the least recently used idle devices when the machine is over its running limit. `false` keeps nothing warm: every idle running device is shut down. | `true` |
| `warmPool.reserveRunning.ios` / `warmPool.reserveRunning.android` | Running slots per platform that idle warm devices may not fill, so a request for a model nobody predicted boots at once instead of shutting a warm device down first. With a running limit of 3 for the platform and a reserve of 1, at most 2 idle devices stay warm. The global running limit loses the sum of the two reserves, each counted at most up to its platform's running limit. A non-negative integer; a reserve at or above the platform's running limit keeps no device of that platform warm. | `0` |
| `warmPool.targets` | Kinds of device Simlock keeps booted, clean and unleased ahead of demand. Each entry is written like a lease request: `platform` (`ios` or `android`), `model` (the exact model name), optionally `osVersion` (a version or an OS range such as `">=18"`) and `mode` (`slim` or `full`), and a `count`. Every pass Simlock resolves each entry the way a lease request is resolved, so the newest installed runtime in range is used and the platform's default mode applies when `mode` is left out, then boots a shut-down device of that kind or creates one until `count` are ready. The first lease for that kind is granted without a boot, including under `lease.identity` `fresh`, where every lease then costs one new device. A target never shuts a device down to make room and never downloads a runtime: one whose runtime or model is not available stays short and is logged. `simlock status` shows each kind of device the targets name (entries that resolve to the same device are one line; an entry that could not be resolved, and every entry while the pool is off or before its first pass, is a line of its own) with how many are ready and booting and, when the last pass could do nothing for it, why it is short (`runtime-missing`, `unknown-model`, `running-limit`, `reserve`, `ram-budget` and the others listed under [`simlock status`](CLI.md#simlock-status)), and with `warmPool.enabled` `false` shows every target as `disabled`; a target that is filling or waiting behind a queued request is not short. `simlock doctor` reports a target whose runtime or model does not exist, and targets whose counts add up to more than the running limit leaves after the reserve. A device that fails to boot is tried again after 1, 2, 4 and so on minutes, at most 10 apart. Unknown keys, a `count` below 1, an unknown platform, more than 256 entries and a `model` or `osVersion` longer than 256 characters fail the load, naming the key. Changes take effect on daemon restart; with `warmPool.enabled` `false` no target is kept. | `[]` |
| `warmPool.maxConcurrentBoots` | The most target devices booted or created at once. A positive integer. | `1` |
| `warmPool.targets` | Kinds of device Simlock keeps booted, clean and unleased ahead of demand. Each entry is written like a lease request: `platform` (`ios` or `android`), `model` (the exact model name), optionally `osVersion` (a version or an OS range such as `">=18"`) and `mode` (`slim` or `full`), and a `count`. Every pass Simlock resolves each entry the way a lease request is resolved, so the newest installed runtime in range is used and the platform's default mode applies when `mode` is left out, then boots a shut-down device of that kind or creates one until `count` are ready. The first lease for that kind is granted without a boot, including under `lease.identity` `fresh`, where every lease then costs one new device. A target never shuts a device down to make room and never downloads a runtime: one whose runtime or model is not available stays short and is logged. `simlock status` shows each kind of device the targets name (entries that resolve to the same device are one line; an entry that could not be resolved, and every entry while the pool is off or before its first pass, is a line of its own) with how many are ready and booting and, when the last pass could do nothing for it, why it is short (`runtime-missing`, `unknown-model`, `running-limit`, `reserve`, `ram-budget` and the others listed under [`simlock status`](CLI.md#simlock-status)), and with `warmPool.enabled` `false` shows every target as `disabled`; a target that is filling or waiting behind a queued request the pool could not serve is not short. `simlock doctor` reports a target whose runtime or model does not exist, and targets whose counts add up to more than the running limit leaves after the reserve. A device that fails to boot is tried again after 1, 2, 4 and so on minutes, at most 10 apart. Unknown keys, a `count` below 1, an unknown platform, more than 256 entries and a `model` or `osVersion` longer than 256 characters fail the load, naming the key. Changes take effect on daemon restart; with `warmPool.enabled` `false` no target is kept. | `[]` |
| `warmPool.maxConcurrentBoots` | The most boots and creations in flight at once. The warm pool starts a boot, or a creation for a request behind the head, for every queued request no ready device serves, oldest first (the head's creation and requests a ready device serves are the lease's own), and then for the targets, up to this many together with the boots and creations queued requests are running themselves. A positive integer. | `max(1, floor(cpuCount / 4))` over the host's CPUs, so `3` on a 12-CPU Mac |
| `warmPool.quarantine.maxRetries` | Failed purge retries allowed on a quarantined device (after the triggering failure) before Simlock gives up and destroys it. A device created under `lease.identity` `fresh` retries its delete instead of a purge. A physical device is never destroyed: its retries are uninstall retries, and when they run out it is unenrolled. | `3` |
| `warmPool.quarantine.retryBackoffMs` | Delay before the first quarantine purge retry. | `30 seconds` |
| `warmPool.quarantine.retryBackoffMultiplier` | Growth factor applied to the backoff after each failed retry. | `2` |
Expand Down
2 changes: 1 addition & 1 deletion docs/EVENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ the gateway's own lease index before any worker is ever contacted. `lease-id-tak
|---|---|---|---|---|
| `capacity.changed` | per platform (`ios`, `android`) and `global`: running, max running, reserved, warm; `ramBudget` (used bytes, limit bytes) only under the `resource` capacity strategy | a worker's capacity figures differ from the last ones emitted: after a registry commit, or after a provisioning or boot reservation is taken or released. Emitted once when the daemon has started, so every run begins with a step; two consecutive events never carry equal figures. The figures are the ones `simlock status` reports | CapacityObserver (worker) | implemented |
| `queue.changed` | depth, `physical: true` when the change is to the physical line | the number of requests waiting in a queue changed: a request joined it or left it. A queue has two lines, simulator and emulator requests and physical requests: `depth` counts the line that changed, and `physical` says which. Emitted once when the daemon has started. A worker emits it for its own queue and a gateway for its fleet queue; a worker's events a gateway relays carry `workerId`, and the gateway's own do not | WaitQueue (worker) / FleetLeaseCoordinator (gateway) | implemented |
| `warm-pool.target-missed` | platform, model, OS version (the one the target resolved to, or the one it names when it did not resolve; absent when it names none and did not resolve), mode, count, ready, reason (the one reason `simlock status` shows as the target's `short`: `no-driver`, `runtime-missing`, `unknown-model`, `unresolvable`, `boot-failed`, `device-limit`, `running-limit`, `reserve` or `ram-budget`) | a warm pool target went short: after a pass the pool could do nothing for a target that has fewer ready devices than its count, and it was not already missed. Once on that edge for each kind of device the targets name (targets that resolve to the same device emit one event between them, with their counts added), not on each short pass after, nor when a retry or a boot fills it and it is short again; only a target whose ready devices reach its count and that is then missed again emits again. A target that is filling, held by `warmPool.maxConcurrentBoots` or waiting behind a queued request is not short | WarmPool (worker) | implemented |
| `warm-pool.target-missed` | platform, model, OS version (the one the target resolved to, or the one it names when it did not resolve; absent when it names none and did not resolve), mode, count, ready, reason (the one reason `simlock status` shows as the target's `short`: `no-driver`, `runtime-missing`, `unknown-model`, `unresolvable`, `boot-failed`, `device-limit`, `running-limit`, `reserve` or `ram-budget`) | a warm pool target went short: after a pass the pool could do nothing for a target that has fewer ready devices than its count, and it was not already missed. Once on that edge for each kind of device the targets name (targets that resolve to the same device emit one event between them, with their counts added), not on each short pass after, nor when a retry or a boot fills it and it is short again; only a target whose ready devices reach its count and that is then missed again emits again. A target that is filling, held by `warmPool.maxConcurrentBoots` or waiting behind a queued request the pool could not serve is not short | WarmPool (worker) | implemented |

## Device lifecycle

Expand Down
2 changes: 1 addition & 1 deletion docs/internal/EVENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ worker is ever contacted. `lease-id-taken` (ADR 0020; widens a published vocabul
|---|---|---|---|---|
| `capacity.changed` | per platform (`ios`, `android`) and `global`: running, max running, reserved, warm; `ramBudget` (used bytes, limit bytes) only under the `resource` capacity strategy | a worker's capacity figures differ from the last ones emitted: after a registry commit, or after a provisioning or boot reservation is taken or released. Emitted once when the daemon has started, so every run begins with a step; two consecutive events never carry equal figures. The figures are the ones `simlock status` reports | CapacityObserver (worker) | implemented |
| `queue.changed` | depth, `physical: true` when the physical line changed (ADR 0022 §3, additive, events rule 6) | the number of requests waiting in a queue changed: a request joined it or left it. A queue has two lines; `depth` is the changed line's, and the event without `physical` is the virtual line's. Emitted once when the daemon has started. A worker emits it for its own queue and a gateway for its fleet queue; a worker's events a gateway relays carry `workerId`, and the gateway's own do not | WaitQueue (worker) / FleetLeaseCoordinator (gateway) | implemented |
| `warm-pool.target-missed` | `{ platform, model, osVersion?, mode, count, ready, reason }` — `osVersion` is the resolved one, or the configured one for a target that did not resolve, and absent when it names none and did not resolve; `reason` is the one reason the pool records for the target (`warm-pool/policy.ts` for one that resolved, `warm-pool/converger.ts` for one the resolver refused), the one `short` carries in `status.get` (the one reason `simlock status` shows as the target's `short`, but never `disabled`, since a pool that is off reports no target: `no-driver`, `runtime-missing`, `unknown-model`, `unresolvable`, `boot-failed`, `device-limit`, `running-limit`, `reserve` or `ram-budget`) | a warm pool target went short: after a pass the pool could do nothing for a target that has fewer ready devices than its count, and it was not already missed (ADR 0017 §7). Emitted once the pass's actions have run (events rule 3), once per report on that edge (targets that resolve to one spec are one report and emit one event between them, with their counts added; each target the resolver refuses emits its own), not on each short pass after, nor when a retry or a boot fills it and it is short again; the edge is kept per configured target, and only ready devices reaching its count end the miss, so a target met in between and missed again emits again. A target that is filling, held by `warmPool.maxConcurrentBoots` or waiting behind a queued request is not short | WarmPool (worker) | implemented |
| `warm-pool.target-missed` | `{ platform, model, osVersion?, mode, count, ready, reason }` — `osVersion` is the resolved one, or the configured one for a target that did not resolve, and absent when it names none and did not resolve; `reason` is the one reason the pool records for the target (`warm-pool/policy.ts` for one that resolved, `warm-pool/converger.ts` for one the resolver refused), the one `short` carries in `status.get` (the one reason `simlock status` shows as the target's `short`, but never `disabled`, since a pool that is off reports no target: `no-driver`, `runtime-missing`, `unknown-model`, `unresolvable`, `boot-failed`, `device-limit`, `running-limit`, `reserve` or `ram-budget`) | a warm pool target went short: after a pass the pool could do nothing for a target that has fewer ready devices than its count, and it was not already missed (ADR 0017 §7). Emitted once the pass's actions have run (events rule 3), once per report on that edge (targets that resolve to one spec are one report and emit one event between them, with their counts added; each target the resolver refuses emits its own), not on each short pass after, nor when a retry or a boot fills it and it is short again; the edge is kept per configured target, and only ready devices reaching its count end the miss, so a target met in between and missed again emits again. A target that is filling, held by `warmPool.maxConcurrentBoots` or waiting behind a queued request the pool could not serve is not short | WarmPool (worker) | implemented |

## Device lifecycle

Expand Down
2 changes: 1 addition & 1 deletion docs/internal/flows/device-selection.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ same platform, same image tag, model equal or `classOf(model)` equal to the clas
`classOf` reads the catalog entry read during resolution; a device record stores no class.

1. A `ready`, unclaimed device that serves → grant.
2. Unless `noWait`: one the warm pool is booting or creating for nobody → wait.
2. Unless `noWait`: one the warm pool is booting or creating under an ownerless claim (for a target, a released device or a request queued behind) → wait.
3. A `shutdown` device that serves → boot it.
4. Else provision the spec, evict an idle device, wait, or `NO_CAPACITY`.

Expand Down
32 changes: 32 additions & 0 deletions e2e/warm-pool-reserve.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,38 @@
expect(status.json).toMatchObject({ capacity: { ios: { warm: 2 } } });
});

it("five detached leases of one kind queued behind a booting device, with maxConcurrentBoots 3, start three makeReady calls at once, not four, then the fourth once one is ready, and every lease is granted with no device left idle", async () => {
const env = await withDaemon({
configOverrides: {
limits: { maxRunning: 10, ios: { maxDevices: 10, maxRunning: 10 } },
warmPool: { maxConcurrentBoots: 3 },
},
driverScript: { ios: { ...IOS, reclaimResult: "shutdown" } },
});
const warm = await lease(env, "warm");
await env.driverScript.merge({ ios: { latencyMs: { makeReady: 4_000 } } });
expect((await env.cli(["release", warm.lease.id])).code).toBe(0);
await waitFor(async () => (await makeReadyCalls(env)) === 2, {
label: "the warm pool's boot of the released device has started",
});

const grants = ["a1", "a2", "a3", "a4", "a5"].map((agent) =>
lease(env, agent, ["--timeout", "60s"]),
);
await waitFor(async () => (await makeReadyCalls(env)) === 5, {
label: "three more boots are running",
});
await new Promise((resolve) => setTimeout(resolve, 1_500));
expect(await makeReadyCalls(env)).toBe(5);

const granted = await Promise.all(grants);
await untilQuiet(env);

expect(new Set(granted.map((grant) => grant.device.id)).size).toBe(5);
expect(await makeReadyCalls(env)).toBe(6);

Check failure on line 135 in e2e/warm-pool-reserve.test.ts

View workflow job for this annotation

GitHub Actions / E2E (2/3)

[e2e] e2e/warm-pool-reserve.test.ts > warm pool reserve and requests that wait for a booting device > five detached leases of one kind queued behind a booting device, with maxConcurrentBoots 3, start three makeReady calls at once, not four, then the fourth once one is ready, and every lease is granted with no device left idle

AssertionError: expected 7 to be 6 // Object.is equality - Expected + Received - 6 + 7 ❯ e2e/warm-pool-reserve.test.ts:135:39
expect(await deviceStates(env)).toEqual(["leased", "leased", "leased", "leased", "leased"]);
});

describe("while the warm pool boots a released device", () => {
async function releasedAndBooting(env: TestEnv): Promise<Grant> {
const first = await lease(env, "holder");
Expand Down
4 changes: 3 additions & 1 deletion e2e/warm-targets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ async function named(env: TestEnv, ...names: string[]) {
describe("warm pool targets", () => {
it("with a target of two iPhone 17 and no devices, keeps two ready one boot after the other, and grants the first lease without a boot", async () => {
const env = await withDaemon({
configOverrides: { warmPool: { targets: [{ ...IPHONE_17, count: 2 }] } },
configOverrides: {
warmPool: { maxConcurrentBoots: 1, targets: [{ ...IPHONE_17, count: 2 }] },
},
driverScript: { ios: { ...IOS, latencyMs: { makeReady: 300 } } },
});

Expand Down
Loading
Loading