Skip to content

Emit upgrade-events.jsonl from the Windows upgrade script

Placeholder ppxd requested to merge feat/windows-upgrade-events into main

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-UpgradeEvent mirroring Linux emit_event: same JSONL shape ({t,phase,kind,msg}), same EVENTS_MAX=50 cap, same terminal-kind set that bypasses the cap, BOM-less UTF8 append (PS 5.1's Add-Content -Encoding UTF8 prepends a BOM that would corrupt the first parsed line).
  • Write-UpgradeStatus now 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 for restart-start and healthz-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 upgradeEvents metadata key regardless of OS). No server, API, or schema change.
  • Phase is tracked via $script:CURRENT_PHASE (A pre-swap → B at 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 defines Write-UpgradeEvent + writes upgrade-events.jsonl; canonical {t,phase,kind,msg} shape; $EVENTS_MAX matches Linux; terminal-kind set matches Linux; truncates before run; status→event map present; events path matches WindowsUpgradeStatusStorage; 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 (pwsh isn't available on the dev host, so the .ps1 is validated structurally here + at runtime on CI)

Merge request reports

Loading