The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): a hand-edited dependency-repair marker never crashes startup (review N08)
Teknium3797b11ef0b4
diff --git a/hermes_cli/_early_recovery.py b/hermes_cli/_early_recovery.pyindex 1975138e8a8..aff2136cede 100644--- a/hermes_cli/_early_recovery.py+++ b/hermes_cli/_early_recovery.py@@ -96,7 +96,10 @@ def _read_marker_attempts(marker_path: Path) -> int:try:import json- return int(json.loads(raw).get("attempts", 0))+ attempts = json.loads(raw).get("attempts", 0)+ if type(attempts) is not int: # only our writers' ints count: Infinity/NaN/true never reach int()+ raise TypeError(attempts)+ return max(0, attempts)except (ValueError, AttributeError, TypeError):for line in reversed(raw.splitlines()):key, separator, value = line.partition("=")diff --git a/tests/hermes_cli/test_early_recovery.py b/tests/hermes_cli/test_early_recovery.pyindex 6d9e0502503..5bd8bdd5720 100644--- a/tests/hermes_cli/test_early_recovery.py+++ b/tests/hermes_cli/test_early_recovery.py@@ -252,3 +252,12 @@ def test_dropping_a_staged_tree_never_changes_a_hardlinked_live_files_mode(tmp_per._drop_path(staging.parent)assert not staging.parent.exists()assert (live / "Hermes.exe").stat().st_mode & 0o777 == 0o555++[email protected]("body", ['{"attempts": Infinity}', '{"attempts": -Infinity}', '{"attempts": NaN}',+ '{"attempts": true}', '{"attempts": -4}'])+def test_marker_attempts_from_a_hand_edited_body_are_a_nonnegative_int(tmp_path, body):+ marker = tmp_path / ".update-incomplete"+ marker.write_text(body, encoding="utf-8")+ attempts = er._read_marker_attempts(marker)+ assert type(attempts) is int and attempts >= 0