Skip to content

native-review: run the desktop journey on a headless macOS VM - #2

Closed
jedwards27 wants to merge 13 commits into
orbit/native-review-basefrom
orbit/native-review-on-blox
Closed

jedwards27 wants to merge 13 commits into
orbit/native-review-basefrom
orbit/native-review-on-blox

Conversation

@jedwards27

@jedwards27 jedwards27 commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

What this is

This makes block/buzz's native review harness (tools/native-review) run end to end on a headless macOS workstation (ec2-macos, no Docker), and scripts the hand fixes that were needed to get there. After it, one setup script plus review-native run tools/native-review/desktop/composer-keyboard.yaml passes all 8 steps on a fresh workstation and writes a receipt and a video.

The latest revision answers a review of the first version: the macOS prompt auto-answer is now limited to the system's own privacy prompt for this run, the setup script no longer trusts whatever is listening on a port (and will not reset a database it did not create), and the window move is checked instead of assumed.

The problem

On a fresh ec2-macos workstation the harness could not get past step 3 (reach_seeded_channel). Five separate things were in the way, and only the first two were environment gaps; the rest were harness bugs that a UI journey never hit on a developer Mac.

# What broke Effect Fix
1 No Docker, so no Postgres, Redis or MinIO for the isolated relay the relay could not start bin/setup-macos-vm runs them natively; BUZZ_HARNESS_NATIVE_SERVICES=1 in scripts/start-isolated-test-relay.sh skips docker compose
2 A TLS-intercepting proxy makes the sherpa-onnx-sys build fail with UnknownIssuer; pub.dev is blocked for iOS the app (and the iOS runner) could not build setup prefetches the archive and SHERPA_ONNX_ARCHIVE_DIR now reaches host builds (never the reviewed app); PUB_HOSTED_URL passes through ios_review.py's allowlist
3 A first-run macOS microphone prompt appears when the app starts and freezes its web view blank window, then step 3 fails with "no accessibility element matched" setup triggers the prompt once and declines it; the driver also answers it while the window comes up (now only when it positively identifies it, see below)
4 The probe server wanted its token in a request header, but the page publishes with navigator.sendBeacon, which cannot set headers every semantic snapshot got a 401 token now travels in the probe URL's query (header still accepted, compared in constant time)
5 The probe client sent a frame at -1px, and the server rejects a whole snapshot if any node leaves the viewport every snapshot after the loading screen got a 400 the probe clips each frame to the viewport and skips nodes with no visible part

Also fixed: the review window opened on a secondary display (where WebKit exposes no accessibility tree), and the accessibility window can appear a moment after the compositor's.

What changed after review

Review finding Change
The prompt auto-answer matched "local network" in any app's window and pressed any button titled "Allow". answer-privacy-prompt replaces it. It presses a button only when all of these hold: the window is owned by the macOS system prompt agent (com.apple.UserNotificationCenter, executable under /System/Library/CoreServices/UserNotificationCenter.app); it is a system alert (AXWindow with subrole AXSystemDialog, not a sheet or document window); its text parses as a microphone, camera or Local Network prompt; the app it names is one of this run's own processes (the driver's ancestry, the process macOS holds responsible for the driver, the app under review, or a trigger child passed with --expect); and exactly one button has the expected title. Otherwise it does nothing and logs why. Tests cover each ownership check (wrong owner, wrong path, .. traversal, sheet, another app's prompt, missing or duplicate button), not only the text matcher.
The setup script assumed an open port was its own, and the relay script's DROP SCHEMA public CASCADE could hit whatever owns localhost:5471. setup-macos-vm writes a marker file in its state dir, starts each service with a pidfile there, and refuses to reuse a port that is open but whose listener is not that pid. It comments the buzz database as the harness database. bin/check-harness-database (data directory equals the state dir's own, marker file present, database marker present; fails closed) runs in setup and in the relay script before the schema reset, and the relay script refuses native mode without BUZZ_HARNESS_STATE_DIR. The 3030 relay is only reused if it is the harness's tmux session.
The setup script should not run outside a VM. It refuses unless sysctl -n kern.hv_vmm_present is 1 (on the workstation: 1, hw.model VirtualMac2,1), unless --allow-non-vm is passed.
The window move was not verified, and moved the first accessibility window while the harness reports the largest on-screen one. The driver moves the accessibility window whose frame matches the window the harness reports (no fallback to "the first"), reads the frame back through the same reporting path, and fails the run unless it is wholly on the main display. Before and after frames are recorded in the receipt at provenance.initial_window.placement.
Stale comment in the relay script; typo in the setup script. The comment above the reset and the teardown message now describe native mode correctly; "is may be" fixed.

Found while re-proving, and fixed in this revision: answer-first-run-prompts could wait forever on a trigger child blocked behind an unanswered prompt (it ignores SIGTERM; now escalates to SIGKILL), and a review started detached (the launcher no longer in the parent chain) left its own microphone prompt alone and froze, because the prompt names the process macOS holds responsible, not necessarily an ancestor. The driver now counts that responsible process as the run's own. Both were caught by the stricter identification, which is how it should fail: closed.

Why it matters

Native review is how an agent proves a desktop change in the real app, with a receipt and a video a reviewer can check. Until this, that only worked on a developer's own Mac; on a workstation it failed with an error that pointed at the wrong thing while the real causes were a frozen app and a probe that silently rejected every update. Severity: medium. Nothing here affects the shipped app (the only product-side file is a test-only probe module), but the native review gate could not run on a workstation without it. The review follow-ups matter because a harness that presses buttons on any dialog, or resets a database on a port it did not start, is a risk to whatever else is on the machine.

Proof

All runs on one fresh ec2-macos workstation (a virtual machine, macOS 26.6.2, arm64), now deleted. The base has no setup script, so the services and isolated relay were started from this PR's setup-macos-vm --skip-prompts, then the checkout was moved to the base. The microphone permission was reset before each run.

Before (base 87433cd96) After (head 041c5ebff)
Result Run A (base as shipped): fails before the app starts. The base scrubs the build environment, so SHERPA_ONNX_ARCHIVE_DIR never reaches tauri build and the sherpa download fails behind the proxy. Run B (same base, archive supplied through the machine's cargo config, no repo change): FAILED at step 3, reach_seeded_channel: postcondition not met within 15000ms: {'exists': {'id': 'message-composer'}} PASSED, all 8 steps
Receipt status: failed, dirty: false (each run has its own receipt, report, log and screenshots) status: passed, dirty: false, head 041c5ebff, cleanup passed, video and share video written
Window placement not recorded moved: true, verified: true; before x -1, y 30, 1442x792, after x 0, y 69, 1440x792 on a 1440x900 main display
Setup not applicable exit 0 from a clean state; a real microphone prompt naming the launcher was found and declined by the new driver

Before (run B, step 3): the app is up but its web content never exposes message-composer.

Before: step 3 fails, composer not in the accessibility tree

After: step 3 reaches the seeded channel.

After: seeded channel reached

After: step 5, with the draft typed into the composer.

After: draft typed into the composer

The safety checks, on the real workstation (output in the evidence notes): re-running setup with its own services passes the database check; running setup with a different state dir while :5471 belongs to the first refuses with "already in use by something this script did not start"; the relay script in native mode with the wrong state dir refuses before any DROP SCHEMA ("server on :5471 runs from ..., not the harness data dir"), and with no state dir refuses outright; the database kept its 91 tables.

Allow path, for real: a small program that sends mDNS and connects to a LAN address raised the genuine macOS prompt Allow "<launcher process>" to find devices on local networks?, and answer-privacy-prompt --expect <trigger> pressed Allow on it ({"ok":true,"answered":true,"button":"Allow", ...}). That was a manual trigger, not part of the journey: dns-sd, which setup uses as its Local Network trigger, did not raise it on this workstation, and by the final run the answer was already remembered, so the journey itself never showed one. The Decline path ran for real inside the proof: setup found the genuine microphone prompt and pressed Don't Allow.

How tested

  • Level: real app, real relay, on a real macOS workstation, plus unit tests.
  • Head tested: 041c5ebffad90ef3026317ce698c450fef8d1f77, checked out clean (dirty: false). The PR head is now 6c31ad993, one test-only commit later: it renames a process name in the Swift prompt fixtures (DriverSupportTests.swift) so no environment-specific name is committed; no other file differs. The workstation was deleted before that commit, so the passing run is against 041c5ebff.
  • After run: reset the microphone permission, tools/native-review/bin/setup-macos-vm (exit 0), then review-native run tools/native-review/desktop/composer-keyboard.yaml, started detached.
  • An earlier attempt on a207f23e4 failed at step 3 with "timed out after 30s waiting for web content accessibility": run detached, the driver (correctly, under the old rule) left the launcher's microphone prompt alone. That is the bug fixed by the responsible-process change in 041c5ebff; the receipt for it is not part of the proof.
  • Unit tests: Python 106 pass (tools/native-review/tests, now including real-script tests of the VM guard, the database check and the relay script's reset guard against stub psql/sysctl), Swift 18 pass (swift test), plus the pre-push lanes (desktop typecheck, biome, desktop tests, rust tests).
  • Sherpa archive mirror: setup-macos-vm downloads the archive from GitHub releases by default; SHERPA_ONNX_DOWNLOAD_BASE points the same path layout at a caching mirror, and the script logs the curl line, HTTP status and size. Proven on a fresh workstation through a mirror: HTTP 200, 19,551,872 bytes, bzip2 -t OK, sherpa-onnx-sys and the desktop build compiled from it, and the journey passed 8/8 (run on 6c31ad993 plus this change, so its receipt says dirty: true).
  • Not tested: the iOS journey (review-ios); the responsible-process lookup is a private libSystem symbol, resolved at run time and covered only by the on-workstation run, not a unit test.

Decisions

  • Decision: identify the prompt by owner, window kind, text and the app it names, and do nothing otherwise, because a button press on the wrong dialog is worse than a frozen review that says why.
  • Decision: count the driver's responsible process as the run's own, because that is what the prompt names and it survives a detached launch where the parent chain does not.
  • Decision: refuse to reset a database unless its data directory, a state-dir marker and a database marker all agree, because on a native stack the port is not ours by construction.
  • Decision: refuse to run setup outside a VM by default, because it starts services on fixed ports and resets a database.
  • Decision: decline the microphone prompt and allow Local Network, because a review never records audio and talks to a local relay.
  • Decision: put the probe token in the URL query rather than change the page to fetch with a header, because sendBeacon survives page teardown and the token is ephemeral and loopback-only.
  • Decision: keep the driver's own prompt answering as well as the setup step, because a prompt can still appear mid-run on a machine setup was not run on.
  • Decision: build on a merge of origin/main into the old stack head and refresh the base by merge (the branch-skew hook compares against current main); the old branch is not rebased or touched. Base orbit/native-review-base is 87433cd96.
  • Decision: do not carry the stack's CI job or automate the iOS CocoaPods mirror; this change is about running on a workstation.

For reviewers

  • Read first: tools/native-review/swift/Sources/BuzzNativeDriverSupport/DriverSupport.swift (decidePrivacyPrompt), bin/check-harness-database, bin/setup-macos-vm, then review_native.py (wait_for_interactive_window, semantic_probe_server) and main.swift (placeWindowOnMainDisplay, answerPrivacyPrompt, responsiblePid).
  • Run on a macOS VM without Docker: tools/native-review/bin/setup-macos-vm, then . ~/.buzz-native-review/env.sh && tools/native-review/bin/review-native run tools/native-review/desktop/composer-keyboard.yaml. Accessibility and Screen Recording must be granted to the invoking process.
  • Unit tests: bin/test-native-review, and node --import ./test-loader.mjs --experimental-strip-types --test src/testing/nativeReviewSemanticProbe.test.mjs in desktop/.
  • Open question: should setup reset the answered prompts (tccutil reset) for a deterministic first run? Existing answers are left alone.

🤖 Generated with Claude Code

jedwards27 and others added 7 commits November 20, 2026 14:04
Make tools/native-review work on a Docker-less, headless macOS workstation and
script the hand fixes that were needed to get there.

- bin/setup-macos-vm: idempotent setup of native Postgres, Redis and MinIO on the
  harness ports (MinIO built with go install, bucket created with a SigV4 curl),
  a prefetched sherpa-onnx archive, the isolated relay, and the Local Network
  prompt.
- scripts/start-isolated-test-relay.sh: BUZZ_HARNESS_NATIVE_SERVICES=1 runs the
  relay against those services instead of docker compose.
- review_native.py: SHERPA_ONNX_ARCHIVE_DIR / SHERPA_ONNX_LIB_DIR reach host
  builds (never the reviewed app); doctor requires ffmpeg; the review window is
  moved onto the main display and the run waits for WebKit's accessibility tree
  before the first locator.
- ios_review.py: PUB_HOSTED_URL passes through the env allowlist.
- Swift driver: place_window and web_ready commands, press-system-alert-button,
  and answering first-run macOS privacy prompts (decline microphone/camera,
  allow Local Network) when the app cannot take focus.

Co-authored-by: Orbit Helper <9743d67196e296c93cc2958036615907e2e0b39128484b59b392cbb380edbb8b@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jude Edwards <judeedwards@squareup.com>
The compositor can report the app window before its accessibility window
exists, so place_window failed with "no accessibility window to place" on a
fresh VM. Retry that one error until the window appears or the wait times out;
every other placement error still fails the run at once.

Co-authored-by: Orbit Helper <9743d67196e296c93cc2958036615907e2e0b39128484b59b392cbb380edbb8b@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jude Edwards <judeedwards@squareup.com>
The reviewed page publishes its semantic snapshot with navigator.sendBeacon,
which cannot set request headers, but the probe server only accepted a token in
an X-Buzz-Native-Review-Token header and never told the page the token. Every
beacon got a 401, the harness saw no semantic nodes, and any step that located
or asserted by id failed even though the UI had rendered.

Put the ephemeral token in the probe URL's query (compared in constant time).
The header is still accepted.

Co-authored-by: Orbit Helper <9743d67196e296c93cc2958036615907e2e0b39128484b59b392cbb380edbb8b@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jude Edwards <judeedwards@squareup.com>
The harness validates a semantic snapshot as a whole and rejects it if any node
leaves the viewport. A single visually hidden 1px element at -1px (the sidebar
has one) made every snapshot after the loading screen fail with a 400, so the
harness kept seeing the stale loading gate and never reached the seeded channel.

Clip each node's frame to the viewport and skip nodes with no visible part.

Co-authored-by: Orbit Helper <9743d67196e296c93cc2958036615907e2e0b39128484b59b392cbb380edbb8b@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jude Edwards <judeedwards@squareup.com>
On a fresh macOS VM the reviewed app triggers a microphone prompt at launch that
freezes its web view until someone answers it, so the window stayed blank and
the run timed out waiting for web content accessibility. Ask the driver to
answer a pending privacy prompt (decline microphone/camera, allow Local
Network) on every poll while the window comes up, and bound the web_ready
accessibility query so a frozen app cannot stall the driver.

Co-authored-by: Orbit Helper <9743d67196e296c93cc2958036615907e2e0b39128484b59b392cbb380edbb8b@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jude Edwards <judeedwards@squareup.com>
The reviewed app asks for the microphone at launch; on a fresh VM the prompt
freezes its web view until answered, and a driver blocked on that frozen view
cannot answer it in time. Have setup trigger the prompt with a one-second
ffmpeg capture and decline it once, next to the Local Network prompt. The
script is renamed answer-first-run-prompts and the flag is now --skip-prompts.

Co-authored-by: Orbit Helper <9743d67196e296c93cc2958036615907e2e0b39128484b59b392cbb380edbb8b@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jude Edwards <judeedwards@squareup.com>
Brings in six commits from main so the push passes the branch-skew check; no
conflicts and no change to the native-review work.

Co-authored-by: Orbit Helper <9743d67196e296c93cc2958036615907e2e0b39128484b59b392cbb380edbb8b@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jude Edwards <judeedwards@squareup.com>
@jedwards27 jedwards27 added the made-in-orbit Made with Orbit label Nov 20, 2026
jedwards27 and others added 6 commits November 20, 2026 15:57
…cement

Review follow-ups for the headless macOS VM path.

Prompt auto-answer: replace the substring match with answer-privacy-prompt.
It acts only on a window owned by the macOS system prompt agent, that is a
system alert (not a sheet or document window), whose text names the prompt
kind and an app that is one of this run's own processes, with exactly one
matching button. Anything else is left alone and the reason is logged.

Setup script: refuse to run outside a VM unless --allow-non-vm; mark the
state dir and the database as the harness's own; identify each service by
pidfile and refuse to reuse an open port that is not ours. The relay script
runs check-harness-database (data directory, marker file, database marker)
before DROP SCHEMA in native-services mode.

Window placement: move the accessibility window that matches the window the
harness reports, read the frame back, fail the run if it is not wholly on the
main display, and record before/after in the receipt.

Also fix the stale relay-script comment and teardown message, and a typo.

Co-authored-by: Orbit Helper <9743d67196e296c93cc2958036615907e2e0b39128484b59b392cbb380edbb8b@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Jude Edwards <judeedwards@squareup.com>
A trigger child blocked on an unanswered privacy prompt can ignore SIGTERM,
so answer-first-run-prompts waited on it forever. Escalate to SIGKILL, report
a driver that could not run instead of exiting silently, and log the prompt
text that was actually answered.

Co-authored-by: Orbit Helper <9743d67196e296c93cc2958036615907e2e0b39128484b59b392cbb380edbb8b@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Jude Edwards <judeedwards@squareup.com>
…eview

A privacy prompt names the process macOS holds responsible for the requester,
not necessarily an ancestor. When a review is started detached (nohup, a
remote exec that returns) the launcher is no longer in the parent chain, so the
driver left the review's own microphone prompt alone and the app's web view
froze. Count the driver's responsible process as one of the review's own.

Co-authored-by: Orbit Helper <9743d67196e296c93cc2958036615907e2e0b39128484b59b392cbb380edbb8b@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Jude Edwards <judeedwards@squareup.com>
The fixtures named the launcher process of one particular workstation
environment. Use a generic name; the tests only need some process that the
review owns.

Co-authored-by: Orbit Helper <9743d67196e296c93cc2958036615907e2e0b39128484b59b392cbb380edbb8b@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Jude Edwards <judeedwards@squareup.com>
setup-macos-vm downloads the sherpa-onnx archive from GitHub releases by
default. SHERPA_ONNX_DOWNLOAD_BASE now points the same path layout at a
caching mirror, and the script logs the curl line, HTTP status and size.
The bzip2 validation and SHERPA_ONNX_ARCHIVE_DIR are unchanged.

Co-authored-by: Orbit Helper <9743d67196e296c93cc2958036615907e2e0b39128484b59b392cbb380edbb8b@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Jude Edwards <judeedwards@squareup.com>
* tmp-base: (23 commits)
  refactor(mobile): remove unused CommunityListNotifier.addCommunity (block#9896)
  fix(mobile): keep Light/Dark/System on each device (block#9894)
  Cache recently opened mobile thread replies (block#9844)
  fix(mobile): align the New menu with desktop (block#9883)
  fix(deps): bump url to 2.5.9 for RUSTSEC-2026-0592 (block#9877)
  Remember collapsed sidebar sections on mobile (block#9879)
  Add inline emoji shortcode suggestions on mobile (block#9882)
  fix(mobile): reply to a thread's head in its open page (block#9889)
  fix(mobile): offer linked identity import when only other backups exist (block#9053)
  feat(mobile): enroll Android devices for push (block#9811)
  fix(mobile): keep "+" reactions working when a new message rebuilds the row (block#9831)
  Request sentence capitalization in the mobile composer (block#9881)
  Offer image and animated avatars for human profiles (block#9724)
  feat(mobile): add people and agents to a DM (block#9153)
  test(ios): check the navigation glass state often instead of once a second (block#9786)
  feat(mobile): add screen breadcrumbs to diagnostic reports (block#9823)
  fix(mobile): keep error names in send, upload and invite failure text (block#9855)
  ci(mobile): run the Mobile Swift Native lane only for native changes (block#9847)
  Revert "perf(db): stop per-id planning of wide #e reads (block#9591)" (block#9848)
  feat(mobile): count networking events for diagnostics (block#9810)
  ...

Signed-off-by: Jude Edwards <judeedwards@squareup.com>
@jedwards27 jedwards27 closed this Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

made-in-orbit Made with Orbit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant