Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
aeb6dfb
test: figures lists learned kinds with origin, tag and short (#777)
V3RON Oct 21, 2026
0324bee
feat(warm-pool): figures lists learned kinds with origin and image ta…
V3RON Oct 21, 2026
af9b42a
test: statusWarmPoolSchema accepts origin, image tag and 320 entries,…
V3RON Oct 21, 2026
3e79ed7
feat(contract): status.get warm pool entries carry origin and image t…
V3RON Oct 21, 2026
9110377
test: simlock status prints the origin word, the tag and a learned li…
V3RON Oct 21, 2026
595ca38
feat(cli): simlock status shows each warm pool entry's origin and tag…
V3RON Oct 21, 2026
5abca70
test: warm-pool.target-missed carries origin configured and no learne…
V3RON Oct 21, 2026
9ac36aa
feat(warm-pool): warm-pool.target-missed names origin configured (#777)
V3RON Oct 21, 2026
8c9f9e8
test: doctor reports warm-pool-target-unreachable for no learned entr…
V3RON Oct 21, 2026
2d60b95
feat(doctor): warm-pool-target-unreachable reads configured entries o…
V3RON Oct 21, 2026
98fbb14
test: the worker page maps origin and the tag onto each warm row and …
V3RON Oct 21, 2026
72e2436
feat(console): the Warm pool table shows each entry's origin and tag …
V3RON Oct 21, 2026
2e39008
docs(warm-pool): describe origin, image tag and the learned pool in s…
V3RON Oct 21, 2026
b6c5f14
refactor(contract): keep WARM_POOL_ENTRIES_MAX private to the schema …
V3RON Oct 21, 2026
2bc8e10
test: the worker page's rows keep the image tag in their key (#777)
V3RON Oct 21, 2026
95bece8
test: no learned kind announces target-missed, with a short learned k…
V3RON Oct 21, 2026
59a65bc
merge: origin/main into task/777 (keep main's test removals) (#777)
V3RON Oct 21, 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
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 the pool could not serve is not short | WarmPool (worker) | implemented |
| `warm-pool.target-missed` | `{ platform, model, osVersion?, mode, origin, count, ready, reason }` — `origin` is always `configured`: the event is for the `warmPool.targets` entries, never for a kind the pool learned, and `count` is the configured count (ADR 0038 §8); `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
1 change: 1 addition & 0 deletions src/bus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ export interface EventMap {
/** Absent for a target that names none and did not resolve. */
readonly osVersion?: string;
readonly mode: "slim" | "full";
readonly origin: "configured";
readonly count: number;
readonly ready: number;
/** why: one reason, not all: the first of the reasons the target is short that applies. */
Expand Down
4 changes: 2 additions & 2 deletions src/cli/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,11 @@ function formatWarmPool(warmPool: NonNullable<StatusGetOutput["warmPool"]>): str
return [
`warm pool: ${enabled ? "enabled" : "disabled"}, reserve ios ${reserveRunning.ios} android ${reserveRunning.android}`,
...targets.map((target) => {
const name = [target.model, target.osVersion, target.mode]
const name = [target.model, target.osVersion, target.mode, target.imageTag]
.filter((part) => part !== undefined)
.join(" / ");
const short = target.short === undefined ? "" : ` short: ${target.short}`;
return ` ${name} wanted ${target.count} ready ${target.ready} booting ${target.booting}${short}`;
return ` ${name} ${target.origin} wanted ${target.count} ready ${target.ready} booting ${target.booting}${short}`;
}),
];
}
Expand Down
25 changes: 20 additions & 5 deletions src/cli/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4112,6 +4112,7 @@ describe("CLI: status renders the fleet a gateway reports (ADR 0005 §20)", () =
count: 2,
mode: "full" as const,
model: "iPhone 17",
origin: "configured" as const,
osVersion: "26.0",
platform: "ios" as const,
ready: 1,
Expand All @@ -4121,17 +4122,29 @@ describe("CLI: status renders the fleet a gateway reports (ADR 0005 §20)", () =
count: 1,
mode: "full" as const,
model: "iPhone 17",
origin: "learned" as const,
osVersion: "27.0",
platform: "ios" as const,
ready: 0,
short: "runtime-missing" as const,
},
{
booting: 0,
count: 1,
imageTag: "google_apis_playstore",
mode: "full" as const,
model: "Pixel 8",
origin: "learned" as const,
osVersion: "35",
platform: "android" as const,
ready: 1,
},
],
};
const statusWith = (block: StatusGetOutput["warmPool"]) =>
fakeClient({ getStatus: () => Promise.resolve({ ...EMPTY_STATUS, warmPool: block }) });

it("simlock status prints whether the pool is on, the reserve, and each target with how many are wanted, ready and booting, and why it is short", async () => {
it("simlock status prints the origin word on every warm pool line, learned lines included, the tag in the name, and a learned line's short:", async () => {
const output = outputCapture();

await runCli(
Expand All @@ -4141,8 +4154,9 @@ describe("CLI: status renders the fleet a gateway reports (ADR 0005 §20)", () =

expect(output.stdout).toContain(
"warm pool: enabled, reserve ios 1 android 0\n" +
" iPhone 17 / 26.0 / full wanted 2 ready 1 booting 1\n" +
" iPhone 17 / 27.0 / full wanted 1 ready 0 booting 0 short: runtime-missing\n",
" iPhone 17 / 26.0 / full configured wanted 2 ready 1 booting 1\n" +
" iPhone 17 / 27.0 / full learned wanted 1 ready 0 booting 0 short: runtime-missing\n" +
" Pixel 8 / 35 / full / google_apis_playstore learned wanted 1 ready 1 booting 0\n",
);
});

Expand All @@ -4157,6 +4171,7 @@ describe("CLI: status renders the fleet a gateway reports (ADR 0005 §20)", () =
count: 1,
mode: "slim" as const,
model: "iPhone 17",
origin: "configured" as const,
platform: "ios" as const,
ready: 0,
},
Expand All @@ -4170,7 +4185,7 @@ describe("CLI: status renders the fleet a gateway reports (ADR 0005 §20)", () =

expect(output.stdout).toContain(
"warm pool: enabled, reserve ios 0 android 0\n" +
" iPhone 17 / slim wanted 1 ready 0 booting 0\n",
" iPhone 17 / slim configured wanted 1 ready 0 booting 0\n",
);
});

Expand All @@ -4194,7 +4209,7 @@ describe("CLI: status renders the fleet a gateway reports (ADR 0005 §20)", () =

expect(output.stdout).toContain(
"warm pool: disabled, reserve ios 0 android 0\n" +
" iPhone 17 / 26.0 / full wanted 2 ready 0 booting 0 short: disabled\n",
" iPhone 17 / 26.0 / full configured wanted 2 ready 0 booting 0 short: disabled\n",
);
});

Expand Down
2 changes: 1 addition & 1 deletion src/contract/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Three identities:

## Protocol version

- `PROTOCOL_VERSION_RANGE` in `protocol.ts` holds it, now `{ min: 52, max: 52 }`. `DAEMON_PROTOCOL_VERSION` (`src/daemon-protocol/`) is its `max`.
- `PROTOCOL_VERSION_RANGE` in `protocol.ts` holds it, now `{ min: 53, max: 53 }`. `DAEMON_PROTOCOL_VERSION` (`src/daemon-protocol/`) is its `max`.
- Every change to a contract shape bumps it by one in the same PR. Move `min` too, unless
a compatibility path stays side by side. `.agents/scripts/protocol-bump-check.mjs` checks
it on push and in CI; it counts every file here as a shape but tests, `index.ts` and the
Expand Down
7 changes: 5 additions & 2 deletions src/contract/operations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ describe("operation input/output round trips", () => {
count: 2,
mode: "full",
model: "iPhone 17",
origin: "configured",
osVersion: "26.0",
platform: "ios",
ready: 1,
Expand All @@ -546,6 +547,7 @@ describe("operation input/output round trips", () => {
count: 1,
mode: "full",
model: "iPhone 17",
origin: "learned",
osVersion: "27.0",
platform: "ios",
ready: 0,
Expand Down Expand Up @@ -594,7 +596,7 @@ describe("operation input/output round trips", () => {
).toEqual({ daemon: { health: "starting", mode: "worker" }, host });
});

it("rejects a short outside the ten reasons, and a target list longer than 256", () => {
it("rejects a short outside the ten reasons, and a target list longer than 320", () => {
const target = warmPool.targets[0];
expect(() =>
OPERATIONS["status.get"].output.parse({
Expand All @@ -605,7 +607,7 @@ describe("operation input/output round trips", () => {
expect(() =>
OPERATIONS["status.get"].output.parse({
...running,
warmPool: { ...warmPool, targets: Array.from({ length: 257 }, () => target) },
warmPool: { ...warmPool, targets: Array.from({ length: 321 }, () => target) },
}),
).toThrow();
});
Expand All @@ -628,6 +630,7 @@ describe("operation input/output round trips", () => {
count: 1,
mode: "full",
model: "iPhone 17",
origin: "configured",
platform: "ios",
ready: 0,
short,
Expand Down
2 changes: 1 addition & 1 deletion src/contract/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface ProtocolRange {
const protocolRangeSchema = z.object({ min: z.number().int(), max: z.number().int() });

/** Widen only once a second version is kept alive side by side with the first; a bump that leaves no shim behind moves both ends. */
export const PROTOCOL_VERSION_RANGE: ProtocolRange = { min: 52, max: 52 };
export const PROTOCOL_VERSION_RANGE: ProtocolRange = { min: 53, max: 53 };

const LEGACY_DAEMON_PROTOCOL_VERSION = 2;

Expand Down
43 changes: 43 additions & 0 deletions src/contract/schemas.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
leaseGrantSchema,
leaseRequestRecordSchema,
platformCatalogSchema,
statusWarmPoolSchema,
statusDeviceSchema,
waitingRequestSchema,
workerViewSchema,
Expand Down Expand Up @@ -1006,3 +1007,45 @@ describe("waitingRequestSchema's workers", () => {
).toBe(false);
});
});

describe("statusWarmPoolSchema", () => {
const entry = {
booting: 0,
count: 1,
mode: "full",
model: "Pixel 8",
origin: "learned",
osVersion: "35",
platform: "android",
ready: 1,
};
const block = (targets: readonly unknown[]) => ({
enabled: true,
reserveRunning: { android: 0, ios: 0 },
targets,
});
const { origin: _origin, ...withoutOrigin } = entry;

it("accepts origin configured and learned, an optional imageTag, and 320 entries, and refuses an entry without origin or with another word, a tag imageTagSchema refuses, and 321 entries", () => {
const cases: readonly { name: string; targets: readonly unknown[]; accepted: boolean }[] = [
{ accepted: true, name: "learned", targets: [entry] },
{ accepted: true, name: "configured", targets: [{ ...entry, origin: "configured" }] },
{ accepted: true, name: "a tag", targets: [{ ...entry, imageTag: "google_apis_playstore" }] },
{ accepted: true, name: "320 entries", targets: Array.from({ length: 320 }, () => entry) },
{ accepted: false, name: "no origin", targets: [withoutOrigin] },
{ accepted: false, name: "another word", targets: [{ ...entry, origin: "remembered" }] },
{ accepted: false, name: "a bad tag", targets: [{ ...entry, imageTag: "no spaces" }] },
{ accepted: false, name: "321 entries", targets: Array.from({ length: 321 }, () => entry) },
];

expect(
cases.map(({ name, targets }) => [
name,
statusWarmPoolSchema.safeParse(block(targets)).success,
]),
).toEqual(cases.map(({ accepted, name }) => [name, accepted]));
expect(
statusWarmPoolSchema.parse(block([{ ...entry, imageTag: "google_apis" }])).targets[0],
).toMatchObject({ imageTag: "google_apis", origin: "learned" });
});
});
8 changes: 6 additions & 2 deletions src/contract/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -517,9 +517,11 @@ export const statusCapacitySchema = z.object({
});

/** Bounds on the warm pool block: a gateway parses it off the wire from every worker. */
/** The most targets the block carries, and the longest model or OS version it names. The config load enforces the same. */
/** why: the most configured targets the config load accepts (the block itself takes `WARM_POOL_ENTRIES_MAX`), and the longest model or OS version the block names. */
export const WARM_POOL_TARGETS_MAX = 256;
export const WARM_POOL_NAME_MAX = 256;
/** why: the configured targets plus the learned kinds, 32 per platform, the pool keeps. */
const WARM_POOL_ENTRIES_MAX = WARM_POOL_TARGETS_MAX + 64;

/** Why a warm target is short, in the order the first that applies is the one reported. */
const warmPoolShortSchema = z.enum([
Expand All @@ -540,6 +542,8 @@ const warmPoolTargetSchema = z.object({
model: z.string().max(WARM_POOL_NAME_MAX),
osVersion: z.string().max(WARM_POOL_NAME_MAX).optional(),
mode: z.enum(["slim", "full"]),
imageTag: imageTagSchema.optional(),
origin: z.enum(["configured", "learned"]),
count: z.number().int().nonnegative(),
ready: z.number().int().nonnegative(),
booting: z.number().int().nonnegative(),
Expand All @@ -553,7 +557,7 @@ export const statusWarmPoolSchema = z.object({
ios: z.number().int().nonnegative(),
android: z.number().int().nonnegative(),
}),
targets: z.array(warmPoolTargetSchema).max(WARM_POOL_TARGETS_MAX),
targets: z.array(warmPoolTargetSchema).max(WARM_POOL_ENTRIES_MAX),
});

export const daemonHealthSchema = z.enum(["starting", "running", "failed"]);
Expand Down
7 changes: 6 additions & 1 deletion src/core/doctor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2387,6 +2387,7 @@ describe("Doctor: optional module findings", () => {
count: 1,
mode: "full" as const,
model: "iPhone 17",
origin: "configured" as const,
osVersion: "27.0",
platform: "ios" as const,
ready: 0,
Expand Down Expand Up @@ -2957,6 +2958,7 @@ describe("Doctor: warm pool targets", () => {
const figuresOf = (
targets: readonly {
model: string;
origin?: "configured" | "learned";
osVersion?: string;
platform?: "ios" | "android";
short?: "runtime-missing" | "unknown-model" | "ram-budget";
Expand All @@ -2968,6 +2970,7 @@ describe("Doctor: warm pool targets", () => {
booting: 0,
count: 1,
mode: "full" as const,
origin: "configured" as const,
platform: "ios" as const,
ready: 0,
...target,
Expand Down Expand Up @@ -3010,11 +3013,13 @@ describe("Doctor: warm pool targets", () => {
return report.findings.filter((finding) => finding.kind === "warm-pool-target-unreachable");
}

it("reports a target short with runtime-missing as unreachable, naming the install command", async () => {
it("reports a configured target short with runtime-missing as unreachable, naming the install command, and no learned entry, even one short runtime-missing", async () => {
const found = await findings({
figures: figuresOf([
{ model: "iPhone 17", osVersion: "26.0" },
{ model: "iPhone 17", osVersion: "27.0", short: "runtime-missing" },
{ model: "iPhone 16", origin: "learned", osVersion: "27.0", short: "runtime-missing" },
{ model: "iPhone 15", origin: "learned", osVersion: "26.0", short: "unknown-model" },
]),
});

Expand Down
4 changes: 2 additions & 2 deletions src/core/doctor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ export class Doctor {
}

/**
* The warm pool's targets that cannot be met as configured: those the last pass found a runtime
* why: the warm pool's configured targets (a learned kind is never a finding) that cannot be met: those the last pass found a runtime
* or a model missing for, and the platforms (or the machine) whose targets add up to more than
* the running limit leaves once the reserve is held back. Read, never acted on, like
* `prerequisite-missing`. A target short for RAM, the device limit or a failed boot is no
Expand All @@ -610,7 +610,7 @@ export class Doctor {
const { enabled, targets } = this.options.config.warmPool;
if (warmPool === undefined || !enabled) return [];
const limits = warmPool.runningCapacity();
const figures = warmPool.figures().targets;
const figures = warmPool.figures().targets.filter((target) => target.origin === "configured");
const catalogs = await this.#catalogsOfMissingRuntimes(figures);
const findings = figures.flatMap((target) =>
unreachableTarget(target, catalogs.get(target.platform)),
Expand Down
9 changes: 5 additions & 4 deletions src/core/warm-pool/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,17 @@ every call, so cancellation removes this protection. The reaper's `idle-shutdown
these devices. With no pass yet, it resolves the targets first. With the pool off it returns none.

Figures (`figures()`, read by `status.get`, doctor's `warm-pool-target-unreachable`, the console):
`enabled`, `reserveRunning`, and per kind `platform`, `model`, `osVersion`, `mode`, `count`, `ready`,
`booting`, `short`. Before the first pass, or with the pool off, they come from config.
`enabled`, `reserveRunning`, and per kind `platform`, `model`, `osVersion`, `mode`, `imageTag`, `origin`
(`configured` or `learned`), `count`, `ready`, `booting`, `short`; learned kinds included, a merged kind once
with the larger count. Before the first pass, or with the pool off, they are the configured targets from config.

`short`, the first that applies: `disabled`; set in the converger `no-driver`, `runtime-missing`,
`unknown-model`, `unresolvable`; set in the policy `boot-failed`, `device-limit`, `running-limit`,
`reserve`, `ram-budget`. None while filling or waiting behind a queued request the pass could not serve.

`warm-pool.target-missed`: once per report that is short now and whose configured targets have not
missed since they were last met (ready ≥ count). Payload: platform, model, osVersion, mode, count,
ready, reason.
missed since they were last met (ready ≥ count). Configured targets only, by the configured count. Payload:
platform, model, osVersion, mode, origin (`configured`), count, ready, reason.

Stop: `close()` at stop start; `drain()` finishes the pass and running boots, starts nothing;
`dispose()` cancels the timers.
Expand Down
Loading
Loading