P-086 (P2): Catch-All-Guard in add_excluded_room + Tests für _persist_excluded_rooms

Auflage 1 (P2-1): add_excluded_room() erhält defensiven Catch-All-Guard
analog remove_room() — ein excluded Raum darf nicht gleichzeitig Catch-All
sein. Behebt API-Asymmetrie (remove_room hatte den Guard, add_excluded_room
nicht). Ohne Guard würde ein übersprungener Catch-All-Raum beim nächsten
validate() einen FATAL auslösen.

Auflage 2 (P2-2): _persist_excluded_rooms (adapter.py) war testlos.
Neue Tests: add+save+reload (Disk-Roundtrip), Idempotenz (kein
Doppelt-Eintrag), Multi-Room-Persistenz, early-return ohne archivar,
Catch-All-Schutz. Zusätzlich add_excluded_room_rejects_catch_all auf
RoomMap-Ebene.
This commit is contained in:
Bernd (Hermes)
2026-08-21 19:53:52 +02:00
parent 5720b48883
commit 2c7cac284c
3 changed files with 189 additions and 0 deletions
+14
View File
@@ -1040,6 +1040,20 @@ class RoomMap:
Args:
room_id: Die Raum-ID.
"""
# P-086 (P2-1): Catch-All-Schutz — ein excluded Raum darf NICHT
# gleichzeitig Catch-All sein. API-Asymmetrie zu remove_room()
# (Z.1024-1027) behoben: remove_room hat diesen Guard, add_excluded_room
# hatte ihn nicht. Ohne Guard würde ein übersprungener Catch-All-Raum
# beim nächsten validate() einen FATAL auslösen (Z.576-580).
catch_all = self.catch_all_room
if catch_all is not None and room_id == catch_all.room_id:
logger.warning(
"Catch-All-Raum '%s' kann nicht excluded werden — "
"add_excluded_room ignoriert room_id '%s'",
catch_all.name,
room_id,
)
return
if room_id in self._excluded_room_ids:
return
self._excluded_room_ids.add(room_id)