The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(gateway): pack compound-statement headers in hosted-room modules (AST-neutral)
Tekniumd10256f36691
diff --git a/gateway/hosted_room_discussion.py b/gateway/hosted_room_discussion.pyindex d60abf7e376..17f001792eb 100644--- a/gateway/hosted_room_discussion.py+++ b/gateway/hosted_room_discussion.py@@ -767,8 +767,7 @@ def reconstruct_task_plan(if not isinstance(identity, driver.TaskIdentity) or not isinstance(payload, Mapping):raise DiscussionReconstructionError("driver task has no valid identity or payload")required_payload = frozenset({"target_profile", "prompt", "source_event_seq"})- if not required_payload <= frozenset(payload) or (- frozenset(payload) - required_payload - {"target_member_id"}):+ if not required_payload <= frozenset(payload) or (frozenset(payload) - required_payload - {"target_member_id"}):raise DiscussionReconstructionError("driver task payload shape changed")match = _TURN_ID_RE.fullmatch(identity.turn_id)if match is None:diff --git a/gateway/hosted_rooms.py b/gateway/hosted_rooms.pyindex 310e879326e..98956d8e9ec 100644--- a/gateway/hosted_rooms.py+++ b/gateway/hosted_rooms.py@@ -336,9 +336,8 @@ def _validate_actor(value: Any, *, kind: str) -> tuple[dict[str, str], str]:raise HostedRoomError(f"actor kind '{actor_kind}' cannot append '{kind}'")actor = {"kind": actor_kind, "id": _actor_id(value.get("id"), "actor.id")}for field, max_chars in (- ("display_name", MAX_ACTOR_LABEL_CHARS),- ("profile", MAX_ACTOR_ID_CHARS),- ("connection_id", MAX_ACTOR_ID_CHARS)):+ ("display_name", MAX_ACTOR_LABEL_CHARS), ("profile", MAX_ACTOR_ID_CHARS), ("connection_id", MAX_ACTOR_ID_CHARS)+ ):field_value = _optional_actor_field(value, field, max_chars)if field_value:actor[field] = field_value@@ -961,8 +960,7 @@ def create_room(now = _now(now)with _transaction(db_path, immediate=True) as conn:- if conn.execute(- "SELECT 1 FROM hosted_room_retired_ids WHERE room_id=?", (room_id,)).fetchone():+ if conn.execute("SELECT 1 FROM hosted_room_retired_ids WHERE room_id=?", (room_id,)).fetchone():raise RoomConflictError("room_id belongs to a disbanded room")existing = conn.execute(_SELECT_ROOM_WITH_BYTES, (room_id,)).fetchone()if existing is not None:@@ -1090,9 +1088,7 @@ def append_event((room_id,)).fetchone()if room is None:_raise_room_not_found(conn, room_id)- if (- room["authority_gateway_id"] != authority_gateway_id- or int(room["authority_epoch"]) != authority_epoch):+ if room["authority_gateway_id"] != authority_gateway_id or int(room["authority_epoch"]) != authority_epoch:raise AuthorityConflictError("stale hosted room authority")seq = int(room["next_seq"])event_bytes = _insert_event(@@ -1299,9 +1295,7 @@ def disband_room(replay = _disband_replay(conn, room_id, room)if replay is not None:return replay- if (- str(room["authority_gateway_id"]) != expected_gateway_id- or int(room["authority_epoch"]) != expected_epoch):+ if str(room["authority_gateway_id"]) != expected_gateway_id or int(room["authority_epoch"]) != expected_epoch:raise AuthorityConflictError("stale hosted room authority")disband_bytes = _insert_event(conn, room, room_id, int(room["next_seq"]), "system:room-disbanded", "room.disbanded",diff --git a/gateway/hosted_rooms_common.py b/gateway/hosted_rooms_common.pyindex b50a31ffc49..5de2f1cdfa2 100644--- a/gateway/hosted_rooms_common.py+++ b/gateway/hosted_rooms_common.py@@ -36,11 +36,7 @@ def identifier(def bounded_int(value: Any, *, error: type[Exception], message: str, low: int = 0, high: int | None = None) -> int:"""Reject bools, non-ints and values outside ``[low, high]`` (``message`` is the exact text)."""- if (- isinstance(value, bool)- or not isinstance(value, int)- or value < low- or (high is not None and value > high)):+ if isinstance(value, bool) or not isinstance(value, int) or value < low or (high is not None and value > high):raise error(message)return value