From 59c7a9908420ef2066755fbc15043162ba95ef02 Mon Sep 17 00:00:00 2001 From: fangliquan Date: Mon, 17 Aug 2026 09:24:07 +0800 Subject: [PATCH] fix(state): avoid overlapping context manager change --- hermes_state.py | 6 ------ tests/test_hermes_state.py | 11 ----------- 2 files changed, 17 deletions(-) diff --git a/hermes_state.py b/hermes_state.py index fe284fab1f..e0de71e3ec 100644 --- a/hermes_state.py +++ b/hermes_state.py @@ -4429,12 +4429,6 @@ class SessionDB(SessionSearchMixin, SessionSchemaMixin, SessionPortabilityMixin) conn, self._conn = self._conn, None self._close_connection_quietly(conn) - def __enter__(self) -> "SessionDB": - return self - - def __exit__(self, _exc_type, _exc, _tb) -> None: - self.close() - def __del__(self) -> None: """Safety net: close the connection if the caller forgot. diff --git a/tests/test_hermes_state.py b/tests/test_hermes_state.py index 89abd59d18..6f03a945b6 100644 --- a/tests/test_hermes_state.py +++ b/tests/test_hermes_state.py @@ -104,17 +104,6 @@ def _no_fts_rebuild_throttle(monkeypatch): class TestConnectionLifecycle: - def test_context_manager_closes_connection(self, tmp_path): - from hermes_cli.sqlite_safe_read import has_live_connection - - db_path = tmp_path / "context-managed.db" - with SessionDB(db_path=db_path) as managed: - managed.create_session("s-context", source="test") - assert has_live_connection(db_path) is True - - assert managed._conn is None - assert has_live_connection(db_path) is False - def test_failed_writable_open_does_not_leak_tracked_connection( self, tmp_path, monkeypatch ):