Run a virtual iPhone on an Apple Silicon Mac.
Swift
Keep generativeexperiencesd out of the trimmed service profile
Jacky2c8ac5c8b22d
diff --git a/Research/Guest/service_trimming.md b/Research/Guest/service_trimming.mdindex e65738ce..11a57fcf 100644--- a/Research/Guest/service_trimming.md+++ b/Research/Guest/service_trimming.md@@ -44,7 +44,7 @@ load a disabled job at the next boot. It is the same mechanism| Group | Default | Labels | Why they can go || --- | --- | --- | --- |-| `base` | on | 134 | Appendix A of the measurement below, less `siriactionsd` (list version 2), `passd` and `financed` (list version 3). Nothing in vphone, IcliKit or the guest hooks talks to them |+| `base` | on | 133 | Appendix A of the measurement below, less `siriactionsd` (list version 2), `passd` and `financed` (list version 3), `generativeexperiencesd` (list version 4). Nothing in vphone, IcliKit or the guest hooks talks to them || `app_store` | on | `com.apple.appstored`, `com.apple.itunesstored` | Off with the App Store and iTunes Store apps a template removes. `appstorecomponentsd` is already in `base` || `signin_followup` | on | `com.apple.followupd`, `com.apple.appleidsetupd` | The sign-in follow-up and Apple Account setup prompts. They complement `libsigninfix`'s pane suppression. A guest that went through `setup.skip` has no follow-up items, so no orphaned badge is left || `accounts` | off, `groups: ["accounts"]` | `com.apple.akd`, `com.apple.amsaccountsd`, `com.apple.appleaccountd` | Only for guests that never sign in: with these off, the guest cannot sign in to an Apple Account |@@ -53,7 +53,7 @@ The `base` group, by area:| Area | Examples | Kind || --- | --- | --- |-| Siri and intelligence | assistantd, siriinferenced, intelligenceflowd, modelmanagerd, corespeechd | Not used. corespeechd and modelmanagerd serve dictation. siriactionsd stays: see below |+| Siri and intelligence | assistantd, siriinferenced, intelligenceflowd, modelmanagerd, corespeechd | Not used. corespeechd and modelmanagerd serve dictation. siriactionsd and generativeexperiencesd stay: see below || Photos and media analysis | mediaanalysisd, photoanalysisd, photosface | mediaanalysisd alone wrote 79 MiB in a 15-minute idle window || Ads, content and recommendations | amsengagementd, promotedcontentd, tipsd, weatherd, gamed | amsengagementd was the top idle CPU and write consumer || Find My | findmydeviced, searchpartyd, findmylocated, fmflocatord | No Apple Account |@@ -89,6 +89,19 @@ killed it; with passd running but financed disabled, the synchronous call neverreturned and the same watchdog fired. With both running Wallet opens; passdkeeps retrying nfcd, which stays disabled, at about 0.02 CPU-seconds a minute.+**generativeexperiencesd stays (list version 4, 2026-11-02).** It serves+`com.apple.generativeexperiences.ExternalProviderService`, and with it+disabled `BackgroundShortcutRunner` reconnects to that service with no back-off+(`EPS failed to resubscribe to provider changes`, NSCocoaErrorDomain 4099,+after each failed bootstrap look-up), while launchd answers every look-up. On+three idle iPhone17,3 27.0.1 guests built `trimmed+accounts`,+BackgroundShortcutRunner used about 9 CPU-seconds and launchd about 4.5 in a+12-second window, and each VM held the host at about 130% CPU. With the label+enabled and the guest restarted, the whole guest used 0.3 to 0.5 CPU-seconds+per 10 seconds, the VM 17% or less, and generativeexperiencesd stayed quiet+([#791](https://github.com/Lakr233/vphone-cli/issues/791)). It is now in+`neverDisable`, on 26 as well as 27.+Some of these are only optional: Shortcuts, dictation, HomeKit, Maps,Mail, Reminders, iMessage and Safari bookmark sync. A research target thatuses one of those frameworks needs its daemon back. Pass that label in `allow`@@ -105,12 +118,13 @@ not measured there. Any other version gets "No trimmed service list".## Never disabled`GuestServiceProfile.neverDisable` lists what the profile refuses to disable,-whatever list or group names it. Four kinds of job were measured to make the+whatever list or group names it. Five kinds of job were measured to make theguest **worse** when off, and are kept out of the lists for that reason:| Job | What happens without it | Evidence || --- | --- | --- || `com.apple.sleepd` | SpringBoard's and mobiletimerd's HealthKit sleep clients (`HKSPXPCConnectionProvider`) reconnect to `com.apple.sleepd.sleepserver` with no back-off | 5000 log lines in 3 s, host at about 400% CPU, launchd used 115 s of CPU and wrote 385 MiB in the first two minutes |+| `com.apple.generativeexperiencesd` | `BackgroundShortcutRunner` reconnects to `com.apple.generativeexperiences.ExternalProviderService` with no back-off | About 9 CPU-seconds per 12 s in BackgroundShortcutRunner and 4.5 in launchd; about 130% host CPU per idle 27.0.1 VM (#791) || `com.apple.CommCenter`, `CommCenterMobileHelper`, `CommCenterRootHelper` | SpringBoard's `SBTelephonyManager` reconnects to `com.apple.commcenter.xpc` every second and resets the idle timer each time (`updateIdleTimerForReason:"TelephonyManager:UpdateSB"`), so **the screen never turns off** | A 1 Hz loop in the log; backboardd grew from 99 to 160 MB; SpringBoard took 4418 wakeups in two minutes || `com.apple.cloudd` | transparencyd (`Retrying CK account state fetch`) and ScreenTimeSettingsAgent keep retrying CloudKit | Each wrote 50–60 MiB per 15 idle minutes, against nothing on the untrimmed guest. Idle writes rose above the untrimmed guest's, to 337 MiB per 15 minutes || `com.apple.nanoregistryd`, `nanoregistrylaunchd` | locationd waits synchronously on NanoRegistry's management queue | A spindump of a hung locationd showed `com.apple.nanoregistry.registry.managementqueue` in `dispatch_sync`. 27.0's locationd also hangs and crashes on its own, so this is kept out of caution |@@ -215,7 +229,7 @@ How it was derived:So `trimmed` on 26 disables 131 + 2 + 2 = 135 labels (`GuestServiceProfile.base26`,`notLoadedOn26`). The never-disabled set needed nothing new: no job of the-list made the guest worse when off, and the four traps of 27 are kept on 26 as+list made the guest worse when off, and the traps of 27 are kept on 26 ason 27 without being measured again.| After 17 minutes idle | Untrimmed | Trimmed (131 + store + follow-up) | Change |diff --git a/Research/vphoned_http_api.md b/Research/vphoned_http_api.mdindex 8c73b7ef..70556670 100644--- a/Research/vphoned_http_api.md+++ b/Research/vphoned_http_api.md@@ -778,8 +778,8 @@ with the same override as `services.disable`; launchd honors it from the nextboot, so the guest has to restart. `apply {profile, groups?, allow?}`:- `profile: "trimmed"` disables the default groups of the list for the- guest's iOS major version (`base`, the 137 labels measured on iOS 27.0, or- on iOS 26 the 131 of them 26.6.2 loads;+ guest's iOS major version (`base`, the 133 labels measured on iOS 27.0, or+ on iOS 26 the 127 of them 26.6.2 loads;`app_store`, appstored and itunesstored; `signin_followup`, followupd andappleidsetupd), plus the optional groups named in `groups` (`accounts`:akd, amsaccountsd, appleaccountd, after which the guest cannot sign in to an@@ -790,7 +790,8 @@ boot, so the guest has to restart. `apply {profile, groups?, allow?}`:- A label already disabled by somebody else (the OTA block, a user in theServices panel) is skipped and never recorded, so `none` leaves it disabled.A recorded label the profile no longer selects is turned back on. The jobs- in `GuestServiceProfile.neverDisable` (sleepd, CommCenter and its helpers,+ in `GuestServiceProfile.neverDisable` (sleepd, generativeexperiencesd,+ CommCenter and its helpers,cloudd, NanoRegistry, mobileassetd, storekitd, vphoned, and what vphone'sfeatures use) are refused whatever names them.- The labels the profile owns go to `/var/db/vphoned/service-profile.plist`diff --git a/VPhoneDaemon/Daemon/GuestServiceProfile.swift b/VPhoneDaemon/Daemon/GuestServiceProfile.swiftindex c37152f5..13db60b8 100644--- a/VPhoneDaemon/Daemon/GuestServiceProfile.swift+++ b/VPhoneDaemon/Daemon/GuestServiceProfile.swift@@ -21,7 +21,7 @@ import Foundationenum GuestServiceProfile {/// Raised whenever a label list changes, and kept in the record, so a/// guest shows which list its overrides came from.- static let listVersion = 3+ static let listVersion = 4static let recordPath = "/var/db/vphoned/service-profile.plist"static let trimmed = "trimmed"static let none = "none"@@ -82,8 +82,9 @@ enum GuestServiceProfile {/// Appendix A of the 2026-10-07 measurement on `svctest-a` (iPhone, 27.0/// 24A435): the LaunchDaemons that were loaded at boot and stayed unloaded/// after the override, with the four traps below already taken out: 137,- /// less siriactionsd since list version 2 and passd and financed since- /// list version 3 (see `neverDisable`).+ /// less siriactionsd since list version 2, passd and financed since list+ /// version 3 and generativeexperiencesd since list version 4 (see+ /// `neverDisable`).static let base27: [String] = ["com.apple.CallHistorySyncHelper","com.apple.Maps.mapspushd",@@ -136,7 +137,6 @@ enum GuestServiceProfile {"com.apple.fitnesscoachingd","com.apple.fitnessintelligenced","com.apple.gamed",- "com.apple.generativeexperiencesd","com.apple.geoanalyticsd","com.apple.hangtelemetryd","com.apple.homed",@@ -244,18 +244,21 @@ enum GuestServiceProfile {/// Jobs the profile refuses to disable, whatever list or group names them.///- /// The first four kinds were measured to make things worse when off: without+ /// The first five kinds were measured to make things worse when off: without/// sleepd, SpringBoard and mobiletimerd reconnect to it with no back-off- /// (about 400% host CPU); without CommCenter, SpringBoard reconnects every- /// second and resets the idle timer, so the screen never sleeps; without- /// cloudd, transparencyd and ScreenTimeSettingsAgent retry CloudKit and- /// write more than the untrimmed guest; without NanoRegistry, locationd- /// waits on it synchronously. The rest are what vphone's own features and- /// the tools it drives (Xcode, DeviceHub, ideviceinstaller, Frida, crash- /// logs, camera and audio) rely on.+ /// (about 400% host CPU); without generativeexperiencesd,+ /// BackgroundShortcutRunner does the same to its ExternalProviderService+ /// (about 130% host CPU on iOS 27); without CommCenter, SpringBoard+ /// reconnects every second and resets the idle timer, so the screen never+ /// sleeps; without cloudd, transparencyd and ScreenTimeSettingsAgent retry+ /// CloudKit and write more than the untrimmed guest; without NanoRegistry,+ /// locationd waits on it synchronously. The rest are what vphone's own+ /// features and the tools it drives (Xcode, DeviceHub, ideviceinstaller,+ /// Frida, crash logs, camera and audio) rely on.static let neverDisable: Set<String> = [// Worse when disabled."com.apple.sleepd",+ "com.apple.generativeexperiencesd","com.apple.CommCenter", "com.apple.CommCenterMobileHelper", "com.apple.CommCenterRootHelper","com.apple.cloudd","com.apple.nanoregistryd", "com.apple.nanoregistrylaunchd",diff --git a/VPhoneDaemon/Tests/LogicTests.swift b/VPhoneDaemon/Tests/LogicTests.swiftindex c4b7b562..56851422 100644--- a/VPhoneDaemon/Tests/LogicTests.swift+++ b/VPhoneDaemon/Tests/LogicTests.swift@@ -113,8 +113,8 @@ enum LogicTests {static func profileCatalog() {let groups = GuestServiceProfile.groups27- expectEqual(GuestServiceProfile.base27.count, 134, "appendix A less siriactionsd, passd and financed")- expectEqual(Set(GuestServiceProfile.base27).count, 134, "appendix A has no duplicates")+ expectEqual(GuestServiceProfile.base27.count, 133, "appendix A less siriactionsd, passd, financed and generativeexperiencesd")+ expectEqual(Set(GuestServiceProfile.base27).count, 133, "appendix A has no duplicates")let all = groups.flatMap(\.labels)expectEqual(Set(all).count, all.count, "no label is in two groups")for label in all + GuestServiceProfile.neverDisable {@@ -132,7 +132,7 @@ enum LogicTests {static func profileCatalog26() {let base26 = GuestServiceProfile.base26- expectEqual(base26.count, 128, "134 minus six 26.6.2 does not load")+ expectEqual(base26.count, 127, "133 minus six 26.6.2 does not load")expectEqual(Set(base26).count, base26.count, "no duplicates")expect(Set(base26).isSubset(of: GuestServiceProfile.base27), "26 adds no label of its own")expect(GuestServiceProfile.notLoadedOn26.isSubset(of: GuestServiceProfile.base27), "only 27 labels are left out")@@ -154,33 +154,42 @@ enum LogicTests {static func profileSelection() {let trimmed = try? GuestServiceProfile.select(profile: "trimmed", iosMajor: 27)- expectEqual(trimmed?.labels.count, 138, "default trimmed = 134 + 2 store + 2 follow-up")+ expectEqual(trimmed?.labels.count, 137, "default trimmed = 133 + 2 store + 2 follow-up")expectEqual(trimmed?.groups, ["base", "app_store", "signin_followup"])expect(trimmed?.labels.contains("com.apple.followupd") == true, "followupd is in trimmed")expect(trimmed?.labels.contains("com.apple.akd") == false, "akd is not in trimmed by default")expect(trimmed?.labels.contains("com.apple.siriactionsd") == false, "siriactionsd serves App Intents controls")expect(GuestServiceProfile.neverDisable.contains("com.apple.siriactionsd"), "siriactionsd is never disabled")expect(trimmed?.labels.contains("com.apple.passd") == false && trimmed?.labels.contains("com.apple.financed") == false, "Wallet's daemons stay")+ expect(trimmed?.labels.contains("com.apple.generativeexperiencesd") == false, "BackgroundShortcutRunner spins without it")+ if let labels = trimmed?.labels {+ // A guest trimmed by list version 3 owns it; applying again turns it back on.+ let v3 = labels + ["com.apple.generativeexperiencesd"]+ let change = GuestServiceProfile.reconcile(+ target: labels, owned: v3, overrides: Dictionary(uniqueKeysWithValues: v3.map { ($0, true) }),+ )+ expectEqual(change.enable, ["com.apple.generativeexperiencesd"], "list version 3 guests get it back")+ }expectEqual(trimmed?.labels, trimmed?.labels.sorted(), "labels sorted")let accounts = try? GuestServiceProfile.select(profile: "trimmed", iosMajor: 27, extraGroups: ["accounts"])- expectEqual(accounts?.labels.count, 141, "accounts adds three")+ expectEqual(accounts?.labels.count, 140, "accounts adds three")expect(accounts?.labels.contains("com.apple.amsaccountsd") == true, "amsaccountsd with accounts")let allowed = try? GuestServiceProfile.select(profile: "trimmed", iosMajor: 27, allow: ["com.apple.weatherd", "com.example.not-listed"],)- expectEqual(allowed?.labels.count, 137, "allow removes one")+ expectEqual(allowed?.labels.count, 136, "allow removes one")expectEqual(allowed?.allowed, ["com.apple.weatherd"], "only catalog labels are reported as allowed")expect(allowed?.labels.contains("com.apple.weatherd") == false, "weatherd kept")let trimmed26 = try? GuestServiceProfile.select(profile: "trimmed", iosMajor: 26)- expectEqual(trimmed26?.labels.count, 132, "26 trimmed = 128 + 2 store + 2 follow-up")+ expectEqual(trimmed26?.labels.count, 131, "26 trimmed = 127 + 2 store + 2 follow-up")expectEqual(trimmed26?.groups, ["base", "app_store", "signin_followup"])expect(trimmed26?.refused.isEmpty == true, "the 26 list names nothing never disabled")expectEqual((try? GuestServiceProfile.select(profile: "trimmed", iosMajor: 26, extraGroups: ["accounts"]))?.labels.count,- 135, "accounts adds three on 26",+ 134, "accounts adds three on 26",)expectEqual(try? GuestServiceProfile.select(profile: "none", iosMajor: 25), GuestServiceProfile.Selection())@@ -212,8 +221,8 @@ enum LogicTests {expect(overlap.isEmpty, "\(group.name) names never-disabled \(overlap.sorted())")}for trap in [- "com.apple.sleepd", "com.apple.CommCenter", "com.apple.CommCenterMobileHelper",- "com.apple.CommCenterRootHelper", "com.apple.cloudd", "com.apple.nanoregistryd",+ "com.apple.sleepd", "com.apple.generativeexperiencesd", "com.apple.CommCenter",+ "com.apple.CommCenterMobileHelper", "com.apple.CommCenterRootHelper", "com.apple.cloudd", "com.apple.nanoregistryd","com.apple.nanoregistrylaunchd", "com.apple.mobileassetd", "com.apple.storekitd","com.apple.cfprefsd.xpc.daemon", "com.apple.SpringBoard", "com.apple.backboardd","com.apple.mobile.installd", "com.apple.lsd", "com.apple.mobileactivationd",@@ -275,7 +284,7 @@ enum LogicTests {var overrides = Dictionary(uniqueKeysWithValues: ota.map { ($0, true) })overrides["com.apple.user-choice"] = truelet apply = GuestServiceProfile.reconcile(target: trimmed.labels, owned: [], overrides: overrides)- expectEqual(apply.disable.count, 135, "138 minus the three already disabled")+ expectEqual(apply.disable.count, 134, "137 minus the three already disabled")expectEqual(apply.skipped.map(\.label), ota.sorted())let owned = GuestServiceProfile.owned(after: apply, failedDisable: [], failedEnable: [])for label in apply.disable {