fix: V8.4.6 — FAISS schließt Ursprungsraum aus + Kontext-Keyword bei Catch-Butler (P0-Bundle)

Problem 1 (P0): Kontext-Keywords bei Catch-All-Räumen
- 'dji' ist ein Kontext-Keyword für DM (catch_all=True), aber Catch-All-Räume
  wurden von der Keyword-Match-Logik komplett ausgeschlossen.
- Fix: room_map.py find_room_by_keywords() erlaubt Catch-All-Räume in Stufe 2+3
  (Kontext-Keywords) als Butler-Ziele. Stufe 1 (100%-Keywords) schließt
  Catch-All weiterhin aus — 100%-Match auf Catch-All ist für Auto-Route,
  nicht für Keyword-Match.
- min_score von 2 auf 1 gesenkt: ein einzelnes Kontext-Keyword reicht für
  einen Butler-Vorschlag.

Problem 2 (P0): FAISS schließt Ursprungsraum nicht aus
- FAISS fand den Ursprungsraum als ähnlichsten Raum (score=0.62,
  target=#RC-Plugin, origin=#RC-Plugin). Sinnlos — Butler kann keinen
  Wechsel von #RC-Plugin → #RC-Plugin vorschlagen.
- Fix: router.py filtert origin_room_id aus FAISS-Ergebnissen heraus.
  Wenn alle Treffer der Ursprungsraum waren → fall-through zu LLM.
  Wenn top-1 excluded wird → top-2 wird verwendet.

Tests: 14 neue Tests in test_v8_4_6.py
- test_faiss_excludes_origin (2 Tests)
- test_faiss_butler_self_match (2 Tests)
- test_context_keyword_min_score_1 (3 Tests)
- test_context_keyword_catch_all (3 Tests)
- Regression (4 Tests)

Aktualisierte Tests:
- test_room_map.py: test_context_keywords_min_score → min_score=1
- test_v8_4_5.py: test_sony_context_keyword_triggers_butler → erwartet Butler

Full suite: 626 passed, 2 skipped, 0 failures
This commit is contained in:
Bernd (Hermes)
2026-07-16 10:37:42 +02:00
parent da5586e776
commit 463e29d594
5 changed files with 592 additions and 110 deletions
+10 -12
View File
@@ -253,28 +253,26 @@ class TestSonyContextKeyword:
"""Kontext-Keyword 'sony' im DM-Raum löst Butler aus (nicht STAY)."""
def test_sony_context_keyword_triggers_butler(self):
"""'Sony Vollformat Kamera' matched 'sony' → Butler fragt."""
"""'Sony Vollformat Kamera' matched 'sony' → Butler fragt (V8.4.6)."""
room_map = _make_room_map_with_sony()
router = _make_router(room_map)
# 'sony' is a context keyword for DM mit Andreas (catch-all)
# But catch-all rooms are excluded from keyword matching by design.
# The keyword match should NOT match the catch-all room.
# Instead, the message should fall through to LLM.
# This test verifies the current behavior: catch-all rooms are
# excluded from keyword matching.
# V8.4.6: Catch-All-Räume sind jetzt bei Kontext-Keywords als
# Butler-Ziele erlaubt. 'sony' matched den DM-Raum → Butler fragt.
decision = asyncio.run(router.route(
"Sony Vollformat Kamera",
origin_room_id="room_rc_plugin",
))
# Catch-all rooms are excluded from keyword matching (room_map.py:206)
# So 'sony' in DM keywords_context won't match.
# The message falls through to LLM → STAY (no LLM mock → fallback)
assert decision.stay_in_room is True, (
"Catch-all rooms are excluded from keyword matching — "
"message should fall through to LLM/fallback"
# V8.4.6: 'sony' context keyword matches DM (catch-all) → butler
assert decision.move_request_sent is True, (
f"V8.4.6: context keyword on catch-all should trigger butler, "
f"got move_request_sent={decision.move_request_sent}"
)
assert decision.target_room == "room_dm_andreas", (
f"Expected target_room='room_dm_andreas', got {decision.target_room}"
)
def test_sony_in_non_catchall_room_triggers_match(self):