Update core/true_arf_oss.py
Browse files- core/true_arf_oss.py +859 -292
core/true_arf_oss.py
CHANGED
|
@@ -1,354 +1,921 @@
|
|
| 1 |
"""
|
| 2 |
-
True ARF OSS v3.3.7
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
"""
|
|
|
|
| 5 |
import asyncio
|
| 6 |
import logging
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
| 8 |
from datetime import datetime
|
|
|
|
| 9 |
|
| 10 |
logger = logging.getLogger(__name__)
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
"""
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
"""
|
| 17 |
|
| 18 |
-
def __init__(self):
|
| 19 |
-
self.
|
| 20 |
-
self.
|
| 21 |
-
self.
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
def
|
| 25 |
-
"""
|
| 26 |
-
|
| 27 |
-
|
|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 117 |
-
|
| 118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
"scenario": scenario_name,
|
| 120 |
-
"
|
| 121 |
-
"
|
| 122 |
-
"
|
|
|
|
| 123 |
}
|
| 124 |
-
)
|
| 125 |
|
| 126 |
-
#
|
| 127 |
-
|
| 128 |
-
# For demo, we'll simulate the OSS workflow but with real package calls
|
| 129 |
|
| 130 |
-
#
|
| 131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
|
| 133 |
-
# Recall
|
| 134 |
-
|
|
|
|
| 135 |
|
| 136 |
-
#
|
| 137 |
-
|
| 138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
)
|
| 140 |
|
| 141 |
-
# Calculate
|
| 142 |
-
|
| 143 |
|
| 144 |
-
#
|
| 145 |
result = {
|
| 146 |
"status": "success",
|
| 147 |
"scenario": scenario_name,
|
| 148 |
-
"arf_version": "3.3.7",
|
| 149 |
-
"edition": self.oss_edition,
|
| 150 |
-
"license": self.oss_license,
|
| 151 |
-
"timestamp": datetime.now().isoformat(),
|
| 152 |
"analysis": {
|
| 153 |
-
"detection":
|
| 154 |
-
|
| 155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
},
|
| 157 |
"capabilities": {
|
| 158 |
-
"execution_allowed":
|
| 159 |
-
"mcp_modes":
|
| 160 |
-
"oss_boundary": "advisory_only"
|
|
|
|
| 161 |
},
|
| 162 |
-
"
|
| 163 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
}
|
| 165 |
|
| 166 |
-
logger.info(f"
|
|
|
|
| 167 |
return result
|
| 168 |
|
| 169 |
except Exception as e:
|
| 170 |
-
logger.error(f"
|
| 171 |
return {
|
| 172 |
"status": "error",
|
| 173 |
"error": str(e),
|
| 174 |
"scenario": scenario_name,
|
| 175 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
}
|
| 177 |
|
| 178 |
-
|
| 179 |
-
"""
|
| 180 |
-
# This simulates what OSS detection would do
|
| 181 |
-
await asyncio.sleep(0.1)
|
| 182 |
-
|
| 183 |
return {
|
| 184 |
-
"
|
| 185 |
-
"
|
| 186 |
-
"
|
| 187 |
-
|
| 188 |
-
"detection_method": "ml_ensemble_v3",
|
| 189 |
-
"component": event.component,
|
| 190 |
-
"tags": ["true_arf", "v3.3.7", "oss_detection"],
|
| 191 |
-
"event_id": f"event_{datetime.now().timestamp()}",
|
| 192 |
-
"advisory_only": True # OSS can only advise
|
| 193 |
-
}
|
| 194 |
-
|
| 195 |
-
async def _simulate_recall(self, event) -> List[Dict[str, Any]]:
|
| 196 |
-
"""Simulate recall agent RAG search (would use real RAG in production)"""
|
| 197 |
-
await asyncio.sleep(0.15)
|
| 198 |
-
|
| 199 |
-
# Simulate finding similar incidents
|
| 200 |
-
similar_incidents = [
|
| 201 |
-
{
|
| 202 |
-
"incident_id": "inc_20250101_001",
|
| 203 |
-
"similarity_score": 0.92,
|
| 204 |
-
"success": True,
|
| 205 |
-
"resolution": "scale_out",
|
| 206 |
-
"cost_savings": 6500,
|
| 207 |
-
"detection_time": "48s",
|
| 208 |
-
"resolution_time": "15m",
|
| 209 |
-
"pattern": "cache_miss_storm_v2",
|
| 210 |
-
"component_match": event.component,
|
| 211 |
-
"rag_source": "production_memory_v3",
|
| 212 |
-
"timestamp": "2025-01-01T10:30:00"
|
| 213 |
},
|
| 214 |
-
{
|
| 215 |
-
"incident_id": "inc_20241215_045",
|
| 216 |
-
"similarity_score": 0.87,
|
| 217 |
-
"success": True,
|
| 218 |
-
"resolution": "warm_cache",
|
| 219 |
-
"cost_savings": 4200,
|
| 220 |
-
"detection_time": "52s",
|
| 221 |
-
"resolution_time": "22m",
|
| 222 |
-
"pattern": "redis_saturation",
|
| 223 |
-
"component_match": event.component,
|
| 224 |
-
"rag_source": "production_memory_v3",
|
| 225 |
-
"timestamp": "2024-12-15T14:45:00"
|
| 226 |
-
}
|
| 227 |
-
]
|
| 228 |
-
|
| 229 |
-
return similar_incidents
|
| 230 |
-
|
| 231 |
-
async def _create_healing_intent(self, event, detection_result: Dict, recall_result: List) -> Dict[str, Any]:
|
| 232 |
-
"""Create real HealingIntent (advisory only)"""
|
| 233 |
-
# Calculate confidence from detection and recall
|
| 234 |
-
detection_confidence = detection_result.get("confidence", 0.85)
|
| 235 |
-
recall_confidence = sum([inc["similarity_score"] for inc in recall_result]) / len(recall_result) if recall_result else 0.75
|
| 236 |
-
overall_confidence = (detection_confidence + recall_confidence) / 2
|
| 237 |
-
|
| 238 |
-
# Determine appropriate intent based on component
|
| 239 |
-
component = event.component.lower()
|
| 240 |
-
|
| 241 |
-
try:
|
| 242 |
-
if "cache" in component or "redis" in component:
|
| 243 |
-
healing_intent = self.create_scale_out_intent(
|
| 244 |
-
component=event.component,
|
| 245 |
-
parameters={"nodes": "3→5", "memory": "16GB→32GB", "strategy": "gradual_scale"},
|
| 246 |
-
confidence=overall_confidence,
|
| 247 |
-
source="oss_analysis"
|
| 248 |
-
)
|
| 249 |
-
elif "database" in component or "postgres" in component or "mysql" in component:
|
| 250 |
-
healing_intent = self.create_restart_intent(
|
| 251 |
-
component=event.component,
|
| 252 |
-
parameters={"connections": "reset_pool", "timeout": "30s", "strategy": "rolling_restart"},
|
| 253 |
-
confidence=overall_confidence,
|
| 254 |
-
source="oss_analysis"
|
| 255 |
-
)
|
| 256 |
-
else:
|
| 257 |
-
healing_intent = self.create_oss_advisory_intent(
|
| 258 |
-
component=event.component,
|
| 259 |
-
parameters={"action": "investigate", "priority": "high", "timeout": "30m"},
|
| 260 |
-
confidence=overall_confidence,
|
| 261 |
-
source="oss_analysis"
|
| 262 |
-
)
|
| 263 |
-
|
| 264 |
-
# Convert to dict for demo display
|
| 265 |
-
healing_intent_dict = {
|
| 266 |
-
"action": healing_intent.action if hasattr(healing_intent, 'action') else "advisory",
|
| 267 |
-
"component": healing_intent.component if hasattr(healing_intent, 'component') else event.component,
|
| 268 |
-
"confidence": overall_confidence,
|
| 269 |
-
"parameters": healing_intent.parameters if hasattr(healing_intent, 'parameters') else {},
|
| 270 |
-
"source": healing_intent.source if hasattr(healing_intent, 'source') else "oss_analysis",
|
| 271 |
-
"requires_enterprise": True, # OSS can only create advisory intents
|
| 272 |
-
"advisory_only": True,
|
| 273 |
-
"execution_allowed": False,
|
| 274 |
-
"safety_check": "✅ Passed (blast radius: 2 services, advisory only)"
|
| 275 |
-
}
|
| 276 |
-
|
| 277 |
-
# Add success rate from similar incidents
|
| 278 |
-
if recall_result:
|
| 279 |
-
success_count = sum(1 for inc in recall_result if inc.get("success", False))
|
| 280 |
-
healing_intent_dict["historical_success_rate"] = success_count / len(recall_result)
|
| 281 |
-
|
| 282 |
-
return healing_intent_dict
|
| 283 |
-
|
| 284 |
-
except Exception as e:
|
| 285 |
-
logger.error(f"Failed to create HealingIntent: {e}")
|
| 286 |
-
return {
|
| 287 |
-
"action": "advisory",
|
| 288 |
-
"component": event.component,
|
| 289 |
-
"confidence": overall_confidence,
|
| 290 |
-
"parameters": {"action": "investigate"},
|
| 291 |
-
"source": "oss_analysis_fallback",
|
| 292 |
-
"requires_enterprise": True,
|
| 293 |
-
"advisory_only": True,
|
| 294 |
-
"error": str(e)
|
| 295 |
-
}
|
| 296 |
-
|
| 297 |
-
def get_capabilities(self) -> Dict[str, Any]:
|
| 298 |
-
"""Get true OSS capabilities"""
|
| 299 |
-
if not self.oss_available:
|
| 300 |
-
return {
|
| 301 |
-
"oss_available": False,
|
| 302 |
-
"error": "ARF OSS package not installed"
|
| 303 |
-
}
|
| 304 |
-
|
| 305 |
-
try:
|
| 306 |
-
capabilities = self.get_oss_engine_capabilities()
|
| 307 |
-
except:
|
| 308 |
-
capabilities = {"available": True}
|
| 309 |
-
|
| 310 |
-
return {
|
| 311 |
"oss_available": self.oss_available,
|
| 312 |
"arf_version": "3.3.7",
|
| 313 |
-
"edition": self.oss_edition,
|
| 314 |
-
"license": self.oss_license,
|
| 315 |
-
"execution_allowed": self.execution_allowed,
|
| 316 |
-
"mcp_modes_allowed": self.mcp_modes_allowed,
|
| 317 |
-
"oss_capabilities": [
|
| 318 |
-
"anomaly_detection",
|
| 319 |
-
"rag_similarity_search",
|
| 320 |
-
"healing_intent_creation",
|
| 321 |
-
"pattern_analysis",
|
| 322 |
-
"advisory_recommendations",
|
| 323 |
-
"reliability_event_tracking",
|
| 324 |
-
"ml_based_detection"
|
| 325 |
-
],
|
| 326 |
-
"enterprise_features_required": [
|
| 327 |
-
"autonomous_execution",
|
| 328 |
-
"novel_execution_protocols",
|
| 329 |
-
"rollback_guarantees",
|
| 330 |
-
"deterministic_confidence",
|
| 331 |
-
"enterprise_mcp_server",
|
| 332 |
-
"audit_trail",
|
| 333 |
-
"license_management",
|
| 334 |
-
"human_approval_workflows"
|
| 335 |
-
],
|
| 336 |
-
"engine_capabilities": capabilities
|
| 337 |
}
|
| 338 |
|
|
|
|
|
|
|
|
|
|
| 339 |
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 349 |
|
|
|
|
|
|
|
|
|
|
| 350 |
|
| 351 |
-
async def
|
| 352 |
-
"""
|
| 353 |
-
|
| 354 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
"""
|
| 2 |
+
True ARF OSS v3.3.7 - Real Implementation
|
| 3 |
+
Production-grade multi-agent AI for reliability monitoring (Advisory only)
|
| 4 |
+
|
| 5 |
+
Core Agents:
|
| 6 |
+
1. Detection Agent: Anomaly detection and incident identification
|
| 7 |
+
2. Recall Agent: RAG-based memory for similar incidents
|
| 8 |
+
3. Decision Agent: Healing intent generation with confidence scoring
|
| 9 |
+
|
| 10 |
+
OSS Edition: Apache 2.0 Licensed, Advisory mode only
|
| 11 |
"""
|
| 12 |
+
|
| 13 |
import asyncio
|
| 14 |
import logging
|
| 15 |
+
import time
|
| 16 |
+
import uuid
|
| 17 |
+
from typing import Dict, Any, List, Optional, Tuple
|
| 18 |
+
from dataclasses import dataclass, field
|
| 19 |
from datetime import datetime
|
| 20 |
+
import numpy as np
|
| 21 |
|
| 22 |
logger = logging.getLogger(__name__)
|
| 23 |
|
| 24 |
+
# ============================================================================
|
| 25 |
+
# DATA MODELS
|
| 26 |
+
# ============================================================================
|
| 27 |
+
|
| 28 |
+
@dataclass
|
| 29 |
+
class TelemetryPoint:
|
| 30 |
+
"""Telemetry data point"""
|
| 31 |
+
timestamp: float
|
| 32 |
+
metric: str
|
| 33 |
+
value: float
|
| 34 |
+
component: str
|
| 35 |
+
|
| 36 |
+
@dataclass
|
| 37 |
+
class Anomaly:
|
| 38 |
+
"""Detected anomaly"""
|
| 39 |
+
id: str
|
| 40 |
+
component: str
|
| 41 |
+
metric: str
|
| 42 |
+
value: float
|
| 43 |
+
expected_range: Tuple[float, float]
|
| 44 |
+
confidence: float
|
| 45 |
+
severity: str # "low", "medium", "high", "critical"
|
| 46 |
+
timestamp: float = field(default_factory=time.time)
|
| 47 |
+
|
| 48 |
+
@dataclass
|
| 49 |
+
class Incident:
|
| 50 |
+
"""Incident representation for RAG memory"""
|
| 51 |
+
id: str
|
| 52 |
+
component: str
|
| 53 |
+
anomaly: Anomaly
|
| 54 |
+
telemetry: List[TelemetryPoint]
|
| 55 |
+
context: Dict[str, Any]
|
| 56 |
+
timestamp: float = field(default_factory=time.time)
|
| 57 |
+
resolved: bool = False
|
| 58 |
+
resolution: Optional[str] = None
|
| 59 |
+
|
| 60 |
+
def to_vector(self) -> List[float]:
|
| 61 |
+
"""Convert incident to vector for similarity search"""
|
| 62 |
+
# Create a feature vector based on incident characteristics
|
| 63 |
+
features = []
|
| 64 |
+
|
| 65 |
+
# Component encoding (simple hash)
|
| 66 |
+
features.append(hash(self.component) % 1000 / 1000.0)
|
| 67 |
+
|
| 68 |
+
# Metric severity encoding
|
| 69 |
+
severity_map = {"low": 0.1, "medium": 0.3, "high": 0.7, "critical": 1.0}
|
| 70 |
+
features.append(severity_map.get(self.anomaly.severity, 0.5))
|
| 71 |
+
|
| 72 |
+
# Anomaly confidence
|
| 73 |
+
features.append(self.anomaly.confidence)
|
| 74 |
+
|
| 75 |
+
# Telemetry features (averages)
|
| 76 |
+
if self.telemetry:
|
| 77 |
+
values = [p.value for p in self.telemetry]
|
| 78 |
+
features.append(np.mean(values))
|
| 79 |
+
features.append(np.std(values) if len(values) > 1 else 0.0)
|
| 80 |
+
else:
|
| 81 |
+
features.extend([0.0, 0.0])
|
| 82 |
+
|
| 83 |
+
# Context features
|
| 84 |
+
if "error_rate" in self.context:
|
| 85 |
+
features.append(self.context["error_rate"])
|
| 86 |
+
else:
|
| 87 |
+
features.append(0.0)
|
| 88 |
+
|
| 89 |
+
if "latency_p99" in self.context:
|
| 90 |
+
features.append(min(self.context["latency_p99"] / 1000.0, 1.0)) # Normalize
|
| 91 |
+
else:
|
| 92 |
+
features.append(0.0)
|
| 93 |
+
|
| 94 |
+
return features
|
| 95 |
+
|
| 96 |
+
# ============================================================================
|
| 97 |
+
# DETECTION AGENT
|
| 98 |
+
# ============================================================================
|
| 99 |
+
|
| 100 |
+
class DetectionAgent:
|
| 101 |
"""
|
| 102 |
+
Detection Agent - Identifies anomalies in telemetry data
|
| 103 |
+
|
| 104 |
+
Features:
|
| 105 |
+
- Statistical anomaly detection
|
| 106 |
+
- Multi-metric correlation analysis
|
| 107 |
+
- Confidence scoring
|
| 108 |
+
- Severity classification
|
| 109 |
"""
|
| 110 |
|
| 111 |
+
def __init__(self, config: Optional[Dict[str, Any]] = None):
|
| 112 |
+
self.config = config or {}
|
| 113 |
+
self.detection_history: List[Anomaly] = []
|
| 114 |
+
self.telemetry_buffer: Dict[str, List[TelemetryPoint]] = {}
|
| 115 |
+
|
| 116 |
+
# Detection thresholds
|
| 117 |
+
self.thresholds = {
|
| 118 |
+
"error_rate": {"warning": 0.01, "critical": 0.05},
|
| 119 |
+
"latency_p99": {"warning": 200, "critical": 500}, # ms
|
| 120 |
+
"cpu_util": {"warning": 0.8, "critical": 0.95},
|
| 121 |
+
"memory_util": {"warning": 0.85, "critical": 0.95},
|
| 122 |
+
"throughput": {"warning": 0.7, "critical": 0.3}, # relative to baseline
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
logger.info("Detection Agent initialized")
|
| 126 |
|
| 127 |
+
async def analyze_telemetry(self, component: str, telemetry: List[TelemetryPoint]) -> List[Anomaly]:
|
| 128 |
+
"""
|
| 129 |
+
Analyze telemetry data for anomalies
|
| 130 |
+
|
| 131 |
+
Args:
|
| 132 |
+
component: Target component name
|
| 133 |
+
telemetry: List of telemetry data points
|
| 134 |
+
|
| 135 |
+
Returns:
|
| 136 |
+
List of detected anomalies
|
| 137 |
+
"""
|
| 138 |
+
anomalies = []
|
| 139 |
+
|
| 140 |
+
# Group telemetry by metric
|
| 141 |
+
metrics = {}
|
| 142 |
+
for point in telemetry:
|
| 143 |
+
if point.metric not in metrics:
|
| 144 |
+
metrics[point.metric] = []
|
| 145 |
+
metrics[point.metric].append(point)
|
| 146 |
+
|
| 147 |
+
# Analyze each metric
|
| 148 |
+
for metric, points in metrics.items():
|
| 149 |
+
if len(points) < 3: # Need at least 3 points for meaningful analysis
|
| 150 |
+
continue
|
| 151 |
+
|
| 152 |
+
values = [p.value for p in points]
|
| 153 |
+
recent_value = values[-1]
|
| 154 |
+
|
| 155 |
+
# Check against thresholds
|
| 156 |
+
if metric in self.thresholds:
|
| 157 |
+
threshold = self.thresholds[metric]
|
| 158 |
+
|
| 159 |
+
# Determine severity and confidence
|
| 160 |
+
if recent_value >= threshold["critical"]:
|
| 161 |
+
severity = "critical"
|
| 162 |
+
confidence = min(0.95 + (recent_value - threshold["critical"]) * 2, 0.99)
|
| 163 |
+
elif recent_value >= threshold["warning"]:
|
| 164 |
+
severity = "high"
|
| 165 |
+
confidence = 0.85 + (recent_value - threshold["warning"]) * 0.5
|
| 166 |
+
else:
|
| 167 |
+
# No anomaly
|
| 168 |
+
continue
|
| 169 |
+
|
| 170 |
+
# Create anomaly
|
| 171 |
+
anomaly = Anomaly(
|
| 172 |
+
id=str(uuid.uuid4()),
|
| 173 |
+
component=component,
|
| 174 |
+
metric=metric,
|
| 175 |
+
value=recent_value,
|
| 176 |
+
expected_range=(0, threshold["warning"]),
|
| 177 |
+
confidence=min(confidence, 0.99),
|
| 178 |
+
severity=severity
|
| 179 |
+
)
|
| 180 |
+
|
| 181 |
+
anomalies.append(anomaly)
|
| 182 |
+
|
| 183 |
+
# Store in buffer for correlation analysis
|
| 184 |
+
self._store_in_buffer(component, metric, points[-5:]) # Last 5 points
|
| 185 |
+
|
| 186 |
+
logger.info(f"Detection Agent: Found {severity} anomaly in {component}.{metric}: {recent_value}")
|
| 187 |
+
|
| 188 |
+
# Correlated anomaly detection (cross-metric analysis)
|
| 189 |
+
correlated = await self._detect_correlated_anomalies(component, metrics)
|
| 190 |
+
anomalies.extend(correlated)
|
| 191 |
+
|
| 192 |
+
# Update history
|
| 193 |
+
self.detection_history.extend(anomalies)
|
| 194 |
+
|
| 195 |
+
return anomalies
|
| 196 |
+
|
| 197 |
+
async def _detect_correlated_anomalies(self, component: str, metrics: Dict[str, List[TelemetryPoint]]) -> List[Anomaly]:
|
| 198 |
+
"""Detect anomalies that correlate across multiple metrics"""
|
| 199 |
+
anomalies = []
|
| 200 |
+
|
| 201 |
+
# Simple correlation: if multiple metrics are anomalous, confidence increases
|
| 202 |
+
anomalous_metrics = []
|
| 203 |
+
|
| 204 |
+
for metric, points in metrics.items():
|
| 205 |
+
if metric in self.thresholds and len(points) >= 3:
|
| 206 |
+
recent_value = points[-1].value
|
| 207 |
+
threshold = self.thresholds[metric]
|
| 208 |
+
|
| 209 |
+
if recent_value >= threshold["warning"]:
|
| 210 |
+
anomalous_metrics.append({
|
| 211 |
+
"metric": metric,
|
| 212 |
+
"value": recent_value,
|
| 213 |
+
"severity": "critical" if recent_value >= threshold["critical"] else "high"
|
| 214 |
+
})
|
| 215 |
+
|
| 216 |
+
# If multiple metrics are anomalous, create a composite anomaly
|
| 217 |
+
if len(anomalous_metrics) >= 2:
|
| 218 |
+
# Calculate combined confidence
|
| 219 |
+
base_confidence = 0.7 + (len(anomalous_metrics) - 2) * 0.1
|
| 220 |
+
confidence = min(base_confidence, 0.97)
|
| 221 |
+
|
| 222 |
+
# Determine overall severity (use highest severity)
|
| 223 |
+
severities = [m["severity"] for m in anomalous_metrics]
|
| 224 |
+
severity = "critical" if "critical" in severities else "high"
|
| 225 |
+
|
| 226 |
+
anomaly = Anomaly(
|
| 227 |
+
id=str(uuid.uuid4()),
|
| 228 |
+
component=component,
|
| 229 |
+
metric="correlated",
|
| 230 |
+
value=len(anomalous_metrics),
|
| 231 |
+
expected_range=(0, 1),
|
| 232 |
+
confidence=confidence,
|
| 233 |
+
severity=severity
|
| 234 |
)
|
| 235 |
|
| 236 |
+
anomalies.append(anomaly)
|
| 237 |
+
logger.info(f"Detection Agent: Found correlated anomaly across {len(anomalous_metrics)} metrics")
|
| 238 |
+
|
| 239 |
+
return anomalies
|
| 240 |
+
|
| 241 |
+
def _store_in_buffer(self, component: str, metric: str, points: List[TelemetryPoint]):
|
| 242 |
+
"""Store telemetry in buffer for trend analysis"""
|
| 243 |
+
key = f"{component}:{metric}"
|
| 244 |
+
if key not in self.telemetry_buffer:
|
| 245 |
+
self.telemetry_buffer[key] = []
|
| 246 |
+
|
| 247 |
+
self.telemetry_buffer[key].extend(points)
|
| 248 |
+
|
| 249 |
+
# Keep only last 100 points per metric
|
| 250 |
+
if len(self.telemetry_buffer[key]) > 100:
|
| 251 |
+
self.telemetry_buffer[key] = self.telemetry_buffer[key][-100:]
|
| 252 |
+
|
| 253 |
+
def get_detection_stats(self) -> Dict[str, Any]:
|
| 254 |
+
"""Get detection statistics"""
|
| 255 |
+
return {
|
| 256 |
+
"total_detections": len(self.detection_history),
|
| 257 |
+
"by_severity": {
|
| 258 |
+
"critical": len([a for a in self.detection_history if a.severity == "critical"]),
|
| 259 |
+
"high": len([a for a in self.detection_history if a.severity == "high"]),
|
| 260 |
+
"medium": len([a for a in self.detection_history if a.severity == "medium"]),
|
| 261 |
+
"low": len([a for a in self.detection_history if a.severity == "low"]),
|
| 262 |
+
},
|
| 263 |
+
"buffer_size": sum(len(points) for points in self.telemetry_buffer.values()),
|
| 264 |
+
"unique_metrics": len(self.telemetry_buffer),
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
# ============================================================================
|
| 268 |
+
# RECALL AGENT (RAG Memory)
|
| 269 |
+
# ============================================================================
|
| 270 |
+
|
| 271 |
+
class RecallAgent:
|
| 272 |
+
"""
|
| 273 |
+
Recall Agent - RAG-based memory for similar incidents
|
| 274 |
+
|
| 275 |
+
Features:
|
| 276 |
+
- Vector similarity search
|
| 277 |
+
- Incident clustering
|
| 278 |
+
- Success rate tracking
|
| 279 |
+
- Resolution pattern extraction
|
| 280 |
+
"""
|
| 281 |
+
|
| 282 |
+
def __init__(self, config: Optional[Dict[str, Any]] = None):
|
| 283 |
+
self.config = config or {}
|
| 284 |
+
self.incidents: List[Incident] = []
|
| 285 |
+
self.incident_vectors: List[List[float]] = []
|
| 286 |
+
|
| 287 |
+
# Resolution outcomes
|
| 288 |
+
self.outcomes: Dict[str, Dict[str, Any]] = {} # incident_id -> outcome
|
| 289 |
+
|
| 290 |
+
# Similarity cache
|
| 291 |
+
self.similarity_cache: Dict[str, List[Dict[str, Any]]] = {}
|
| 292 |
+
|
| 293 |
+
logger.info("Recall Agent initialized")
|
| 294 |
+
|
| 295 |
+
async def add_incident(self, incident: Incident) -> str:
|
| 296 |
+
"""
|
| 297 |
+
Add incident to memory
|
| 298 |
+
|
| 299 |
+
Args:
|
| 300 |
+
incident: Incident to add
|
| 301 |
|
| 302 |
+
Returns:
|
| 303 |
+
Incident ID
|
| 304 |
+
"""
|
| 305 |
+
self.incidents.append(incident)
|
| 306 |
+
self.incident_vectors.append(incident.to_vector())
|
| 307 |
+
|
| 308 |
+
logger.info(f"Recall Agent: Added incident {incident.id} for {incident.component}")
|
| 309 |
+
return incident.id
|
| 310 |
+
|
| 311 |
+
async def find_similar(self, current_incident: Incident, k: int = 5) -> List[Dict[str, Any]]:
|
| 312 |
+
"""
|
| 313 |
+
Find similar incidents using vector similarity
|
| 314 |
+
|
| 315 |
+
Args:
|
| 316 |
+
current_incident: Current incident to compare against
|
| 317 |
+
k: Number of similar incidents to return
|
| 318 |
|
| 319 |
+
Returns:
|
| 320 |
+
List of similar incidents with similarity scores
|
| 321 |
+
"""
|
| 322 |
+
if not self.incidents:
|
| 323 |
+
return []
|
| 324 |
+
|
| 325 |
+
# Check cache first
|
| 326 |
+
cache_key = f"{current_incident.component}:{current_incident.anomaly.metric}"
|
| 327 |
+
if cache_key in self.similarity_cache:
|
| 328 |
+
return self.similarity_cache[cache_key][:k]
|
| 329 |
+
|
| 330 |
+
# Calculate similarity
|
| 331 |
+
current_vector = np.array(current_incident.to_vector())
|
| 332 |
+
similarities = []
|
| 333 |
+
|
| 334 |
+
for idx, (incident, vector) in enumerate(zip(self.incidents, self.incident_vectors)):
|
| 335 |
+
# Skip if component doesn't match (optional)
|
| 336 |
+
if current_incident.component != incident.component:
|
| 337 |
+
continue
|
| 338 |
+
|
| 339 |
+
# Calculate cosine similarity
|
| 340 |
+
incident_vector = np.array(vector)
|
| 341 |
+
if np.linalg.norm(current_vector) == 0 or np.linalg.norm(incident_vector) == 0:
|
| 342 |
+
similarity = 0.0
|
| 343 |
+
else:
|
| 344 |
+
similarity = np.dot(current_vector, incident_vector) / (
|
| 345 |
+
np.linalg.norm(current_vector) * np.linalg.norm(incident_vector)
|
| 346 |
+
)
|
| 347 |
|
| 348 |
+
# Get outcome if available
|
| 349 |
+
outcome = self.outcomes.get(incident.id, {})
|
| 350 |
+
success_rate = outcome.get("success_rate", 0.0)
|
| 351 |
+
resolution_time = outcome.get("resolution_time_minutes", 0.0)
|
|
|
|
| 352 |
|
| 353 |
+
similarities.append({
|
| 354 |
+
"incident": incident,
|
| 355 |
+
"similarity": float(similarity),
|
| 356 |
+
"success_rate": success_rate,
|
| 357 |
+
"resolution_time_minutes": resolution_time,
|
| 358 |
+
"index": idx
|
| 359 |
+
})
|
| 360 |
+
|
| 361 |
+
# Sort by similarity (descending)
|
| 362 |
+
similarities.sort(key=lambda x: x["similarity"], reverse=True)
|
| 363 |
+
|
| 364 |
+
# Convert to simplified format
|
| 365 |
+
results = []
|
| 366 |
+
for sim in similarities[:k]:
|
| 367 |
+
incident = sim["incident"]
|
| 368 |
+
results.append({
|
| 369 |
+
"incident_id": incident.id,
|
| 370 |
+
"component": incident.component,
|
| 371 |
+
"severity": incident.anomaly.severity,
|
| 372 |
+
"similarity_score": sim["similarity"],
|
| 373 |
+
"success_rate": sim["success_rate"],
|
| 374 |
+
"resolution_time_minutes": sim["resolution_time_minutes"],
|
| 375 |
+
"timestamp": incident.timestamp,
|
| 376 |
+
"anomaly_metric": incident.anomaly.metric,
|
| 377 |
+
"anomaly_value": incident.anomaly.value,
|
| 378 |
+
})
|
| 379 |
+
|
| 380 |
+
# Cache results
|
| 381 |
+
self.similarity_cache[cache_key] = results
|
| 382 |
+
|
| 383 |
+
logger.info(f"Recall Agent: Found {len(results)} similar incidents for {current_incident.component}")
|
| 384 |
+
return results
|
| 385 |
|
| 386 |
+
async def add_outcome(self, incident_id: str, success: bool,
|
| 387 |
+
resolution_action: str, resolution_time_minutes: float):
|
| 388 |
"""
|
| 389 |
+
Add resolution outcome to incident
|
| 390 |
|
| 391 |
+
Args:
|
| 392 |
+
incident_id: ID of the incident
|
| 393 |
+
success: Whether the resolution was successful
|
| 394 |
+
resolution_action: Action taken to resolve
|
| 395 |
+
resolution_time_minutes: Time taken to resolve
|
| 396 |
"""
|
| 397 |
+
# Find incident
|
| 398 |
+
incident_idx = -1
|
| 399 |
+
for idx, incident in enumerate(self.incidents):
|
| 400 |
+
if incident.id == incident_id:
|
| 401 |
+
incident_idx = idx
|
| 402 |
+
break
|
| 403 |
+
|
| 404 |
+
if incident_idx == -1:
|
| 405 |
+
logger.warning(f"Recall Agent: Incident {incident_id} not found for outcome")
|
| 406 |
+
return
|
| 407 |
+
|
| 408 |
+
# Update incident
|
| 409 |
+
self.incidents[incident_idx].resolved = True
|
| 410 |
+
self.incidents[incident_idx].resolution = resolution_action
|
| 411 |
+
|
| 412 |
+
# Store outcome
|
| 413 |
+
if incident_id not in self.outcomes:
|
| 414 |
+
self.outcomes[incident_id] = {
|
| 415 |
+
"successes": 0,
|
| 416 |
+
"attempts": 0,
|
| 417 |
+
"actions": [],
|
| 418 |
+
"resolution_times": []
|
| 419 |
}
|
| 420 |
|
| 421 |
+
self.outcomes[incident_id]["attempts"] += 1
|
| 422 |
+
if success:
|
| 423 |
+
self.outcomes[incident_id]["successes"] += 1
|
| 424 |
+
|
| 425 |
+
self.outcomes[incident_id]["actions"].append(resolution_action)
|
| 426 |
+
self.outcomes[incident_id]["resolution_times"].append(resolution_time_minutes)
|
| 427 |
+
|
| 428 |
+
# Update success rate
|
| 429 |
+
attempts = self.outcomes[incident_id]["attempts"]
|
| 430 |
+
successes = self.outcomes[incident_id]["successes"]
|
| 431 |
+
self.outcomes[incident_id]["success_rate"] = successes / attempts if attempts > 0 else 0.0
|
| 432 |
+
|
| 433 |
+
# Update average resolution time
|
| 434 |
+
times = self.outcomes[incident_id]["resolution_times"]
|
| 435 |
+
self.outcomes[incident_id]["resolution_time_minutes"] = sum(times) / len(times)
|
| 436 |
+
|
| 437 |
+
logger.info(f"Recall Agent: Added outcome for incident {incident_id} (success: {success})")
|
| 438 |
+
|
| 439 |
+
def get_memory_stats(self) -> Dict[str, Any]:
|
| 440 |
+
"""Get memory statistics"""
|
| 441 |
+
return {
|
| 442 |
+
"total_incidents": len(self.incidents),
|
| 443 |
+
"resolved_incidents": len([i for i in self.incidents if i.resolved]),
|
| 444 |
+
"outcomes_tracked": len(self.outcomes),
|
| 445 |
+
"cache_size": len(self.similarity_cache),
|
| 446 |
+
"vector_dimension": len(self.incident_vectors[0]) if self.incident_vectors else 0,
|
| 447 |
+
}
|
| 448 |
+
|
| 449 |
+
# ============================================================================
|
| 450 |
+
# DECISION AGENT
|
| 451 |
+
# ============================================================================
|
| 452 |
+
|
| 453 |
+
class DecisionAgent:
|
| 454 |
+
"""
|
| 455 |
+
Decision Agent - Generates healing intents based on analysis
|
| 456 |
+
|
| 457 |
+
Features:
|
| 458 |
+
- Confidence scoring
|
| 459 |
+
- Action selection
|
| 460 |
+
- Parameter optimization
|
| 461 |
+
- Safety validation
|
| 462 |
+
"""
|
| 463 |
+
|
| 464 |
+
def __init__(self, config: Optional[Dict[str, Any]] = None):
|
| 465 |
+
self.config = config or {}
|
| 466 |
+
|
| 467 |
+
# Action success rates (learned from history)
|
| 468 |
+
self.action_success_rates = {
|
| 469 |
+
"restart_container": 0.95,
|
| 470 |
+
"scale_out": 0.87,
|
| 471 |
+
"circuit_breaker": 0.92,
|
| 472 |
+
"traffic_shift": 0.85,
|
| 473 |
+
"rollback": 0.78,
|
| 474 |
+
"alert_team": 0.99,
|
| 475 |
+
}
|
| 476 |
+
|
| 477 |
+
# Action recommendations based on anomaly type
|
| 478 |
+
self.anomaly_to_action = {
|
| 479 |
+
"cpu_util": ["scale_out", "traffic_shift"],
|
| 480 |
+
"memory_util": ["scale_out", "restart_container"],
|
| 481 |
+
"error_rate": ["circuit_breaker", "rollback", "alert_team"],
|
| 482 |
+
"latency_p99": ["scale_out", "traffic_shift", "circuit_breaker"],
|
| 483 |
+
"throughput": ["scale_out", "traffic_shift"],
|
| 484 |
+
"correlated": ["alert_team", "scale_out", "restart_container"],
|
| 485 |
+
}
|
| 486 |
+
|
| 487 |
+
logger.info("Decision Agent initialized")
|
| 488 |
+
|
| 489 |
+
async def generate_healing_intent(
|
| 490 |
+
self,
|
| 491 |
+
anomaly: Anomaly,
|
| 492 |
+
similar_incidents: List[Dict[str, Any]],
|
| 493 |
+
context: Dict[str, Any]
|
| 494 |
+
) -> Dict[str, Any]:
|
| 495 |
+
"""
|
| 496 |
+
Generate healing intent based on anomaly and similar incidents
|
| 497 |
+
|
| 498 |
+
Args:
|
| 499 |
+
anomaly: Detected anomaly
|
| 500 |
+
similar_incidents: Similar historical incidents
|
| 501 |
+
context: Additional context
|
| 502 |
+
|
| 503 |
+
Returns:
|
| 504 |
+
Healing intent dictionary
|
| 505 |
+
"""
|
| 506 |
+
# Step 1: Select appropriate action
|
| 507 |
+
action = await self._select_action(anomaly, similar_incidents)
|
| 508 |
+
|
| 509 |
+
# Step 2: Calculate confidence
|
| 510 |
+
confidence = await self._calculate_confidence(anomaly, similar_incidents, action)
|
| 511 |
+
|
| 512 |
+
# Step 3: Determine parameters
|
| 513 |
+
parameters = await self._determine_parameters(anomaly, action, context)
|
| 514 |
+
|
| 515 |
+
# Step 4: Generate justification
|
| 516 |
+
justification = await self._generate_justification(anomaly, similar_incidents, action, confidence)
|
| 517 |
+
|
| 518 |
+
# Step 5: Create healing intent
|
| 519 |
+
healing_intent = {
|
| 520 |
+
"action": action,
|
| 521 |
+
"component": anomaly.component,
|
| 522 |
+
"parameters": parameters,
|
| 523 |
+
"confidence": confidence,
|
| 524 |
+
"justification": justification,
|
| 525 |
+
"anomaly_id": anomaly.id,
|
| 526 |
+
"anomaly_severity": anomaly.severity,
|
| 527 |
+
"similar_incidents_count": len(similar_incidents),
|
| 528 |
+
"similar_incidents_success_rate": self._calculate_average_success_rate(similar_incidents),
|
| 529 |
+
"requires_enterprise": True, # OSS boundary
|
| 530 |
+
"oss_advisory": True,
|
| 531 |
+
"timestamp": time.time(),
|
| 532 |
+
"arf_version": "3.3.7",
|
| 533 |
+
}
|
| 534 |
+
|
| 535 |
+
logger.info(f"Decision Agent: Generated {action} intent for {anomaly.component} (confidence: {confidence:.2f})")
|
| 536 |
+
return healing_intent
|
| 537 |
+
|
| 538 |
+
async def _select_action(self, anomaly: Anomaly,
|
| 539 |
+
similar_incidents: List[Dict[str, Any]]) -> str:
|
| 540 |
+
"""Select the most appropriate healing action"""
|
| 541 |
+
# Check similar incidents for successful actions
|
| 542 |
+
if similar_incidents:
|
| 543 |
+
# Group by action and calculate success rates
|
| 544 |
+
action_successes = {}
|
| 545 |
+
for incident in similar_incidents:
|
| 546 |
+
# Extract action from resolution (simplified)
|
| 547 |
+
resolution = incident.get("resolution", "")
|
| 548 |
+
success = incident.get("success_rate", 0.5) > 0.5
|
| 549 |
+
|
| 550 |
+
if resolution:
|
| 551 |
+
if resolution not in action_successes:
|
| 552 |
+
action_successes[resolution] = {"successes": 0, "total": 0}
|
| 553 |
+
|
| 554 |
+
action_successes[resolution]["total"] += 1
|
| 555 |
+
if success:
|
| 556 |
+
action_successes[resolution]["successes"] += 1
|
| 557 |
+
|
| 558 |
+
# Calculate success rates
|
| 559 |
+
for action, stats in action_successes.items():
|
| 560 |
+
success_rate = stats["successes"] / stats["total"] if stats["total"] > 0 else 0.0
|
| 561 |
+
action_successes[action]["rate"] = success_rate
|
| 562 |
+
|
| 563 |
+
# Select action with highest success rate
|
| 564 |
+
if action_successes:
|
| 565 |
+
best_action = max(action_successes.items(),
|
| 566 |
+
key=lambda x: x[1]["rate"])
|
| 567 |
+
return best_action[0]
|
| 568 |
+
|
| 569 |
+
# Fallback: Use anomaly-to-action mapping
|
| 570 |
+
candidate_actions = self.anomaly_to_action.get(anomaly.metric, ["alert_team"])
|
| 571 |
+
|
| 572 |
+
# Filter by severity
|
| 573 |
+
if anomaly.severity in ["critical", "high"]:
|
| 574 |
+
# Prefer more aggressive actions for severe anomalies
|
| 575 |
+
preferred_actions = ["scale_out", "circuit_breaker", "restart_container"]
|
| 576 |
+
candidate_actions = [a for a in candidate_actions if a in preferred_actions]
|
| 577 |
+
|
| 578 |
+
# Select action with highest success rate
|
| 579 |
+
if candidate_actions:
|
| 580 |
+
action_rates = [(a, self.action_success_rates.get(a, 0.5))
|
| 581 |
+
for a in candidate_actions]
|
| 582 |
+
return max(action_rates, key=lambda x: x[1])[0]
|
| 583 |
+
|
| 584 |
+
return "alert_team" # Default safe action
|
| 585 |
+
|
| 586 |
+
async def _calculate_confidence(self, anomaly: Anomaly,
|
| 587 |
+
similar_incidents: List[Dict[str, Any]],
|
| 588 |
+
selected_action: str) -> float:
|
| 589 |
+
"""Calculate confidence score for the selected action"""
|
| 590 |
+
base_confidence = anomaly.confidence * 0.8 # Start with detection confidence
|
| 591 |
+
|
| 592 |
+
# Boost for similar incidents
|
| 593 |
+
if similar_incidents:
|
| 594 |
+
avg_similarity = np.mean([i.get("similarity_score", 0.0)
|
| 595 |
+
for i in similar_incidents])
|
| 596 |
+
similarity_boost = avg_similarity * 0.3
|
| 597 |
+
base_confidence += similarity_boost
|
| 598 |
+
|
| 599 |
+
# Boost for successful similar incidents
|
| 600 |
+
avg_success = self._calculate_average_success_rate(similar_incidents)
|
| 601 |
+
success_boost = avg_success * 0.2
|
| 602 |
+
base_confidence += success_boost
|
| 603 |
+
|
| 604 |
+
# Adjust for action success rate
|
| 605 |
+
action_rate = self.action_success_rates.get(selected_action, 0.5)
|
| 606 |
+
action_factor = 0.5 + action_rate * 0.5 # Map 0-1 success rate to 0.5-1.0 factor
|
| 607 |
+
base_confidence *= action_factor
|
| 608 |
+
|
| 609 |
+
# Cap at 0.99 (never 100% certain)
|
| 610 |
+
return min(base_confidence, 0.99)
|
| 611 |
+
|
| 612 |
+
async def _determine_parameters(self, anomaly: Anomaly,
|
| 613 |
+
action: str, context: Dict[str, Any]) -> Dict[str, Any]:
|
| 614 |
+
"""Determine parameters for the healing action"""
|
| 615 |
+
parameters = {}
|
| 616 |
+
|
| 617 |
+
if action == "scale_out":
|
| 618 |
+
# Scale factor based on severity
|
| 619 |
+
severity_factor = {"low": 1, "medium": 2, "high": 3, "critical": 4}
|
| 620 |
+
scale_factor = severity_factor.get(anomaly.severity, 2)
|
| 621 |
+
|
| 622 |
+
parameters = {
|
| 623 |
+
"scale_factor": scale_factor,
|
| 624 |
+
"resource_profile": "standard",
|
| 625 |
+
"strategy": "gradual" if anomaly.severity in ["low", "medium"] else "immediate"
|
| 626 |
+
}
|
| 627 |
+
|
| 628 |
+
elif action == "restart_container":
|
| 629 |
+
parameters = {
|
| 630 |
+
"grace_period": 30,
|
| 631 |
+
"force": anomaly.severity == "critical"
|
| 632 |
+
}
|
| 633 |
+
|
| 634 |
+
elif action == "circuit_breaker":
|
| 635 |
+
parameters = {
|
| 636 |
+
"threshold": 0.5,
|
| 637 |
+
"timeout": 60,
|
| 638 |
+
"half_open_after": 300
|
| 639 |
+
}
|
| 640 |
+
|
| 641 |
+
elif action == "rollback":
|
| 642 |
+
parameters = {
|
| 643 |
+
"revision": "previous",
|
| 644 |
+
"verify": True
|
| 645 |
+
}
|
| 646 |
+
|
| 647 |
+
elif action == "traffic_shift":
|
| 648 |
+
parameters = {
|
| 649 |
+
"percentage": 50,
|
| 650 |
+
"target": "canary" if anomaly.severity in ["low", "medium"] else "stable"
|
| 651 |
+
}
|
| 652 |
+
|
| 653 |
+
elif action == "alert_team":
|
| 654 |
+
parameters = {
|
| 655 |
+
"severity": anomaly.severity,
|
| 656 |
+
"channels": ["slack", "email"],
|
| 657 |
+
"escalate_after_minutes": 5 if anomaly.severity == "critical" else 15
|
| 658 |
+
}
|
| 659 |
+
|
| 660 |
+
# Add context-specific parameters
|
| 661 |
+
if "environment" in context:
|
| 662 |
+
parameters["environment"] = context["environment"]
|
| 663 |
+
|
| 664 |
+
return parameters
|
| 665 |
+
|
| 666 |
+
async def _generate_justification(self, anomaly: Anomaly,
|
| 667 |
+
similar_incidents: List[Dict[str, Any]],
|
| 668 |
+
action: str, confidence: float) -> str:
|
| 669 |
+
"""Generate human-readable justification"""
|
| 670 |
+
|
| 671 |
+
if similar_incidents:
|
| 672 |
+
similar_count = len(similar_incidents)
|
| 673 |
+
avg_success = self._calculate_average_success_rate(similar_incidents)
|
| 674 |
+
|
| 675 |
+
return (
|
| 676 |
+
f"Detected {anomaly.severity} anomaly in {anomaly.component} ({anomaly.metric}: {anomaly.value:.2f}). "
|
| 677 |
+
f"Found {similar_count} similar historical incidents with {avg_success:.0%} average success rate. "
|
| 678 |
+
f"Recommended action '{action}' with {confidence:.0%} confidence based on pattern matching."
|
| 679 |
+
)
|
| 680 |
+
else:
|
| 681 |
+
return (
|
| 682 |
+
f"Detected {anomaly.severity} anomaly in {anomaly.component} ({anomaly.metric}: {anomaly.value:.2f}). "
|
| 683 |
+
f"No similar historical incidents found. "
|
| 684 |
+
f"Recommended action '{action}' with {confidence:.0%} confidence based on anomaly characteristics."
|
| 685 |
+
)
|
| 686 |
+
|
| 687 |
+
def _calculate_average_success_rate(self, similar_incidents: List[Dict[str, Any]]) -> float:
|
| 688 |
+
"""Calculate average success rate from similar incidents"""
|
| 689 |
+
if not similar_incidents:
|
| 690 |
+
return 0.0
|
| 691 |
+
|
| 692 |
+
success_rates = [inc.get("success_rate", 0.0) for inc in similar_incidents]
|
| 693 |
+
return sum(success_rates) / len(success_rates)
|
| 694 |
+
|
| 695 |
+
def update_success_rate(self, action: str, success: bool):
|
| 696 |
+
"""Update action success rate based on outcome"""
|
| 697 |
+
if action not in self.action_success_rates:
|
| 698 |
+
self.action_success_rates[action] = 0.5
|
| 699 |
+
|
| 700 |
+
current_rate = self.action_success_rates[action]
|
| 701 |
+
# Simple moving average update
|
| 702 |
+
if success:
|
| 703 |
+
new_rate = current_rate * 0.9 + 0.1
|
| 704 |
+
else:
|
| 705 |
+
new_rate = current_rate * 0.9
|
| 706 |
+
|
| 707 |
+
self.action_success_rates[action] = new_rate
|
| 708 |
+
logger.info(f"Decision Agent: Updated {action} success rate to {new_rate:.2f}")
|
| 709 |
+
|
| 710 |
+
# ============================================================================
|
| 711 |
+
# TRUE ARF OSS INTEGRATION
|
| 712 |
+
# ============================================================================
|
| 713 |
+
|
| 714 |
+
class TrueARFOSS:
|
| 715 |
+
"""
|
| 716 |
+
True ARF OSS v3.3.7 - Complete integration of all agents
|
| 717 |
+
|
| 718 |
+
This is the class that TrueARF337Orchestrator expects to import.
|
| 719 |
+
Provides real ARF OSS functionality for the demo.
|
| 720 |
+
"""
|
| 721 |
+
|
| 722 |
+
def __init__(self, config: Optional[Dict[str, Any]] = None):
|
| 723 |
+
self.config = config or {}
|
| 724 |
+
self.detection_agent = DetectionAgent(config)
|
| 725 |
+
self.recall_agent = RecallAgent(config)
|
| 726 |
+
self.decision_agent = DecisionAgent(config)
|
| 727 |
+
self.oss_available = True
|
| 728 |
+
|
| 729 |
+
logger.info("True ARF OSS v3.3.7 initialized")
|
| 730 |
+
|
| 731 |
+
async def analyze_scenario(self, scenario_name: str,
|
| 732 |
+
scenario_data: Dict[str, Any]) -> Dict[str, Any]:
|
| 733 |
+
"""
|
| 734 |
+
Complete ARF analysis for a scenario
|
| 735 |
+
|
| 736 |
+
Args:
|
| 737 |
+
scenario_name: Name of the scenario
|
| 738 |
+
scenario_data: Scenario data including telemetry and context
|
| 739 |
+
|
| 740 |
+
Returns:
|
| 741 |
+
Complete analysis result
|
| 742 |
+
"""
|
| 743 |
+
start_time = time.time()
|
| 744 |
|
| 745 |
try:
|
| 746 |
+
# Extract component and telemetry from scenario
|
| 747 |
+
component = scenario_data.get("component", "unknown")
|
| 748 |
+
telemetry_data = scenario_data.get("telemetry", [])
|
| 749 |
+
context = scenario_data.get("context", {})
|
| 750 |
+
|
| 751 |
+
# Convert telemetry data to TelemetryPoint objects
|
| 752 |
+
telemetry = []
|
| 753 |
+
for point in telemetry_data:
|
| 754 |
+
telemetry.append(TelemetryPoint(
|
| 755 |
+
timestamp=point.get("timestamp", time.time()),
|
| 756 |
+
metric=point.get("metric", "unknown"),
|
| 757 |
+
value=point.get("value", 0.0),
|
| 758 |
+
component=component
|
| 759 |
+
))
|
| 760 |
+
|
| 761 |
+
# Step 1: Detection Agent - Find anomalies
|
| 762 |
+
logger.info(f"True ARF OSS: Running detection for {scenario_name}")
|
| 763 |
+
anomalies = await self.detection_agent.analyze_telemetry(component, telemetry)
|
| 764 |
+
|
| 765 |
+
if not anomalies:
|
| 766 |
+
# No anomalies detected
|
| 767 |
+
return {
|
| 768 |
+
"status": "success",
|
| 769 |
"scenario": scenario_name,
|
| 770 |
+
"result": "no_anomalies_detected",
|
| 771 |
+
"analysis_time_ms": (time.time() - start_time) * 1000,
|
| 772 |
+
"arf_version": "3.3.7",
|
| 773 |
+
"oss_edition": True
|
| 774 |
}
|
|
|
|
| 775 |
|
| 776 |
+
# Use the most severe anomaly
|
| 777 |
+
anomaly = max(anomalies, key=lambda a: a.confidence)
|
|
|
|
| 778 |
|
| 779 |
+
# Create incident for RAG memory
|
| 780 |
+
incident = Incident(
|
| 781 |
+
id=str(uuid.uuid4()),
|
| 782 |
+
component=component,
|
| 783 |
+
anomaly=anomaly,
|
| 784 |
+
telemetry=telemetry[-10:], # Last 10 telemetry points
|
| 785 |
+
context=context
|
| 786 |
+
)
|
| 787 |
|
| 788 |
+
# Step 2: Recall Agent - Find similar incidents
|
| 789 |
+
logger.info(f"True ARF OSS: Searching for similar incidents for {scenario_name}")
|
| 790 |
+
similar_incidents = await self.recall_agent.find_similar(incident, k=5)
|
| 791 |
|
| 792 |
+
# Add incident to memory
|
| 793 |
+
await self.recall_agent.add_incident(incident)
|
| 794 |
+
|
| 795 |
+
# Step 3: Decision Agent - Generate healing intent
|
| 796 |
+
logger.info(f"True ARF OSS: Generating healing intent for {scenario_name}")
|
| 797 |
+
healing_intent = await self.decision_agent.generate_healing_intent(
|
| 798 |
+
anomaly, similar_incidents, context
|
| 799 |
)
|
| 800 |
|
| 801 |
+
# Calculate analysis metrics
|
| 802 |
+
analysis_time_ms = (time.time() - start_time) * 1000
|
| 803 |
|
| 804 |
+
# Create comprehensive result
|
| 805 |
result = {
|
| 806 |
"status": "success",
|
| 807 |
"scenario": scenario_name,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 808 |
"analysis": {
|
| 809 |
+
"detection": {
|
| 810 |
+
"anomaly_found": True,
|
| 811 |
+
"anomaly_id": anomaly.id,
|
| 812 |
+
"metric": anomaly.metric,
|
| 813 |
+
"value": anomaly.value,
|
| 814 |
+
"confidence": anomaly.confidence,
|
| 815 |
+
"severity": anomaly.severity,
|
| 816 |
+
"detection_time_ms": analysis_time_ms * 0.3, # Estimated
|
| 817 |
+
},
|
| 818 |
+
"recall": similar_incidents,
|
| 819 |
+
"decision": healing_intent,
|
| 820 |
},
|
| 821 |
"capabilities": {
|
| 822 |
+
"execution_allowed": False, # OSS boundary
|
| 823 |
+
"mcp_modes": ["advisory"],
|
| 824 |
+
"oss_boundary": "advisory_only",
|
| 825 |
+
"requires_enterprise": True,
|
| 826 |
},
|
| 827 |
+
"agents_used": ["Detection", "Recall", "Decision"],
|
| 828 |
+
"analysis_time_ms": analysis_time_ms,
|
| 829 |
+
"arf_version": "3.3.7",
|
| 830 |
+
"oss_edition": True,
|
| 831 |
+
"demo_display": {
|
| 832 |
+
"real_arf_version": "3.3.7",
|
| 833 |
+
"true_oss_used": True,
|
| 834 |
+
"enterprise_simulated": False,
|
| 835 |
+
"agent_details": {
|
| 836 |
+
"detection_confidence": anomaly.confidence,
|
| 837 |
+
"similar_incidents_count": len(similar_incidents),
|
| 838 |
+
"decision_confidence": healing_intent["confidence"],
|
| 839 |
+
"healing_action": healing_intent["action"],
|
| 840 |
+
}
|
| 841 |
+
}
|
| 842 |
}
|
| 843 |
|
| 844 |
+
logger.info(f"True ARF OSS: Analysis complete for {scenario_name} "
|
| 845 |
+
f"({analysis_time_ms:.1f}ms)")
|
| 846 |
return result
|
| 847 |
|
| 848 |
except Exception as e:
|
| 849 |
+
logger.error(f"True ARF OSS analysis failed: {e}", exc_info=True)
|
| 850 |
return {
|
| 851 |
"status": "error",
|
| 852 |
"error": str(e),
|
| 853 |
"scenario": scenario_name,
|
| 854 |
+
"analysis_time_ms": (time.time() - start_time) * 1000,
|
| 855 |
+
"arf_version": "3.3.7",
|
| 856 |
+
"oss_edition": True,
|
| 857 |
+
"demo_display": {
|
| 858 |
+
"real_arf_version": "3.3.7",
|
| 859 |
+
"true_oss_used": True,
|
| 860 |
+
"error": str(e)[:100]
|
| 861 |
+
}
|
| 862 |
}
|
| 863 |
|
| 864 |
+
def get_agent_stats(self) -> Dict[str, Any]:
|
| 865 |
+
"""Get statistics from all agents"""
|
|
|
|
|
|
|
|
|
|
| 866 |
return {
|
| 867 |
+
"detection": self.detection_agent.get_detection_stats(),
|
| 868 |
+
"recall": self.recall_agent.get_memory_stats(),
|
| 869 |
+
"decision": {
|
| 870 |
+
"action_success_rates": self.decision_agent.action_success_rates
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 871 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 872 |
"oss_available": self.oss_available,
|
| 873 |
"arf_version": "3.3.7",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 874 |
}
|
| 875 |
|
| 876 |
+
# ============================================================================
|
| 877 |
+
# FACTORY FUNCTION
|
| 878 |
+
# ============================================================================
|
| 879 |
|
| 880 |
+
async def get_true_arf_oss(config: Optional[Dict[str, Any]] = None) -> TrueARFOSS:
|
| 881 |
+
"""
|
| 882 |
+
Factory function for TrueARFOSS
|
| 883 |
+
|
| 884 |
+
This is the function that TrueARF337Orchestrator expects to call.
|
| 885 |
+
|
| 886 |
+
Args:
|
| 887 |
+
config: Optional configuration
|
| 888 |
+
|
| 889 |
+
Returns:
|
| 890 |
+
TrueARFOSS instance
|
| 891 |
+
"""
|
| 892 |
+
return TrueARFOSS(config)
|
| 893 |
|
| 894 |
+
# ============================================================================
|
| 895 |
+
# SIMPLE MOCK FOR BACKWARDS COMPATIBILITY
|
| 896 |
+
# ============================================================================
|
| 897 |
|
| 898 |
+
async def get_mock_true_arf_oss(config: Optional[Dict[str, Any]] = None) -> TrueARFOSS:
|
| 899 |
+
"""
|
| 900 |
+
Mock version for when dependencies are missing
|
| 901 |
+
"""
|
| 902 |
+
logger.warning("Using mock TrueARFOSS - real implementation not available")
|
| 903 |
+
|
| 904 |
+
class MockTrueARFOSS:
|
| 905 |
+
def __init__(self, config):
|
| 906 |
+
self.config = config or {}
|
| 907 |
+
self.oss_available = False
|
| 908 |
+
|
| 909 |
+
async def analyze_scenario(self, scenario_name, scenario_data):
|
| 910 |
+
return {
|
| 911 |
+
"status": "mock",
|
| 912 |
+
"scenario": scenario_name,
|
| 913 |
+
"message": "Mock analysis - install true ARF OSS v3.3.7 for real analysis",
|
| 914 |
+
"demo_display": {
|
| 915 |
+
"real_arf_version": "mock",
|
| 916 |
+
"true_oss_used": False,
|
| 917 |
+
"enterprise_simulated": False,
|
| 918 |
+
}
|
| 919 |
+
}
|
| 920 |
+
|
| 921 |
+
return MockTrue
|