Skip to content

The agent that grows with you

fix(gateway): rename and archive of a compressed local conversation authorize on its owner

Tekniume06e4e346791
diff --git a/gateway/session_mutations.py b/gateway/session_mutations.py
index 3eaf712558e..3d2cffa89e7 100644
--- a/gateway/session_mutations.py
+++ b/gateway/session_mutations.py
@@ -58,11 +58,13 @@ def _authorize_control(authority, actor, ref, params):
def _owner_ref(authority, ref, params):
- """A delete names the listed row, which may be a later reset segment of a local conversation;
- the conversation's creation id owns its policy, FIFO and live session, so control and the
- session gate are checked on that owner (the store deletes the whole lineage either way)."""
- if params.get('operation') != 'delete':
- return ref
+ """A control mutation names the listed row, which may be a later reset or compression segment of
+ a local conversation; the conversation's creation id owns its policy, FIFO and live session, so
+ control and the session gate are checked on that owner for every operation. The write itself
+ still names the listed row (a title or archive flag belongs to it; delete takes the lineage).
+ Gating only ``delete`` restored a cold segment as if it were an owner, and rename/archive of a
+ compressed conversation answered ``storage_unavailable`` (#134889 LC-22, as LC-12 on resume)."""
+ del params
from gateway.session_contract import SessionRef
from hermes_state_local import local_lineage_owner
with authority.db._read_ctx() as conn:
diff --git a/tests/gateway/test_local_control_compression_child.py b/tests/gateway/test_local_control_compression_child.py
new file mode 100644
index 00000000000..271ba575823
--- /dev/null
+++ b/tests/gateway/test_local_control_compression_child.py
@@ -0,0 +1,38 @@
+"""Rename and archive of a cold compressed local conversation by its physical id (LC-22).
+
+Session lists hand Desktop the listed row's physical id, which after a compression is a child
+segment. ``_owner_ref`` remapped only ``delete`` to the lineage owner, so a rename or archive of a
+cold child restored the CHILD as if it were an owner and answered ``storage_unavailable`` (same
+class as LC-12 on the resume door). Real authority, real SQLite, real compression publish.
+"""
+import pytest
+
+from tests.gateway.test_local_resume_compression_child import _cold, _compressed
+
+
+async def _mutate(authority, sid, request_id, operation, payload):
+ from gateway.session_controls import AuthorityConnection
+ connection = AuthorityConnection(authority, object(), {
+ 'provider': 'local', 'user_id': 'owner', 'profile_id': 'fixture', 'instance_id': authority.instance_id,
+ 'capabilities': ['session:create', 'session:read', 'session:control']})
+ try:
+ row = authority.db.get_session(sid)
+ return await connection.dispatch({'id': 1, 'method': 'session.mutate', 'params': {
+ 'session_id': sid, 'request_id': request_id, 'expected_revision': row['runtime_revision'],
+ 'operation': operation, 'payload': payload}})
+ finally:
+ await connection.close()
+
+
[email protected]('cold', [False, True])
+async def test_rename_and_archive_of_a_compression_segment(tmp_path, monkeypatch, cold):
+ compressed = await _compressed(tmp_path, monkeypatch)
+ authority = await _cold(compressed) if cold else compressed.warm
+ renamed = await _mutate(authority, 'child-2', 'rename-1', 'rename', {'title': 'Renamed'})
+ assert 'result' in renamed, renamed
+ archived = await _mutate(authority, 'child-2', 'archive-1', 'archive', {'archived': True})
+ assert 'result' in archived, archived
+ # The write lands on a row of the user's conversation, and the listing reads it back.
+ titles = {authority.db.get_session(sid).get('title') for sid in (compressed.owner, 'child-1', 'child-2')}
+ assert 'Renamed' in titles, titles