diff --git a/hermes_cli/desktop_update_verify.py b/hermes_cli/desktop_update_verify.py new file mode 100644 index 0000000000..353fb693cc --- /dev/null +++ b/hermes_cli/desktop_update_verify.py @@ -0,0 +1,25 @@ +"""Read-only verification at the Windows Desktop handoff receipt boundary.""" +from pathlib import Path + +from hermes_cli.main_desktop import ( + _desktop_build_needed, + _desktop_exe_integrity_error, + _desktop_packaged_executable, +) + + +def verify_windows_desktop_update(project_root: Path) -> None: + """Raise when a zero-exit updater left an unusable or stale packaged app.""" + desktop = project_root / "apps" / "desktop" + executable = _desktop_packaged_executable(desktop) + if executable is None: + raise RuntimeError("The updated Desktop executable is missing") + error = _desktop_exe_integrity_error(executable) + if error: + raise RuntimeError(f"The updated Desktop executable is invalid: {error}") + resources = executable.parent / "resources" + for required in (resources / "app.asar", resources / "app.asar.unpacked" / "dist" / "index.html"): + if not required.is_file(): + raise RuntimeError(f"The updated Desktop bundle is incomplete: {required}") + if _desktop_build_needed(desktop, project_root, source_mode=False): + raise RuntimeError("The updated Desktop build is stale, unstamped, or incomplete") diff --git a/scripts/desktop-update/windows.ps1 b/scripts/desktop-update/windows.ps1 index 2fdc441338..a3068ece4a 100644 --- a/scripts/desktop-update/windows.ps1 +++ b/scripts/desktop-update/windows.ps1 @@ -1444,6 +1444,15 @@ try { exit 0 } + # Check only the interpreter here: dependency recovery belongs to update. + $pythonExe = Join-Path $InstallRoot "venv\Scripts\python.exe" + if (-not (Test-Path -LiteralPath $pythonExe -PathType Leaf)) { + $finalCode = 3 + $finalMsg = "Update aborted: $pythonExe is missing. Repair the installation and review antivirus quarantine before retrying." + Write-HandoffLog $finalMsg + exit $finalCode + } + # -- 1. Wait for the Desktop to exit (FAIL CLOSED) ---------------------- Publish-UiProgress "Waiting for Hermes to close" if ($DesktopPid -gt 0) { @@ -1597,10 +1606,11 @@ try { # A zero-exit update is not proof that the runtime survived the update. if ($res.Code -eq 0 -and -not $desktopBuildFailed) { - $verify = Invoke-HermesStep $pythonExe @("-c", "import hermes_cli.main") "verify" + $verifyCode = "import hermes_cli.main; from pathlib import Path; from hermes_cli.desktop_update_verify import verify_windows_desktop_update; verify_windows_desktop_update(Path.cwd())" + $verify = Invoke-HermesStep $pythonExe @("-c", $verifyCode) "verify" if ($verify.Code -ne 0) { $finalCode = 8 - $finalMsg = "The updated Hermes runtime failed verification. Repair the installation and review antivirus quarantine before retrying." + $finalMsg = "The updated Hermes runtime or Desktop build failed verification. Repair the installation and review antivirus quarantine before retrying." Write-HandoffLog $finalMsg exit $finalCode } diff --git a/website/docs/getting-started/updating.md b/website/docs/getting-started/updating.md index 7b84c2a7cf..de9b6c5d50 100644 --- a/website/docs/getting-started/updating.md +++ b/website/docs/getting-started/updating.md @@ -34,7 +34,7 @@ When you run `hermes update`, the following steps occur: ### Missing Windows updater files -If the maintained updater script is missing (for example after antivirus quarantine), the legacy update forwarder fails instead of reporting a successful hand-off. Repair the installation and review the security software's quarantine report before retrying; do not disable antivirus protection. The maintained updater also checks that the updated Python runtime can import the CLI before reporting success. These checks do not validate the desktop artifact's build stamp. +If the maintained updater script is missing (for example after antivirus quarantine), the legacy update forwarder fails instead of reporting a successful hand-off. Repair the installation and review the security software's quarantine report before retrying; do not disable antivirus protection. The maintained updater checks that the updated Python runtime can import the CLI and that the packaged Desktop has a valid Windows executable, its app archive and renderer entry files, and a current build stamp before reporting success. Missing prerequisites are reported before waiting for Desktop shutdown; dependency repair is still allowed to run as part of the update. ### Updating against a non-default branch: `--branch`