fix: V9.2.2 — False-Positive Puls-Bug: Puls-Timer nur bei delegate_subagent > 0
Root Cause: _apply_counter_delta prüfte subagent_active über alle drei Counter (delegate_subagent, chat_profile, background_term). on_session_start feuert bei JEDEM Turn und inkrementiert chat_profile → Puls startete ohne echten Subagenten. Fix: - Puls-Trigger (pulse_counters) prüft NUR delegate_subagent - chat_profile und background_term zeigen weiterhin AWAY (statisch, ohne Puls) - _on_pulse_tick und _on_circuit_breaker_expired ebenfalls auf delegate_subagent-only umgestellt Tests (5 neue): - test_no_pulse_on_session_start: on_session_start → kein Puls - test_no_pulse_on_background_term: terminal(bg=true) → kein Puls - test_pulse_only_on_delegate_subagent: nur delegate_subagent triggert Puls - test_pulse_stops_when_delegate_done_others_stay: delegate→0 stoppt Puls trotz chat_profile>0 - test_chat_profile_away_no_pulse: chat_profile → AWAY statisch, kein Puls Alle 77 V9-Tests PASSED, keine Regression.
This commit is contained in:
@@ -289,10 +289,13 @@ class PresenceEngine:
|
||||
return
|
||||
|
||||
with self._transition_lock:
|
||||
# ── V9.2: Subagent-Aktivität VOR Mutation prüfen ─────────────
|
||||
subagent_counters = ["delegate_subagent", "chat_profile", "background_term"]
|
||||
subagent_active_before = any(
|
||||
self.counters[c] > 0 for c in subagent_counters
|
||||
# ── V9.2.2: Puls-Trigger VOR Mutation prüfen ─────────────────
|
||||
# Der Puls-Timer startet NUR bei delegate_subagent > 0.
|
||||
# chat_profile und background_term zeigen AWAY (statisch, ohne Puls),
|
||||
# weil sie keine echten Subagenten sind (False-Positive Bug V9.2.2).
|
||||
pulse_counters = ["delegate_subagent"]
|
||||
pulse_active_before = any(
|
||||
self.counters[c] > 0 for c in pulse_counters
|
||||
)
|
||||
|
||||
# ── Counter mutieren ─────────────────────────────────────────
|
||||
@@ -312,21 +315,21 @@ class PresenceEngine:
|
||||
counter_name, old_value, new_value, total, self._status,
|
||||
)
|
||||
|
||||
# ── V9.2: Subagent-Aktivität NACH Mutation prüfen ────────────
|
||||
subagent_active_now = any(
|
||||
self.counters[c] > 0 for c in subagent_counters
|
||||
# ── V9.2.2: Puls-Trigger NACH Mutation prüfen ─────────────────
|
||||
pulse_active_now = any(
|
||||
self.counters[c] > 0 for c in pulse_counters
|
||||
)
|
||||
|
||||
if subagent_active_now and not subagent_active_before:
|
||||
# Subagent wurde gerade aktiv → Puls starten
|
||||
if pulse_active_now and not pulse_active_before:
|
||||
# delegate_subagent wurde gerade aktiv → Puls starten
|
||||
self._start_pulse()
|
||||
# Initialen AWAY-Status setzen (der Puls-Timer übernimmt dann)
|
||||
self._status = "AWAY"
|
||||
self._cancel_away_grace()
|
||||
self._schedule_transition("away", "beschaeftigt — Subagent aktiv")
|
||||
return
|
||||
elif not subagent_active_now and subagent_active_before:
|
||||
# Subagent wurde gerade inaktiv → Puls stoppen
|
||||
elif not pulse_active_now and pulse_active_before:
|
||||
# delegate_subagent wurde gerade inaktiv → Puls stoppen
|
||||
self._cancel_pulse()
|
||||
|
||||
# ── Transition prüfen (3-State: ONLINE/BUSY/AWAY) ─────────────
|
||||
@@ -542,13 +545,12 @@ class PresenceEngine:
|
||||
return
|
||||
|
||||
with self._transition_lock:
|
||||
# Prüfe ob Subagent immer noch aktiv ist
|
||||
subagent_active = (
|
||||
# V9.2.2: Puls stoppt nur wenn delegate_subagent == 0.
|
||||
# chat_profile und background_term triggern keinen Puls (False-Positive Fix).
|
||||
pulse_active = (
|
||||
self.counters.get("delegate_subagent", 0) > 0
|
||||
or self.counters.get("chat_profile", 0) > 0
|
||||
or self.counters.get("background_term", 0) > 0
|
||||
)
|
||||
if not subagent_active:
|
||||
if not pulse_active:
|
||||
# Subagent ist fertig — Puls beenden
|
||||
self._pulse_active = False
|
||||
self._pulse_timer = None
|
||||
@@ -662,13 +664,12 @@ class PresenceEngine:
|
||||
self._circuit_breaker_paused = False
|
||||
self._circuit_breaker_timer = None
|
||||
|
||||
# Puls resumen wenn Subagent immer noch aktiv
|
||||
subagent_active = (
|
||||
# V9.2.2: Puls resumen nur wenn delegate_subagent > 0.
|
||||
# chat_profile und background_term triggern keinen Puls (False-Positive Fix).
|
||||
pulse_active = (
|
||||
self.counters.get("delegate_subagent", 0) > 0
|
||||
or self.counters.get("chat_profile", 0) > 0
|
||||
or self.counters.get("background_term", 0) > 0
|
||||
)
|
||||
if subagent_active and self._pulse_active:
|
||||
if pulse_active and self._pulse_active:
|
||||
self._schedule_pulse_tick()
|
||||
|
||||
def _cancel_circuit_breaker(self) -> None:
|
||||
|
||||
Reference in New Issue
Block a user