Skip to content

The agent that grows with you

refactor: remove obsolete updater sidecar deletion path

Teknium5889565343c9
diff --git a/hermes_cli/update_cmd.py b/hermes_cli/update_cmd.py
index beba4e72bf0..f4cf5c49940 100644
--- a/hermes_cli/update_cmd.py
+++ b/hermes_cli/update_cmd.py
@@ -98,7 +98,7 @@ from hermes_cli.update_cmd_git import ( # noqa: F401
_sync_with_upstream_if_needed)
from hermes_cli.update_cmd_maint import ( # noqa: F401
_PRE_UPDATE_SNAPSHOT_KEEP, _PRE_UPDATE_SNAPSHOT_MAX_FILE_SIZE, _STALE_PURGE_PREFIXES,
- _STALE_PURGE_PROTECTED, _UPDATE_RUNTIME_RELOAD_MODULES, _clear_stale_sqlite_sidecars,
+ _STALE_PURGE_PROTECTED, _UPDATE_RUNTIME_RELOAD_MODULES,
_ensure_acp_launcher, _ensure_fhs_path_guard, _finish_dashboard_update_cleanup,
_format_time_ago, _post_update_sqlite_runtime_status, _print_bundled_skills_sync_report,
_print_curator_first_run_notice, _print_curator_recent_run_notice,
diff --git a/hermes_cli/update_cmd_maint.py b/hermes_cli/update_cmd_maint.py
index b318d62e297..3e314ce843f 100644
--- a/hermes_cli/update_cmd_maint.py
+++ b/hermes_cli/update_cmd_maint.py
@@ -410,19 +410,6 @@ def _print_verified_update_completion(message: str) -> bool:
return False
-def _clear_stale_sqlite_sidecars(db_path: Path) -> None:
- """Delete -wal/-shm/-journal next to *db_path*, immediately before overwriting it with a
- snapshot image.
-
- Snapshots are checkpointed ``sqlite3.backup()`` images with no WAL; copying replaces only
- the main file, so a leftover WAL from the OLD database would be replayed over the fresh
- image on next open (passes integrity_check while serving old contents). Safe because the
- caller has already declared that database corrupt.
- """
- for suffix in ("-wal", "-shm", "-journal"):
- db_path.with_name(db_path.name + suffix).unlink(missing_ok=True)
-
-
def _print_update_summary(*, node_failures: list, desktop_build_ok: bool, pre_update_version: str | None) -> bool:
"""Final banner. A failed Desktop rebuild is non-fatal but must not print ``✓ Update complete!``.
diff --git a/tests/hermes_cli/test_update_state_autorestore.py b/tests/hermes_cli/test_update_state_autorestore.py
index d9023c5b5a7..f67682bcf31 100644
--- a/tests/hermes_cli/test_update_state_autorestore.py
+++ b/tests/hermes_cli/test_update_state_autorestore.py
@@ -1,22 +1,4 @@
-"""Auto-restore of state.db must not inherit the corrupt database's WAL.
-
-The post-update integrity guard added for #68474 restores ``state.db`` from a
-pre-update quick snapshot with a plain ``shutil.copy2``. The snapshot image is
-produced by ``backup._safe_copy_db`` via ``sqlite3.backup()``, so it is already
-checkpointed and owns no WAL — which is why ``backup._EXCLUDED_SUFFIXES``
-deliberately refuses to ship ``-wal`` / ``-shm`` / ``-journal`` inside a
-snapshot.
-
-Copying that image over the live path replaces only the main database file. A
-``state.db-wal`` left behind by the *old* database — a crashed writer, or a
-second Hermes holder the updater's drain did not stop — survives the copy and is
-replayed over the fresh image on the next open. The restored file then passes
-``PRAGMA integrity_check`` while serving the discarded database's contents, so
-the CLI prints "✓ Auto-restored from snapshot" over data the user has lost.
-
-These tests exercise REAL SQLite files, in WAL mode, with a genuinely hot
-sidecar.
-"""
+"""Updater restore must publish snapshot rows without replaying the old WAL."""
import shutil
import sqlite3
@@ -25,7 +7,6 @@ from pathlib import Path
import pytest
from hermes_cli.update_cmd import (
- _clear_stale_sqlite_sidecars,
_restore_state_db_from_snapshot,
)
@@ -106,29 +87,6 @@ def _row_count(db_path: Path) -> int:
conn.close()
-def test_restore_over_hot_wal_serves_snapshot_rows(live_db_with_hot_wal, snapshot_db):
- """The restored database must contain the SNAPSHOT's rows, not the WAL's.
-
- Without clearing the sidecars the copy silently loses every restored row:
- SQLite replays the old WAL and serves the discarded database instead.
- """
- _clear_stale_sqlite_sidecars(live_db_with_hot_wal)
- shutil.copy2(snapshot_db, live_db_with_hot_wal)
-
- assert _row_count(live_db_with_hot_wal) == SNAPSHOT_ROWS
-
-
-def test_stale_wal_is_not_left_beside_the_restored_file(
- live_db_with_hot_wal, snapshot_db
-):
- """No sidecar from the discarded database may survive the restore."""
- _clear_stale_sqlite_sidecars(live_db_with_hot_wal)
- shutil.copy2(snapshot_db, live_db_with_hot_wal)
-
- for suffix in ("-wal", "-shm", "-journal"):
- assert not _sidecar(live_db_with_hot_wal, suffix).exists()
-
-
def test_torn_restore_is_what_the_guard_prevents(live_db_with_hot_wal, snapshot_db):
"""Pin the SQLite behaviour that makes the guard necessary.
@@ -150,38 +108,12 @@ def test_torn_restore_is_what_the_guard_prevents(live_db_with_hot_wal, snapshot_
assert _row_count(live_db_with_hot_wal) != SNAPSHOT_ROWS
-def test_clear_is_a_noop_when_no_sidecars_exist(tmp_path):
- """A snapshot-clean destination must not raise (``missing_ok``)."""
- db_path = tmp_path / "state.db"
- conn = sqlite3.connect(db_path)
- conn.execute("CREATE TABLE t (a INTEGER)")
- conn.commit()
- conn.close()
-
- _clear_stale_sqlite_sidecars(db_path)
-
- assert db_path.exists()
-
-
-def test_clear_removes_every_sidecar_suffix_and_spares_the_database(tmp_path):
- db_path = tmp_path / "state.db"
- db_path.write_bytes(b"main-db")
- for suffix in ("-wal", "-shm", "-journal"):
- _sidecar(db_path, suffix).write_bytes(b"stale")
-
- _clear_stale_sqlite_sidecars(db_path)
-
- for suffix in ("-wal", "-shm", "-journal"):
- assert not _sidecar(db_path, suffix).exists()
- assert db_path.read_bytes() == b"main-db"
-
-
def test_restore_helper_serves_snapshot_rows_over_a_hot_wal(
live_db_with_hot_wal, snapshot_db
):
"""The shared restore helper is what both update paths call.
- It must clear, copy and verify as one unit: after it returns, the database
+ It must restore and verify as one unit: after it returns, the database
has to hold the SNAPSHOT's rows even though the destination still owned a
hot WAL from the corrupt database.
"""