Skip to content

The agent that grows with you

refactor(update): print the owed-tail notice once, in the process that boots

kshitijk4poord9f6a844c1b3
diff --git a/hermes_cli/venv_sync.py b/hermes_cli/venv_sync.py
index 85b234ad0cd..2a1a7238ee9 100644
--- a/hermes_cli/venv_sync.py
+++ b/hermes_cli/venv_sync.py
@@ -228,8 +228,7 @@ def _supervised_child() -> bool:
Launcher markers only — not INVOCATION_ID, which systemd exports to every
descendant: an ordinary hermes command inside a CI runner still owes its repair.
- Same truthy set as the neighbouring ``HERMES_DISABLE_LAZY_INSTALLS`` read, so
- an explicit ``0``/``false`` does not suppress the completion tail.
+ Parsed as a truthy flag, so an explicit ``0``/``false`` does not suppress the tail.
"""
return any(
os.environ.get(name, "").strip().lower() in ("1", "true", "yes", "on")
@@ -245,13 +244,9 @@ def prepare_launch(project_root: Path, argv: list[str]) -> Path | None:
so a tail that failed is retried on the next launch WITHOUT rebuilding
dependencies that are already current. Old updaters need not write a
marker (and cannot accidentally clear this obligation).
- A supervised child never retries that tail: its manager restarts it on
- every start, so a sticky marker would re-run the tail (and its
- environment builds) on each boot until the disk fills. The tail stays
- the CLI's to finish, via ``hermes update`` / ``hermes pm install``.
- Stale dependencies stay a supervised child's one-shot duty, though: it
- still syncs those and relaunches instead of booting on an out-of-date
- tree (or crash-looping under its manager's restart policy).
+ A supervised child leaves that tail to ``hermes update`` when its dependencies
+ are current: its manager restarts it on every start, so a sticky marker would
+ re-run the tail (and its environment builds) on each boot until the disk fills.
Return the store interpreter when this process must restart cleanly.
"""
import os
@@ -286,11 +281,8 @@ def prepare_launch(project_root: Path, argv: list[str]) -> Path | None:
current = pm.venv_is_current(project_root=root)
pending = completion_pending_path(root)
- if current and pending.is_file() and _supervised_child():
- # Left owed, not dropped: say so where an operator of the unit will read it.
- print("hermes: a source update is unfinished; run `hermes update` from a shell to finish it",
- file=sys.stderr, flush=True)
- elif not current or pending.is_file():
+ owed_to_cli = current and pending.is_file() and _supervised_child()
+ if not owed_to_cli and (not current or pending.is_file()):
lock = UpdateLock()
if not lock.acquire():
raise RuntimeError("an update is still running; wait for it to exit, then relaunch Hermes")
@@ -323,6 +315,11 @@ def prepare_launch(project_root: Path, argv: list[str]) -> Path | None:
if not current or not same:
publish_launchers(root)
return python
+ if owed_to_cli:
+ # Left owed, not dropped: say so (once, in the process that boots) where an
+ # operator of the unit will read it.
+ print("hermes: a source update is unfinished; run `hermes update` from a shell to finish it",
+ file=sys.stderr, flush=True)
return None
diff --git a/tests/hermes_cli/test_update_launch_completion.py b/tests/hermes_cli/test_update_launch_completion.py
index 249f68b5029..7516692bbcb 100644
--- a/tests/hermes_cli/test_update_launch_completion.py
+++ b/tests/hermes_cli/test_update_launch_completion.py
@@ -340,7 +340,7 @@ def test_launch_under_the_owning_update_does_not_run_the_tail_again(tmp_path, mo
def test_supervised_launch_leaves_a_pending_tail_to_the_cli(
tmp_path, monkeypatch, capsys, completion_tail, marker, value, owed_by_cli
):
- """A supervised start retries the tail on every manager restart (#123340).
+ """A supervised start leaves a pending tail to the CLI; its manager restarts it every boot (#123340).
systemd/launchd/s6 restart the gateway under a policy; with a marker that never
clears, each boot would rebuild the completion environment until the disk fills.
@@ -364,7 +364,8 @@ def test_supervised_launch_leaves_a_pending_tail_to_the_cli(
if owed_by_cli:
assert completion_tail == []
assert pending.is_file(), "a supervised child discharged an obligation the CLI still owes"
- assert "run `hermes update`" in capsys.readouterr().err
+ out, err = capsys.readouterr()
+ assert out == "" and err.count("run `hermes update`") == 1
else:
assert len(completion_tail) == 1
assert not pending.is_file()