The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
chore: review follow-ups for salvaged #99954
kshitijk4poord4611ac83789
diff --git a/hermes_cli/update_cmd.py b/hermes_cli/update_cmd.pyindex e92237b2d3b..0452f63a8b7 100644--- a/hermes_cli/update_cmd.py+++ b/hermes_cli/update_cmd.py@@ -2100,6 +2100,11 @@ def _verify_and_restore_one_state_db(home: Path, *, label: str) -> None:returnok = verify_sqlite_integrity(state_path, check_header=True, run_pragma=True)if ok.get("valid"):+ logger.debug(+ "Post-update state.db integrity OK (%s): %s",+ label,+ ok.get("message"),+ )returnprint()print(@@ -2151,11 +2156,12 @@ def _verify_and_restore_state_dbs_post_update() -> None:the update was never detected and never auto-restored, leaving thatprofile's sessions silently gone while the root DB passed."""- _verify_and_restore_one_state_db(get_hermes_home(), label="default home")+ home = get_hermes_home()+ _verify_and_restore_one_state_db(home, label="default home")try:from hermes_cli.backup import _sibling_profile_homes- for name, profile_home in _sibling_profile_homes(get_hermes_home()):+ for name, profile_home in _sibling_profile_homes(home):_verify_and_restore_one_state_db(profile_home, label=f"profile {name}")except Exception as exc:logger.debug("Sibling-profile state.db guard sweep failed: %s", exc)diff --git a/tests/hermes_cli/test_update_state_autorestore.py b/tests/hermes_cli/test_update_state_autorestore.pyindex 25326a57391..7b543408350 100644--- a/tests/hermes_cli/test_update_state_autorestore.py+++ b/tests/hermes_cli/test_update_state_autorestore.py@@ -216,23 +216,21 @@ def test_restore_helper_propagates_copy_errors(tmp_path):# ── Multi-profile coverage (#97994) ─────────────────────────────────────-def _make_valid_db(path: Path, rows: int, tag: str) -> None:+def _make_valid_db(path: Path, rows: int) -> None:conn = sqlite3.connect(path)conn.execute("CREATE TABLE sessions (id INTEGER PRIMARY KEY, name TEXT)")conn.executemany("INSERT INTO sessions (name) VALUES (?)",- [(f"{tag}{i}",) for i in range(rows)],+ [(str(i),) for i in range(rows)],)conn.commit()conn.close()-def _make_valid_snapshot(home: Path, snap_id: str, rows: int, tag: str) -> Path:+def _make_valid_snapshot(home: Path, snap_id: str, rows: int) -> None:snap_dir = home / "state-snapshots" / snap_idsnap_dir.mkdir(parents=True)- snap_db = snap_dir / "state.db"- _make_valid_db(snap_db, rows, tag)- return snap_dir+ _make_valid_db(snap_dir / "state.db", rows)def test_post_update_guard_covers_sibling_profiles(tmp_path, monkeypatch, capsys):@@ -248,12 +246,12 @@ def test_post_update_guard_covers_sibling_profiles(tmp_path, monkeypatch, capsyssibling_home.mkdir(parents=True)# Root DB: valid, with its own snapshot — must be left untouched.- _make_valid_db(root_home / "state.db", 10, "root")+ _make_valid_db(root_home / "state.db", 10)root_before = (root_home / "state.db").read_bytes()# Sibling: live DB corrupted post-update (the #68474 zeroed signature),# with its own VALID pre-update snapshot under its own snapshots dir.- _make_valid_snapshot(sibling_home, "20260901-pre-update", 25, "snap")+ _make_valid_snapshot(sibling_home, "20260901-pre-update", 25)(sibling_home / "state.db").write_bytes(b"\x00" * 4096)monkeypatch.setattr(update_cmd, "get_hermes_home", lambda: root_home)@@ -283,8 +281,8 @@ def test_post_update_guard_leaves_valid_sibling_dbs_alone(tmp_path, monkeypatch,sibling_home = tmp_path / "profiles" / "work"sibling_home.mkdir(parents=True)- _make_valid_db(root_home / "state.db", 10, "root")- _make_valid_db(sibling_home / "state.db", 7, "sib")+ _make_valid_db(root_home / "state.db", 10)+ _make_valid_db(sibling_home / "state.db", 7)sibling_before = (sibling_home / "state.db").read_bytes()monkeypatch.setattr(update_cmd, "get_hermes_home", lambda: root_home)@@ -310,7 +308,7 @@ def test_post_update_guard_survives_missing_sibling_snapshot(tmp_path, monkeypatsibling_home = tmp_path / "profiles" / "work"sibling_home.mkdir(parents=True)- _make_valid_db(root_home / "state.db", 10, "root")+ _make_valid_db(root_home / "state.db", 10)(sibling_home / "state.db").write_bytes(b"\x00" * 4096)monkeypatch.setattr(update_cmd, "get_hermes_home", lambda: root_home)