Skip to content

The agent that grows with you

test: give the mixed compression chain its own test

kshitijk4poor1f4542c27b9c
diff --git a/tests/hermes_cli/test_sessions_source_local.py b/tests/hermes_cli/test_sessions_source_local.py
index 2910ad7c915..b9a167bf75e 100644
--- a/tests/hermes_cli/test_sessions_source_local.py
+++ b/tests/hermes_cli/test_sessions_source_local.py
@@ -32,25 +32,6 @@ def test_list_includes_a_compression_tip_whose_root_has_no_created_source(tmp_pa
"chain-tip", input_tokens=2, output_tokens=1, model="m", api_call_count=1, source="cli")
assert [db.get_session(sid)["created_source"] for sid in ("chain-root", "chain-mid", "chain-tip")] == [
"cli", "cli", "cli"]
- # Mixed chain: a NULL root behind a mid segment already on the same surface is still
- # stamped; an ancestor on another surface stops the walk.
- with db._lock:
- db._conn.execute("UPDATE sessions SET created_source=NULL WHERE id=?", ("chain-root",))
- db._conn.execute("UPDATE sessions SET created_source=NULL WHERE id=?", ("chain-tip",))
- db._conn.commit()
- db.update_token_counts("chain-tip", input_tokens=1, model="m", api_call_count=1, source="cli")
- assert db.get_session("chain-root")["created_source"] == "cli"
- with db._lock:
- db._conn.execute("UPDATE sessions SET created_source=NULL WHERE id=?", ("chain-root",))
- db._conn.execute("UPDATE sessions SET created_source='tui' WHERE id=?", ("chain-mid",))
- db._conn.execute("UPDATE sessions SET created_source=NULL WHERE id=?", ("chain-tip",))
- db._conn.commit()
- db.update_token_counts("chain-tip", input_tokens=1, model="m", api_call_count=1, source="cli")
- assert [db.get_session(sid)["created_source"] for sid in ("chain-root", "chain-mid", "chain-tip")] == [
- None, "tui", "cli"]
- with db._lock:
- db._conn.execute("UPDATE sessions SET created_source='cli' WHERE id IN ('chain-root', 'chain-mid')")
- db._conn.commit()
capsys.readouterr()
_cmd_list(db, Namespace(limit=20, source="cli", workspace=None))
listed = capsys.readouterr().out
diff --git a/tests/hermes_state/test_compression_created_source.py b/tests/hermes_state/test_compression_created_source.py
index 7026c55ec2b..410b2761996 100644
--- a/tests/hermes_state/test_compression_created_source.py
+++ b/tests/hermes_state/test_compression_created_source.py
@@ -48,3 +48,24 @@ def test_desktop_worker_heals_gui_to_desktop(tmp_path, child_created):
assert _created(db, "parent-" + child) == "desktop"
finally:
db.close()
+
+
[email protected]("mid_created, expected_root", [("cli", "cli"), ("tui", None)])
+def test_stamp_walks_through_a_same_surface_mid_segment(tmp_path, mid_created, expected_root):
+ """root(NULL) -> mid -> tip(NULL): a usage write on the tip stamps the root through a mid
+ segment already on the tip's surface; a mid on another surface stops the walk."""
+ db = SessionDB(db_path=tmp_path / "state.db")
+ try:
+ mid = _compress(db, None, "mid")
+ db.publish_compression_child(
+ parent_session_id=mid, child_session_id="tip", source="local",
+ messages=[{"role": "user", "content": "hi"}], require_compression_lease=False)
+ with db._lock:
+ db._conn.execute("UPDATE sessions SET created_source=? WHERE id=?", (mid_created, mid))
+ db._conn.execute("UPDATE sessions SET created_source=NULL WHERE id='tip'")
+ db._conn.commit()
+ db.update_token_counts("tip", input_tokens=1, model="m", api_call_count=1, source="cli")
+ assert [_created(db, sid) for sid in ("parent-mid", mid, "tip")] == [
+ expected_root, mid_created, "cli"]
+ finally:
+ db.close()