From 1f1d116c140c80e3a54c49b790339b7fbc070677 Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Tue, 17 Nov 2026 09:43:29 +0100 Subject: [PATCH 1/5] docs(adr): propose 0082, a worker may serve only some iOS device modes (#1645) --- ...er-may-serve-only-some-ios-device-modes.md | 130 ++++++++++++++++++ docs/internal/adr/README.md | 1 + 2 files changed, 131 insertions(+) create mode 100644 docs/internal/adr/0082-a-worker-may-serve-only-some-ios-device-modes.md diff --git a/docs/internal/adr/0082-a-worker-may-serve-only-some-ios-device-modes.md b/docs/internal/adr/0082-a-worker-may-serve-only-some-ios-device-modes.md new file mode 100644 index 000000000..d8603b83d --- /dev/null +++ b/docs/internal/adr/0082-a-worker-may-serve-only-some-ios-device-modes.md @@ -0,0 +1,130 @@ +# 0082. A worker may serve only some iOS device modes + +- **Status:** Proposed +- **Date:** 2026-11-17 +- **Issue:** [#1645](https://github.com/callstackincubator/simlock/issues/1645) (request [#1557](https://github.com/callstackincubator/simlock/issues/1557)) +- **Narrows:** [ADR 0007](0007-a-lease-request-chooses-the-device-mode.md) + §3 ("Every worker honours both modes") and §4 ("It is never an error"); + [ADR 0009](0009-gateway-routing-is-a-list-of-stages.md) §4 (the table + gains a row) and §5 (one more "cannot serve" code); + [ADR 0008](0008-the-catalog-pairs-models-with-runtimes-and-status-carries-host-facts.md) + §1 (the iOS catalog entry gains a field). +- **Depends on:** ADR 0007, 0009, 0065, 0066. + +## Context + +A full iOS simulator runs every system service; a slim one (ADR 0060) +turns the heavy ones off and uses much less memory. ADR 0007 lets each +lease request pick its mode, and makes every worker serve both (§3). A +worker's `ios.defaultMode` only sets the mode of a request that names +none. + +An operator whose worker is short of memory wants no full simulator on +it at all. Today they cannot stop one: a client may ask `--mode full`, a +slim request on iOS below 18.5 quietly becomes full (§4), and warm-pool +targets, learned kinds and full baselines boot full devices with no +request at all. + +Through a gateway, a worker that refused a mode would also need the +gateway to send full requests elsewhere: today a code the gateway does +not class as "cannot serve" is a final answer. + +## Decision + +### 1. A worker key lists the iOS modes it serves + +`ios.modes` is a list of `slim` and `full`, at least one, no repeats. +Unset, it is both: every worker serves what it serves today. It is a +core key of the `ios` section, beside `defaultMode` (ADR 0065), because +leasing, the warm pool, the catalog and the gateway act on it, and the +driver does not. + +The default mode must be served. When `ios.defaultMode` is unset and only +one mode is listed, that mode is the default. A `defaultMode` that is set +and not listed fails the config load. + +Android gets no key: its driver never slims, so a list could only say +`full`. + +```mermaid +flowchart TD + R[Request mode, or baseline's, or the default] --> D[Driver resolves the spec] + D --> M{Resolved mode in ios.modes?} + M -- yes --> P[Plan and boot as today] + M -- no --> X[MODE_UNAVAILABLE, nothing created or downloaded] +``` + +### 2. The check is on the resolved mode, in leasing's one resolve step + +Leasing checks the mode the driver resolved, not the one asked for, so a +slim request that would fall back to full (§4 of ADR 0007) is refused on a +worker without full instead of being granted full. Lease requests, warm +targets and learned kinds all pass that one step, so all are refused the +same way, and a warm target that cannot be met is reported by doctor. + +A slim boot whose readback fails still records `full` (ADR 0007 §8) and +is granted as today: the check is a planning rule, not a promise about +what the OS did. + +### 3. A new error code + +The refusal is `MODE_UNAVAILABLE`: exit 12 and HTTP 422, the group for +"this machine cannot provide it". Its message names the mode and the key. +It is a new code rather than `UNKNOWN_MODEL` or `BAD_REQUEST` because the +model is fine and the request is valid elsewhere in a fleet; a client +can tell it apart and ask for the other mode. Its `lease.rejected` reason +is `unresolvable-spec`, like every other resolve refusal. + +### 4. The catalog says which modes a worker serves, and a gateway routes by it + +A worker's iOS catalog entry carries `modes` when it serves only some. +Absent means both, so a worker from before this change reads as serving +both. The gateway's merged entry carries the union. + +A gateway sends a request whose mode is known (named, or a baseline's) +only to a worker that serves it. When no known iOS worker serves it, the +request fails at once with `MODE_UNAVAILABLE`: a new row of ADR 0009 §4, +after "no known worker has the platform". A request with no mode goes to +any worker and gets that worker's default, which it serves by §1. + +A worker's own `MODE_UNAVAILABLE` before a progress push counts as +"cannot serve" (ADR 0009 §5): the gateway leaves that worker out for that +request and tries the others. + +```mermaid +sequenceDiagram + participant A as Agent + participant G as Gateway + participant W1 as Worker (slim only) + participant W2 as Worker (both) + A->>G: lease --mode full + G->>G: W1 does not serve full + G->>W2: lease.request + W2-->>G: granted + G-->>A: granted +``` + +## Consequences + +- A full request on a slim-only worker fails at once; it never waits. +- A worker with `ios.modes: ["slim"]` never boots a full iOS simulator + for any request, target or baseline. A slim pass that fails at boot is + the one way such a device can still run full. +- The catalog field and the new code move the protocol by one. +- An older gateway strips the field and relays the code as a final + answer: behind it, a full request that one worker refuses is not tried + on another. + +## Alternatives considered + +- **`ios.fullMode: false`, a boolean.** Simpler, but it can only turn full + off; a list names what the worker serves in the request's own words. +- **Reuse `UNKNOWN_MODEL` or `BAD_REQUEST`.** No new code, but the first + points the caller at the model list and the second says the request was + wrong, when another worker could serve it. +- **No catalog field; the gateway retries on the worker's refusal.** + Cheaper, but each request costs a round trip per refusing worker, and + when none serves the mode the caller gets one worker's answer instead of + the fleet's. +- **Keep the slim-to-full fallback on a slim-only worker.** It would + grant exactly the device the operator turned off. diff --git a/docs/internal/adr/README.md b/docs/internal/adr/README.md index ee85e48e4..8713d3e33 100644 --- a/docs/internal/adr/README.md +++ b/docs/internal/adr/README.md @@ -115,3 +115,4 @@ the status is stale. | [0078](0078-an-android-worker-tries-its-default-image-tag-first-and-falls-back-to-none.md) | An Android worker tries its default image tag first, and a lease falls back to none | Accepted | | [0079](0079-one-capture-per-device-is-shared-by-every-viewer-and-every-capture-sends-a-key-frame-every-5-s.md) | One capture per device is shared by every viewer, and every capture sends a key frame at least every 5 s | Accepted; narrows 0045 §5 | | [0080](0080-an-android-worker-may-enrol-phones-reached-over-the-network.md) | An Android worker may enrol phones reached over the network | Accepted; narrows 0022 §6 and §7, and 0073 §2 and §5 | +| [0082](0082-a-worker-may-serve-only-some-ios-device-modes.md) | A worker may serve only some iOS device modes | Proposed; narrows 0007 §3 and §4, 0008 §1, 0009 §4 and §5 | From 240365d0bf65fa6598082d1d0a2c58b321aaab3a Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Tue, 17 Nov 2026 09:56:10 +0100 Subject: [PATCH 2/5] docs(adr): 0082 learned kinds and pre-resolve check --- ...a-worker-may-serve-only-some-ios-device-modes.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/internal/adr/0082-a-worker-may-serve-only-some-ios-device-modes.md b/docs/internal/adr/0082-a-worker-may-serve-only-some-ios-device-modes.md index d8603b83d..e9eb36f7b 100644 --- a/docs/internal/adr/0082-a-worker-may-serve-only-some-ios-device-modes.md +++ b/docs/internal/adr/0082-a-worker-may-serve-only-some-ios-device-modes.md @@ -56,11 +56,14 @@ flowchart TD ### 2. The check is on the resolved mode, in leasing's one resolve step -Leasing checks the mode the driver resolved, not the one asked for, so a -slim request that would fall back to full (§4 of ADR 0007) is refused on a -worker without full instead of being granted full. Lease requests, warm -targets and learned kinds all pass that one step, so all are refused the -same way, and a warm target that cannot be met is reported by doctor. +Leasing checks the asked, default or baseline mode before it resolves the +spec, so nothing is downloaded for it, and checks the mode the driver +resolved after, so a slim request that would fall back to full (§4 of ADR +0007) is refused on a worker without full instead of being granted full. +Lease requests and warm targets pass that one step, so both are refused +the same way, and a warm target that cannot be met is reported by doctor. +Learned kinds are planned from their stored spec, so the warm pool's own +catalog check forgets one whose mode is not served. A slim boot whose readback fails still records `full` (ADR 0007 §8) and is granted as today: the check is a planning rule, not a promise about From 907082bd53265bf178a43e5d795fb4129aeb1091 Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Tue, 17 Nov 2026 09:59:40 +0100 Subject: [PATCH 3/5] docs(adr): accept 0082 (#1645) --- .../adr/0082-a-worker-may-serve-only-some-ios-device-modes.md | 2 +- docs/internal/adr/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/internal/adr/0082-a-worker-may-serve-only-some-ios-device-modes.md b/docs/internal/adr/0082-a-worker-may-serve-only-some-ios-device-modes.md index e9eb36f7b..84a9a9d5a 100644 --- a/docs/internal/adr/0082-a-worker-may-serve-only-some-ios-device-modes.md +++ b/docs/internal/adr/0082-a-worker-may-serve-only-some-ios-device-modes.md @@ -1,6 +1,6 @@ # 0082. A worker may serve only some iOS device modes -- **Status:** Proposed +- **Status:** Accepted — not yet implemented - **Date:** 2026-11-17 - **Issue:** [#1645](https://github.com/callstackincubator/simlock/issues/1645) (request [#1557](https://github.com/callstackincubator/simlock/issues/1557)) - **Narrows:** [ADR 0007](0007-a-lease-request-chooses-the-device-mode.md) diff --git a/docs/internal/adr/README.md b/docs/internal/adr/README.md index 8713d3e33..44d981c2c 100644 --- a/docs/internal/adr/README.md +++ b/docs/internal/adr/README.md @@ -115,4 +115,4 @@ the status is stale. | [0078](0078-an-android-worker-tries-its-default-image-tag-first-and-falls-back-to-none.md) | An Android worker tries its default image tag first, and a lease falls back to none | Accepted | | [0079](0079-one-capture-per-device-is-shared-by-every-viewer-and-every-capture-sends-a-key-frame-every-5-s.md) | One capture per device is shared by every viewer, and every capture sends a key frame at least every 5 s | Accepted; narrows 0045 §5 | | [0080](0080-an-android-worker-may-enrol-phones-reached-over-the-network.md) | An Android worker may enrol phones reached over the network | Accepted; narrows 0022 §6 and §7, and 0073 §2 and §5 | -| [0082](0082-a-worker-may-serve-only-some-ios-device-modes.md) | A worker may serve only some iOS device modes | Proposed; narrows 0007 §3 and §4, 0008 §1, 0009 §4 and §5 | +| [0082](0082-a-worker-may-serve-only-some-ios-device-modes.md) | A worker may serve only some iOS device modes | Accepted — not yet implemented; narrows 0007 §3 and §4, 0008 §1, 0009 §4 and §5 | From 4385216238b36383bd8ef441c43c6c7d70afe03b Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Wed, 18 Nov 2026 09:05:19 +0100 Subject: [PATCH 4/5] docs(adr): list 0081 before 0082 in the index after merging main --- docs/internal/adr/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/internal/adr/README.md b/docs/internal/adr/README.md index 2b2358a9d..543d7ecba 100644 --- a/docs/internal/adr/README.md +++ b/docs/internal/adr/README.md @@ -115,8 +115,8 @@ the status is stale. | [0078](0078-an-android-worker-tries-its-default-image-tag-first-and-falls-back-to-none.md) | An Android worker tries its default image tag first, and a lease falls back to none | Accepted | | [0079](0079-one-capture-per-device-is-shared-by-every-viewer-and-every-capture-sends-a-key-frame-every-5-s.md) | One capture per device is shared by every viewer, and every capture sends a key frame at least every 5 s | Accepted; narrows 0045 §5 | | [0080](0080-an-android-worker-may-enrol-phones-reached-over-the-network.md) | An Android worker may enrol phones reached over the network | Accepted; narrows 0022 §6 and §7, and 0073 §2 and §5 | -| [0082](0082-a-worker-may-serve-only-some-ios-device-modes.md) | A worker may serve only some iOS device modes | Accepted — not yet implemented; narrows 0007 §3 and §4, 0008 §1, 0009 §4 and §5 | | [0081](0081-a-remote-caller-speaks-the-daemon-protocol-over-one-websocket-path-with-its-tokens-identity.md) | A remote caller speaks the daemon protocol over one WebSocket path, with its token's identity | Accepted; narrows 0003 §4, §5 and §10, and 0005 §19c | +| [0082](0082-a-worker-may-serve-only-some-ios-device-modes.md) | A worker may serve only some iOS device modes | Accepted — not yet implemented; narrows 0007 §3 and §4, 0008 §1, 0009 §4 and §5 | | [0083](0083-a-worker-may-turn-single-slim-services-on-or-off-beside-its-categories.md) | A worker may turn single slim services on or off beside its categories | Accepted; narrows 0060 §1, §2 and 0066 §2 | | [0084](0084-a-worker-may-serve-a-platforms-enrolled-phones-only.md) | A worker may serve a platform's enrolled phones only | Accepted; narrows 0022 and 0009 §4 | | [0085](0085-an-ios-simulator-takes-keys-on-every-runtime-and-the-app-switcher-and-lock.md) | An iOS simulator takes keys on every runtime, and the app switcher and Lock | Accepted; narrows 0049 §4 | From b56a744fa20c4dfcd3c0a071061f18e6674094c1 Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Wed, 18 Nov 2026 09:10:05 +0100 Subject: [PATCH 5/5] docs(adr): 0082 draws both mode checks and lists every narrowed section --- ...ker-may-serve-only-some-ios-device-modes.md | 18 ++++++++++++------ docs/internal/adr/README.md | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/docs/internal/adr/0082-a-worker-may-serve-only-some-ios-device-modes.md b/docs/internal/adr/0082-a-worker-may-serve-only-some-ios-device-modes.md index 84a9a9d5a..dddd63e05 100644 --- a/docs/internal/adr/0082-a-worker-may-serve-only-some-ios-device-modes.md +++ b/docs/internal/adr/0082-a-worker-may-serve-only-some-ios-device-modes.md @@ -8,7 +8,11 @@ [ADR 0009](0009-gateway-routing-is-a-list-of-stages.md) §4 (the table gains a row) and §5 (one more "cannot serve" code); [ADR 0008](0008-the-catalog-pairs-models-with-runtimes-and-status-carries-host-facts.md) - §1 (the iOS catalog entry gains a field). + §1 (the iOS catalog entry gains a field) and §9 (one more config-derived + field joins the catalog); [ADR 0007](0007-a-lease-request-chooses-the-device-mode.md) + §1 ("The default is `full`" holds only when `full` is served); + [ADR 0009](0009-gateway-routing-is-a-list-of-stages.md) §2 and §3 (what a + worker can serve is also decided by its modes, not only model and runtime). - **Depends on:** ADR 0007, 0009, 0065, 0066. ## Context @@ -48,10 +52,12 @@ Android gets no key: its driver never slims, so a list could only say ```mermaid flowchart TD - R[Request mode, or baseline's, or the default] --> D[Driver resolves the spec] - D --> M{Resolved mode in ios.modes?} - M -- yes --> P[Plan and boot as today] - M -- no --> X[MODE_UNAVAILABLE, nothing created or downloaded] + R[Request mode, or baseline's, or the default] --> M1{Asked mode in ios.modes?} + M1 -- no --> X[MODE_UNAVAILABLE] + M1 -- yes --> D[Driver resolves the spec, may download] + D --> M2{Resolved mode in ios.modes?} + M2 -- yes --> P[Plan and boot as today] + M2 -- no --> X ``` ### 2. The check is on the resolved mode, in leasing's one resolve step @@ -59,7 +65,7 @@ flowchart TD Leasing checks the asked, default or baseline mode before it resolves the spec, so nothing is downloaded for it, and checks the mode the driver resolved after, so a slim request that would fall back to full (§4 of ADR -0007) is refused on a worker without full instead of being granted full. +0007) is refused on a worker without full instead of being granted full. That second refusal can come after a download the request allowed. Lease requests and warm targets pass that one step, so both are refused the same way, and a warm target that cannot be met is reported by doctor. Learned kinds are planned from their stored spec, so the warm pool's own diff --git a/docs/internal/adr/README.md b/docs/internal/adr/README.md index 543d7ecba..cb2ac0ea6 100644 --- a/docs/internal/adr/README.md +++ b/docs/internal/adr/README.md @@ -116,7 +116,7 @@ the status is stale. | [0079](0079-one-capture-per-device-is-shared-by-every-viewer-and-every-capture-sends-a-key-frame-every-5-s.md) | One capture per device is shared by every viewer, and every capture sends a key frame at least every 5 s | Accepted; narrows 0045 §5 | | [0080](0080-an-android-worker-may-enrol-phones-reached-over-the-network.md) | An Android worker may enrol phones reached over the network | Accepted; narrows 0022 §6 and §7, and 0073 §2 and §5 | | [0081](0081-a-remote-caller-speaks-the-daemon-protocol-over-one-websocket-path-with-its-tokens-identity.md) | A remote caller speaks the daemon protocol over one WebSocket path, with its token's identity | Accepted; narrows 0003 §4, §5 and §10, and 0005 §19c | -| [0082](0082-a-worker-may-serve-only-some-ios-device-modes.md) | A worker may serve only some iOS device modes | Accepted — not yet implemented; narrows 0007 §3 and §4, 0008 §1, 0009 §4 and §5 | +| [0082](0082-a-worker-may-serve-only-some-ios-device-modes.md) | A worker may serve only some iOS device modes | Accepted — not yet implemented; narrows 0007 §1, §3 and §4, 0008 §1 and §9, 0009 §2, §3, §4 and §5 | | [0083](0083-a-worker-may-turn-single-slim-services-on-or-off-beside-its-categories.md) | A worker may turn single slim services on or off beside its categories | Accepted; narrows 0060 §1, §2 and 0066 §2 | | [0084](0084-a-worker-may-serve-a-platforms-enrolled-phones-only.md) | A worker may serve a platform's enrolled phones only | Accepted; narrows 0022 and 0009 §4 | | [0085](0085-an-ios-simulator-takes-keys-on-every-runtime-and-the-app-switcher-and-lock.md) | An iOS simulator takes keys on every runtime, and the app switcher and Lock | Accepted; narrows 0049 §4 |