Bernd (Hermes)
|
0310bd5fd5
|
P1 Fix: OutboundGate Stale-Entry + user_map Fallback — 3 Bugs
B3: ContextVar _CURRENT_SESSION_ID (adapter.py)
- Neue ContextVar _CURRENT_SESSION_ID mit default=''
- Setzung in _dispatch_agent via uuid4().hex (Fallback)
- Lesung in send() und send_clarify() für release()
B1: _TurnHandle.owner_session_id (outbound_gate.py)
- _TurnHandle dataclass: neues Feld owner_session_id: str = ''
- try_acquire() neuer Parameter owner_session_id: str = ''
- release() Session-ID-Fallback: wenn task_token leer aber
owner_session_id existiert → release OK (Stream-Retry in
anderem asyncio-Task)
- 4 try_acquire-Aufrufstellen in adapter.py übergeben
_CURRENT_SESSION_ID.get()
B2: allow_proactive_user_map Opt-In (adapter.py)
- Plugin-Config-Flag allow_proactive_user_map: false (default)
- Priority 2 (_user_rooms[-1]) und _find_fallback_room_for_user
NUR nutzen wenn allow_proactive_user_map=True
- metadata['allow_proactive']=True überschreibt Config pro-Aufruf
- BEIDE Guess-Pfade geschützt: send() und send_clarify()
B+: Sweep-Intervall + max_entry_age reduziert
- _gate_sweep_loop: 30s → 5s
- OutboundGate default max_entry_age_s: 60.0 → 10.0
- adapter.py OutboundGate-Instanziierung: max_entry_age_s=10.0
Tests: 16 neue Tests in test_session_isolation.py
- test_session_id_propagation, test_session_id_no_core_arg_fallback
- test_try_acquire_records_owner_session_id
- test_release_respects_owner_session_id
- test_release_token_mismatch_no_session_match_skips
- test_release_token_match_no_session_needed
- test_user_map_blocked_by_default
- test_user_map_allowed_with_optin
- test_fallback_room_respects_optin
- test_allow_proactive_metadata_override
- test_max_entry_age_default_is_10s
- test_sweep_removes_stale_after_10s
- test_session_id_isolates_concurrent_sessions
- test_same_session_multi_turn_allowed
Bestehende Tests: 2 Tests in test_v8_1_p1_contextvar.py
angepasst (allow_proactive_user_map=True für _user_rooms-Fallback)
Gesamtsuite: 1381 passed, 4 skipped, 1 xfailed
|
2026-08-01 10:27:28 +02:00 |
|
Bernd (Hermes)
|
9f3cc02148
|
P1: Quick-Reply Dedup — zentraler Helper, kontextabhängiger Text, Same-Room-Erkennung
- _maybe_send_quick_reply() in adapter.py: Dedup via OutboundGate-Flag
- outbound_gate.py: quick_reply_sent-Flag in _TurnHandle, mark/check-Methoden
- Same-Room: 'Ich bin gerade beschäftigt' (kein Raum-Name)
- Cross-Room: 'Ich antworte gerade in #RaumX'
- Tests: test_outbound_gate.py +50 Zeilen, test_quick_reply_dedup.py +83 Zeilen
Re-Implementierung nach .45 Clean-Install (31.07.2026).
|
2026-08-01 06:40:40 +02:00 |
|
Bernd (Hermes)
|
1958a53f0e
|
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.
|
2026-07-30 08:43:00 +02:00 |
|
Bernd (Hermes)
|
e28c575169
|
P5 V9.x: OutboundGate — Parallel-Stream-Schutz für ausgehende Nachrichten
Implementiert mechanisches Gate im Adapter-Layer das verhindert dass
der Agent gleichzeitig in zwei verschiedenen Räumen antwortet.
Neue Dateien:
- plugin/archivar/outbound_gate.py: OutboundGate-Klasse mit
try_acquire (nicht-blockierend), release (idempotent),
wait_until_clear (async mit Timeout 30s), _sweep_stale_entries.
GateStats Dataclass mit 9 Countern. Reine asyncio-Datenstruktur.
- plugin/archivar/tests/test_outbound_gate.py: 7 Unit-Tests
(Marker @pytest.mark.outbound_gate), alle GRÜN.
Regeln:
- W1: NIEMALS synchron blockieren, nur asyncio.wait_for
- W2: release in try/except BaseException im finally-Block
- W3: Multi-Turn gleicher Raum gleicher Token = allowed
- W4: Vor Live-Schaltung alle Tests GRÜN
Adapter-Integration (User-Space):
- __init__: OutboundGate nach Archivar-Block
- send(): Gate-Check nach Red-Flag, vor P1-6 Prefix
- send_clarify(): Gleicher Gate-Check wie send()
- _process_incoming finally: release symmetrisch zu mark_busy_done
- _dispatch_agent finally: release im finally-Block
- _post_message_unlocked: Direkter REST-Call ohne Gate (Quick-Reply)
- ArchivarMessageHandler.bind_outbound_gate(): Hook
Archivar SKILL.md: Outbound-Sicht V9.x Abschnitt ergänzt.
Tests: 1359 passed, 0 failed, 0 regressions.
|
2026-07-30 08:27:14 +02:00 |
|