Compare commits
20 Commits
83b9d6c347
...
39fee34d89
| Author | SHA1 | Date | |
|---|---|---|---|
| 39fee34d89 | |||
| c8f54d0cef | |||
| 78b9a15cbd | |||
| 90c122cc74 | |||
| 0a05816b68 | |||
| 9db62bf94a | |||
| 324e7cd491 | |||
| 3ef57653c9 | |||
| ad84f665bc | |||
| bfd9cad899 | |||
| 81a17921e9 | |||
| fac0a79644 | |||
| 56baaaf038 | |||
| acd92f81cb | |||
| 2a92267bf4 | |||
| e0bf428799 | |||
| dcd014291e | |||
| 9e214a423c | |||
| 07ba653b65 | |||
| 0bfa791d79 |
@@ -0,0 +1,526 @@
|
||||
# RC-Plugin Funktionsbereichs-Zerlegung
|
||||
|
||||
Repo: /home/bernd/projekte/Hermes_rocket.chat_Plugin
|
||||
HEAD: 83b9d6c ("fix(plugin.yaml): name rocketchat-platform → rocketchat (Pitfall 4)")
|
||||
Analyse: Rainer (Architektur-Reviewer)
|
||||
Datum: 2026-07-24
|
||||
Zweck: Systematische Aufteilung des RC-Plugins in unabhängig prüfbare Funktionsbereiche, gegen die jeweils das Zielbild (Vorgaben, Designentscheidungen, Restriktionen) referenziert werden kann.
|
||||
|
||||
================================================================
|
||||
METRIKEN-BASIS
|
||||
================================================================
|
||||
- adapter.py: 6921 LOC (Gateway, DDP, REST, Dispatch, Onboarding-Wiring)
|
||||
- install.sh: 1611 LOC (Deployment, Verifikation, 11 Pitfalls dokumentiert)
|
||||
- archivar/ gesamt: ~15.000 LOC, 24 Module
|
||||
- Tests: ~70 Dateien, davon 16 v8_4_x (Vektor-Routing) + 8 v8_3_x (P0-Round) + 9 v8_2/8_3 + onboarding/room_map/router/presence/...
|
||||
- Plugin-Dateien (Top-Level): adapter.py, tools.py, plugin.yaml
|
||||
- Konfiguration: templates/config.yaml + room-map.json + .env (RUNTIME)
|
||||
|
||||
================================================================
|
||||
ZERLEGUNGSKRITERIEN
|
||||
================================================================
|
||||
1. Kohärenz: Ein Bereich hat EINE Hauptverantwortung. Module mit gemeinsamer
|
||||
Verantwortung (z.B. DDP-Layer, Routing-Decision) werden zusammengefasst.
|
||||
2. Unabhängige Prüfbarkeit: Jeder Bereich hat definierte Eingaben (Triggers),
|
||||
Ausgaben (Effekte) und kann gegen eine Teilmenge der Vorgaben geprüft werden,
|
||||
ohne andere Bereiche zu laden.
|
||||
3. Vollständigkeit: Adapter-Lifecycle, Persistenz, Deployment und Konfiguration
|
||||
sind explizite Bereiche — nicht "alles andere".
|
||||
|
||||
================================================================
|
||||
FUNKTIONSBEREICHE (sortiert nach Onboarding → Verarbeitung → Output → Persistenz → Infrastruktur)
|
||||
================================================================
|
||||
|
||||
────────────────────────────────────────────────────────────────────
|
||||
FB-01 Onboarding & Review ✅ BEREITS REVIEWED
|
||||
────────────────────────────────────────────────────────────────────
|
||||
Verantwortung:
|
||||
Steuerung des Erstgesprächs mit neuen Nutzern/Räumen: Greeting-Flow,
|
||||
Interview-State-Machine, Review-Subphasen, Lock-Mechanismus, Fact-Store-Pfad.
|
||||
Endet in persistierter room-map.json.
|
||||
|
||||
Hauptdateien:
|
||||
- plugin/archivar/onboarding.py (492 LOC — Greeting, Lazy-Check, Lock)
|
||||
- plugin/archivar/onboarding_state.py (592 LOC — StateMachine, OnboardingData)
|
||||
- plugin/archivar/onboarding_review.py (1146 LOC — Review-Subphasen-Dispatcher)
|
||||
- plugin/adapter.py (_send_onboarding_message, _complete_onboarding)
|
||||
- room-map.json / _persist_room_map_changes (Output)
|
||||
|
||||
Schlüsselfeatures:
|
||||
- F-OB1 Lazy Onboarding (check_room_map_completeness_delta)
|
||||
- F-OB2 Onboarding-Greeting-Flow (build_greeting_message, run_onboarding_greeting_flow)
|
||||
- F-OB3 State-Machine (GREETING → AWAITING_NAME → ... → COMPLETE)
|
||||
- F-OB4 Review-Subphasen (Room-Step, Edit, Keywords-Edit, Theme-Edit, Catch-All-Toggle, Remove, Add-New)
|
||||
- F-OB5 Fact-Store-Pfad-Validierung
|
||||
- F-OB6 Onboarding-Lock (acquire/release/cleanup_stale)
|
||||
|
||||
Bekannte Probleme:
|
||||
- F6 R18 P1: adapter.py Z.4270-4271/5815-5816 rufen self._presence_engine.x OHNE
|
||||
hasattr/None-Guard — bei Init-Exception (Z.822-827) wirft Onboarding AttributeError
|
||||
(widerspricht R-4 Graceful Degradation).
|
||||
- Onboarding-Test-Lock-Datei-Problematik in CI (siehe test_onboarding_lock).
|
||||
- Verteilung: 1146 LOC in onboarding_review.py → Refactoring-Kandidat
|
||||
(render_review_room_* sehr ähnlich, Template-Pattern).
|
||||
|
||||
Review-Status: ARCHITEKTUR-REVIEW ABGESCHLOSSEN (Onboarding-Teil).
|
||||
Vorgaben geprüft: State-Machine-Korrektheit ✅, Review-Buttons-Korrektheit ✅,
|
||||
Fact-Store-Pfad ✅. Noch offen: Interaction mit FB-04 (Keyword-Lernen) und
|
||||
FB-09 (Error-Recovery).
|
||||
|
||||
────────────────────────────────────────────────────────────────────
|
||||
FB-02 DDP-Client & Verbindungs-Lifecycle ⏳ ANSTEHEND
|
||||
────────────────────────────────────────────────────────────────────
|
||||
Verantwortung:
|
||||
Aufbau, Aufrechterhaltung und Wiederherstellung der WebSocket-Verbindung zum
|
||||
Rocket.Chat-Server via DDP-Protokoll. Login, Subscription, Reader-Loop,
|
||||
Future-Store für await-Semantik, Reconnect-Logik.
|
||||
|
||||
Hauptdateien:
|
||||
- plugin/adapter.py Z.274-889 (DDPTimeout, DDPServerError, DDPNotConnected, DDPClient)
|
||||
- plugin/adapter.py Z.292+ (class DDPClient, _recv_loop, Future-Store, result-Handler)
|
||||
|
||||
Schlüsselfeatures:
|
||||
- F-DDP1 Login (auth-Tokens, self.user-Extraktion aus Login-Response — P0-Fix f61b0ba)
|
||||
- F-DDP2 Subscribe (stream-room-messages, notify-on-room)
|
||||
- F-DDP3 Reader-Loop (Blocking, Thread-Trennung, Heartbeat)
|
||||
- F-DDP4 Future-Store + result-Handler (async-await via run_coroutine_threadsafe, P1-2-O2)
|
||||
- F-DDP5 Reconnect-Backoff
|
||||
- F-DDP6 Own-Message-Filter (P0-Fix f61b0ba: self.user aus DDP, nicht Env)
|
||||
|
||||
Bekannte Probleme:
|
||||
- F19 R19 P0-1 (archiviert, aber referenced): PulseController in presence_engine
|
||||
erstellt self._pulse_controller/_detection_timer NIE → 348 Zeilen Dead-Code.
|
||||
NICHT in diesem Bereich, aber DDP-Layer muss fehlende Pulse-Calls
|
||||
kompensieren (DDP set_status als kostenloser Fallback).
|
||||
- Eigene DDP-Reader-Thread vs. asyncio.loop-Thread: Synchronisation
|
||||
prüfen (run_coroutine_threadsafe-Pfad).
|
||||
|
||||
────────────────────────────────────────────────────────────────────
|
||||
FB-03 REST-Client & API-Wrapper ⏳ ANSTEHEND
|
||||
────────────────────────────────────────────────────────────────────
|
||||
Verantwortung:
|
||||
Kapselt die Rocket.Chat-REST-API für Out-of-Band-Operationen:
|
||||
Posten von Nachrichten, Senden von Buttons, Datei-Upload/Download,
|
||||
Room-Info-Lookup. Trennt synchronen HTTP-Pfad von asynchronem DDP-Pfad.
|
||||
|
||||
Hauptdateien:
|
||||
- plugin/adapter.py Z.138-273 (class RocketChatREST)
|
||||
- plugin/adapter.py Z.31-38 (RocketChatRateLimitError)
|
||||
- plugin/adapter.py Z.40-130 (Helper: _MULTIROOM, _get_config_str)
|
||||
|
||||
Schlüsselfeatures:
|
||||
- F-REST1 Message-POST (chat.postMessage)
|
||||
- F-REST2 Button-Attachments (send mit attachments-Array)
|
||||
- F-REST3 Rate-Limit-Handling
|
||||
- F-REST4 Datei-Upload (rooms.upload)
|
||||
- F-REST5 Datei-Download (für Inlining)
|
||||
- F-REST6 Room-Info-Lookup (rooms.info, users.info)
|
||||
|
||||
Bekannte Probleme:
|
||||
- Trennung REST/DDP-Nachrichten: Race-Conditions möglich wenn REST-Post
|
||||
und DDP-Event dieselbe Nachricht betreffen (z.B. Echo-Filter).
|
||||
- Token-Refresh: Wenn auth_token abläuft, kein automatischer Re-Login
|
||||
im REST-Pfad (nur DDP reconnectet).
|
||||
|
||||
────────────────────────────────────────────────────────────────────
|
||||
FB-04 Archivar-Routing & Klassifikation ⏳ ANSTEHEND
|
||||
────────────────────────────────────────────────────────────────────
|
||||
Verantwortung:
|
||||
Kernlogik: Eingehende Nachricht → Klassifikation (FAKT/FRAGE/ALARM/etc.)
|
||||
→ Routing-Decision → Ziel-Raum. Hybrid aus Keyword-Matcher (Stufe 0),
|
||||
Sentence-Marker-Erkennung, FAISS-Vektor-Routing (Stufe 1) und
|
||||
LLM-Fallback (Stufe 2).
|
||||
|
||||
Hauptdateien:
|
||||
- plugin/archivar/router.py (2261 LOC — BidirectionalRouter)
|
||||
- plugin/archivar/classifier.py (716 LOC — IntentClassifier, EmbeddingClient, LLMClient)
|
||||
- plugin/archivar/keyword_matcher.py (481 LOC — Stemmer, Levenshtein, Word-Boundary)
|
||||
- plugin/archivar/sentence_markers.py (307 LOC — MarkerClass, detect_sentence_marker)
|
||||
- plugin/archivar/booster.py (277 LOC — KeywordBooster)
|
||||
- plugin/archivar/multiroom_context.py (205 LOC — Cross-Room-Entry, MultiRoomContextRing)
|
||||
- plugin/archivar/feedback_detector.py (232 LOC — RoutingWiderspruchDetector)
|
||||
- plugin/archivar/archivar_state.py (1173 LOC — RoomState, ArchivarState)
|
||||
|
||||
Schlüsselfeatures:
|
||||
- F-RT1 BidirectionalRouter (RoutingDecision, Red-Flag-Erkennung)
|
||||
- F-RT2 2-Stufen-Klassifikator (Keyword → FAISS → LLM)
|
||||
- F-RT3 Sentence-Marker-Pattern (FRAGE/ALARM/FAKT/...)
|
||||
- F-RT4 KeywordBooster (Hybrid mit FAISS)
|
||||
- F-RT5 Cross-Room-Context-Ring
|
||||
- F-RT6 Routing-Konflikt-Detektor (Widerspruchs-Erkennung)
|
||||
- F-RT7 Recursive Routing (v7_4)
|
||||
- F-RT8 Sticky Sessions (test_sticky_session)
|
||||
- F-RT9 V8.4 FAISS-Routing-Tests (8 Test-Dateien: v8_4_2 ... v8_4_6)
|
||||
|
||||
Bekannte Probleme:
|
||||
- 2261 LOC in router.py — höchste Komplexität im Plugin. Refactoring-Druck.
|
||||
- FAISS-Performance bei wachsendem Index (siehe faiss_performance_test*.py im Root).
|
||||
- Hybrid-Booster mit FAISS: User-Präferenz aus Memory dokumentiert
|
||||
("Hybridansatz mit KeywordBooster"), aber Integration-Drift-Risiko
|
||||
(R18-Anm.: _update_dst dupliziert deploy_plugin-Logik).
|
||||
- Sentence-Marker-Validierung: validate_sentence_marker ist async und
|
||||
wird aus synchronem Routing-Pfad aufgerufen — Race-Risk.
|
||||
|
||||
────────────────────────────────────────────────────────────────────
|
||||
FB-05 Presence-Engine & Status-Pulse ⏳ ANSTEHEND (KRITISCH)
|
||||
────────────────────────────────────────────────────────────────────
|
||||
Verantwortung:
|
||||
Visuelle Präsenz des Butlers: "online"/"away"-Status, Pulse-Intervall,
|
||||
Detection-Timer (Gateway-Heartbeat-Erkennung). P0-Status: Implementierung
|
||||
hat dokumentierte Lücken aus F19 R19 Review.
|
||||
|
||||
Hauptdateien:
|
||||
- plugin/archivar/presence_engine.py (1119 LOC — PresenceEngine, PulseController, DetectionTimer)
|
||||
- plugin/adapter.py (DDP set_status, on_agent_busy, on_message_received)
|
||||
|
||||
Schlüsselfeatures:
|
||||
- F-PR1 PresenceEngine (idle/active/dnd-Modi)
|
||||
- F-PR2 PulseController (Async-Pulse via run_coroutine_threadsafe)
|
||||
- F-PR3 DetectionTimer (pgrep-Heuristik, gateway_state-Signal)
|
||||
- F-PR4 ROCKETCHAT_PRESENCE_PULSE_INTERVAL (5-30s Clamp)
|
||||
- F-PR5 Honeymoon-Timer (b40b221: Status busy minimum 1s sichtbar)
|
||||
- F-PR6 Status-Farben (d964d7d: grün/gelb/rot, Flughafen-Prinzip)
|
||||
|
||||
Bekannte Probleme (F19 R19 dokumentiert, CHANGES NEEDED):
|
||||
- P0-1 ARCHITEKTUR-BRUCH: presence_engine erstellt _pulse_controller/
|
||||
_detection_timer NIE, adapter instanziiert sie auch nicht → 348 Z.
|
||||
Dead-Code, alle hasattr-Guards (presence_engine Z.476/488, adapter
|
||||
Z.871-876) No-Ops.
|
||||
- P0-2 PulseController.cancel_pending() = pass (Z.604-613) — EC-5
|
||||
NICHT implementiert.
|
||||
- P1-1 on_agent_busy/on_message_received (Z.479/491) in adapter.py
|
||||
0 Aufrufer.
|
||||
- P1-2 K3: ::setstatus on/off ruft enable/disable, nicht PulseController.
|
||||
- P1-3 ROCKETCHAT_PRESENCE_PULSE_INTERVAL geht an PresenceEngine
|
||||
(clamp 5-30s), PulseController-Default 1.5s.
|
||||
- P1-4 DetectionTimer pgrep 'len > 1' — 0 Prozesse = False, kein
|
||||
Heuristik-Unterschied.
|
||||
- P1-5 heartbeat_pulse/detection ungelockt.
|
||||
- P1-6 _pulse_loop Pause-Check nur in Sleep (0.1s Latenz).
|
||||
- P2-1 pgrep 6/min unkritisch.
|
||||
- P2-2 REST-Fallback auth_token+user_id ungebunden.
|
||||
|
||||
Review-Status: REVIEW CHANGES NEEDED — keine Freigabe möglich bis P0-1, P0-2,
|
||||
P1-2 behoben sind. DDP set_status (adapter Z.544-549) ist kostenloser
|
||||
Workaround bis dahin.
|
||||
|
||||
────────────────────────────────────────────────────────────────────
|
||||
FB-06 Inline-Commands (::-Präfix) ⏳ ANSTEHEND
|
||||
────────────────────────────────────────────────────────────────────
|
||||
Verantwortung:
|
||||
Verarbeitung von `::hilfe`, `::status`, `::multiroom`, etc. — direkte
|
||||
Nutzer-Befehle, die vor dem Routing abgefangen werden.
|
||||
|
||||
Hauptdateien:
|
||||
- plugin/archivar/inline_commands.py (431 LOC — InlineCommandRegistry, parse_inline_command)
|
||||
- plugin/archivar/adapter_integration.py (1270 LOC — Routing-Integration)
|
||||
|
||||
Schlüsselfeatures:
|
||||
- F-IC1 ::hilfe (build_help_text)
|
||||
- F-IC2 ::status (build_status_text)
|
||||
- F-IC3 ::multiroom (Kontext an/aus)
|
||||
- F-IC4 ::setstatus (on/off, siehe FB-05 P1-2)
|
||||
- F-IC5 Natural Help Request Detection (is_natural_help_request)
|
||||
- F-IC6 Command-Question-Extraction (extract_command_question)
|
||||
- F-IC7 Build-Command-Help (pro Command)
|
||||
|
||||
Bekannte Probleme:
|
||||
- ::setstatus nutzt enable/disable statt PulseController (siehe FB-05).
|
||||
- Hilfe-Text-Wartung: Bei neuen Commands muss build_help_text manuell
|
||||
erweitert werden — kein Auto-Discovery aus Registry.
|
||||
|
||||
────────────────────────────────────────────────────────────────────
|
||||
FB-07 Button-System (Rendering, Dispatch, Templates) ⏳ ANSTEHEND
|
||||
────────────────────────────────────────────────────────────────────
|
||||
Verantwortung:
|
||||
Rendering von interaktiven Button-Attachments (Room-Auswahl, Review-Aktionen,
|
||||
Move-Requests), Dispatch eingehender Button-Klicks, Template-System.
|
||||
|
||||
Hauptdateien:
|
||||
- plugin/archivar/onboarding_review.py (build_button_attachments, dispatch_review_button)
|
||||
- plugin/archivar/inline_commands.py (Button-Hilfe)
|
||||
- plugin/archivar/archivar_state.py (Button-Action-IDs?)
|
||||
- plugin/adapter.py (Button-Click-Handler im DDP-Reader-Pfad)
|
||||
- tests/test_f6_adapter_dispatch.py (F6-Dispatch-Tests)
|
||||
- tests/test_p1_button_click_fix.py (P1-Button-Klick-Fix)
|
||||
- docs/BUTTON_GUIDE.md
|
||||
- docs/move-request-button-ux.md
|
||||
|
||||
Schlüsselfeatures:
|
||||
- F-BT1 Review-Buttons (room-step, edit, keywords, theme, catch-all, remove, add-new)
|
||||
- F-BT2 Move-Request-Buttons (Butler Klärungsflow)
|
||||
- F-BT3 Button-Action-ID-Schema
|
||||
- F-BT4 Template-Rendering
|
||||
- F-BT5 F6-Adapter-Dispatch-Pfad (Test existiert, deckt Pfad ab)
|
||||
|
||||
Bekannte Probleme:
|
||||
- Button-Click-Parsing sitzt in adapter.py — Suchpfad muss verifiziert
|
||||
werden (P1-Button-Click-Fix deutet auf Historie).
|
||||
- docs/move-request-button-ux.md deutet auf eigenen Sub-Flow mit
|
||||
noch nicht vollständig implementierter UX.
|
||||
|
||||
────────────────────────────────────────────────────────────────────
|
||||
FB-08 File-Handling (Upload, Download, Inlining, [FILE]-Stripping) ⏳ ANSTEHEND
|
||||
────────────────────────────────────────────────────────────────────
|
||||
Verantwortung:
|
||||
Behandlung von Datei-Anhängen: Upload via REST, Download für Inline-Vorschau,
|
||||
[FILE:...]-Block-Stripping bei fehlgeschlagenen Downloads, MIME-Type-Behandlung.
|
||||
|
||||
Hauptdateien:
|
||||
- plugin/adapter.py (_download_and_inline_files, _upload_file, [FILE]-Stripping)
|
||||
- plugin/adapter.py (342a1cd: P2-1-Fix — Block-Stripping nach fehlgeschlagenen Downloads)
|
||||
|
||||
Schlüsselfeatures:
|
||||
- F-FH1 Datei-Upload (rooms.upload via REST)
|
||||
- F-FH2 Datei-Download (für Inlining)
|
||||
- F-FH3 [FILE:pfad]-Block-Parsing
|
||||
- F-FH4 [FILE]-Stripping nach fehlgeschlagenen Downloads (P2-1)
|
||||
- F-FH5 MIME-Type-Erkennung
|
||||
|
||||
Bekannte Probleme:
|
||||
- Datei-Pfad-Injektion: [FILE:...]-Parsing muss gegen Traversal gesichert sein.
|
||||
- Download-Fehler-Handling: 342a1cd behebt Block-Stripping, aber Upload-
|
||||
Fehler-Fallbacks noch nicht verifiziert.
|
||||
- Größen-Limits: Kein expliziter Check in adapter.py sichtbar — Regressionsrisiko
|
||||
bei sehr großen Dateien.
|
||||
|
||||
────────────────────────────────────────────────────────────────────
|
||||
FB-09 Butler (Move-Requests, Clarification, 2. Stufe) ⏳ ANSTEHEND
|
||||
────────────────────────────────────────────────────────────────────
|
||||
Verantwortung:
|
||||
Wenn Routing unsicher ist: Klärungs-Anfrage an Butler (Nutzer) senden,
|
||||
Antwort verarbeiten, ggf. Move-Request initiieren. "Gelber Status" (away)
|
||||
signalisiert Klärungsbedarf.
|
||||
|
||||
Hauptdateien:
|
||||
- plugin/archivar/router.py (_parse_red_flag_response, validate_sentence_marker)
|
||||
- plugin/archivar/onboarding.py (Lazy-Onboarding-Check)
|
||||
- plugin/archivar/inline_commands.py (::multiroom-Kontext)
|
||||
- plugin/adapter.py (Move-Request-Versand)
|
||||
- docs/move-request-button-ux.md
|
||||
- docs/rocketchat_send_clarify_architecture.md (im Root-Repo)
|
||||
- tests/test_butler_mode.py
|
||||
- tests/test_d_pending_resolver.py
|
||||
|
||||
Schlüsselfeatures:
|
||||
- F-BU1 Red-Flag-Erkennung (LLM-Antwort unsicher)
|
||||
- F-BU2 Clarification-Request (Nachfrage an Nutzer)
|
||||
- F-BU3 Move-Request (Routing-Vorschlag als Button)
|
||||
- F-BU4 Pending-Resolver (d_pending_resolver)
|
||||
- F-BU5 Away-Status (573335c: gelb bei Klärungsflow)
|
||||
- F-BU6 Stufe-2-Klärung (DM-Routing in unsicheren Fällen)
|
||||
|
||||
Bekannte Probleme:
|
||||
- d_pending_resolver-Tests deutet auf komplexen State-Resolver — Refactoring-Druck.
|
||||
- Butler-Status-Kopplung an Presence (FB-05): away-Status-Logik muss mit
|
||||
PulseController-Implementierung harmonieren.
|
||||
|
||||
────────────────────────────────────────────────────────────────────
|
||||
FB-10 Room-Map (Verwaltung, Onboarding, Keywords) ⏳ ANSTEHEND
|
||||
────────────────────────────────────────────────────────────────────
|
||||
Verantwortung:
|
||||
Persistente Datenstruktur für Raum-Metadaten: Raum → Keywords, Theme,
|
||||
Catch-All-Status, Owner, Excluded-Liste. CRUD-API für Onboarding-Review
|
||||
und Auto-Learning.
|
||||
|
||||
Hauptdateien:
|
||||
- plugin/archivar/room_map.py (1043 LOC — RoomEntry, RoomMap, _migrate_from_env_vars)
|
||||
- plugin/archivar/room_index.py (664 LOC — RoomIndexManager, RoomIndexError)
|
||||
- room-map.json (Runtime-Output)
|
||||
|
||||
Schlüsselfeatures:
|
||||
- F-RM1 RoomEntry (name, id, keywords, theme, catch_all, owner)
|
||||
- F-RM2 RoomMap CRUD (load, save, add_room, remove_room, update_room)
|
||||
- F-RM3 Two-Stage Keyword Evidence
|
||||
- F-RM4 Room-Exclusion (excluded_ids)
|
||||
- F-RM5 Room-Validation (RoomMapValidationError)
|
||||
- F-RM6 Migration from Env-Vars (_migrate_from_env_vars)
|
||||
- F-RM7 Write-API (test_room_map_write_api)
|
||||
- F-RM8 Weighted-Keywords (test_room_map_weighted)
|
||||
- F-RM9 Room-Index (FAISS-Index für schnelles Lookup)
|
||||
|
||||
Bekannte Probleme:
|
||||
- Room-Map-Datei ist Single-Source-of-Truth, aber kein Locking-Mechanismus
|
||||
sichtbar — Concurrency-Risk bei parallelem Onboarding mehrerer Räume.
|
||||
- Migration-Path von Env-Vars deprecated aber noch vorhanden.
|
||||
|
||||
────────────────────────────────────────────────────────────────────
|
||||
FB-11 Adapter-Dispatch & ArchivarMessageHandler ⏳ ANSTEHEND
|
||||
────────────────────────────────────────────────────────────────────
|
||||
Verantwortung:
|
||||
Glue-Code zwischen DDP-Inbox und Archivar-Subsystem: Message-Sanitizing,
|
||||
Reply-Quote-Stripping, Auftrags-Erkennung, Decision-Logging, Adapter-Tests
|
||||
(F6-Dispatch-Pfad).
|
||||
|
||||
Hauptdateien:
|
||||
- plugin/archivar/adapter_integration.py (1270 LOC — ArchivarMessageHandler)
|
||||
- plugin/archivar/reply_quote_stripper.py (196 LOC — strip_reply_quote)
|
||||
- plugin/archivar/sentence_markers.py (Sentence-Marker → Routing-Decision)
|
||||
- plugin/archivar/routing_telemetry.py (137 LOC — RoutingTelemetry)
|
||||
- plugin/archivar/routing_counter.py (57 LOC — RoutingCounter)
|
||||
- plugin/adapter.py (_is_auftrag, _build_announcement, ArchivarMessageHandler-Aufruf)
|
||||
- tests/test_f6_adapter_dispatch.py
|
||||
- tests/test_reply_quote_stripper.py
|
||||
- tests/test_r5_inline_commands.py
|
||||
- tests/test_a1b_integration.py
|
||||
- tests/test_r1_integration.py
|
||||
|
||||
Schlüsselfefeatures:
|
||||
- F-AD1 ArchivarMessageHandler (Hauptentry-Point für DDP-Nachrichten)
|
||||
- F-AD2 Reply-Quote-Stripping (RC-spezifisch: [ ](per-Channel))
|
||||
- F-AD3 Auftrags-Erkennung (_is_auftrag)
|
||||
- F-AD4 Routing-Telemetry (Entscheidungsprotokollierung)
|
||||
- F-AD5 Routing-Counter (Häufigkeits-Statistik)
|
||||
- F-AD6 Adapter-Dispatch-Pfad (F6)
|
||||
|
||||
Bekannte Probleme:
|
||||
- 1270 LOC in adapter_integration.py — Kandidat für Aufteilung in
|
||||
Pre-Processing / Decision / Post-Processing.
|
||||
- Reply-Quote-Stripping: 4 Strip-Funktionen (attachments, rc-reply-link,
|
||||
blockquotes, quote-blocks) — Reihenfolge-Risiko.
|
||||
|
||||
────────────────────────────────────────────────────────────────────
|
||||
FB-12 Config & Persistenz ⏳ ANSTEHEND
|
||||
────────────────────────────────────────────────────────────────────
|
||||
Verantwortung:
|
||||
Konfigurations-Management: plugin.yaml (Manifest), templates/config.yaml
|
||||
(Default), .env (Runtime-Secrets), room-map.json (Runtime-State),
|
||||
Fact-Store-Pfad-Validierung, Conversation-History.
|
||||
|
||||
Hauptdateien:
|
||||
- plugin/plugin.yaml (12 LOC — name: rocketchat, kind: platform)
|
||||
- templates/config.yaml (88 LOC — Default-Config)
|
||||
- .env (Runtime — nicht in Git)
|
||||
- plugin/archivar/config.py (338 LOC — _resolve_room_mapping)
|
||||
- plugin/archivar/doc_store.py (144 LOC — DocumentationStore)
|
||||
- plugin/archivar/conversation_history.py (237 LOC — ConversationHistory, MessageEntry)
|
||||
- plugin/archivar/seed_data.py (134 LOC — Seed-Data)
|
||||
- room-map.json (Runtime-Output)
|
||||
|
||||
Schlüsselfeatures:
|
||||
- F-CF1 plugin.yaml-Manifest (Pitfall 4: name muss "rocketchat" sein)
|
||||
- F-CF2 templates/config.yaml (Default-Config-Template)
|
||||
- F-CF3 .env-Loading (via _get_config_str mit env_var-Fallback)
|
||||
- F-CF4 Fact-Store-Pfad (validate_fact_store_path, create_and_verify_fact_store)
|
||||
- F-CF5 DocumentationStore (FAKT-Routing-Output)
|
||||
- F-CF6 ConversationHistory (gespeicherte Konversations-Snapshots)
|
||||
- F-CF7 Seed-Data (Erstausstattung Room-Map, Keywords)
|
||||
|
||||
Bekannte Probleme:
|
||||
- .env nicht versioniert — Drift zwischen Test- und Prod-Config.
|
||||
- Migration _migrate_from_env_vars deprecated, aber noch im Code.
|
||||
- plugin.yaml-Name "rocketchat" (P1-2-O2-Fix 83b9d6c) — Hinweis auf
|
||||
subtile Pitfall-Klassen (Plugin-Loader-Strict-Matching).
|
||||
|
||||
────────────────────────────────────────────────────────────────────
|
||||
FB-13 install.sh & Deployment ⏳ ANSTEHEND
|
||||
────────────────────────────────────────────────────────────────────
|
||||
Verantwortung:
|
||||
Deployment-Skript: Plugin-Pfad-Validierung, venv-Setup, systemd-Service-
|
||||
Konfiguration, Verifikations-Loop, Restart-Logik. 11 dokumentierte
|
||||
Susi-Deployment-Pitfalls.
|
||||
|
||||
Hauptdateien:
|
||||
- install.sh (1611 LOC — Deployment, 99979d6 dokumentiert 9 Pitfalls)
|
||||
- bootstrap.sh (2325 Bytes — Wrapper?)
|
||||
- scripts/rebuild_index.py (FAISS-Index-Rebuild)
|
||||
- scripts/smoke_test_booster.py (Booster-Smoke-Test)
|
||||
- scripts/smoke_test_faiss.py (FAISS-Smoke-Test)
|
||||
- docs/INSTALL.md
|
||||
- docs/deployment-runbook.md
|
||||
- tests/test_install_update_only.py
|
||||
|
||||
Schlüsselfeatures:
|
||||
- F-IN1 Plugin-Pfad-Validierung (Core-Plugin-Pfad vs. Custom)
|
||||
- F-IN2 venv-Setup (numpy2-Installations-Pitfall)
|
||||
- F-IN3 systemd-Service-Config
|
||||
- F-IN4 Verifikations-Loop (is-active-Check, 30s-Timeout)
|
||||
- F-IN5 Update-Only-Pfad (test_install_update_only)
|
||||
- F-IN6 bootstrap.sh (Schnell-Setup)
|
||||
- F-IN7 Index-Rebuild-Skript
|
||||
- F-IN8 Smoke-Tests (Booster, FAISS)
|
||||
|
||||
Bekannte Probleme:
|
||||
- F6 R18 dokumentiert: 11 Pitfalls, install.sh 5 Schritte sauber,
|
||||
30s is-active-Loop robust, journalctl --since '1 minute ago' akzeptiert
|
||||
(systemd 257 getestet), --no-restart + --dry-run korrekt.
|
||||
- F6 R18: bash -n OK.
|
||||
- F18 (18d87d8): local outside function — replace with plain assignment
|
||||
(kleiner Cleanup, P0-charakter).
|
||||
|
||||
Review-Status: F6 R18 APPROVED mit 1 P1 (adapter.py Guard-Issue, NICHT
|
||||
install.sh selbst). Verifikation: 1288 passed, 37 failed pre-existing.
|
||||
|
||||
────────────────────────────────────────────────────────────────────
|
||||
FB-14 Telemetrie, Tests & Diagnostics ⏳ ANSTEHEND
|
||||
────────────────────────────────────────────────────────────────────
|
||||
Verantwortung:
|
||||
Routing-Telemetry, Routing-Counter, Test-Infrastruktur (pytest + 70 Test-Dateien),
|
||||
Diagnostics-Endpoints, Performance-Tests.
|
||||
|
||||
Hauptdateien:
|
||||
- plugin/archivar/routing_telemetry.py (137 LOC)
|
||||
- plugin/archivar/routing_counter.py (57 LOC)
|
||||
- plugin/archivar/tests/ (Test-Suite archivar-intern)
|
||||
- tests/ (Top-level-Tests: test_adapter, test_booster, test_ddp_await, test_install_update_only, test_onboarding, test_room_index)
|
||||
- scripts/smoke_test_*.py
|
||||
- faiss_performance_test*.py (im Root-Repo, nicht im Plugin)
|
||||
|
||||
Schlüsselfeatures:
|
||||
- F-TM1 Routing-Telemetry (Entscheidungs-Logging)
|
||||
- F-TM2 Routing-Counter (Statistik)
|
||||
- F-TM3 Test-Suite (70+ Dateien, F6-F19-Generationen)
|
||||
- F-TM4 Smoke-Tests (Booster, FAISS)
|
||||
- F-TM5 Performance-Tests (FAISS, Index-Größe)
|
||||
|
||||
Bekannte Probleme:
|
||||
- Test-Suite-Wartung: 16 v8_4_x-Dateien deuten auf hohe Iterationsfrequenz
|
||||
— Refactoring-Signale.
|
||||
- 37 pre-existing failed Tests (laut F6 R18) — müssen auf "broken-by-design"
|
||||
oder "fixable" klassifiziert werden.
|
||||
|
||||
================================================================
|
||||
ZUSAMMENFASSUNG
|
||||
================================================================
|
||||
|
||||
14 Funktionsbereiche identifiziert, alle Plugin-Aspekte abgedeckt:
|
||||
|
||||
✅ FB-01 Onboarding & Review REVIEWED (F6 R18)
|
||||
⏳ FB-02 DDP-Client ANSTEHEND
|
||||
⏳ FB-03 REST-Client ANSTEHEND
|
||||
⏳ FB-04 Archivar-Routing & Klassifikation ANSTEHEND (komplex, 2261 LOC)
|
||||
⏳ FB-05 Presence-Engine & Pulse ANSTEHEND, CHANGES NEEDED
|
||||
⏳ FB-06 Inline-Commands ANSTEHEND
|
||||
⏳ FB-07 Button-System ANSTEHEND
|
||||
⏳ FB-08 File-Handling ANSTEHEND
|
||||
⏳ FB-09 Butler (Move/Clarify) ANSTEHEND
|
||||
⏳ FB-10 Room-Map ANSTEHEND
|
||||
⏳ FB-11 Adapter-Dispatch ANSTEHEND
|
||||
⏳ FB-12 Config & Persistenz ANSTEHEND
|
||||
⏳ FB-13 install.sh & Deployment ANSTEHEND (F6 R18 APPROVED)
|
||||
⏳ FB-14 Telemetrie & Tests ANSTEHEND
|
||||
|
||||
Review-Reihenfolge-Empfehlung (nach Abhängigkeit + Risiko):
|
||||
1. FB-05 Presence (P0-Blocker für 8+ andere Bereiche)
|
||||
2. FB-13 install.sh (F6 R18 APPROVED → Re-Verifikation der P1)
|
||||
3. FB-02 DDP-Client (Grundlage für alle Inbox-Pfade)
|
||||
4. FB-04 Archivar-Routing (komplex, zentral, FAISS-Tests vorhanden)
|
||||
5. FB-10 Room-Map (Datenquelle für FB-04)
|
||||
6. FB-11 Adapter-Dispatch (Glue zwischen DDP und Archivar)
|
||||
7. FB-09 Butler (koppelt zurück an FB-05)
|
||||
8. FB-06 Inline-Commands (kleiner, isoliert)
|
||||
9. FB-07 Button-System (UX-kritisch, dokumentiert in BUTTON_GUIDE.md)
|
||||
10. FB-08 File-Handling (Sicherheits-Relevanz)
|
||||
11. FB-12 Config & Persistenz (Grundlage, niedrig-Risiko)
|
||||
12. FB-03 REST-Client (einfach, von DDP abgekoppelt)
|
||||
13. FB-14 Telemetrie & Tests (Wartbarkeit, Querschnitt)
|
||||
|
||||
Lücken-/Überlappungs-Check:
|
||||
- ABGEDECKT: DDP, REST, Routing, Onboarding, Presence, Inline-Commands,
|
||||
Buttons, Files, Butler, Room-Map, Config, Deployment, Tests.
|
||||
- NICHT als eigener Bereich: Logging (Querschnitt, in jedem FB prüfen),
|
||||
Error-Handling (Querschnitt), Security (Querschnitt — siehe FB-08,
|
||||
FB-12, FB-10 für Pfad-/Lock-Aspekte).
|
||||
- EXPLIZIT AUSGELAGERT: room-map.json sowohl in FB-10 (Schema) als auch
|
||||
FB-12 (Persistenz) — bei Review Klarstellung welcher Bereich
|
||||
Schema-Validierung vs. I/O-Verantwortung trägt.
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
# P2 Backlog — FB-02 DDP-Client Review (Rainer)
|
||||
|
||||
Erstellt: 2026-07-24
|
||||
Status: Offen (nicht in diesem Durchgang)
|
||||
|
||||
---
|
||||
|
||||
## B4 (P2): [Platzhalter — Details fehlen]
|
||||
|
||||
**Problem:** [TBD]
|
||||
|
||||
**Lösung:** [TBD]
|
||||
|
||||
**Commit:** `fix(B4): [TBD]`
|
||||
|
||||
---
|
||||
|
||||
## B5 (P2): [Platzhalter — Details fehlen]
|
||||
|
||||
**Problem:** [TBD]
|
||||
|
||||
**Lösung:** [TBD]
|
||||
|
||||
**Commit:** `fix(B5): [TBD]`
|
||||
|
||||
---
|
||||
|
||||
## B6 (P2): [Platzhalter — Details fehlen]
|
||||
|
||||
**Problem:** [TBD]
|
||||
|
||||
**Lösung:** [TBD]
|
||||
|
||||
**Commit:** `fix(B6): [TBD]`
|
||||
|
||||
---
|
||||
|
||||
## B7 (P2): [Platzhalter — Details fehlen]
|
||||
|
||||
**Problem:** [TBD]
|
||||
|
||||
**Lösung:** [TBD]
|
||||
|
||||
**Commit:** `fix(B7): [TBD]`
|
||||
|
||||
---
|
||||
|
||||
## Erledigt (dieser Durchgang)
|
||||
|
||||
| Bug | Prio | Commit | Beschreibung |
|
||||
|-----|------|--------|-------------|
|
||||
| B1 | P0 | `90c122c` | Future-Cleanup bei Disconnect |
|
||||
| B2 | P1 | `78b9a15` | Exponential Backoff bei Reconnect |
|
||||
| B3 | P1 | `c8f54d0` | Doc-String _on_ddp_connected set_status sync |
|
||||
+834
-1002
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,93 @@
|
||||
"""
|
||||
Gemeinsamer Button-Builder für Onboarding und Review-Flow.
|
||||
|
||||
Extrahiert aus onboarding_review.py (P0-1), damit adapter.py und
|
||||
onboarding_review.py die GLEICHE Button-Konstruktion nutzen — kein Drift.
|
||||
|
||||
Regeln:
|
||||
- Nummerierte Buttons: max 3 pro Attachment, mit 1️⃣ 2️⃣ 3️⃣...
|
||||
- Sonderschaltflächen (↩️ Zurück, ⏭️ Skip, ➕ Neu): KEINE Nummer,
|
||||
IMMER in separatem (letztem) Attachment
|
||||
- Jedes Attachment hat max 3 actions
|
||||
"""
|
||||
|
||||
from typing import List, Tuple
|
||||
|
||||
# Emoji-Nummern für bis zu 10 Buttons
|
||||
EMOJI_NUMBERS = ["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣", "🔟"]
|
||||
|
||||
|
||||
def build_button_attachments(
|
||||
num_buttons: List[Tuple[str, str]],
|
||||
special_buttons: List[Tuple[str, str, str]],
|
||||
color: str = "#1d74f5",
|
||||
title: str = "",
|
||||
number_buttons: bool = True,
|
||||
button_style: str = "primary",
|
||||
) -> List[dict]:
|
||||
"""Baut Attachments nach Andreas' 2-Reihen-Button-Pattern.
|
||||
|
||||
Regeln:
|
||||
- Nummerierte Buttons: max 3 pro Attachment, mit 1️⃣ 2️⃣ 3️⃣...
|
||||
(Nummerierung kann via number_buttons=False deaktiviert werden)
|
||||
- Sonderschaltflächen (↩️ Zurück, ⏭️ Skip, ➕ Neu): KEINE Nummer,
|
||||
IMMER in separatem (letztem) Attachment
|
||||
- Jedes Attachment hat max 3 actions
|
||||
|
||||
Args:
|
||||
num_buttons: Liste von (label, prefix) Tuples für nummerierte Buttons
|
||||
special_buttons: Liste von (label, prefix, style) Tuples für Sonderschaltflächen
|
||||
color: Attachment-Farbe (default: "#1d74f5")
|
||||
title: Attachment-Titel (nur für erstes Attachment)
|
||||
number_buttons: Wenn False, werden Buttons NICHT nummeriert
|
||||
(z.B. für X-Buttons in Keywords-Edit)
|
||||
button_style: Rocket.Chat button style für num_buttons (default: "primary")
|
||||
|
||||
Returns:
|
||||
Liste von Attachment-Dicts (jedes mit max 3 actions)
|
||||
"""
|
||||
attachments: List[dict] = []
|
||||
|
||||
# Nummerierte Buttons in 3er-Blöcke aufteilen
|
||||
for i in range(0, len(num_buttons), 3):
|
||||
chunk = num_buttons[i:i + 3]
|
||||
actions = []
|
||||
for j, (label, prefix) in enumerate(chunk):
|
||||
if number_buttons:
|
||||
num_idx = i + j
|
||||
emoji = EMOJI_NUMBERS[num_idx] if num_idx < len(EMOJI_NUMBERS) else str(num_idx + 1)
|
||||
text = f"{emoji} {label}"
|
||||
else:
|
||||
text = label
|
||||
actions.append({
|
||||
"type": "button",
|
||||
"text": text,
|
||||
"msg": prefix,
|
||||
"msg_in_chat_window": True,
|
||||
"style": button_style,
|
||||
})
|
||||
att = {
|
||||
"color": color,
|
||||
"actions": actions,
|
||||
}
|
||||
if i == 0 and title:
|
||||
att["title"] = title
|
||||
attachments.append(att)
|
||||
|
||||
# Sonderschaltflächen in separatem Attachment
|
||||
if special_buttons:
|
||||
special_actions = []
|
||||
for label, prefix, style in special_buttons:
|
||||
special_actions.append({
|
||||
"type": "button",
|
||||
"text": label,
|
||||
"msg": prefix,
|
||||
"msg_in_chat_window": True,
|
||||
"style": style,
|
||||
})
|
||||
attachments.append({
|
||||
"color": color,
|
||||
"actions": special_actions,
|
||||
})
|
||||
|
||||
return attachments
|
||||
@@ -154,85 +154,10 @@ def _persist_room_map_changes(
|
||||
|
||||
|
||||
# ── UX REFACTOR: build_button_attachments() Helper ──────────────────────────
|
||||
# P0-1: In gemeinsames Modul button_builder.py extrahiert,
|
||||
# damit adapter.py und onboarding_review.py die GLEICHE Button-Konstruktion nutzen.
|
||||
|
||||
# Emoji-Nummern für bis zu 10 Buttons
|
||||
_EMOJI_NUMBERS = ["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣", "🔟"]
|
||||
|
||||
|
||||
def build_button_attachments(
|
||||
num_buttons: List[Tuple[str, str]],
|
||||
special_buttons: List[Tuple[str, str, str]],
|
||||
color: str = "#1d74f5",
|
||||
title: str = "",
|
||||
number_buttons: bool = True,
|
||||
button_style: str = "primary",
|
||||
) -> List[dict]:
|
||||
"""Baut Attachments nach Andreas' 2-Reihen-Button-Pattern.
|
||||
|
||||
Regeln:
|
||||
- Nummerierte Buttons: max 3 pro Attachment, mit 1️⃣ 2️⃣ 3️⃣...
|
||||
(Nummerierung kann via number_buttons=False deaktiviert werden)
|
||||
- Sonderschaltflächen (↩️ Zurück, ⏭️ Skip, ➕ Neu): KEINE Nummer,
|
||||
IMMER in separatem (letztem) Attachment
|
||||
- Jedes Attachment hat max 3 actions
|
||||
|
||||
Args:
|
||||
num_buttons: Liste von (label, prefix) Tuples für nummerierte Buttons
|
||||
special_buttons: Liste von (label, prefix, style) Tuples für Sonderschaltflächen
|
||||
color: Attachment-Farbe (default: "#1d74f5")
|
||||
title: Attachment-Titel (nur für erstes Attachment)
|
||||
number_buttons: Wenn False, werden Buttons NICHT nummeriert
|
||||
(z.B. für X-Buttons in Keywords-Edit)
|
||||
button_style: Rocket.Chat button style für num_buttons (default: "primary")
|
||||
|
||||
Returns:
|
||||
Liste von Attachment-Dicts (jedes mit max 3 actions)
|
||||
"""
|
||||
attachments: List[dict] = []
|
||||
|
||||
# Nummerierte Buttons in 3er-Blöcke aufteilen
|
||||
for i in range(0, len(num_buttons), 3):
|
||||
chunk = num_buttons[i:i + 3]
|
||||
actions = []
|
||||
for j, (label, prefix) in enumerate(chunk):
|
||||
if number_buttons:
|
||||
num_idx = i + j
|
||||
emoji = _EMOJI_NUMBERS[num_idx] if num_idx < len(_EMOJI_NUMBERS) else str(num_idx + 1)
|
||||
text = f"{emoji} {label}"
|
||||
else:
|
||||
text = label
|
||||
actions.append({
|
||||
"type": "button",
|
||||
"text": text,
|
||||
"msg": prefix,
|
||||
"msg_in_chat_window": True,
|
||||
"style": button_style,
|
||||
})
|
||||
att = {
|
||||
"color": color,
|
||||
"actions": actions,
|
||||
}
|
||||
if i == 0 and title:
|
||||
att["title"] = title
|
||||
attachments.append(att)
|
||||
|
||||
# Sonderschaltflächen in separatem Attachment
|
||||
if special_buttons:
|
||||
special_actions = []
|
||||
for label, prefix, style in special_buttons:
|
||||
special_actions.append({
|
||||
"type": "button",
|
||||
"text": label,
|
||||
"msg": prefix,
|
||||
"msg_in_chat_window": True,
|
||||
"style": style,
|
||||
})
|
||||
attachments.append({
|
||||
"color": color,
|
||||
"actions": special_actions,
|
||||
})
|
||||
|
||||
return attachments
|
||||
from archivar.button_builder import build_button_attachments, EMOJI_NUMBERS
|
||||
|
||||
|
||||
# ── Schritt 1: review_room Top-Level Renderer ─────────────────────────────
|
||||
@@ -297,7 +222,7 @@ def render_review_room_step(
|
||||
# Nummerierte Optionen im Text
|
||||
lines.append("👉 Klicke auf einen Raum zum Anpassen:")
|
||||
for i, (label, _) in enumerate(num_buttons):
|
||||
emoji = _EMOJI_NUMBERS[i] if i < len(_EMOJI_NUMBERS) else str(i + 1)
|
||||
emoji = EMOJI_NUMBERS[i] if i < len(EMOJI_NUMBERS) else str(i + 1)
|
||||
lines.append(f" {emoji} {label}")
|
||||
|
||||
# Sonderschaltflächen
|
||||
@@ -672,10 +597,21 @@ def render_review_room_add_new(
|
||||
(text, attachments) Tuple
|
||||
"""
|
||||
if not available_rooms:
|
||||
# P0-4: Auch bei leerer Liste einen Zurück-Button rendern,
|
||||
# damit der User nicht in einer UX-Sackgasse steckt.
|
||||
special_buttons: List[Tuple[str, str, str]] = [
|
||||
("↩️ Zurück", REVIEW_ROOM_BACK, "default"),
|
||||
]
|
||||
attachments = build_button_attachments(
|
||||
[],
|
||||
special_buttons,
|
||||
color="#1d74f5",
|
||||
title="Neuen Raum hinzufügen",
|
||||
)
|
||||
return (
|
||||
"📋 **Neuer Raum** — Keine weiteren Räume verfügbar.\n"
|
||||
"Alle Rocket.Chat-Räume sind bereits in der Room-Map.",
|
||||
[],
|
||||
attachments,
|
||||
)
|
||||
|
||||
lines = [
|
||||
@@ -691,7 +627,7 @@ def render_review_room_add_new(
|
||||
name = room.get("name", rid)
|
||||
rtype = room.get("type", "c")
|
||||
type_label = "💬" if rtype == "d" else "#"
|
||||
emoji = _EMOJI_NUMBERS[i] if i < len(_EMOJI_NUMBERS) else str(i + 1)
|
||||
emoji = EMOJI_NUMBERS[i] if i < len(EMOJI_NUMBERS) else str(i + 1)
|
||||
lines.append(f" {emoji} {type_label} {name}")
|
||||
# Kurzer Button-Name (max 9 Zeichen)
|
||||
short_name = name[:9] if len(name) > 9 else name
|
||||
|
||||
@@ -217,8 +217,8 @@ class PresenceEngine:
|
||||
self._active_tasks -= 1
|
||||
count = self._active_tasks
|
||||
# FIX: Resume pulse when all active tasks complete.
|
||||
# on_agent_busy() pauses the pulse, but resume() was never called
|
||||
# in production — the pulse stayed paused forever.
|
||||
# mark_busy_started() pauses the pulse via adapter, but resume()
|
||||
# was never called in production — the pulse stayed paused forever.
|
||||
if count == 0:
|
||||
self._pulse_controller.resume()
|
||||
logger.info("[presence] active_tasks=0 → pulse resumed")
|
||||
@@ -246,8 +246,12 @@ class PresenceEngine:
|
||||
with self._busy_honeymoon_lock:
|
||||
self._busy_counter += 1
|
||||
if self._busy_honeymoon_timer is None:
|
||||
# First busy start — record time and start honeymoon timer
|
||||
self._busy_started_at = time.monotonic()
|
||||
# B2: _busy_started_at nur beim ERSTEN busy-Start setzen.
|
||||
# Wenn der Honeymoon-Timer bereits abgelaufen ist (Timer=None)
|
||||
# aber _busy_started_at noch existiert (weil active > 0),
|
||||
# dann NICHT neu setzen — sonst künstliche Verlängerung um 1s.
|
||||
if self._busy_started_at == 0.0:
|
||||
self._busy_started_at = time.monotonic()
|
||||
self._busy_honeymoon_timer = threading.Timer(
|
||||
self.MIN_BUSY_VISIBLE_S,
|
||||
self._honeymoon_expired,
|
||||
@@ -255,8 +259,8 @@ class PresenceEngine:
|
||||
self._busy_honeymoon_timer.daemon = True
|
||||
self._busy_honeymoon_timer.start()
|
||||
logger.debug(
|
||||
"[presence] Honeymoon-Timer gestartet (%.1fs), counter=%d",
|
||||
self.MIN_BUSY_VISIBLE_S, self._busy_counter,
|
||||
"[presence] Honeymoon-Timer gestartet (%.1fs), counter=%d, started_at=%.3f",
|
||||
self.MIN_BUSY_VISIBLE_S, self._busy_counter, self._busy_started_at,
|
||||
)
|
||||
else:
|
||||
logger.debug(
|
||||
@@ -308,6 +312,8 @@ class PresenceEngine:
|
||||
|
||||
Called by threading.Timer after MIN_BUSY_VISIBLE_S.
|
||||
If no active tasks remain, sets status to online.
|
||||
B3: Checks pending_status under _active_tasks_lock to prevent
|
||||
race with mark_busy_started.
|
||||
"""
|
||||
with self._busy_honeymoon_lock:
|
||||
self._busy_honeymoon_timer = None
|
||||
@@ -316,6 +322,20 @@ class PresenceEngine:
|
||||
active = self._active_tasks
|
||||
|
||||
if active == 0:
|
||||
# B3: Race-Schutz — prüfe ob pending_status 'busy' ist.
|
||||
# mark_busy_started könnte parallel update_presence() mit
|
||||
# pending='busy' aufgerufen haben. Dann NICHT überschreiben.
|
||||
with self._coalesce_lock:
|
||||
pending = self._pending_status
|
||||
if pending == "busy":
|
||||
logger.debug(
|
||||
"[presence] Honeymoon-Timer abgelaufen, aber pending_status=busy — "
|
||||
"nicht überschreiben (Race-Schutz)"
|
||||
)
|
||||
return
|
||||
# B2: Reset _busy_started_at when honeymoon fully expires
|
||||
# and no active tasks remain — next busy cycle starts fresh.
|
||||
self._busy_started_at = 0.0
|
||||
logger.info(
|
||||
"[presence] Honeymoon-Timer abgelaufen, active_tasks=0 → online"
|
||||
)
|
||||
@@ -577,24 +597,6 @@ class PresenceEngine:
|
||||
"""
|
||||
self._pulse_controller.cancel_pending()
|
||||
|
||||
def on_agent_busy(self, room_name: str = "") -> None:
|
||||
"""Hook: Agent is processing a message — pause pulse, set busy.
|
||||
|
||||
Priority 1 (highest): busy (rot) — Nachricht wird verarbeitet.
|
||||
"""
|
||||
self.set_current_room(room_name)
|
||||
self.increment_active_tasks()
|
||||
self.update_presence()
|
||||
# Pause pulse if running
|
||||
self._pulse_controller.pause()
|
||||
|
||||
def on_message_received(self, room_name: str = "") -> None:
|
||||
"""Hook: Message received — same as on_agent_busy.
|
||||
|
||||
Alias for on_agent_busy for semantic clarity.
|
||||
"""
|
||||
self.on_agent_busy(room_name=room_name)
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
# PulseController — DDP-basierte Heartbeat-Pulsierung (1.5s Intervall)
|
||||
@@ -634,7 +636,7 @@ class PulseController:
|
||||
self._phase: bool = False # False=online, True=away
|
||||
self._last_sent_phase: Optional[bool] = None
|
||||
self._background_count: int = 0
|
||||
self._cancel_pending: bool = False # P0-2: skip next tick flag
|
||||
self._cancel_pending_event = threading.Event() # B6: thread-safe via Event statt bool
|
||||
# P1-2 O-2: Async-await bridge
|
||||
self._loop: Optional[asyncio.AbstractEventLoop] = None
|
||||
self._await_timeout: float = 2.0
|
||||
@@ -745,7 +747,7 @@ class PulseController:
|
||||
status fires while the PulseController is running.
|
||||
Sets a flag that the next tick will skip.
|
||||
"""
|
||||
self._cancel_pending = True
|
||||
self._cancel_pending_event.set()
|
||||
logger.debug("[pulse] cancel_pending: next tick will be skipped")
|
||||
|
||||
# ── Internal: Pulse Loop ─────────────────────────────────────────────
|
||||
@@ -794,13 +796,14 @@ class PulseController:
|
||||
self._phase,
|
||||
self._ddp is not None,
|
||||
self._paused.is_set(),
|
||||
self._cancel_pending,
|
||||
self._cancel_pending_event.is_set(),
|
||||
self._loop is not None,
|
||||
)
|
||||
|
||||
# P0-2: Check cancel_pending flag (set by PresenceEngine._set_presence)
|
||||
if self._cancel_pending:
|
||||
self._cancel_pending = False
|
||||
# B6: thread-safe via threading.Event statt bool
|
||||
if self._cancel_pending_event.is_set():
|
||||
self._cancel_pending_event.clear()
|
||||
logger.debug("[pulse] _pulse_tick skip: cancel_pending was set")
|
||||
return
|
||||
|
||||
@@ -822,7 +825,17 @@ class PulseController:
|
||||
self._pulse_tick_async(),
|
||||
self._loop,
|
||||
)
|
||||
future.result(timeout=self._pulse_interval)
|
||||
# B5: Polling mit Pause-Check — pause() wirkt in 50ms statt 1.5s.
|
||||
# future.result(timeout=...) blockiert bis zu pulse_interval,
|
||||
# währenddessen kann pause() nicht greifen.
|
||||
while not future.done():
|
||||
if self._paused.is_set():
|
||||
future.cancel()
|
||||
logger.debug("[pulse] _pulse_tick async cancelled by pause")
|
||||
break
|
||||
time.sleep(0.05)
|
||||
if not future.cancelled():
|
||||
future.result(timeout=0) # already done, no blocking
|
||||
return
|
||||
except Exception as e:
|
||||
logger.info(
|
||||
|
||||
@@ -20,6 +20,47 @@ import pytest
|
||||
# Ensure the plugin package is importable
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
# B4: Autouse fixture — engine.shutdown() nach jedem Test
|
||||
# Verhindert dass Honeymoon-/Coalesce-/Pulse-/Detection-Timer in
|
||||
# nachfolgende Tests leaken (20-30% Failure-Rate).
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
_ENGINE_REGISTRY: list = []
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _shutdown_presence_engines():
|
||||
"""Track all PresenceEngine instances and call shutdown() after each test.
|
||||
|
||||
Monkey-patches PresenceEngine.__init__ to register every instance.
|
||||
After the test (in finally), calls engine.shutdown() on all registered
|
||||
instances — stops Honeymoon, Coalesce, PulseController, DetectionTimer.
|
||||
"""
|
||||
from plugin.archivar.presence_engine import PresenceEngine
|
||||
|
||||
_original_init = PresenceEngine.__init__
|
||||
|
||||
def _tracking_init(self, *args, **kwargs):
|
||||
_original_init(self, *args, **kwargs)
|
||||
_ENGINE_REGISTRY.append(self)
|
||||
|
||||
PresenceEngine.__init__ = _tracking_init
|
||||
_ENGINE_REGISTRY.clear()
|
||||
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
PresenceEngine.__init__ = _original_init
|
||||
for engine in _ENGINE_REGISTRY:
|
||||
try:
|
||||
engine.shutdown()
|
||||
except Exception:
|
||||
pass
|
||||
_ENGINE_REGISTRY.clear()
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
# Phase 1: Basis-PresenceEngine
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
@@ -1095,10 +1136,10 @@ class TestEdgeCaseReconnectRace:
|
||||
|
||||
|
||||
class TestEdgeCaseOnAgentBusy:
|
||||
"""Test 31: on_agent_busy() — pausiert Pulse, setzt busy (rot)."""
|
||||
"""Test 31: mark_busy_started() + pause() — pausiert Pulse, setzt busy (rot)."""
|
||||
|
||||
def test_on_agent_busy_pauses_pulse(self):
|
||||
"""on_agent_busy() pausiert den PulseController und setzt busy."""
|
||||
"""mark_busy_started() + pause() pausiert den PulseController und setzt busy."""
|
||||
from plugin.archivar.presence_engine import PresenceEngine
|
||||
|
||||
mock_rest = MagicMock()
|
||||
@@ -1123,8 +1164,9 @@ class TestEdgeCaseOnAgentBusy:
|
||||
time.sleep(0.1)
|
||||
assert engine._pulse_controller.is_running()
|
||||
|
||||
# on_agent_busy: pausiert Pulse
|
||||
engine.on_agent_busy(room_name="#Test")
|
||||
# A3: mark_busy_started + pause ersetzt on_agent_busy (toter Code entfernt)
|
||||
engine.mark_busy_started(room_name="#Test")
|
||||
engine._pulse_controller.pause()
|
||||
|
||||
time.sleep(0.1)
|
||||
# Pulse sollte pausiert sein
|
||||
@@ -1157,8 +1199,9 @@ class TestEdgeCaseOnAgentBusy:
|
||||
engine._pulse_controller.start()
|
||||
engine._background_tasks = 3
|
||||
|
||||
# on_agent_busy
|
||||
engine.on_agent_busy(room_name="#Test")
|
||||
# A3: mark_busy_started + pause ersetzt on_agent_busy
|
||||
engine.mark_busy_started(room_name="#Test")
|
||||
engine._pulse_controller.pause()
|
||||
time.sleep(0.1)
|
||||
|
||||
# Task beendet → decrement + update
|
||||
@@ -1173,10 +1216,10 @@ class TestEdgeCaseOnAgentBusy:
|
||||
|
||||
|
||||
class TestEdgeCaseOnMessageReceived:
|
||||
"""Test 32: on_message_received() — wie on_agent_busy, pausiert Pulse."""
|
||||
"""Test 32: mark_busy_started() + pause() — wie on_agent_busy, pausiert Pulse."""
|
||||
|
||||
def test_on_message_received_pauses_pulse(self):
|
||||
"""on_message_received() verhält sich wie on_agent_busy()."""
|
||||
"""mark_busy_started() + pause() verhält sich wie on_agent_busy()."""
|
||||
from plugin.archivar.presence_engine import PresenceEngine
|
||||
|
||||
mock_rest = MagicMock()
|
||||
@@ -1197,8 +1240,9 @@ class TestEdgeCaseOnMessageReceived:
|
||||
time.sleep(0.1)
|
||||
assert engine._pulse_controller.is_running()
|
||||
|
||||
# on_message_received → wie on_agent_busy
|
||||
engine.on_message_received(room_name="#Test")
|
||||
# A3: mark_busy_started + pause ersetzt on_message_received
|
||||
engine.mark_busy_started(room_name="#Test")
|
||||
engine._pulse_controller.pause()
|
||||
|
||||
time.sleep(0.1)
|
||||
assert not engine._pulse_controller.is_running() or engine._pulse_controller._paused.is_set()
|
||||
|
||||
@@ -327,6 +327,9 @@ class TestRenderReviewRoomAddNew:
|
||||
def test_renders_empty_available(self):
|
||||
text, attachments = render_review_room_add_new([], _mock_build_buttons)
|
||||
assert "Keine weiteren Räume verfügbar" in text
|
||||
# P0-4: Zurück-Button muss auch bei leerer Liste gerendert werden
|
||||
assert len(attachments) > 0, "Leere Liste muss Zurück-Button rendern"
|
||||
assert "Zurück" in str(attachments)
|
||||
|
||||
|
||||
# ── dispatch_review_button ──────────────────────────────────────────────────
|
||||
|
||||
+60
-2
@@ -413,7 +413,7 @@ class TestPulseControllerPauseInAsyncMode:
|
||||
|
||||
# Setze cancel_pending
|
||||
pc.cancel_pending()
|
||||
assert pc._cancel_pending is True
|
||||
assert pc._cancel_pending_event.is_set()
|
||||
|
||||
# _pulse_tick sollte übersprungen werden
|
||||
pc._pulse_tick()
|
||||
@@ -421,7 +421,7 @@ class TestPulseControllerPauseInAsyncMode:
|
||||
# set_status sollte NICHT aufgerufen worden sein
|
||||
mock_ddp.set_status.assert_not_called()
|
||||
# cancel_pending sollte zurückgesetzt sein
|
||||
assert pc._cancel_pending is False
|
||||
assert not pc._cancel_pending_event.is_set()
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
@@ -481,3 +481,61 @@ class TestLegacyTimerSetStatusRemainsSync:
|
||||
adapter.ddp.set_status("away")
|
||||
|
||||
mock_ddp.set_status.assert_called_with("away")
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
# Test 11: B1 — disconnect clears pending Futures with DDPNotConnected
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
class TestDisconnectClearsPendingFutures:
|
||||
"""B1: disconnect() löst alle pending Futures mit DDPNotConnected auf."""
|
||||
|
||||
def test_disconnect_clears_pending_futures(self):
|
||||
"""Engine erstellt, set_status_async aufrufen, disconnect() → DDPNotConnected."""
|
||||
client = _make_ddp_client(connected=True)
|
||||
client._send_json = MagicMock()
|
||||
|
||||
async def _run():
|
||||
# Starte set_status_async — registriert einen Future
|
||||
task = asyncio.create_task(client.set_status_async("online", timeout=5.0))
|
||||
await asyncio.sleep(0.05)
|
||||
|
||||
# Verifiziere: Future ist registriert
|
||||
with client._result_lock:
|
||||
assert len(client._pending_results) == 1
|
||||
|
||||
# Disconnect — muss den Future mit DDPNotConnected auflösen
|
||||
client.disconnect()
|
||||
|
||||
# Der Task sollte jetzt DDPNotConnected werfen
|
||||
with pytest.raises(DDPNotConnected) as exc_info:
|
||||
await task
|
||||
assert "connection closed" in str(exc_info.value).lower()
|
||||
|
||||
# _pending_results muss leer sein
|
||||
with client._result_lock:
|
||||
assert len(client._pending_results) == 0
|
||||
|
||||
asyncio.run(_run())
|
||||
|
||||
def test_reader_loop_exit_clears_pending_futures(self):
|
||||
"""Simuliere reader-loop exit: _cancel_pending_results wird aufgerufen."""
|
||||
client = _make_ddp_client(connected=True)
|
||||
client._send_json = MagicMock()
|
||||
|
||||
# Registriere einen pending Future manuell
|
||||
future = concurrent.futures.Future()
|
||||
with client._result_lock:
|
||||
client._pending_results["st9999999999_1"] = future
|
||||
|
||||
# Simuliere reader-loop exit (wie in _reader_loop nach while-Schleife)
|
||||
client._cancel_pending_results()
|
||||
|
||||
# Future muss DDPNotConnected haben
|
||||
assert future.done()
|
||||
with pytest.raises(DDPNotConnected):
|
||||
future.result()
|
||||
|
||||
# Store muss leer sein
|
||||
with client._result_lock:
|
||||
assert len(client._pending_results) == 0
|
||||
|
||||
Reference in New Issue
Block a user