From e6df2fad28647be3bfa301c15f906878570a6ac1 Mon Sep 17 00:00:00 2001 From: OoO Date: Sat, 2 May 2026 13:09:39 +0800 Subject: [PATCH] fix(ea): remove weekly_strategy/meta_analysis from autonomous engine triggers (Phase 1 stopgap) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Critic-approved 3-point revision (REVISE → adopted): 1. Disable weekly_insight trigger at definition (line 279-285) — EA no longer evaluates the 6h / >=5 ai_insights condition that fired _generate_strategy_report without force_tg_alert=True. 2. Remove the openclaw weekly/meta dispatch table branches (line 591-606). The 5 actions (generate_strategic_analysis, generate_weekly_strategy, generate_market_analysis, generate_pricing_strategy, generate_meta_analysis) now fall through to the existing `raise ValueError(f"Unrecognized step: ...")` at line 631, which _execute_decision's try/except converts into a circuit-breaker failure. This is the correct failure semantics critic asked for. 3. Convert _generate_strategy_report / _generate_meta_report into hard RuntimeError raisers and drop their imports of openclaw_strategist_service. Deep insurance: any future caller crashes immediately instead of silently bypassing dedupe. Evidence: ai_insights logged 35+ duplicate weekly_strategy sends in 7 days because EA's `_generate_strategy_report` invoked generate_weekly_strategy_report() without force_tg_alert=True, bypassing the run_scheduler.py weekly dedupe gate. Out of scope (per task contract): - run_scheduler.py:115 Monday 06:00 schedule — preserved (sole owner) - services/openclaw_strategist_service.py — owned by B-series (SQL) - Other EA triggers (price_drop_alert / market_opportunity / threat_escalation / code_exception / resource_optimization) — preserved - Other dispatch branches (hermes / nemotron / auto_heal / code_fix / price_adjustment review) — preserved - Did NOT add force_tg_alert=True defensive layer (critic flagged as anti-pattern) - Did NOT touch _TRIGGER_TO_DECISION_TYPE / _ALLOWED_ACTION_TYPES Not pushed, not deployed. D1 deployment will be issued separately and must use `docker compose up -d --no-deps --force-recreate momo-scheduler` (per feedback_compose_restart_vs_up). Co-Authored-By: Claude Opus 4.7 (1M context) --- services/elephant_alpha_autonomous_engine.py | 39 +++++++++----------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/services/elephant_alpha_autonomous_engine.py b/services/elephant_alpha_autonomous_engine.py index 264bfd0..ed650a0 100644 --- a/services/elephant_alpha_autonomous_engine.py +++ b/services/elephant_alpha_autonomous_engine.py @@ -280,7 +280,8 @@ class ElephantAlphaAutonomousEngine: trigger_type="weekly_insight", conditions={"min_new_insights": 5, "cooldown_hours": 6}, threshold=0.7, - enabled=True, + # weekly_strategy 由 run_scheduler.py 週一 06:00 統一發送,EA 不再 6h 觸發(防 35+/週重複) + enabled=False, ), ] @@ -588,22 +589,11 @@ class ElephantAlphaAutonomousEngine: ) return - if agent_type == "openclaw" and action in ( - "generate_strategic_analysis", - "generate_weekly_strategy", - "generate_market_analysis", - "generate_pricing_strategy", - ): - return await self._run_with_timeout( - self._generate_strategy_report, - timeout=SSH_COMMAND_TIMEOUT, - ) - - if agent_type == "openclaw" and action == "generate_meta_analysis": - return await self._run_with_timeout( - self._generate_meta_report, - timeout=SSH_COMMAND_TIMEOUT, - ) + # NOTE: openclaw weekly_strategy / meta_analysis / strategic_analysis / + # market_analysis / pricing_strategy dispatch removed — weekly_strategy 由 + # run_scheduler.py 週一 06:00 統一發送(防 EA 6h 重複觸發 35+/週)。 + # 若 orchestrator Gemini 仍回傳這些 action,會落到下方 raise ValueError, + # 由 _execute_decision 的 try/except 捕捉並計入 circuit breaker。 if action in {"auto_heal", "resource_optimization", "optimize_resources", "handle_exception"}: return await self._run_with_timeout( @@ -644,12 +634,19 @@ class ElephantAlphaAutonomousEngine: ) async def _generate_strategy_report(self) -> Any: - from services.openclaw_strategist_service import generate_weekly_strategy_report - return await self._run_with_timeout(generate_weekly_strategy_report, timeout=SSH_COMMAND_TIMEOUT) + # 深層保險:即便未來新增 caller,此 method 仍立即崩,避免 EA 再度繞過 dedupe + # 重複發送 weekly_strategy。weekly_strategy 路徑唯一擁有者:run_scheduler.py 週一 06:00。 + raise RuntimeError( + "EA autonomous engine no longer generates weekly/meta reports — " + "owned by run_scheduler.py" + ) async def _generate_meta_report(self) -> Any: - from services.openclaw_strategist_service import generate_meta_analysis_report - return await self._run_with_timeout(generate_meta_analysis_report, timeout=SSH_COMMAND_TIMEOUT) + # 同 _generate_strategy_report:meta_analysis 不再由 EA 觸發。 + raise RuntimeError( + "EA autonomous engine no longer generates weekly/meta reports — " + "owned by run_scheduler.py" + ) def _run_auto_heal(self, error_type: str, context: Dict[str, Any]) -> Any: from services.auto_heal_service import auto_heal_service