Skip to content

The agent that grows with you

fix(update): key the early-spawn sync on currency, not on a commit

ethernet6ce9ed4223d8
diff --git a/hermes_cli/venv_sync.py b/hermes_cli/venv_sync.py
index ef5fd604de4..08046dcac2b 100644
--- a/hermes_cli/venv_sync.py
+++ b/hermes_cli/venv_sync.py
@@ -257,14 +257,15 @@ def prepare_launch(project_root: Path, argv: list[str]) -> Path | None:
# under the launching process's own claim (its pid is our ancestor) we ARE that
# tail and owe nothing — without this, a pending marker recurses forever.
if not lock.acquired and read_live_update() is not None:
- from pm.environments import committed_venv
-
- if committed_venv(root) is not None:
+ if current:
return None
- # A process the update spawns before PM commits (a restarted gateway) has no
- # environment to run on. Commit one — never the tail, which is the updater's —
- # then relaunch below; the relaunched process sees the commit and returns above.
+ # A process the update spawns before its dependencies are current (a restarted
+ # gateway) would boot on a tree built for another interpreter. Sync — never the
+ # tail, which is the updater's — then relaunch below into a current install.
_sync_source_dependencies(root, arm=False)
+ if not pm.venv_is_current(project_root=root):
+ # Relaunching would land back here and sync again, forever.
+ raise RuntimeError("dependency sync left this install out of date")
else:
_finish_source_update(root, current=current, pending=pending)
finally:
diff --git a/tests/pm/test_source_update_launch.py b/tests/pm/test_source_update_launch.py
index be0429e813f..7f8ecb03861 100644
--- a/tests/pm/test_source_update_launch.py
+++ b/tests/pm/test_source_update_launch.py
@@ -270,8 +270,8 @@ def test_launch_without_marker_publishes_then_skips_and_rebuilds_on_lock_change(
@pytest.mark.platforms("posix")
def test_process_spawned_by_the_update_commits_dependencies_but_not_the_tail(source_launch, tmp_path):
- """A process an update spawns before PM commits (its restarted gateway) must not boot on the
- pre-PM venv: that tree was built for the old interpreter and loses its compiled modules."""
+ """A process an update spawns before its dependencies are current (its restarted gateway)
+ must not boot on a tree built for another interpreter; it syncs, but leaves the tail alone."""
import time
from hermes_cli.update_lock import update_marker_path
from pm.environments import committed_venv