From 3960315af7bce6194801ddc628199afa8862489f Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Fri, 24 Jul 2026 14:46:59 -0700 Subject: [PATCH] test: order compression-tip fixtures around the closed-parent write guard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two compression-tip hydration tests simulated legacy state by emptying the parent AFTER end_session(compression) — exactly the durable write the new closed-parent guard refuses. Reordered: empty first, close second. The tests' actual contract (old id hydrates from the live tip) is unchanged and still pinned. --- tests/gateway/test_session_api.py | 5 ++++- tests/hermes_cli/test_web_server.py | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/gateway/test_session_api.py b/tests/gateway/test_session_api.py index f9989e18e00..3f6f28bf7ee 100644 --- a/tests/gateway/test_session_api.py +++ b/tests/gateway/test_session_api.py @@ -176,9 +176,12 @@ async def test_session_crud_and_message_history(adapter, session_db): async def test_session_messages_follow_compression_tip(adapter, session_db): source_id = session_db.create_session("source-session", "api_server") session_db.append_message(source_id, "user", "before compression") + # Empty the parent BEFORE closing it: the closed-parent write guard + # (CompressionSessionClosedError) refuses durable writes to a session + # ended by compression, so the legacy-state simulation must run first. + session_db.replace_messages(source_id, []) session_db.end_session(source_id, "compression") session_db.create_session("tip-session", "api_server", parent_session_id=source_id) - session_db.replace_messages(source_id, []) session_db.append_message("tip-session", "user", "after compression") app = _create_session_app(adapter) diff --git a/tests/hermes_cli/test_web_server.py b/tests/hermes_cli/test_web_server.py index ad8cedab4de..7f0119ec2bc 100644 --- a/tests/hermes_cli/test_web_server.py +++ b/tests/hermes_cli/test_web_server.py @@ -2293,6 +2293,9 @@ class TestWebServerEndpoints: try: db.create_session(session_id="desktop-root", source="cli") db.append_message(session_id="desktop-root", role="user", content="before compression") + # Empty before closing: the closed-parent write guard refuses + # durable writes to compression-ended sessions. + db.replace_messages("desktop-root", []) db.end_session("desktop-root", "compression") now = _time.time() db._conn.execute( @@ -2301,7 +2304,6 @@ class TestWebServerEndpoints: ) db.create_session(session_id="desktop-tip", source="cli", parent_session_id="desktop-root") db._conn.execute("UPDATE sessions SET started_at = ? WHERE id = ?", (now - 4, "desktop-tip")) - db.replace_messages("desktop-root", []) db.append_message(session_id="desktop-tip", role="user", content="after compression") db._conn.commit() finally: