The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(state): a compression publish stamps the chain's unset ancestors
kshitijk4poor19788a0448bc
diff --git a/hermes_state_compression.py b/hermes_state_compression.pyindex ee58931ceab..f365b918775 100644--- a/hermes_state_compression.py+++ b/hermes_state_compression.py@@ -438,6 +438,9 @@ class SessionCompressionMixin:"WHERE id = ? AND ended_at IS NULL", (time.time(), parent_session_id))if updated.rowcount != 1:raise RuntimeError(f"Compression parent changed during publication: {parent_session_id}")+ # A child on a real surface stamps the chain's unset ancestors, so compressing a conversation+ # whose root predates write-time stamping lists it again under its surface.+ stamp_compression_ancestors(conn, child_session_id)from hermes_state_local_lineage import advance_local_targetadvance_local_target(conn, parent_session_id, child_session_id)if parent["archived"]:diff --git a/tests/hermes_state/test_compression_created_source.py b/tests/hermes_state/test_compression_created_source.pyindex 410b2761996..5e8c80558e1 100644--- a/tests/hermes_state/test_compression_created_source.py+++ b/tests/hermes_state/test_compression_created_source.py@@ -69,3 +69,21 @@ def test_stamp_walks_through_a_same_surface_mid_segment(tmp_path, mid_created, eexpected_root, mid_created, "cli"]finally:db.close()++[email protected]("root_created", [None, "unknown", "local"])+def test_compressing_a_stamped_tip_stamps_its_legacy_root(tmp_path, root_created):+ """A chain compressed before write-time stamping has an unset root and a stamped tip. The+ next compression publish copies the tip's surface to the child and stamps the root."""+ db = SessionDB(db_path=tmp_path / "state.db")+ try:+ tip = _compress(db, root_created, "legacy-tip")+ with db._lock:+ db._conn.execute("UPDATE sessions SET created_source='cli' WHERE id=?", (tip,))+ db._conn.commit()+ db.publish_compression_child(+ parent_session_id=tip, child_session_id="new-tip", source="local",+ messages=[{"role": "user", "content": "hi"}], require_compression_lease=False)+ assert [_created(db, sid) for sid in ("parent-" + tip, tip, "new-tip")] == ["cli"] * 3+ finally:+ db.close()