The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): a digit-lookalike tmp sibling never crashes lock admission (review N06)
Teknium0ab849e5bd5a
diff --git a/hermes_cli/update_lock.py b/hermes_cli/update_lock.pyindex 63ab4ad2694..e65c3c97b96 100644--- a/hermes_cli/update_lock.py+++ b/hermes_cli/update_lock.py@@ -675,8 +675,8 @@ def _sweep_dead_tmp_siblings(path: Path) -> None:name = entry.nameif not (name.startswith(prefix) and name.endswith(".tmp")):continue- owner = name[len(prefix):].split(".", 1)[0]- if owner.isdigit() and int(owner) != os.getpid() and not _pid_alive(int(owner)):+ owner = _bounded_int(name[len(prefix):].split(".", 1)[0], _U32_MAX)+ if owner is not None and owner != os.getpid() and not _pid_alive(owner):with suppress(OSError):entry.unlink()diff --git a/tests/hermes_cli/test_update_lock.py b/tests/hermes_cli/test_update_lock.pyindex 87aac3ee21c..cb527390410 100644--- a/tests/hermes_cli/test_update_lock.py+++ b/tests/hermes_cli/test_update_lock.py@@ -328,6 +328,19 @@ def test_claim_publishes_whole_and_reclaims_dead_writers_tmp_files(marker):lock.release()[email protected]("owner", ["\u00b2", "\u2460"], ids=["superscript-two", "circled-one"])+def test_tmp_litter_with_a_digit_lookalike_pid_never_breaks_admission(marker, owner):+ """A sibling whose pid field is a Unicode digit lookalike is not a pid we can judge: it is+ left alone and the claim still lands (``str.isdigit`` accepts it, ``int`` refuses it)."""+ odd = marker.with_name(f"{marker.name}.{owner}.tmp")+ odd.write_text("x")++ lock = UpdateLock(path=marker)+ assert lock.acquire() is True+ assert marker.read_text(encoding="utf-8").startswith(f"{os.getpid()}\n")+ lock.release()++def test_unreadable_creation_time_gets_the_v1_ceiling(marker, other_pid, monkeypatch):"""Contract A1: a live pid whose creation time cannot be read (Windows denies it forelevated/other-user pids) is live only within the legacy ceiling: it may be a reused pid."""