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:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user