Experiment Spec: macOS VM Process Context, Headless Display, and Virtual HID
Repository: chr33s/iso
Date: 2026-10-06
Status: proposed real-hardware experiment
Target: Apple Silicon host, macOS 27+ host and macOS guest
Primary decision: determine the minimum host process/session/UI context required to run a macOS VZVirtualMachine and expose reliable computer-use observation + input.
1. Questions
Q1 — VM ownership
Can a macOS VZVirtualMachine reliably start, run, stop, and restart in each context?
- Interactive process in a logged-in user session.
user/$UIDbackground launchd job — currentiso-sandboxmodel.gui/$UIDLaunchAgent.- System LaunchDaemon as root.
- System LaunchDaemon with
UserNameset to a non-root standard user. - System LaunchDaemon with
UserNamebefore that user has logged in.
Q2 — computer-use UI
What host GUI state is required for VZVirtualMachineView-based observation and keyboard/pointer delivery?
Test whether a view:
- needs an
NSWindow; - needs the window visible;
- needs it key/focused;
- works while occluded;
- works on an inactive Space;
- works minimized;
- works hidden or offscreen;
- works with the host screen locked;
- can produce capturable pixels without a visible window;
- can receive synthetic input without moving the host cursor or stealing host focus.
Q1 and Q2 must be evaluated independently.
2. Apple-documented controls
Treat these as established by Apple documentation:
- The VM-owning process needs the
com.apple.security.virtualizationentitlement. VZVirtualMachinecan use a specific dispatch queue.- VM lifecycle/state is exposed through
VZVirtualMachine. - macOS guests use
VZMacPlatformConfiguration. - Graphics, keyboards, pointing devices, sockets, network, and storage are configured on
VZVirtualMachineConfiguration. - Apple’s documented graphical interaction path is
VZVirtualMachineView. VZVirtualMachineViewAdaptorbridges a VM on its VM queue to a view on the main actor.VZMacGraphicsDisplayConfigurationconfigures a display shown inVZVirtualMachineView.
Apple’s Virtualization documentation does not establish these as requirements:
- Aqua session;
- logged-in console user;
- unlocked login keychain;
- visible
NSWindow; - LaunchAgent instead of LaunchDaemon;
- non-root execution;
- automatic login.
Those are experiment hypotheses.
Official references:
- https://developer.apple.com/documentation/virtualization
- https://developer.apple.com/documentation/virtualization/vzvirtualmachine
- https://developer.apple.com/documentation/virtualization/vzvirtualmachineview
- https://developer.apple.com/documentation/virtualization/vzvirtualmachineviewadaptor
- https://developer.apple.com/documentation/virtualization/vzmacgraphicsdisplayconfiguration
- https://developer.apple.com/documentation/virtualization/adding-the-virtualization-entitlement-to-your-project
3. Current iso baseline
iso-sandbox currently supervises each VM owner in:
user/<uid>
LimitLoadToSessionType = Background
The dynamically generated plist is stored in sandbox state and written mode 0600.
Preferred outcome: macOS guests preserve this ownership model. Move to a GUI domain only if the experiment proves it necessary.
Relevant source:
iso-sandbox/Sources/IsoSandboxCore/Launchd.swift
4. Hypotheses
H1 — runtime is GUI-independent
A macOS VZVirtualMachine starts and operates from user/$UID background launchd ownership without a VZVirtualMachineView.
Preferred: pass.
H2 — root is unnecessary
Running the VM as root provides no required capability.
Preferred: non-root ownership works reliably.
H3 — pre-login runtime may work
A preinstalled VM can start before GUI login from a system LaunchDaemon running as a standard user through UserName.
This is a hypothesis only.
H4 — GUI context may be needed only for the view
The VM remains headless while display/input requires a gui/$UID AppKit helper.
This is an acceptable result.
H5 — visible/focused window is not required
Computer use works without a visible focused host window.
A requirement for a visible focused host window is a failure for the proposed production architecture.
5. Hardware and host setup
Use a dedicated Apple Silicon Mac with no production secrets.
Record:
host model / SoC
RAM
host macOS version + build
Xcode version
SDK version
probe build hash
guest macOS version + build
Create a dedicated standard host account:
iso-vz-test
Do not sign it into iCloud or production accounts.
Probe entitlement starts with:
com.apple.security.virtualization
6. Test VM
6.1 Use a preinstalled guest first
Do not start with VZMacOSInstaller.
Create one known-good guest under the interactive baseline and persist:
hardware model
machine identifier
auxiliary storage
main disk
display configuration
network configuration
Use that same VM identity across process-context tests.
This isolates process/session behavior from installation behavior.
6.2 Guest setup
Initial configuration:
- one fixed display;
- fixed geometry, e.g. 1440×900;
- automatic display reconfiguration disabled;
- one network device;
- one keyboard;
- one absolute-coordinate pointing device;
- optional virtio socket;
- SSH enabled;
- test user auto-logged in for GUI phases;
- guest sleep/lock disabled.
Use CPU/RAM values supported by the restore image rather than imposing a value below Apple’s requirements.
7. Guest fixture
Install a small AppKit test application.
Visible content:
random run token
frame counter incrementing every 250 ms
10x10 clickable grid
text field
key/modifier event display
drag target
scroll region
Each grid cell has a unique ID.
The fixture atomically writes:
~/Library/Application Support/IsoVZProbe/state.json
Example:
{
"run_token": "7cd9...",
"frame_counter": 1842,
"last_clicked_cell": "G07",
"received_text": "hello",
"keys_down": [],
"drag_target": "D04"
}
The host reads this via SSH as an independent oracle.
8. Host probe program
Create a standalone Swift experiment target, not production code:
experiments/macos-vz-context-probe/
Suggested commands:
vz-context-probe report-context
vz-context-probe vm-run
vz-context-probe vm-view
Output JSONL.
At startup record:
pid / ppid
uid / euid / gid
HOME
whether user/$UID exists
whether gui/$UID exists
virtualization support
VM validation result
Keychain diagnostic rule
Keychain state is metadata only.
Do not:
- make it a primary pass condition;
- auto-unlock it in baseline tests;
- put passwords in plists, argv, logs, or repository files.
Only test keychain correlation later if pre-login VM start fails.
9. Phase 1 — VM ownership context
Context matrix
| ID | Context | Host login state |
|---|---|---|
| C0 | Interactive Terminal | logged in/unlocked |
| C1 | user/$UID + Background |
logged in |
| C2 | gui/$UID LaunchAgent |
logged in |
| C3 | system LaunchDaemon, root | no login requirement |
| C4 | system LaunchDaemon + UserName=iso-vz-test |
logged in |
| C5 | system LaunchDaemon + UserName=iso-vz-test |
cold boot, user never logged in |
C0 is the positive control.
C1 is the preferred iso architecture.
C2 is the fallback.
C3-C5 establish technical feasibility only.
No-view procedure
For each context:
- create VM configuration;
- validate it;
- construct
VZVirtualMachineon an explicit serial queue; - do not instantiate
VZVirtualMachineView; - start;
- observe state;
- wait for guest network;
- wait for SSH;
- read guest build/fixture state;
- request graceful stop;
- require stopped state;
- exit owner cleanly.
Pass
- validation succeeds;
- start succeeds;
- VM reaches running;
- guest independently becomes reachable;
- stop succeeds;
- no SIGTRAP/crash/deadlock;
- owner exits cleanly.
Repetition
Development:
10 runs per cell
Qualification:
100 start/stop cycles for every context intended for support
10. Phase 2 — host session transitions
For Phase-1 contexts that pass, test:
| ID | Host state |
|---|---|
| S0 | logged in/unlocked |
| S1 | screen locked |
| S2 | display asleep |
| S3 | wake from display sleep |
| S4 | fast-user-switch away |
| S5 | switch back |
| S6 | host sleep/wake if intended |
For VM runtime only, verify:
VM state
SSH
owner process
boot identity
stop behavior
Do not mix graphical view behavior into this phase.
11. Phase 3 — VZVirtualMachineView topology
Start in gui/$UID.
Use VZVirtualMachineViewAdaptor when appropriate.
Set:
automaticallyReconfiguresDisplay = false
View/window matrix
| ID | Topology |
|---|---|
| V0 | visible window, key/focused |
| V1 | visible window, not key |
| V2 | visible but fully occluded |
| V3 | window on inactive Space |
| V4 | minimized |
| V5 | hidden / ordered out |
| V6 | fully offscreen |
| V7 | view retained but unattached to NSWindow |
| V8 | no view |
The objective is to find the least-visible topology that still supports correct observation/input.
12. Observation tests
Apple does not document a raw framebuffer callback for VZVirtualMachineView, so test observation mechanisms explicitly.
O1 — AppKit view capture
Attempt capture using supported AppKit view rendering/caching mechanisms.
Record:
capture success
image dimensions
frame hash
fixture token present
frame counter freshness
If GPU content is absent, mark O1 unsupported. Do not call the VM display broken based on O1 alone.
O2 — ScreenCaptureKit diagnostic control
For window-backed topologies, use a separate signed host diagnostic app with Screen Recording permission to capture the VM window/display.
This is a diagnostic control, not automatically the production design.
It answers:
Is the VM content rendered by WindowServer even if AppKit snapshotting cannot access it?
Observation oracle
For each capture:
- SSH-read fixture token/counter;
- capture host-side image;
- verify known fixture pattern/token;
- wait 500 ms;
- capture again;
- require fresh counter/pixel change.
Qualifying result
A topology qualifies only if:
- application pixels are present;
- token matches current guest;
- frames refresh;
- no black/desktop-only/stale result;
- at least 1,000 consecutive captures succeed.
13. Virtual HID/input tests
Primary input path should not inject global host events.
Construct synthetic NSEvent objects and exercise the VZVirtualMachineView/NSResponder path under test.
Before/after every batch record:
host frontmost app
host key window
host cursor position
Unintended host cursor movement or focus theft is a failure unless explicitly accepted.
13.1 Absolute pointer
Using the 10×10 fixture grid:
- choose random cell;
- derive coordinate from observed framebuffer;
- inject move/click;
- read
last_clicked_cellvia SSH; - compare.
Development:
1,000 randomized clicks
Qualification:
10,000 randomized clicks
Require:
0 wrong-target clicks
0 silent-success mismatches
13.2 Pointer coverage
Test:
- move;
- left/right/double click;
- down/up;
- drag;
- long drag;
- scroll;
- edges/corners.
13.3 Keyboard
Test:
letters
digits
punctuation
Shift / Control / Option / Command
Return / Tab / Escape
arrows
delete / backspace
Cmd-S
Cmd-Q
Cmd-Tab if claimed
Require:
- exact event ordering;
- no stuck modifiers;
- complete key-up pairs;
- guest receives events;
- host app receives none.
14. Phase 4 — computer use across host session changes
Take the best non-visible topology from Phase 3.
Test during:
- lock;
- unlock;
- inactive Space;
- fast-user-switch;
- display sleep/wake;
- host sleep/wake if supported.
Record independently:
VM running
SSH alive
frame fresh
pointer correct
keyboard correct
host focus unchanged
A valid documented result may be:
VM runtime works while locked
computer-use display/input unavailable while locked
provided it is deterministic.
15. Phase 5 — cold boot / no login
This directly tests the claims about login/session/Secure Enclave/keychain dependence.
Use a disposable test host.
Procedure:
- configure C3 and C5;
- fully shut down;
- power on;
- do not log into any GUI account;
- allow job to attempt VM start;
- retrieve logs through independent administration if available;
- determine whether guest reaches SSH;
- only then log into host for inspection.
Do not:
- auto-login;
- auto-unlock keychain;
- create a GUI session before recording result.
Record:
validation result
start result
VZ error domain/code
owner exit status
system log excerpt
guest SSH reached: yes/no
Do not infer “keychain” or “Secure Enclave” solely from human-readable error text.
16. Phase 6 — keychain correlation diagnostic
Run only if C5 fails.
Compare:
D0 no GUI login, default keychain state
D1 same process context after manual test-keychain unlock
D2 same user after one GUI login, then locked
D3 gui/$UID LaunchAgent after login
This is empirical correlation, not proof of an Apple API contract.
17. Phase 7 — installer context
Only after runtime ownership is understood, test VZMacOSInstaller.
Primary intended control:
interactive `iso setup --guest macos`
Require:
- installer created/driven on the correct VM queue;
- progress behaves coherently;
- failed install never publishes a template;
- five clean installs succeed.
Do not require all runtime-owner contexts to support installation unless the product intends that.
18. Evidence
Each run writes:
results/<run-id>/
metadata.json
context.json
vm-events.jsonl
host-session-events.jsonl
capture-events.jsonl
input-events.jsonl
owner.stdout.log
owner.stderr.log
guest-state/
screenshots/
Result schema:
{
"run_id": "...",
"context": "C1",
"session_state": "S0",
"view_topology": "V7",
"vm_runtime": "pass",
"observation": "pass",
"pointer": "pass",
"keyboard": "pass",
"failure_code": null
}
Statuses:
pass
fail
not_supported
environment_error
not_run
Missing tests are never passes.
19. Secret/privacy rules
Do not collect:
- passwords;
- Keychain contents;
- provider credentials;
- SSH private keys;
- unrelated screenshots of the operator desktop.
Use only synthetic guest content.
20. Decision table
A — ideal
C1 runtime passes
non-visible V5/V6/V7 observation passes
HID works without host focus
lock behavior acceptable
Keep current-style background ownership.
B — split architecture
C1 runtime passes
view/HID requires gui/$UID
Keep background lifecycle if possible and introduce a GUI-session computer-use component, subject to a safe ownership/IPC design.
C — GUI owner required
C1 fails
C2 passes reliably
macOS guests require a logged-in GUI-domain owner.
Linux keeps current background ownership.
D — pre-login runtime works
C5 passes
A system LaunchDaemon with UserName is technically viable for lifecycle on the tested build, but should only be adopted if it is operationally/security-wise better than C1/C2.
E — root fails, user succeeds
Do not run macOS VM owners as root.
Record exact failures; do not generalize beyond tested OS builds.
F — visible/focused window required
only V0 is reliable
Reject VZVirtualMachineView as the production computer-use path.
Evaluate guest-side display/input streaming or standard remote desktop. Virtual HID may remain useful for setup/login/recovery.
21. Minimum go/no-go sequence
Run in this order:
E0 C0: preinstalled VM starts/stops, no view
E1 C1: current user/$UID Background owner starts/stops, no view
E2 C5: pre-login non-root LaunchDaemon test
E3 V0: visible VZ view shows fresh guest pixels
E4 V7: unattached-view capture test
E5 V5/V6: hidden/offscreen-view test
E6 1,000 random absolute clicks, 0 wrong targets
E7 keyboard/modifier exactness
E8 lock/unlock behavior
E9 reboot invalidates prior computer-use session
Stop and redesign before integration if:
- E1 fails and only root works;
- no host-side observation works without a visible focused window;
- input requires moving/focusing the host UI;
- clicks can silently land on wrong targets;
- framebuffer freshness cannot be independently proven.
22. Architecture acceptance bar
Approve background-owner + host-side computer use only if:
- C1 passes 100 start/stop cycles.
- One non-visible topology passes 1,000 fresh captures.
- 10,000 randomized pointer actions yield zero wrong targets.
- Keyboard tests yield zero stuck/leaked modifiers.
- Host focus/cursor remain unchanged.
- Supported host-session transitions are deterministic.
- Old computer-use sessions fail after reboot/replacement.
- The result reproduces on the exact host/guest build intended for release.
Report failures by layer:
VM runtime
AppKit/view
observation
HID
host session transition
identity/session binding
Do not conclude broadly that “headless Virtualization.framework does not work” when only one layer fails.
23. Relationship to broader qualification
This is the architecture-selection spike that precedes the full macOS computer-use qualification plan.
It must establish:
- owner process context;
- view/window topology;
- observation path;
- input path;
- host session limitations.
Only then should broader application/network/storage/security qualification begin.