The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): fingerprint orphan backends from the classification psutil handle
Tekniumce942ab125e2
diff --git a/hermes_cli/update_cmd.py b/hermes_cli/update_cmd.pyindex adedb4e8f03..de2f6cb3728 100644--- a/hermes_cli/update_cmd.py+++ b/hermes_cli/update_cmd.py@@ -5697,11 +5697,13 @@ def _orphaned_desktop_backend_pids(continuetry:proc = psutil.Process(int(pid))- from gateway.status import get_process_start_time-- process_start_time = get_process_start_time(int(pid))- if process_start_time is None:- return None+ # Fingerprint from the SAME psutil handle used for classification+ # below, quantized to centiseconds — the exact scheme+ # gateway.status.get_process_start_time uses on Windows, so the+ # value round-trips through pid_is_hermes at kill time. (Reading+ # /proc/<pid>/stat here instead would consult the HOST process+ # table and use different units.)+ process_start_time = int(round(proc.create_time() * 100))except psutil.NoSuchProcess:# The candidate itself exited during classification; there is# nothing left to reap and no identity to pass to taskkill.diff --git a/tests/gateway/test_whatsapp_connect.py b/tests/gateway/test_whatsapp_connect.pyindex daf2b3345a3..756282ba294 100644--- a/tests/gateway/test_whatsapp_connect.py+++ b/tests/gateway/test_whatsapp_connect.py@@ -337,7 +337,9 @@ class TestKillPortProcess:return mock_taskkillreturn MagicMock()- with patch("plugins.platforms.whatsapp.adapter.subprocess.run", side_effect=run_side_effect) as mock_run:+ with patch("plugins.platforms.whatsapp.adapter.subprocess.run", side_effect=run_side_effect) as mock_run, \+ patch("plugins.platforms.whatsapp.adapter._pid_looks_like_node_bridge",+ return_value=True):_kill_port_process(3000)# netstat called@@ -350,6 +352,31 @@ class TestKillPortProcess:for call in mock_run.call_args_list)+ @pytest.mark.windows_only+ def test_windows_refuses_taskkill_on_non_bridge_pid(self):+ """#89614 class: the netstat-scanned PID is a bare number — if the+ live process is not a node bridge, taskkill must never fire."""+ from plugins.platforms.whatsapp.adapter import _kill_port_process++ netstat_output = (+ " Proto Local Address Foreign Address State PID\n"+ " TCP 0.0.0.0:3000 0.0.0.0:0 LISTENING 12345\n"+ )++ def run_side_effect(cmd, **kwargs):+ if cmd[0] == "netstat":+ return MagicMock(stdout=netstat_output)+ return MagicMock()++ with patch("plugins.platforms.whatsapp.adapter.subprocess.run", side_effect=run_side_effect) as mock_run, \+ patch("plugins.platforms.whatsapp.adapter._pid_looks_like_node_bridge",+ return_value=False):+ _kill_port_process(3000)++ assert not any(+ call.args[0][0] == "taskkill" for call in mock_run.call_args_list+ )+@pytest.mark.linux_onlydef test_kills_only_listeners_on_linux(self):