petter2025 commited on
Commit
1567ae5
·
verified ·
1 Parent(s): ff55846

Create true_arf_orchestrator.py

Browse files
Files changed (1) hide show
  1. core/true_arf_orchestrator.py +133 -0
core/true_arf_orchestrator.py ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Updated orchestrator that combines:
3
+ 1. True ARF OSS v3.3.7 for real advisory analysis
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
+
11
+ class TrueARF337Orchestrator:
12
+ """
13
+ True ARF v3.3.7 orchestrator with:
14
+ - Real OSS package for advisory analysis
15
+ - Enterprise simulation to show upgrade value
16
+ """
17
+
18
+ def __init__(self):
19
+ self.true_oss = None
20
+ self.enterprise_sim = None
21
+ self._initialize_components()
22
+
23
+ def _initialize_components(self):
24
+ """Initialize true ARF components"""
25
+ try:
26
+ from core.true_arf_oss import get_true_arf_oss
27
+ self.true_oss = get_true_arf_oss
28
+ logger.info("✅ True ARF OSS v3.3.7 component available")
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
35
+ self.enterprise_sim = get_enterprise_simulation
36
+ logger.info("✅ Enterprise simulation component available")
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
+ """
43
+ Complete analysis using:
44
+ 1. True ARF OSS v3.3.7 for real advisory analysis
45
+ 2. Enterprise simulation to show upgrade value
46
+ """
47
+ logger.info(f"Running true ARF v3.3.7 analysis for: {scenario_name}")
48
+
49
+ try:
50
+ # Step 1: Run true OSS analysis
51
+ oss_analysis = None
52
+ if self.true_oss:
53
+ true_oss_instance = await self.true_oss()
54
+ oss_analysis = await true_oss_instance.analyze_scenario(scenario_name, scenario_data)
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
+ enterprise_instance = await self.enterprise_sim()
63
+ enterprise_enhancements = await enterprise_instance.enhance_oss_analysis(
64
+ oss_analysis, scenario_name
65
+ )
66
+
67
+ # Combine results
68
+ result = {
69
+ "status": "success",
70
+ "scenario": scenario_name,
71
+ "arf_version": "3.3.7",
72
+ "true_oss_used": self.true_oss is not None,
73
+ "enterprise_simulated": self.enterprise_sim is not None,
74
+ "oss_analysis": oss_analysis,
75
+ "enterprise_enhancements": enterprise_enhancements,
76
+ "recommendation": self._get_recommendation(oss_analysis, enterprise_enhancements)
77
+ }
78
+
79
+ return result
80
+
81
+ except Exception as e:
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
+ # Use existing mock ARF with scenario-aware metrics
92
+ from demo.mock_arf import (
93
+ simulate_arf_analysis,
94
+ run_rag_similarity_search,
95
+ calculate_pattern_confidence,
96
+ create_mock_healing_intent
97
+ )
98
+
99
+ scenario_data_with_name = scenario_data.copy()
100
+ scenario_data_with_name["name"] = scenario_name
101
+
102
+ detection = simulate_arf_analysis(scenario_data_with_name)
103
+ recall = run_rag_similarity_search(scenario_data_with_name)
104
+ confidence = calculate_pattern_confidence(scenario_data_with_name, recall)
105
+ decision = create_mock_healing_intent(scenario_data_with_name, recall, confidence)
106
+
107
+ return {
108
+ "status": "success",
109
+ "scenario": scenario_name,
110
+ "analysis": {
111
+ "detection": detection,
112
+ "recall": recall,
113
+ "decision": decision
114
+ },
115
+ "capabilities": {
116
+ "execution_allowed": False,
117
+ "mcp_modes": ["advisory"],
118
+ "oss_boundary": "advisory_only"
119
+ },
120
+ "note": "Using fallback mock analysis"
121
+ }
122
+
123
+ def _get_recommendation(self, oss_analysis: Dict, enterprise_enhancements: Dict) -> str:
124
+ """Generate recommendation based on analysis"""
125
+ if not oss_analysis or oss_analysis.get("status") != "success":
126
+ return "Analysis failed. Check logs."
127
+
128
+ if enterprise_enhancements and enterprise_enhancements.get("enterprise_available"):
129
+ return "✅ Both OSS and Enterprise features available. Full ARF v3.3.7 capabilities enabled."
130
+ elif enterprise_enhancements:
131
+ return "✅ OSS analysis complete. ⚡ Enterprise features simulated - shows upgrade value. Contact sales@arf.dev for Enterprise trial."
132
+ else:
133
+ return "✅ OSS analysis complete. Install agentic-reliability-framework==3.3.7 for real advisory capabilities."