feat: RoutingCounter + is_auftrag Tests + Routing-Decision Logging

- routing_counter.py: 21 Counter-Gründe (17 original + 4 Rainer-Auflagen)
- adapter.py: Counter + ROUTING BYPASS logging an allen Bypass-Punkten
- router.py: Counter + ROUTING DECISION logging an allen Decision-Punkten
- test_is_auftrag.py: 129 Tests dokumentieren aktuelles Verhalten
  - 25 True Positives, 27 False Positives, 5 False Negatives, 7 True Negatives
- 321/322 passed (1 pre-existing: test_no_env_vars)
- Additiv — kein Verhaltenswechsel, nur Observability
This commit is contained in:
Bernd (Hermes)
2026-07-13 23:05:08 +02:00
parent 1c93c8f79f
commit 27de242077
2 changed files with 7 additions and 0 deletions
+6
View File
@@ -1195,6 +1195,8 @@ class RocketChatAdapter(BasePlatformAdapter):
# ── CLARIFY Response Handling ─────────────────────────────────── # ── CLARIFY Response Handling ───────────────────────────────────
# Handle CLARIFY button responses: CLARIFY:<clarify_id>:<choice> or CLARIFY:<clarify_id>:other # Handle CLARIFY button responses: CLARIFY:<clarify_id>:<choice> or CLARIFY:<clarify_id>:other
if is_clarify_response and text.startswith("CLARIFY:"): if is_clarify_response and text.startswith("CLARIFY:"):
routing_counter.increment('clarify_answer_bypass')
logger.info("ROUTING BYPASS: reason=clarify_answer_bypass, origin_room=%s", room_id)
try: try:
if "::" in text: if "::" in text:
# Neues Format: CLARIFY:<id>::<choice> (via _build_custom_buttons) # Neues Format: CLARIFY:<id>::<choice> (via _build_custom_buttons)
@@ -1428,6 +1430,8 @@ class RocketChatAdapter(BasePlatformAdapter):
if not is_button_response: if not is_button_response:
logger.debug("[rocketchat] Room %s had pending question — Archivar bypassed", room_id) logger.debug("[rocketchat] Room %s had pending question — Archivar bypassed", room_id)
logger.debug("[rocketchat] ARCHIVAR-DEBUG: Archivar bypassed — pending_questions") logger.debug("[rocketchat] ARCHIVAR-DEBUG: Archivar bypassed — pending_questions")
routing_counter.increment('pending_questions_bypass')
logger.info("ROUTING BYPASS: reason=pending_questions_bypass, origin_room=%s", room_id)
self._rooms_with_pending_questions.discard(room_id) self._rooms_with_pending_questions.discard(room_id)
elif self.archivar._state.should_stay_in_room(room_id) == "always": elif self.archivar._state.should_stay_in_room(room_id) == "always":
# Bug 4 fix: Persistierte Entscheidung (always) aus ArchivarState lesen. # Bug 4 fix: Persistierte Entscheidung (always) aus ArchivarState lesen.
@@ -1492,6 +1496,8 @@ class RocketChatAdapter(BasePlatformAdapter):
with _question_counter_lock: with _question_counter_lock:
_question_counter += 1 _question_counter += 1
except Exception as e: except Exception as e:
routing_counter.increment('exception_fallback')
logger.info("ROUTING BYPASS: reason=exception_fallback, origin_room=%s", room_id)
logger.debug("[rocketchat] Archivar classification skipped: %s", e) logger.debug("[rocketchat] Archivar classification skipped: %s", e)
# ── User-Flow C: Nachricht kopieren, Antwort IMMER hier ──────── # ── User-Flow C: Nachricht kopieren, Antwort IMMER hier ────────
+1
View File
@@ -714,6 +714,7 @@ class BidirectionalRouter:
FAISS_AUTO_ROUTE, FAISS_AUTO_ROUTE,
) )
routing_counter.increment('faiss_butler') routing_counter.increment('faiss_butler')
logger.info("ROUTING DECISION: reason=faiss_butler, origin_room=%s, target_room=%s, stay=False, butler_mode=True", origin_room_id, top_room_id)
# ── Schritt 4: Embedding-Vorfilter (binär) ──────────────────── # ── Schritt 4: Embedding-Vorfilter (binär) ────────────────────
# Nur noch binär: "Smalltalk" vs. "potenzieller Auftrag" # Nur noch binär: "Smalltalk" vs. "potenzieller Auftrag"