P0-1: install.sh schreibt ARCHIVAR_ENABLE_LLM=true in rocketchat.env bei MULTIROOM=true
P0-2: Dead-Code adapter.py:1359-1435 entfernt (Silent-Copy-Pfad im v6-Flow unerreichbar)
P0-3: should_stay_in_room() gibt jetzt 'origin_first'/'sticky'/None statt True/False/None
P1-1: Reconnect-Onboarding prüft jetzt auf neue Räume statt immer zu skippen
P1-2: _set_catch_all() baut FAISS-Index nach Catch-All-Wechsel neu
P1-3: stay_tracker in ArchivarState persistiert (archivar_state.json)
P1-4: onboarding_state in ArchivarState persistiert (archivar_state.json)
P1: Document M13→B9 ordering guarantee in _sync_room_map_with_membership docstring
P2: Clean up self._subscribed_rooms and self._room_info for removed rooms in M13 GC
P3: Add DDPClient.unsubscribe() and call it for each removed room in M13 GC
Bug 7: Replace reconnect_and_restore() calls with _reconnect_ddp() that runs
REST get_rooms() + M13 GC before subscribing, preventing ghost re-subscriptions
after kick. reconnect_and_restore() kept as deprecated wrapper.
Erweitert _sync_room_map_with_membership() um die von Andreas geforderten
Bereinigungsschritte nach room-map.json-GC:
1. FAISS-Index: rebuild + save (war bereits in M13, jetzt robuster)
2. KeywordBooster: cleanup_orphaned_rooms() — baut _keyword_to_rooms
Mapping aus bereinigter RoomMap neu
3. ArchivarState: cleanup_orphaned_rooms() — entfernt stay_decision,
keyword_weights, sticky_keywords, manual_overrides, promotion_candidates
für gelöschte Räume
4. Onboarding _stay_tracker: entfernt Einträge für gelöschte Räume
Reihenfolge im Gateway-Start (adapter.py connect()):
DDP connect → _sync_room_map_with_membership() → DDP subscribe →
Archivar init → Auto-Onboarding
Alle neuen Methoden sind idempotent und mit Tests abgedeckt:
- test_archivar_state.py: +8 Tests (cleanup_orphaned_rooms)
- test_booster.py: +4 Tests (cleanup_orphaned_rooms)
- Gleiche Sortierreihenfolge in beiden Funktionen: (not is_catch, name)
- _get_onboarding_room_list liefert jetzt 3-Tupel (rid, name, is_current)
statt 2-Tupel — '(aktuell)'-Marker kann nun auch in der Auswahlliste
angezeigt werden (is_current=True für den Operator-DM)
- Tote insert(0,...)-Aufrufe in beiden Funktionen durch append + Kommentar
'wird nachfolgend einsortiert' ersetzt
- Caller (catch_all_change-Phase) auf 3-Tupel-Unpacking angepasst
_finish_onboarding: DM-Raum aus _room_info wird immer in die
Catch-All-Auswahlliste aufgenommen (auch wenn nicht in room_map).
DM bekommt '(aktuell)'-Marker statt '(Catch-All)'.
_get_onboarding_room_list: Gleiche Logik — DM immer inkludiert,
mit echtem Namen statt 'Catch-All (legacy)'.
catch_all_change-Phase: DM-Auswahl ist no-op (bleibt Catch-All),
andere Raum-Auswahl setzt _set_catch_all() wie bisher.
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
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).
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)
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)
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.
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).
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).
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.'
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'.
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.
'::' 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.
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
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.
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.
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.
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')
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.