Skip to content

fix(watch): cancel a boot's slim when the device shuts down, add watch --json - #74

Merged
Interlap01 merged 2 commits into
mainfrom
fix/watch-stale-pass
Nov 17, 2026
Merged

Interlap01 merged 2 commits into
mainfrom
fix/watch-stale-pass

Conversation

@Interlap01

@Interlap01 Interlap01 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #71

What

  • Race fix. scan() called forget(udid) on shutdown but left the running after-boot pass alone. After a quick shutdown and reboot, the old pass kept retrying into the new boot and disabled services a wrapper had turned on with enable after the new pass logged slimmed. Each pass now has its own cancel (slimPass), called when the device shuts down or is deleted (prune). A superseded pass reports stopped. It no longer reports slimmed, and a late failure no longer clears the newer boot's claim, which used to start a third pass.
  • Seed after a slow shutdown. seed() marked a device seeded when a scan caught it Shutting Down, although preslimDevice writes nothing until Shutdown. That shutdown was never seeded, so services enabled during the boot carried into the next one. A device is now seeded only once it reads Shutdown.
  • watch --json. One JSON object per line on stdout, documented as stable:
    {"event":"slimmed","udid":"…","set":"default"}
    The events are slimming, slimmed, failed (with error), stopped, and slimmed_before_boot (with services). A wrapper boots the device, waits for slimmed or failed, then calls enable. Per the --json convention, stderr stays quiet.
  • Library: WatchWithEvents and WatchEvent are new. Watch keeps its signature.

Testing

  • make check passes.
  • New tests: TestWatchCancelsPassWhenDeviceShutsDown (the old pass is cancelled, events are slimming, stopped, slimming, slimmed) and TestWatchStalePassKeepsNewBootClaimed (a late failure from the old pass doesn't start a third pass or report failed).
  • The watcher tests pass under -race -count=3.
  • TestWatchSeedsDeviceScannedMidShutdown fails without the seed fix.
  • Seed fix checked against a real iOS 27.0 simulator: with store enabled live, a real simctl shutdown was scanned by the watcher. The old code caught Shutting Down and wrote 0 disables (0/14 store services off). The fixed code wrote all 14, and the next boot passed simslim verify.
  • The cancellation fix is covered by unit tests only.

…h --json

A device shut down mid-pass and booted again kept its old after-boot pass
running: forget() dropped the claim but not the pass, so its retries ran
into the new boot and disabled services a wrapper had enabled after the
new boot's pass finished. Each pass now has its own cancel, called on
shutdown or deletion, and a superseded pass reports stopped instead of
slimmed or clearing the newer boot's claim.

watch --json prints one WatchEvent per line on stdout (slimming, slimmed,
failed, stopped, slimmed_before_boot), a stable signal for wrappers that
wait for a boot's slim before calling enable.

Fixes #71
seed() marked a Shutting Down device as seeded although preslimDevice
writes nothing until Shutdown, so that shutdown was never seeded and
services enabled during the boot carried into the next one.
@Interlap01
Interlap01 merged commit 7883f31 into main Nov 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

watch: a stable way to know a device's boot has been slimmed (for wrappers that enable services per run)

1 participant