Skip to content

Reset one platform with nuke, and remake an iOS seed whose simulator is gone #1836

Done
1 of 1 issue completed

Description

@V3RON

Request: #1797

Problem

On a worker that has served iOS and Android leases, switching drivers.ios.deviceSet from simlock to default is refused while Simlock's own iOS set still holds simulators, the iOS seeds among them. The only supported way to empty it, simlock nuke --delete-devices, also deletes every Android seed and resets every Android device, which is slow and costly to rebuild, just to change an iOS setting.

The only iOS-only way out is xcrun simctl --set …/sources delete <udid>, which the refusal message suggests. After it, Simlock still keeps the deleted seed's record as ready, so every iOS lease of that kind fails (PROVISION_FAILED: simctl clone <udid> … Provided set path does not exist, or Invalid device: <udid>), on either device set, and simlock doctor reports nothing.

Who it is for

The operator of a worker that serves both platforms, who wants to change an iOS-only setting (here the device set, so Maestro, Detox or xcodebuild -destination id= can see the simulators) without losing the Android emulators and their seeds.

Outcome

  • simlock nuke --delete-devices --platform ios resets iOS only: iOS leases end, iOS simulators, seeds and baselines are deleted, and the warm pool forgets its iOS kinds. Android leases already held, emulators, seeds, baselines and learned kinds are untouched. --platform android is the mirror.
  • While any nuke runs, every lease request is refused with killed, of both platforms, as today: an Android request made or still booting during an iOS nuke fails, and the agent asks again afterwards.
  • A ready iOS seed whose simulator is gone is dropped and made again at the next lease of its kind, and that lease is granted, instead of failing.
  • simlock doctor lists such a seed under sources, with a stale reason that says its simulator is gone.

How it works for the user

flowchart TD
  A[Operator: switch drivers.ios.deviceSet] --> B{Old iOS set empty?}
  B -- no --> C[Daemon refuses iOS: message names nuke --delete-devices --platform ios]
  C --> D[simlock nuke --delete-devices --platform ios]
  D --> E[iOS leases end, iOS devices + seeds + baselines deleted; Android untouched]
  E --> F[simlock doctor --purge-orphans]
  F --> A
  B -- yes --> G[iOS lease]
  G --> H{Kind's seed simulator present?}
  H -- yes --> I[Clone seed, grant]
  H -- "no (deleted by hand)" --> J[Drop the seed record, make a new seed, clone, grant]
  K[simlock doctor] --> L[sources: seed with staleReason 'its simulator is gone …']
Loading

Before:

$ simlock nuke --delete-devices --platform ios --yes
{"error":{"code":"USAGE","message":"Unknown option '--platform'. …"}}        # exit 2: nuke has no --platform
$ simlock nuke --delete-devices --yes
{"deletedDevices":[…iOS and Android…],"releasedLeaseIds":[…every lease…],"removedBaselines":[…every baseline…]}

# after `xcrun simctl --set ~/.simlock/devices/ios/sources delete <seed udid>`:
$ simlock lease --platform ios --model "iPhone 17"
{"error":{"code":"PROVISION_FAILED","message":"… simctl clone <seed udid> … Invalid device: <seed udid>"}}
$ simlock doctor
(no finding; the seed is listed under sources with no staleReason)

After:

$ simlock nuke --delete-devices --platform ios
Nuke Simlock-managed ios devices? [y/N] y
{"deletedDevices":[…iOS only…],"releasedLeaseIds":[…iOS leases only…],"removedBaselines":[…iOS baselines only…]}

$ simlock nuke --platform windows --yes
{"error":{"code":"USAGE","message":"nuke --platform must be ios or android"}}   # exit 2

# after the same hand deletion:
$ simlock doctor --json
{… "sources":[{"platform":"ios","kind":"seed","model":"iPhone 17","osVersion":"27.2","staleReason":"its simulator is gone; the next lease of its kind makes it again"}]}
$ simlock lease --platform ios --model "iPhone 17"
(a new seed is made, the lease is granted)

Examples

Command Today After
simlock nuke --yes whole reset, both platforms same
simlock nuke --delete-devices --yes whole reset and delete, both platforms same
simlock nuke --platform ios --yes usage error, exit 2 ends iOS leases, cancels every waiting request (both platforms), shuts iOS simulators down, forgets iOS learned kinds; deletes nothing
simlock nuke --delete-devices --platform ios --yes usage error, exit 2 the above, plus deletes iOS simulators, seeds and baselines
simlock nuke --delete-devices --platform android --yes usage error, exit 2 the same for Android only
simlock nuke --platform windows --yes usage error, exit 2 usage error, exit 2: nuke --platform must be ios or android
simlock nuke --platform iOS --yes usage error, exit 2 usage error, exit 2 (same message; names are lower case, as catalog --platform)
simlock nuke --platform usage error, exit 2 usage error, exit 2: Option '--platform <value>' argument missing
iOS seed state at a lease of its kind Today After
row ready, simulator in the current sources set cloned cloned
row ready, simulator deleted by hand PROVISION_FAILED row dropped, new seed made, lease granted
row ready, simulator in the other device set's sources set (setting switched) PROVISION_FAILED row dropped, new seed made, lease granted

What could go wrong

  • An operator types --platform ios and still loses Android work: unlikely, the scoping is tested per platform, and the report lists only the platform's ids.
  • During a platform nuke (about a minute with deletions), an agent of the other platform whose request was waiting or booting gets killed, and its releases and renewals wait until the nuke ends. Its held lease stays. Likely whenever agents are busy; the agent asks again.
  • A sources set that cannot be read fails the lease as today; only a folder that is not there counts as gone.

Words used

  • seed: the simulator or emulator Simlock copies to make each new device of a kind, e.g. one iPhone 17 / iOS 27.2 seed. It is never leased.
  • sources set: the folder that holds the iOS seeds and baselines, e.g. ~/.simlock/devices/ios/sources under deviceSet: simlock.
  • kind: the model and OS a device is made for, e.g. iPhone 17 on iOS 27.2.
  • learned kind: a kind the warm pool keeps booted because a lease asked for it.
  • platform nuke: simlock nuke with --platform.

Non-goals

  • A seeds-only command (simlock seeds remove) or a migration that runs by itself when drivers.ios.deviceSet changes.
  • A platform scope for doctor --purge-orphans or cleanup.
  • An Android seed folder deleted by hand: not the reported case; Android already remakes a seed it judges stale.
  • Through a gateway: nuke stays refused there.

Completion conditions

  • On a worker with an iOS and an Android lease, simlock nuke --delete-devices --platform ios --yes ends the iOS lease only, deletes the iOS simulators, seeds and baselines, and leaves the Android lease, emulators, seeds and baselines in place (simlock status, simlock doctor --json sources).
  • After xcrun simctl --set <sources set> delete <seed udid>, simlock doctor --json lists that seed with the stale reason, and the next iOS lease of its kind is granted.
  • The device-set refusal message names simlock nuke --delete-devices --platform ios.

Open questions

Decisions

  • No ADR: the maintainer's decision (2026-11-24, comment on drivers.ios.deviceSet switch is blocked by iOS seeds; the only supported purge (nuke --delete-devices) also wipes Android seeds #1797) fixes the three outcomes; ADR 0061 §1 (nuke deletes seeds, never an orphan) holds per platform.
  • Decided in the session: --platform also works without --delete-devices (a reset of one platform that deletes nothing), because the flag means the same either way and refusing it would be a second rule to learn.
  • Decided in the session: a platform nuke ends the platform's physical-device leases too, as the whole nuke does; the device stays enrolled.
  • Maintainer decision (session, 2026-11-25): a platform nuke keeps the one maintenance gate. While it runs, every request of both platforms is refused or cancelled with killed (new, waiting or still booting), and releases and renewals of both wait, as for a whole nuke. Only leases, devices, seeds, baselines and learned kinds are scoped to the platform. Splitting the gate per platform was rejected as a larger change than the request needs.
  • Decided in the session: the warm pool forgets only the platform's learned kinds, baseline kinds included; configured targets stay, as today.
  • Decided in the session: the gone check is "the seed's UDID folder is not in the sources set this process uses". A gone seed's row (and its files rows and slim overrides folder) is dropped without any simctl call, because simctl --set on a sources set that does not exist yet fails (Provided set path does not exist).
  • Decided in the session: a baseline source whose simulator is gone gets the stale reason its simulator is gone; save it again, so the baseline turns stale through the existing check; only seeds are made again.
  • Decided in the session: the confirmation prompt names the platform: Nuke Simlock-managed <platform> devices? [y/N] .
  • Decided in the session: the protocol moves both ends by one, as every bump does (PROTOCOL_VERSION_RANGE has min = max), so an older CLI cannot reach a newer daemon and no older daemon can drop platform and nuke both platforms.

Behaviours

Id Behaviour (invoker, action, what it sees) Seam Cases Task
B1 An operator runs a platform nuke: only that platform's leases end (released killed), only its devices are shut down or deleted, and the report (deletedDevices, releasedLeaseIds) lists only its ids. Every waiting request, of both platforms, is cancelled (NukeCancelledError, refusal reason killed), as today. real core and leasing: createHarness (src/leasing/test-create-leasing.ts), engine.nuke, platform faked with FakeDriver; report via Nuke.run iOS with an iOS and an Android lease held → Android lease and device stay; Android mirror; an iOS physical lease ends, device stays enrolled; a waiting Android request is cancelled killed by an iOS nuke; no platform → both platforms, as today (existing nuke tests) #1842
B2 With --delete-devices and a platform, only that platform's seeds and baselines are deleted (baseline.removed reason nuke for its baselines only) and removedBaselines lists only them; orphans stay. NukeService.nuke with fake drivers and BaselineService iOS: iOS seed + baseline deleted, Android seed + baseline kept; Android mirror; without --delete-devices: no seed or baseline deleted; an orphan iOS source stays #1842
B3 A platform nuke forgets only that platform's learned warm kinds, baseline kinds included. LearnedKinds (src/core/warm-pool/learned.ts) through NukeService iOS kinds forgotten, Android kinds kept; an iOS baseline kind forgotten; no platform → all forgotten (as today) #1842
B4 The CLI takes --platform <ios|android> on nuke, sends it in nuke.run, and prompts with the platform; a bad value is a usage error, exit 2, nuke --platform must be ios or android. --help prints Usage: simlock nuke [--delete-devices] [--platform <ios|android>] [--yes]. simlock nuke (src/cli/commands/nuke.ts) with a fake client --platform ios, --platform android, windows, iOS, missing value (Option '--platform <value>' argument missing), absent (no platform sent), prompt text with and without a platform #1842
B5 An iOS lease of a kind whose ready seed's simulator is not in the current sources set is granted: the seed row is dropped (with its files rows and overrides folder, no simctl call) and a new seed is made from a throwaway. IosDriver.provision (src/drivers/ios/index.ts) with fake simctl and filesystem, as index-seed-provision.test.ts folder present → cloned, no make; folder deleted by hand → remade; sources set folder missing entirely (switched set) → remade; two provisions of the kind at once → one make #1842
B6 simlock doctor lists a ready iOS source whose simulator is gone with a stale reason: a seed its simulator is gone; the next lease of its kind makes it again, a baseline its simulator is gone; save it again, which makes the baseline stale. IosDriver.listSources and Doctor.run sources seed gone; baseline gone → baseline listed stale; both present → no reason; the runtime-missing reason still wins when both apply #1842
B7 When the daemon refuses an iOS device set because the set given up still holds simulators, its message tells the operator to run simlock nuke --delete-devices --platform ios. refuseOwnSetLeftovers, refuseDefaultSourcesLeftovers, refuseXcodeSetLeftovers (src/drivers/ios/device-set-leftovers.ts) own set with leftovers; default sources set with leftovers; Xcode's set with leftovers #1842

Stored state

Id What and where Created, changed, deleted by Listed or swept by A restart mid-step leaves Schema step Task Used by
S1 ios_source_data row of a seed whose simulator is gone (src/drivers/ios/source-data.ts), with its ios_source_files rows deleted by B5 at the next provision of its kind, before the new seed's making row listSources (B6, doctor), nuke (B2) the row deleted or not; either way the next provision checks again none #1842 —
S2 warm_kinds rows of one platform, baseline kinds included (its baseline column), and their warm_kind_leases rows (src/core/warm-pool/learned.ts) deleted by B3 warm-pool passes one transaction, as clear() today none #1842 —

Interfaces

Id What Shape and bounds Errors and limits Where Task Used by
I1 nuke.run input { deleteDevices?: boolean, platform?: "ios" | "android" } (platformSchema); output nukeReportSchema unchanged. Bumps the protocol by one (min and max). an unknown platform: BAD_REQUEST from the schema src/contract/operations-admin.ts #1842 —
I2 SimlockAdminClient.runNuke(input?) NukeRunInput inferred from I1 — src/simlock-client/client-api.ts, client-impl.ts #1842 —
I3 simlock nuke [--delete-devices] [--platform <ios|android>] [--yes] as B4 nuke --platform must be ios or android (exit 2); nuke requires confirmation or --yes unchanged src/cli/commands/nuke.ts #1842 —
I4 NukeExecutor.nuke(deleteDevices, platform?), LeaseMaintenance.releaseAllDuringMaintenance(reason, platform?), baselines.removeAll(platform?), warmPool.forget(platform?); acquisition beginMaintenance() unchanged platform absent means both, as today — src/core/nuke-service.ts, src/core/core-ports.ts, src/core/create-core.ts, src/leasing/lease-release-coordinator.ts, src/core/baselines.ts, src/core/warm-pool/converger.ts; the test helper engine.nuke in src/leasing/testing.ts passes platform too #1842 —
I5 Website pages reference/cli.mdx (nuke section and doctor sources sentence), worker/free-disk.mdx (nuke section: what --platform scopes, and that every waiting request of both platforms is still cancelled), worker/change-a-setting.mdx (switch the iOS device set: step 1 uses --platform ios, caution reworded), reference/node-client.mdx (runNuke row), concepts/cleanup.mdx (nuke paragraph) — website/src/content/docs/docs/ #1842 —

Existing code

Commit 200afe5.

Searches: rg nuke src (30 files, non-test), rg "listSources|destroySource" src (driver, doctor, nuke, baselines), rg "cancelAll|releaseAllDuringMaintenance|beginMaintenance" src/leasing src/core (5 non-test), rg "findReadySeed|sourceFolders" src/drivers/ios (seeds.ts), rg nuke website/src/content/docs (18 pages).

Id Code (path:line) Today With this feature Handled by
X1 src/core/nuke-service.ts:92 #runNuke releases every lease, forgets every learned kind, resets every virtual device, deletes every driver's seeds and every baseline each step takes the platform; absent = all B1, B2, B3
X2 src/core/nuke-service.ts:142 #destroySeeds loops every driver only the platform's driver B2
X3 src/core/nuke.ts:17 Nuke.run deletedDevices = every non-deleted device before that is deleted after before limited to the platform's devices B1
X4 src/leasing/lease-release-coordinator.ts:492 #releaseAll every lease in the registry only leases whose device (virtual or physical) is of the platform B1
X5 src/leasing/lease-acquisition-coordinator.ts:150 beginMaintenance → src/leasing/wait-queue.ts:433 cancelAll; lease-acquisition-coordinator.ts:101 admit and src/leasing/acquisition-workflow.ts:291 decide refuse while admission is closed; lease-release-coordinator.ts:260 renew and release wait in #runNormal one gate for both platforms unchanged, by the maintainer's decision B1
X6 src/core/baselines.ts:405 removeAll deletes every row, then every source only rows of the platform B2
X7 src/core/warm-pool/converger.ts:208 forget → src/core/warm-pool/learned.ts:217 clear deletes every learned row only the platform's rows B3
X8 src/drivers/ios/seeds.ts:328 #findOrMakeSeed a ready row is reused unless stale by runtime build; its simulator is never checked, so simctl clone fails (seeds.ts:229) a row whose UDID is not in #sourceFolders() (seeds.ts:286) is dropped and the seed made again B5
X9 src/drivers/ios/seeds.ts:111 listSources / seeds.ts:604 sourceStaleReason reasons: no lineage, runtime missing or changed, device type missing adds the gone reason, after the existing ones B6
X10 src/core/doctor.ts:139 #sources; src/core/baselines.ts:303 stale check lists driver sources with staleReason; a baseline turns stale on its source's reason unchanged; picks up X9 B6
X11 src/drivers/ios/device-set-leftovers.ts:9 SWITCH_STEPS names simlock nuke --delete-devices (three messages: :27, :45, :67, and :45 once more in its own text) names simlock nuke --delete-devices --platform ios B7
X12 src/cli/commands/nuke.ts:9 flags delete-devices, yes adds platform, validated as src/cli/commands/catalog.ts:23 does B4
X13 src/daemon/dispatcher-admin.ts:52 nukeRun passes deleteDevices passes platform too I1
X14 src/gateway/dispatcher.ts:266 refuses nuke.run unchanged —

Tasks

Completion conditions: all three are delivered by #1842's Done when and its B1, B2, B5, B6, B7 tests.

Open work in the same area (searched gh pr list by changed files and gh issue list --label task:ready on 2026-11-25):

Written by an agent.

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. added
    feature:spec
    on Nov 24, 2026
  2. V3RON commented on Nov 24, 2026

    @V3RON
    ContributorAuthor

    Design posted: whole body (Problem to Existing code), one task.

    Written by an agent.

  3. V3RON commented on Nov 25, 2026

    @V3RON
    ContributorAuthor

    Spec updated: task #1842 written; Task cells name it; Tasks section filled with the open quick-seeds work it depends on (#1746, #1747, #1749).

    Written by an agent.

  4. added
    feature:planned
    and removed
    feature:spec
    on Nov 25, 2026
  5. github-actions commented on Nov 25, 2026

    @github-actions
    Contributor

    Closing: all 1 sub-issues are closed. The PR that closed the last one walks the completion conditions (delivery rule 9); reopen this if one does not hold on main. Flip its ADRs to Accepted if delivery has not.

  6. V3RON commented on Nov 25, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: #1854 (#1842)
    Parked: none
    Waiting: none
    Decided: #1842 — a lease naming a baseline whose simulator is gone → refused source <id> is stale: its simulator is gone; save it again, no clone (pending the maintainer)

    Written by an agent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature:planned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions