Skip to content

The agent that grows with you

fix(gateway): an old messaging conversation can be deleted from the picker

yoniebansaf1e83491987
diff --git a/gateway/session_mutations.py b/gateway/session_mutations.py
index 6df67e83dbf..755b462349d 100644
--- a/gateway/session_mutations.py
+++ b/gateway/session_mutations.py
@@ -56,7 +56,13 @@ def _authorize_control(authority, actor, ref, params, owner=None):
require_history_claim(authority, conn, actor, ref.session_id)
cold_history = authorize_history(conn, actor, ref.session_id)
if not cold_history:
- authority.authorize(actor, ref, 'session:control')
+ if params.get('operation') == 'delete':
+ # The read gate mounts a cold row first, so the check below sees what it is.
+ authority.authorize(actor, ref, 'session:read')
+ if not (params.get('operation') == 'delete' and authority.sessions[ref.session_id].superseded):
+ # An old conversation its chat moved past is read-only, but deleting it retires its
+ # own lineage only (retirement never evicts a read-only mount's route).
+ authority.authorize(actor, ref, 'session:control')
return cold_history
@@ -71,13 +77,18 @@ def _owner_ref(authority, ref, params):
A transcript- or policy-changing operation (rewind, reset, compress, a policy pick) keeps the
listed id: its busy gate, generation fence and eviction are keyed by the session it writes, so
authorizing it on the owner while writing the segment would bypass the owner's FIFO. A segment
- of a live owner therefore stays a named refusal for those, as on main."""
+ of a live owner therefore stays a named refusal for those, as on main. A delete of a messaging
+ conversation's later compression segment resolves to its lineage root, where its lane's
+ session lives (``messaging_owner_ref``, as resume does)."""
if params.get('operation') not in _OWNER_AUTHORIZED:
return ref
from gateway.session_contract import SessionRef
from hermes_state_local import local_lineage_owner
with authority.db._read_ctx() as conn:
owner = local_lineage_owner(conn, ref.session_id)
+ if owner == ref.session_id and params.get('operation') == 'delete':
+ from gateway.session_route_recovery import messaging_owner_ref
+ return messaging_owner_ref(authority, ref)
return ref if owner == ref.session_id else SessionRef(ref.profile_id, owner)