The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): read_live_update's fail-open waiver names the checkout kernel lock as the guard
Teknium3004b252c9cf
diff --git a/hermes_cli/update_lock.py b/hermes_cli/update_lock.pyindex 6da39e07d20..37daecedc78 100644--- a/hermes_cli/update_lock.py+++ b/hermes_cli/update_lock.py@@ -857,7 +857,11 @@ def read_live_update(*, path: Path | None = None, install_root: Path | str | Nonupdater's tree (its completion, build or git) still runs, the marker is kept, and theanswer is a ``held`` holder (R6; ``marker.sh``/``marker.ps1`` answer ``held`` too). Otherwisea dead marker is reclaimed — judged again and removed inside the marker mutex, so a claim- published after our first read is never the one deleted. Never raises.+ published after our first read is never the one deleted. Never raises: a marker that cannot+ be judged at all also reads as ``None``. That fails open on the MARKER only; the checkout+ kernel lock is the guard, and every caller that acts on ``None`` still consults it+ (``update_in_progress`` ORs :func:`checkout_lock_held`; ``UpdateLock.acquire`` /+ ``acquire_checkout`` take it), so a live update is never joined or raced through this answer."""marker = path or update_marker_path()try:@@ -870,7 +874,7 @@ def read_live_update(*, path: Path | None = None, install_root: Path | str | Nonif _reclaim_dead(marker, install_root) == "held":return UpdateHolder(pid=0, age_seconds=max(parsed.age(), 0.0) if parsed.started_at is not None else 0.0,held=True)- except Exception as exc: # health: allow BLE001 -- documented never-raises probe: unjudgeable = no live update+ except Exception as exc: # health: allow BLE001 -- never raises: fails open on the marker only; the kernel lock guards (doc)logger.debug("Could not judge update marker %s: %s", marker, exc)return Nonediff --git a/tests/hermes_cli/test_update_lock.py b/tests/hermes_cli/test_update_lock.pyindex 4771c94bd22..04de47c0b25 100644--- a/tests/hermes_cli/test_update_lock.py+++ b/tests/hermes_cli/test_update_lock.py@@ -503,6 +503,37 @@ def test_checkout_lock_excludes_an_update_from_another_home(tmp_path):lock.release()[email protected]("posix")+def test_an_unjudgeable_marker_never_admits_a_contender_past_a_held_checkout_lock(tmp_path, monkeypatch):+ """L5: read_live_update never raises, so a marker it cannot judge (any exception) reads as+ "no live update". That fails open on the marker only: the checkout kernel lock stays the+ guard, so update_in_progress still answers True and a contender's acquire is refused."""+ from hermes_cli import update_lock++ install = tmp_path / "checkout"+ install.mkdir()+ marker_path = tmp_path / "marker"+ holder = subprocess.Popen(+ [sys.executable, "-c", _HOLD_CHECKOUT, str(REPO_ROOT), str(install), str(tmp_path / "homeA" / "m")],+ stdout=subprocess.PIPE, stdin=subprocess.DEVNULL, text=True,+ )+ try:+ assert holder.stdout.readline().strip() == "held"+ _claim_v2(marker_path, holder.pid)++ def unjudgeable(_path):+ raise RuntimeError("an error the parse was never expected to raise")++ monkeypatch.setattr(update_lock, "_read_marker", unjudgeable)+ assert read_live_update(path=marker_path, install_root=install) is None+ assert update_in_progress(install), "an unjudgeable marker hid a held checkout lock"+ lock = UpdateLock(path=marker_path, install_root=install)+ assert lock.acquire() is False, "a contender got past a held checkout lock"+ finally:+ holder.kill()+ holder.wait()++@pytest.mark.platforms("posix")def test_checkout_lock_outlives_its_owner_while_an_inheriting_child_runs(tmp_path):"""Invariant: lock free => no process of the update tree alive (pass_fds children)."""