Commit Graph
3 Commits
Author SHA1 Message Date
Anees IqbalandClaude cdaa8c1a67 🔧 One Return is not reliably the Return that lands, so the consent answer is a retry and belongs to the call
Component: host-side probe harness (`scripts/lib/guest-display.sh`,
`scripts/window-drag-probe/`). No device or Rust change.

`93a1fb67` answered the Apple Events consent panel once, in a dedicated step
before the probe's real work. On macos-12 that was not enough and the probe
stopped with "Safari is running but has no front window" while a screenshot
showed the panel plainly up — the same shape of misreport the commit set out to
remove, one step further along.

Two ways the single press misses, and they pull in opposite directions:

- **The panel is not up yet.** A cold application can take longer to accept its
  first Apple Event than the consent step waits, so the Return goes out before
  any modal exists and the panel is raised later, by one of the probe's own
  queries.
- **Something else takes the keystroke.** The guest desktop raises its own
  transient furniture; a software-update notification arrived during one run.

So the answer is no longer a step, it is a property of the call.
`guest_osa_consenting` runs any short AppleScript and, each time it times out,
presses the default button of whatever modal is up and tries again — three times
by default, `GUEST_CONSENT_ATTEMPTS`. `guest_apple_events_consent` is now a thin
call to it with the smallest query that raises the panel, and the drag probe's
`appwin` helper routes every frame read through it. On a guest that has already
consented nothing changes: the call returns at once and no key is pressed.

Still never blind — the keystroke goes out only after a call has been *seen* to
hang, because that remains the only evidence available that a modal is up.

Verified on a live macos-12 boot (macOS 12.7.6, x86 `reims-vgpu-pci`, KVM,
discrete NVIDIA host). Before: the probe exited 2 at the frame read. After: it
completes, and gives this rail its first driven measurement —

  present_hz / offered_hz  med 57.70  max 59.60 Hz over 25 samples
  draw_us/draw             med 133.64      flush_us/flush med 181.23
  window blocked 0, window wait_us 0 in every sample
  draws_fresh              med 59, draws_stale med 0

The last run's own line reports that the achieved motion rate bounds these, so
they are not this rail's ceiling.

Not verified: the retry was not exercised on a rail that has never consented at
all in this session — macos-12 had already consented by the time it landed, so
what is proven here is that the loop is harmless when there is nothing to answer
and that the probe now completes. Nothing on arm64. No Rust touched, so no
clippy, test or feature-matrix arm applies.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-09 11:19:11 +03:00
Anees IqbalandClaude 93a1fb67dd 🔧 Every GUI probe was written against the one rail that had been clicked through by hand
Component: host-side probe harness (`vm/guest-authorize.sh`, `scripts/lib/`,
`scripts/window-drag-probe/`). No device or Rust change; no pathway behaviour
changes.

Driving a guest's GUI needed four separate things that only the macos-13 rail
had, and each one failed in a way that read as a defect somewhere else. On
macos-11 the combined symptom was `could not read Safari's window frame (pos ''
size '')`, which reads as a compositor that produces no windows — on a rail
whose desktop was on screen at the time.

1. **Apple Events consent has a panel and nobody was answering it.** The first
   `osascript ... "System Events"` from an ssh session raises a modal on the
   guest's own screen; until it is answered the call never returns. Nothing on
   the host can see it. `vm/guest-authorize.sh` now runs a consent probe, and
   *only if that probe is seen to hang* presses Return over QMP's usb-kbd — the
   panel's default button is Allow. The keystroke is never sent blind, because a
   Return at a live desktop is not free. Self-verifying: the same call is
   retried and has to answer. `--no-automation` opts out.

2. **TCC scopes Apple Events per (client, target) pair**, so consenting System
   Events says nothing about Safari. `guest_apple_events_consent` in
   `scripts/lib/guest-display.sh` is the one implementation, called per app.

3. **The probes drove windows through System Events, which needs assistive
   access — and that has no panel to answer.** It is granted by hand in System
   Preferences, and macos-13 is the only rail where someone did. Everywhere else
   `System Events` answers `-25211` and the probe reports an app with no
   windows. Both the frame reads and `reposition.applescript` now go through the
   target application's own Standard Suite (`bounds of front window`), which
   needs only consent 1–2. `bounds` is {l,t,r,b}, so the loop carries the window
   size across steps to move without resizing.

4. **Two guest-side dependencies that are not part of macOS.** `open -a Safari
   about:blank` fails on macOS 11 — Big Sur's `open` resolves a bare argument as
   a path first, so Safari never launched; the probe now opens a local blank
   file, which also keeps the network out of a compositing measurement. And the
   reposition run was timed by a guest-side `python3`, which is a
   Command-Line-Tools stub that raises an install dialog on a rail without them
   and does not exist at all from 12.3. Timing moved to the host, so the guest
   step is `osascript` and nothing else; the ssh round trip is counted into
   elapsed, which understates the achieved rate and never overstates it.

Also: an unreadable frame now names which of the three causes it was, instead of
printing the empty string it got.

Verified on the live macos-11 rail (macOS 11.7.11, x86 `reims-vgpu-pci`, KVM,
discrete NVIDIA host), snapshot `current`. First driven measurement this rail has
ever had — `window-drag-probe --seconds 25 --app Safari` now completes:

  posted 1202 steps in 24.5 s = 49.1 Hz achieved
  present_hz  med 46.65  max 50.00      offered_hz med 46.65
  window blocked 0, window wait_us 0    draw_us/draw med 137
  module_rejected 0 across the whole boot

The device tracked the stressor: 46.7 Hz presented against a 49.1 Hz motion, so
these counters are bounded by the Apple Events round trip and are not this
device's ceiling. The probe says so itself.

Not verified: `--motion drag` still needs clang on the guest and Accessibility
trust, and neither is available on this rail — that path is unchanged and still
reports its own build failure. Nothing here was run on arm64, on macos-12/14/15/26,
or with `REIMS_GUEST_IMPORT=off`; no Rust code is touched so no clippy or
feature-matrix arm is affected.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-09 10:32:50 +03:00
Anees Iqbal 0a5b9b14ba 🐛 Every probe read the desktop size from a report macOS 12 does not produce
Component: scripts/ — the guest-facing probes (wallpaper, modal-button,
window-drag) and the new scripts/lib/guest-display.sh they share.

`system_profiler SPDisplaysDataType | grep Resolution:` was how three probes
learned the desktop's size. On the macos-12 rail that report names the GPU and
**no display at all** — no `Displays:` section, no `Resolution:` line — so all
three exited 2 before doing anything, and `visual-gate --quick` reported
SETUP-FAILED with 0/3 probes green on a rail whose desktop, Dock and menu bar
were up and rendering. The same call has been observed hanging indefinitely on
macos-11, which an unattended harness cannot tell from a wedged boot.

`guest_display_size` asks with `screencapture` plus `sips` instead. Both ship
with every macOS, neither needs root, and the answer is the stronger form of
the question a two-observation probe is asking: not what the guest's
configuration claims the display is, but how many pixels its compositor just
produced. Verified on the macos-12 rail — 1920x1080, where system_profiler
returned nothing — and the wallpaper probe now reaches its trials there.

Second failure on the same rail, same cause class: `osascript -e 'tell
application "System Events" ...'` over ssh hangs forever when the session has
not been granted Automation access, because the consent prompt is raised on the
guest's own desktop and nobody answers it. Every System Events call in every
probe hung there. `guest_osa` bounds them host-side at 15 s (GUEST_OSA_TIMEOUT),
which is the difference between a probe that reports "this rail cannot be
scripted" and one that stalls a sweep. The bound does not kill the remote
osascript; it only stops us waiting on it.

Tests: no Rust change. `bash -n` clean on all four files. Verified live against
the macos-12 rail: the size read returns 1920x1080 where the old one returned
nothing.

Not verified: the macos-11, 14, 15 and 26 rails, and the arm64 pathway. The
Automation-consent gap on macos-12 is a guest provisioning matter and is not
fixed here — the probes now report it quickly instead of hanging on it.
2026-08-09 07:55:04 +03:00