V7-2: Thematisches never_route — _sticky_rooms spatial bypass entfernt

Button 2 (Generell hier bleiben): set_never_route(room_id, topic) mit
Thema aus room_name_to_topic() — bereits korrekt in P0-B implementiert.

Button 3 (Nur diesmal): stay_tracker-Inkrement + Auto-Promotion nach 3x
mit set_never_route(room_id, topic) — bereits korrekt in P0-B.

Router: _check_never_route_topic prüft matched_room.name → topic gegen
never_route[room_id][topic] — bereits korrekt in P0-B.

DER BUG: _sticky_rooms war ein räumlicher Bypass, der ALLE Nachrichten
in einem Raum blockierte, unabhängig vom Thema. Entfernt:
- __init__: _sticky_rooms-Dict entfernt
- Button 2: _sticky_rooms[room_id] = time.time() entfernt
- Button 3 Auto-Promotion: _sticky_rooms[room_id] = time.time() entfernt
- Archivar-Bypass: elif room_id in self._sticky_rooms entfernt

Jetzt läuft jede Nachricht durch den Router, der thematisch prüft:
never_route für 'lan-dokumentation' blockt NICHT 'protonbridge'.

Tests: 8 neue Tests in TestNeverRouteThematic (alle grün, 107/108 passed,
1 pre-existing env-var failure unrelated).
This commit is contained in:
Bernd (Hermes)
2026-07-13 15:44:08 +02:00
parent f687c49295
commit d36ac73212
2 changed files with 148 additions and 8 deletions
+5 -7
View File
@@ -520,9 +520,10 @@ class RocketChatAdapter(BasePlatformAdapter):
else:
self.archivar = None
self._conversation_history = None
# User-Flow C: Move-Requests + Sticky Rooms
# User-Flow C: Move-Requests
self._pending_move_requests: Dict[str, dict] = {}
self._sticky_rooms: Dict[str, float] = {} # room_id → timestamp
# V7-2: _sticky_rooms removed — thematic never_route replaces spatial bypass.
# The router's _check_never_route_topic handles per-topic blocking now.
# Clarify state: maps clarify_id → session_key for gateway resolution
self._clarify_state: Dict[str, str] = {}
# Auto-Onboarding v2: structured interview state
@@ -1312,7 +1313,7 @@ class RocketChatAdapter(BasePlatformAdapter):
elif choice in ("2", "2️⃣", "generell", "generell hier bleiben", "stay_here"):
# 2️⃣ Generell hier bleiben → Antwort im Ursprungsraum + Sticky-Eintrag
# P0-B: Thematischer Sticky (v7) — Thema aus Match-Ergebnis extrahieren
self._sticky_rooms[room_id] = time.time()
# V7-2: _sticky_rooms entfernt — thematisches never_route ersetzt räumlichen Bypass
if _MULTIROOM() and self.archivar is not None:
try:
# Extrahiere Topic aus dem gematchten Raum-Namen
@@ -1350,7 +1351,7 @@ class RocketChatAdapter(BasePlatformAdapter):
topic = room_name_to_topic(target_name)
if topic:
self.archivar._state.set_never_route(room_id, topic)
self._sticky_rooms[room_id] = time.time()
# V7-2: _sticky_rooms entfernt — thematisches never_route reicht
logger.info("[rocketchat] Auto-promoted to never_route after %d stays in room %s, topic '%s'", count, room_id[:8], topic)
await self._post_message_with_retry(room_id, "🔒 Ich habe gemerkt, dass du hier bleiben möchtest — dieser Raum wird ab jetzt nicht mehr automatisch geroutet.")
except Exception as e:
@@ -1418,9 +1419,6 @@ class RocketChatAdapter(BasePlatformAdapter):
logger.debug("[rocketchat] Room %s had pending question — Archivar bypassed", room_id)
logger.debug("[rocketchat] ARCHIVAR-DEBUG: Archivar bypassed — pending_questions")
self._rooms_with_pending_questions.discard(room_id)
elif room_id in self._sticky_rooms:
logger.debug("[rocketchat] Room %s is sticky — Archivar bypassed", room_id[:8])
logger.debug("[rocketchat] ARCHIVAR-DEBUG: Archivar bypassed — sticky_room=%s", room_id[:8])
elif self.archivar._state.should_stay_in_room(room_id) == "always":
# Bug 4 fix: Persistierte Entscheidung (always) aus ArchivarState lesen.
# P0-B: "never_route" ist jetzt thematisch (v7) — wird im Router