Update core/true_arf_orchestrator.py
Browse files- core/true_arf_orchestrator.py +125 -1
core/true_arf_orchestrator.py
CHANGED
|
@@ -4,7 +4,9 @@ Updated orchestrator that combines:
|
|
| 4 |
2. Enterprise simulation to show value proposition
|
| 5 |
"""
|
| 6 |
import logging
|
|
|
|
| 7 |
from typing import Dict, Any
|
|
|
|
| 8 |
|
| 9 |
logger = logging.getLogger(__name__)
|
| 10 |
|
|
@@ -18,6 +20,8 @@ class TrueARF337Orchestrator:
|
|
| 18 |
def __init__(self):
|
| 19 |
self.true_oss = None
|
| 20 |
self.enterprise_sim = None
|
|
|
|
|
|
|
| 21 |
self._initialize_components()
|
| 22 |
|
| 23 |
def _initialize_components(self):
|
|
@@ -82,6 +86,13 @@ class TrueARF337Orchestrator:
|
|
| 82 |
logger.error(f"Error in enterprise enhancement: {e}")
|
| 83 |
# Continue without enterprise enhancements
|
| 84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
# Combine results
|
| 86 |
result = {
|
| 87 |
"status": "success",
|
|
@@ -105,6 +116,114 @@ class TrueARF337Orchestrator:
|
|
| 105 |
"suggestion": "Check logs for details"
|
| 106 |
}
|
| 107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
async def _fallback_oss_analysis(self, scenario_name: str, scenario_data: Dict[str, Any]) -> Dict[str, Any]:
|
| 109 |
"""Fallback mock analysis"""
|
| 110 |
try:
|
|
@@ -157,4 +276,9 @@ class TrueARF337Orchestrator:
|
|
| 157 |
elif enterprise_enhancements:
|
| 158 |
return "β
OSS analysis complete. β‘ Enterprise features simulated - shows upgrade value. Contact sales@arf.dev for Enterprise trial."
|
| 159 |
else:
|
| 160 |
-
return "β
OSS analysis complete. Install agentic-reliability-framework==3.3.7 for real advisory capabilities."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
2. Enterprise simulation to show value proposition
|
| 5 |
"""
|
| 6 |
import logging
|
| 7 |
+
import time
|
| 8 |
from typing import Dict, Any
|
| 9 |
+
from datetime import datetime, timedelta
|
| 10 |
|
| 11 |
logger = logging.getLogger(__name__)
|
| 12 |
|
|
|
|
| 20 |
def __init__(self):
|
| 21 |
self.true_oss = None
|
| 22 |
self.enterprise_sim = None
|
| 23 |
+
self.arf_analysis_results = {} # Store analysis results for execution
|
| 24 |
+
self.audit_trail_manager = None # Will be set by app
|
| 25 |
self._initialize_components()
|
| 26 |
|
| 27 |
def _initialize_components(self):
|
|
|
|
| 86 |
logger.error(f"Error in enterprise enhancement: {e}")
|
| 87 |
# Continue without enterprise enhancements
|
| 88 |
|
| 89 |
+
# Store analysis result for potential execution
|
| 90 |
+
self.arf_analysis_results[scenario_name] = {
|
| 91 |
+
"oss_analysis": oss_analysis,
|
| 92 |
+
"enterprise_enhancements": enterprise_enhancements,
|
| 93 |
+
"timestamp": datetime.now().isoformat()
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
# Combine results
|
| 97 |
result = {
|
| 98 |
"status": "success",
|
|
|
|
| 116 |
"suggestion": "Check logs for details"
|
| 117 |
}
|
| 118 |
|
| 119 |
+
async def execute_healing(self, scenario_name: str, mode: str = "autonomous") -> Dict[str, Any]:
|
| 120 |
+
"""
|
| 121 |
+
Execute enterprise healing for a given scenario.
|
| 122 |
+
|
| 123 |
+
Args:
|
| 124 |
+
scenario_name: Name of the scenario to heal
|
| 125 |
+
mode: Execution mode ("autonomous", "approval", "manual")
|
| 126 |
+
|
| 127 |
+
Returns:
|
| 128 |
+
Dict with execution results
|
| 129 |
+
"""
|
| 130 |
+
try:
|
| 131 |
+
# Log execution start
|
| 132 |
+
logger.info(f"β‘ Executing enterprise healing for: {scenario_name} (mode: {mode})")
|
| 133 |
+
|
| 134 |
+
# Get the latest analysis for this scenario
|
| 135 |
+
if not self.arf_analysis_results or scenario_name not in self.arf_analysis_results:
|
| 136 |
+
# Run analysis first if not available
|
| 137 |
+
logger.warning(f"No analysis found for {scenario_name}, running analysis first")
|
| 138 |
+
await self.analyze_incident(scenario_name, {})
|
| 139 |
+
|
| 140 |
+
# Get the analysis result
|
| 141 |
+
analysis_result = self.arf_analysis_results.get(scenario_name, {})
|
| 142 |
+
oss_analysis = analysis_result.get("oss_analysis", {})
|
| 143 |
+
|
| 144 |
+
# Extract healing intent from analysis
|
| 145 |
+
healing_intent = {}
|
| 146 |
+
if oss_analysis and "analysis" in oss_analysis and "decision" in oss_analysis["analysis"]:
|
| 147 |
+
healing_intent = oss_analysis["analysis"]["decision"]
|
| 148 |
+
elif oss_analysis and "healing_intent" in oss_analysis:
|
| 149 |
+
healing_intent = oss_analysis["healing_intent"]
|
| 150 |
+
|
| 151 |
+
# Simulate enterprise execution with proper boundaries
|
| 152 |
+
enterprise_result = {
|
| 153 |
+
"status": "success",
|
| 154 |
+
"mode": mode,
|
| 155 |
+
"scenario": scenario_name,
|
| 156 |
+
"execution_id": f"exe_{int(time.time())}_{scenario_name.lower().replace(' ', '_')}",
|
| 157 |
+
"timestamp": datetime.now().isoformat(),
|
| 158 |
+
"boundary": "Enterprise Simulation",
|
| 159 |
+
"enterprise_features_used": [
|
| 160 |
+
"AutonomousExecutionEngine",
|
| 161 |
+
"SafetyOrchestrator",
|
| 162 |
+
"ComplianceGuardrails",
|
| 163 |
+
"RealTimeTelemetry",
|
| 164 |
+
"LearningEngineIntegration"
|
| 165 |
+
],
|
| 166 |
+
"execution_summary": {
|
| 167 |
+
"action": healing_intent.get("action", "Scale infrastructure"),
|
| 168 |
+
"target": healing_intent.get("target", "redis_cache"),
|
| 169 |
+
"parameters": healing_intent.get("parameters", {}),
|
| 170 |
+
"confidence": oss_analysis.get("analysis", {}).get("decision", {}).get("confidence", 0.85)
|
| 171 |
+
if oss_analysis else 0.85,
|
| 172 |
+
"estimated_duration": "12 minutes",
|
| 173 |
+
"blast_radius": "2 services",
|
| 174 |
+
"safety_checks_passed": True
|
| 175 |
+
},
|
| 176 |
+
"business_impact": {
|
| 177 |
+
"mttr_reduction": "73% faster (45m β 12m)",
|
| 178 |
+
"cost_saved": 6375,
|
| 179 |
+
"revenue_protected": 8500,
|
| 180 |
+
"users_protected": 45000,
|
| 181 |
+
"incidents_prevented": 3
|
| 182 |
+
},
|
| 183 |
+
"telemetry": {
|
| 184 |
+
"start_time": datetime.now().isoformat(),
|
| 185 |
+
"end_time": (datetime.now() + timedelta(minutes=12)).isoformat(),
|
| 186 |
+
"resources_affected": ["redis_node_1", "redis_node_2"],
|
| 187 |
+
"rollback_available": True,
|
| 188 |
+
"audit_trail_enabled": True
|
| 189 |
+
},
|
| 190 |
+
"notes": [
|
| 191 |
+
"β
Enterprise execution simulation complete",
|
| 192 |
+
"π Safety boundaries enforced via MCP",
|
| 193 |
+
"π Real-time telemetry active",
|
| 194 |
+
"π§ Learning engine updated with outcome",
|
| 195 |
+
"πΎ Audit trail recorded"
|
| 196 |
+
]
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
# Record execution in audit trail if manager is available
|
| 200 |
+
if self.audit_trail_manager:
|
| 201 |
+
try:
|
| 202 |
+
self.audit_trail_manager.record_execution(
|
| 203 |
+
execution_id=enterprise_result["execution_id"],
|
| 204 |
+
scenario_name=scenario_name,
|
| 205 |
+
status="success",
|
| 206 |
+
mode=mode,
|
| 207 |
+
details=enterprise_result
|
| 208 |
+
)
|
| 209 |
+
except Exception as e:
|
| 210 |
+
logger.warning(f"Could not record execution in audit trail: {e}")
|
| 211 |
+
|
| 212 |
+
logger.info(f"β
Enterprise healing execution simulated for {scenario_name}")
|
| 213 |
+
return enterprise_result
|
| 214 |
+
|
| 215 |
+
except Exception as e:
|
| 216 |
+
logger.error(f"β Enterprise healing execution failed: {e}")
|
| 217 |
+
return {
|
| 218 |
+
"status": "failed",
|
| 219 |
+
"error": str(e),
|
| 220 |
+
"scenario": scenario_name,
|
| 221 |
+
"mode": mode,
|
| 222 |
+
"timestamp": datetime.now().isoformat(),
|
| 223 |
+
"boundary": "Enterprise Simulation Failed",
|
| 224 |
+
"notes": ["Execution failed in simulation mode"]
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
async def _fallback_oss_analysis(self, scenario_name: str, scenario_data: Dict[str, Any]) -> Dict[str, Any]:
|
| 228 |
"""Fallback mock analysis"""
|
| 229 |
try:
|
|
|
|
| 276 |
elif enterprise_enhancements:
|
| 277 |
return "β
OSS analysis complete. β‘ Enterprise features simulated - shows upgrade value. Contact sales@arf.dev for Enterprise trial."
|
| 278 |
else:
|
| 279 |
+
return "β
OSS analysis complete. Install agentic-reliability-framework==3.3.7 for real advisory capabilities."
|
| 280 |
+
|
| 281 |
+
def set_audit_trail_manager(self, manager):
|
| 282 |
+
"""Set audit trail manager for recording executions."""
|
| 283 |
+
self.audit_trail_manager = manager
|
| 284 |
+
logger.info("β
Audit trail manager connected to orchestrator")
|