[V10.318] 收緊 EA HITL 告警證據與排版治理
All checks were successful
CD Pipeline / deploy (push) Successful in 1m23s
All checks were successful
CD Pipeline / deploy (push) Successful in 1m23s
This commit is contained in:
@@ -231,6 +231,55 @@ def test_escalate_resource_optimization_without_evidence_is_suppressed(monkeypat
|
||||
assert suppressed == [("resource_optimization", "no_concrete_evidence")]
|
||||
|
||||
|
||||
def test_escalate_price_alert_without_evidence_is_suppressed(monkeypatch):
|
||||
import services.elephant_alpha_autonomous_engine as engine_module
|
||||
from services.elephant_alpha_autonomous_engine import (
|
||||
AutonomousTrigger,
|
||||
ElephantAlphaAutonomousEngine,
|
||||
)
|
||||
from services.elephant_alpha_orchestrator import StrategicDecision
|
||||
|
||||
engine = ElephantAlphaAutonomousEngine()
|
||||
suppressed = []
|
||||
cooldown = []
|
||||
|
||||
async def _no_concrete_actions(top_n=5):
|
||||
return None
|
||||
|
||||
def _raise_if_db_opened():
|
||||
raise AssertionError("no-concrete price escalation should not write human_review")
|
||||
|
||||
monkeypatch.setattr(engine, "_fetch_hermes_threats_summary", _no_concrete_actions)
|
||||
monkeypatch.setattr(engine_module, "get_session", _raise_if_db_opened)
|
||||
monkeypatch.setattr(engine, "_store_escalation", lambda trigger_type: cooldown.append(trigger_type))
|
||||
monkeypatch.setattr(
|
||||
engine,
|
||||
"_record_suppressed_escalation",
|
||||
lambda decision, trigger, reason: suppressed.append((trigger.trigger_type, reason)),
|
||||
)
|
||||
|
||||
decision = StrategicDecision(
|
||||
priority="medium",
|
||||
agents_required=["openclaw"],
|
||||
reasoning="價格調整建議信心不足",
|
||||
expected_outcome="待人工確認",
|
||||
confidence=0.62,
|
||||
execution_plan=[],
|
||||
resource_requirements={},
|
||||
)
|
||||
trigger = AutonomousTrigger(
|
||||
trigger_type="price_drop_alert",
|
||||
conditions={},
|
||||
threshold=0.8,
|
||||
enabled=True,
|
||||
)
|
||||
|
||||
asyncio.run(engine._escalate_to_human(decision, trigger))
|
||||
|
||||
assert cooldown == ["price_drop_alert"]
|
||||
assert suppressed == [("price_drop_alert", "no_concrete_evidence")]
|
||||
|
||||
|
||||
def test_resource_pressure_classifier_does_not_equate_backlog_with_cpu_load():
|
||||
from services.elephant_alpha_autonomous_engine import ElephantAlphaAutonomousEngine
|
||||
|
||||
|
||||
@@ -41,3 +41,26 @@ def test_ea_escalation_uses_structured_incident_brief():
|
||||
assert "PChome:<code>DABC53-A9009OEF</code>" in msg
|
||||
assert " • [5900068]" not in msg
|
||||
assert keyboard["inline_keyboard"][0][0]["callback_data"] == "momo:eig:ea_review_test"
|
||||
|
||||
|
||||
def test_ea_escalation_generic_actions_do_not_render_as_sku_cards():
|
||||
msg, _ = triaged_alert(
|
||||
base_event={
|
||||
"event_type": "ea_escalation",
|
||||
"title": "🐘 EA 升級審核 · 程式碼異常偵測",
|
||||
"summary": "低信心且缺少可格式化的具體行動",
|
||||
"id": "ea_review_generic",
|
||||
},
|
||||
tier_label="🐘 Elephant Alpha · L3 HITL",
|
||||
ai_summary="已隱藏 LLM plan 文字,避免把推測當成事實。",
|
||||
ai_cause="觸發類型:程式碼異常偵測 | 信心度:0.62 | 缺少可直接審核的實證資料",
|
||||
ai_actions=[
|
||||
"檢查觸發條件:{\"scan_containers\": [\"momo-pro-system\"]}",
|
||||
"不執行自動動作;請先在觀測台確認對應資料來源與最近錯誤紀錄。",
|
||||
],
|
||||
)
|
||||
|
||||
assert "📋 <b>待確認事項</b>" in msg
|
||||
assert "📋 <b>TOP 待審 SKU</b>" not in msg
|
||||
assert "• 待審 SKU" not in msg
|
||||
assert "未取得實證前,不執行自動調價、修復或策略派發" in msg
|
||||
|
||||
Reference in New Issue
Block a user