Skip to content

macOS guests 3/6: Darwin guest service, readiness and exec - #500

Draft
chruffins wants to merge 1 commit into
feat/macos-oci-imagesfrom
feat/macos-guest-service
Draft

chruffins wants to merge 1 commit into
feat/macos-oci-imagesfrom
feat/macos-guest-service

Conversation

@chruffins

@chruffins chruffins commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

PR 3 of 6: Darwin shared GuestService, readiness, exec, and file copy for macOS guests. Base: #499.

  • The shared GuestService listens on host-CID vsock 2222 on Darwin. The Linux transport is unchanged.
  • A root system agent (LaunchDaemon) with an explicit shutdown policy. Readiness is probed and persisted. Boot markers are committed only for the boot they were probed for, and a stopped boot never gains readiness.
  • A lost shutdown reply during a stop still waits for power-off, so a macOS guest is not force-killed while it is powering off. A strict stop (used by build export) requires an acknowledged shutdown and owned VMM exit. A normal stop falls back to forced hypervisor shutdown after its timeout.
  • Exec and file copy are gated on the agent declared by the image. Exec TTY and non-TTY modes share one lifecycle. Cancellation kills the process group, and output drains are bounded.
  • Linux behavior: exec still does not cancel on client disconnect. A TTY command whose output stays open after the shell exits now reports its status after a bounded drain instead of waiting indefinitely.
  • Stat is served by the same agent.
  • Readiness probes for macOS guests no longer evict the shared guest connection on a retryable error. Concurrent callers (for example a restore readiness wait) were losing in-flight RPCs to Canceled.

Validation

  • Live, in an isolated QA guest with a root agent installed by hand: UID 0 exec in TTY and non-TTY modes, root file round-trip with exact bytes, timeout with descendant cleanup, readiness persisted, normal stop with acknowledged shutdown and no forced fallback.
  • Race-tested unit suites for the guest agent, exec, boot markers, and shutdown policy.
  • Cross-compiles for Linux and Windows for the agent package. Windows is not functional yet (see PR 3 limitations).

Limitations

  • The root agent is installed manually. There is no image-level installer or automatic provisioning.
  • Windows support is a compile check only. Process-tree kill, the vsock listener, and the ready path are stubs that return explicit errors.
  • Vsock accept polls at 10 ms.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8f6dd1c. Configure here.

if err != nil {
return n, &net.OpError{Op: "read", Net: "vsock", Err: err}
}
return n, err

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read wraps EOF as OpError

Low Severity

vmConn.Read wraps every os.File.Read failure, including bare io.EOF, in net.OpError. Standard net.Conn implementations leave io.EOF unwrapped, and gRPC/HTTP2 compare with == io.EOF for a clean close. Guest disconnects can be treated as transport errors instead of orderly EOF.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 8f6dd1c. Configure here.

@chruffins

Copy link
Copy Markdown
Contributor Author

Real native Darwin GuestService2222 QA passed in an isolated cold-booted OCI guest using the current shared binary, user-launched at UID501 only. Host shared client verified id -u=501, synthetic file copy-to/from exact bytes, and client deadline cancellation of shell + sleep descendant (child PID no longer existed). Three repeated race runs passed. Shutdown correctly returned PermissionDenied for nonroot; guest remained running. Fixed two QA harness assumptions before the passing run: CopyFromInstance's destination is a directory, and deadline may surface as gRPC DeadlineExceeded rather than errors.Is(context.DeadlineExceeded).

Root daemon was not installed: guest noninteractive sudo is unavailable and no privileged provisioning was performed. System image capability remained false. These results prove native transport/user-level exec/files/cancellation and shutdown admission, not normal API system-agent installation/readiness or successful graceful root shutdown. Those remain gates. Original guest/API/storage untouched; isolated QA VM ended stopped.

@chruffins
chruffins force-pushed the feat/macos-guest-service branch 5 times, most recently from a1ed358 to 243ce9a Compare October 9, 2026 21:53
@chruffins
chruffins changed the base branch from spike/macos-guests to feat/macos-oci-images October 9, 2026 21:53
@chruffins

Copy link
Copy Markdown
Contributor Author

Simplification update at 243ce9a: common command setup/process-group cancellation and bounded wait/drain/final-status handling for both TTY modes. Permanent tests cover pre-cancelled starts and failed output sends cancelling/reaping commands. Full agent/client race suites passed 3 runs; combined post-restack focused suites also passed 3 runs. Base changed to feat/macos-oci-images so the image rollback fix and bundle consolidation are inherited once rather than duplicated. Root provisioning remains undone.

All PRs remain draft. This is source-level/synthetic validation, not a new live boot or production build proof. Default Codex independent review was attempted but is still blocked by authentication (HTTP401). Published atomically after checking reviewer heads with explicit per-ref force-with-lease; prior heads preserved locally.

@chruffins

Copy link
Copy Markdown
Contributor Author

Root QA follow-up pushed as ae3685d; desktop restacked atomically with explicit leases. Manually installed shared system-role agent survived isolated normal-API cold boots. Repeated race-instrumented authenticated API tests verified UID0 exec (both TTY modes), root-owned0600 file copy round trips, and descendant cancellation. Live testing reproduced and fixed Darwin readiness using the nonexistent /bin/true; /usr/bin/true now probes successfully and normal GET persists GuestAgentReadyAt without a Linux workload marker. Fixed premature shutdown fallback after a lost Darwin RPC reply: configured grace period is retained while still requiring owned VMM exit; Linux policy is unchanged. Final normal API stop accepted the RPC and confirmed VMM exit/storage closure without forced fallback. Corrected stale opt-in test calls left after runtime simplification. Focused instances/API/agent/client tests pass race,count3; default independent autoreview remains401-blocked. Manual QA provisioning is not automatic image installation or end-to-end build/publication proof. PR remains draft.

@chruffins
chruffins force-pushed the feat/macos-guest-service branch 2 times, most recently from c336b30 to 1cae99b Compare October 11, 2026 16:31
@chruffins
chruffins force-pushed the feat/macos-guest-service branch from 1cae99b to 24fad86 Compare October 11, 2026 16:55
@chruffins
chruffins force-pushed the feat/macos-guest-service branch from 24fad86 to 2df3f56 Compare October 11, 2026 17:16
@chruffins
chruffins force-pushed the feat/macos-guest-service branch from 2df3f56 to ebf6c6e Compare October 11, 2026 17:30
@chruffins
chruffins force-pushed the feat/macos-guest-service branch from ebf6c6e to fbfd9d2 Compare October 11, 2026 18:11
@chruffins chruffins changed the title macOS guests 3/6: Darwin shared GuestService macOS guests 3/6: Darwin guest service, readiness and exec Oct 11, 2026
@chruffins
chruffins added this pull request to stack #507 October 11, 2026 18:29
@chruffins
chruffins force-pushed the feat/macos-guest-service branch 2 times, most recently from 39e247a to f472950 Compare October 11, 2026 21:49
@chruffins
chruffins force-pushed the feat/macos-guest-service branch 3 times, most recently from cd74e1a to c39227e Compare October 12, 2026 01:29
Shared GuestService on host-CID vsock 2222, root system agent, readiness and boot
markers committed only for the probed boot, bounded exec lifecycle, agent-gated
exec, copy and stat, one macOS stop floor, one OS capability table.
@chruffins
chruffins force-pushed the feat/macos-guest-service branch from c39227e to 48a1f21 Compare October 12, 2026 01:34

This branch has not been deployed

No deployments
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