You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
iOS clone can skip its lineage swap when its seed is deleted between clone and swap #1731
Found by reading the code, not seen on a device yet.
provision (src/drivers/ios/seeds.ts:214) clones the seed inside the seed's turn (:227-232), then leaves the turn. Only afterwards does it swap the clone's lineage files, reading the seed's file list from ios_source_files (#swapLineage, :508-516, filesOf(seed.sourceId)).
A seed can be deleted in between. Its deletion waits only for clones that are still inside the turn (takeToDelete, :320-321). Then deleteRow drops the seed's ios_source_files rows (src/drivers/ios/source-data.ts:170-175). The clone that already left the turn then reads an empty list, swaps no files, and is handed out still naming the seed's throwaway UDID in its files and links: the state ADR 0076 exists to prevent.
Paths that delete a ready seed while a clone may be between the two steps:
a stale seed remade by another provision of the same kind (#findOrMakeSeed → #destroySeed, :324-329, :458-461), for example after a runtime build change;
destroySource (:197-212);
destroySeedsOf on runtime removal (:559-573).
What you expected
A clone's lineage swap uses the file list of the seed it was cloned from, whatever happens to that seed afterwards.
How to reproduce
Provision a kind so its seed exists.
Start a provision of that kind and hold it after the clone returns, before #swapLineage.
Destroy the seed (stale remake or destroySource) and let it finish.
Let the provision go on: the swap reads no files, and the device is returned with its lineage files unswapped.
A unit test with a fake simctl and a gate after createSimulator should show it.
The swap's debug line would read swapped 0 files and 0 links for a seed that recorded files. Surfaced while designing background seed settling (#1540), which would replace seeds routinely and widen the window.
Confirmed as reported. src/drivers/ios/index-seed-swap.test.ts, "a copy swaps every file and link its seed recorded even when the seed is destroyed between the clone and the swap", on bug/1731-repro. The test holds the provision after the clone returns, at the LaunchServices folder check, then runs destroySource on the seed to the end and lets the provision go on. The seed recorded two files and one link, and the test asserts all three.
pnpm exec vitest run --project unit src/drivers/ios/index-seed-swap.test.ts
AssertionError: first: expected '/Devices/AAAAAAAA-1111-2222-3333-BBBB…' to be '/Devices/CCCCCCCC-4444-5555-6666-DDDD…'
❯ src/drivers/ios/index-seed-swap.test.ts:259:38
Root cause
Defect. The bug is in src/drivers/ios/seeds.ts:514-515 (#swapLineage, reached from :242). It reads this.#sources.filesOf(sourceId) after the clone's turn (:227-232) has ended. A seed's deletion waits only for turns that are still open (#deleteSeedInTurn, :320-321, then deleteRow at :211, :460 or :565). So the file rows can be gone by the time the swap reads them. The swap then gets an empty list and returns a device whose files still name the seed's lineage. Nothing fails until that device boots.
Simplest fix
Read the file list inside the clone's turn and pass it to #swapLineage:
const{ files, result }=awaitthis.#seedTurns.take(seed.udid,async()=>({files: this.#sources.filesOf(seed.sourceId),result: awaitthis.#simctl.createSimulator([...],{...}),}));
...
if(seed.lineage!==undefined)awaitthis.#swapLineage(files,seed.lineage,udid);
#swapLineage(files: readonly SourceFile[], ...) then filters files instead of calling filesOf. I tried it (21 lines in seeds.ts):
pnpm exec vitest run --project unit src/drivers/ios/index-seed-{swap,sources,provision,record,throwaway}.test.ts src/drivers/ios/index-save-source-lifecycle.test.ts
Test Files 6 passed (6)
Tests 73 passed (73)
pnpm typecheck # clean
Alternatives rejected
Keep the turn open through the swap: clones of one seed would then swap one at a time, which slows parallel provisions.
Read the files together with the seed row (ReadySeed.files): this works too, but it changes findReadySeed, #namedSource and #makeSeed for the same result.
Delete a seed's file rows only after the last clone is done: this needs per-clone counting for a list that is never used after the clone.
Risk
The turn callback is now async; check that the read stays inside the turn, before any deletion queued behind it.
Activity
V3RON commentedon Nov 19, 2026
Reproduction
Confirmed as reported.
src/drivers/ios/index-seed-swap.test.ts, "a copy swaps every file and link its seed recorded even when the seed is destroyed between the clone and the swap", onbug/1731-repro. The test holds the provision after the clone returns, at the LaunchServices folder check, then runsdestroySourceon the seed to the end and lets the provision go on. The seed recorded two files and one link, and the test asserts all three.Root cause
Defect. The bug is in
src/drivers/ios/seeds.ts:514-515(#swapLineage, reached from:242). It readsthis.#sources.filesOf(sourceId)after the clone's turn (:227-232) has ended. A seed's deletion waits only for turns that are still open (#deleteSeedInTurn,:320-321, thendeleteRowat:211,:460or:565). So the file rows can be gone by the time the swap reads them. The swap then gets an empty list and returns a device whose files still name the seed's lineage. Nothing fails until that device boots.Simplest fix
Read the file list inside the clone's turn and pass it to
#swapLineage:#swapLineage(files: readonly SourceFile[], ...)then filtersfilesinstead of callingfilesOf. I tried it (21 lines inseeds.ts):Alternatives rejected
ReadySeed.files): this works too, but it changesfindReadySeed,#namedSourceand#makeSeedfor the same result.Risk
copyOverrides(seed.udid, …)at:249also runs after the turn. Today nothing deletes a seed's overrides folder, so it is safe; iOS destroySource leaves a baseline's launchd overrides folder behind #1780 would change that.Fast track
Side findings
Written by an agent.
fix(ios): a copy reads its seed's recorded files inside the seed's tu…