P5 V9.x: Rainer Review Fixes — A1-A4 + W2
FIX A1: Adapter-Integration nachgeliefert - adapter.py: init self._outbound_gate nach Z.1177, Gate-Check in send() nach Red-Flag, send_clarify() Gate-Check, release in _process_incoming finally und _dispatch_agent finally, _post_message_unlocked für Quick-Reply - archivar/SKILL.md: Z.20-21 ergänzt + Outbound-Sicht V9.x Abschnitt - archivar/adapter_integration.py: bind_outbound_gate Hook FIX A2: Tests grün (7/7, keine Warnings) - pytest-asyncio bereits installiert (pytest 9.1.0) - @pytest.mark.outbound_gate in conftest.py registriert FIX A3: try_acquire Spec-Abweichung behoben - try_acquire jetzt ASYNC (await asyncio.Lock) - Rückgabetyp: GateDecision Dataclass (allow, reason, blocking_room_id) - Reasons: gate_clear, same_room_same_token, same_room_different_token, different_room_busy FIX A4: wait_until_clear Spec-Abweichung behoben - blocking_room_id Parameter hinzugefügt - _waiters per-Raum Dict (nicht flat List) → kein False-Wake-Bug - _TurnHandle jetzt Dataclass mit task und chat_id Feldern W2: Sweep-Loop als asyncio.create_task im Adapter - _gate_sweep_loop() alle 30s, nicht threading.Timer - Gestartet in connect() nach _listen_loop Tests: 1359 passed, 0 failed, 0 regressions.
This commit is contained in:
@@ -18,7 +18,8 @@ date: 2026-06-03
|
||||
## Übersicht
|
||||
|
||||
Der Archivar ist ein Submodul des Rocket.Chat-Plugins, das eingehende Nachrichten
|
||||
automatisch klassifiziert und optional in konfigurierte Zielräume weiterleitet.
|
||||
automatisch klassifiziert und optional in konfigurierte Zielräume weiterleitet,
|
||||
und ausgehende Nachrichten über ein opt-in Outbound Gate vor Parallel-Antworten schützt (V9.x).
|
||||
|
||||
**Kernfunktion:**
|
||||
- **Embedding-basierte Klassifikation** via nomic-embed-text (Ollama, localhost:11434)
|
||||
@@ -105,3 +106,42 @@ Bei Ollama-Ausfall greift diese Heuristik:
|
||||
|---|---|---|
|
||||
| FRAGE | frage, wie, was ist, warum, hilfe, problem, funktioniert nicht, kaputt, erklären | question, how, why, help, problem, explain |
|
||||
| ALARM | alarm, hilfe, dringend, sofort, notfall, ausfall, absturz, kritisch | alarm, emergency, urgent, critical, crash, sos |
|
||||
|
||||
## Outbound-Sicht V9.x
|
||||
|
||||
Der Archivar schützt seit V9.x auch ausgehende Nachrichten vor Parallel-Antworten
|
||||
in verschiedenen Räumen (Cross-Contamination). Das **OutboundGate** (`outbound_gate.py`)
|
||||
ist eine reine asyncio-Datenstruktur ohne LLM/Embedding-Logik.
|
||||
|
||||
**Funktionsweise:**
|
||||
- `try_acquire(room_id, task_token)`: Async, nicht-blockierend — prüft ob ein anderer Raum sendet.
|
||||
Gibt `GateDecision` zurück mit `allow`, `reason`, `blocking_room_id`.
|
||||
- `release(room_id, task_token)`: Idempotent — gibt den Slot frei.
|
||||
- `wait_until_clear(blocking_room_id, timeout_s)`: Async wait mit Timeout (default 30s).
|
||||
A4: Per-Raum `_waiters` Dict — kein False-Wake-Bug.
|
||||
- `_sweep_stale_entries()`: Räumt hängende Einträge auf (max_entry_age_s=60s).
|
||||
|
||||
**Regeln:**
|
||||
- Leeres Gate → allow (reason="gate_clear")
|
||||
- Gleicher Raum + gleicher Token → allow (Multi-Turn, W3, reason="same_room_same_token")
|
||||
- Gleicher Raum + anderer Token → block (reason="same_room_different_token")
|
||||
- Anderer Raum busy → block (reason="different_room_busy") → wait_until_clear(30s) → Quick-Reply bei Timeout
|
||||
|
||||
**Quick-Reply:** "Ich antworte gerade in #RaumA — einen Moment bitte, ich bin gleich bei dir."
|
||||
Geht über `_post_message_unlocked` (NICHT durch den Gate, sonst Endlosschleife).
|
||||
|
||||
**Integration:**
|
||||
- `adapter.py __init__`: `self._outbound_gate = OutboundGate()`
|
||||
- `adapter.py send()`: Gate-Check nach Red-Flag-Block, vor P1-6 Prefix
|
||||
- `adapter.py send_clarify()`: Gleicher Gate-Check wie send()
|
||||
- `adapter.py _process_incoming finally`: release symmetrisch zu mark_busy_done
|
||||
- `adapter.py _dispatch_agent finally`: release im finally-Block
|
||||
- `archivar.adapter_integration`: `bind_outbound_gate()` Hook
|
||||
|
||||
**Warn-Signale:**
|
||||
- W1: Gate blockiert NIEMALS synchron, nur asyncio.wait_for
|
||||
- W2: release in try/except BaseException im finally-Block
|
||||
- W3: Multi-Turn gleicher Raum gleicher Token = allowed, KEIN neuer Eintrag
|
||||
- W4: Vor Live-Schaltung alle Tests GRÜN
|
||||
|
||||
**Tests:** `plugin/archivar/tests/test_outbound_gate.py` (7 Tests, Marker `@pytest.mark.outbound_gate`)
|
||||
|
||||
Reference in New Issue
Block a user