Skip to content

The agent that grows with you

fix(update): the pause reader calls update_lock.incarnation_live, the one incarnation rule (R12)

Tekniumc59e10b359d8
diff --git a/hermes_cli/update_pause_record.py b/hermes_cli/update_pause_record.py
index 5e2ee0c196e..422f10fe02d 100644
--- a/hermes_cli/update_pause_record.py
+++ b/hermes_cli/update_pause_record.py
@@ -72,18 +72,14 @@ def identity(pid: int | None = None) -> dict:
def identity_is_live(ident: dict | None) -> bool:
- """The update marker's incarnation rule (``update_lock``), applied to a recorded identity."""
+ """The update marker's incarnation rule (``update_lock.incarnation_live``) for a recorded identity.
+
+ Unprovable (alive, no readable creation time) counts as live: a record is never taken from, nor
+ a paused process restarted over, a process that may still be the one recorded.
+ """
from hermes_cli import update_lock
- try:
- pid = int((ident or {}).get("pid") or 0)
- except (TypeError, ValueError):
- return False
- recorded = str((ident or {}).get("ct") or "")
- try:
- created = float(recorded[3:]) if recorded.startswith("ct:") else None
- except ValueError:
- created = None
- return pid > 0 and update_lock._identity_live(pid, created, 0.0)
+ ident = ident or {}
+ return update_lock.incarnation_live(ident.get("pid") or 0, ident.get("ct") or None) is not False
class RecordConflict(OSError):
diff --git a/tests/hermes_cli/test_update_pause_record.py b/tests/hermes_cli/test_update_pause_record.py
index 7a62e3d28da..dd65e835048 100644
--- a/tests/hermes_cli/test_update_pause_record.py
+++ b/tests/hermes_cli/test_update_pause_record.py
@@ -403,3 +403,7 @@ def test_our_own_pid_is_ours_only_at_our_exact_creation_time():
created = float(me["ct"][3:])
reused = {"pid": os.getpid(), "ct": f"ct:{created - 0.5:.3f}"} # inside the cross-writer skew
assert not pause_record.identity_is_live(reused), "a killed update's record became ours by pid reuse"
+
+
+def test_a_record_naming_our_pid_without_a_creation_time_is_a_previous_incarnation():
+ assert not pause_record.identity_is_live({"pid": os.getpid(), "ct": None})