The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): an unbuilt Desktop app is reported by one whole line the hand-offs match (review F6-desktop-build-debt-grep)
Tekniume28c05e4b02a
diff --git a/hermes_cli/source_build.py b/hermes_cli/source_build.pyindex f9208d71bd8..086a1e9c12d 100644--- a/hermes_cli/source_build.py+++ b/hermes_cli/source_build.py@@ -138,12 +138,18 @@ def build_update_products(project_root: Path, *, desktop: bool) -> None:attempt("feature dependencies", lambda: _install_configured_features_missing_deps(project_root))frontends = source_frontends(project_root)if frontends:- env = source_build_env(explicit=True)+ desktop_built = False+ env: dict = {}workspaces = frontends + (("apps/desktop",) if desktop else ())publish_stage("Updating Node dependencies")++ def node_dependencies() -> None:+ # Acquiring npm is part of this step: its failure must be reported like the install's.+ env.update(source_build_env(explicit=True))+ prepare_source_dependencies(project_root, workspaces, env=env, explicit=True)+# Every product compiles from these node_modules: without them there is nothing to build.- if attempt("Node dependencies", lambda: prepare_source_dependencies(- project_root, workspaces, env=env, explicit=True)):+ if attempt("Node dependencies", node_dependencies):# An update that changed no TUI/web input reuses the receipted output, as the# launch path already does; recompiling it produces the same bytes. Desktop# additionally needs the packaged app to name HEAD (its baked stamp carries the@@ -162,7 +168,11 @@ def build_update_products(project_root: Path, *, desktop: bool) -> None:publish_stage("Building the web UI")attempt("web UI build", lambda: build_source_web(project_root, env=env))if desktop:- attempt("desktop app build", lambda: _build_desktop_product(project_root, env, publish_stage))+ desktop_built = attempt("desktop app build", lambda: _build_desktop_product(project_root, env, publish_stage))+ if desktop and not desktop_built:+ # One whole line the Desktop hand-off scripts match: the follow-up text is truncated+ # and names whichever products failed first, so it cannot say if THIS app was rebuilt.+ print(f" Desktop app build owed: {failures[-1][0]} failed")# A configured memory provider that no longer ships in core is installed from the# catalog for every profile home sharing this venv (config, data and tool names# unchanged). The update must finish even if the migration blows up.diff --git a/scripts/desktop-update/posix.sh b/scripts/desktop-update/posix.shindex 84e15ea6335..aad25662d0a 100755--- a/scripts/desktop-update/posix.sh+++ b/scripts/desktop-update/posix.sh@@ -890,10 +890,11 @@ fiif [ "$CODE" -eq 0 ]; then FINAL_CODE=0 FINAL_MSG="Update complete."# Contract C3: a Desktop build that fails after the code committed is an owed- # follow-up (hermes update exits 0 and prints it). The user is on the new- # Hermes, but this app was not rebuilt: say so and say how to fix it, never- # "finished OK" and never "still on the previous version".- if printf '%s' "$OUT" | grep -Eq "Update follow-up 'build' did not finish: .*(desktop app build|Node dependencies)"; then+ # follow-up (hermes update exits 0 and prints one whole "Desktop app build+ # owed:" line for it; the follow-up text itself is truncated). The user is on+ # the new Hermes, but this app was not rebuilt: say so and say how to fix it,+ # never "finished OK" and never "still on the previous version".+ if printf '%s\n' "$OUT" | grep -Eq '^[[:space:]]*Desktop app build owed: '; thenAPP_REBUILD_FAILED=1DONE_NOTE="Hermes was updated, but the Desktop app could not be rebuilt, so it still runs its old build. Run hermes desktop --force-build in a terminal to rebuild it; the update log has the build error."log "desktop app build is an owed follow-up of the committed update"diff --git a/scripts/desktop-update/windows.ps1 b/scripts/desktop-update/windows.ps1index 2bda29767dc..6b97693f5d5 100644--- a/scripts/desktop-update/windows.ps1+++ b/scripts/desktop-update/windows.ps1@@ -1731,6 +1731,15 @@ try {}}+ # Contract C3: a Desktop build that failed after the code committed is an owed follow-up+ # (exit 0); the CLI prints one whole "Desktop app build owed:" line for it. The user is on+ # the new Hermes but this app was not rebuilt: a manual outcome, never plain success.+ if ($res.Code -eq 0 -and -not $desktopBuildFailed -and $res.Output -match '(?m)^\s*Desktop app build owed: ') {+ $manualAction = $true+ $manualMsg = ("Hermes was updated, but the Desktop app could not be rebuilt, so it still runs its old build. Run ``hermes desktop --force-build`` in a terminal to rebuild it; the update log has the build error. " + $manualMsg).Trim()+ Write-HandoffLog $manualMsg+ }+if ($res.Code -eq 0 -and -not $desktopBuildFailed) {$finalCode = 0$finalMsg = "Update complete."diff --git a/tests/hermes_cli/test_source_build.py b/tests/hermes_cli/test_source_build.pyindex dbdea3e1477..afe7de03449 100644--- a/tests/hermes_cli/test_source_build.py+++ b/tests/hermes_cli/test_source_build.py@@ -321,6 +321,35 @@ def test_update_failure_raises_without_retries_or_replacing_live_app(source_prodassert not (Path(os.environ["HERMES_HOME"]) / "desktop-build-stamp.json").exists()[email protected]("linux")[email protected]("failure", ["npm-unavailable", "desktop-after-long-feature-failure"])+def test_unbuilt_desktop_is_named_on_one_whole_line(source_products, monkeypatch, capsys, failure):+ # The Desktop hand-off keys on this line: the receipt follow-up is truncated and leads with+ # whichever product failed first, and an npm acquisition failure used to escape un-named.+ import hermes_cli.main_install_repair as install_repair+ from hermes_cli.source_build import ProductBuildError, build_update_products++ root, _ = source_products++ def fail(error):+ def raiser(*_args, **_kwargs):+ raise error+ return raiser++ if failure == "npm-unavailable":+ monkeypatch.setattr(pm, "ensure", fail(pm.InstallError("npm", "unavailable")))+ expected = "Desktop app build owed: Node dependencies failed"+ else:+ monkeypatch.setattr(install_repair, "_install_configured_features_missing_deps",+ fail(RuntimeError("pip install failed: " + "x" * 600)))+ (root / "fail-desktop").touch()+ expected = "Desktop app build owed: desktop app build failed"+ with pytest.raises(ProductBuildError):+ build_update_products(root, desktop=True)+ lines = [line.strip() for line in capsys.readouterr().out.splitlines()]+ assert [line for line in lines if line.startswith("Desktop app build owed:")] == [expected]++@pytest.mark.platforms("linux")@pytest.mark.parametrize("desktop", [False, True])def test_module_cli_builds_the_requested_products(source_products, desktop, monkeypatch):diff --git a/tests/scripts/desktop_update/test_desktop_update_gateway_flag.py b/tests/scripts/desktop_update/test_desktop_update_gateway_flag.pyindex 36133d6ce78..8f3d05b9185 100644--- a/tests/scripts/desktop_update/test_desktop_update_gateway_flag.py+++ b/tests/scripts/desktop_update/test_desktop_update_gateway_flag.py@@ -13,6 +13,7 @@ opt-out can silently regress.from __future__ import annotations+import jsonimport osimport subprocessimport time@@ -34,10 +35,11 @@ requires_posix_handoff = pytest.mark.skipif(FAKE_HERMES = """#!/usr/bin/env bashcase "$*" in *--help*) echo "--keep-stash"; exit 0 ;; esacprintf '%s\\n' "$*" >> "$HERMES_TEST_ARGV"+case " $* " in *" update "*) printf '%s\\n' "${HERMES_TEST_UPDATE_OUTPUT:-}" ;; esacexit 0"""-def _run_handoff(tmp_path: Path, extra_args: list[str]) -> list[str]:+def _run_handoff(tmp_path: Path, extra_args: list[str], update_output: str = "") -> list[str]:"""Run the real hand-off end to end; return the argv of each hermes call."""install_root = tmp_path / "hermes-agent"(install_root / "venv" / "bin").mkdir(parents=True)@@ -47,7 +49,8 @@ def _run_handoff(tmp_path: Path, extra_args: list[str]) -> list[str]:argv_log = tmp_path / "argv.jsonl"# posix.sh honours an ambient HERMES_HOME; the result file must land where this test looks.- env = {**os.environ, "TMPDIR": str(tmp_path), "HERMES_TEST_ARGV": str(argv_log), "HERMES_HOME": str(tmp_path)}+ env = {**os.environ, "TMPDIR": str(tmp_path), "HERMES_TEST_ARGV": str(argv_log), "HERMES_HOME": str(tmp_path),+ "HERMES_TEST_UPDATE_OUTPUT": update_output}subprocess.run(["/bin/bash", str(SHIM_DIR / "posix.sh"), "--install-root", str(install_root), "--no-ui", *extra_args],env=env,@@ -89,3 +92,19 @@ def test_no_gateway_flag_omits_gateway_from_update(tmp_path):assert "--gateway" not in argv, f"--gateway reappeared in update argv: {call}"assert "--keep-stash" in argv, "--no-gateway must not disturb --keep-stash"assert "--yes" in argv+++@requires_posix_handoff+def test_owed_desktop_build_is_a_manual_outcome_even_when_the_followup_is_truncated(tmp_path):+ """Contract C3: the update committed (exit 0) but this app was not rebuilt.++ The receipt follow-up is capped at 500 chars and leads with whichever product failed first,+ so it can lose the desktop part; the CLI's own whole-line marker is what the hand-off reads.+ """+ followup = " ⚠ Update follow-up 'build' did not finish: feature dependencies: " + "x" * 440+ _run_handoff(tmp_path, [], f"{followup}\n Desktop app build owed: desktop app build failed\n✓ Update complete!")++ result = json.loads((tmp_path / ".hermes-update-result.json").read_text(encoding="utf-8-sig"))+ assert result["exit_code"] == 0+ assert result["manual"] is True+ assert "could not be rebuilt" in result["message"]