Skip to content

The agent that grows with you

fix(goals): reject dead wait-on PIDs

KoNit-Kc70db196eb89
diff --git a/hermes_cli/goals.py b/hermes_cli/goals.py
index d0b754f99ad..cb9b52454e0 100644
--- a/hermes_cli/goals.py
+++ b/hermes_cli/goals.py
@@ -1362,6 +1362,8 @@ class GoalManager:
pid = int(pid)
if pid <= 0:
raise ValueError("pid must be a positive integer")
+ if not _pid_alive(pid):
+ raise ValueError("pid is not alive on this host")
return self._park(reason, waiting_on_pid=pid)
def wait_on_session(self, session_id: str, reason: str = "") -> GoalState:
diff --git a/tests/hermes_cli/test_goals.py b/tests/hermes_cli/test_goals.py
index 17c320913d1..421e447ac79 100644
--- a/tests/hermes_cli/test_goals.py
+++ b/tests/hermes_cli/test_goals.py
@@ -454,6 +454,20 @@ class TestWaitBarrier:
proc.terminate()
proc.wait(timeout=10)
+ def test_wait_on_rejects_a_pid_not_alive_on_this_host(self, hermes_home, monkeypatch):
+ """Regression for #110826: do not persist a barrier for remote/dead PIDs."""
+ from hermes_cli import goals
+ from hermes_cli.goals import GoalManager
+
+ monkeypatch.setattr(goals, "_pid_alive", lambda pid: False)
+ mgr = GoalManager(session_id="wb-dead")
+ mgr.set("ship it")
+
+ with pytest.raises(ValueError, match="not alive on this host"):
+ mgr.wait_on(4242, reason="remote CI")
+
+ assert mgr.state.waiting_on_pid is None
+
def test_stop_waiting_clears_barrier(self, hermes_home):
from hermes_cli.goals import GoalManager