The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test: R2's custody test stalls git with a clean filter, not a hook the updater no longer runs
Teknium62c29c2a94f0
diff --git a/tests/hermes_cli/test_update_lock_protocol.py b/tests/hermes_cli/test_update_lock_protocol.pyindex 9ece6563f8f..d86cbfd84b0 100644--- a/tests/hermes_cli/test_update_lock_protocol.py+++ b/tests/hermes_cli/test_update_lock_protocol.py@@ -278,7 +278,7 @@ from hermes_cli.update_lock import UpdateLockfrom hermes_cli.update_cmd import _git_runroot = Path(sys.argv[2])assert UpdateLock(path=root / "owner-marker", install_root=root).acquire()-_git_run(["git"], ["commit", "-qm", "after"], cwd=root, check=True)+_git_run(["git"], ["add", "tracked"], cwd=root, check=True)"""@@ -289,8 +289,9 @@ def _git(root: Path, *args: str) -> str:@posix_onlydef test_git_keeps_checkout_custody_after_its_updater_is_killed(tmp_path):- """R2: `_git_run`'s git (and the hook it runs) inherits the checkout lock. Pre-fix the- killed updater's lock fell free while its git still committed, and a contender acquired."""+ """R2: `_git_run`'s git (and any program it runs) inherits the checkout lock. Pre-fix the+ killed updater's lock fell free while its git still wrote the index, and a contender acquired.+ A clean filter stalls git: repository hooks never run under the updater (F1)."""root = tmp_path / "checkout"root.mkdir()_git(root, "init", "-q")@@ -299,22 +300,23 @@ def test_git_keeps_checkout_custody_after_its_updater_is_killed(tmp_path):(root / "tracked").write_text("before\n")_git(root, "add", "tracked")_git(root, "commit", "-qm", "before")+ stall = tmp_path / "stall.py"+ stall.write_text(f"import os, sys, time\nfrom pathlib import Path\nr = Path({str(tmp_path)!r})\n"+ "(r / 'stalled').write_text(str(os.getpid()))\n"+ "while not (r / 'go').exists(): time.sleep(0.02)\n"+ "sys.stdout.buffer.write(sys.stdin.buffer.read())\n")+ _git(root, "config", "filter.stall.clean", f"'{sys.executable}' '{stall}'")+ (root / ".git/info/attributes").write_text("tracked filter=stall\n")(root / "tracked").write_text("after\n")- _git(root, "add", "tracked")- hook = root / ".git/hooks/pre-commit"- hook.write_text(f"#!{sys.executable}\nimport os, time\nfrom pathlib import Path\nr = Path({str(tmp_path)!r})\n"- "(r / 'hook').write_text(str(os.getpid()))\n"- "while not (r / 'go').exists(): time.sleep(0.02)\n")- hook.chmod(0o700)owner = _python(tmp_path, _GIT_OWNER, root, env={**os.environ, "GIT_CONFIG_NOSYSTEM": "1","GIT_CONFIG_GLOBAL": os.devnull})contender = UpdateLock(path=tmp_path / "contender-marker", install_root=root)try:- hook_pid = int(_wait_for(tmp_path / "hook", owner))+ stalled_pid = int(_wait_for(tmp_path / "stalled", owner))owner.kill()owner.wait()- assert _alive(hook_pid)- assert contender.acquire() is False, "a contender owns the checkout while git still commits"+ assert _alive(stalled_pid)+ assert contender.acquire() is False, "a contender owns the checkout while git still writes"(tmp_path / "go").touch()end = time.monotonic() + 30while not contender.acquire():