fix(verification): align playbook and mcp evidence for canary alerts
This commit is contained in:
@@ -170,6 +170,11 @@ class MCPToolRegistry:
|
||||
list[RegisteredTool]: 推薦工具(已排序)
|
||||
"""
|
||||
suggested: list[RegisteredTool] = []
|
||||
labels = incident_labels or {}
|
||||
has_k8s_locator = any(
|
||||
labels.get(key)
|
||||
for key in ("deployment", "pod", "node", "namespace", "container")
|
||||
)
|
||||
|
||||
# 依優先度排序後篩選
|
||||
sorted_tools = sorted(self._tools, key=lambda t: t.priority)
|
||||
@@ -181,7 +186,9 @@ class MCPToolRegistry:
|
||||
|
||||
# incident_type_hints 過濾
|
||||
if reg.incident_type_hints:
|
||||
if not any(alertname.startswith(hint) for hint in reg.incident_type_hints):
|
||||
matches_hint = any(alertname.startswith(hint) for hint in reg.incident_type_hints)
|
||||
is_k8s_state_tool = SensorDimension.D1_K8S_STATE in reg.dimensions
|
||||
if not matches_hint and not (has_k8s_locator and is_k8s_state_tool):
|
||||
continue
|
||||
|
||||
# 感官維度去重(每個維度取優先度最高的一個工具即可)
|
||||
|
||||
@@ -96,10 +96,11 @@ async def _resolve_exact_yaml_rule(
|
||||
"""
|
||||
SELECT playbook_id
|
||||
FROM playbooks
|
||||
WHERE source = 'yaml_rule'
|
||||
AND status = 'approved'
|
||||
WHERE status = 'approved'
|
||||
AND (symptom_pattern::jsonb->'alert_names') ? :alertname
|
||||
ORDER BY updated_at DESC
|
||||
ORDER BY
|
||||
CASE WHEN source = 'yaml_rule' THEN 0 ELSE 1 END,
|
||||
updated_at DESC
|
||||
LIMIT 1
|
||||
"""
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user