Skip to content

Grant app permissions on open and add simulator data steps - #175

Merged
bitomule merged 1 commit into
setup-installs-every-driverfrom
open-permissions-and-sim-steps
Dec 3, 2026
Merged

bitomule merged 1 commit into
setup-installs-every-driverfrom
open-permissions-and-sim-steps

Conversation

@bitomule

@bitomule bitomule commented Dec 3, 2026

Copy link
Copy Markdown
Owner

Closes #152. Closes #160.

Stacked on #172 (setup installs every simulator driver). Review only the top commit here; once #172 lands this PR's base moves to main.

Permissions on open (#152)

mav open --clear-state --permissions notifications=allow,location=always,photos=allow
mav open --permissions all
- open: { clearState: true, permissions: { notifications: allow, location: always, camera: allow } }
- open: { permissions: all }
  • Granted after install (a clearState reinstall would wipe them) and before the fixture and the launch (simctl privacy terminates a running app, and a prompt already shown is too late).
  • xcrun simctl privacy sets calendar, contacts (allow|limited), location (always|inuse), media-library, microphone, motion, photos (allow|add), reminders and siri, each with allow|deny|unset. It has no notifications or camera service, so those two go through idb: idb approve for allow, idb revoke for unset.
  • Notifications and camera take no deny. On an iOS 26.4 simulator idb revoke put both back to notDetermined (the app asks again), not to denied, and no other tool can store a refusal for them. A deny is refused at lint time and on the command line instead of being reported as applied.
  • all = simctl privacy grant all + idb approve notification camera.
  • The whole set is routed before anything runs: without idb, notifications=allow fails with permissions_driver_missing service=notifications next="mav setup --install idb" before anything is installed, granted or launched. Other refusals: permissions_invalid, permissions_unsupported_on_device|macos, and --no-relaunch cannot be combined with --permissions.
  • The ok line reports permissions=<canonical spec> and permissions_drivers=camera:idb,location:simctl,...; each driver call goes to the run's command trail.

Simulator data steps (#160)

Step / command Driver Fallback
sim.keychain.clear / mav sim keychain clear simctl keychain reset idb clear-keychain
sim.media.add { files } / mav sim media add simctl addmedia idb add-media
sim.push { payload, bundle? } / mav sim push simctl push idb notification send
sim.memoryWarning / mav sim memory-warning idb simulate-memory-warning —

The issue listed some of these as idb-only, but simctl already covers keychain reset, addmedia (photos, videos, vCard contacts) and push. So they follow the router: simctl is canonical and idb is the fallback. idb is routed only the surfaces it alone covers (notifications, camera, memory warning), and AXe 2 stays the driver for the tree, taps, typing and gestures. Paths in steps are relative to the flow file. Each step record names its driver. The steps use the sim.* prefix like the existing simulator-only steps.

New capabilities are declared in drivers/simdata.go and implemented in simctl/simdata.go and idb/simdata.go, on simulator targets only. mav doctor reports sim_permissions_driver, sim_notification_permission_driver, sim_camera_permission_driver, sim_keychain_driver, sim_media_driver, sim_push_driver and sim_memory_warning_driver (or missing and sim_data_next). The CLI logic lives in new files (permissions.go, sim_data.go); cli.go and launch.go only gain dispatch, help and one hook in the launch recipe.

Validation

make check passes (gofmt, go test ./..., build).

Ablations: each fix was reverted, its tests went red, and went green again once restored:

== 1: no permissions step in the launch recipe
--- FAIL: TestOpenGrantsPermissionsBetweenInstallAndLaunch
--- FAIL: TestOpenPermissionsAllGrantsEverySimctlServiceAndTheIDBOnes
--- FAIL: TestFlowOpenStepGrantsItsPermissions
== 2: flow open does not pass permissions
--- FAIL: TestFlowOpenStepGrantsItsPermissions
== 3: no routing before the recipe
--- FAIL: TestOpenPermissionsWithoutIDBFailsBeforeTouchingTheSimulator
== 4: sim.* paths not resolved against the flow
--- FAIL: TestSimDataFlowStepsRunWithPathsRelativeToTheFlow
== 5: idb does not provide the simulator data capabilities
--- FAIL: TestGolden_DoctorAxeAndIdb
--- FAIL: TestOpenGrantsPermissionsBetweenInstallAndLaunch
--- FAIL: TestSimDataCommandsRouteToSimctlFirstAndIDBForWhatOnlyItHas
== restored
ok  github.com/bitomule/mav/internal/mav

On a dedicated iOS 26.4 simulator (iPhone 17 Pro, idb_companion 1.7.x), with a probe app that shows its own authorization status:

  • Before any grant: notifications=0 camera=0 microphone=0 photos=0 location=0.
  • After the commands --permissions notifications=allow,camera=allow,microphone=allow,photos=allow,location=always issues: notifications=2 camera=3 microphone=3 location=3 (authorized / always). For photos, TCC.db holds kTCCServicePhotos = 2 for the app; the ad-hoc-signed probe still read notDetermined from PhotoKit, which is simctl/iOS behaviour and not mav's.
  • After idb revoke notification camera and simctl revoke: notifications=0 camera=0 (back to undecided) and microphone=2 location=2 (denied). That measurement is why notifications and camera take unset and not deny.
  • mav sim keychain clear|media add|push|memory-warning and a mav run of a flow with the four sim.* steps all returned ok (driver=simctl for the first three, idb for the memory warning), in 0.5 s for the flow.

open --permissions (and open: { permissions: ... } in a flow) grants app
permissions after install and before the fixture and launch, so a flow
never meets their prompts. simctl privacy sets the services it covers;
notifications and camera, which simctl has no service for, go through
idb approve/revoke. The whole set is routed before anything runs, so a
request that needs a missing idb fails up front instead of half-granted.

New sim.* steps and mav sim commands cover the keychain, the media
library, push payloads and memory warnings. Each is routed by
capability: simctl serves keychain reset, addmedia and push, with idb
as the fallback, and idb is the only driver for the memory warning.
doctor reports the driver for each surface.

Closes #152. Closes #160.
@bitomule
bitomule force-pushed the setup-installs-every-driver branch from 3a3264d to ffcdc72 Compare December 3, 2026 00:13
@bitomule
bitomule force-pushed the open-permissions-and-sim-steps branch from 477b961 to 9c92d28 Compare December 3, 2026 00:13
@bitomule
bitomule merged commit a13a3de into setup-installs-every-driver Dec 3, 2026
1 check passed
bitomule added a commit that referenced this pull request Dec 3, 2026
open --permissions (and open: { permissions: ... } in a flow) grants app
permissions after install and before the fixture and launch, so a flow
never meets their prompts. simctl privacy sets the services it covers;
notifications and camera, which simctl has no service for, go through
idb approve/revoke. The whole set is routed before anything runs, so a
request that needs a missing idb fails up front instead of half-granted.

New sim.* steps and mav sim commands cover the keychain, the media
library, push payloads and memory warnings. Each is routed by
capability: simctl serves keychain reset, addmedia and push, with idb
as the fallback, and idb is the only driver for the memory warning.
doctor reports the driver for each surface.

Closes #152. Closes #160.
bitomule added a commit that referenced this pull request Dec 3, 2026
…driver (#172)

* Install every simulator driver with setup deps and drop preferred_ui_driver

mav setup --install deps now installs AXe 2, baguette and idb. After each
install it checks the tool with the driver's own probe, runs an explicit
brew upgrade for one left below mav's floor, and fails with the floor and
the next command when the upgrade does not reach it. idb setup fails when
pipx is missing instead of installing the companion alone.

preferred_ui_driver was written by setup but never read by the router. It
is no longer asked or written; a config that still carries it loads, and
doctor reports it as config_deprecated.

Part of #160.

* Grant app permissions on open and add simulator data steps (#175)

open --permissions (and open: { permissions: ... } in a flow) grants app
permissions after install and before the fixture and launch, so a flow
never meets their prompts. simctl privacy sets the services it covers;
notifications and camera, which simctl has no service for, go through
idb approve/revoke. The whole set is routed before anything runs, so a
request that needs a missing idb fails up front instead of half-granted.

New sim.* steps and mav sim commands cover the keychain, the media
library, push payloads and memory warnings. Each is routed by
capability: simctl serves keychain reset, addmedia and push, with idb
as the fallback, and idb is the only driver for the memory warning.
doctor reports the driver for each surface.

Closes #152. Closes #160.
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.

1 participant