The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): refuse a peer submit for a member its route does not name
unsupportedpastels3dc8fc736943
diff --git a/tests/tui_gateway/test_hosted_room_peer_transport.py b/tests/tui_gateway/test_hosted_room_peer_transport.pyindex 8da9120e6b8..39f3f9e60f9 100644--- a/tests/tui_gateway/test_hosted_room_peer_transport.py+++ b/tests/tui_gateway/test_hosted_room_peer_transport.py@@ -4,6 +4,8 @@ from __future__ import annotationsfrom typing import Any+import pytest+from gateway.hosted_room_driver import TaskIdentityfrom tui_gateway.hosted_room_driver import HostedRoomBinding, ROOM_SESSION_SOURCEfrom tui_gateway.hosted_room_peer_transport import (@@ -171,6 +173,29 @@ def test_peer_transport_dispatches_full_fenced_coordinates_and_exact_stop():assert len([call for call in client.calls if call[0] == "stop"]) == 1+def test_peer_transport_refuses_a_submit_for_another_member():+ client = FakePeerClient()+ transport = _transport(client)+ transport.create(+ profile="reviewer",+ title="Group: room-1",+ source=ROOM_SESSION_SOURCE,+ )+ args = dict(+ profile="reviewer",+ session_id="group-session",+ prompt="Review this change.",+ source=ROOM_SESSION_SOURCE,+ task=TaskIdentity("room-1", "task-1", "thread-1", "turn-1"),+ execution_generation=1,+ on_terminal=lambda _receipt: None,+ )+ with pytest.raises(ValueError, match="member does not match"):+ transport.submit(**args, member_id="member-other")+ assert not [call for call in client.calls if call[0] == "dispatch"]+ assert transport.submit(**args, member_id="member-reviewer")["status"] == "accepted"++def test_peer_transport_carries_each_turns_real_source_event_sequence():observed = []for index, source_event_seq in enumerate((7, 42), start=1):diff --git a/tui_gateway/hosted_room_peer_transport.py b/tui_gateway/hosted_room_peer_transport.pyindex e49594c5f9c..c352e6c9856 100644--- a/tui_gateway/hosted_room_peer_transport.py+++ b/tui_gateway/hosted_room_peer_transport.py@@ -193,9 +193,12 @@ class PeerHostedRoomTransport(InternalSessionRPC):def submit(self, *, profile: str, session_id: str, prompt: str, source: str, task: TaskIdentity,- execution_generation: int, on_terminal: Callable[[Mapping[str, Any]], None], member_id: str = "",+ execution_generation: int, on_terminal: Callable[[Mapping[str, Any]], None],+ member_id: str | None = None,) -> Mapping[str, Any]:- del member_id # the signed route already names the member+ # The signed route names one member: a task for another member reached the wrong route.+ if member_id is not None and member_id != self.route.member_id:+ raise ValueError("peer room transport member does not match its grant")self._validate_coordinates(profile=profile, source=source)if self._session_id not in {None, session_id}:raise ValueError("peer room session changed during admission")