feat(archivar): Stufe 5 Commit 3 — Red-Flag Auto-Promotion + Learning-by-Use
- F5.2 Learning-by-Use: 5x innerhalb 30 Tagen → Keyword auto-permanent (sicherer Auto-Route-Pfad) - F5.3 Red-Flag-Auto-Promotion: 5x dasselbe Thema→Raum ohne User-'Nein' → permanent - Use-Counter pro (keyword, room)-Paar mit 30d-Decay (bereits in Commit 1) - User-'Nein' resettet Counter (F5.3) - 18 neue Unit-Tests in test_stufe5_feedback_learning.py - Gesamtsuite: 1661 passed, 0 failed (keine Regression Stufe 1-4)
This commit is contained in:
+60
-8
@@ -4221,6 +4221,35 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
# V8.3.1 F4: Vereinheitlicht auf room_name_to_topic(target_name)
|
||||
# statt matched_keywords[0] — konsistent mit current_topic-Berechnung.
|
||||
sticky_topic = room_name_to_topic(target_name) if target_name else ""
|
||||
# ── Stufe 5 F5.2: Learning-by-Use Auto-Promotion ─────────
|
||||
# Sichere Routings (Keyword 100%, FAISS >90%) laufen OHNE
|
||||
# Butler-Rückfrage. Der Use-Counter zählt im Hintergrund.
|
||||
# 5x innerhalb 30 Tagen → Keyword wird automatisch permanent.
|
||||
if _MULTIROOM() and self.archivar is not None and sticky_topic:
|
||||
try:
|
||||
use_count = self.archivar._state._record_routing_use(
|
||||
sticky_topic, target_room_id
|
||||
)
|
||||
if self.archivar._state.check_auto_promotion(
|
||||
sticky_topic, target_room_id
|
||||
):
|
||||
# Auto-Promotion: Keyword permanent lernen.
|
||||
self.archivar._state.record_routing_decision(
|
||||
keyword=sticky_topic,
|
||||
room_id=target_room_id,
|
||||
decision="route",
|
||||
scope="permanent",
|
||||
source="learning_by_use",
|
||||
)
|
||||
logger.info(
|
||||
"[rocketchat] Stufe 5 F5.2: Learning-by-Use "
|
||||
"Auto-Promotion — keyword='%s' room=%s (use_count=%d)",
|
||||
sticky_topic, target_room_id[:8], use_count,
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
"[rocketchat] Stufe 5 F5.2 Learning-by-Use failed: %s", e
|
||||
)
|
||||
# ── V8.3-1: Ankündigung im Ursprungsraum VOR Zielraum-Post ──
|
||||
# V8.3.4 B5: Zufällige Variante aus 5 Formulierungen.
|
||||
target_display = target_name.lstrip('#') if target_name else "Zielraum"
|
||||
@@ -7935,16 +7964,39 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
keyword = room_name_to_topic(target_name)
|
||||
if keyword:
|
||||
# Use-Counter zählen (F5.2/F5.3) — ohne Lernen.
|
||||
self.archivar._state._record_routing_use(
|
||||
use_count = self.archivar._state._record_routing_use(
|
||||
keyword, red_flag_target_room
|
||||
)
|
||||
# Butler-Rückfrage-Kontext für nach dem Senden.
|
||||
pending_learn_ask = {
|
||||
"keyword": keyword,
|
||||
"decision": red_flag_decision,
|
||||
"origin_room_id": red_flag_state.get("origin_room", ""),
|
||||
"target_room_id": red_flag_target_room,
|
||||
}
|
||||
# ── F5.3: Red-Flag-Auto-Promotion ──────────
|
||||
# 5x dasselbe Thema in denselben Raum (ohne
|
||||
# User-'Nein') → automatisch permanent. Der
|
||||
# Counter wird nur bei User-'Nein' resettet.
|
||||
if self.archivar._state.check_auto_promotion(
|
||||
keyword, red_flag_target_room
|
||||
):
|
||||
self.archivar._state.record_routing_decision(
|
||||
keyword=keyword,
|
||||
room_id=red_flag_target_room,
|
||||
decision=red_flag_decision,
|
||||
scope="permanent",
|
||||
source="red_flag",
|
||||
)
|
||||
logger.info(
|
||||
"[rocketchat] Stufe 5 F5.3: Red-Flag "
|
||||
"Auto-Promotion — keyword='%s' room=%s "
|
||||
"(use_count=%d)",
|
||||
keyword, red_flag_target_room[:8], use_count,
|
||||
)
|
||||
# Keine Butler-Rückfrage — bereits permanent.
|
||||
pending_learn_ask = None
|
||||
else:
|
||||
# Butler-Rückfrage-Kontext für nach dem Senden.
|
||||
pending_learn_ask = {
|
||||
"keyword": keyword,
|
||||
"decision": red_flag_decision,
|
||||
"origin_room_id": red_flag_state.get("origin_room", ""),
|
||||
"target_room_id": red_flag_target_room,
|
||||
}
|
||||
logger.info(
|
||||
"[rocketchat] Stufe 5 Red-Flag-Feedback: "
|
||||
"reason=%s decision=%s keyword='%s' room=%s → Butler-Rückfrage",
|
||||
|
||||
Reference in New Issue
Block a user