Commit Graph

63 Commits

Author SHA1 Message Date
Bernd (Hermes) c3a66239fd fix: Bug 3 (Onboarding-Buttons), Bug 4 (Move-Request-Sticky), Bug 5 (room-map.json), B9 (Auto-Onboarding)
Bug 3 — Onboarding-Buttons als Text statt interactive:
- adapter.py: Neue Methode _get_build_custom_buttons() mit lokalem Fallback
  der korrekte Rocket.Chat Button-Dicts baut, wenn das rocketchat-Modul
  nicht in sys.modules ist (Race-Condition beim Import)
- _start_onboarding() nutzt jetzt _get_build_custom_buttons() statt
  des Modul-Level-Fallbacks _build_custom_buttons (der [] liefern kann)
- _onboarding_next_room() ebenfalls auf _get_build_custom_buttons() umgestellt
- Operator-DM-Erkennung nicht mehr hardcoded auf 'andreas' — nimmt ersten DM
- Selbsterklärende Onboarding-Nachricht mit Emoji und Kontext

Bug 4 — Move-Request-Schleife, Sticky greift nicht:
- Option 2 (Generell hier): Persistiert jetzt in ArchivarState
  (set_room_state(room_id, 'never_route', username)) — überlebt Neustarts
- Option 3 (Hier bleiben): Stay-Counter — nach 3x Stay in 10 Min
  wird der Raum automatisch auf never_route promoted
- _sticky_rooms (in-memory) bleibt als schneller Cache erhalten

Bug 5 — Falsche room-map.json wird geladen:
- install.sh: Alle 3 room-map.json-Deploy-Stellen prüfen jetzt, ob die
  existierende Datei 0 Räume enthält (leeres Template) → dann neu deployen
- Verhindert dass das leere Template nach Erstinstallation für immer bleibt

B9 — Auto-Onboarding ohne Vorkenntnisse:
- connect(): Trigger prüft jetzt: MULTIROOM_AGENT=true + Räume ohne Map-Eintrag
  + Ausnahme: Nur DM → kein Onboarding
- Zusätzlich: Wenn room-map.json 0 Räume hat → Onboarding für ALLE non-DM-Räume
- _finish_onboarding(): FAISS-Index wird nach Onboarding neu gebaut + gespeichert
- _is_user_operator(): Nicht mehr hardcoded — erster DM-User wird Operator

Syntax-Check: Alle .py (20 Dateien) + install.sh → OK
2026-07-12 12:11:26 +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) 8760d29036 fix(adapter): Antwort-Routing — _CURRENT_ORIGIN_ROOM hat Vorrang vor Archivar-Target 2026-06-23 06:16:43 +02:00
Bernd (Hermes) bc7b05d768 fix(adapter): _MULTIROOM from module-level constant to runtime function 2026-06-22 13:26:38 +02:00
Bernd (Hermes) 572bc89205 fix(adapter): move same-room check before _THEMATIC_TARGET_ROOM.set() 2026-06-22 12:05:20 +02:00
Bernd (Hermes) 54de0d1b69 fix(adapter): prevent move-request when target room equals origin room 2026-06-22 11:59:11 +02:00
Bernd (Hermes) 52dd470e00 debug: add Archivar trace logging to identify classify_and_route blocker 2026-06-22 10:32:12 +02:00
Bernd (Hermes) a442e42b4e feat: MULTIROOM_AGENT env switch for single-room mode 2026-06-22 10:12:07 +02:00
Bernd (Hermes) ba2ba33616 fix(adapter): _room_context + _room_context_lock vor Archivar-Import definieren
Zirkulärer Import: adapter.py → adapter_integration.py → adapter.py.
_room_context und _room_context_lock fehlten komplett in adapter.py,
adapter_integration.py versuchte sie zu importieren → ImportError.

Fix: _room_context (Dict) + _room_context_lock (threading.Lock) VOR
dem ArchivarMessageHandler-Import definieren. Behebt P17-Altlast
(ContextVar→global dict war nie ins Repo zurückportiert).

Deployment-Pfad braucht zusätzlich relative Imports (.archivar.),
weil Gateway Plugins als flache Module lädt (Pattern D4).
2026-06-20 16:39:36 +02:00
Bernd (Hermes) 658f1ba8a0 fix(adapter): exponential backoff retry for 429 rate-limit on chat.postMessage 2026-06-19 23:12:48 +02:00
Bernd (Hermes) ac1751e9ce debug(adapter): enable DEBUG logging + DDP health check for 24h stability test 2026-06-19 19:31:00 +02:00
Bernd (Hermes) 34087299e8 fix(adapter): remove last 2 relative imports — use top-level sys.modules access 2026-06-19 17:44:04 +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) 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) 27b117e151 fix(adapter): BUTTON_CLICK lost-context fallback — retry as TEXT after gateway restart 2026-06-17 21:38:22 +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) a3875f5fbf fix: Silent Copy setzt _CURRENT_ORIGIN_ROOM auf Zielraum statt Ursprungsraum
Bei Auto-Route Silent Copy (Typ 1, kein Move-Request) wurde die
Notiz im Ursprungsraum gesendet, aber _CURRENT_ORIGIN_ROOM blieb auf
dem Ursprungsraum — der Agent antwortete dann fälschlich dort.

Fix: Nach der Silent Copy _CURRENT_ORIGIN_ROOM auf decision.target_room
setzen und forwarded=True, damit der Fallback in Zeile 927-928
übersprungen wird. Der Agent antwortet jetzt im Zielraum.
2026-06-16 21:28:07 +02:00
Bernd (Hermes) 1f7054eab8 fix(adapter): CLARIFY-Exklusion in Button-Detection — False-Positive BUTTON_CLICK bei CLARIFY-Antworten 2026-06-16 05:18:49 +02:00
Bernd (Hermes) a1fc4cc9b5 fix(onboarding): globale Button-Actions skip_all/later erkennen 2026-06-15 20:32:18 +02:00
Bernd (Hermes) aa50857193 fix(ux): Onboarding-Buttons — blaue Nummern statt Text-Labels (12→6 Buttons)
Pro Raum: EIN blauer Nummern-Button (1️⃣, 2️⃣, …) via style='primary'
Globale Buttons: ⏭️ Alle überspringen, ⏰ Später
Payload: ONBOARD:<rid>::select, ONBOARD::skip_all, ONBOARD::later

UX-Fix: Rocket.Chat UI hat feste Button-Breite — 12 Buttons
(4 Räume × 3 Aktionen) wurden auf 1 Buchstabe gekürzt.
6 Buttons (4 Nummern + 2 global) passen ohne Truncation.
2026-06-15 20:24:23 +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) 6e02a12431 fix(archivar): Kontext-Reset — _THEMATIC_TARGET_ROOM pro Nachricht zurücksetzen
Bug: DM ohne Routing nach einem Projektraum-Turn → alte
_THEMATIC_TARGET_ROOM klebt → Antwort im falschen Raum.

Fix: _THEMATIC_TARGET_ROOM.set('') zu Beginn jeder neuen Nachricht
in _process_incoming(). Der Archivar setzt sie dann neu — oder sie
bleibt leer (DM, Smalltalk, Catch-All).

Erkannt 20:21 durch Andreas: Tagesabschluss-Anfrage im DM,
Antwort landete in #Rocketchat-Plugin (vorheriger Turn).
2026-06-14 20:30:31 +02:00
Bernd (Hermes) b05b1ab1ec feat(archivar): Vierter Baustein — Agent-Antwortziel via Archivar-Kontext
Option C (Adapter routet Antwort automatisch um):
Priority 0 im Virtual→Real Room Translation: Wenn _THEMATIC_TARGET_ROOM
gesetzt ist und vom Ursprungsraum abweicht, geht die Antwort dorthin.

Null Core-Impact, +8 Zeilen in adapter.py, kein Prompt-Cache-Break.
Der Agent antwortet wie bisher — der Adapter lenkt um.

Flow: Agent sendet Antwort → Adapter prüft _THEMATIC_TARGET_ROOM →
gesetzt? → Zielraum. Sonst → _CURRENT_ORIGIN_ROOM (wie bisher).
2026-06-14 19:41:19 +02:00
Bernd (Hermes) 1f7d09a7fd fix(archivar): Timeout-Fallback zeigt Raumliste für Agent-Autonomie
Wenn der Archivar-LLM-Call timed out, erhält der Agent jetzt die
Liste aller subscribed Projekt-Räume im Prompt:
  [Frage N, Timeout — Räume: #BAT-Team, #Rocketchat-Plugin, ...]

Damit kann der Agent selbstständig entscheiden, in welchen Raum
eine Frage gehört — auch ohne Archivar-Ergebnis. Erfüllt die
Auftraggeber-Vision: 'Antwortet der Archivar nach dem Timeout
nicht, entscheidet der Agent selbst, auch wenn es Token kostet.'
2026-06-14 19:26:58 +02:00
Bernd (Hermes) c6b82cc33c fix: remove duplicate global _question_counter in TimeoutError handler 2026-06-14 18:35:56 +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
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 2b53537638 fix(adapter): stay_in_room vom Router respektieren
Bug: Der Router setzte stay_in_room=True (excluded_rooms, Meta-Fragen,
Keyword-Match auf Ursprungsraum), aber der Adapter ignorierte das Flag.
Er prüfte nur target_room != room_id → routete trotzdem.

Symptom: 'Die RC Beschreibung klingt toll' aus #Rocketchat-Plugin
löste Move-Request aus, obwohl:
- excluded_rooms → stay_in_room=True
- 'RC' matcht keywords_100 'rc' → Ziel = Ursprungsraum

Fix: Eine Zeile in der Routing-Bedingung:
  and not getattr(decision, 'stay_in_room', False)

Jetzt respektiert der Adapter, wenn der Router sagt 'bleib hier'.
2026-06-12 20:43:45 +02:00
Hermes Agent 7e6e9fb15d fix(adapter): Move-Request Button-UX — erklärender Text vor Buttons 2026-06-12 17:52:37 +02:00
Hermes Agent 6348578678 fix(adapter): Move-Request auf native Action-Buttons umgestellt
- Move-Request sendet jetzt native RC Buttons (✅Ja, 📍Hier, 📌Generell)
  statt nummerierter Textoptionen — Button-Garantie eingehalten
- Response-Handler erkennt MOVE_REQ:room_id::choice Payloads
- Fallback auf Textoptionen bei Button-Send-Fehler
- Altes numerisches Format (1/2/3) weiterhin unterstützt
2026-06-12 07:29:26 +02:00
Hermes Agent a261c771fc fix(archivar): wire button_send_callback — Archivar now sends native RC buttons
ArchivarMessageHandler was initialized without button_send_callback,
so every clarification request fell back to text-only ('Antworte mit
einer Zahl: 1 = Ja...'). Added _send_archivar_buttons() method that
translates Archivar button format into native Rocket.Chat Action-Buttons
with msg_in_chat_window=True. Also marks room in _rooms_with_pending_questions
so the response stays in the same room.
2026-06-12 07:24:57 +02:00
Hermes Agent 43ef3e6a91 fix(adapter): Button-Detection False-Positive — :: in Text matched Normalsprache
'::' in text (Zeile 571) klassifizierte JEDE Nachricht mit :: als
BUTTON_CLICK — z.B. Andreas' ':: Ich brauche den Wetterbericht'.
Der Agent sah die Nachricht nie → keine Antwort trotz grünem Status.

Fix: text.split('::', 1)[0].strip() != '' — erkennt nur echte
Button-Payloads (wo vor :: tatsächlich Inhalt steht wie CLARIFY:id).
':: Nachricht' → split[0] ist leer → kein Button → MessageType.TEXT.

Root Cause: Ein 3-Zeilen-ODER-Detector, der drei Payload-Formate
in einer Variable vermischt. Fragil weil Substring-Match.
2026-06-09 21:56:46 +02:00
Hermes Agent e7e6b66ba2 fix(adapter): CLARIFY-Trennzeichen-Bug — :: vs : zwischen clarify_id und choice
_build_custom_buttons() sendet Payloads mit :: (Doppel-Doppelpunkt),
aber _process_incoming() splittete mit text.split(':', 2) → choice=':1'
→ ':1'.isdigit()=False → Clarify nie resolved → Gateway Timeout.

Fix: Zweistufiger Split — erst '::' prüfen (neues Format),
dann ':' als Fallback (Other-Button). Beide Formate werden erkannt:
- CLARIFY:id::1 (numerischer Button)
- CLARIFY:id:other (Other-Button)

Architektur: Rainer | Implementierung: Miguel | QG: Rainer F1-F5 bestanden
2026-06-09 21:32:07 +02:00
Hermes Agent 2fe574cf71 feat(rc-adapter): native clarify buttons via REST attachments
Render clarify prompts with Rocket.Chat action buttons instead of
fallback text lists ('Reply with the number'). Full flow:

send_clarify():
- choices non-empty: builds RC buttons via _build_custom_buttons(),
  one per choice + '✏️ Other' button
- clarify_id encoded as CLARIFY:{id}:{idx} or CLARIFY:{id}:other
- stores clarify_id→session_key in _clarify_state
- fallback to super().send_clarify() on empty choices or REST failure

_process_incoming():
- intercepts DDP messages starting with 'CLARIFY:'
- 'other' token → mark_awaiting_text() for text capture
- numeric token → resolve_gateway_clarify() with choice text
- returns immediately (no agent routing) for button clicks

__init__:
- adds self._clarify_state dict for session key mapping
2026-06-09 20:55:18 +02:00
Hermes Agent 09c327b5a1 fix(archivar): integrate '::' into bypass branch, not Archivar call
The uncommitted diff from 06.06. had a bug: '::' (button response
marker) was placed in the wrong elif branch, routing it through the
Archivar instead of bypassing it.

Fixed: '::' detection moved into the top-level bypass condition alongside
is_button_response and _rooms_with_pending_questions. The dead
'elif room_type == d and is_auftrag' guard removed (redundant — DM
orders never reach this branch). Last elif promoted to else.
2026-06-09 16:13:14 +02:00
Hermes Agent 0f8dc06f15 fix(archivar): echte Rocket.Chat Action-Buttons statt numerischer Optionen
Der Adapter kann schon lange Buttons (send() parst [[BUTTONS:custom]] seit
Monaten). Move-Requests nutzten trotzdem nur numerische Text-Optionen.

Jetzt: _build_custom_buttons() direkt im Move-Request-Flow. Rocket.Chat
Action-Buttons [Ja, rüberkopieren] [Hier bleiben] [Generell hier bleiben]
— klickbar, keine Zahlen, kein Kontext-Verlust.
2026-06-08 19:06:35 +02:00
Hermes Agent ffb7cafff6 fix(archivar): Move-Request NICHT returnen — Originaltext an Agent durchreichen
Kritischer Bug: Nach 'Hier bleiben'/'Generell hier bleiben' wurde return
aufgerufen → der Original-Auftragstext ging verloren, nur '3' erreichte
den Agenten → Agent antwortete verwirrt.

Jetzt: Originaltext aus move_req['text'] wiederherstellen, skip_archivar=True
setzen, als normale Nachricht durchreichen. Der Agent verarbeitet den Auftrag
normal weiter — der User hat nur das Routing entschieden.
2026-06-08 16:05:55 +02:00
Hermes Agent 62c996c4da fix(archivar): Move-Request vor Archivar, room-basiert, numerische Antworten
Drei kritische Bugs behoben:
1. Move-Request-Prüfung VOR Archivar-Klassifikation — '3' wurde vorher als
   thematische Frage ins Catch-All kopiert, jetzt wird die Antwort erkannt
2. _pending_move_requests von msg_id auf room_id umgestellt — jede Antwort
   mit neuer msg_id schlug vorher fehl
3. Numerische Antworten (1/2/3) werden jetzt direkt erkannt, nicht nur
   Text-Matches ('rüberkopieren'/'hier bleiben'/'generell')
2026-06-08 15:53:51 +02:00
Hermes Agent f47ffc93f4 fix(archivar): Raum-Name-Fallback + nummerierte Optionen statt Buttons
- Bug 1: 'Zielraum' als Platzhalter → jetzt 3-Stufen-Fallback (matched_room_name → room_info → room_map → ID-Fragment)
- Bug 2: Native Buttons existieren nicht im Adapter → nummerierte Text-Optionen (1/2/3)
2026-06-08 14:32:31 +02:00
Hermes Agent e7ed81c189 fix: send() method structure — restore button-parsing + REST-post code that fell out of method body
The send() method in adapter.py had a structural defect where the
button-parsing, template-handling, and rest.post_message code (98 lines)
was at module level instead of inside the send() method body.

send() ended after room-resolution without a return statement, causing
it to return None. _send_with_retry() in base.py then crashed with
AttributeError: 'NoneType' object has no attribute 'success'.

This made every Rocket.Chat response silently fail — the agent
processed messages but could never deliver replies.

Fix: moved the orphaned code block back into the send() method body
where it belongs, after the room-resolution logic and before
_find_fallback_room_for_user.
2026-06-08 11:33:59 +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 af56280ebc fix(archivar): User-Flow C — Antwort bleibt im Ursprungsraum, Nachricht wird kopiert
DM-Aufträge werden nie geroutet. Bei thematischen Fragen: Silent Copy.
Bei Aufträgen: Buttons [Ja, rüberkopieren] [Hier bleiben] [Generell hier bleiben].

Architektur-Skizze: docs/archivar-user-flow-c.md
2026-06-08 06:44:40 +02:00
Hermes Agent 5e9c4ece77 fix(adapter): button clicks bypass Archivar routing
Button responses (`is_button_response`) are ALWAYS direct replies to an agent
question and carry a `question_id::choice` payload. Routing them through the
Archivar risked landing a one-character "A" in the catch-all room where the
agent would see it without the original question context.

Now button clicks skip `classify_and_route()` entirely and stay in whatever
room they originated from.
2026-06-06 20:43:36 +02:00
Hermes Agent 7140da3154 feat(onboarding): catch-all change via numeric answer, generic example
- Trigger now catches 'Name = Thema', '#Name', 'Raum:', digits, skip words
- After onboarding: numbered room list with Catch-All marker
- User can change Catch-All by replying with room number
- 'überspringen'/'skip' keeps current Catch-All
- Example text is generic (not project-specific): 'Projektraum = Entwicklung, ...'
2026-06-06 20:03:04 +02:00
Hermes Agent 72e8c8cb90 fix(onboarding): generic example, numbered rooms, catch-all change prompt
- Example text: 'Projektraum = Entwicklung, Code-Reviews, ...' (not project-specific)
- Onboarding prompt: numbered list (1. Raum, 2. Raum, ...)
- After completion: shows all rooms with Catch-All marker, asks if change wanted
2026-06-06 20:01:02 +02:00
Hermes Agent ddc69167c1 fix(onboarding): remove # from display to prevent RC link rendering
- Onboarding message shows room names WITHOUT # (RC auto-links them)
- Parser accepts both 'Name' and '#Name' (case-insensitive match)
- Pattern: #? makes hash optional, matching against lstrip(#)
2026-06-06 19:58:31 +02:00
Hermes Agent 7d454f62b6 fix(onboarding): parse #Name = Thema format, auto-derive keywords, fix newlines
- Parser accepts '#Name = Thema' (no 'Raum:' prefix needed)
- _derive_keywords() extracts keywords from room name + theme
- Onboarding message uses real newlines (join list, not \n literals)
- Shows actual missing room names with '=' prompt, plus example
2026-06-06 19:51:34 +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 4d35669174 fix: prevent room-map.json overwrite + is_unrouteable handler
ROOT CAUSE: install.sh --update-only blindly deployed room-map.json
from the repo (containing 'GENERAL' as catch_all) to the production
/home/bernd/.hermes/data/ directory, overwriting the machine-specific map.

FIXES (3 changes):

1. REMOVED room-map.json from repo + added to .gitignore
   This file is machine-specific data, not source code.

2. REMOVED room-map.json deploy from install.sh (both paths):
   - Normal install block (section 3.5)
   - --update-only emergency deploy (section 3.5)
   Replaced with comment: 'MACHINE-SPECIFIC — created by RC-Skill onboarding'

3. FIX adapter.py: is_unrouteable guard on ContextVar routing
   Before: ContextVar set to target_room even when unrouteable
   Result: 'Ich antworte im Zielraum.' note appeared, but Hermes
   couldn't deliver to unsubscribed room — answer lost silently.
   After: Forward block checks not getattr(decision, 'is_unrouteable', False)
   If unrouteable → stays in origin room, answers there normally.

PRODUCTION: Correct room-map.json deployed with 4 project rooms
+ DM catch_all on .101. Excluded rooms: multi-agent DM, testbot DM.
2026-06-06 18:53:11 +02:00