Commit Graph

20 Commits

Author SHA1 Message Date
Bernd (Hermes) 8853a1d9e3 fix: V8.1 Routing-Engine — 7 Root Causes (Auto-Route, Sticky, Echo, Kontext-Ring, LLM-URL, FAISS, Buttons)
P1: 100%-Keyword-Route sendet Antwort in Zielraum (echtes Routing)
    - adapter.py:1603-1645: Auto-Route-Block vor _CURRENT_ORIGIN_ROOM
    - Bei move_request_sent=False + target_room != room_id → dispatch in Zielraum
    - Nachricht wird in Zielraum kopiert, Agent antwortet dort

P2: Temporäres Sticky (30 Min) bei confirm_move
    - adapter.py:625: _session_room_preferences Dict
    - adapter.py:1414-1428: Sticky bei confirm_move gesetzt
    - adapter.py:1557-1597: Session-Sticky-Check vor Archivar (Auto-Route)
    - adapter.py:1638-1645: Sticky auch bei Auto-Route gesetzt

P3: Echtes Move (Original löschen) statt Copy+Breadcrumb
    - adapter.py:1414-1420: Kein Copy mehr bei confirm_move
    - Nur Breadcrumb "Wir sind rübergewechselt → #Zielraum" im Ursprungsraum

P4: MultiRoomContext-Ring — raum-übergreifender Konversations-Kontext
    - Neu: archivar/multiroom_context.py (Ring-Buffer, 10 Einträge)
    - adapter.py:1293-1299: Ring-Update bei jeder User-Nachricht
    - adapter.py:1752-1767: Ring-Summary in System-Prompt injiziert

P5: LLM-Router URL — ARCHIVAR_LLM_BASE_URL statt OLLAMA_BASE_URL
    - config.py:150-153: Neue Env-Var ARCHIVAR_LLM_BASE_URL
    - OLLAMA_BASE_URL als Legacy-Fallback

P6: FAISS is_stale() — Member-Set-Check zusätzlich zu Version
    - room_index.py:540-590: Prüft set(map_rooms) == set(index_rooms)
    - Bei Mismatch → rebuild mit Logging

P7: Move-Request-Template auf 3 Buttons
    - config.py:209-215: 1️⃣ Rüber, 2️⃣ Generell hier, 3️⃣ Nur diesmal
    - stay_once fällt in else-Branch (adapter.py:1447)

Verifikation: 345/346 archivar tests passed (1 pre-existing env fail)
2026-07-14 19:31:55 +02:00
Bernd (Hermes) 8b67e03f7e feat(v6): Phase 1 — Origin-First Guard + LLM Fix + Proaktiver Broadcast
P3: LLM_CONFIG base_url jetzt aus OLLAMA_BASE_URL Env-Var (config.py:150)
I1: LLM_ROOM_PROMPT umgeschrieben — STAY/ROUTE statt CATCH_ALL,
    Ursprungsraum-Kontext, Few-Shot-Beispiele, Catch-All nicht als Option
    (config.py:175-195, router.py:_llm_room_lookup)
P2: Origin-First Guard (Schritt -0.5) in router.py:route():
    - origin_room_id leer (echte DM) → normaler Flow
    - origin_room ist Catch-All → stay_in_room
    - origin_room ist excluded → ignore
    - LLM sagt STAY → stay_in_room
    - LLM == origin_room → stay_in_room
    - LLM == catch_all_room → stay_in_room (kein DM-Routing!)
    - LLM == anderer Raum → Move-Request (Butler-Prinzip)
Catch-All-Schutz: DM-Nachrichten skippen Routing-Flow (router.py:270-282)
Move-Request-Routing-Fix (adapter.py):
    - 1️⃣ Rüberkopieren → _CURRENT_ORIGIN_ROOM = Zielraum
    - 2️⃣ Generell hier bleiben → Sticky-Eintrag
    - 3️⃣ Hier bleiben → nur diesmal, kein Sticky
    - Button-Labels aktualisiert: 1️⃣ Rüber / 2️⃣ Generell / 3️⃣ Hier
B6: Proaktiver Raum-Broadcast (tools.py):
    - Neues Tool rocketchat_broadcast mit 5-Min-Cooldown
    - Format: menschenähnlich, kein Bot-Ton
    - Registriert in _TOOLS mit 📢 Emoji
2026-07-09 17:33:14 +02:00
Bernd (Hermes) 1ad9155a24 fix(config): use ARCHIVAR_EMBEDDING_BASE_URL for embeddings — separate from OLLAMA_BASE_URL (chat) 2026-06-19 21:08:36 +02:00
Bernd (Hermes) 4596ffba2a perf(config): increase LLM timeout 10s→30s — iterative binary search optimization 2026-06-19 21:06:11 +02:00
Bernd (Hermes) 0e13e4b30d fix(archivar): ContextVar→global dict, asyncio.to_thread, EMBEDDING_BASE_URL, FAISS_AUTO_ROUTE=0.55
- adapter.py: ContextVars durch globales _room_context dict + threading.Lock ersetzt
  (Agent-Task sieht jetzt Archivar-Zielraum — kein error-not-allowed mehr)
- adapter_integration.py: Stay-Feedback-Handler leert thematic_target
  (verhindert dass nächster Send auf alten Archivar-Vorschlag fällt)
- classifier.py: _llm_raw() nutzt asyncio.to_thread() statt direktem await
  (LLMClient.generate() ist synchron — vorher TypeError)
- config.py: ARCHIVAR_EMBEDDING_BASE_URL trennt Embeddings von Chat-URL
  (OLLAMA_BASE_URL-Kollision behoben). FAISS_AUTO_ROUTE 0.70→0.55
  (mehr Nachrichten durch Booster statt direktem FAISS-Routing)
2026-06-19 09:09:17 +02:00
Bernd (Hermes) d005eb769d feat(archivar): Booster-Gewichtung verstärkt — FAISS + Keywords
Booster-Strategie: IMMER aktiv (nicht nur bei Konflikten)
- router.py: Konfliktbedingung entfernt, Booster auf alle FAISS-Treffer
- booster.py: Boost +0.05→+0.10, zusätzlich +0.05 pro weiterem unique Keyword
- config.py: FAISS_AUTO_ROUTE 0.85→0.70

Kombiniert semantische Breite (FAISS) mit präziser Keyword-Diskriminierung.
Ziel: granulare Raum-Entscheidungen bei überlappenden Themen.
2026-06-18 07:55:14 +02:00
Bernd (Hermes) 134c21a218 feat(archivar): FAISS Phase-1 Router-Integration
config.py:
- FAISS_AUTO_ROUTE (0.85): Direkt-Routing-Schwelle ohne LLM
- FAISS_MIN_SCORE (0.50): Minimaler Treffer-Score
- FAISS_TOP_K (3): Top-Treffer aus dem Index
- FAISS_CONFLICT_DIFF (0.05): Booster-Aktivierungsschwelle

router.py:
- RoutingDecision: 5 neue FAISS-Felder (faiss_score, faiss_room_id,
  faiss_room_name, is_faiss_routed, booster_applied)
- BidirectionalRouter.__init__: optionale room_index + booster Parameter
  (None = Phase-1 übersprungen, bestehendes Verhalten)
- route(): Schritt 3.5 FAISS Phase-1 zwischen Keyword-Match und
  Embedding-Vorfilter eingefügt
  - search_text() → Booster bei knappen Top-2 → Auto-Route bei >= 0.85
  - Score < 0.85 → Fall-through zu Embedding + LLM (unverändert)
- Drei-Schichten-Logik: FAISS → Keyword-Booster → LLM
- Bestehender LLM/Embedding-Code unverändert
2026-06-16 19:18:36 +02:00
Bernd (Hermes) 186308c983 fix(archivar): Timeouts auf 10s erhöht — empirisch ermittelt (Ø 2.4s, Cold-Start 7.8s) 2026-06-14 15:47:28 +02:00
Bernd (Hermes) 170f7e6096 feat(archivar): LLM-basierter Raum-Router ersetzt IntentClassifier — Embedding-Vorfilter + LLM_ROOM_PROMPT + Move-Request-Buttons
Korrigierter Archivar-Routing-Flow gemäß Architekturskizze:

1. Embedding-Vorfilter (nomic-embed-text): binär Smalltalk vs. potenzieller Auftrag
   - Klarer Smalltalk → stay_in_room
   - Unsicher → LLM-Raum-Router

2. LLM-Raum-Router (qwen2.5:7b): LLM_ROOM_PROMPT als zentraler Prompt
   - Erhält Nachrichtentext + Raumliste mit IDs und ALLEN Keywords
   - Liefert room_id direkt (keine Kategorien, kein Name-Matching)

3. Move-Request-Buttons (Butler-Prinzip): ✅Ja/📍Hier VOR Routing
   - Kein automatisches Routing ohne User-Bestätigung

4. Betriebsstufen-Log: 'Archivar Stufe 1: Embedding-Vorfilter + LLM-Raum-Router aktiv (5 Räume)'

Änderungen:
- config.py: LLM_ROOM_PROMPT auf Raum-ID-Ausgabe umgestellt, Keywords pro Raum,
  ARCHIVAR_STUFE_LOG, MOVE_REQUEST_TEMPLATE, max_tokens=30
- classifier.py: LLMClient.generate() als neue ABC-Methode + OllamaLLMClient-Impl,
  _llm_raw_sync nutzt generate() statt classify()
- router.py: RoutingDecision um move_request_sent/target_name/target_id erweitert,
  route() komplett neu: Embedding→LLM→Move-Request, _llm_room_lookup() mit IDs+Keywords
- adapter_integration.py: _send_move_request() + handle_move_request_response(),
  classify_and_route() behandelt move_request_sent, handle_and_forward() wartet auf Bestätigung

IntentClassifier.classify() wird NICHT gelöscht — nur als binärer Vorfilter verwendet.
Bestehende Tests: 53/54 grün (1 pre-existing env-var issue).
2026-06-14 10:25:33 +02:00
Hermes Agent 4bb1ccbc82 feat(archivar): Lernsystem-Verdrahtung — Move-Request + Clarify lernen Keyword-Gewichte
- RoutingDecision um matched_keywords-Feld erweitert (router.py)
- _extract_routing_keywords-Stub entfernt, Keywords aus Decision durchreichen (adapter_integration.py)
- _routed_messages nach classify_and_route() befüllen (adapter.py)
- move_req-Dict um message_id erweitert (adapter.py)
- Move-Request-Handler: handle_feedback_response mit confirm/stay/never aufrufen (adapter.py)
- handle_clarification_response: update_keyword_weight für ambige Keywords lernen (adapter_integration.py)
- Clarify-Frage-Text: "Ich möchte mir das für die Zukunft richtig merken..." (config.py)

Feedback-Mapping: 1️⃣ Rüber=confirm, 2️⃣ Hier=stay, 3️⃣ Nein=never, 📝/💬=stay, 📋=confirm
2026-06-13 09:50:54 +02:00
Hermes Agent c23127c9c5 fix(archivar): sync __init__.py barrel imports + test_router.py to v3 class names
- __init__.py: MessageClassifier→IntentClassifier, MessageRouter→BidirectionalRouter, CONFIDENCE_THRESHOLD→CONFIDENCE_THRESHOLDS, added ROOM_MAP_PATH, ARCHIVAR_STATE_PATH, ArchivarState
- config.py: added missing ROOM_MAP_PATH constant (imported by router.py)
- test_router.py: updated imports + BidirectionalRouter(state=ArchivarState()) constructor

Root cause: Miguel's v3 refactoring renamed classes but didn't update the barrel file. Gateway failed with 'No adapter available for rocketchat' because archivar/__init__.py imported non-existent names.
2026-06-11 22:25:35 +02:00
Hermes Agent 92bdb396a9 feat(archivar): Update config.py für Archivar v3 - Neue CATEGORY_TEXTS, Intent-Typen und Konfiguration 2026-06-11 21:39:21 +02:00
Hermes Agent 83a5d262c7 fix: User-Map-Fallback + LLM-Prompt-Fix
- User-Map: Fallback aus DM-Namen-Parsing + REST-API-Abfrage wenn usernames-Feld fehlt (Rainer)
- LLM: max_tokens 10→5, Prompt verschärft auf Ein-Wort-Antwort (Raum-Name oder CATCH_ALL)
- Keine Erklärungen, keine Sätze — der Validator akzeptiert jetzt alle Antworten
- Vault-Doku: Rocket.Chat Plugin.md aktualisiert (User-Flow C, Bugfixes)
2026-06-08 07:40:04 +02:00
Hermes Agent 54a19a039d Task 3: Deprecated marker für LLM_CLASSIFY_PROMPT in config.py hinzugefügt 2026-06-06 06:14:52 +02:00
Hermes Agent 58f00c0c23 feat(archivar): Phase 1-3 — RoomMap + thematischer Router
Phase 1 (Datenmodell):
- plugin/archivar/room_map.py: RoomMap, RoomEntry, RoomMapValidationError
- room-map.schema.json: JSON-Schema für room-map.json
- room-map.json: Echte Raum-IDs (RC, BAT, LAN-Doku, DM Andreas)
- config.py: LLM_ROOM_PROMPT, ROOM_MAP_PATH, deprecated-Marker

Phase 2 (Router-Umbau):
- router.py: MessageRouter nutzt RoomMap statt ROOM_MAPPING Env-Vars
  - Neue Methode _llm_room_lookup() fragt LLM: 'In welchen Raum?'
  - Keyword-Match aus RoomEntry.keywords (vor Embedding)
  - Excluded rooms check via RoomMap.is_excluded()
  - origin_room_id Parameter für Multi-Agent-Raum-Ausschluss

Phase 3 (Integration):
- adapter_integration.py: _load_room_map() mit Env-Var-Fallback
  - validate() beim Gateway-Start
  - classify_and_route() reicht origin_room_id durch
- classifier.py: _llm_raw_sync() für Room-Prompts (nicht Kategorien)

12/12 Unit-Tests bestanden ✅
2026-06-05 22:06:32 +02:00
Hermes Agent e5a32abf5c feat(archivar): dreistufiger Klassifikator — Keyword + Embedding + LLM (qwen2.5:7b)
Phase 3 (Miguel): 236 Zeilen in config.py, classifier.py, adapter_integration.py.
Phase 4 (Rainer): Quality Gate F1–F5 bestanden.

- Stufe 0: Keyword-Vorfilter mit erweiterten ALARM/FRAGE-Listen
- Stufe 1: Embedding (nomic-embed-text, Schwelle 0.70)
- Stufe 2: LLM-Klassifikation (qwen2.5:7b) für Grenzfälle
- Feature-Flag ARCHIVAR_ENABLE_LLM über Env-Variable
- LLMClient-Interface für Testbarkeit
- router.py unverändert (Blackbox-Integration)
2026-06-04 21:49:17 +02:00
Hermes Agent ccce90fdb0 FAKT ist Dokumentation, keine Kommunikation — nie in Chat-Räume routen
Vier harte Änderungen:
1. config.py: ARCHIVAR_FAKT_ROOM existiert nicht mehr. FAKT wird
   niemals in ROOM_MAPPING aufgenommen — Env-Variable obsolet.
2. router.py: FAKT-Entscheidungen werden VOR der Subscription-
   Validierung als is_unrouteable markiert. Kein if/else, kein
   Ermessensspielraum.
3. adapter_integration.py: classify_and_route() legt FAKT automatisch
   im DocumentationStore ab (existiert bereits).
4. Env-Variable ARCHIVAR_FAKT_ROOM aus systemd env.conf entfernt.

Resultat: Nur FRAGE und ALARM werden jemals in Chat-Räume geroutet.
FAKT-Nachrichten wie 'CPU-Last bei 92%' sind reine Dokumentation —
sie landen als Markdown unter data/archivar_docs/fakt/
2026-06-03 22:11:25 +02:00
Hermes Agent 1c7b82e27f feat: Archivar-Universalisierung A–E — env-vars, SKILL.md, Pipeline-Integration, file-download
A: config.py auf Env-Vars umgestellt (ARCHIVAR_FAKT_ROOM, _FRAGE_ROOM, _ALARM_ROOM, _CATCHALL_ROOM, _PROJECT_ROOMS)
B: adapter.py-Kommentare von BAT-Terminologie auf generisch umgeschrieben
C: archivar/SKILL.md — Hermes-Skill-Schema mit Triggern, Architektur, Konfiguration, Pitfalls
D: classify_and_route() + send_callback in _process_incoming() integriert, chat_name mit [KATEGORIE] angereichert
E: RocketChatREST.download_file() — authentifizierter Datei-Download via X-Auth-Token, kein Security-Scanner-Trigger mehr
    _download_and_inline_files() inlined [FILE]-Inhalte direkt in den Prompt
2026-06-03 20:14:40 +02:00
Hermes Agent bb8623aed5 fix: binary corruption in adapter.py + absolute→relative imports in archivar/
- adapter.py: recopied from production (write_file corrupted the em-dash on line 8)
- All archivar/*.py: from archivar.X → from .X for plugin-context compatibility
2026-06-03 10:17:03 +02:00
Hermes Agent 88b7149dd1 feat: Archivar delivery + install.sh v2.2 — full function set
- Add archivar/ submodule to plugin/ (5 files, relative imports)
- Update adapter.py with relative Archivar import from .archivar.adapter_integration
- install.sh: fix --non-interactive env-var reading (Z.316-318, Bug #7)
- install.sh: recursive file copy (was 4 flat files, now entire plugin/ tree incl. submodules)
- install.sh: Ollama presence check + nomic-embed-text pull
- install.sh: write OLLAMA_BASE_URL to rocketchat.env
- install.sh: add new message keys (collama_check, nomic_pull, nomic_ok, nomic_fail, copied)

Closes: Archivar delivery gap (2026-06-03)
Reviewed-by: Bernd (Advisor)
2026-06-03 10:12:47 +02:00