From 88d895f6ab33e83195c93bb7f1ddfc2531c94ea3 Mon Sep 17 00:00:00 2001 From: "Bernd (Hermes)" Date: Tue, 18 Aug 2026 20:02:04 +0200 Subject: [PATCH] =?UTF-8?q?refactor(P-078):=20Remove=20Step=203=20(on=5Fre?= =?UTF-8?q?view=5Ffork=5Fclose)=20=E2=80=94=20Core-Unabhaengigkeit=20Ziel?= =?UTF-8?q?=20#14.=20Steps=201+2=20bleiben=20(Golden=20Source=20+=20pgrep?= =?UTF-8?q?=20Telemetrie)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/__init__.py | 13 ++----- plugin/archivar/presence_engine.py | 16 --------- .../tests/test_drift_correction_tasklist.py | 36 ------------------- 3 files changed, 2 insertions(+), 63 deletions(-) diff --git a/plugin/__init__.py b/plugin/__init__.py index eb9a2f2..89a92e7 100644 --- a/plugin/__init__.py +++ b/plugin/__init__.py @@ -282,21 +282,12 @@ def _register_presence_hooks() -> None: ctx.register_hook("post_tool_call", _on_post_tool_call) ctx.register_hook("background_process_stop", _on_background_process_stop) - # ── STEP 3: on_review_fork_close Hook (Hook-Symmetrie) ────────── - # Der Review-Fork (background_review.py) feuert on_session_start - # (chat_profile += 1), aber on_session_finalize feuert NICHT - # (_end_session_on_close=False). Dieser Hook dekrementiert idempotent. - def _on_review_fork_close(**kwargs): - _get_engine_and_call("on_review_fork_close", **kwargs) - - ctx.register_hook("on_review_fork_close", _on_review_fork_close) - _hooks_registered = True logger.info( - "[presence-v10] 12 Hooks registriert: " + "[presence-v10] 11 Hooks registriert: " "pre_gateway_dispatch, post_llm_call, subagent_start, subagent_stop, " "on_session_start, on_session_end, on_session_finalize, on_session_reset, " - "pre_tool_call, post_tool_call, background_process_stop, on_review_fork_close" + "pre_tool_call, post_tool_call, background_process_stop" ) except Exception as e: logger.warning( diff --git a/plugin/archivar/presence_engine.py b/plugin/archivar/presence_engine.py index 8afee30..16929cb 100644 --- a/plugin/archivar/presence_engine.py +++ b/plugin/archivar/presence_engine.py @@ -1872,22 +1872,6 @@ class PresenceEngine: """ self._apply_counter_delta("chat_profile", -1) - def on_review_fork_close(self, **kwargs) -> None: - """Hook: on_review_fork_close → chat_profile -= 1 (idempotent). - - STEP 3 (Hook-Symmetrie): Der Review-Fork (background_review.py) feuert - on_session_start (chat_profile += 1) via run_conversation, aber - on_session_finalize feuert NICHT — weil der Fork _end_session_on_close=False - setzt (er teilt die session_id des Parents und darf die Session nicht - finalisieren). Ohne diesen Hook bleibt chat_profile nach jedem Review - dauerhaft +1 → GREEN_PULSE im Leerlauf. - - Dieser Hook wird vom Core im finally-Block des Review-Threads gefeuert - und stellt die Symmetrie her. Idempotent: _apply_counter_delta klemmt - bei 0 (P-032), ein doppelter Aufruf ist harmlos. - """ - self._apply_counter_delta("chat_profile", -1) - def on_session_reset(self, **kwargs) -> None: """Hook: on_session_reset → alle Counter auf 0 (P-032 Fix). diff --git a/plugin/archivar/tests/test_drift_correction_tasklist.py b/plugin/archivar/tests/test_drift_correction_tasklist.py index fab983e..c60772b 100644 --- a/plugin/archivar/tests/test_drift_correction_tasklist.py +++ b/plugin/archivar/tests/test_drift_correction_tasklist.py @@ -6,7 +6,6 @@ Agenten-Taskliste (delegation_tracker.json) als Primärquelle. STEP 1: Taskliste als Primärquelle. STEP 2: pgrep als Fallback (nur Telemetrie). -STEP 3: Hook-Symmetrie (on_review_fork_close) — separat getestet. Test-Pflicht (Rainer): - Taskliste 0 → GREEN_STATIC (nicht GREEN_PULSE) @@ -317,38 +316,3 @@ class TestIntegrationFalsePositive: # P-063: kein Auto-Inkrement — Counter bleibt 0. assert engine.counters["delegate_subagent"] == 0 - - -# ═══════════════════════════════════════════════════════════════════════════ -# STEP 3: Hook-Symmetrie (on_review_fork_close) -# ═══════════════════════════════════════════════════════════════════════════ - -class TestReviewForkCloseHook: - """on_review_fork_close → chat_profile -= 1 (idempotent).""" - - def test_review_fork_close_decrements_chat_profile(self): - """chat_profile=1 → on_review_fork_close → 0.""" - engine = _make_engine() - engine.on_session_start() # chat_profile=1 (Review-Fork feuert on_session_start) - assert engine.counters["chat_profile"] == 1 - - engine.on_review_fork_close() - assert engine.counters["chat_profile"] == 0 - - def test_review_fork_close_idempotent(self): - """Doppelter Aufruf → bleibt 0 (kein negativer Counter).""" - engine = _make_engine() - engine.on_review_fork_close() # chat_profile=0 → Clamp bei 0 - engine.on_review_fork_close() # nochmal → bleibt 0 - assert engine.counters["chat_profile"] == 0 - - def test_review_fork_close_returns_to_green_static(self): - """Nach Review-Fork-Close: GREEN_STATIC (nicht GREEN_PULSE).""" - from plugin.archivar.presence_engine import Phase - - engine = _make_engine() - engine.on_session_start() # GREEN_PULSE (chat_profile=1) - assert engine.get_current_phase() == Phase.GREEN_PULSE - - engine.on_review_fork_close() # chat_profile=0 → GREEN_STATIC - assert engine.get_current_phase() == Phase.GREEN_STATIC