From ba2ba336160e564a974b8788a156af9771092a43 Mon Sep 17 00:00:00 2001 From: "Bernd (Hermes)" Date: Sat, 20 Jun 2026 16:39:36 +0200 Subject: [PATCH] fix(adapter): _room_context + _room_context_lock vor Archivar-Import definieren MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- plugin/adapter.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugin/adapter.py b/plugin/adapter.py index 208d363..2b4a0c1 100644 --- a/plugin/adapter.py +++ b/plugin/adapter.py @@ -30,6 +30,11 @@ class RocketChatRateLimitError(Exception): """HTTP 429 Too Many Requests from Rocket.Chat REST API.""" pass +# ── Room context (global dict statt ContextVar — ContextVars sind asyncio-task-lokal, +# aber der Agent läuft in einem separaten Task und sieht sie nicht) ── +_room_context: Dict[str, Dict[str, str]] = {} # chat_id → {thematic_target, origin_room} +_room_context_lock = threading.Lock() + from archivar.adapter_integration import ArchivarMessageHandler # ── Access __init__ symbols (plugin loaded as flat module, no relative imports) ──