This commit is contained in:
@@ -252,6 +252,7 @@ def test_resource_optimization_bypasses_llm_orchestrator(monkeypatch):
|
||||
sent.append(args)
|
||||
|
||||
monkeypatch.setattr(engine_module.elephant_orchestrator, "analyze_and_coordinate", _boom)
|
||||
monkeypatch.setattr(engine, "_run_action_plan_hygiene", lambda: {"updated_count": 0})
|
||||
monkeypatch.setattr(engine, "_record_resource_pressure_insight", lambda *args, **kwargs: 77)
|
||||
monkeypatch.setattr(engine, "_send_resource_pressure_telegram", _capture_send)
|
||||
monkeypatch.setattr(engine, "_store_escalation", lambda trigger_type: stored.append(trigger_type))
|
||||
@@ -280,3 +281,40 @@ def test_resource_optimization_bypasses_llm_orchestrator(monkeypatch):
|
||||
assert stored == ["resource_optimization"]
|
||||
assert len(sent) == 1
|
||||
assert engine.max_autonomous_decisions_per_hour == 8
|
||||
|
||||
|
||||
def test_resource_pressure_message_reports_hygiene_result():
|
||||
from services.elephant_alpha_autonomous_engine import ElephantAlphaAutonomousEngine
|
||||
|
||||
metrics = ElephantAlphaAutonomousEngine._classify_resource_pressure({
|
||||
"action_queue_size": 9,
|
||||
"high_priority_count": 0,
|
||||
"human_review_count": 0,
|
||||
"stale_count": 0,
|
||||
"system_load_pct": 20.0,
|
||||
"queue_threshold": 10,
|
||||
"load_threshold_pct": 80,
|
||||
"high_priority_threshold": 5,
|
||||
"stale_threshold": 5,
|
||||
})
|
||||
metrics["pre_hygiene"] = {
|
||||
"action_queue_size": 100,
|
||||
"high_priority_count": 47,
|
||||
"stale_count": 99,
|
||||
}
|
||||
metrics["hygiene_result"] = {
|
||||
"updated_count": 91,
|
||||
"by_source": {"code_review_fix": 66, "openclaw_recommendation": 25},
|
||||
}
|
||||
|
||||
msg = ElephantAlphaAutonomousEngine._build_resource_pressure_telegram_message(
|
||||
metrics,
|
||||
insight_id=124,
|
||||
previous_limit=10,
|
||||
new_limit=10,
|
||||
)
|
||||
|
||||
assert "P4 resolved" in msg
|
||||
assert "清理前 Action queue:100" in msg
|
||||
assert "已自動關閉過期 action_plans 91 筆" in msg
|
||||
assert "只改 status/metadata,不刪除資料" in msg
|
||||
|
||||
Reference in New Issue
Block a user