Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

feat(test-infra): opt-in windows-vm and mac-vm legs

Martin Vogel37956940da0a
diff --git a/test-infrastructure/run.sh b/test-infrastructure/run.sh
index b66548f7e..c6396ac22 100755
--- a/test-infrastructure/run.sh
+++ b/test-infrastructure/run.sh
@@ -7,8 +7,12 @@
# Linux portable: Alpine musl static build + smoke [portable binary]
# Windows: cross-compile with mingw-w64 [compile-check; Wine
# CANNOT reproduce real Windows ACL/token/owner semantics —
-# those need a real Windows VM or the CI legs]
+# use the windows-vm leg for those]
# macOS: run natively (not in Docker)
+# windows-vm: OPT-IN real Windows (UTM) — kernel-real ACL/token/owner
+# semantics incl. the runner default-owner policy (vm/README.md)
+# mac-vm: OPT-IN GitHub-runner macOS environment (Tart) — the env
+# class where runner-only failures reproduce (vm/README.md)
#
# Speed first: test containers run unconstrained by default. Before pushing
# anything that touches timing, scheduling, or subprocess code, run ONE pass
@@ -144,8 +148,50 @@ case "${1:-full}" in
echo "=== Debug shell (Alpine) ==="
$COMPOSE run --rm --entrypoint bash test-portable
;;
+ windows-vm)
+ # OPT-IN: real Windows semantics (ACL/token/owner) — see vm/README.md.
+ [ -f "$ROOT/test-infrastructure/vm/config.env" ] && . "$ROOT/test-infrastructure/vm/config.env"
+ if [ -z "${CBM_WIN_VM_SSH:-}" ]; then
+ echo "windows-vm leg not configured (opt-in)." >&2
+ echo " Setup: test-infrastructure/vm/README.md — UTM + CrystalFetch," >&2
+ echo " run vm/windows-bootstrap.ps1 in the VM, then set CBM_WIN_VM_SSH" >&2
+ echo " in test-infrastructure/vm/config.env" >&2
+ exit 2
+ fi
+ echo "=== Windows VM: sync + build + test (real ACL/token semantics) ==="
+ SUITES="${2:-}"
+ tar -C "$ROOT" --exclude build --exclude .git -cf - . | ssh "$CBM_WIN_VM_SSH" \
+ "C:/msys64/usr/bin/bash.exe -lc 'rm -rf /c/cbm/src && mkdir -p /c/cbm/src && cd /c/cbm/src && tar -xf - && scripts/test.sh CC=clang CXX=clang++ ${SUITES:+TEST_SUITES=\"$SUITES\"}'"
+ ;;
+ mac-vm)
+ # OPT-IN: GitHub-runner-equivalent macOS environment — see vm/README.md.
+ if ! command -v tart >/dev/null 2>&1 || ! tart list 2>/dev/null | grep -q cbm-mac-runner; then
+ echo "mac-vm leg not configured (opt-in)." >&2
+ echo " Setup: brew trust cirruslabs/cli && brew install tart &&" >&2
+ echo " tart clone ghcr.io/cirruslabs/macos-runner:sequoia cbm-mac-runner" >&2
+ exit 2
+ fi
+ echo "=== macOS runner VM: sync + test (GitHub-runner environment) ==="
+ tart run --no-graphics cbm-mac-runner >/dev/null 2>&1 &
+ TART_PID=$!
+ trap '{ kill "$TART_PID" 2>/dev/null || true; }' EXIT
+ VM_IP=""
+ for _ in $(seq 1 60); do
+ VM_IP=$(tart ip cbm-mac-runner 2>/dev/null) && [ -n "$VM_IP" ] && break
+ sleep 2
+ done
+ [ -n "$VM_IP" ] || { echo "ERROR: VM did not obtain an IP" >&2; exit 1; }
+ if ! ssh -o BatchMode=yes -o StrictHostKeyChecking=accept-new "admin@$VM_IP" true 2>/dev/null; then
+ echo "One-time: install your key in the VM (password: admin):" >&2
+ echo " ssh-copy-id admin@$VM_IP" >&2
+ exit 2
+ fi
+ tar -C "$ROOT" --exclude build --exclude .git -cf - . | \
+ ssh -o BatchMode=yes "admin@$VM_IP" \
+ 'rm -rf ~/cbm-src && mkdir -p ~/cbm-src && cd ~/cbm-src && tar -xf - && scripts/test.sh CC=cc CXX=c++'
+ ;;
*)
- echo "Usage: $0 {full|test|build|smoke|portable|portable-test|windows|amd64|all|lint|shell|shell-alpine}"
+ echo "Usage: $0 {full|test|build|smoke|portable|portable-test|windows|amd64|all|lint|shell|shell-alpine|windows-vm|mac-vm}"
exit 1
;;
esac
diff --git a/test-infrastructure/vm/README.md b/test-infrastructure/vm/README.md
new file mode 100644
index 000000000..804c2fb14
--- /dev/null
+++ b/test-infrastructure/vm/README.md
@@ -0,0 +1,55 @@
+# VM test legs (opt-in)
+
+Two failure classes cannot be reproduced by the container legs and need real
+virtual machines. Both stacks are free; the legs activate automatically in
+`run.sh` when the tooling and the named VM are detected, and print setup
+guidance otherwise.
+
+## Windows VM (`run.sh windows-vm`) — real ACL/token/owner semantics
+
+Wine only compile-checks Windows: kernel-real security semantics (object
+ownership, DACLs, token identity — e.g. the Administrators-default-owner
+policy on CI runners) need real Windows.
+
+One-time setup (~15 min interactive):
+
+1. `brew install --cask utm crystalfetch` (both free/open source).
+2. Open **CrystalFetch** → download the latest **Windows 11 ARM64** ISO
+ (fetched directly from Microsoft). Windows runs unactivated for testing
+ (cosmetic watermark); add a license if you want it clean.
+3. Open **UTM** → New VM → Virtualize → Windows → select the ISO →
+ 4+ CPUs / 8 GB. Click through Windows setup (local account, e.g. `dev`).
+4. Inside Windows, run `vm/windows-bootstrap.ps1` (elevated PowerShell):
+ installs msys2 + CLANG64 toolchain + git, enables OpenSSH server, and
+ mirrors the GitHub-runner security policy
+ (`NoDefaultAdminOwner=0` → new objects owned by BUILTIN\Administrators —
+ the policy that surfaces the exact-owner validation class).
+5. Note the VM's IP (`ipconfig`) and write it to `vm/config.env`:
+ `CBM_WIN_VM_SSH=dev@<ip>`.
+
+The leg then drives the VM over ssh: sync the worktree, build with the
+CLANG64 toolchain, run the requested suites — a debugger-capable local loop
+for the class that previously needed blind CI round-trips.
+
+## macOS runner VM (`run.sh mac-vm`) — the GitHub-runner macOS environment
+
+A local Mac is not the GitHub macOS runner (different temp ancestry, ACLs,
+policies): failures like the index-supervisor worker exits reproduce only
+there. Cirrus Labs publishes runner-equivalent images.
+
+One-time setup (automated, big download):
+
+1. `brew trust cirruslabs/cli && brew install tart` (free OSS).
+2. `tart clone ghcr.io/cirruslabs/macos-runner:sequoia cbm-mac-runner`
+ (tens of GB, one time).
+
+The leg boots the VM headless (`tart run --no-graphics cbm-mac-runner`),
+syncs the worktree over ssh (default credentials admin/admin inside the
+runner image), and executes `scripts/test.sh` — the same environment class
+GitHub schedules, locally and debuggable.
+
+## Honesty rules
+
+- These legs are OPT-IN: absent tooling prints guidance and exits with a
+ distinct status; it is never silently skipped when explicitly requested.
+- VM results complement, never replace, the CI matrix on the final SHA.
diff --git a/test-infrastructure/vm/windows-bootstrap.ps1 b/test-infrastructure/vm/windows-bootstrap.ps1
new file mode 100644
index 000000000..331b09709
--- /dev/null
+++ b/test-infrastructure/vm/windows-bootstrap.ps1
@@ -0,0 +1,31 @@
+# windows-bootstrap.ps1 — one-time setup inside the Windows test VM.
+# Run in an ELEVATED PowerShell. Installs the CLANG64 toolchain, enables
+# ssh-based driving from the host, and mirrors the GitHub-runner security
+# policy that surfaces the exact-owner validation class.
+
+$ErrorActionPreference = "Stop"
+
+Write-Host "=== 1/4: msys2 + CLANG64 toolchain ==="
+winget install -e --id MSYS2.MSYS2 --accept-source-agreements --accept-package-agreements
+& C:\msys64\usr\bin\bash.exe -lc "pacman -S --noconfirm --needed mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-compiler-rt mingw-w64-clang-x86_64-zlib mingw-w64-clang-x86_64-ccache make git"
+
+Write-Host "=== 2/4: OpenSSH server (host drives the VM over ssh) ==="
+Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
+Set-Service -Name sshd -StartupType Automatic
+Start-Service sshd
+New-NetFirewallRule -Name cbm-sshd -DisplayName "OpenSSH (cbm test VM)" `
+ -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 `
+ -ErrorAction SilentlyContinue | Out-Null
+
+Write-Host "=== 3/4: mirror GitHub-runner security policy ==="
+# 'System objects: Default owner for objects created by members of the
+# Administrators group' = Administrators (0). This is the policy that makes
+# freshly created objects owned by BUILTIN\Administrators instead of the
+# user SID — the class the daemon's exact-owner gates must survive.
+Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" `
+ -Name NoDefaultAdminOwner -Value 0 -Type DWord
+
+Write-Host "=== 4/4: workspace ==="
+New-Item -ItemType Directory -Path C:\cbm -Force | Out-Null
+Write-Host "Done. Reboot once, then from the host: ipconfig -> put"
+Write-Host "CBM_WIN_VM_SSH=<user>@<ip> into test-infrastructure/vm/config.env"