The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test: the hand-off pid an update child is told is checked by running the hand-off
Tekniumcb070f86e118
diff --git a/tests/scripts/desktop_update/test_posix_handoff_pid_export.py b/tests/scripts/desktop_update/test_posix_handoff_pid_export.pyindex 40a20597791..859636a725b 100644--- a/tests/scripts/desktop_update/test_posix_handoff_pid_export.py+++ b/tests/scripts/desktop_update/test_posix_handoff_pid_export.py@@ -1,47 +1,42 @@-"""posix.sh must export the marker's OWNER as HERMES_UPDATE_HANDOFF_PID, not its own pid.--`hermes update` adopts an existing claim only when the live owner is its own pid, the-``HERMES_UPDATE_HANDOFF_PID`` value, or one of its ancestors-(``update_lock.UpdateLock._is_partner``). The posix hand-off hands marker line 1 to a-*custodian* subshell (``marker_refresher_start``) that outlives the hand-off script, so the-owner is a **sibling** of that script: never its own pid, and never an ancestor of the-``hermes update`` it spawns. Exporting ``$$`` therefore left the custodian unrecognisable and-every desktop-initiated update refused its own claim with exit code 2 ---``Another Hermes update is already running (started Ns ago, process <custodian>)``.--The runtime hand-off protocol suite (``test_desktop_update_posix_handoff_protocol.py``) is-``platforms("linux")`` because it decides liveness through ``/proc``; these assertions pin the-same invariant on every platform.+"""The update a POSIX Desktop hand-off spawns is told the marker's live owner as its hand-off pid.++``hermes update`` adopts an existing claim only when the live owner is its own pid, the+``HERMES_UPDATE_HANDOFF_PID`` value, or an ancestor (``update_lock.UpdateLock._is_partner``).+``posix.sh`` hands marker line 1 to a custodian before any update work starts, and the custodian is+a sibling of the update child, never an ancestor. On macOS the delegate line cannot rescue it (a+whole-second creation time never matches the child's own), so a hand-off pid naming the script+instead of the custodian made every Desktop-initiated update refuse its own claim with exit 2+(#133992, #134268, #134309, #134381)."""from __future__ import annotations-from pathlib import Path-import pytest-POSIX = Path(__file__).resolve().parents[3] / "scripts" / "desktop-update" / "posix.sh"-EXPORT = "export HERMES_UPDATE_HANDOFF_PID="-+from tests.scripts.desktop_update.test_desktop_update_posix_marker import FAKE_CLI, _custodian, _install, _run[email protected](scope="module")-def body() -> str:- return POSIX.read_text(encoding="utf-8-sig")+pytestmark = pytest.mark.platforms("linux") # /proc creation times, like the rest of the posix marker suite--def test_handoff_pid_names_the_marker_owner_not_the_script(body):- """Line 1 of the marker carries $MY_PID, so that is what the update child must be told."""- assert f'{EXPORT}"$MY_PID"' in body- assert f'{EXPORT}"$$"' not in body+RECORD_UPDATE_VIEW = """+import os, sys+from pathlib import Path+if sys.argv[1:2] == ['update']:+ marker = Path(os.environ['HERMES_HOME']) / '.hermes-update-in-progress'+ owner = marker.read_text(encoding='utf-8-sig').splitlines()[0]+ Path(os.environ['HANDOFF_VIEW']).write_text(+ f"{os.environ.get('HERMES_UPDATE_HANDOFF_PID', '')} {owner}", encoding='utf-8')+"""-def test_custodian_handover_precedes_the_export(body):- """$MY_PID only becomes the custodian when marker_refresher_start runs; an export placed- before that call site would still name the hand-off script itself."""- call_site = body.index("\nmarker_refresher_start\n") # the call, not the definition- assert call_site < body.index(EXPORT)+def test_the_update_child_is_told_the_live_marker_owner(tmp_path):+ home, install = _install(tmp_path)+ (install / "hermes_cli" / "main.py").write_text(RECORD_UPDATE_VIEW + FAKE_CLI, encoding="utf-8")+ view = tmp_path / "view.txt"+ result = _run(tmp_path, home, install, HANDOFF_VIEW=str(view))-def test_the_owner_the_marker_names_is_what_my_pid_is_set_to(body):- """marker.sh writes line 1 from "$MY_PID" (marker_custody_take_locked / marker_canonical),- and the handover is what re-points it at the custodian."""- assert 'MY_PID="$MARKER_REFRESHER"' in body+ assert result.returncode == 0, result.stdout + result.stderr+ custodian = _custodian(home)+ assert custodian, "the hand-off never named a custodian"+ handoff_pid, owner = view.read_text(encoding="utf-8").split()+ assert owner == custodian, "line 1 must name the custodian while the update runs"+ assert handoff_pid == owner, "the update child must be told the marker's owner, not the hand-off script"