The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): the launch repair never runs git object bytes that do not hash to pre's blob (review N02)
Tekniumc42e9f6211c6
diff --git a/hermes_cli/_launchers.py b/hermes_cli/_launchers.pyindex c73eb5c01ff..5d588ba4c9d 100644--- a/hermes_cli/_launchers.py+++ b/hermes_cli/_launchers.py@@ -369,6 +369,8 @@ def _hermes_closure_repair():blobs = {__INIT__: b''}for rel in __CLOSURE__:blobs[rel] = git_out('cat-file', 'blob', ids[rel])+ if blob_id(blobs[rel]) != ids[rel]: # an object that inflates to bytes pre never had+ raise OSError('%s does not hash to %s' % (rel, ids[rel]))blobs[__MANIFEST__] = ''.join('%s %s\\n' % (blob_id(data), rel) for rel, data in blobs.items()).encode('utf-8')for rel, data in blobs.items():(staging / rel).parent.mkdir(parents=True, exist_ok=True)diff --git a/tests/hermes_cli/test_update_recovery_closure.py b/tests/hermes_cli/test_update_recovery_closure.pyindex bce5d56c067..8fdcec4c4ed 100644--- a/tests/hermes_cli/test_update_recovery_closure.py+++ b/tests/hermes_cli/test_update_recovery_closure.py@@ -17,6 +17,7 @@ import signalimport subprocessimport sysimport time+import zlibfrom pathlib import Pathimport pytest@@ -176,3 +177,28 @@ def test_a_damaged_published_closure_is_rebuilt_from_git_objects_not_trusted(tmpassert "NOT_PRE_CODE_RAN" not in launch.stderr, launch.stderrassert (root / "hermes_bootstrap.py").read_bytes() == originalassert not (root / ".git/hermes-update-pull").exists()++[email protected]("posix")[email protected]("corrupt", [False, True])+def test_git_object_bytes_that_do_not_hash_to_pres_blob_never_run(tmp_path, corrupt):+ """No published closure, and ``pre``'s loose object of the repair inflates to other bytes: they+ never run and nothing is published; the marker stays for a later launch or update (N02)."""+ ran = tmp_path / "FOREIGN_RAN"+ root, env, original, launcher = _killed_mid_write(tmp_path, "hermes_bootstrap.py")+ (closure,) = (root / ".git/hermes-update-recovery").iterdir() # named for ``pre``+ shutil.rmtree(closure.parent)+ if corrupt:+ oid = subprocess.check_output(["git", "-C", str(root), "rev-parse", f"{closure.name}:hermes_cli/_early_recovery.py"],+ env=env, text=True).strip()+ obj = root / ".git/objects" / oid[:2] / oid[2:]+ foreign = f"open({str(ran)!r}, 'w').close()\n".encode()+ obj.chmod(0o644)+ obj.write_bytes(zlib.compress(b"blob %d\0" % len(foreign) + foreign))+ launch = subprocess.run([str(launcher)], cwd=tmp_path, env=env, capture_output=True, text=True, encoding="utf-8",+ errors="replace", timeout=60)+ assert not ran.exists(), launch.stderr+ assert (launch.returncode == 0) is not corrupt, launch.stderr+ assert (root / "hermes_bootstrap.py").exists() is not corrupt+ assert (root / ".git/hermes-update-pull").exists() is corrupt+ assert not (corrupt and (root / ".git/hermes-update-recovery").exists()), "published foreign bytes"