Commit Graph

104 Commits

Author SHA1 Message Date
Bernd (Hermes) 6f47885b1c fix(install.sh): numpy, circular import, room-map.json, archivar symlink in hermes root
FIX 1: numpy/faiss-cpu pip install in venv nach Plugin-Deployment
       in allen drei Pfaden (perform_update, perform_update_only,
       main interactive). Archivar braucht diese Packages für
       FAISS Phase-1 RoomIndex — ohne sie crasht der Import.

FIX 2: Zirkelimport adapter.py ↔ archivar/adapter_integration.py
       gebrochen. _room_context/_room_context_lock werden jetzt
       lazy innerhalb handle_feedback_response() importiert.

FIX 3: Minimale room-map.json (version=1, rooms={}) wird als
       Template bereitgestellt und bei Clean-Install ins
       Datenverzeichnis kopiert. RC-Skill-Onboarding erstellt
       die vollständige, maschinen-spezifische Version.

FIX 4: Archivar-Symlink liegt bereits korrekt im HERMES_DIR
       (Commit 5c8026c). Keine Änderung nötig.
2026-06-22 12:47:50 +02:00
Bernd (Hermes) 4d6fae6bf7 fix(archivar): is_stale()-Check in initialize() — FAISS-Index erkennt Keyword-Updates in room-map.json
P45-Fix: Nach load() wird is_stale() geprüft. Wenn die RoomMap-Version
neuer ist als der gespeicherte Index, wird automatisch rebuild + save
ausgeführt. Verhindert, dass Keyword-Änderungen in room-map.json erst
nach manuellem Löschen der .faiss/.meta-Dateien wirken.
2026-06-21 08:06:17 +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) 2599a574e1 fix(classifier): wrap sync generate() in asyncio.to_thread() — remove broken await on non-coroutine 2026-06-19 19:53:59 +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) 97d59f5272 feat(room_index): weave seed_data messages into FAISS embedding text
Strategie B: _room_to_text() webt kuratierte seed_data-Messages
in den Embedding-Text ein, um FAISS-Similarity zu schärfen.

Änderungen:
- room_index.py: import SEED_DATA, _room_to_text() erweitert
  um Seed-Message-Einwebung (nur für Räume mit SEED_DATA-Eintrag)
- test_room_index.py: MockEmbeddingClient auf Keyword-Zählung
  umgestellt (statt binär any()) — verhindert Cross-Contamination
  durch längere Embedding-Texte mit Seed-Messages

Tests: 35/35 passed (22 booster + 13 room_index)
2026-06-18 07:27:34 +02:00
Bernd (Hermes) 60665c5fd4 feat(archivar): 200-Wort-Raumbeschreibungen für FAISS Phase-1
room-map.json v3:
- Neues 'description'-Feld (~200 Wörter) für alle 4 Nicht-Catch-All-Räume
- BAT-Team: Trading-Plattform, Docker, Next.js, Prisma, Wyckoff
- Rocketchat-Plugin: DDP/WebSocket, Archivar, Gateway, Buttons
- LAN-Dokumentation: Homelab, Proxmox, Subnetze, VLAN, pfSense
- Protonbridge-Plugin: IMAP/SMTP-Proxy, Himalaya, Bridge

room_map.py:
- RoomEntry.description als optionales Feld (default '')
- _from_dict, save, add_or_update_room, Legacy-Migration aktualisiert

room_index.py:
- _room_to_text(): description prioritär, theme als Fallback
- Keywords weiterhin doppelt gewichtet im Embedding-Text

room-map.schema.json:
- description als optional string (minLength 50)
- version minimum auf 3

FAISS-Neubau via is_stale() nach Version-Bump automatisch
2026-06-18 06:31:11 +02:00
Bernd (Hermes) 8d6deb7f2d feat(archivar): RoutingWiderspruchDetector — textbasierte Widerspruch-Erkennung
NEUES MODUL: plugin/archivar/feedback_detector.py
- RoutingWiderspruchDetector mit 4 Regex-Gruppen (Hauptmuster, Umrouting,
  Verneinung, Befehle)
- ContradictionResult dataclass: has_contradiction, contradiction_type,
  confidence, target_room, rejected_room, matched_pattern
- Edge Cases: 'nicht in X, sondern in Y' → X negativ, Y als Ziel
- Kein LLM-Fallback (nur Regex in v1)

EINHAENGUNG adapter_integration.py:
- ArchivarMessageHandler.__init__(): self._feedback_detector
- detect_routing_contradiction(text, origin_room_id) → ContradictionResult|None
- Bei Treffer: update_keyword_weight(feedback_type='never')
- _resolve_room_name_to_id() für Raum-Name → room_id Auflösung

EINHAENGUNG adapter.py:
- _process_incoming(): VOR classify_and_route() → contradiction-Check
- Bei Treffer: Decision überschreiben (stay_in_room=True)
- [WIDERSPRUCH]-Präfix — Nachricht NICHT schlucken, normal an Agent
- NUR wenn KEIN Button-Feedback aktiv (kein pending move-request)

Tests: 57/58 passed (1 pre-existing env-var failure unverändert)
2026-06-18 06:21:24 +02:00
Bernd (Hermes) 3fe2dd832e fix(archivar): correct Coroutine-Bug root cause — _llm_raw_sync→async _llm_raw, direct await
OllamaLLMClient.generate() is async def — run_in_executor cannot
correctly execute async functions. The coroutine was never awaited.

Also fix Move-Request parser: native button '1️⃣ Rüber' was not
matched against '1️⃣' — fell through to 'stay' instead of 'move'.

- classifier.py: _llm_raw_sync → async _llm_raw, await generate()
- router.py: remove run_in_executor, direct await _llm_raw()
- adapter.py: normalize MOVE_REQ choice (extract leading digit/emoji)
2026-06-17 22:01:45 +02:00
Bernd (Hermes) c590b8a53a fix(archivar): replace asyncio.to_thread with run_in_executor in _llm_room_lookup 2026-06-17 20:21:29 +02:00
Bernd (Hermes) ea96ebbde7 fix(archivar): Multi-Request-Resilienz — threading.Lock, asyncio.Semaphore, Catch-All-Schutz + try/except 2026-06-17 07:54:12 +02:00
Bernd (Hermes) 7776e26fb2 FAISS index persistence: load() before build_index(), save() after build
- initialize() now tries load() from disk first
- If load succeeds: log 'Index von Disk geladen' + wire router
- If load fails: build_index() + save() + log 'Index gebaut + gespeichert' + wire router
- Eliminates unnecessary index rebuild on every gateway restart
- All 58 tests pass
2026-06-16 21:07:37 +02:00
Bernd (Hermes) d54c9a8896 fix(archivar): add StreamHandler to adapter_integration logger
setLevel(INFO) alone was not enough — without a handler and with
propagate=True (default), logs were accepted by the root logger
(level WARNING) but silently discarded since root has no handlers.

Now matches adapter.py pattern: StreamHandler + propagate=False,
so all submodule logs (classifier, router, room_index, booster)
are visible via the shared parent logger.
2026-06-16 20:42:01 +02:00
Bernd (Hermes) 0b4ff2169e fix(archivar): set logger level to INFO in adapter_integration.py
Root logger defaults to WARNING (level 30) when no basicConfig is set.
adapter_integration.py only called getLogger(__name__) without setLevel,
so all INFO logs were silently filtered. adapter.py already had its own
setLevel(INFO) + handler, which is why its logs appeared.

Fix: add logger.setLevel(logging.INFO) after getLogger(__name__) at line 94.
This restores all suppressed INFO logs:
- Initializing ArchivarMessageHandler...
- FAISS Phase-1: RoomIndexManager + KeywordBooster ready
- FAISS Phase-1: Index built
- FAISS Phase-1: Router wired
- ArchivarMessageHandler ready
2026-06-16 20:38:50 +02:00
Bernd (Hermes) 03d3bb44df BUGFIX: FAISS Phase-1 TypeError float+str in adapter_integration.py:292
Root cause: RoomIndexManager.stats() returns a dict with mixed types
(bool, int, float, str). sum() iterated over all values and crashed
when hitting built_at_iso (str) after built_at (float).

Fix: Replace stats() call with direct .size and .room_ids properties.
Also commit FAISS Phase-1 files (booster.py, room_index.py, seed_data.py)
that were deployed to Gateway but not yet in repo.

Tests: 58 passed (0 failures)
2026-06-16 20:31:57 +02:00
Bernd (Hermes) 43d14b2d58 fix(archivar): FAISS Phase-1 Integration — RoomIndexManager + KeywordBooster in ArchivarMessageHandler verdrahtet
- __init__: RoomIndexManager(room_map, embedding_client) + KeywordBooster(room_map)
- initialize(): build_index() aus Seed-Daten, Router mit FAISS-Objekten neu erstellen
- Fallback: bei Fehler → None → bestehendes LLM-Verhalten
2026-06-16 19:58:15 +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) 00d6ca4e75 fix(archivar): Hardcodierte Pfade durch ROOM_MAP_PATH/DEFAULT_MAP_PATH ersetzt
check_room_map_completeness() und _load_room_map() verwendeten
hardcodierte Pfade (~/.hermes/hermes-agent/data/room-map.json)
statt der Konstanten ROOM_MAP_PATH/DEFAULT_MAP_PATH.

Das führte dazu, dass Unit-Tests die produktive room-map.json
überschrieben — der Mock-Patch auf ROOM_MAP_PATH griff nicht,
weil save() und reload() den hardcodierten Pfad verwendeten.

Fix:
- adapter_integration.py: 2 hardcodierte Pfade → ROOM_MAP_PATH
- room_map.py: Doppelte DEFAULT_MAP_PATH-Zuweisung entfernt
2026-06-15 20:07:05 +02:00
Bernd (Hermes) 92697b5fff fix(test): ROOM_MAP_PATH-Patch in setUp/tearDown statt Decorator 2026-06-15 20:06:06 +02:00
Bernd (Hermes) 948666fcdd fix(archivar): Timeout-Fallback auf Ursprungsraum + Keyword-Matching vor LLM
Drei Routing-Bug-Fixes basierend auf Analyse des Timeout-Falls vom 15.06.2026:

FIX 1 (KRITISCH): Timeout-Fallback auf Ursprungsraum statt Catch-All
- _llm_room_lookup() gibt jetzt (RoomEntry|None, bool) zurück
- bool=True signalisiert LLM-Aufruf-Fehler (Exception/Timeout)
- Bei LLM-Fehler: stay_in_room=True, is_catch_all=False
- Nur bei explizitem CATCH_ALL vom LLM: catch_all-Raum als Ziel

FIX 2: Keyword-Matching vor LLM-Aufruf (Embedding+Keyword-Fallback)
- Nach Embedding-Vorfilter: wenn work_order mit conf < 0.9
- find_room_by_keywords() aufrufen, bei Match direkt zurückgeben
- Verhindert unnötige LLM-Calls für klare Keyword-Matches

FIX 3: find_room_by_keywords() verbessert
- keywords_100-Matches: nicht erster Treffer, sondern Raum mit
  den MEISTEN 100%-Matches gewinnt (best_100_score)
- keywords_context bleibt Fallback wenn kein 100%-Match existiert

Tests: 57/58 passed (1 pre-existing env-var failure)
2026-06-15 19:43:43 +02:00
Bernd (Hermes) 2eb723fb63 feat(archivar): Auto-Onboarding v2 — strukturiertes 4-Fragen-Interview pro Raum
Ersetzt den v1-Text-Flow ('Name = Thema') durch ein strukturiertes
Interview mit 4 Fragen pro fehlendem Raum:

1. theme — 'Worum geht es in diesem Raum? (1–2 Sätze)'
2. keywords_100 — 'Welche Begriffe treffen SICHER zu? (Sofort-Match)'
3. keywords_context — 'Welche Begriffe deuten auf das Thema hin? (Kontext-Match)'
4. catch_all — 'Soll dieser Raum der Catch-All sein? (Ja/Nein)'

Änderungen:
- adapter.py: _start_onboarding() sendet Buttons pro Raum
  [Projektraum einrichten] [Überspringen] [Später]
- adapter.py: _onboarding_state dict steuert Interview-Phasen
- adapter.py: _process_onboarding_response() verarbeitet Button-Klicks
  (ONBOARD:<room_id>::<action>) und Text-Antworten auf die 4 Fragen
- adapter.py: _ask_onboarding_question(), _onboarding_next_room(),
  _finish_onboarding() für den strukturierten Ablauf
- adapter.py: _process_incoming() erkennt ONBOARD:-Prefix und
  prüft Operator-Raum-Zugehörigkeit
- room_map.py: RoomMap.save() mit fcntl.flock File-Lock gegen
  parallele Schreibzugriffe
- room_map.py: add_or_update_room() akzeptiert keywords_100 und
  keywords_context getrennt (v2-Schema)
- room-map.schema.json: version minimum=2, keywords→keywords_100
  + keywords_context
- room-map.json: generische Platzhalter (öffentliches Repo)
- Tests: 4 neue v2-Tests (keyword-Trennung, File-Lock, reload,
  Single-Room v2-Felder), bestehende Tests auf v2-Schema migriert

Invarianten erhalten: Single-Room-Regel, DM-Ignorierung,
onboarding_active-Flag, kein Dauer-Check.
2026-06-15 19:39:04 +02:00
Bernd (Hermes) 80842a365e fix(archivar): Move-Request-Zielraum an _CURRENT_ORIGIN_ROOM übergeben
ZWEI-PUNKT-FIX (Miguel):

1. adapter_integration.py (Zeile 458-466):
   _send_move_request() übergibt jetzt _move_request-Payload an
   den Button-Send-Callback — mit target_room, target_name, text.

2. adapter.py _send_archivar_buttons (Zeile 978-1004):
   Erkennt den _move_request-Payload, befüllt _pending_move_requests,
   verwendet MOVE_REQ:: Separator für korrektes Button-Parsing.

3. adapter.py Move-Request-Handler (Zeile 739):
   Akzeptiert 'confirm_move' und '✅ja' als Routing-Trigger.

Flow: Archivar v4 → _send_move_request → _send_archivar_buttons
→ _pending_move_requests gesetzt → ✅Ja-Button → Response-Handler
findet pending request → _CURRENT_ORIGIN_ROOM auf Zielraum gesetzt ✓
2026-06-14 16:14:48 +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 f27de836dc chore(archivar): Test an Single-Room-Regel angepasst, room-map.json auf v2 aktualisiert, Model-Check-Architecture-Skizze 2026-06-13 05:55:33 +02:00
Hermes Agent 6b97ccfad9 feat(archivar): Selbstlernendes Keyword-Gewicht-System (Teil 2)
- KeywordWeightEntry + ManualOverride Dataclasses in archivar_state.py
- Lernalgorithmus: confirm (+0.1), stay (-0.05), never (0.0+sticky)
- Promotion: 3 confirmations + weight ≥0.85 → keywords_100
- Degradation + zeitbasierte Abwertung (Decay: 30d -10%, 90d -30%)
- Cold-Start: Bootstrap Tag 1-7 (LR=0.2), Tag 8+ (LR=0.1)
- Gewichtetes Scoring in find_room_by_keywords()
- Feedback-Schleife in adapter_integration.py nach Move-Request-Auflösung
- 54 Tests grün (inkl. 8 neue für gewichtetes Scoring)
2026-06-12 19:57:46 +02:00
Hermes Agent 017dc2b69c feat(archivar): Zweistufiges Keyword-Evidenz-System — 100% + context 2026-06-12 19:30:27 +02:00
Hermes Agent 53dd436a86 feat(archivar): Origin-Priorität im Keyword-Matcher + Architekturskizzen
- room_map.py: find_room_by_keywords() prüft zuerst Ursprungsraum (Origin-First)
- router.py: reicht origin_room_id an Keyword-Matcher durch
- docs/keyword-matcher-origin-priority.md: Architekturskizze (Rainer)
- docs/move-request-button-ux.md: Architekturskizze Button-UX (Rainer)
- docs/keyword-evidence-system.md: Architekturskizze Evidenz-System (Rainer)
2026-06-12 19:25:36 +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 dba856ffab feat(archivar): Implement Button-Garantie und ArchivarState-Integration für Archivar v3 2026-06-11 21:44:38 +02:00
Hermes Agent b11c2c9fe7 feat(archivar): Implement bidirektionales Routing für Archivar v3 2026-06-11 21:42:26 +02:00
Hermes Agent 87f95b818f feat(archivar): Implement Persistenz-Layer (archivar_state.py) für Archivar v3 2026-06-11 21:40:44 +02:00
Hermes Agent 5e8e9c9a9c feat(archivar): Implement Intent-Erkenner und Confidence-Framework für Archivar v3 2026-06-11 21:40:21 +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 b21a8bec19 feat(archivar): zweistufige Keyword-Optimierung mit min_score=2
- find_room_by_keywords() mit min_score Parameter (default=2)
  Nur wenn best_score >= min_score → Raum returned, sonst None
  → Router fällt zu Embedding/LLM-Klassifikator durch
- verhindert Fehlrouting bei einzelnen Keyword-Treffern (plugin, etc.)

Architektur: Rainer | Implementierung: Miguel | QG: Rainer F1-F5 bestanden
2026-06-09 21:13:27 +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 ad852c1642 fix(archivar): doc_store writes to fact_store_path from room_map
DocumentationStore() now uses RoomMap.fact_store_path instead of the
hardcoded ~/.hermes/.../archivar_docs default. One-line change — the
doc_store is initialized after _load_room_map() so room_map is available.

This allows per-deployment configuration: in production, fact_store_path
points to /data/Wissensdatenbank/0100 Inbox so FAKT messages land in the
Obsidian vault's inbox for StartObsidian integration.
2026-06-06 20:32:13 +02:00
Hermes Agent 8591933d8d feat(archivar): auto-onboarding — room-map completeness check after gateway start
Implements the RC-Skill's promised room-map completeness check after
Adapter.connect(). Previously the adapter subscribed to rooms but never
verified they were all present in room-map.json. New rooms were
subscribed but invisible to the Archivar router.

Scope (~450 lines, 4 files):

- adapter_integration.py: check_room_map_completeness() compares
  subscribed rooms (filtered to c/p types) against RoomMap.
  Single-Room-Regel: 1 relevant room → auto catch_all, no interview.
  onboarding_active flag in _stats prevents re-triggering.

- room_map.py: add_or_update_room() for safe in-memory mutations,
  reload() for disk-to-memory sync without gateway restart,
  static save() for atomic file writes.

- adapter.py: connect() calls check after Archivar init, triggers
  _start_onboarding() if rooms missing. _process_incoming() intercepts
  'Raum: #Name = Thema' responses during active onboarding.

- test_auto_onboarding.py: 4 unit tests covering single-room
  auto-assign, multi-room detection, DM filtering, and already-
  complete map (no action).

Deployed to production: adapter.py + archivar/*.py copied to
Auslieferungspfad. Gateway restarted — no onboarding triggered
(map already complete).
2026-06-06 19:31:46 +02:00
Hermes Agent 1afa822e6f Task 5: Neuen test_router.py mit 2 Integrationstests erstellt 2026-06-06 06:14:58 +02:00
Hermes Agent 06567d3988 Task 4: test_room_map.py um 2 LLM-Lookup-Tests erweitert 2026-06-06 06:14:56 +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 9bc06ef858 Task 1: LLM_CONFIDENCE_THRESHOLD-Zweig entfernt und durch einfaches Return des Embedding-Ergebnisses ersetzt 2026-06-06 06:14:45 +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 70008660fc SKILL.md aktualisiert: FAKT→DocStore, Subscription-Validierung, DocumentationStore dokumentiert 2026-06-03 22:38:30 +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 886e566e77 Doc-Store: Messages in nicht abonnierte Räume werden im Filesystem abgelegt
Harte Durchsetzung: Der Archivar darf NUR in Räume routen, die der Bot
tatsächlich abonniert hat. Alles andere ist ein Architekturfehler.

Neu:
- doc_store.py: DocumentationStore — speichert unrouteable Nachrichten
  als Markdown mit YAML-Frontmatter unter data/archivar_docs/{category}/
- router.py: RoutingDecision.is_unrouteable + unrouteable_reason,
  MessageRouter.set_subscribed_room_ids(), Zielraum-Validierung
- adapter_integration.py: ArchivarMessageHandler.set_subscribed_room_ids(),
  classify_and_route() leitet bei is_unrouteable in doc_store um
- adapter.py: set_subscribed_room_ids() wird nach connect() mit den
  realen subscribed rooms gefüttert

Verhalten: Wenn jemand 'ALARM: Server down' in einem Raum schreibt,
den der Bot nicht abonniert hat, wird die Nachricht KLASSIFIZIERT,
aber NICHT geroutet — sie landet im doc_store mit Begründung.
2026-06-03 22:06:30 +02:00