fix(presence): P-094 main_agent aus GC-Reset entfernen, P-095 DDP_TIMEOUT_S 3.0→1.0
P-094: main_agent ist ein reiner Hook-Counter (on_pre_gateway_dispatch +1, on_post_llm_call -1). Der P-085 GC-Reset wurde entfernt, weil pgrep_count für den Hauptagent IMMER 0 ist (Gateway matched nicht als 'hermes chat --profile') und der GC main_agent während aktiver Turns (>60s LLM-Inferenz/Tool-Calls) fälschlich resettete. Rainers Veto: Hook-Counter nie via pgrep resetten (P-039) — der Hook IST die Wahrheit. Entfernt: main_agent GC-Block in _drift_correction(), main_agent aus der DRIFT-STALE-Diagnose ausgeschlossen, MAIN_AGENT_GC_TIMEOUT_DEFAULT_S und _main_agent_gc_timeout_s Konstante/Attribut, PRESENCE_MAIN_AGENT_GC_TIMEOUT_S Env-Override. P-095: DDP_TIMEOUT_S 3.0s → 1.0s. Reduziert Blocking-Zeit von 3.5s auf 1.5s pro Status-Wechsel; bei DDP-Fehlern (DDPServerError) auf .101 kumulierte sich das. DDP-Ausfall (E4) geht ohnehin direkt zu REST. Tests: P-085-Testklasse → P-094-Testklasse (kein GC-Reset), DDP-Timeout- Tests auf 1.0/1.5s aktualisiert.
This commit is contained in:
@@ -1272,8 +1272,10 @@ class DDPFirstSender:
|
||||
P-042: DDP-Call hat IMMER einen Timeout. Kein Timeout =
|
||||
sync-Caller-Hänger. Timeout + Fallback als Paar, nicht optional.
|
||||
|
||||
P-041b H2: DDP_TIMEOUT_S 1.5s → 3.0s. DDP-Timeout darf großzügiger
|
||||
sein als UX-Intervall, sie sind entkoppelt. +0.5s Buffer → 3.5s total.
|
||||
P-095: DDP_TIMEOUT_S 3.0s → 1.0s. P-041b H2 hatte den Timeout ohne
|
||||
Messwert erhöht; bei DDP-Fehlern (DDPServerError) auf .101 kumuliert
|
||||
sich das Blocking. 1.0s reduziert die Blocking-Zeit auf 1.5s total.
|
||||
Bei DDP-Ausfall (E4: ddp_untrusted) geht es ohnehin direkt zu REST.
|
||||
|
||||
P-041b H1: connected-Check VOR Future — connected=False → sofort
|
||||
REST-Fallback, KEIN 1.5s-Wait.
|
||||
@@ -1286,7 +1288,7 @@ class DDPFirstSender:
|
||||
nicht connected.
|
||||
"""
|
||||
|
||||
DDP_TIMEOUT_S: float = 3.0 # P-041b H2: 1.5s → 3.0s
|
||||
DDP_TIMEOUT_S: float = 1.0 # P-095: 3.0s → 1.0s (P-041b H2 hatte ohne Messwert erhöht)
|
||||
|
||||
def __init__(self, adapter, rest_sender, mediator=None):
|
||||
"""Initialisiere DDPFirstSender.
|
||||
@@ -1364,7 +1366,7 @@ class DDPFirstSender:
|
||||
|
||||
try:
|
||||
# P-041b H2: DDP-Call mit Timeout via run_coroutine_threadsafe
|
||||
# DDP_TIMEOUT_S=3.0 + 0.5s Buffer = 3.5s total
|
||||
# DDP_TIMEOUT_S=1.0 + 0.5s Buffer = 1.5s total
|
||||
future = asyncio.run_coroutine_threadsafe(
|
||||
ddp.set_status_async(status, timeout=self.DDP_TIMEOUT_S),
|
||||
loop,
|
||||
@@ -1538,11 +1540,6 @@ class PresenceEngine:
|
||||
# Default 1800s (30 Min) — ein Turn ohne Activity ist definitiv tot.
|
||||
# Überschreibbar via Env-Variable PRESENCE_GC_TIMEOUT_S.
|
||||
GC_TIMEOUT_DEFAULT_S: float = 1800.0
|
||||
# P-085: GC-Timeout für main_agent (Hook-Counter via pre_gateway_dispatch/
|
||||
# post_llm_call). KÜRZER als chat_profile (60s statt 1800s), weil
|
||||
# main_agent der häufigste Counter ist und stale-Zustände schnell
|
||||
# erkannt werden müssen. Überschreibbar via PRESENCE_MAIN_AGENT_GC_TIMEOUT_S.
|
||||
MAIN_AGENT_GC_TIMEOUT_DEFAULT_S: float = 60.0
|
||||
# P-093: Stale-Reset-Timeout für chat_profile + background_term.
|
||||
# Kürzer als der alte 1800s-GC-Timeout (P-041a): ein Hook-Counter,
|
||||
# dessen Timestamp > 60s alt ist und bei dem pgrep==0 gilt, ist
|
||||
@@ -1579,15 +1576,6 @@ class PresenceEngine:
|
||||
os.getenv("PRESENCE_GC_TIMEOUT_S", str(self.GC_TIMEOUT_DEFAULT_S))
|
||||
)
|
||||
|
||||
# P-085: main_agent GC-Timeout aus Env-Variable (Default 60s).
|
||||
# Kürzer als chat_profile, weil main_agent der häufigste Counter ist.
|
||||
self._main_agent_gc_timeout_s = float(
|
||||
os.getenv(
|
||||
"PRESENCE_MAIN_AGENT_GC_TIMEOUT_S",
|
||||
str(self.MAIN_AGENT_GC_TIMEOUT_DEFAULT_S),
|
||||
)
|
||||
)
|
||||
|
||||
# ── Counter-Dict: 5 Zähler (P-043: +manual_task) ──────────────────
|
||||
self.counters: Dict[str, int] = {
|
||||
"main_agent": 0,
|
||||
@@ -1607,9 +1595,9 @@ class PresenceEngine:
|
||||
# Wird beim Inkrementieren auf time.time() gesetzt, beim
|
||||
# Dekrementieren auf 0.0 zurückgesetzt. Dient als Guard für
|
||||
# den negativen GC-Check in _drift_correction().
|
||||
# P-085: main_agent ist ebenfalls ein Hook-Counter (via
|
||||
# on_pre_gateway_dispatch/on_post_llm_call) und wird hier
|
||||
# mitgetrackt, damit der Stale-Reset (60s) greifen kann.
|
||||
# P-094: main_agent wird NICHT mehr via GC zurückgesetzt — der
|
||||
# Timestamp wird zwar weiter mitgetrackt (generischer Hook-Code),
|
||||
# aber kein GC-Block liest ihn mehr. Der Hook ist die Wahrheit.
|
||||
self._counter_timestamps: Dict[str, float] = {
|
||||
"main_agent": 0.0,
|
||||
"chat_profile": 0.0,
|
||||
@@ -1906,7 +1894,11 @@ class PresenceEngine:
|
||||
# pgrep detektiert nur delegate_subagent-Prozesse; Hook-gesetzte
|
||||
# Counter (chat_profile, background_term, manual_task) sind bei
|
||||
# pgrep==0 verdächtig auf Hängenbleiben.
|
||||
# P-094: main_agent ausgeschlossen — pgrep ist für den Hauptagent
|
||||
# IMMER 0 (Gateway matched nicht als 'hermes chat --profile').
|
||||
for _diag_name, _diag_value in self.counters.items():
|
||||
if _diag_name == "main_agent":
|
||||
continue
|
||||
if _diag_value > 0 and pgrep_count == 0:
|
||||
logger.warning(
|
||||
"[presence-v10] DRIFT-STALE-DETECTED: counter=%s value=%d but pgrep=0 — stale counter suspected",
|
||||
@@ -2042,43 +2034,17 @@ class PresenceEngine:
|
||||
self.STALE_RESET_TIMEOUT_S,
|
||||
)
|
||||
|
||||
# ── P-085: main_agent Stale-Reset ────────────────────────────
|
||||
# main_agent ist ein Hook-Counter (via on_pre_gateway_dispatch/
|
||||
# on_post_llm_call). Wenn on_post_llm_call nicht zuverlässig
|
||||
# feuert, läuft der Counter hoch und bleibt hängen → RED_STATIC
|
||||
# obwohl der Agent idle ist.
|
||||
#
|
||||
# P-039: Hook-Counter nie via pgrep resetten — ABER der GC-Reset
|
||||
# ist die dokumentierte Ausnahme (pgrep-leer + timeout). Analog
|
||||
# zum chat_profile GC-Reset (P-041/P-041a), aber mit KÜRZEREM
|
||||
# Timeout (60s statt 1800s), weil main_agent der häufigste
|
||||
# Counter ist und stale-Zustände schnell erkannt werden müssen.
|
||||
#
|
||||
# Guard: NUR resetten wenn pgrep==0 (kein aktiver Hauptagent-
|
||||
# Prozess) UND Timestamp-Alter > 60s (nicht bei frischen Hooks).
|
||||
# P-063: NUR Reset, niemals Auto-Inkrement.
|
||||
_ma_value = self.counters.get("main_agent", 0)
|
||||
if _ma_value > 0 and pgrep_count == 0:
|
||||
_ma_ts = self._counter_timestamps.get("main_agent", 0.0)
|
||||
if _ma_ts > 0.0:
|
||||
_ma_age = time.time() - _ma_ts
|
||||
if _ma_age > self._main_agent_gc_timeout_s:
|
||||
logger.warning(
|
||||
"[presence-v10] Drift-Korrektur: GC-Reset für main_agent — "
|
||||
"Counter=%d, Timestamp-Alter=%.1fs (>%.0fs), "
|
||||
"Grund=pgrep-leer+timeout (P-085)",
|
||||
_ma_value, _ma_age, self._main_agent_gc_timeout_s,
|
||||
)
|
||||
self.counters["main_agent"] = 0
|
||||
self._counter_timestamps["main_agent"] = 0.0
|
||||
self._telemetry_drift_corrections += 1
|
||||
else:
|
||||
logger.debug(
|
||||
"[presence-v10] Drift-Korrektur: GC-Skip für main_agent — "
|
||||
"Counter=%d, Timestamp-Alter=%.1fs (<%.0fs) — "
|
||||
"Race-Schutz aktiv (P-085)",
|
||||
_ma_value, _ma_age, self._main_agent_gc_timeout_s,
|
||||
)
|
||||
# ── P-094: main_agent wird NIE via GC zurückgesetzt ──────────
|
||||
# main_agent ist ein reiner Hook-Counter (on_pre_gateway_dispatch
|
||||
# +1, on_post_llm_call -1). P-039: Hook-Counter nie via pgrep
|
||||
# resetten — der Hook IST die Wahrheit. Der frühere P-085
|
||||
# GC-Reset wurde aufgehoben: pgrep_count ist für den Hauptagent
|
||||
# IMMER 0 (der Gateway-Prozess matched nicht als
|
||||
# 'hermes chat --profile'), sodass der GC main_agent während
|
||||
# aktiver Turns (>60s LLM-Inferenz/Tool-Calls) fälschlich
|
||||
# resettete. Kein GC-Reset, kein pgrep-Check, kein Timestamp-
|
||||
# Check. Falls der Hook unzuverlässig ist, ist das ein
|
||||
# Hook-Symmetrie-Bug (P-024/P-032), kein GC-Problem.
|
||||
|
||||
# ── P-043: GC für manuelle Tasks (> 60 Min) ──────────────────
|
||||
_MANUAL_TASK_GC_TIMEOUT_S = 3600.0 # 60 Minuten
|
||||
|
||||
@@ -5,7 +5,7 @@ Tests für:
|
||||
- DDPFirstSender: ddp_healthy State Machine, E4 (untrusted), H1 (connected-Check)
|
||||
- Mediator: 3-Schichten-Cache, pulse_lock (E3), E1 (DDP-Fail-Mid-Pulse), E5 (Reconciliation-Skip)
|
||||
- PULSE_INTERVAL_S=2.5
|
||||
- DDP_TIMEOUT_S=3.0
|
||||
- DDP_TIMEOUT_S=1.0 (P-095)
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -66,12 +66,23 @@ def _make_ddp_sender(adapter=None, rest_sender=None):
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
class TestDDPFirstSenderTimeout:
|
||||
"""P-041b H2: DDP_TIMEOUT_S = 3.0."""
|
||||
"""P-095: DDP_TIMEOUT_S = 1.0."""
|
||||
|
||||
def test_ddp_timeout_is_3_seconds(self):
|
||||
"""DDP_TIMEOUT_S muss 3.0 sein (nicht 1.5)."""
|
||||
assert DDPFirstSender.DDP_TIMEOUT_S == 3.0, (
|
||||
f"DDP_TIMEOUT_S sollte 3.0 sein, ist {DDPFirstSender.DDP_TIMEOUT_S}"
|
||||
def test_ddp_timeout_is_1_second(self):
|
||||
"""DDP_TIMEOUT_S muss 1.0 sein (nicht 3.0)."""
|
||||
assert DDPFirstSender.DDP_TIMEOUT_S == 1.0, (
|
||||
f"DDP_TIMEOUT_S sollte 1.0 sein, ist {DDPFirstSender.DDP_TIMEOUT_S}"
|
||||
)
|
||||
|
||||
def test_ddp_timeout_buffer_is_0_5_seconds(self):
|
||||
"""P-095: future.result(timeout=DDP_TIMEOUT_S + 0.5) = 1.5s total.
|
||||
|
||||
Verifiziert die +0.5s-Buffer-Logik im call-Pfad. Die Blocking-Zeit
|
||||
pro Status-Wechsel reduziert sich von 3.5s auf 1.5s.
|
||||
"""
|
||||
assert DDPFirstSender.DDP_TIMEOUT_S + 0.5 == 1.5, (
|
||||
f"DDP_TIMEOUT_S + 0.5 sollte 1.5 sein, "
|
||||
f"ist {DDPFirstSender.DDP_TIMEOUT_S + 0.5}"
|
||||
)
|
||||
|
||||
def test_ddp_timeout_logged_on_timeout(self):
|
||||
|
||||
@@ -8,8 +8,8 @@ blieb bis zu 50 Min auf 1 und die Engine pulsierte endlos in GREEN_PULSE.
|
||||
|
||||
Fix (analog zu P-089 für background_term): Wenn chat_profile > 0 UND
|
||||
pgrep==0 UND (kein Timestamp ODER Timestamp > STALE_RESET_TIMEOUT_S=60s)
|
||||
→ Reset auf 0. main_agent bleibt ausgeschlossen (Rainers Veto — eigener
|
||||
Block mit eigenem Timeout).
|
||||
→ Reset auf 0. main_agent bleibt ausgeschlossen (P-094 — Rainers Veto:
|
||||
main_agent ist reiner Hook-Counter, wird NIE via GC zurückgesetzt).
|
||||
|
||||
Testfälle:
|
||||
1. chat_profile=1, Timestamp > 60s, pgrep=0 → GC-Reset auf 0 (der Bug)
|
||||
@@ -17,7 +17,7 @@ Testfälle:
|
||||
3. chat_profile=1, Timestamp < 60s (frisch), pgrep=0 → KEIN Reset
|
||||
4. background_term=1, Timestamp > 60s, pgrep=0 → GC-Reset (analog P-089)
|
||||
5. main_agent=1, Timestamp > 60s, pgrep=0 → KEIN Reset durch diesen Block
|
||||
(main_agent hat eigenen Block mit eigenem Timeout — Rainers Veto)
|
||||
(main_agent ist reiner Hook-Counter, kein GC-Reset — P-094, Rainers Veto)
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -131,14 +131,14 @@ class TestP093ChatProfileStaleReset:
|
||||
def test_main_agent_not_reset_by_chat_profile_block(self):
|
||||
"""Fall 5: main_agent bleibt von diesem Block unberührt (Rainers Veto).
|
||||
|
||||
main_agent hat einen eigenen GC-Block mit eigenem Timeout
|
||||
(MAIN_AGENT_GC_TIMEOUT_DEFAULT_S=60s). Der chat_profile/background_term
|
||||
Block darf main_agent NICHT anfassen.
|
||||
main_agent ist ein reiner Hook-Counter (P-094) und wird NIE via GC
|
||||
zurückgesetzt. Der chat_profile/background_term-Block darf
|
||||
main_agent NICHT anfassen.
|
||||
"""
|
||||
engine = _make_engine()
|
||||
engine.on_pre_gateway_dispatch() # main_agent=1, Timestamp=now
|
||||
assert engine.counters["main_agent"] == 1
|
||||
# main_agent-Timestamp frisch lassen (< 60s) → eigener Block greift nicht
|
||||
# main_agent-Timestamp frisch lassen (< 60s) → kein GC betroffen
|
||||
# chat_profile/background_term sind 0 → dieser Block greift nicht
|
||||
|
||||
with patch.object(engine, "_count_delegated_subagents", return_value=0), \
|
||||
|
||||
@@ -994,71 +994,92 @@ class TestMultipleSubagents:
|
||||
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
# P-085: main_agent Stale-Reset Tests
|
||||
# P-094: main_agent wird NIE via GC zurückgesetzt
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
class TestMainAgentStaleReset:
|
||||
"""P-085: main_agent Hook-Counter wird bei pgrep==0 + Timeout resettet.
|
||||
class TestMainAgentNoGcReset:
|
||||
"""P-094: main_agent ist ein reiner Hook-Counter, kein GC-Reset.
|
||||
|
||||
Analog zum chat_profile GC-Reset (P-041/P-041a), aber mit kürzerem
|
||||
Timeout (60s statt 1800s). Guard: NUR resetten wenn pgrep==0 UND
|
||||
Timestamp-Alter > 60s. P-063: NUR Reset, niemals Auto-Inkrement.
|
||||
Rainers Veto: main_agent wird via Hook gesetzt (on_pre_gateway_dispatch
|
||||
+1, on_post_llm_call -1). P-039: Hook-Counter nie via pgrep resetten —
|
||||
der Hook IST die Wahrheit. Der frühere P-085 GC-Reset wurde aufgehoben,
|
||||
weil pgrep_count für den Hauptagent IMMER 0 ist (der Gateway-Prozess
|
||||
matched nicht als 'hermes chat --profile'). Der GC resettete main_agent
|
||||
während aktiver Turns (>60s LLM-Inferenz/Tool-Calls) fälschlich.
|
||||
"""
|
||||
|
||||
def _make_stale_engine(self, main_agent_value=24, age_s=120.0):
|
||||
"""Erzeuge Engine mit stale main_agent (Timestamp in der Vergangenheit)."""
|
||||
def _make_engine_with_main_agent(self, value=1, age_s=90.0):
|
||||
"""Erzeuge Engine mit main_agent=value und Timestamp age_s alt."""
|
||||
engine = _make_engine()
|
||||
# main_agent via Hook setzen (setzt Timestamp auf time.time())
|
||||
for _ in range(main_agent_value):
|
||||
for _ in range(value):
|
||||
engine.on_pre_gateway_dispatch()
|
||||
# Timestamp künstlich altern lassen (stale simulieren)
|
||||
# Timestamp künstlich altern lassen (lange Turn simulieren)
|
||||
engine._counter_timestamps["main_agent"] = time.time() - age_s
|
||||
return engine
|
||||
|
||||
def test_main_agent_stale_reset_when_pgrep_zero_and_timeout(self):
|
||||
"""pgrep==0 + Timestamp-Alter > 60s → main_agent auf 0, Phase GREEN_STATIC."""
|
||||
engine = self._make_stale_engine(main_agent_value=24, age_s=120.0)
|
||||
# pgrep==0 (kein aktiver Hauptagent-Prozess) + Taskliste leer
|
||||
with patch.object(engine, "_count_delegated_subagents", return_value=0), \
|
||||
patch.object(engine, "_count_active_tasks_from_tracker", return_value=0):
|
||||
engine._drift_correction()
|
||||
def test_main_agent_not_reset_when_stale_and_pgrep_zero(self):
|
||||
"""Der Kern-Bug: main_agent=1, Timestamp > 60s, pgrep=0 → KEIN Reset.
|
||||
|
||||
assert engine.counters["main_agent"] == 0
|
||||
assert engine._counter_timestamps["main_agent"] == 0.0
|
||||
# Phase fällt auf GREEN_STATIC (main_agent=0, delegate_subagent=0)
|
||||
assert engine.get_current_phase().name == "GREEN_STATIC"
|
||||
|
||||
def test_main_agent_not_reset_when_fresh_hook(self):
|
||||
"""Frischer Hook (Timestamp-Alter < 60s) → kein Reset."""
|
||||
engine = self._make_stale_engine(main_agent_value=1, age_s=5.0)
|
||||
with patch.object(engine, "_count_delegated_subagents", return_value=0), \
|
||||
patch.object(engine, "_count_active_tasks_from_tracker", return_value=0):
|
||||
engine._drift_correction()
|
||||
|
||||
# Frischer Hook: main_agent bleibt unverändert
|
||||
Simuliert einen langen Turn (>90s LLM-Inferenz/Tool-Calls). Der alte
|
||||
P-085-Block hätte main_agent hier fälschlich auf 0 resettet, obwohl
|
||||
der Agent aktiv arbeitet.
|
||||
"""
|
||||
engine = self._make_engine_with_main_agent(value=1, age_s=90.0)
|
||||
assert engine.counters["main_agent"] == 1
|
||||
|
||||
def test_main_agent_not_reset_when_pgrep_nonzero(self):
|
||||
"""pgrep > 0 (aktiver Hauptagent-Prozess) → kein Reset trotz Timeout."""
|
||||
engine = self._make_stale_engine(main_agent_value=24, age_s=120.0)
|
||||
# pgrep==0 (Hauptagent matched nie) + Taskliste leer
|
||||
with patch.object(engine, "_count_delegated_subagents", return_value=0), \
|
||||
patch.object(engine, "_count_active_tasks_from_tracker", return_value=0):
|
||||
engine._drift_correction()
|
||||
|
||||
assert engine.counters["main_agent"] == 1, (
|
||||
"P-094 FAIL: main_agent darf NIE via GC resettet werden — der Hook "
|
||||
"ist die einzige Wahrheitsquelle. Blieb aber auf "
|
||||
f"{engine.counters['main_agent']} statt 1."
|
||||
)
|
||||
|
||||
def test_main_agent_not_reset_when_stale_and_pgrep_nonzero(self):
|
||||
"""main_agent=24, Timestamp > 60s, pgrep>0 → KEIN Reset (auch nicht nötig)."""
|
||||
engine = self._make_engine_with_main_agent(value=24, age_s=120.0)
|
||||
with patch.object(engine, "_count_delegated_subagents", return_value=1), \
|
||||
patch.object(engine, "_count_active_tasks_from_tracker", return_value=0):
|
||||
engine._drift_correction()
|
||||
|
||||
# pgrep findet Prozess → main_agent bleibt (kein Reset)
|
||||
assert engine.counters["main_agent"] == 24
|
||||
assert engine.counters["main_agent"] == 24, (
|
||||
"P-094 FAIL: main_agent darf auch bei pgrep>0 nicht via GC "
|
||||
"angefasst werden."
|
||||
)
|
||||
|
||||
def test_main_agent_gc_timeout_default_is_60s(self):
|
||||
"""MAIN_AGENT_GC_TIMEOUT_DEFAULT_S == 60.0 (kürzer als chat_profile 1800s)."""
|
||||
def test_main_agent_not_reset_when_fresh_hook(self):
|
||||
"""Frischer Hook (Timestamp < 60s) → kein Reset."""
|
||||
engine = self._make_engine_with_main_agent(value=1, age_s=5.0)
|
||||
with patch.object(engine, "_count_delegated_subagents", return_value=0), \
|
||||
patch.object(engine, "_count_active_tasks_from_tracker", return_value=0):
|
||||
engine._drift_correction()
|
||||
|
||||
assert engine.counters["main_agent"] == 1
|
||||
|
||||
def test_main_agent_has_no_gc_timeout_constant(self):
|
||||
"""MAIN_AGENT_GC_TIMEOUT_DEFAULT_S existiert nicht mehr (P-085 aufgehoben)."""
|
||||
from plugin.archivar.presence_engine import PresenceEngine
|
||||
assert PresenceEngine.MAIN_AGENT_GC_TIMEOUT_DEFAULT_S == 60.0
|
||||
assert PresenceEngine.MAIN_AGENT_GC_TIMEOUT_DEFAULT_S < PresenceEngine.GC_TIMEOUT_DEFAULT_S
|
||||
assert not hasattr(PresenceEngine, "MAIN_AGENT_GC_TIMEOUT_DEFAULT_S"), (
|
||||
"P-094 FAIL: MAIN_AGENT_GC_TIMEOUT_DEFAULT_S muss entfernt sein — "
|
||||
"main_agent wird nicht mehr via GC zurückgesetzt."
|
||||
)
|
||||
|
||||
def test_main_agent_has_no_gc_timeout_instance_attr(self):
|
||||
"""Engine-Instanz hat kein _main_agent_gc_timeout_s mehr."""
|
||||
engine = _make_engine()
|
||||
assert not hasattr(engine, "_main_agent_gc_timeout_s"), (
|
||||
"P-094 FAIL: _main_agent_gc_timeout_s muss entfernt sein."
|
||||
)
|
||||
|
||||
def test_chat_profile_gc_reset_still_works(self):
|
||||
"""F4: chat_profile GC-Reset (P-041/P-041a) darf nicht brechen."""
|
||||
engine = _make_engine()
|
||||
engine.on_session_start() # chat_profile=1, Timestamp=now
|
||||
# chat_profile-Timestamp altern lassen (über 1800s Default)
|
||||
# chat_profile-Timestamp altern lassen (über 60s STALE_RESET_TIMEOUT_S)
|
||||
engine._counter_timestamps["chat_profile"] = time.time() - 2000.0
|
||||
with patch.object(engine, "_count_delegated_subagents", return_value=0), \
|
||||
patch.object(engine, "_count_active_tasks_from_tracker", return_value=0):
|
||||
@@ -1067,3 +1088,4 @@ class TestMainAgentStaleReset:
|
||||
assert engine.counters["chat_profile"] == 0
|
||||
assert engine._counter_timestamps["chat_profile"] == 0.0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user