feat(matrix-bridge-dagi): support N rooms in BRIDGE_ROOM_MAP, reject duplicate room_id (M2.0)

Made-with: Cursor
This commit is contained in:
Apple
2026-03-05 01:21:07 -08:00
parent 70dd2a97dc
commit 79db053b38
2 changed files with 87 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
"""
Room-to-Agent Mapping — Phase M1
Room-to-Agent Mapping — Phase M2.0 (N rooms, 1 agent per room)
Parses BRIDGE_ROOM_MAP env var and provides:
- room_id → agent_id lookup
@@ -148,6 +148,16 @@ def parse_room_map(raw: str, allowed_agents: FrozenSet[str]) -> RoomMappingConfi
if errors:
raise ValueError(f"BRIDGE_ROOM_MAP parse errors: {'; '.join(errors)}")
# M2.0: fail fast on duplicate room_id (1 room must map to exactly 1 agent)
seen_rooms: Dict[str, str] = {}
for m in mappings:
if m.room_id in seen_rooms:
raise ValueError(
f"Duplicate room_id {m.room_id!r}: already bound to agent "
f"{seen_rooms[m.room_id]!r}, cannot rebind to {m.agent_id!r}"
)
seen_rooms[m.room_id] = m.agent_id
config = RoomMappingConfig(mappings=mappings, allowed_agents=allowed_agents)
logger.info(
"Room mapping loaded: %d entries, allowed_agents=%s",