The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: an unopenable checkout lock reads held to every Python reader, as the scripts and Desktop read it
Tekniume046826bf3cd
diff --git a/hermes_cli/update_lock.py b/hermes_cli/update_lock.pyindex f15116f0872..90b2c0d71bf 100644--- a/hermes_cli/update_lock.py+++ b/hermes_cli/update_lock.py@@ -1280,14 +1280,22 @@ def checkout_lock_held(install_root: Path | str | None = None) -> bool:A probe takes the lock for the microseconds of one try and drops it (closing the fd), theway ``marker.sh::checkout_lock_held`` does; an updater acquiring at that instant waits- :data:`CHECKOUT_CONTENTION_WAIT_SECONDS` instead of failing (R6/D17)."""+ :data:`CHECKOUT_CONTENTION_WAIT_SECONDS` instead of failing (R6/D17).++ Only a missing lock file is free. One that exists but cannot be opened answers held, the same+ verdict ``marker.sh`` / ``marker.ps1`` and the Desktop probes give, so no reader admits a+ launch the others would park. A lock call that fails outright (ENOLCK on NFS without lockd,+ EOPNOTSUPP on some SMB shares) means nothing can hold it: free, so the interrupted-pull repair+ runs unguarded there as designed."""path = checkout_lock_path(install_root)if _HELD is not None and _HELD["path"] == str(path):return Truetry:fd = os.open(path, os.O_RDONLY | getattr(os, "O_BINARY", 0))- except OSError:+ except FileNotFoundError:return False+ except OSError:+ return Truetry:if not _try_lock(fd):return Truediff --git a/tests/hermes_cli/test_update_lock_fd_provenance.py b/tests/hermes_cli/test_update_lock_fd_provenance.pyindex 2b411198c57..96dc9f7a8cf 100644--- a/tests/hermes_cli/test_update_lock_fd_provenance.py+++ b/tests/hermes_cli/test_update_lock_fd_provenance.py@@ -114,3 +114,23 @@ def test_exec_child_reenters_the_lock_it_explicitly_inherited(tmp_path):child.wait()contender.release()owner.release()++[email protected]("posix")[email protected](hasattr(os, "geteuid") and os.geteuid() == 0, reason="root opens a mode-000 file")+def test_an_unopenable_checkout_lock_reads_held_and_only_a_missing_one_reads_free(tmp_path):+ root = tmp_path / "checkout"+ root.mkdir()+ lock_path = update_lock.checkout_lock_path(root)+ assert update_lock.checkout_lock_held(root) is False, "no lock file: nothing can hold it"+ lock_path.parent.mkdir(parents=True, exist_ok=True)+ lock_path.touch()+ assert update_lock.checkout_lock_held(root) is False, "an openable, unlocked file is free"+ lock_path.chmod(0)+ try:+ assert update_lock.checkout_lock_held(root) is True, (+ "a lock file that exists but cannot be opened answers held, as marker.sh/marker.ps1 "+ "and the Desktop probes do"+ )+ finally:+ lock_path.chmod(0o600)