Skip to content

The agent that grows with you

fix: the commit point exposes no test-only API

Teknium20d067890036
diff --git a/hermes_cli/update_cmd_commit.py b/hermes_cli/update_cmd_commit.py
index 9be532f73d4..911515acd37 100644
--- a/hermes_cli/update_cmd_commit.py
+++ b/hermes_cli/update_cmd_commit.py
@@ -161,10 +161,6 @@ def _owe_for(root: Path, sha: str) -> None:
"run `hermes gateway restart` once the update is done.", file=sys.stderr)
-def commit_obligations_armed() -> bool:
- return _armed_snapshot is not None
-
-
def debt_sha_for_move(pre: str, target: str) -> str:
"""The commit a fast-forward ``pre`` -> ``target`` arms the obligations for.
@@ -609,7 +605,3 @@ def preflight_refusal(git_cmd, root: Path, target_ref: str, critical_files) -> s
return (f"✗ The update target has a syntax error in a critical file:\n {path}\n "
+ "\n ".join(error.splitlines()[:6]))
return None
-
-
-def reset_for_tests() -> None:
- begin_update_attempt()
diff --git a/tests/hermes_cli/test_update_commit_obligations.py b/tests/hermes_cli/test_update_commit_obligations.py
index a6ed11cd844..fc991ce7ff0 100644
--- a/tests/hermes_cli/test_update_commit_obligations.py
+++ b/tests/hermes_cli/test_update_commit_obligations.py
@@ -22,9 +22,9 @@ from hermes_cli.update_host_obligation import host_obligation_path
def _fresh_commit_point(tmp_path, monkeypatch):
monkeypatch.setenv("HERMES_HOME", str(tmp_path / "home"))
(tmp_path / "home").mkdir()
- commit.reset_for_tests()
+ commit.begin_update_attempt()
yield
- commit.reset_for_tests()
+ commit.begin_update_attempt()
@pytest.fixture
@@ -183,7 +183,7 @@ def test_one_installs_disarm_never_deletes_another_installs_debt_for_the_same_sh
other.mkdir()
commit.arm_commit_obligations(root, "a" * 40) # install A
run_a = _run_state()
- commit.reset_for_tests()
+ commit.begin_update_attempt()
commit.arm_commit_obligations(other, "a" * 40) # install B, same pulled SHA
run_b = _run_state()
diff --git a/tests/hermes_cli/test_update_existing_branch_baseline.py b/tests/hermes_cli/test_update_existing_branch_baseline.py
index c6e7cd31f21..65112ea1d39 100644
--- a/tests/hermes_cli/test_update_existing_branch_baseline.py
+++ b/tests/hermes_cli/test_update_existing_branch_baseline.py
@@ -285,13 +285,13 @@ def test_a_refused_branch_switch_prints_the_refusal_not_a_missing_branch(checkou
from hermes_cli._early_recovery import interrupted_pull_marker
root, old, _tip = checkout
- update_cmd_commit.reset_for_tests()
+ update_cmd_commit.begin_update_attempt()
interrupted_pull_marker(root).mkdir()
try:
with pytest.raises(SystemExit):
prepare(root)
finally:
- update_cmd_commit.reset_for_tests()
+ update_cmd_commit.begin_update_attempt()
out = capsys.readouterr().out
assert "could not arm the update" in out and "does not exist" not in out
diff --git a/tests/hermes_cli/test_update_fork_sync_identity.py b/tests/hermes_cli/test_update_fork_sync_identity.py
index c9b708faa15..9bef03b0f93 100644
--- a/tests/hermes_cli/test_update_fork_sync_identity.py
+++ b/tests/hermes_cli/test_update_fork_sync_identity.py
@@ -103,12 +103,12 @@ def test_an_upstream_sync_whose_marker_cannot_be_written_never_moves_the_tree(tm
from hermes_cli._early_recovery import interrupted_pull_marker
clone, commits = _fork_behind_upstream(tmp_path, monkeypatch)
- update_cmd_commit.reset_for_tests()
+ update_cmd_commit.begin_update_attempt()
interrupted_pull_marker(clone).mkdir()
try:
assert _sync_with_upstream_if_needed(["git"], clone, assume_yes=True) is False
finally:
- update_cmd_commit.reset_for_tests()
+ update_cmd_commit.begin_update_attempt()
assert _git(clone, "rev-parse", "HEAD") == commits[1]
assert _git(clone, "status", "--porcelain", "--untracked-files=no") == ""
@@ -118,9 +118,10 @@ def test_a_failed_upstream_sync_after_the_pull_owes_the_restart_for_the_pulled_c
c1 (dischargeable at HEAD), not the c2 the checkout never reached (F23)."""
from hermes_cli import update_cmd_commit, update_custody
from hermes_cli.update_host_obligation import read_host_obligation
+ from hermes_cli.venv_sync import completion_pending_path
clone, commits = _fork_behind_upstream(tmp_path, monkeypatch)
- update_cmd_commit.reset_for_tests()
+ update_cmd_commit.begin_update_attempt()
_git(clone, "reset", "-q", "--hard", commits[0])
update_cmd_commit.record_run_start(["git"], clone)
update_cmd_commit.arm_commit_obligations(clone, commits[1])
@@ -135,11 +136,11 @@ def test_a_failed_upstream_sync_after_the_pull_owes_the_restart_for_the_pulled_c
monkeypatch.setattr(update_custody, "run_git", merge_fails)
try:
assert _sync_with_upstream_if_needed(["git"], clone, assume_yes=True) is False
- assert update_cmd_commit.commit_obligations_armed()
finally:
- update_cmd_commit.reset_for_tests()
+ update_cmd_commit.begin_update_attempt()
assert _git(clone, "rev-parse", "HEAD") == commits[1]
assert (read_host_obligation() or {}).get("expected_sha") == commits[1]
+ assert completion_pending_path(clone).is_file()
def test_a_custody_refused_upstream_merge_after_the_pull_still_owes_the_pulled_commit(tmp_path, monkeypatch, capsys):
@@ -150,7 +151,7 @@ def test_a_custody_refused_upstream_merge_after_the_pull_still_owes_the_pulled_c
from hermes_cli.update_host_obligation import read_host_obligation
clone, commits = _fork_behind_upstream(tmp_path, monkeypatch)
- update_cmd_commit.reset_for_tests()
+ update_cmd_commit.begin_update_attempt()
_git(clone, "reset", "-q", "--hard", commits[0])
update_cmd_commit.record_run_start(["git"], clone)
update_cmd_commit.arm_commit_obligations(clone, commits[1])
@@ -166,7 +167,7 @@ def test_a_custody_refused_upstream_merge_after_the_pull_still_owes_the_pulled_c
try:
assert _sync_with_upstream_if_needed(["git"], clone, assume_yes=True) is False
finally:
- update_cmd_commit.reset_for_tests()
+ update_cmd_commit.begin_update_attempt()
assert "process job (access denied)" in capsys.readouterr().out
assert _git(clone, "rev-parse", "HEAD") == commits[1]
assert (read_host_obligation() or {}).get("expected_sha") == commits[1]
@@ -181,7 +182,7 @@ def test_a_failed_upstream_sync_whose_retarget_write_fails_still_owes_the_pulled
from hermes_cli.update_host_obligation import read_host_obligation
clone, commits = _fork_behind_upstream(tmp_path, monkeypatch)
- update_cmd_commit.reset_for_tests()
+ update_cmd_commit.begin_update_attempt()
_git(clone, "reset", "-q", "--hard", commits[0])
update_cmd_commit.record_run_start(["git"], clone)
update_cmd_commit.arm_commit_obligations(clone, commits[1])
@@ -202,7 +203,7 @@ def test_a_failed_upstream_sync_whose_retarget_write_fails_still_owes_the_pulled
try:
assert _sync_with_upstream_if_needed(["git"], clone, assume_yes=True) is False
finally:
- update_cmd_commit.reset_for_tests()
+ update_cmd_commit.begin_update_attempt()
assert _git(clone, "rev-parse", "HEAD") == commits[1]
assert commits[2] not in writes
assert (read_host_obligation() or {}).get("expected_sha") == commits[1]
@@ -220,12 +221,12 @@ def test_a_broken_upstream_target_is_refused_before_the_second_move(tmp_path, mo
(upstream / "hermes_constants.py").write_text("def broken(:\n", encoding="utf-8")
_git(upstream, "add", "hermes_constants.py")
_git(upstream, "commit", "-qm", "broken c3")
- update_cmd_commit.reset_for_tests()
+ update_cmd_commit.begin_update_attempt()
try:
with pytest.raises(UpstreamTargetBroken) as refused:
_sync_with_upstream_if_needed(["git"], clone, assume_yes=True)
finally:
- update_cmd_commit.reset_for_tests()
+ update_cmd_commit.begin_update_attempt()
assert refused.value.path == "hermes_constants.py"
assert _git(clone, "rev-parse", "HEAD") == commits[1]
assert not interrupted_pull_marker(clone).exists()
diff --git a/tests/hermes_cli/test_update_interrupted_pull.py b/tests/hermes_cli/test_update_interrupted_pull.py
index eba56ea7ac0..5477c57ca01 100644
--- a/tests/hermes_cli/test_update_interrupted_pull.py
+++ b/tests/hermes_cli/test_update_interrupted_pull.py
@@ -632,9 +632,9 @@ def test_a_refusal_whose_holder_exits_before_the_probe_retries_the_lock(tmp_path
def commit_point():
from hermes_cli import update_cmd_commit as commit
- commit.reset_for_tests()
+ commit.begin_update_attempt()
yield commit
- commit.reset_for_tests()
+ commit.begin_update_attempt()
def _unmovable(root: Path, a: str) -> None:
@@ -652,7 +652,10 @@ def test_a_pull_whose_marker_cannot_be_written_never_moves_the_tree(checkout, co
_pull(root)
_unmovable(root, a)
- assert not commit_point.commit_obligations_armed()
+ from hermes_cli.update_host_obligation import read_host_obligation
+ from hermes_cli.venv_sync import completion_pending_path
+
+ assert read_host_obligation() is None and not completion_pending_path(root).exists(), "the refused move left a debt"
def test_a_pull_whose_target_does_not_resolve_never_moves_the_tree(checkout, commit_point, monkeypatch):
diff --git a/tests/hermes_cli/test_update_zip_two_phase.py b/tests/hermes_cli/test_update_zip_two_phase.py
index da699183908..0cb9cdc38b9 100644
--- a/tests/hermes_cli/test_update_zip_two_phase.py
+++ b/tests/hermes_cli/test_update_zip_two_phase.py
@@ -641,6 +641,8 @@ def test_a_journal_that_cannot_be_dropped_after_the_commit_never_fails_the_updat
"""The swap committed: an AV scan holding the journal must not turn it into a reported failure
that disarms the new tree's completion obligations (F19)."""
from hermes_cli import update_cmd_commit
+ from hermes_cli.update_host_obligation import read_host_obligation
+ from hermes_cli.venv_sync import completion_pending_path
live, extracted = tmp_path / "live", tmp_path / "extracted"
_live_tree(live, {"payload": "old"})
@@ -652,14 +654,15 @@ def test_a_journal_that_cannot_be_dropped_after_the_commit_never_fails_the_updat
raise PermissionError(13, "being used by another process", str(self))
return real(self, *args, **kwargs)
- update_cmd_commit.reset_for_tests()
+ update_cmd_commit.begin_update_attempt()
monkeypatch.setattr(Path, "unlink", held)
try:
update_cmd_zip._journaled_stage_and_swap(str(extracted), ["payload"], live, "b" * 40)
- assert update_cmd_commit.commit_obligations_armed()
finally:
- update_cmd_commit.reset_for_tests()
+ update_cmd_commit.begin_update_attempt()
assert (live / "payload" / "version.txt").read_text(encoding="utf-8-sig") == "new"
+ assert completion_pending_path(live).is_file()
+ assert (read_host_obligation() or {}).get("expected_sha") == "b" * 40
_KILLED_BACKUP_COPY = r'''