Idle booted Simulator device shutdown specification.
Purpose
Release CPU, memory, and graphics resources held by forgotten Apple Simulator devices without interrupting recent interactive use or supported unattended test runs.
Scope
- In scope:
- Booted devices in the current user's default CoreSimulator device set.
- User inactivity, device age, consecutive confirmation, and test automation protection.
- Exact-device shutdown through
xcrun simctl. - Local status, event history, and batched notifications.
- Out of scope:
- Erasing, deleting, or resetting Simulator devices or their data.
- Shutting down physical Apple devices.
- Per-application activity measurement inside a simulated device.
- Simulator device sets selected through a custom
--setpath. - Automatic shutdown while
xcodebuildorxctestis running for the current user.
Persistence
Entities
IdleSimulatorMonitorobservations: A map keyed by Simulator UDID with the latest device snapshot and consecutive observation count.
SimulatorDeviceudid: The canonical uppercase CoreSimulator device identifier.name: The user-visible device name.runtime: The runtime heading reported bysimctl.state:bootedfor devices returned by the scanner.last_used_at: The CoreSimulatorlastUsedAttimestamp, or unavailable.
Event- Use the existing DETS event store with target
simulators. - Store UDID, name, runtime, state, and
last_used_at. - Detection events also store the consecutive observation count.
- Skipped and failed actions store a bounded reason value.
- Use the existing DETS event store with target
Lifecycle
- A booted device old enough to qualify creates or advances an observation.
- User activity, supported test automation, a changed
lastUsedAttimestamp, shutdown, a missing device, or an unavailable scan clears the incomplete sequence. - Three consecutive observations produce one exact-device shutdown action.
- A successful shutdown removes the device from future scans.
- A failed or skipped action requires a new three-observation sequence before another attempt.
Constraints and Indexes
- User inactivity must be at least 30 minutes.
- Device
lastUsedAtage must be at least 30 minutes. - Confirmation requires three consecutive five-minute full check rounds.
- Missing or invalid
lastUsedAtdata makes a device non-actionable. - A current-user
xcodebuildorxctestprocess blocks shutdown for every device in that round. - Actions use one validated UDID and never use the
allalias. - The device must still be booted with the same
lastUsedAtimmediately before shutdown. - The monitor must not create atoms from device or process metadata.
Retention and Privacy
- Monitor state and events stay in the existing local Canaryd DETS files.
- Existing event retention behavior applies.
- Device data paths, process arguments, application data, and test output are not persisted.
Relationships
Canaryd.Checkerruns the monitor during the five-minute full health check.Canaryd.System.idle_duration/0supplies whole-Mac keyboard and pointer inactivity.Canaryd.Simulatorsreads CoreSimulator state, detects supported automation, revalidates device identity, and performs shutdown.- Thermal, idle-memory, unresponsive-app, and CleanClip policies remain independent.
Behavior
- While the user has been inactive for less than 30 minutes, skip Simulator collection and clear incomplete observations.
- List booted devices with
xcrun simctl list devices booted. - Read each device's CoreSimulator
lastUsedAttimestamp. Treat it as a device-age guard, not as proof of per-device input activity while booted. - Inspect current-user process names without storing arguments.
- If
xcodebuildorxctestis active, clear incomplete observations and do not shut down any device. - Keep only booted devices whose
lastUsedAtage is at least 30 minutes. - Require three consecutive eligible observations for the same UDID and
lastUsedAtvalue. - Immediately before acting, recheck whole-Mac inactivity and supported test automation.
- Re-list booted devices and require the exact UDID and unchanged
lastUsedAtvalue. - Run
xcrun simctl shutdown <UDID>for each confirmed device. - Never run
simctl erase,simctl delete, orsimctl shutdown all. - Log every detection, shutdown, skipped action, and failed action.
- Batch successful or failed device names into at most one notification for each result class per check round.
- Expose pending devices through
canaryd statusand events throughcanaryd history simulators.
BDD Scenarios
BDD-01 Shut down a sustained idle Simulator
Given:
- The user has been inactive for at least 30 minutes.
- A Simulator device has been booted or last used for at least 30 minutes.
- No current-user
xcodebuildorxctestprocess is active.
When:
- The same UDID and
lastUsedAtvalue remain eligible for three consecutive full checks.
Then:
- Canaryd revalidates the safety signals and exact device identity.
- Canaryd runs
simctl shutdownfor that UDID. - Canaryd preserves the device and all of its data.
BDD-02 Reset transient observations
Given:
- A booted Simulator has one or two eligible observations.
When:
- The user becomes active, test automation starts, the device timestamp changes, the device shuts down, or collection becomes unavailable.
Then:
- Canaryd clears the incomplete sequence.
- A later eligible sample starts again at one.
BDD-03 Protect active automation and unverifiable devices
Given:
- A current-user
xcodebuildorxctestprocess is active, or a device lacks a validlastUsedAtvalue.
When:
- Canaryd runs a full check.
Then:
- Canaryd does not shut down that Simulator device.
- Canaryd does not erase, delete, or mutate device data.
Search
- Not applicable.
AI
- Not applicable.
Cross-Spec Links
Open Questions
- Expand the automation blocker list only when a new tool has a stable, low-false-positive process identity.