Skip to content

The agent that grows with you

test(sessions): pin the /save json projection by exported row ids

kshitijk4poor6e0bdb943582
diff --git a/tests/hermes_cli/test_save_transcript_history.py b/tests/hermes_cli/test_save_transcript_history.py
index 419f5c367b2..6440c0ffb25 100644
--- a/tests/hermes_cli/test_save_transcript_history.py
+++ b/tests/hermes_cli/test_save_transcript_history.py
@@ -81,6 +81,9 @@ def test_save_json_restores_compacted_history_as_archived(tmp_path, monkeypatch,
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
db = _compacted_store(tmp_path / "state.db")
+ # A model-only live row (a micro-compaction merge) is context, not display history: only the transfer
+ # projection carries it, so the snapshot's ids pin that projection, not the display read.
+ db.append_message("s1", "user", "merged", display_metadata={"model_only": True})
db.append_message("s1", "user", "undone secret")
db.rewind_to_message("s1", db.get_messages("s1")[-1]["id"])
@@ -90,7 +93,8 @@ def test_save_json_restores_compacted_history_as_archived(tmp_path, monkeypatch,
try:
shown, live = shape(db, include_compacted=True), shape(db)
snapshot = json.loads(save(db, "json", tmp_path / "saved.json"))
- assert "undone secret" not in [m["content"] for m in snapshot["messages"]]
+ kept = [m["id"] for m in db.get_messages("s1", include_inactive=True) if m["active"] or m["compacted"]]
+ assert [m["id"] for m in snapshot["messages"]] == kept # every kept row, not the deduped display read
# Like `hermes sessions export`, the in-memory backup is capped per session (sessions.max_export_messages).
monkeypatch.setattr("hermes_state.resolved_max_export_messages", lambda: 5)
assert "max_export_messages" in save(db, "json", tmp_path / "capped.json")