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
2 changes: 1 addition & 1 deletion docs/internal/EVENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Simlock registry (ADR 0002, `docs/internal/adr/0002-opt-in-slim-ios-simulators.m
only") is satisfied by waiting for that commit to become observable, not by waiting on a registry
write: the driver writes the launchd overrides file while the simulator is shut down, boots it once, and only fires
`onSlimmed` once the readback shows the overrides in force. The registry's own `device.ready` for that same boot is a separate,
later event, emitted through the normal readiness path once the driver call returns. A slim
later event, emitted through the normal readiness path once the driver call returns. A boot with a lease's except list (ADR 0066) reports `categories` as the smaller list (the worker's slim set minus the excepted categories), `signature` as that list's signature and `labelCount` as the labels written `true`, so a kept label that a slimmed category also lists is not counted; a boot whose smaller list is empty is granted `full` and emits none. A slim
request on a runtime older than iOS 18.5 is resolved to a full spec before planning (ADR 0007
§4), so it never reaches a slim boot. A *skipped* slim on a slim-spec device -- its runtime id
didn't parse, the overrides file could not be written, or the readback disagreed or failed -- is deliberately not an event: it isn't a fact worth putting in front of every event-bus
Expand Down
18 changes: 18 additions & 0 deletions src/core/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface ExactDeviceRequest {
readonly osVersion?: string;
readonly mode?: DeviceMode;
readonly imageTag?: string;
readonly except?: readonly string[];
}

export interface DeviceRequest extends Omit<ExactDeviceRequest, "model"> {
Expand Down Expand Up @@ -301,6 +302,7 @@ export interface Driver {
options: {
readonly purpose: "prepare" | "recover";
readonly mode: DeviceMode;
readonly except?: readonly string[];
},
): Promise<DriverDevice>;
reclaim(
Expand Down Expand Up @@ -598,6 +600,22 @@ export class UnsupportedRequestOptionError extends Error {
}
}

/** why: A refusal that carries its own message, where `UnsupportedRequestOptionError` builds a fixed one. */
export class BadDeviceRequestError extends Error {
constructor(message: string) {
super(message);
this.name = "BadDeviceRequestError";
}
}

/** why: A device booted with a lease's except list but a kept category's service is not running, or that could not be shown (ADR 0066 §2): the driver refuses the device rather than tell the lease it is on. */
export class KeptCategoriesError extends Error {
constructor(message: string) {
super(message);
this.name = "KeptCategoriesError";
}
}

export class UnknownModelError extends Error {
readonly class: DeviceClass | undefined;
readonly model: string | undefined;
Expand Down
2 changes: 2 additions & 0 deletions src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ export {
UnknownModelError,
BaselineMismatchError,
BaselineStaleError,
BadDeviceRequestError,
KeptCategoriesError,
UnsupportedRequestOptionError,
} from "./driver.js";
export {
Expand Down
13 changes: 12 additions & 1 deletion src/daemon/error-code.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { describe, expect, it } from "vitest";

import { ComponentInstallerClosedError, UnsupportedRequestOptionError } from "../core/index.js";
import {
BadDeviceRequestError,
ComponentInstallerClosedError,
UnsupportedRequestOptionError,
} from "../core/index.js";
import {
NoCapacityError,
ProvisionFailedError,
Expand Down Expand Up @@ -57,5 +61,12 @@ describe("classifyError on a request option the driver does not have", () => {
code: "BAD_REQUEST",
message: "ios lease requests do not take imageTag",
});

const bad = new BadDeviceRequestError('unknown slim category "wallet"');
expect(classifyError(bad)).toBe("BAD_REQUEST");
expect(describeLeaseRequestFailure(bad)).toEqual({
code: "BAD_REQUEST",
message: 'unknown slim category "wallet"',
});
});
});
3 changes: 2 additions & 1 deletion src/daemon/error-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
UnknownLeaseError,
UnknownModelError,
UnknownPassthroughToolError,
BadDeviceRequestError,
UnsupportedRequestOptionError,
type LeaseRequestFailure,
} from "../core/index.js";
Expand Down Expand Up @@ -153,7 +154,7 @@ export function classifyError(error: unknown): SimlockErrorCode | undefined {
}
// A request option the platform's driver does not have: the request itself is wrong, and
// asking again unchanged can never succeed.
if (error instanceof UnsupportedRequestOptionError) {
if (error instanceof UnsupportedRequestOptionError || error instanceof BadDeviceRequestError) {
return "BAD_REQUEST";
}
if (error instanceof InsufficientDiskSpaceError) {
Expand Down
1 change: 1 addition & 0 deletions src/drivers/ios/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Resolve and boot:
- `RuntimeMissingError` is only for what a download can fix: an OS outside the device type's range, an installed runtime not paired with the type, and anything below iOS 16 are refused instead.
- A boot is `simctl boot`, `bootstatus -b`, then `listapps` until it succeeds, on one deadline: bootstatus can finish before the installer accepts requests.
- Slim (ADR 0060), on `prepare` of a slim spec only: the managed labels are merged into the simulator's `disabled.plist` before the boot (other entries kept; a failed write is logged and the boot goes on), and `launchctl print-disabled system` is read back after it. A label not as written returns `full`; a readback that fails returns `slim`; both call `onSlimSkipped`, logged only. Every label as written and the write ok: `slim`, and `onSlimmed` becomes `device.slimmed`.
- Slim `except` (ADR 0066, `slim-except.ts`): an excepted category's labels are written `false`; an unknown name is `BAD_REQUEST`; a kept label not read back throws `KeptCategoriesError`.
- A recovery boot writes no overrides and reads nothing back.
- The overrides folder lives outside the device set (`launchdOverridesRoot`), so `destroy` removes it itself after `simctl delete`.
- After every boot and before the readback, `runAfterBoot` (`boot-courtesies.ts`) runs the volume step, then the window step. Each only reports its failure (`onSilenceFailed`, `onWindowFailed`), and the device stays in use.
Expand Down
Loading
Loading