fix: V8.1.1 — 3 Blocker (Catch-All-Guard, Ring-GC, Tests)

R1 (P0): Catch-All-Sticky-Vergiftung behoben
- Session-Sticky-Block (adapter.py:1581) prüft jetzt is_catch_all
  und should_stay_in_room VOR dem Auto-Route
- Catch-All-Zielraum → Sticky wird gelöscht, Fall-Through zu Archivar
- stay_in_room=always/never_route → Sticky wird gelöscht, Fall-Through

R2 (P1): MultiRoomContextRing.move_gc() implementiert
- Neue Methode entfernt stale Topics aus Ursprungsraum bei Move
- Fügt neuen Ring-Eintrag für Zielraum hinzu
- Aufruf bei confirm_move (Button 1) und Auto-Route (100%-Match)

R3 (P1): 4 neue Test-Suites (56 Tests)
- test_multiroom_context.py: Ring-Buffer, move_gc, System-Prompt
- test_sticky_session.py: temporäres Sticky, 30 Min TTL, Guards
- test_auto_route.py: 100%-Match, self-match, Catch-All
- test_edge_cases.py: leerer Ring, Catch-All+Auto-Route, Move-Ketten

R4 (P2): Doc-Kommentar für _CURRENT_ORIGIN_ROOM ContextVar-Reset

Verifikation: 401 passed, 1 pre-existing fail (test_no_env_vars)
This commit is contained in:
Bernd (Hermes)
2026-07-14 19:40:44 +02:00
parent 8853a1d9e3
commit 0e39e7076a
6 changed files with 994 additions and 28 deletions
+53
View File
@@ -138,6 +138,59 @@ class MultiRoomContextRing:
for e in self._entries
]
async def move_gc(
self,
origin_room_id: str,
target_room_id: str,
topic: str,
room_name: str = "",
) -> None:
"""Bereinige stale Einträge aus Ursprungsraum bei Move und füge neuen Eintrag für Zielraum hinzu.
Wird aufgerufen wenn eine Konversation von origin_room_id nach
target_room_id verschoben wird (Button-Bestätigung oder Auto-Route).
Args:
origin_room_id: Rocket.Chat Raum-ID des Ursprungsraums.
target_room_id: Rocket.Chat Raum-ID des Zielraums.
topic: Thema / Zusammenfassung des verschobenen Beitrags.
room_name: Menschenlesbarer Name des Zielraums (optional).
"""
if not origin_room_id or not target_room_id or not topic:
return
async with self._lock:
# Prüfe ob das Thema schon im Ring existiert (aus Ursprungsraum)
existing = [
e for e in self._entries
if e.room_id == origin_room_id and e.topic == topic.strip()
]
if existing:
# Alte Einträge aus Ursprungsraum für dieses Thema entfernen
self._entries = deque(
(
e for e in self._entries
if not (e.room_id == origin_room_id and e.topic == topic.strip())
),
maxlen=self._max_entries,
)
logger.debug(
"move_gc: Removed %d stale entries from origin room %s (topic: %s)",
len(existing), origin_room_id[:8], topic[:50],
)
# Neuer Ring-Eintrag für Zielraum
entry = CrossRoomEntry(
room_id=target_room_id,
room_name=room_name or target_room_id[:12],
topic=topic.strip(),
)
self._entries.append(entry)
logger.debug(
"move_gc: Added entry for target room %s (topic: %s)",
target_room_id[:8], topic[:50],
)
async def clear(self) -> None:
"""Lösche alle Einträge."""
async with self._lock: