Repository navigation
Description
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*"]
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
src/core/driver.ts:ExactDeviceRequest.except?: readonly string[];makeReadyoptionexcept?: 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 (UnsupportedRequestOptionErrorbuilds a fixed one, F3).src/daemon/error-code.ts:BadDeviceRequestError→BAD_REQUEST, besideUnsupportedRequestOptionError(F4).src/drivers/ios/slim-except.ts(new, asindex.tsis 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 writtenfalse.src/drivers/ios/index.ts:resolveSpeccallscheckExcept;makeReadypassesexceptto 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.tsandtest-*.tsas test files, and only they may import./testing.js,.dependency-cruiser.mjs:15,:69-75) that both test files import;index.test.tsonly shrinks. T3 usesFakeDriver.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":
overridesForkeep. - 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 grantedfullreports noexcept"). - shrink-only size limits (
source-hygiene.test.ts): new code inslim-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 (amsaccountsdwith exceptstore, slim setstore, icloud: writtenfalse); a kept label read back disabled (KeptCategoriesError); write fails (KeptCategoriesError); readback fails (KeptCategoriesError); a non-kept label mismatched (grantedfull); except naming the whole slim set (file written allfalse, grantedfull);device.slimmedcarries the smaller list, its signature and the count of labels writtentrue. - 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.tsstays at or below its size limit.- The iOS manual's Boot steps describe the except write and check.
Out of scope
- Passing
exceptfrom a lease request (T3); rebooting a warm device (T3). - Any change to a boot without an except list.
Depends on
- Re-sync the iOS slim label list to simslim v0.14.0 #1328 (the category list with
mdm) - iOS simulator tunnels: forward only to the lease's simulator, reverse on the exact port #1288 (edits
src/drivers/ios/index.tsnear its size limit)
Written by an agent.
Activity
test: a kept label read back disabled, a failed write or a failed rea…
feat(ios): a kept label not enabled, a failed write or a failed readb…
feat(ios): an except list naming the whole slim set writes every labe…
test: the iOS driver refuses an except list it cannot serve at resolve (
feat(ios): resolve refuses an except list naming an unknown category …
docs(ios): Boot steps 2-3 and the device.slimmed row describe the exc…
refactor(ios): move the simctl JSON parsers out of index.ts into simc…
chore(stack): merge task/1328 into the slim-except branch (#1329)
refactor(ios): split #readBack into helpers to lower its CRAP score (#…
feat(ios): the iOS driver boots a slim simulator with a lease's excep…