feat: V8.3.3 — Routing-Telemetrie (Konfidenz-Logging) + Echte Integration-Tests
FEATURE 1: Routing-Telemetrie (Konfidenz-Logging) - Neue Datei: archivar/routing_telemetry.py — RoutingTelemetry Klasse - Feature-Flag: ARCHIVAR_ROUTING_TELEMETRY env var (Default true) - Pro Routing-Entscheidung: stage, score, decision, target, origin, duration_ms - Format: [TELEMETRY] stage=keyword_100 score=1.00 decision=route ... - NIEMALS Nachrichteninhalte im Log (Datenschutz) - Telemetrie-Punkte in router.py an allen 5 Stufen: keyword_100, context_keyword, faiss, llm, default - Flush in adapter.py nach classify_and_route() FEATURE 2: Echte Integration-Tests - Neue Datei: archivar/tests/test_v8_3_3.py (18 Tests) - Echte RoutingDecision-Objekte statt Dict-Simulationen - 7 Integration-Test-Klassen: 1. 100%-Keyword im falschen Raum → route 2. 100%-Keyword im richtigen Raum → stay (self-match) 3. Kontext-Keyword → butler 4. FAISS hohe Ähnlichkeit → route 5. FAISS mittlere Ähnlichkeit → butler 6. LLM → STAY 7. LLM → ROUTE - Telemetrie-Tests: Logging, Datenschutz, Feature-Flag - Erweiterte conftest.py: multi_room_map, Mock-LLM Fixtures Verifikation: 527 passed, 1 pre-existing fail, 2 skipped (FAISS)
This commit is contained in:
@@ -4,6 +4,9 @@ V8.2.1: pytest-Fixtures für saubere Pfad-Tests.
|
||||
Statt nested patches in jedem Test wird der room-map.json Pfad
|
||||
pro Test umgebogen. Verwendet tempfile.TemporaryDirectory für
|
||||
Isolation.
|
||||
|
||||
V8.3.3: Erweiterte Fixtures für echte Integration-Tests mit
|
||||
RoomMap, FAISS-Index und Mock-LLM.
|
||||
"""
|
||||
|
||||
import json
|
||||
@@ -62,3 +65,130 @@ def temp_state_path():
|
||||
state_path = str(Path(tmp.name) / "archivar_state.json")
|
||||
yield state_path
|
||||
tmp.cleanup()
|
||||
|
||||
|
||||
# ── V8.3.3: Erweiterte Fixtures für echte Integration-Tests ──────────────
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def multi_room_map_path():
|
||||
"""Erzeugt eine temporäre room-map.json mit 4 Räumen + Catch-All.
|
||||
|
||||
Räume:
|
||||
- #RC-Plugin (keywords_100: plugin, rocketchat; context: adapter, gateway)
|
||||
- #LAN-Doku (keywords_100: dokumentation, doku; context: netzwerk, lan)
|
||||
- #BAT-Team (keywords_100: bat, team; context: support, hilfe)
|
||||
- #DevOps (keywords_100: devops, deployment; context: ci, cd, pipeline)
|
||||
- #CatchAll (catch_all)
|
||||
|
||||
Returns:
|
||||
Path: Pfad zur temporären room-map.json.
|
||||
"""
|
||||
tmp = tempfile.TemporaryDirectory()
|
||||
map_path = Path(tmp.name) / "room-map.json"
|
||||
|
||||
test_data = {
|
||||
"version": 5,
|
||||
"rooms": {
|
||||
"room_rc_plugin": {
|
||||
"name": "#RC-Plugin",
|
||||
"theme": "Rocket.Chat Plugin Entwicklung und Wartung",
|
||||
"description": "Entwicklung des Hermes Rocket.Chat Plugins",
|
||||
"keywords_100": ["plugin", "rocketchat"],
|
||||
"keywords_context": ["adapter", "gateway"],
|
||||
"catch_all": False,
|
||||
},
|
||||
"room_lan_doku": {
|
||||
"name": "#LAN-Doku",
|
||||
"theme": "LAN Dokumentation und Netzwerk",
|
||||
"description": "Dokumentation des LAN-Netzwerks",
|
||||
"keywords_100": ["dokumentation", "doku"],
|
||||
"keywords_context": ["netzwerk", "lan"],
|
||||
"catch_all": False,
|
||||
},
|
||||
"room_bat_team": {
|
||||
"name": "#BAT-Team",
|
||||
"theme": "BAT Team Koordination",
|
||||
"description": "Koordination des BAT-Teams",
|
||||
"keywords_100": ["bat", "team"],
|
||||
"keywords_context": ["support", "hilfe"],
|
||||
"catch_all": False,
|
||||
},
|
||||
"room_devops": {
|
||||
"name": "#DevOps",
|
||||
"theme": "DevOps und Deployment",
|
||||
"description": "CI/CD und Deployment-Infrastruktur",
|
||||
"keywords_100": ["devops", "deployment"],
|
||||
"keywords_context": ["ci", "cd", "pipeline"],
|
||||
"catch_all": False,
|
||||
},
|
||||
"room_catchall": {
|
||||
"name": "#CatchAll",
|
||||
"theme": "Catch-all room",
|
||||
"keywords_100": [],
|
||||
"keywords_context": [],
|
||||
"catch_all": True,
|
||||
},
|
||||
},
|
||||
"excluded_rooms": [],
|
||||
"butler_mode": "cognitive",
|
||||
"fact_store_path": str(Path(tmp.name) / "docs"),
|
||||
}
|
||||
with open(map_path, "w") as f:
|
||||
json.dump(test_data, f)
|
||||
|
||||
yield map_path
|
||||
tmp.cleanup()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def multi_room_map(multi_room_map_path):
|
||||
"""Lädt eine echte RoomMap aus multi_room_map_path.
|
||||
|
||||
Returns:
|
||||
RoomMap: Geladene RoomMap mit 4 Räumen + Catch-All.
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[3]))
|
||||
|
||||
from plugin.archivar.room_map import RoomMap
|
||||
|
||||
return RoomMap.load(path=Path(str(multi_room_map_path)))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_llm_stay():
|
||||
"""Mock-LLM das immer STAY zurückgibt.
|
||||
|
||||
Returns:
|
||||
callable: Async-Funktion die (None, False, False) zurückgibt (STAY).
|
||||
"""
|
||||
async def _mock_llm(prompt: str):
|
||||
return "STAY" # STAY
|
||||
return _mock_llm
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_llm_route():
|
||||
"""Mock-LLM das immer ROUTE zu room_rc_plugin zurückgibt.
|
||||
|
||||
Returns:
|
||||
callable: Async-Funktion die (RoomEntry, False, False) zurückgibt.
|
||||
"""
|
||||
async def _mock_llm(prompt: str):
|
||||
return "room_rc_plugin" # ROUTE to #RC-Plugin
|
||||
return _mock_llm
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_llm_failed():
|
||||
"""Mock-LLM das immer fehlschlägt (None zurückgibt).
|
||||
|
||||
Returns:
|
||||
callable: Async-Funktion die (None, False, True) zurückgibt (FAILED).
|
||||
"""
|
||||
async def _mock_llm(prompt: str):
|
||||
return None # FAILED
|
||||
return _mock_llm
|
||||
|
||||
Reference in New Issue
Block a user