The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): ZIP swap recovery also drops a backup copy killed before its rename
Teknium4e49f5e62ef5
diff --git a/hermes_cli/_early_recovery.py b/hermes_cli/_early_recovery.pyindex 336e6add832..0acfbb4554c 100644--- a/hermes_cli/_early_recovery.py+++ b/hermes_cli/_early_recovery.py@@ -825,7 +825,8 @@ def restore_interrupted_zip_swap(project_root: Path | None = None) -> bool:elif existed and not dst.exists() and old.exists():os.rename(old, dst) # the backup is the only copy leftchanged = True- for leftover in (staging, old):+ # ``<old>.tmp``: a backup copy killed before its rename (no-hardlink file systems).+ for leftover in (staging, old, Path(f"{old}.tmp")):_drop_path(leftover)except OSError as exc:failed = Truediff --git a/tests/hermes_cli/test_update_zip_two_phase.py b/tests/hermes_cli/test_update_zip_two_phase.pyindex dc88f4901f9..d67df7a268c 100644--- a/tests/hermes_cli/test_update_zip_two_phase.py+++ b/tests/hermes_cli/test_update_zip_two_phase.py@@ -597,3 +597,23 @@ def test_a_journal_that_cannot_be_dropped_after_the_commit_never_fails_the_updatfinally:update_cmd_commit.reset_for_tests()assert (live / "payload" / "version.txt").read_text(encoding="utf-8-sig") == "new"+++def test_a_backup_copy_killed_before_its_rename_is_cleared_by_the_recovery(tmp_path):+ """On a file system without hardlinks ``_file_backup`` copies to ``<entry>.hermes-update-old.tmp``+ first. A kill inside that copy left the temp behind: recovery dropped only staging and the backup,+ so every later ZIP update refused on "uncommitted changes" (review C4)."""+ from hermes_cli._early_recovery import ZIP_SWAP_JOURNAL, restore_interrupted_zip_swap, write_zip_swap_journal++ live = tmp_path / "live"+ live.mkdir()+ (live / "a.py").write_text("old\n", encoding="utf-8")+ (live / "a.py.hermes-update-staging").write_text("new\n", encoding="utf-8")+ (live / "a.py.hermes-update-old.tmp").write_text("ol", encoding="utf-8") # the killed copy+ write_zip_swap_journal(live, "swapping", [["a.py", True]])++ restore_interrupted_zip_swap(live)++ assert not (live / ZIP_SWAP_JOURNAL).exists()+ assert sorted(p.name for p in live.iterdir() if not p.name.endswith(".lock")) == ["a.py"]+ assert (live / "a.py").read_text(encoding="utf-8") == "old\n"