Skip to content

The agent that grows with you

fix(update): bracket the post-repair lazy restore with the lazy-refresh marker

teknium1bafbf8803200
diff --git a/hermes_cli/update_cmd.py b/hermes_cli/update_cmd.py
index 72ca4be62d9..72f9630a2bb 100644
--- a/hermes_cli/update_cmd.py
+++ b/hermes_cli/update_cmd.py
@@ -701,8 +701,15 @@ def _repair_current_checkout(
# are gone (#112571). Restore the pre-cutover snapshots exactly as the pull path
# and the unhealthy-venv repair do; the healthy core set needs no reinstall.
repair_prefix, repair_env = _pip_install_prefix(repair_uv)
- _m()._refresh_active_lazy_features(
- repair_prefix, env=repair_env, features=active_lazy_features)
+ # Same marker discipline as the pull path: an interrupted or failed lazy restore
+ # must leave the breadcrumb so the next `hermes` run finishes the repair.
+ _write_lazy_refresh_incomplete_marker()
+ if _m()._refresh_active_lazy_features(
+ repair_prefix, env=repair_env, features=active_lazy_features):
+ _m()._clear_lazy_refresh_incomplete_marker()
+ else:
+ print(" ⚠ Lazy-refresh recovery incomplete — run `hermes` again "
+ "to finish import-based venv repair.")
_m()._restore_active_tool_dependencies(
active_tool_dependencies, repair_prefix, env=repair_env)
current_checkout_complete = _repair_node_deps_on_current_checkout(
diff --git a/tests/hermes_cli/test_cmd_update.py b/tests/hermes_cli/test_cmd_update.py
index fa5df5d8701..b19e2153981 100644
--- a/tests/hermes_cli/test_cmd_update.py
+++ b/tests/hermes_cli/test_cmd_update.py
@@ -267,7 +267,7 @@ class TestRepairCurrentCheckoutRuntimeRepair:
"""Already-up-to-date path after a managed SQLite runtime repair (#112571)."""
@staticmethod
- def _run(monkeypatch, *, repaired: bool):
+ def _run(monkeypatch, *, repaired: bool, lazy_refresh_ok: bool = True):
from hermes_cli.managed_uv import RuntimeRepairResult
from hermes_cli import main as hm
@@ -282,10 +282,19 @@ class TestRepairCurrentCheckoutRuntimeRepair:
monkeypatch.setattr(
update_cmd, "_pip_install_prefix", lambda _uv: (["uv", "pip"], {"VIRTUAL_ENV": "venv"})
)
+ markers = []
monkeypatch.setattr(
- hm, "_refresh_active_lazy_features",
- lambda prefix, *, env, features: restored.append(("lazy", prefix, env, features)),
+ update_cmd, "_write_lazy_refresh_incomplete_marker", lambda: markers.append("write")
)
+ monkeypatch.setattr(
+ hm, "_clear_lazy_refresh_incomplete_marker", lambda: markers.append("clear")
+ )
+
+ def refresh(prefix, *, env, features):
+ restored.append(("lazy", prefix, env, features))
+ return lazy_refresh_ok
+
+ monkeypatch.setattr(hm, "_refresh_active_lazy_features", refresh)
monkeypatch.setattr(
hm, "_restore_active_tool_dependencies",
lambda dependencies, prefix, *, env: restored.append(("tools", prefix, env, dependencies)),
@@ -312,23 +321,34 @@ class TestRepairCurrentCheckoutRuntimeRepair:
upstream_checked=True,
_windows_gateway_resume=None,
)
- return restored, lazy_features, tool_dependencies
+ return restored, lazy_features, tool_dependencies, markers
def test_restores_optional_dependencies_after_runtime_repair(self, monkeypatch):
"""A SQLite venv replacement passes the core-import probe, yet the swapped-in venv was
built from uv.lock alone: the captured lazy backends and Hermes Tools deps must be
restored into it, once each, with the repaired installer prefix."""
- restored, lazy_features, tool_dependencies = self._run(monkeypatch, repaired=True)
+ restored, lazy_features, tool_dependencies, markers = self._run(monkeypatch, repaired=True)
assert restored == [
("lazy", ["uv", "pip"], {"VIRTUAL_ENV": "venv"}, lazy_features),
("tools", ["uv", "pip"], {"VIRTUAL_ENV": "venv"}, tool_dependencies),
]
+ assert markers == ["write", "clear"]
+
+ def test_failed_lazy_restore_keeps_incomplete_marker(self, monkeypatch, capsys):
+ """Mirror of the pull path (update_cmd_deps): the lazy-refresh breadcrumb is written
+ before the restore and cleared only when the refresh reports success, so a failed
+ restore into the swapped-in venv is picked up by the next `hermes` run instead of
+ being hidden behind "Already up to date!"."""
+ _, _, _, markers = self._run(monkeypatch, repaired=True, lazy_refresh_ok=False)
+ assert markers == ["write"]
+ assert "Lazy-refresh recovery incomplete" in capsys.readouterr().out
def test_healthy_venv_without_runtime_repair_is_left_alone(self, monkeypatch):
"""Control: no repair + healthy core imports = the venv was never replaced, so nothing
is reinstalled (the up-to-date path stays a no-op for Python deps)."""
- restored, _, _ = self._run(monkeypatch, repaired=False)
+ restored, _, _, markers = self._run(monkeypatch, repaired=False)
assert restored == []
+ assert markers == []
class TestCmdUpdateBranchFallback: