P-039 + P-040: Bugfixes Presence-Engine + DM-Routing

P-039 (Pulse-Intervall + Drift-Korrektur):
- PULSE_INTERVAL_S: 3.0 -> 5.0 (429-Storms mit 2+ Agenten)
- _drift_correction: nur delegate_subagent via pgrep resetten,
  chat_profile + background_term (Hook-gesetzt) bleiben unveraendert
- _count_real_subagents -> _count_delegated_subagents umbenannt
- Reconciliation-Schutz: skip wenn letzte Counter-Mutation < 5s her
  (_last_counter_change in __init__ + _apply_counter_delta + _on_reconcile)

P-040 (Move-Request in DM ohne origin==target Check):
- router.py DM-Branch: origin==target Check VOR is_100_percent_match
- router.py: origin_room_id=None -> origin_room_id=origin_room_id
  (Origin-Priorisierung aktivieren)
- adapter_integration.py _send_move_request: defensiver origin==target
  Check am Anfang, return False ohne Button

Tests: 10/10 passed
- test_p039_pulse_interval_5s.py (3 tests)
- test_p039_drift_keeps_chat_profile.py (3 tests)
- test_p040_dm_move_request_origin_target.py (2 tests)
- test_p040_move_request_skips_self.py (2 tests)

REVERSIBLE-VIA-GIT
This commit is contained in:
Bernd (Hermes)
2026-08-07 22:39:55 +02:00
parent 0aa510fee5
commit e1d68ec00a
7 changed files with 471 additions and 32 deletions
+18 -1
View File
@@ -484,8 +484,25 @@ class BidirectionalRouter:
# Kein 100%-Treffer → Catch-All (LLM antwortet im DM).
# FAISS + weiche Keywords: in DMs NICHT ausführen.
routing_telemetry.start_timer()
matched_room = self._room_map.find_room_by_keywords(text, origin_room_id=None)
matched_room = self._room_map.find_room_by_keywords(text, origin_room_id=origin_room_id)
if matched_room is not None:
# P-040: origin==target Check — wenn der gefundene Raum
# der eigene DM-Raum ist, KEIN Move-Request (Nachricht
# ist bereits im korrekten Raum).
if matched_room.room_id == origin_room_id:
logger.info(
"P-040: DM-Match ist origin_room %s — skip Move-Request",
origin_room_id[:8],
)
routing_counter.increment('dm_self_match_stay')
logger.info("ROUTING DECISION: reason=dm_self_match_stay, origin_room=%s, target_room=, stay=True, butler_mode=False", origin_room_id)
return RoutingDecision(
category="direct_question",
target_room="",
confidence=0.0,
is_catch_all=True,
stay_in_room=True,
)
is_100 = self._room_map.is_100_percent_match(text, matched_room)
if is_100:
# 100%-Keyword in DM → Butler (Move-Request vorschlagen)