Update core/true_arf_orchestrator.py
Browse files- core/true_arf_orchestrator.py +67 -40
core/true_arf_orchestrator.py
CHANGED
|
@@ -29,6 +29,9 @@ class TrueARF337Orchestrator:
|
|
| 29 |
except ImportError as e:
|
| 30 |
logger.warning(f"True ARF OSS not available: {e}")
|
| 31 |
self.true_oss = None
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
try:
|
| 34 |
from core.enterprise_simulation import get_enterprise_simulation
|
|
@@ -37,6 +40,9 @@ class TrueARF337Orchestrator:
|
|
| 37 |
except ImportError as e:
|
| 38 |
logger.warning(f"Enterprise simulation not available: {e}")
|
| 39 |
self.enterprise_sim = None
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
async def analyze_incident(self, scenario_name: str, scenario_data: Dict[str, Any]) -> Dict[str, Any]:
|
| 42 |
"""
|
|
@@ -50,19 +56,31 @@ class TrueARF337Orchestrator:
|
|
| 50 |
# Step 1: Run true OSS analysis
|
| 51 |
oss_analysis = None
|
| 52 |
if self.true_oss:
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
else:
|
| 56 |
# Fallback to mock
|
| 57 |
oss_analysis = await self._fallback_oss_analysis(scenario_name, scenario_data)
|
| 58 |
|
| 59 |
# Step 2: Enhance with Enterprise features (simulation)
|
| 60 |
enterprise_enhancements = None
|
| 61 |
-
if self.enterprise_sim and oss_analysis.get("status") == "success":
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
# Combine results
|
| 68 |
result = {
|
|
@@ -82,43 +100,52 @@ class TrueARF337Orchestrator:
|
|
| 82 |
logger.error(f"Analysis failed: {e}", exc_info=True)
|
| 83 |
return {
|
| 84 |
"status": "error",
|
| 85 |
-
"error": str(e),
|
| 86 |
-
"scenario": scenario_name
|
|
|
|
| 87 |
}
|
| 88 |
|
| 89 |
async def _fallback_oss_analysis(self, scenario_name: str, scenario_data: Dict[str, Any]) -> Dict[str, Any]:
|
| 90 |
"""Fallback mock analysis"""
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
"
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
"
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
def _get_recommendation(self, oss_analysis: Dict, enterprise_enhancements: Dict) -> str:
|
| 124 |
"""Generate recommendation based on analysis"""
|
|
|
|
| 29 |
except ImportError as e:
|
| 30 |
logger.warning(f"True ARF OSS not available: {e}")
|
| 31 |
self.true_oss = None
|
| 32 |
+
except Exception as e:
|
| 33 |
+
logger.error(f"Error initializing True ARF OSS: {e}")
|
| 34 |
+
self.true_oss = None
|
| 35 |
|
| 36 |
try:
|
| 37 |
from core.enterprise_simulation import get_enterprise_simulation
|
|
|
|
| 40 |
except ImportError as e:
|
| 41 |
logger.warning(f"Enterprise simulation not available: {e}")
|
| 42 |
self.enterprise_sim = None
|
| 43 |
+
except Exception as e:
|
| 44 |
+
logger.error(f"Error initializing Enterprise simulation: {e}")
|
| 45 |
+
self.enterprise_sim = None
|
| 46 |
|
| 47 |
async def analyze_incident(self, scenario_name: str, scenario_data: Dict[str, Any]) -> Dict[str, Any]:
|
| 48 |
"""
|
|
|
|
| 56 |
# Step 1: Run true OSS analysis
|
| 57 |
oss_analysis = None
|
| 58 |
if self.true_oss:
|
| 59 |
+
try:
|
| 60 |
+
true_oss_instance = await self.true_oss()
|
| 61 |
+
if hasattr(true_oss_instance, 'oss_available') and true_oss_instance.oss_available:
|
| 62 |
+
oss_analysis = await true_oss_instance.analyze_scenario(scenario_name, scenario_data)
|
| 63 |
+
else:
|
| 64 |
+
logger.warning("True ARF OSS not available - using fallback mock")
|
| 65 |
+
oss_analysis = await self._fallback_oss_analysis(scenario_name, scenario_data)
|
| 66 |
+
except Exception as e:
|
| 67 |
+
logger.error(f"Error in true OSS analysis: {e}")
|
| 68 |
+
oss_analysis = await self._fallback_oss_analysis(scenario_name, scenario_data)
|
| 69 |
else:
|
| 70 |
# Fallback to mock
|
| 71 |
oss_analysis = await self._fallback_oss_analysis(scenario_name, scenario_data)
|
| 72 |
|
| 73 |
# Step 2: Enhance with Enterprise features (simulation)
|
| 74 |
enterprise_enhancements = None
|
| 75 |
+
if self.enterprise_sim and oss_analysis and oss_analysis.get("status") == "success":
|
| 76 |
+
try:
|
| 77 |
+
enterprise_instance = await self.enterprise_sim()
|
| 78 |
+
enterprise_enhancements = await enterprise_instance.enhance_oss_analysis(
|
| 79 |
+
oss_analysis, scenario_name
|
| 80 |
+
)
|
| 81 |
+
except Exception as e:
|
| 82 |
+
logger.error(f"Error in enterprise enhancement: {e}")
|
| 83 |
+
# Continue without enterprise enhancements
|
| 84 |
|
| 85 |
# Combine results
|
| 86 |
result = {
|
|
|
|
| 100 |
logger.error(f"Analysis failed: {e}", exc_info=True)
|
| 101 |
return {
|
| 102 |
"status": "error",
|
| 103 |
+
"error": f"Analysis failed: {str(e)}", # Make sure error is a string
|
| 104 |
+
"scenario": scenario_name,
|
| 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:
|
| 111 |
+
# Use existing mock ARF with scenario-aware metrics
|
| 112 |
+
from demo.mock_arf import (
|
| 113 |
+
simulate_arf_analysis,
|
| 114 |
+
run_rag_similarity_search,
|
| 115 |
+
calculate_pattern_confidence,
|
| 116 |
+
create_mock_healing_intent
|
| 117 |
+
)
|
| 118 |
+
|
| 119 |
+
scenario_data_with_name = scenario_data.copy()
|
| 120 |
+
scenario_data_with_name["name"] = scenario_name
|
| 121 |
+
|
| 122 |
+
detection = simulate_arf_analysis(scenario_data_with_name)
|
| 123 |
+
recall = run_rag_similarity_search(scenario_data_with_name)
|
| 124 |
+
confidence = calculate_pattern_confidence(scenario_data_with_name, recall)
|
| 125 |
+
decision = create_mock_healing_intent(scenario_data_with_name, recall, confidence)
|
| 126 |
+
|
| 127 |
+
return {
|
| 128 |
+
"status": "success",
|
| 129 |
+
"scenario": scenario_name,
|
| 130 |
+
"analysis": {
|
| 131 |
+
"detection": detection,
|
| 132 |
+
"recall": recall,
|
| 133 |
+
"decision": decision
|
| 134 |
+
},
|
| 135 |
+
"capabilities": {
|
| 136 |
+
"execution_allowed": False,
|
| 137 |
+
"mcp_modes": ["advisory"],
|
| 138 |
+
"oss_boundary": "advisory_only"
|
| 139 |
+
},
|
| 140 |
+
"note": "Using fallback mock analysis"
|
| 141 |
+
}
|
| 142 |
+
except Exception as e:
|
| 143 |
+
logger.error(f"Fallback analysis failed: {e}")
|
| 144 |
+
return {
|
| 145 |
+
"status": "error",
|
| 146 |
+
"error": f"Fallback analysis failed: {str(e)}",
|
| 147 |
+
"scenario": scenario_name
|
| 148 |
+
}
|
| 149 |
|
| 150 |
def _get_recommendation(self, oss_analysis: Dict, enterprise_enhancements: Dict) -> str:
|
| 151 |
"""Generate recommendation based on analysis"""
|