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).
This commit is contained in:
Bernd (Hermes)
2026-08-01 06:40:40 +02:00
parent 6aaadcdb88
commit 9f3cc02148
4 changed files with 230 additions and 23 deletions
@@ -280,3 +280,53 @@ def test_outbound_gate_stats_defaults():
assert stats.quick_reply == 0
assert stats.stale_swept == 0
assert stats.released_total == 0
# ═══════════════════════════════════════════════════════════════════════════
# 6.1: mark_quick_reply_sent returns True on first call
# ═══════════════════════════════════════════════════════════════════════════
@pytest.mark.outbound_gate
def test_mark_quick_reply_sent_first_call_returns_true():
"""6.1: mark_quick_reply_sent returns True beim ersten Aufruf."""
gate = OutboundGate()
room = "ROOM_QR_TEST_1"
result = gate.mark_quick_reply_sent(room)
assert result is True, "First mark_quick_reply_sent should return True"
# ═══════════════════════════════════════════════════════════════════════════
# 6.2: mark_quick_reply_sent returns False on second call (idempotent)
# ═══════════════════════════════════════════════════════════════════════════
@pytest.mark.outbound_gate
def test_mark_quick_reply_sent_second_call_returns_false():
"""6.2: mark_quick_reply_sent returns False beim zweiten Aufruf (idempotent)."""
gate = OutboundGate()
room = "ROOM_QR_TEST_2"
first = gate.mark_quick_reply_sent(room)
assert first is True
second = gate.mark_quick_reply_sent(room)
assert second is False, "Second mark_quick_reply_sent should return False (idempotent)"
# ═══════════════════════════════════════════════════════════════════════════
# 6.3: quick_reply_already_sent returns correct before/after mark
# ═══════════════════════════════════════════════════════════════════════════
@pytest.mark.outbound_gate
def test_quick_reply_already_sent_before_and_after():
"""6.3: quick_reply_already_sent returns korrekt vor/nach mark."""
gate = OutboundGate()
room = "ROOM_QR_TEST_3"
# Before mark: should be False
assert gate.quick_reply_already_sent(room) is False
gate.mark_quick_reply_sent(room)
# After mark: should be True
assert gate.quick_reply_already_sent(room) is True