The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(recovery): name the real state.db in the copy-pasteable recovery banners
kshitijk4poor914d8a0bd6d1
diff --git a/gateway/run.py b/gateway/run.pyindex afe4cad2956..26024795258 100644--- a/gateway/run.py+++ b/gateway/run.py@@ -27476,20 +27476,27 @@ class GatewayRunner(GatewayAuthorizationMixin, GatewayKanbanWatchersMixin, Gatewif not error:return- from hermes_state import classify_persistence_error, format_session_db_unavailable+ from hermes_state import (+ _default_db_path,+ classify_persistence_error,+ format_session_db_unavailable,+ )cause = classify_persistence_error(error)hint = format_session_db_unavailable()if cause == "corrupt":+ # Copy-pasteable, so name the real store (profiles / HERMES_HOME+ # do not live under ~/.hermes).+ db_path = _default_db_path()message = ("⚠️ Session database corruption detected. Messages may not be ""persisted. Recovery options:\n""1. Run `hermes doctor --fix`\n""2. Stop the gateway, then recover with:\n"- " hermes sessions recover --source ~/.hermes/state.db "+ f" hermes sessions recover --source {db_path} ""--inspect-only\n"" (if it reports recoverable) hermes sessions recover "- "--source ~/.hermes/state.db --output recovered-state.db\n"+ f"--source {db_path} --output recovered-state.db\n"" — recovery snapshots the damaged file first; do NOT run ""`sqlite3 ... \".recover\"` against the live state.db, a ""vulnerable sqlite3 CLI can corrupt it further\n"diff --git a/hermes_cli/session_lost_and_found.py b/hermes_cli/session_lost_and_found.pyindex cb1622783a5..09a362076bb 100644--- a/hermes_cli/session_lost_and_found.py+++ b/hermes_cli/session_lost_and_found.py@@ -32,7 +32,9 @@ import tempfilefrom pathlib import Pathfrom typing import Any, Optional-logger = logging.getLogger(__name__)# Hermes session ids are timestamps: 20260812_135332_ab12cd. This is the+logger = logging.getLogger(__name__)++# Hermes session ids are timestamps: 20260812_135332_ab12cd. This is the# strongest sentinel available for classifying schema-less rows.SESSION_ID_PATTERN = re.compile(r"^\d{8}_\d{6}_")diff --git a/run_agent.py b/run_agent.pyindex 90a32b77146..8796236a9e2 100644--- a/run_agent.py+++ b/run_agent.py@@ -4423,6 +4423,11 @@ class AIAgent:"pending_messages/pending-*.json.")if cause == "corrupt":+ from hermes_state import _default_db_path++ # Copy-pasteable, so name the real store (profiles /+ # HERMES_HOME do not live under ~/.hermes).+ db_path = _default_db_path()return (prefix+ "the turn was stopped because the state database "@@ -4431,10 +4436,10 @@ class AIAgent:"not help. Recovery options:\n""1. Run `hermes doctor --fix`\n""2. Stop the gateway, then recover with:\n"- " hermes sessions recover --source ~/.hermes/state.db "+ f" hermes sessions recover --source {db_path} ""--inspect-only\n"" (if it reports recoverable) hermes sessions recover "- "--source ~/.hermes/state.db --output recovered-state.db\n"+ f"--source {db_path} --output recovered-state.db\n"" — recovery snapshots the damaged file first; do NOT ""run `sqlite3 ... \".recover\"` against the live ""state.db, a vulnerable sqlite3 CLI can corrupt it "diff --git a/tests/hermes_cli/test_sqlite3_cli_salvage_gate.py b/tests/hermes_cli/test_sqlite3_cli_salvage_gate.pyindex bda5a4b1050..ec999aa4e5e 100644--- a/tests/hermes_cli/test_sqlite3_cli_salvage_gate.py+++ b/tests/hermes_cli/test_sqlite3_cli_salvage_gate.py@@ -307,9 +307,9 @@ class TestEmittedCommandsSatisfyCliContract:return argparse.Namespace(**fields)def test_old_v1_shape_is_still_rejected(self, tmp_path):- """Guard the test's own premise: neither --inspect-only nor- --output (the shape the v1 banner printed) is rejected with rc 2- by the real dispatcher."""+ """Guard the test's own premise: the bare `--source <db>` shape the+ v1 banner printed (neither --inspect-only nor --output) is rejected+ with rc 2 by the real dispatcher."""import hermes_cli.sessions_cmd as scrc = sc.cmd_sessions(self._namespace(tmp_path / "state.db"))