fix(goals): reject dead wait-on PIDs

This commit is contained in:
KoNit-K
2026-09-14 20:14:18 +08:00
committed by Teknium
parent 8d66d2dd30
commit c70db196eb
2 changed files with 16 additions and 0 deletions
+2
View File
@@ -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:
+14
View File
@@ -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