Files
orca/tools/win-update-e2e/platform-guard.mjs
T
Jinwoo Hong d2d0d4325d feat(daemon): Phase 0 update-survival groundwork — daemon file log + packaged-update proof harness
Two independent pieces, no behavior change to terminal handling:

1. Daemon lifecycle file log. The detached daemon runs with stdio
ignored, so field failures have zero daemon-side evidence. The daemon
now writes rotated NDJSON lifecycle events (startup/ready/hello
accept+reject/session create/attach/exit/kill/shutdown/uncaught
exceptions) to logs/daemon.log via a new optional --log-file fork arg.
Fail-open (any fs error disables logging), adoption-neutral (old
daemons without the arg keep working, protocol untouched), and the
diagnostic bundle collector now includes the file, bounded by the same
lookback window as trace spans.

2. tools/win-update-e2e: a packaged NSIS update proof harness. Installs
version N, drives the installed app (isolated userData), plants a
canary marker session, silently updates to N+1, relaunches, and
asserts an explicit expectations profile: --expect cold-restore
(today's behavior) or --expect survival (the Phase 1 target). Window
flashes are detected by baseline-diffed window enumeration with
canary-title attribution; daemons are identified by command-line
marker, never exe name. Refuses to run when a pre-existing Orca app is
running or (without --allow-existing-install) installed, and only
uninstalls an install it fully owns.
2026-07-06 04:12:58 -04:00

39 lines
1.6 KiB
JavaScript

// Windows-only guards for the packaged-update E2E harness.
//
// This tool drives real NSIS installers, named-pipe daemons, and Win32 window
// enumeration, none of which exist off Windows. Every entry point calls
// assertWin32() so a macOS/Linux invocation fails loudly with a useful message
// instead of throwing an opaque "powershell: command not found" later.
import { runCommandSync } from './powershell-runner.mjs'
/** Throw a clear error unless we are on win32. */
export function assertWin32(context = 'win-update-e2e') {
if (process.platform !== 'win32') {
throw new Error(
`${context} is Windows-only (it drives NSIS installers, named-pipe ` +
`daemons, and Win32 window enumeration). Detected platform ` +
`"${process.platform}". Run it on a Windows machine or CI runner.`
)
}
}
/**
* True when this process is running elevated. Non-elevated is the expected,
* supported mode (per-user oneClick NSIS needs no elevation); this is only used
* to print an informational warning during preflight.
*/
export function isElevated() {
if (process.platform !== 'win32') {
return false
}
// Use the WindowsPrincipal role check via PowerShell rather than `whoami`,
// which under a Git Bash / MSYS PATH can resolve to a Unix whoami that
// rejects the /groups flag.
const { stdout } = runCommandSync(
`[bool]([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()` +
`).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)`
)
return stdout.trim().toLowerCase() === 'true'
}