fix(desktop): reject incomplete Windows builds before success receipts

Native Windows run 34096838164 reports false success for absent and corrupt executables, missing bundle files, missing chunks and missing or stale stamps. Reuse the existing build identity and PE validators, and check interpreter presence before waiting for Desktop. Preserve dependency recovery and exit-2 refusal behavior.

Co-authored-by: Konstantin Khlopkov <konstantin.khlopkov93@gmail.com>
This commit is contained in:
Teknium
2026-09-07 00:49:39 -07:00
parent 90ac288c7d
commit 5ce8e974c2
3 changed files with 38 additions and 3 deletions
+25
View File
@@ -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")
+12 -2
View File
@@ -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
}
+1 -1
View File
@@ -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`