Skip to content

The agent that grows with you

fix(update): the packaged Desktop build runs in checkout custody (review F04)

Tekniumea49b1f76082
diff --git a/hermes_cli/main_desktop.py b/hermes_cli/main_desktop.py
index 2190922cb17..3ca1ab16bf4 100644
--- a/hermes_cli/main_desktop.py
+++ b/hermes_cli/main_desktop.py
@@ -1566,7 +1566,7 @@ def _diagnose_esbuild_ignore_scripts(output: Optional[str]) -> None:
def build_prepared_desktop(desktop_dir: Path, *, source_mode: bool, npm: str, env: dict,
icons: Path | None = None) -> Optional[Path]:
"""Build prepared desktop sources, then publish the verified staged app."""
- from pm.progress import run_contained
+ from hermes_cli.source_build import run_in_custody # npm writes the checkout: update custody
if not source_mode and sys.platform == "win32" and (ancestor := _desktop_ancestor_in(desktop_dir)):
# The Desktop running this build holds the exe lock the promotion rename needs,
@@ -1600,11 +1600,11 @@ def build_prepared_desktop(desktop_dir: Path, *, source_mode: bool, npm: str, en
if stopped:
print(f" ⚠ Stopped running desktop app to free the build output (pid {', '.join(map(str, stopped))})")
try:
- run_contained(build_cmd, f"Building desktop {build_label}", cwd=desktop_dir, env=build_env)
+ run_in_custody(desktop_dir.parents[1], build_cmd, f"Building desktop {build_label}", cwd=desktop_dir, env=build_env)
if staging_dir is not None:
- run_contained([npm, "run", "builder", "--", "--dir", "--publish", "never",
+ run_in_custody(desktop_dir.parents[1], [npm, "run", "builder", "--", "--dir", "--publish", "never",
f"-c.directories.output={staging_dir}"], "Packaging the desktop app",
- cwd=desktop_dir, env=build_env)
+ cwd=desktop_dir, env=build_env)
packaged_executable = (
_promote_staged_desktop_app(desktop_dir, staging_dir) if staging_dir is not None else None
)
diff --git a/tests/hermes_cli/test_update_custody.py b/tests/hermes_cli/test_update_custody.py
index 869328b2a1e..42eb59926a8 100644
--- a/tests/hermes_cli/test_update_custody.py
+++ b/tests/hermes_cli/test_update_custody.py
@@ -350,3 +350,23 @@ def test_no_build_descendant_outlives_the_build_call(repo, tmp_path, monkeypatch
time.sleep(3)
assert not late.exists(), "a build descendant kept writing after the build call returned"
+
[email protected](not Path("/proc/self/fd").is_dir(), reason="needs /proc fd listing")
+def test_the_desktop_build_runs_in_checkout_custody(repo, tmp_path, monkeypatch):
+ """F04: the desktop app build (npm run build / builder) writes the checkout like the other
+ product builds, so it holds the checkout lock while it runs."""
+ from hermes_cli import main_desktop
+
+ npm = _held_lock_recorder(tmp_path, "npm", "exit 0")
+ out = tmp_path / "npm.out"
+ monkeypatch.setenv("HERMES_TEST_LOCK", os.path.realpath(ul.checkout_lock_path(repo)))
+ monkeypatch.setenv("HERMES_TEST_OUT", str(out))
+ desktop = repo / "apps" / "desktop"
+ desktop.mkdir(parents=True)
+ lock = ul.UpdateLock(path=tmp_path / "marker", install_root=repo)
+ assert lock.acquire()
+ try:
+ main_desktop.build_prepared_desktop(desktop, source_mode=True, npm=str(npm), env=dict(os.environ))
+ finally:
+ lock.release()
+ assert out.read_text(encoding="utf-8-sig").split() == ["yes"], "the desktop build ran without the checkout lock"