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
@@ -149,3 +149,18 @@ class TestAddExcludedRoom:
room_map.add_excluded_room("r_never_onboarded")
assert room_map.is_excluded("r_never_onboarded") is True
assert "r_never_onboarded" not in room_map.rooms
def test_add_excluded_room_rejects_catch_all(self):
"""P-086 (P2-1): Catch-All-Raum kann NICHT excluded werden.
API-Asymmetrie zu remove_room() behoben — der Guard verhindert, dass
ein übersprungener Catch-All-Raum beim nächsten validate() einen
FATAL auslöst (Z.576-580).
"""
room_map = _make_map([_room("r_catchall", "#CatchAll", catch_all=True)])
room_map.add_excluded_room("r_catchall")
assert room_map.is_excluded("r_catchall") is False
assert len(room_map.excluded_room_ids) == 0
# Catch-All bleibt intakt
assert room_map.catch_all_room is not None
assert room_map.catch_all_room.room_id == "r_catchall"