Skip to content

The agent that grows with you

refactor(gateway): one-line docstring-only exception classes in hosted-room modules

Teknium95219370c02e
diff --git a/gateway/hosted_room_discussion.py b/gateway/hosted_room_discussion.py
index 2ce3ae782ad..9273ca7ff65 100644
--- a/gateway/hosted_room_discussion.py
+++ b/gateway/hosted_room_discussion.py
@@ -66,8 +66,7 @@ _GATEWAY_EVENT_FIELDS = {
_EPOCH_STAMPED_KINDS = _TERMINAL_EVENT_KINDS | {"message.member", *_GATEWAY_EVENT_FIELDS}
-class DiscussionPolicyError(ValueError):
- """Base class for invalid policy input or unreconstructable state."""
+class DiscussionPolicyError(ValueError): """Base class for invalid policy input or unreconstructable state."""
class DiscussionValidationError(DiscussionPolicyError):
diff --git a/gateway/hosted_room_driver.py b/gateway/hosted_room_driver.py
index ec294db1644..89533d2ae50 100644
--- a/gateway/hosted_room_driver.py
+++ b/gateway/hosted_room_driver.py
@@ -103,36 +103,28 @@ _GENERATION_TRANSITIONS = {
"deferred task generation changed", "deferred task changed during requeue")}
-class DriverStateError(ValueError):
- """Base class for invalid or conflicting driver-state operations."""
+class DriverStateError(ValueError): """Base class for invalid or conflicting driver-state operations."""
-class DriverValidationError(DriverStateError):
- """Raised when an identifier, clock, TTL, or payload is invalid."""
+class DriverValidationError(DriverStateError): """Raised when an identifier, clock, TTL, or payload is invalid."""
-class RoomUnavailableError(DriverStateError):
- """Raised when the hosted room does not exist or was disbanded."""
+class RoomUnavailableError(DriverStateError): """Raised when the hosted room does not exist or was disbanded."""
-class LeaseHeldError(DriverStateError):
- """Raised when another unexpired driver generation owns the room."""
+class LeaseHeldError(DriverStateError): """Raised when another unexpired driver generation owns the room."""
-class StaleLeaseError(DriverStateError):
- """Raised when a lease generation can no longer mutate room state."""
+class StaleLeaseError(DriverStateError): """Raised when a lease generation can no longer mutate room state."""
-class TaskConflictError(DriverStateError):
- """Raised when an idempotency key is reused for different task state."""
+class TaskConflictError(DriverStateError): """Raised when an idempotency key is reused for different task state."""
-class StaleTaskError(DriverStateError):
- """Raised when an obsolete task attempt or cancellation tries to commit."""
+class StaleTaskError(DriverStateError): """Raised when an obsolete task attempt or cancellation tries to commit."""
-class InvalidTaskTransitionError(DriverStateError):
- """Raised when a requested task transition is not allowed."""
+class InvalidTaskTransitionError(DriverStateError): """Raised when a requested task transition is not allowed."""
_identifier = partial(identifier, error=DriverValidationError, max_chars=MAX_IDENTIFIER_CHARS)
diff --git a/gateway/hosted_room_execution_policy.py b/gateway/hosted_room_execution_policy.py
index 2014b38680b..6bc87f6a86e 100644
--- a/gateway/hosted_room_execution_policy.py
+++ b/gateway/hosted_room_execution_policy.py
@@ -17,8 +17,7 @@ _IDENTIFIER_RE = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._:-]*$")
_POLICY_FIELDS = {"version", "target_profile", "enabled_toolsets", "approval_mode", "max_iterations", "policy_digest"}
-class RoomExecutionPolicyError(ValueError):
- """A RoomLink execution policy is malformed or no longer current."""
+class RoomExecutionPolicyError(ValueError): """A RoomLink execution policy is malformed or no longer current."""
def _policy_digest(unsigned: Mapping[str, Any]) -> str:
diff --git a/gateway/hosted_room_peer.py b/gateway/hosted_room_peer.py
index ab532d8c9f7..bcb22f7d2b4 100644
--- a/gateway/hosted_room_peer.py
+++ b/gateway/hosted_room_peer.py
@@ -39,12 +39,10 @@ LinkMode = Literal["direct", "overlay", "relay", "pull", "desktop"]
TransportSecurity = Literal["tls", "loopback"]
-class HostedRoomPeerError(ValueError):
- """Base error for malformed or unauthorized peer-room input."""
+class HostedRoomPeerError(ValueError): """Base error for malformed or unauthorized peer-room input."""
-class HostedRoomGrantError(HostedRoomPeerError):
- """Raised when a room-scoped grant is invalid or expired."""
+class HostedRoomGrantError(HostedRoomPeerError): """Raised when a room-scoped grant is invalid or expired."""
_ROOM_GRANT_SECRET_FILE = ".room-link-grant-secret"
diff --git a/gateway/hosted_room_replicas.py b/gateway/hosted_room_replicas.py
index cb733966390..2ab23d22a8c 100644
--- a/gateway/hosted_room_replicas.py
+++ b/gateway/hosted_room_replicas.py
@@ -40,16 +40,13 @@ _INSERT_REPLICA_EVENT = f"INSERT INTO hosted_room_replica_events {_EVENT_COLUMNS
_SELECT_REPLICA = "SELECT * FROM hosted_room_replicas WHERE room_id=?"
-class ReplicaError(HostedRoomError):
- """Base class for invalid or conflicting replica operations."""
+class ReplicaError(HostedRoomError): """Base class for invalid or conflicting replica operations."""
-class ReplicaGapError(ReplicaError):
- """A page does not start at the replica's next expected sequence."""
+class ReplicaGapError(ReplicaError): """A page does not start at the replica's next expected sequence."""
-class ReplicaEpochRegressionError(ReplicaError):
- """A page or demotion carries an older authority epoch than stored."""
+class ReplicaEpochRegressionError(ReplicaError): """A page or demotion carries an older authority epoch than stored."""
def _initialize_replica_schema(conn: sqlite3.Connection) -> None:
diff --git a/gateway/hosted_rooms.py b/gateway/hosted_rooms.py
index 8562024dad7..7ae15b9039c 100644
--- a/gateway/hosted_rooms.py
+++ b/gateway/hosted_rooms.py
@@ -188,12 +188,10 @@ _SELECT_LIVE_RESERVATION = (
f"SELECT 1 FROM hosted_room_peer_reservations {_LIVE_RESERVATION_WHERE} LIMIT 1")
-class HostedRoomError(ValueError):
- """Base class for invalid or conflicting hosted-room operations."""
+class HostedRoomError(ValueError): """Base class for invalid or conflicting hosted-room operations."""
-class RoomNotFoundError(HostedRoomError):
- """Raised when a room does not exist or has been disbanded."""
+class RoomNotFoundError(HostedRoomError): """Raised when a room does not exist or has been disbanded."""
class RoomHistoryExpiredError(RoomNotFoundError):
@@ -202,16 +200,14 @@ class RoomHistoryExpiredError(RoomNotFoundError):
reason = "room_history_expired"
-class RoomConflictError(HostedRoomError):
- """Raised when an idempotency key is reused for different room state."""
+class RoomConflictError(HostedRoomError): """Raised when an idempotency key is reused for different room state."""
class RoomProbeUnavailableError(HostedRoomError):
"""Raised when a non-blocking ownership probe cannot read the room store."""
-class EventConflictError(HostedRoomError):
- """Raised when an event id is reused with different immutable content."""
+class EventConflictError(HostedRoomError): """Raised when an event id is reused with different immutable content."""
class AuthorityConflictError(HostedRoomError):