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:
Bernd (Hermes)
2026-07-30 08:43:00 +02:00
parent e28c575169
commit 1958a53f0e
8 changed files with 1314 additions and 100 deletions
+10
View File
@@ -134,6 +134,7 @@ class ArchivarMessageHandler:
self._send_callback = send_callback
self._button_send_callback = button_send_callback
self._presence_engine = None # P2-2: via set_presence_engine() gesetzt
self._outbound_gate = None # P5 V9.x: via bind_outbound_gate() gesetzt
self._enable_llm = LLM_CONFIG["enabled"]
# Create LLM client if enabled and not provided
@@ -1185,6 +1186,15 @@ class ArchivarMessageHandler:
"""
self._presence_engine = engine
def bind_outbound_gate(self, gate) -> None:
"""P5 V9.x: Bindet das OutboundGate für Parallel-Stream-Schutz.
Args:
gate: OutboundGate-Instanz.
"""
self._outbound_gate = gate
logger.info("[archivar] OutboundGate gebunden (V9.x)")
def set_subscribed_room_ids(self, room_ids: Optional[list]) -> None:
"""Set the bot's current subscribed room IDs for routing validation.