Skip to content

The agent that grows with you

test(state): trim reflush identity tests to two invariants

kshitijk4poor4bb0e270f268
diff --git a/tests/hermes_state/test_unaddressed_rewrite_identity.py b/tests/hermes_state/test_unaddressed_rewrite_identity.py
index e9afa46dbf1..5cfb772944d 100644
--- a/tests/hermes_state/test_unaddressed_rewrite_identity.py
+++ b/tests/hermes_state/test_unaddressed_rewrite_identity.py
@@ -8,8 +8,6 @@ snapshot remains the compare-and-swap proof for the version we actually loaded.
from __future__ import annotations
-import json
-
import pytest
from agent.context_compressor import _DB_PERSISTED_MARKER
@@ -63,33 +61,6 @@ def test_unaddressed_mutated_replay_rewrites_its_original_row(db):
assert after[0]["content"] == "after repair"
-def test_unaddressed_tool_call_repair_does_not_append_a_clone(db):
- sid = "tool-repair"
- db.create_session(sid, "desktop")
- original = {
- "role": "assistant",
- "content": "calling tool",
- "timestamp": 2000.0,
- "tool_calls": [{
- "id": "call_1",
- "type": "function",
- "function": {"name": "demo", "arguments": '{"broken":'},
- }],
- }
- assert db.append_messages_batch(sid, [original]) == 1
- before = _active_rows(db, sid)
-
- restored = db.get_messages_as_conversation(sid, repair_alternation=True)
- restored[0]["tool_calls"][0]["function"]["arguments"] = "{}"
- restored[0].pop(_DB_PERSISTED_MARKER, None)
-
- assert db.append_messages_batch(sid, restored) == 0
- after = _active_rows(db, sid)
- assert len(after) == 1 and after[0]["id"] == before[0]["id"]
- calls = json.loads(after[0]["tool_calls"])
- assert calls[0]["function"]["arguments"] == "{}"
-
-
def test_fresh_identical_message_is_never_adopted_by_payload(db):
"""Content and timestamps are not identity: two real occurrences may be byte-identical."""
sid = "identical-twins"
@@ -104,59 +75,3 @@ def test_fresh_identical_message_is_never_adopted_by_payload(db):
rows = _active_rows(db, sid)
assert len(rows) == 2
assert rows[0]["message_uid"] != rows[1]["message_uid"]
-
-
-def test_message_uid_without_snapshot_does_not_authorize_adoption(db):
- """Logical identity alone can span physical generations; the CAS proof is required."""
- sid = "uid-copy"
- db.create_session(sid, "desktop")
- first = {"role": "assistant", "content": "generation one", "timestamp": 3500.0}
- assert db.append_messages_batch(sid, [first]) == 1
-
- copied_generation = {
- "role": "assistant",
- "content": "generation two",
- "timestamp": 3501.0,
- "message_uid": first["message_uid"],
- }
- assert DB_ROW_SNAPSHOT not in copied_generation and "_row_id" not in copied_generation
- assert db.append_messages_batch(sid, [copied_generation]) == 1
-
- rows = _active_rows(db, sid)
- assert len(rows) == 2
- assert rows[0]["message_uid"] == rows[1]["message_uid"] == first["message_uid"]
-
-
-def test_unaddressed_replay_respects_a_concurrent_winner(db):
- sid = "concurrent-winner"
- db.create_session(sid, "desktop")
- original = {"role": "assistant", "content": "base", "timestamp": 4000.0}
- db.append_messages_batch(sid, [original])
- row_id = _active_rows(db, sid)[0]["id"]
-
- stale = db.get_messages_as_conversation(sid, repair_alternation=True)[0]
- assert isinstance(stale.get(DB_ROW_SNAPSHOT), str)
-
- # Simulate another writer changing the durable payload after this replay was loaded.
- db._conn.execute(
- "UPDATE messages SET content = ? WHERE id = ?",
- (db._encode_content("foreign winner"), row_id),
- )
- db._conn.commit()
-
- stale["content"] = "stale local edit"
- stale.pop(_DB_PERSISTED_MARKER, None)
- assert db.append_messages_batch(sid, [stale]) == 0
-
- rows = _active_rows(db, sid)
- assert len(rows) == 1
- assert rows[0]["id"] == row_id
- assert rows[0]["content"] == "foreign winner"
-
-
-def test_plain_read_shape_does_not_expose_internal_cas_digest(db):
- sid = "plain-read"
- db.create_session(sid, "desktop")
- db.append_message(sid, "user", "hello")
- plain = db.get_messages_as_conversation(sid)
- assert plain and DB_ROW_SNAPSHOT not in plain[0]