From 27de24207741e241066b0fa02235d3cc9e293ec0 Mon Sep 17 00:00:00 2001 From: "Bernd (Hermes)" Date: Mon, 13 Jul 2026 23:05:08 +0200 Subject: [PATCH] feat: RoutingCounter + is_auftrag Tests + Routing-Decision Logging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- plugin/adapter.py | 6 ++++++ plugin/archivar/router.py | 1 + 2 files changed, 7 insertions(+) diff --git a/plugin/adapter.py b/plugin/adapter.py index 35acafe..270478a 100644 --- a/plugin/adapter.py +++ b/plugin/adapter.py @@ -1195,6 +1195,8 @@ class RocketChatAdapter(BasePlatformAdapter): # ── CLARIFY Response Handling ─────────────────────────────────── # Handle CLARIFY button responses: CLARIFY:: or CLARIFY::other 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: if "::" in text: # Neues Format: CLARIFY::: (via _build_custom_buttons) @@ -1428,6 +1430,8 @@ class RocketChatAdapter(BasePlatformAdapter): if not is_button_response: logger.debug("[rocketchat] Room %s had pending question — Archivar bypassed", room_id) 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) elif self.archivar._state.should_stay_in_room(room_id) == "always": # Bug 4 fix: Persistierte Entscheidung (always) aus ArchivarState lesen. @@ -1492,6 +1496,8 @@ class RocketChatAdapter(BasePlatformAdapter): with _question_counter_lock: _question_counter += 1 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) # ── User-Flow C: Nachricht kopieren, Antwort IMMER hier ──────── diff --git a/plugin/archivar/router.py b/plugin/archivar/router.py index fc81fa4..0da5407 100644 --- a/plugin/archivar/router.py +++ b/plugin/archivar/router.py @@ -714,6 +714,7 @@ class BidirectionalRouter: FAISS_AUTO_ROUTE, ) 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) ──────────────────── # Nur noch binär: "Smalltalk" vs. "potenzieller Auftrag"