From 031983bbf8bb05b535a20b7f69f456ed476df7b6 Mon Sep 17 00:00:00 2001 From: Aditya Rajesh Gadgil Date: Tue, 5 May 2026 12:57:38 +0000 Subject: [PATCH] fix: limit pre-update state snapshots --- hermes_cli/backup.py | 7 +++++-- hermes_cli/main.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hermes_cli/backup.py b/hermes_cli/backup.py index ffdf4f94e1b..2068082676f 100644 --- a/hermes_cli/backup.py +++ b/hermes_cli/backup.py @@ -512,6 +512,7 @@ def _quick_snapshot_root(hermes_home: Optional[Path] = None) -> Path: def create_quick_snapshot( label: Optional[str] = None, hermes_home: Optional[Path] = None, + keep: Optional[int] = None, ) -> Optional[str]: """Create a quick state snapshot of critical files. @@ -585,8 +586,10 @@ def create_quick_snapshot( with open(snap_dir / "manifest.json", "w", encoding="utf-8") as f: json.dump(meta, f, indent=2) - # Auto-prune - _prune_quick_snapshots(root, keep=_QUICK_DEFAULT_KEEP) + # Auto-prune. Defaults preserve historical manual /snapshot behavior; callers + # with known high-churn safety snapshots (for example pre-update) can pass a + # smaller keep value so large state.db copies do not accumulate indefinitely. + _prune_quick_snapshots(root, keep=_QUICK_DEFAULT_KEEP if keep is None else keep) logger.info("State snapshot created: %s (%d files)", snap_id, len(manifest)) return snap_id diff --git a/hermes_cli/main.py b/hermes_cli/main.py index 5d6a9ccac7b..4d9b37db240 100644 --- a/hermes_cli/main.py +++ b/hermes_cli/main.py @@ -9033,7 +9033,7 @@ def _cmd_update_impl(args, gateway_mode: bool): try: from hermes_cli.backup import create_quick_snapshot - snap_id = create_quick_snapshot(label="pre-update") + snap_id = create_quick_snapshot(label="pre-update", keep=1) if snap_id: print(f" ✓ Pre-update snapshot: {snap_id}") except Exception as exc: