Skip to content

The agent that grows with you

fix: keep status session inspection read-only

Tekniumca77b19711b7
diff --git a/hermes_cli/status.py b/hermes_cli/status.py
index 8d1536b1869..20c1b2368df 100644
--- a/hermes_cli/status.py
+++ b/hermes_cli/status.py
@@ -265,7 +265,7 @@ def _render_sessions(ctx):
# pre-migration installs.
try:
from hermes_state import SessionDB
- db = SessionDB()
+ db = SessionDB(db_path=get_hermes_home() / "state.db", read_only=True)
try:
gateway_rows = db.list_gateway_sessions(active_only=True) or []
finally:
diff --git a/tests/hermes_cli/test_status_readonly.py b/tests/hermes_cli/test_status_readonly.py
new file mode 100644
index 00000000000..6be1f424231
--- /dev/null
+++ b/tests/hermes_cli/test_status_readonly.py
@@ -0,0 +1,22 @@
+"""Status must not bootstrap the session writer it merely observes."""
+
+import json
+from types import SimpleNamespace
+
+import pytest
+
+
[email protected]("legacy", [False, True])
+def test_session_status_does_not_create_database(tmp_path, monkeypatch, capsys, legacy):
+ from hermes_cli import status
+
+ monkeypatch.setenv("HERMES_HOME", str(tmp_path))
+ monkeypatch.setattr(status, "get_hermes_home", lambda: tmp_path)
+ if legacy:
+ directory = tmp_path / "sessions"
+ directory.mkdir()
+ (directory / "sessions.json").write_text(json.dumps({"fixture": {}}))
+ status._render_sessions(SimpleNamespace(config={}))
+ output = capsys.readouterr().out
+ assert "1 session(s)" in output if legacy else "Active:" in output
+ assert not (tmp_path / "state.db").exists()