The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(gateway): hug dangling closers in hosted-room modules (AST-neutral)
Teknium8fceac9b630c
diff --git a/gateway/hosted_room_driver.py b/gateway/hosted_room_driver.pyindex 08ddfc6c033..eeca73ec39e 100644--- a/gateway/hosted_room_driver.py+++ b/gateway/hosted_room_driver.py@@ -232,8 +232,7 @@ def _initialize_schema(conn: sqlite3.Connection) -> None:authority_epoch INTEGER NOT NULL CHECK (authority_epoch >= 1), process_generation TEXT NOT NULL,lease_generation INTEGER NOT NULL CHECK (lease_generation >= 1),expires_at REAL NOT NULL, acquired_at REAL NOT NULL, updated_at REAL NOT NULL, released_at REAL,- FOREIGN KEY (room_id) REFERENCES hosted_rooms(room_id))"""- )+ FOREIGN KEY (room_id) REFERENCES hosted_rooms(room_id))""")_create_task_table(conn)_validate_schema(conn)conn.execute(_TASK_INDEX_SQL.format(if_not_exists="IF NOT EXISTS "))@@ -254,8 +253,7 @@ def _validate_schema(conn: sqlite3.Connection) -> None:def _schema_objects_exist(conn: sqlite3.Connection) -> bool:rows = conn.execute("""SELECT name FROM sqlite_master WHERE type='table'- AND name IN ('hosted_room_driver_leases', 'hosted_room_driver_tasks')"""- ).fetchall()+ AND name IN ('hosted_room_driver_leases', 'hosted_room_driver_tasks')""").fetchall()if {row[0] for row in rows} != {"hosted_room_driver_leases", "hosted_room_driver_tasks"}:return Falseindex = conn.execute(diff --git a/gateway/hosted_room_replicas.py b/gateway/hosted_room_replicas.pyindex 93ec8b69bd3..495c44fb4ef 100644--- a/gateway/hosted_room_replicas.py+++ b/gateway/hosted_room_replicas.py@@ -44,15 +44,13 @@ def _initialize_replica_schema(conn: sqlite3.Connection) -> None:last_seq INTEGER NOT NULL DEFAULT 0 CHECK (last_seq >= 0),latest_seq INTEGER NOT NULL DEFAULT 0, event_bytes INTEGER NOT NULL DEFAULT 0,created_at REAL NOT NULL, updated_at REAL NOT NULL- )"""- )+ )""")conn.execute("""CREATE TABLE IF NOT EXISTS hosted_room_replica_events (room_id TEXT NOT NULL, seq INTEGER NOT NULL CHECK (seq >= 1), event_id TEXT NOT NULL,kind TEXT NOT NULL, actor_json TEXT NOT NULL, authority_epoch INTEGER,payload_json TEXT NOT NULL, created_at REAL NOT NULL,PRIMARY KEY (room_id, seq)- )"""- )+ )""")@contextmanagerdiff --git a/gateway/hosted_rooms.py b/gateway/hosted_rooms.pyindex 4e2622de82d..e8330d5bbd1 100644--- a/gateway/hosted_rooms.py+++ b/gateway/hosted_rooms.py@@ -396,8 +396,7 @@ def _migrate_legacy_columns(conn: sqlite3.Connection) -> None:)FROM hosted_room_eventsWHERE hosted_room_events.room_id=hosted_rooms.room_id- ), 0)"""- )+ ), 0)""")def _initialize_schema(conn: sqlite3.Connection) -> None:@@ -636,8 +635,7 @@ def list_room_link_records(db_path: DbPath) -> list[dict[str, Any]]:catalog_json, cancellation_scope_id, trace_id,transport_security, status, updated_atFROM hosted_room_links- ORDER BY room_id, member_id"""- ).fetchall()+ ORDER BY room_id, member_id""").fetchall()return [dict(row) for row in rows]