Repository navigation
docs(adr): propose 0082, a worker may serve only some iOS device modes (#1645) #1647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1f1d116
docs(adr): propose 0082, a worker may serve only some iOS device mode…
V3RON 240365d
docs(adr): 0082 learned kinds and pre-resolve check
V3RON 907082b
docs(adr): accept 0082 (#1645)
V3RON e49ede4
Merge remote-tracking branch 'origin/main' into feature/1645-adr
V3RON 4385216
docs(adr): list 0081 before 0082 in the index after merging main
V3RON b56a744
docs(adr): 0082 draws both mode checks and lists every narrowed section
V3RON c23ee58
Merge remote-tracking branch 'origin/main' into HEAD
V3RON File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
139 changes: 139 additions & 0 deletions
139
docs/internal/adr/0082-a-worker-may-serve-only-some-ios-device-modes.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| # 0082. A worker may serve only some iOS device modes | ||
|
|
||
| - **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) | ||
| §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) 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 | ||
|
|
||
| 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] --> 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 | ||
|
|
||
| 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. 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 | ||
| 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 | ||
| 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. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reject requests when no worker can serve the combined constraints.
If worker A serves slim and model X, and worker B serves full and model Y, a full request for X passes the new mode row and the existing model/runtime rows. Neither worker can serve it. ADR 0009's row 5 requires a known worker that can serve the request, so row 6 permits the request to wait indefinitely. Define a cannot-serve result for the combined mode, model and runtime constraints.
LanguageTool
[style] ~88-~88: Consider using “who” when you are referring to a person instead of an object.
Context: ...amed, or a baseline's) only to a worker that serves it. When no known iOS worker ser...
(THAT_WHO)