The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: preserve hosted room ownership during service shutdown
Tekniumbfa8022d88c4
diff --git a/gateway/session_group_controls.py b/gateway/session_group_controls.pyindex 1d20c08e1b9..ca1dac0f5fc 100644--- a/gateway/session_group_controls.py+++ b/gateway/session_group_controls.py@@ -86,7 +86,7 @@ def _group(authority, actor, home, method, params):service = Noneexecution_methods = {'groups.send', 'groups.stop', 'groups.retry', 'groups.approve'}- if service is not None and 'room_id' in params:+ if getattr(authority, 'hosted_room_service', None) is not None and 'room_id' in params:if room_authorizer is None:raise RuntimeStoreError('permission_denied')room_authorizer(actor.subject, params['room_id'], create=method == 'groups.create')@@ -107,7 +107,21 @@ def _group(authority, actor, home, method, params):def listing():limit, offset = params.get('limit', rooms.MAX_ROOM_LIST_LIMIT), params.get('offset', 0)result = rooms.list_rooms(db_path, **params)- return {'rooms': result, 'next_offset': offset + limit if len(result) == limit else None}+ next_offset = offset + limit if len(result) == limit else None+ if getattr(authority, 'hosted_room_service', None) is not None:+ visible = []+ for room in result:+ if room_authorizer is None:+ raise RuntimeStoreError('permission_denied')+ try:+ room_authorizer(actor.subject, room['room_id'])+ except RuntimeStoreError as exc:+ if exc.reason != 'permission_denied':+ raise+ else:+ visible.append(room)+ result = visible+ return {'rooms': result, 'next_offset': next_offset}def create():if service is not None:diff --git a/tests/gateway/test_session_group_execution_controls.py b/tests/gateway/test_session_group_execution_controls.pyindex 038f6b1ba28..b0ddf652982 100644--- a/tests/gateway/test_session_group_execution_controls.py+++ b/tests/gateway/test_session_group_execution_controls.py@@ -70,6 +70,9 @@ def test_execution_controls_preserve_native_wire_and_exact_task_identity(tmp_patassert service.calls[-1] == ('create', 'owned')state = await call('groups.state', room_id='owned')assert state['result']['driver_status'] == service.status('owned')+ other = AuthorityConnection(authority, object(), {'user_id': 'bob'})+ listed = await other.dispatch({'id': 1, 'method': 'groups.list', 'params': {}})+ assert listed['result']['rooms'] == []payload = {'text': '@one hello', 'mentions': ['one']}sent = await call('groups.send', room_id='owned', event_id='input', payload=payload)@@ -133,6 +136,9 @@ def test_execution_controls_reject_foreign_actor_profile_room_and_unready_servicassert result['error']['message'] == 'runtime_coordination_required'caps = await owner.dispatch({'id': 1, 'method': 'groups.capabilities', 'params': {}})assert caps['result']['driver'] is False+ foreign = AuthorityConnection(authority, object(), {'user_id': 'bob'})+ result = await foreign.dispatch({'id': 1, 'method': 'groups.state', 'params': {'room_id': 'owned'}})+ assert result['error']['message'] == 'permission_denied'assert service.calls == []asyncio.run(probe())