Skip to content

The agent that grows with you

fix: retain corruption restore for non-runtime SQLite stores

Tekniumad354c28ab6f
diff --git a/hermes_cli/backup.py b/hermes_cli/backup.py
index 176d7297c08..fbeaba2ea59 100644
--- a/hermes_cli/backup.py
+++ b/hermes_cli/backup.py
@@ -479,6 +479,9 @@ def _restore_epoch_source(src: Path, dst: Path):
An unreadable destination cannot prove its epoch floor: use transcript salvage
into a separate output rather than silently restoring with a recycled epoch.
"""
+ if dst.name != 'state.db' and dst.resolve().name != 'state.db':
+ yield src
+ return
floor = _restore_epoch(dst)
if floor <= _restore_epoch(src):
yield src
diff --git a/tests/hermes_cli/test_runtime_maintenance_exclusion.py b/tests/hermes_cli/test_runtime_maintenance_exclusion.py
index 3b067eeba61..19709b44376 100644
--- a/tests/hermes_cli/test_runtime_maintenance_exclusion.py
+++ b/tests/hermes_cli/test_runtime_maintenance_exclusion.py
@@ -165,6 +165,12 @@ def test_import_and_startup_exclude_each_other_before_publication(tmp_path, monk
assert refused.value.code == 1
finally:
owner.close()
+ # Unrelated SQLite stores have no authority epoch; retain corruption restore.
+ damaged = home / 'projects.db'
+ damaged.write_bytes(b'not a SQLite database')
+ assert backup._safe_restore_db(tmp_path / 'donor.db', damaged)
+ with sqlite3.connect(damaged) as db:
+ assert db.execute('SELECT value FROM marker').fetchall() == [('restored',)]
def test_recovery_output_exemption_excludes_canonical_activation(tmp_path):