Skip to content

The iOS driver boots a slim simulator with a lease's except list #1329

Closed

Description

@V3RON

Part of #1326.

Scope

The iOS driver can boot a slim simulator with a lease's except list: it writes the worker's slim set minus those categories before the boot, and after the boot it refuses the device unless every kept label reads back enabled. It also refuses an except list naming a category it does not know or the worker does not slim. Nothing calls it with an except list until T3.

In short

A slim boot today writes the worker's whole slim set into the device's launchd overrides file, boots, and reads it back (ADR 0060). With an except list, the driver writes the slim set minus the excepted categories, so their services start at boot, and the readback must show each of their labels enabled. A label that is in a kept category and in a slimmed one is kept on (com.apple.passd is in store and other).

flowchart LR
  A["makeReady(prepare, slim, except)"] --> B["write slim set minus except *changed*"] --> C[boot] --> D["read back *changed*"]
  D -- every kept label enabled --> E[slim device]
  D -- a kept label disabled, write failed, readback failed --> F["KeptCategoriesError *new*"]
Loading
ios.slim.categories except Written off After boot
unset [store, other] every category but store, other; amsaccountsd (also in icloud) stays on slim, kept labels enabled
unset [] / none every category, as today as today
[store, icloud] [store] icloud minus the three ams* labels slim
[store] [store] nothing off: every managed label written false granted full, no except
[store] [mdm] — refused at resolve: "mdm" is not in this worker's slim categories (store)
any [wallet] — refused at resolve: unknown slim category "wallet"

If this goes wrong, a lease is told a category is on while its services are off.

Technical spec

Facts

Commit cc39ec8.

# Fact Source
F1 ExactDeviceRequest carries platform, model, osVersion?, mode?, imageTag?; no except src/core/driver.ts:26-32
F2 makeReady(device, { purpose, mode }) src/core/driver.ts:299-303
F3 resolveSpec refuses an option iOS lacks with UnsupportedRequestOptionError("ios", "imageTag") src/drivers/ios/index.ts:429-432; class at src/core/driver.ts:591
F4 UnsupportedRequestOptionError maps to BAD_REQUEST src/daemon/error-code.ts:154-158
F5 resolveSpec returns a slim spec only for a slim request on a runtime it can slim src/drivers/ios/index.ts:446
F6 makeReady plans the slim boot (planSlimBoot, :2563), writes overrides, boots, then reads back src/drivers/ios/index.ts:1146-1175
F7 #writeOverrides resolves the configured categories and writes overridesFor(...); a write error is kept as writeError, and the boot goes on src/drivers/ios/index.ts:1235-1260
F8 overridesFor(categories): every managed label false, labels of the given categories true, never-disable labels false src/drivers/ios/slim-labels.ts:336-347
F9 Readback: a failed read grants slim (:1291-1292); any mismatched label grants full (:1296-1303); a write error alone grants slim (:1306) src/drivers/ios/index.ts:1284-1306
F10 Labels in two categories: navd (widgets, connectivity), amsaccountsd, amsengagementd, amsondevicestoraged (icloud, store), passd, financed (store, other) src/drivers/ios/slim-labels.ts lines 31/247, 87-89/116-118, 119-120/272-273 (spec-explorer T2)
F11 resolveSlimCategories(undefined) is every category; unknown names are reported, not thrown src/drivers/ios/slim-labels.ts:297-320
F12 index.ts is 2672 lines against a shrink-only limit of 2700; index.test.ts is at its limit 5996 wc -l; src/source-hygiene.test.ts:41-42
F13 The readback spawns launchctl print-disabled system, parsed by parsePrintDisabled src/drivers/ios/index.ts:1276-1294
F14 index.test.ts fakes simctl with ScriptedProcessRunner; slim helpers createSlimDriver (4974), printDisabled (5134), slimBootCalls (5152), prepareSlimWith (5170); model test "writes the launchd overrides before the one boot and grants slim after the readback" (2809) src/drivers/ios/index.test.ts
F15 The experiment: after enable rewrote disabled.plist, a shutdown and boot (9 s) ran the re-enabled passd and financed ADR 0066 Context; experiment of 2026-11-05 on iOS 26.4.1 (23E254a)
F16 With no known category to write, today's path writes nothing and returns full (no-categories), leaving any older file in place; a seed's copy boots with the seed's copied file src/drivers/ios/index.ts:1229-1234, :1174-1175, :1078-1086
F17 device.slimmed's categories, labelCount and signature come from the write's resolved categories and wanted labels src/drivers/ios/index.ts:1311-1318; docs/internal/EVENTS.md:99
F18 FakeDriver.failOn("makeReady", n, error) throws any error from makeReady src/core/fake-driver.ts:692-694

Modules touched

Searches: ExactDeviceRequest, makeReady(, overridesFor, #writeOverrides, UnsupportedRequestOptionError.

flowchart LR
  core["core/driver.ts *changed*<br/>ExactDeviceRequest.except, makeReady except,<br/>KeptCategoriesError"] --> ios["drivers/ios/index.ts *changed*<br/>resolveSpec, makeReady wiring"]
  ios --> ex["drivers/ios/slim-except.ts *new*<br/>check names, smaller list, kept check"]
  ex --> labels["drivers/ios/slim-labels.ts *changed*<br/>overridesFor keep"]
  fake["core/fake-driver.ts *changed*"] --> core
Loading
  • src/core/driver.ts: ExactDeviceRequest.except?: readonly string[]; makeReady option except?: readonly string[]; KeptCategoriesError (kept label not enabled, write failed, readback failed), message names the first label or the reason; BadDeviceRequestError(message), a refusal that carries its own message (UnsupportedRequestOptionError builds a fixed one, F3).
  • src/daemon/error-code.ts: BadDeviceRequestError → BAD_REQUEST, beside UnsupportedRequestOptionError (F4).
  • src/drivers/ios/slim-except.ts (new, as index.ts is near its size limit): checkExcept(except, slimSet), the smaller list, and the kept-label check over a parsed readback.
  • src/drivers/ios/slim-labels.ts: overridesFor(categories, keep?): labels of kept categories written false.
  • src/drivers/ios/index.ts: resolveSpec calls checkExcept; makeReady passes except to the write and the check. Its line count stays at or below 2700.
  • src/drivers/ios/index.test.ts → its slim helpers (createSlimDriver, printDisabled, slimBootCalls, prepareSlimWith) move to a shared non-test file (src/drivers/ios/test-slim.ts: dependency-cruiser counts only *.test.ts and test-*.ts as test files, and only they may import ./testing.js, .dependency-cruiser.mjs:15, :69-75) that both test files import; index.test.ts only shrinks. T3 uses FakeDriver.failOn("makeReady", …) (F18); no fake-driver change.
  • src/drivers/ios/AGENTS.md: Boot steps 2-3.

Contract and event changes

None in this task: no wire shape changes. For a boot with an except list, device.slimmed carries categories = the smaller list, signature = slimSignature(smaller list), labelCount = the labels written true (kept labels that a slimmed category also lists are not counted). EVENTS.md's device.slimmed row says so in words; no shape change. A boot whose smaller list is empty emits no device.slimmed (it is granted full).

Other code on the same state

Searched disabled.plist, #writeOverrides, #readOverrides, overridesFor (index.ts, slim-overrides.ts, tests): the prepare write (this), a seed's copied disabled.plist (index.ts:1082, rewritten by the prepare write since every managed label is written), the recovery boot (writes nothing, ADR 0060 §4). Open PR #1243 (lease --label) also edits src/drivers/ios/index.ts; whichever merges second keeps the file at or below its limit. A warm device booted earlier with the full slim set is rewritten whole by the next prepare write, so the smaller list replaces it (T3 does the shutdown). When the smaller list is empty (the except list names the whole slim set), the driver still writes the file, with every managed label false, so no older or seed-copied entry survives; today's no-categories path (F16) is not taken for an except boot.

Failure modes

Call Outcome What happens Limit, counted from
resolveSpec with except unknown name BadDeviceRequestError, message unknown slim category "<name>" none
resolveSpec with except name not in slim set BadDeviceRequestError, message "<name>" is not in this worker's slim categories (<names>) none
overrides write, except given fails boot goes on (as today), then KeptCategoriesError could not write the launchd overrides file: <reason> none
boot fails or times out BootTimeoutError, as today ios.slim.bootTimeoutMs, from the boot
readback, except given cannot run KeptCategoriesError could not read back the launchd overrides: <reason> 120 s, from the spawn
readback, except given a kept label not enabled KeptCategoriesError <n> kept labels are not enabled; first: <label> —
readback, except given only non-kept labels mismatched granted full, as today —
readback, except given all as written granted slim —
write, except names the whole slim set smaller list empty file written with every managed label false; boot; granted full, no except, no device.slimmed —

A restart mid-boot: as today (the device is destroyed by startup, ADR 0061). Two callers: one device, one makeReady under its claim, as today.

Rules in play

  • ADR 0066 §2, "a kept label not read back false (enabled), a write that failed, or a readback that could not run fails the boot": KeptCategoriesError.
  • ADR 0066 §2, "an excepted category wins": overridesFor keep.
  • ADR 0060 §1, the write before boot: unchanged, with a smaller list.
  • iOS manual rule "A slim spec is returned only for a slim request the driver will slim": the spec stays slim; a boot whose smaller list is empty returns full, as a slim spec on a runtime below 18.5 does today; ADR 0066 §2 ("A device granted full reports no except").
  • shrink-only size limits (source-hygiene.test.ts): new code in slim-except.ts, tests in a new file.

Tests

Seam: the iOS driver's resolveSpec and makeReady with a ScriptedProcessRunner, modelled on index.test.ts "writes the launchd overrides before the one boot and grants slim after the readback" (2809), in a new test file beside it (the old one is at its size limit).

  • The iOS driver boots a slim device with an except list and grants only when every kept label reads back enabled: cases kept labels enabled (written file has them false, granted slim); a kept label also in a slimmed category (amsaccountsd with except store, slim set store, icloud: written false); a kept label read back disabled (KeptCategoriesError); write fails (KeptCategoriesError); readback fails (KeptCategoriesError); a non-kept label mismatched (granted full); except naming the whole slim set (file written all false, granted full); device.slimmed carries the smaller list, its signature and the count of labels written true.
  • The iOS driver refuses an except list it cannot serve at resolve: cases unknown name; name outside the slim set; set unset accepts every known name.

Done when

  • pnpm exec vitest run --project unit src/drivers/ios/ src/core/ passes.
  • src/drivers/ios/index.ts stays at or below its size limit.
  • The iOS manual's Boot steps describe the except write and check.

Out of scope

  • Passing except from a lease request (T3); rebooting a warm device (T3).
  • Any change to a boot without an except list.

Depends on

Written by an agent.

Activity

  1. added
    task:draftScope written; technical spec or its spec check missing.
    on Nov 5, 2026
  2. added
    task:readySpec checked. An agent may implement it once its Depends on allow.
    and removed
    task:draftScope written; technical spec or its spec check missing.
    on Nov 5, 2026
  3. self-assigned this
    on Nov 6, 2026
  4. added a commit that references this issue on Nov 6, 2026
    cdb9b3c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

task:readySpec checked. An agent may implement it once its Depends on allow.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions