fix(daemon): make the daemon reachable on native Windows hosts (#3291)

Merged
TH
2mo ago
+854-144

Summary

On native Windows the daemon never became reachable:

  1. truncateDaemonLog no longer ftruncates an append-only handle (Windows EPERMs that). POSIX keeps the original pinned 'a' handle, byte-identical to origin/main; win32 empties the log through an 'r+' handle, append-creation confined to the missing-file path.
  2. host-process.ts gains a Windows branch at the existing host-process seam: one PowerShell CIM (Win32_Process) query answers birth, CommandLine, and liveness per identity decision. The CIM row rule is "null field prints empty, never raises"; PowerShell's console is pinned to UTF-8; failed queries stay unknown evidence, fail-closed. All POSIX probes pin /bin/ps.

Refs #3291 — the live Windows run below now exists; closure is the maintainer's call.

Validation

pnpm check:affected --run passed at head a7821ef58. Mutation evidence: dropping the reaper's command/zombie comparisons or reverting either fix fails the named regression tests.

Live Windows 11 run by @pai-scaffolde at head a7821ef58 (evidence): Windows 11 Enterprise 10.0.26200, Node 24.21.0 + Electron 44.4.2, socket + HTTP, fresh state dir: doctor --debug exit 0, zero EPERM; processStartTime = exact CIM CreationDate (202610091601014504740); daemon reused on both transports; graceful stop, pid gone. Non-ASCII paths (üïøé junction + state dir) start/reuse/stop cleanly. Baseline 0.21.12 on the same host publishes no processStartTime; stop fails.

Residual (note, not blocker): full-table/cold-boot CIM timings unmeasured (warm single-PID 324–345 ms vs the 2 s budget); PowerShell-per-poll stop cost folded into the 1.2–1.4 s stop total.

iOS Smoke 'Preflight' reds were lane flakes (#3342): pass on rerun, failed identically on PRs lacking these hunks.