Emit upgrade-events.jsonl from the Windows upgrade script
Summary
- The Linux upgrade script emits a per-phase event timeline (
upgrade-events.jsonl) that the server reads on each Capabilities RPC and surfaces in the upgrade timeline/UI. The Windows script emitted only the status file, so Windows operators saw no per-phase timeline. The agent already reads the Windows path (WindowsUpgradeStatusStorage.EventsFileSubPath = upgrade\upgrade-events.jsonl) — nothing wrote it. - Add
Write-UpgradeEventmirroring Linuxemit_event: same JSONL shape ({t,phase,kind,msg}), sameEVENTS_MAX=50cap, same terminal-kind set that bypasses the cap, BOM-less UTF8 append (PS 5.1'sAdd-Content -Encoding UTF8prepends a BOM that would corrupt the first parsed line). -
Write-UpgradeStatusnow auto-emits a phase-tagged event mapped from each status (start/swapped/success/method-exhausted/rollback-*), so the timeline tracks the status file 1:1 with no per-call-site duplication; plus event-only emits forrestart-startandhealthz-pass. The events file is truncated at the start of the (single-invocation) run so a prior attempt doesn't leak.
Design notes
-
Agent-side only / non-breaking: the server is already OS-agnostic (reads the
upgradeEventsmetadata key regardless of OS). No server, API, or schema change. - Phase is tracked via
$script:CURRENT_PHASE(Apre-swap →Bat Phase B entry); em-dashes stay confined to comments (new string literals are ASCII), consistent with the existing script.
Test plan
-
WindowsUpgradeEventsParityTests(8 cross-platform drift pins): Windows definesWrite-UpgradeEvent+ writesupgrade-events.jsonl; canonical{t,phase,kind,msg}shape;$EVENTS_MAXmatches Linux; terminal-kind set matches Linux; truncates before run; status→event map present; events path matchesWindowsUpgradeStatusStorage; BOM-less append -
Full unit suite: 5841/5841 green (no drift-detector regression) -
Runtime emission exercised by the Windows upgrade E2E suite on Windows CI ( pwshisn't available on the dev host, so the.ps1is validated structurally here + at runtime on CI)