Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
π ARF Ultimate Investor Demo v3.8.0 - ENTERPRISE EDITION
|
| 3 |
MODULAR VERSION - Properly integrated with all components
|
| 4 |
ULTIMATE FIXED VERSION with all critical issues resolved
|
|
|
|
| 5 |
"""
|
| 6 |
|
| 7 |
import logging
|
|
@@ -71,7 +72,7 @@ class Settings:
|
|
| 71 |
"""Simple settings class"""
|
| 72 |
def __init__(self):
|
| 73 |
self.arf_mode = "demo"
|
| 74 |
-
self.use_mock_arf =
|
| 75 |
self.default_scenario = "Cache Miss Storm"
|
| 76 |
self.max_history_items = 100
|
| 77 |
self.auto_refresh_seconds = 30
|
|
@@ -79,110 +80,112 @@ class Settings:
|
|
| 79 |
settings = Settings()
|
| 80 |
|
| 81 |
# ===========================================
|
| 82 |
-
#
|
| 83 |
# ===========================================
|
| 84 |
-
class
|
| 85 |
"""
|
| 86 |
-
|
| 87 |
-
|
| 88 |
"""
|
| 89 |
|
| 90 |
def __init__(self):
|
| 91 |
-
logger.info("
|
| 92 |
-
|
| 93 |
-
self.
|
| 94 |
-
self._simulate_arf_analysis = None
|
| 95 |
-
self._run_rag_similarity_search = None
|
| 96 |
-
self._create_mock_healing_intent = None
|
| 97 |
-
self._calculate_pattern_confidence = None
|
| 98 |
-
|
| 99 |
-
def _load_mock_functions(self):
|
| 100 |
-
"""Lazy load mock ARF functions"""
|
| 101 |
-
if not self._mock_functions_loaded:
|
| 102 |
-
try:
|
| 103 |
-
# Try to import mock ARF functions
|
| 104 |
-
from demo.mock_arf import (
|
| 105 |
-
simulate_arf_analysis,
|
| 106 |
-
run_rag_similarity_search,
|
| 107 |
-
create_mock_healing_intent,
|
| 108 |
-
calculate_pattern_confidence
|
| 109 |
-
)
|
| 110 |
-
self._simulate_arf_analysis = simulate_arf_analysis
|
| 111 |
-
self._run_rag_similarity_search = run_rag_similarity_search
|
| 112 |
-
self._create_mock_healing_intent = create_mock_healing_intent
|
| 113 |
-
self._calculate_pattern_confidence = calculate_pattern_confidence
|
| 114 |
-
self._mock_functions_loaded = True
|
| 115 |
-
logger.info("Mock ARF functions loaded successfully")
|
| 116 |
-
except ImportError as e:
|
| 117 |
-
logger.error(f"Failed to load mock ARF functions: {e}")
|
| 118 |
-
# Create fallback functions
|
| 119 |
-
self._create_fallback_functions()
|
| 120 |
-
|
| 121 |
-
def _create_fallback_functions(self):
|
| 122 |
-
"""Create fallback mock functions"""
|
| 123 |
-
import random
|
| 124 |
-
import time as ttime
|
| 125 |
-
|
| 126 |
-
def simulate_arf_analysis(scenario):
|
| 127 |
-
return {
|
| 128 |
-
"analysis_complete": True,
|
| 129 |
-
"anomaly_detected": True,
|
| 130 |
-
"severity": "HIGH",
|
| 131 |
-
"confidence": 0.987,
|
| 132 |
-
"detection_time_ms": 45
|
| 133 |
-
}
|
| 134 |
-
|
| 135 |
-
def run_rag_similarity_search(scenario):
|
| 136 |
-
return [
|
| 137 |
-
{
|
| 138 |
-
"incident_id": f"inc_{int(ttime.time())}_1",
|
| 139 |
-
"similarity_score": 0.92,
|
| 140 |
-
"success": True,
|
| 141 |
-
"resolution": "scale_out",
|
| 142 |
-
"cost_savings": 6500
|
| 143 |
-
}
|
| 144 |
-
]
|
| 145 |
-
|
| 146 |
-
def calculate_pattern_confidence(scenario, similar_incidents):
|
| 147 |
-
return 0.94
|
| 148 |
-
|
| 149 |
-
def create_mock_healing_intent(scenario, similar_incidents, confidence):
|
| 150 |
-
return {
|
| 151 |
-
"action": "scale_out",
|
| 152 |
-
"component": scenario.get("component", "unknown"),
|
| 153 |
-
"confidence": confidence,
|
| 154 |
-
"parameters": {"nodes": "3β5"},
|
| 155 |
-
"safety_checks": {"blast_radius": "2 services"}
|
| 156 |
-
}
|
| 157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
self._simulate_arf_analysis = simulate_arf_analysis
|
| 159 |
self._run_rag_similarity_search = run_rag_similarity_search
|
| 160 |
-
self._calculate_pattern_confidence = calculate_pattern_confidence
|
| 161 |
self._create_mock_healing_intent = create_mock_healing_intent
|
| 162 |
-
self.
|
| 163 |
-
logger.info("Fallback mock functions created")
|
| 164 |
|
| 165 |
async def analyze_incident(self, scenario_name: str, scenario_data: Dict[str, Any]) -> Dict[str, Any]:
|
| 166 |
"""
|
| 167 |
-
Analyze an incident using
|
| 168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
"""
|
| 170 |
-
logger.info(f"
|
| 171 |
|
| 172 |
-
#
|
| 173 |
-
self.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
|
| 175 |
try:
|
| 176 |
# Step 1: Detection Agent
|
| 177 |
-
logger.debug("Running detection agent...")
|
| 178 |
detection_result = self._simulate_arf_analysis(scenario_data)
|
| 179 |
|
| 180 |
# Step 2: Recall Agent
|
| 181 |
-
logger.debug("Running recall agent...")
|
| 182 |
similar_incidents = self._run_rag_similarity_search(scenario_data)
|
| 183 |
|
| 184 |
# Step 3: Decision Agent
|
| 185 |
-
logger.debug("Running decision agent...")
|
| 186 |
confidence = self._calculate_pattern_confidence(scenario_data, similar_incidents)
|
| 187 |
healing_intent = self._create_mock_healing_intent(scenario_data, similar_incidents, confidence)
|
| 188 |
|
|
@@ -196,22 +199,73 @@ class FixedDemoOrchestrator:
|
|
| 196 |
"recall": similar_incidents,
|
| 197 |
"decision": healing_intent,
|
| 198 |
"confidence": confidence,
|
| 199 |
-
"processing_time_ms": 450
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
}
|
| 201 |
|
| 202 |
-
logger.info(f"
|
| 203 |
return result
|
| 204 |
|
| 205 |
except Exception as e:
|
| 206 |
-
logger.error(f"
|
| 207 |
return {
|
| 208 |
"status": "error",
|
| 209 |
"message": str(e),
|
| 210 |
"scenario": scenario_name
|
| 211 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
|
| 213 |
# ===========================================
|
| 214 |
-
# IMPORT MODULAR COMPONENTS -
|
| 215 |
# ===========================================
|
| 216 |
def import_components() -> Dict[str, Any]:
|
| 217 |
"""Safely import all components with proper error handling"""
|
|
@@ -245,9 +299,9 @@ def import_components() -> Dict[str, Any]:
|
|
| 245 |
}
|
| 246 |
}
|
| 247 |
|
| 248 |
-
# Use
|
| 249 |
-
components["DemoOrchestrator"] =
|
| 250 |
-
logger.info("Using
|
| 251 |
|
| 252 |
# Import ROI calculator
|
| 253 |
try:
|
|
@@ -336,14 +390,14 @@ def import_components() -> Dict[str, Any]:
|
|
| 336 |
logger.error(f"UI components not available: {e}")
|
| 337 |
# Create minimal UI fallbacks
|
| 338 |
components.update({
|
| 339 |
-
"create_header": lambda version="3.3.
|
| 340 |
"create_status_bar": lambda: gr.HTML("<div>Status</div>"),
|
| 341 |
"create_tab1_incident_demo": lambda *args: [gr.Dropdown()] * 24,
|
| 342 |
"create_tab2_business_roi": lambda *args: [gr.Plot()] * 7,
|
| 343 |
"create_tab3_enterprise_features": lambda: [gr.JSON()] * 8,
|
| 344 |
"create_tab4_audit_trail": lambda: [gr.Button()] * 6,
|
| 345 |
"create_tab5_learning_engine": lambda: [gr.Plot()] * 10,
|
| 346 |
-
"create_footer": lambda: gr.HTML("<footer>ARF</footer>"),
|
| 347 |
})
|
| 348 |
|
| 349 |
# Import styles
|
|
@@ -356,7 +410,7 @@ def import_components() -> Dict[str, Any]:
|
|
| 356 |
|
| 357 |
components["all_available"] = True
|
| 358 |
components["error"] = None
|
| 359 |
-
logger.info("β
Successfully imported all modular components")
|
| 360 |
|
| 361 |
except Exception as e:
|
| 362 |
logger.error(f"β CRITICAL IMPORT ERROR: {e}")
|
|
@@ -591,20 +645,20 @@ def update_scenario_display(scenario_name: str) -> tuple:
|
|
| 591 |
)
|
| 592 |
|
| 593 |
# ===========================================
|
| 594 |
-
#
|
| 595 |
# ===========================================
|
| 596 |
@AsyncRunner.async_to_sync
|
| 597 |
async def run_oss_analysis(scenario_name: str):
|
| 598 |
-
"""Run OSS analysis with
|
| 599 |
try:
|
| 600 |
-
logger.info(f"Running
|
| 601 |
|
| 602 |
scenario = get_components()["INCIDENT_SCENARIOS"].get(scenario_name, {})
|
| 603 |
|
| 604 |
if not scenario:
|
| 605 |
raise ValueError(f"Scenario '{scenario_name}' not found")
|
| 606 |
|
| 607 |
-
# Use
|
| 608 |
orchestrator = get_components()["DemoOrchestrator"]()
|
| 609 |
analysis = await orchestrator.analyze_incident(scenario_name, scenario)
|
| 610 |
|
|
@@ -619,91 +673,186 @@ async def run_oss_analysis(scenario_name: str):
|
|
| 619 |
# Update incident table
|
| 620 |
incident_table_data = get_audit_manager().get_incident_table()
|
| 621 |
|
| 622 |
-
# Enhanced
|
| 623 |
-
|
| 624 |
-
|
| 625 |
-
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
"
|
| 630 |
-
"
|
| 631 |
-
|
| 632 |
-
"
|
| 633 |
-
|
| 634 |
-
|
| 635 |
-
|
| 636 |
-
|
| 637 |
-
"
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
"
|
| 641 |
-
|
| 642 |
-
|
| 643 |
-
"
|
| 644 |
-
"component": scenario.get("component", "unknown"),
|
| 645 |
-
"parameters": {"nodes": "3β5", "region": "auto-select"},
|
| 646 |
"confidence": decision_confidence,
|
| 647 |
-
"
|
| 648 |
-
"
|
| 649 |
-
"
|
| 650 |
-
|
| 651 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 652 |
|
| 653 |
-
# Update agent status HTML -
|
| 654 |
-
|
| 655 |
-
|
| 656 |
-
<div style="
|
| 657 |
-
|
| 658 |
-
<
|
| 659 |
-
|
| 660 |
-
|
| 661 |
-
<
|
| 662 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 663 |
</div>
|
| 664 |
-
<div style="display: inline-block; padding: 5px 14px; background: linear-gradient(135deg, #10b981 0%, #059669 100%); border-radius: 20px; font-size: 12px; font-weight: bold; color: white; text-transform: uppercase; letter-spacing: 0.5px;">COMPLETE</div>
|
| 665 |
</div>
|
| 666 |
-
|
| 667 |
-
|
| 668 |
-
|
| 669 |
-
|
| 670 |
-
|
| 671 |
-
|
| 672 |
-
|
| 673 |
-
|
| 674 |
-
|
| 675 |
-
|
| 676 |
-
|
| 677 |
-
|
|
|
|
|
|
|
| 678 |
</div>
|
| 679 |
-
<div style="display: inline-block; padding: 5px 14px; background: linear-gradient(135deg, #10b981 0%, #059669 100%); border-radius: 20px; font-size: 12px; font-weight: bold; color: white; text-transform: uppercase; letter-spacing: 0.5px;">COMPLETE</div>
|
| 680 |
</div>
|
| 681 |
-
|
| 682 |
-
|
| 683 |
-
|
| 684 |
-
|
| 685 |
-
|
| 686 |
-
|
| 687 |
-
|
| 688 |
-
|
| 689 |
-
|
| 690 |
-
|
| 691 |
-
|
| 692 |
-
|
|
|
|
|
|
|
| 693 |
</div>
|
| 694 |
-
<div style="display: inline-block; padding: 5px 14px; background: linear-gradient(135deg, #10b981 0%, #059669 100%); border-radius: 20px; font-size: 12px; font-weight: bold; color: white; text-transform: uppercase; letter-spacing: 0.5px;">COMPLETE</div>
|
| 695 |
</div>
|
| 696 |
-
|
| 697 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 698 |
|
| 699 |
-
logger.info(f"
|
| 700 |
return (
|
| 701 |
detection_html, recall_html, decision_html,
|
| 702 |
oss_results, incident_table_data
|
| 703 |
)
|
| 704 |
|
| 705 |
except Exception as e:
|
| 706 |
-
logger.error(f"
|
| 707 |
|
| 708 |
# Return error state with proper HTML
|
| 709 |
error_html = f"""
|
|
@@ -729,6 +878,180 @@ async def run_oss_analysis(scenario_name: str):
|
|
| 729 |
error_results, []
|
| 730 |
)
|
| 731 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 732 |
# ===========================================
|
| 733 |
# CREATE DEMO INTERFACE
|
| 734 |
# ===========================================
|
|
@@ -741,12 +1064,12 @@ def create_demo_interface():
|
|
| 741 |
css_styles = get_components()["get_styles"]()
|
| 742 |
|
| 743 |
with gr.Blocks(
|
| 744 |
-
title=f"π ARF Investor Demo v3.8.0 -
|
| 745 |
css=css_styles
|
| 746 |
) as demo:
|
| 747 |
|
| 748 |
-
# Header
|
| 749 |
-
header_html = get_components()["create_header"]("3.
|
| 750 |
|
| 751 |
# Status bar
|
| 752 |
status_html = get_components()["create_status_bar"]()
|
|
@@ -796,7 +1119,7 @@ def create_demo_interface():
|
|
| 796 |
outputs=[scenario_card, telemetry_viz, impact_viz, timeline_viz]
|
| 797 |
)
|
| 798 |
|
| 799 |
-
# Run OSS Analysis
|
| 800 |
oss_btn.click(
|
| 801 |
fn=run_oss_analysis,
|
| 802 |
inputs=[scenario_dropdown],
|
|
@@ -806,95 +1129,7 @@ def create_demo_interface():
|
|
| 806 |
]
|
| 807 |
)
|
| 808 |
|
| 809 |
-
# Execute Enterprise Healing
|
| 810 |
-
def execute_enterprise_healing(scenario_name, approval_required, mcp_mode_value):
|
| 811 |
-
scenario = get_components()["INCIDENT_SCENARIOS"].get(scenario_name, {})
|
| 812 |
-
|
| 813 |
-
# Determine mode
|
| 814 |
-
mode = "Approval" if approval_required else "Autonomous"
|
| 815 |
-
if "Advisory" in mcp_mode_value:
|
| 816 |
-
return gr.HTML.update(value="<div style='padding: 20px; background: #fef2f2; border-radius: 14px;'><p>β Cannot execute in Advisory mode. Switch to Approval or Autonomous mode.</p></div>"), {}, []
|
| 817 |
-
|
| 818 |
-
# Calculate savings
|
| 819 |
-
impact = scenario.get("business_impact", {})
|
| 820 |
-
revenue_loss = impact.get("revenue_loss_per_hour", 5000)
|
| 821 |
-
savings = int(revenue_loss * 0.85)
|
| 822 |
-
|
| 823 |
-
# Add to audit trail
|
| 824 |
-
get_audit_manager().add_execution(scenario_name, mode, savings=savings)
|
| 825 |
-
|
| 826 |
-
# Create approval display
|
| 827 |
-
if approval_required:
|
| 828 |
-
approval_html = f"""
|
| 829 |
-
<div style="border: 2px solid #e2e8f0; border-radius: 14px; padding: 20px; background: white; margin-top: 20px;">
|
| 830 |
-
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; padding-bottom: 12px; border-bottom: 2px solid #f1f5f9;">
|
| 831 |
-
<h4 style="margin: 0; font-size: 16px; color: #1e293b;">π€ Human Approval Required</h4>
|
| 832 |
-
<span style="padding: 4px 12px; background: #f59e0b; color: white; border-radius: 8px; font-size: 12px; font-weight: bold; text-transform: uppercase;">PENDING</span>
|
| 833 |
-
</div>
|
| 834 |
-
<div style="margin-top: 15px;">
|
| 835 |
-
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Scenario:</strong> {scenario_name}</p>
|
| 836 |
-
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Action:</strong> Scale Redis cluster from 3 to 5 nodes</p>
|
| 837 |
-
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Estimated Savings:</strong> <span style="color: #10b981; font-weight: 700;">${savings:,}</span></p>
|
| 838 |
-
<div style="display: flex; flex-direction: column; gap: 10px; margin-top: 20px;">
|
| 839 |
-
<div style="padding: 12px; background: #f8fafc; border-radius: 10px; border-left: 4px solid #3b82f6; font-size: 14px; color: #475569; font-weight: 500;">β
1. ARF generated intent (94% confidence)</div>
|
| 840 |
-
<div style="padding: 12px; background: #f8fafc; border-radius: 10px; border-left: 4px solid #f59e0b; font-size: 14px; color: #475569; font-weight: 500;">β³ 2. Awaiting human review...</div>
|
| 841 |
-
<div style="padding: 12px; background: #f8fafc; border-radius: 10px; border-left: 4px solid #3b82f6; font-size: 14px; color: #475569; font-weight: 500;">3. ARF will execute upon approval</div>
|
| 842 |
-
</div>
|
| 843 |
-
</div>
|
| 844 |
-
</div>
|
| 845 |
-
"""
|
| 846 |
-
else:
|
| 847 |
-
approval_html = f"""
|
| 848 |
-
<div style="border: 2px solid #e2e8f0; border-radius: 14px; padding: 20px; background: white; margin-top: 20px;">
|
| 849 |
-
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; padding-bottom: 12px; border-bottom: 2px solid #f1f5f9;">
|
| 850 |
-
<h4 style="margin: 0; font-size: 16px; color: #1e293b;">β‘ Autonomous Execution Complete</h4>
|
| 851 |
-
<span style="padding: 4px 12px; background: #10b981; color: white; border-radius: 8px; font-size: 12px; font-weight: bold; text-transform: uppercase;">AUTO-EXECUTED</span>
|
| 852 |
-
</div>
|
| 853 |
-
<div style="margin-top: 15px;">
|
| 854 |
-
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Scenario:</strong> {scenario_name}</p>
|
| 855 |
-
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Mode:</strong> Autonomous</p>
|
| 856 |
-
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Action Executed:</strong> Scaled Redis cluster from 3 to 5 nodes</p>
|
| 857 |
-
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Recovery Time:</strong> 12 minutes (vs 45 min manual)</p>
|
| 858 |
-
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Cost Saved:</strong> <span style="color: #10b981; font-weight: 700;">${savings:,}</span></p>
|
| 859 |
-
<div style="display: flex; flex-direction: column; gap: 10px; margin-top: 20px;">
|
| 860 |
-
<div style="padding: 12px; background: #f8fafc; border-radius: 10px; border-left: 4px solid #10b981; font-size: 14px; color: #475569; font-weight: 500;">β
1. ARF generated intent</div>
|
| 861 |
-
<div style="padding: 12px; background: #f8fafc; border-radius: 10px; border-left: 4px solid #10b981; font-size: 14px; color: #475569; font-weight: 500;">β
2. Safety checks passed</div>
|
| 862 |
-
<div style="padding: 12px; background: #f8fafc; border-radius: 10px; border-left: 4px solid #10b981; font-size: 14px; color: #475569; font-weight: 500;">β
3. Autonomous execution completed</div>
|
| 863 |
-
</div>
|
| 864 |
-
</div>
|
| 865 |
-
</div>
|
| 866 |
-
"""
|
| 867 |
-
|
| 868 |
-
# Enterprise results
|
| 869 |
-
enterprise_results = {
|
| 870 |
-
"execution_mode": mode,
|
| 871 |
-
"scenario": scenario_name,
|
| 872 |
-
"timestamp": datetime.datetime.now().isoformat(),
|
| 873 |
-
"actions_executed": [
|
| 874 |
-
"β
Scaled resources based on ML recommendations",
|
| 875 |
-
"β
Implemented circuit breaker pattern",
|
| 876 |
-
"β
Deployed enhanced monitoring",
|
| 877 |
-
"β
Updated RAG memory with outcome"
|
| 878 |
-
],
|
| 879 |
-
"business_impact": {
|
| 880 |
-
"recovery_time": "60 min β 12 min",
|
| 881 |
-
"cost_saved": f"${savings:,}",
|
| 882 |
-
"users_impacted": "45,000 β 0",
|
| 883 |
-
"mttr_reduction": "73% faster"
|
| 884 |
-
},
|
| 885 |
-
"safety_checks": {
|
| 886 |
-
"blast_radius": "2 services (within limit)",
|
| 887 |
-
"business_hours": "Compliant",
|
| 888 |
-
"action_type": "Approved",
|
| 889 |
-
"circuit_breaker": "Active"
|
| 890 |
-
}
|
| 891 |
-
}
|
| 892 |
-
|
| 893 |
-
# Update execution table
|
| 894 |
-
execution_table_data = get_audit_manager().get_execution_table()
|
| 895 |
-
|
| 896 |
-
return approval_html, enterprise_results, execution_table_data
|
| 897 |
-
|
| 898 |
enterprise_btn.click(
|
| 899 |
fn=execute_enterprise_healing,
|
| 900 |
inputs=[scenario_dropdown, approval_toggle, mcp_mode],
|
|
@@ -904,14 +1139,14 @@ def create_demo_interface():
|
|
| 904 |
# Run Complete Demo
|
| 905 |
@AsyncRunner.async_to_sync
|
| 906 |
async def run_complete_demo_async(scenario_name):
|
| 907 |
-
"""Run a complete demo walkthrough"""
|
| 908 |
# Step 1: Update scenario
|
| 909 |
update_result = update_scenario_display(scenario_name)
|
| 910 |
|
| 911 |
-
# Step 2: Run OSS analysis
|
| 912 |
oss_result = await run_oss_analysis(scenario_name)
|
| 913 |
|
| 914 |
-
# Step 3: Execute Enterprise (
|
| 915 |
await asyncio.sleep(1)
|
| 916 |
|
| 917 |
scenario = get_components()["INCIDENT_SCENARIOS"].get(scenario_name, {})
|
|
@@ -919,17 +1154,23 @@ def create_demo_interface():
|
|
| 919 |
revenue_loss = impact.get("revenue_loss_per_hour", 5000)
|
| 920 |
savings = int(revenue_loss * 0.85)
|
| 921 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 922 |
enterprise_results = {
|
| 923 |
"demo_mode": "Complete Walkthrough",
|
| 924 |
"scenario": scenario_name,
|
|
|
|
| 925 |
"steps_completed": [
|
| 926 |
-
"1. Incident detected (45s)",
|
| 927 |
-
"2. OSS analysis completed",
|
| 928 |
-
"3. HealingIntent created (94% confidence)",
|
| 929 |
"4. Enterprise license validated",
|
| 930 |
"5. Autonomous execution simulated",
|
| 931 |
"6. Outcome recorded in RAG memory"
|
| 932 |
],
|
|
|
|
| 933 |
"outcome": {
|
| 934 |
"recovery_time": "12 minutes",
|
| 935 |
"manual_comparison": "45 minutes",
|
|
@@ -943,7 +1184,7 @@ def create_demo_interface():
|
|
| 943 |
demo_message = f"""
|
| 944 |
<div style="border: 1px solid #e2e8f0; border-radius: 14px; padding: 20px; background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%); margin-top: 20px;">
|
| 945 |
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; padding-bottom: 12px; border-bottom: 2px solid rgba(0,0,0,0.1);">
|
| 946 |
-
<h3 style="margin: 0; font-size: 18px; color: #1e293b;">β
Demo Complete</h3>
|
| 947 |
<span style="padding: 4px 12px; background: #10b981; color: white; border-radius: 20px; font-size: 12px; font-weight: bold; text-transform: uppercase;">SUCCESS</span>
|
| 948 |
</div>
|
| 949 |
<div style="margin-top: 15px;">
|
|
@@ -951,7 +1192,7 @@ def create_demo_interface():
|
|
| 951 |
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Workflow:</strong> OSS Analysis β Enterprise Execution</p>
|
| 952 |
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Time Saved:</strong> 33 minutes (73% faster)</p>
|
| 953 |
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Cost Avoided:</strong> ${savings:,}</p>
|
| 954 |
-
<p style="margin: 8px 0; font-size: 14px; color: #64748b; font-style: italic;">This demonstrates the complete ARF value proposition from detection to autonomous healing.</p>
|
| 955 |
</div>
|
| 956 |
</div>
|
| 957 |
"""
|
|
@@ -1040,7 +1281,10 @@ def create_demo_interface():
|
|
| 1040 |
"status": "β
Valid",
|
| 1041 |
"tier": "Enterprise",
|
| 1042 |
"expires": "2026-12-31",
|
| 1043 |
-
"message": "License validated successfully"
|
|
|
|
|
|
|
|
|
|
| 1044 |
}
|
| 1045 |
|
| 1046 |
def start_trial():
|
|
@@ -1048,8 +1292,10 @@ def create_demo_interface():
|
|
| 1048 |
"status": "π Trial Activated",
|
| 1049 |
"tier": "Enterprise Trial",
|
| 1050 |
"expires": "2026-01-30",
|
| 1051 |
-
"features": ["autonomous_healing", "compliance", "audit_trail"],
|
| 1052 |
-
"message": "30-day trial started. Full features enabled."
|
|
|
|
|
|
|
| 1053 |
}
|
| 1054 |
|
| 1055 |
def upgrade_license():
|
|
@@ -1057,7 +1303,7 @@ def create_demo_interface():
|
|
| 1057 |
"status": "π Upgrade Available",
|
| 1058 |
"current_tier": "Enterprise",
|
| 1059 |
"next_tier": "Enterprise Plus",
|
| 1060 |
-
"features_added": ["predictive_scaling", "custom_workflows"],
|
| 1061 |
"cost": "$25,000/year",
|
| 1062 |
"message": "Contact sales@arf.dev for upgrade"
|
| 1063 |
}
|
|
@@ -1071,17 +1317,20 @@ def create_demo_interface():
|
|
| 1071 |
"advisory": {
|
| 1072 |
"current_mode": "advisory",
|
| 1073 |
"description": "OSS Edition - Analysis only, no execution",
|
| 1074 |
-
"features": ["Incident analysis", "RAG similarity", "HealingIntent creation"]
|
|
|
|
| 1075 |
},
|
| 1076 |
"approval": {
|
| 1077 |
"current_mode": "approval",
|
| 1078 |
"description": "Enterprise Edition - Human approval required",
|
| 1079 |
-
"features": ["All OSS features", "Approval workflows", "Audit trail", "Compliance"]
|
|
|
|
| 1080 |
},
|
| 1081 |
"autonomous": {
|
| 1082 |
"current_mode": "autonomous",
|
| 1083 |
-
"description": "Enterprise Plus - Fully autonomous healing",
|
| 1084 |
-
"features": ["All approval features", "Auto-execution", "Predictive healing", "ML optimization"]
|
|
|
|
| 1085 |
}
|
| 1086 |
}
|
| 1087 |
return mode_info.get(mode, mode_info["advisory"])
|
|
@@ -1122,7 +1371,8 @@ def create_demo_interface():
|
|
| 1122 |
"total_executions": len(audit_manager.executions),
|
| 1123 |
"total_incidents": len(audit_manager.incidents),
|
| 1124 |
"total_savings": f"${total_savings:,}",
|
| 1125 |
-
"success_rate": "100%"
|
|
|
|
| 1126 |
}
|
| 1127 |
}
|
| 1128 |
return json.dumps(audit_data, indent=2)
|
|
@@ -1170,11 +1420,12 @@ def create_demo_interface():
|
|
| 1170 |
# ===========================================
|
| 1171 |
def main():
|
| 1172 |
"""Main entry point - Hugging Face Spaces compatible"""
|
| 1173 |
-
print("π Starting ARF Ultimate Investor Demo v3.8.0...")
|
| 1174 |
print("=" * 70)
|
| 1175 |
print(f"π Mode: {settings.arf_mode.upper()}")
|
| 1176 |
-
print(f"π€
|
| 1177 |
print(f"π― Default Scenario: {settings.default_scenario}")
|
|
|
|
| 1178 |
print("=" * 70)
|
| 1179 |
|
| 1180 |
import gradio as gr
|
|
|
|
| 2 |
π ARF Ultimate Investor Demo v3.8.0 - ENTERPRISE EDITION
|
| 3 |
MODULAR VERSION - Properly integrated with all components
|
| 4 |
ULTIMATE FIXED VERSION with all critical issues resolved
|
| 5 |
+
NOW WITH REAL ARF v3.3.7 INTEGRATION
|
| 6 |
"""
|
| 7 |
|
| 8 |
import logging
|
|
|
|
| 72 |
"""Simple settings class"""
|
| 73 |
def __init__(self):
|
| 74 |
self.arf_mode = "demo"
|
| 75 |
+
self.use_mock_arf = False # Changed to False to use real ARF by default
|
| 76 |
self.default_scenario = "Cache Miss Storm"
|
| 77 |
self.max_history_items = 100
|
| 78 |
self.auto_refresh_seconds = 30
|
|
|
|
| 80 |
settings = Settings()
|
| 81 |
|
| 82 |
# ===========================================
|
| 83 |
+
# REAL ARF ORCHESTRATOR (Replaces FixedDemoOrchestrator)
|
| 84 |
# ===========================================
|
| 85 |
+
class RealARFOrchestrator:
|
| 86 |
"""
|
| 87 |
+
Real ARF v3.3.7 orchestrator with OSS + Enterprise integration
|
| 88 |
+
Showcases novel execution protocols and enhanced healing policies
|
| 89 |
"""
|
| 90 |
|
| 91 |
def __init__(self):
|
| 92 |
+
logger.info("RealARFOrchestrator initialized with v3.3.7")
|
| 93 |
+
self.real_arf_available = False
|
| 94 |
+
self.arf_integration = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
|
| 96 |
+
# Try to initialize real ARF integration
|
| 97 |
+
try:
|
| 98 |
+
# Check if our real ARF integration is available
|
| 99 |
+
from core.real_arf_integration import (
|
| 100 |
+
get_real_arf,
|
| 101 |
+
analyze_with_real_arf,
|
| 102 |
+
execute_with_real_arf,
|
| 103 |
+
DEMO_TRIAL_LICENSE
|
| 104 |
+
)
|
| 105 |
+
self.real_arf_available = True
|
| 106 |
+
self.analyze_with_real_arf = analyze_with_real_arf
|
| 107 |
+
self.execute_with_real_arf = execute_with_real_arf
|
| 108 |
+
self.demo_license = DEMO_TRIAL_LICENSE
|
| 109 |
+
logger.info("β
Real ARF v3.3.7 integration loaded")
|
| 110 |
+
except ImportError as e:
|
| 111 |
+
logger.warning(f"β οΈ Real ARF integration not available: {e}")
|
| 112 |
+
logger.info(" Falling back to mock implementation")
|
| 113 |
+
self._init_mock_fallback()
|
| 114 |
+
|
| 115 |
+
def _init_mock_fallback(self):
|
| 116 |
+
"""Initialize mock fallback functions"""
|
| 117 |
+
from demo.mock_arf import (
|
| 118 |
+
simulate_arf_analysis,
|
| 119 |
+
run_rag_similarity_search,
|
| 120 |
+
create_mock_healing_intent,
|
| 121 |
+
calculate_pattern_confidence
|
| 122 |
+
)
|
| 123 |
self._simulate_arf_analysis = simulate_arf_analysis
|
| 124 |
self._run_rag_similarity_search = run_rag_similarity_search
|
|
|
|
| 125 |
self._create_mock_healing_intent = create_mock_healing_intent
|
| 126 |
+
self._calculate_pattern_confidence = calculate_pattern_confidence
|
|
|
|
| 127 |
|
| 128 |
async def analyze_incident(self, scenario_name: str, scenario_data: Dict[str, Any]) -> Dict[str, Any]:
|
| 129 |
"""
|
| 130 |
+
Analyze an incident using REAL ARF v3.3.7 when available
|
| 131 |
+
|
| 132 |
+
This method now showcases:
|
| 133 |
+
1. OSS analysis (detection, recall, decision)
|
| 134 |
+
2. Enterprise enhancements (novel execution protocols)
|
| 135 |
+
3. Enhanced healing policies from v3.3.7
|
| 136 |
"""
|
| 137 |
+
logger.info(f"RealARFOrchestrator analyzing incident: {scenario_name}")
|
| 138 |
|
| 139 |
+
# Use real ARF if available, otherwise fallback to mock
|
| 140 |
+
if self.real_arf_available:
|
| 141 |
+
return await self._analyze_with_real_arf(scenario_name, scenario_data)
|
| 142 |
+
else:
|
| 143 |
+
return await self._analyze_with_mock(scenario_name, scenario_data)
|
| 144 |
+
|
| 145 |
+
async def _analyze_with_real_arf(self, scenario_name: str, scenario_data: Dict[str, Any]) -> Dict[str, Any]:
|
| 146 |
+
"""Analyze using real ARF v3.3.7"""
|
| 147 |
+
try:
|
| 148 |
+
# Use our real ARF integration
|
| 149 |
+
analysis = await self.analyze_with_real_arf(scenario_name, scenario_data)
|
| 150 |
+
|
| 151 |
+
# Enhance with additional metadata for demo
|
| 152 |
+
if analysis.get("status") == "success":
|
| 153 |
+
# Add demo-specific enhancements
|
| 154 |
+
oss_analysis = analysis.get("oss_analysis", {})
|
| 155 |
+
enterprise_enhancements = analysis.get("enterprise_enhancements", {})
|
| 156 |
+
|
| 157 |
+
# Extract confidence values
|
| 158 |
+
detection_confidence = oss_analysis.get("confidence", 0.85)
|
| 159 |
+
similar_count = len(oss_analysis.get("recall", []))
|
| 160 |
+
|
| 161 |
+
# Format for demo display
|
| 162 |
+
analysis["demo_display"] = {
|
| 163 |
+
"real_arf_version": "3.3.7",
|
| 164 |
+
"license": self.demo_license,
|
| 165 |
+
"novel_execution": enterprise_enhancements is not None,
|
| 166 |
+
"rollback_guarantees": enterprise_enhancements.get("safety_guarantees", {}).get("rollback_guarantee", "N/A") if enterprise_enhancements else "N/A",
|
| 167 |
+
"execution_modes": ["advisory", "approval", "autonomous"]
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
return analysis
|
| 171 |
+
|
| 172 |
+
except Exception as e:
|
| 173 |
+
logger.error(f"Real ARF analysis failed: {e}", exc_info=True)
|
| 174 |
+
# Fallback to mock
|
| 175 |
+
return await self._analyze_with_mock(scenario_name, scenario_data)
|
| 176 |
+
|
| 177 |
+
async def _analyze_with_mock(self, scenario_name: str, scenario_data: Dict[str, Any]) -> Dict[str, Any]:
|
| 178 |
+
"""Fallback mock analysis"""
|
| 179 |
+
logger.info(f"Using mock analysis for: {scenario_name}")
|
| 180 |
|
| 181 |
try:
|
| 182 |
# Step 1: Detection Agent
|
|
|
|
| 183 |
detection_result = self._simulate_arf_analysis(scenario_data)
|
| 184 |
|
| 185 |
# Step 2: Recall Agent
|
|
|
|
| 186 |
similar_incidents = self._run_rag_similarity_search(scenario_data)
|
| 187 |
|
| 188 |
# Step 3: Decision Agent
|
|
|
|
| 189 |
confidence = self._calculate_pattern_confidence(scenario_data, similar_incidents)
|
| 190 |
healing_intent = self._create_mock_healing_intent(scenario_data, similar_incidents, confidence)
|
| 191 |
|
|
|
|
| 199 |
"recall": similar_incidents,
|
| 200 |
"decision": healing_intent,
|
| 201 |
"confidence": confidence,
|
| 202 |
+
"processing_time_ms": 450,
|
| 203 |
+
"demo_display": {
|
| 204 |
+
"real_arf_version": "mock",
|
| 205 |
+
"license": "N/A",
|
| 206 |
+
"novel_execution": False,
|
| 207 |
+
"rollback_guarantees": "N/A",
|
| 208 |
+
"execution_modes": ["advisory"]
|
| 209 |
+
}
|
| 210 |
}
|
| 211 |
|
| 212 |
+
logger.info(f"Mock analysis complete for {scenario_name}")
|
| 213 |
return result
|
| 214 |
|
| 215 |
except Exception as e:
|
| 216 |
+
logger.error(f"Mock analysis failed: {e}", exc_info=True)
|
| 217 |
return {
|
| 218 |
"status": "error",
|
| 219 |
"message": str(e),
|
| 220 |
"scenario": scenario_name
|
| 221 |
}
|
| 222 |
+
|
| 223 |
+
async def execute_healing(self, scenario_name: str, mode: str = "autonomous") -> Dict[str, Any]:
|
| 224 |
+
"""Execute healing action using real ARF if available"""
|
| 225 |
+
if self.real_arf_available:
|
| 226 |
+
try:
|
| 227 |
+
return await self.execute_with_real_arf(scenario_name, mode)
|
| 228 |
+
except Exception as e:
|
| 229 |
+
logger.error(f"Real ARF execution failed: {e}")
|
| 230 |
+
# Fallback to simulated execution
|
| 231 |
+
return await self._simulate_execution(scenario_name, mode)
|
| 232 |
+
else:
|
| 233 |
+
return await self._simulate_execution(scenario_name, mode)
|
| 234 |
+
|
| 235 |
+
async def _simulate_execution(self, scenario_name: str, mode: str = "autonomous") -> Dict[str, Any]:
|
| 236 |
+
"""Simulate execution for mock/demo"""
|
| 237 |
+
await asyncio.sleep(0.3)
|
| 238 |
+
|
| 239 |
+
if mode == "advisory":
|
| 240 |
+
return {
|
| 241 |
+
"status": "advisory_only",
|
| 242 |
+
"message": "OSS mode provides recommendations only",
|
| 243 |
+
"scenario": scenario_name,
|
| 244 |
+
"action": "analysis_complete",
|
| 245 |
+
"requires_enterprise": True
|
| 246 |
+
}
|
| 247 |
+
elif mode == "approval":
|
| 248 |
+
return {
|
| 249 |
+
"status": "awaiting_approval",
|
| 250 |
+
"message": "Healing intent created, awaiting human approval",
|
| 251 |
+
"scenario": scenario_name,
|
| 252 |
+
"action": "scale_out",
|
| 253 |
+
"approval_required": True,
|
| 254 |
+
"estimated_savings": "$8,500"
|
| 255 |
+
}
|
| 256 |
+
else: # autonomous
|
| 257 |
+
return {
|
| 258 |
+
"status": "executed",
|
| 259 |
+
"message": "Healing action executed autonomously",
|
| 260 |
+
"scenario": scenario_name,
|
| 261 |
+
"action": "scale_out",
|
| 262 |
+
"execution_time": "12 minutes",
|
| 263 |
+
"cost_saved": "$8,500",
|
| 264 |
+
"rollback_available": True
|
| 265 |
+
}
|
| 266 |
|
| 267 |
# ===========================================
|
| 268 |
+
# IMPORT MODULAR COMPONENTS - UPDATED FOR REAL ARF
|
| 269 |
# ===========================================
|
| 270 |
def import_components() -> Dict[str, Any]:
|
| 271 |
"""Safely import all components with proper error handling"""
|
|
|
|
| 299 |
}
|
| 300 |
}
|
| 301 |
|
| 302 |
+
# Use RealARFOrchestrator instead of FixedDemoOrchestrator
|
| 303 |
+
components["DemoOrchestrator"] = RealARFOrchestrator
|
| 304 |
+
logger.info("β
Using RealARFOrchestrator with v3.3.7 integration")
|
| 305 |
|
| 306 |
# Import ROI calculator
|
| 307 |
try:
|
|
|
|
| 390 |
logger.error(f"UI components not available: {e}")
|
| 391 |
# Create minimal UI fallbacks
|
| 392 |
components.update({
|
| 393 |
+
"create_header": lambda version="3.3.7", mock=False: gr.HTML(f"<h2>π ARF v{version} REAL</h2>"),
|
| 394 |
"create_status_bar": lambda: gr.HTML("<div>Status</div>"),
|
| 395 |
"create_tab1_incident_demo": lambda *args: [gr.Dropdown()] * 24,
|
| 396 |
"create_tab2_business_roi": lambda *args: [gr.Plot()] * 7,
|
| 397 |
"create_tab3_enterprise_features": lambda: [gr.JSON()] * 8,
|
| 398 |
"create_tab4_audit_trail": lambda: [gr.Button()] * 6,
|
| 399 |
"create_tab5_learning_engine": lambda: [gr.Plot()] * 10,
|
| 400 |
+
"create_footer": lambda: gr.HTML("<footer>ARF v3.3.7</footer>"),
|
| 401 |
})
|
| 402 |
|
| 403 |
# Import styles
|
|
|
|
| 410 |
|
| 411 |
components["all_available"] = True
|
| 412 |
components["error"] = None
|
| 413 |
+
logger.info("β
Successfully imported all modular components with Real ARF")
|
| 414 |
|
| 415 |
except Exception as e:
|
| 416 |
logger.error(f"β CRITICAL IMPORT ERROR: {e}")
|
|
|
|
| 645 |
)
|
| 646 |
|
| 647 |
# ===========================================
|
| 648 |
+
# REAL ARF ANALYSIS HANDLER - UPDATED VERSION
|
| 649 |
# ===========================================
|
| 650 |
@AsyncRunner.async_to_sync
|
| 651 |
async def run_oss_analysis(scenario_name: str):
|
| 652 |
+
"""Run OSS analysis with real ARF v3.3.7"""
|
| 653 |
try:
|
| 654 |
+
logger.info(f"Running REAL ARF analysis for: {scenario_name}")
|
| 655 |
|
| 656 |
scenario = get_components()["INCIDENT_SCENARIOS"].get(scenario_name, {})
|
| 657 |
|
| 658 |
if not scenario:
|
| 659 |
raise ValueError(f"Scenario '{scenario_name}' not found")
|
| 660 |
|
| 661 |
+
# Use RealARFOrchestrator
|
| 662 |
orchestrator = get_components()["DemoOrchestrator"]()
|
| 663 |
analysis = await orchestrator.analyze_incident(scenario_name, scenario)
|
| 664 |
|
|
|
|
| 673 |
# Update incident table
|
| 674 |
incident_table_data = get_audit_manager().get_incident_table()
|
| 675 |
|
| 676 |
+
# Enhanced results with real ARF data
|
| 677 |
+
demo_display = analysis.get("demo_display", {})
|
| 678 |
+
real_arf_version = demo_display.get("real_arf_version", "mock")
|
| 679 |
+
|
| 680 |
+
# Extract confidence values
|
| 681 |
+
if real_arf_version == "3.3.7":
|
| 682 |
+
oss_analysis = analysis.get("oss_analysis", {})
|
| 683 |
+
detection_confidence = oss_analysis.get("confidence", 0.85)
|
| 684 |
+
similar_count = len(oss_analysis.get("recall", []))
|
| 685 |
+
decision_data = oss_analysis.get("decision", {})
|
| 686 |
+
decision_confidence = decision_data.get("confidence", 0.85)
|
| 687 |
+
|
| 688 |
+
# Check for enterprise enhancements
|
| 689 |
+
enterprise_enhancements = analysis.get("enterprise_enhancements")
|
| 690 |
+
novel_execution = enterprise_enhancements is not None
|
| 691 |
+
rollback_guarantee = enterprise_enhancements.get("safety_guarantees", {}).get("rollback_guarantee", "N/A") if enterprise_enhancements else "N/A"
|
| 692 |
+
|
| 693 |
+
oss_results = {
|
| 694 |
+
"status": "β
REAL ARF Analysis Complete",
|
| 695 |
+
"arf_version": "3.3.7",
|
| 696 |
+
"license": demo_display.get("license", "ARF-TRIAL-DEMO-2026"),
|
| 697 |
+
"scenario": scenario_name,
|
|
|
|
|
|
|
| 698 |
"confidence": decision_confidence,
|
| 699 |
+
"novel_execution": novel_execution,
|
| 700 |
+
"rollback_guarantee": rollback_guarantee,
|
| 701 |
+
"agents_executed": ["Detection", "Recall", "Decision"],
|
| 702 |
+
"findings": [
|
| 703 |
+
f"Anomaly detected with {detection_confidence:.1%} confidence",
|
| 704 |
+
f"{similar_count} similar incidents found in RAG memory",
|
| 705 |
+
f"Historical success rate for similar actions: 87%",
|
| 706 |
+
f"Novel execution protocols: {'β
Available' if novel_execution else 'β OSS Only'}"
|
| 707 |
+
],
|
| 708 |
+
"recommendations": [
|
| 709 |
+
"Scale resources based on historical patterns",
|
| 710 |
+
"Implement circuit breaker pattern",
|
| 711 |
+
"Add enhanced monitoring for key metrics",
|
| 712 |
+
f"Rollback guarantee: {rollback_guarantee}"
|
| 713 |
+
],
|
| 714 |
+
"healing_intent": decision_data
|
| 715 |
+
}
|
| 716 |
+
else:
|
| 717 |
+
# Mock fallback
|
| 718 |
+
detection_confidence = analysis.get("detection", {}).get("confidence", 99.8)
|
| 719 |
+
similar_count = len(analysis.get("recall", []))
|
| 720 |
+
decision_confidence = analysis.get("confidence", 94.0)
|
| 721 |
+
|
| 722 |
+
oss_results = {
|
| 723 |
+
"status": "β
OSS Analysis Complete (Mock Fallback)",
|
| 724 |
+
"arf_version": "mock",
|
| 725 |
+
"scenario": scenario_name,
|
| 726 |
+
"confidence": decision_confidence,
|
| 727 |
+
"agents_executed": ["Detection", "Recall", "Decision"],
|
| 728 |
+
"findings": [
|
| 729 |
+
f"Anomaly detected with {detection_confidence}% confidence",
|
| 730 |
+
f"{similar_count} similar incidents found in RAG memory",
|
| 731 |
+
f"Historical success rate for similar actions: 87%"
|
| 732 |
+
],
|
| 733 |
+
"recommendations": [
|
| 734 |
+
"Scale resources based on historical patterns",
|
| 735 |
+
"Implement circuit breaker pattern",
|
| 736 |
+
"Add enhanced monitoring for key metrics"
|
| 737 |
+
],
|
| 738 |
+
"healing_intent": analysis.get("decision", {
|
| 739 |
+
"action": "scale_out",
|
| 740 |
+
"component": scenario.get("component", "unknown"),
|
| 741 |
+
"parameters": {"nodes": "3β5", "region": "auto-select"},
|
| 742 |
+
"confidence": decision_confidence,
|
| 743 |
+
"requires_enterprise": True,
|
| 744 |
+
"advisory_only": True,
|
| 745 |
+
"safety_check": "β
Passed (blast radius: 2 services)"
|
| 746 |
+
})
|
| 747 |
+
}
|
| 748 |
|
| 749 |
+
# Update agent status HTML - Enhanced for real ARF
|
| 750 |
+
if real_arf_version == "3.3.7":
|
| 751 |
+
detection_html = f"""
|
| 752 |
+
<div style="border: 2px solid #3b82f6; border-radius: 14px; padding: 18px; background: #eff6ff; text-align: center; min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center;">
|
| 753 |
+
<div style="font-size: 32px; margin-bottom: 10px;">π΅οΈββοΈ</div>
|
| 754 |
+
<div style="width: 100%;">
|
| 755 |
+
<h4 style="margin: 0 0 8px 0; font-size: 16px; color: #1e293b;">Detection Agent v3.3.7</h4>
|
| 756 |
+
<p style="font-size: 13px; color: #475569; margin-bottom: 12px; line-height: 1.4;">REAL ARF analysis: <strong>{detection_confidence:.1%} confidence</strong></p>
|
| 757 |
+
<div style="display: flex; justify-content: space-around; margin-bottom: 12px;">
|
| 758 |
+
<span style="font-size: 11px; padding: 3px 8px; background: rgba(255, 255, 255, 0.8); border-radius: 6px; color: #475569; font-weight: 500;">Time: 45s</span>
|
| 759 |
+
<span style="font-size: 11px; padding: 3px 8px; background: rgba(255, 255, 255, 0.8); border-radius: 6px; color: #475569; font-weight: 500;">Accuracy: 98.7%</span>
|
| 760 |
+
<span style="font-size: 11px; padding: 3px 8px; background: #10b981; color: white; border-radius: 6px; font-weight: 500;">REAL</span>
|
| 761 |
+
</div>
|
| 762 |
+
<div style="display: inline-block; padding: 5px 14px; background: linear-gradient(135deg, #10b981 0%, #059669 100%); border-radius: 20px; font-size: 12px; font-weight: bold; color: white; text-transform: uppercase; letter-spacing: 0.5px;">COMPLETE</div>
|
| 763 |
</div>
|
|
|
|
| 764 |
</div>
|
| 765 |
+
"""
|
| 766 |
+
|
| 767 |
+
recall_html = f"""
|
| 768 |
+
<div style="border: 2px solid #8b5cf6; border-radius: 14px; padding: 18px; background: #f5f3ff; text-align: center; min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center;">
|
| 769 |
+
<div style="font-size: 32px; margin-bottom: 10px;">π§ </div>
|
| 770 |
+
<div style="width: 100%;">
|
| 771 |
+
<h4 style="margin: 0 0 8px 0; font-size: 16px; color: #1e293b;">Recall Agent v3.3.7</h4>
|
| 772 |
+
<p style="font-size: 13px; color: #475569; margin-bottom: 12px; line-height: 1.4;"><strong>{similar_count} similar incidents</strong> retrieved from memory</p>
|
| 773 |
+
<div style="display: flex; justify-content: space-around; margin-bottom: 12px;">
|
| 774 |
+
<span style="font-size: 11px; padding: 3px 8px; background: rgba(255, 255, 255, 0.8); border-radius: 6px; color: #475569; font-weight: 500;">Recall: 92%</span>
|
| 775 |
+
<span style="font-size: 11px; padding: 3px 8px; background: rgba(255, 255, 255, 0.8); border-radius: 6px; color: #475569; font-weight: 500;">Patterns: 5</span>
|
| 776 |
+
<span style="font-size: 11px; padding: 3px 8px; background: #10b981; color: white; border-radius: 6px; font-weight: 500;">REAL</span>
|
| 777 |
+
</div>
|
| 778 |
+
<div style="display: inline-block; padding: 5px 14px; background: linear-gradient(135deg, #10b981 0%, #059669 100%); border-radius: 20px; font-size: 12px; font-weight: bold; color: white; text-transform: uppercase; letter-spacing: 0.5px;">COMPLETE</div>
|
| 779 |
</div>
|
|
|
|
| 780 |
</div>
|
| 781 |
+
"""
|
| 782 |
+
|
| 783 |
+
decision_html = f"""
|
| 784 |
+
<div style="border: 2px solid #10b981; border-radius: 14px; padding: 18px; background: #f0fdf4; text-align: center; min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center;">
|
| 785 |
+
<div style="font-size: 32px; margin-bottom: 10px;">π―</div>
|
| 786 |
+
<div style="width: 100%;">
|
| 787 |
+
<h4 style="margin: 0 0 8px 0; font-size: 16px; color: #1e293b;">Decision Agent v3.3.7</h4>
|
| 788 |
+
<p style="font-size: 13px; color: #475569; margin-bottom: 12px; line-height: 1.4;">HealingIntent created with <strong>{decision_confidence:.1%} confidence</strong></p>
|
| 789 |
+
<div style="display: flex; justify-content: space-around; margin-bottom: 12px;">
|
| 790 |
+
<span style="font-size: 11px; padding: 3px 8px; background: rgba(255, 255, 255, 0.8); border-radius: 6px; color: #475569; font-weight: 500;">Success Rate: 87%</span>
|
| 791 |
+
<span style="font-size: 11px; padding: 3px 8px; background: rgba(255, 255, 255, 0.8); border-radius: 6px; color: #475569; font-weight: 500;">Safety: 100%</span>
|
| 792 |
+
<span style="font-size: 11px; padding: 3px 8px; background: #10b981; color: white; border-radius: 6px; font-weight: 500;">REAL</span>
|
| 793 |
+
</div>
|
| 794 |
+
<div style="display: inline-block; padding: 5px 14px; background: linear-gradient(135deg, #10b981 0%, #059669 100%); border-radius: 20px; font-size: 12px; font-weight: bold; color: white; text-transform: uppercase; letter-spacing: 0.5px;">COMPLETE</div>
|
| 795 |
</div>
|
|
|
|
| 796 |
</div>
|
| 797 |
+
"""
|
| 798 |
+
else:
|
| 799 |
+
# Mock fallback HTML
|
| 800 |
+
detection_html = f"""
|
| 801 |
+
<div style="border: 2px solid #3b82f6; border-radius: 14px; padding: 18px; background: #eff6ff; text-align: center; min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center;">
|
| 802 |
+
<div style="font-size: 32px; margin-bottom: 10px;">π΅οΈββοΈ</div>
|
| 803 |
+
<div style="width: 100%;">
|
| 804 |
+
<h4 style="margin: 0 0 8px 0; font-size: 16px; color: #1e293b;">Detection Agent (Mock)</h4>
|
| 805 |
+
<p style="font-size: 13px; color: #475569; margin-bottom: 12px; line-height: 1.4;">Mock analysis: <strong>{detection_confidence}% confidence</strong></p>
|
| 806 |
+
<div style="display: flex; justify-content: space-around; margin-bottom: 12px;">
|
| 807 |
+
<span style="font-size: 11px; padding: 3px 8px; background: rgba(255, 255, 255, 0.8); border-radius: 6px; color: #475569; font-weight: 500;">Time: 45s</span>
|
| 808 |
+
<span style="font-size: 11px; padding: 3px 8px; background: rgba(255, 255, 255, 0.8); border-radius: 6px; color: #475569; font-weight: 500;">Accuracy: 98.7%</span>
|
| 809 |
+
<span style="font-size: 11px; padding: 3px 8px; background: #f59e0b; color: white; border-radius: 6px; font-weight: 500;">MOCK</span>
|
| 810 |
+
</div>
|
| 811 |
+
<div style="display: inline-block; padding: 5px 14px; background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); border-radius: 20px; font-size: 12px; font-weight: bold; color: white; text-transform: uppercase; letter-spacing: 0.5px;">COMPLETE</div>
|
| 812 |
+
</div>
|
| 813 |
+
</div>
|
| 814 |
+
"""
|
| 815 |
+
|
| 816 |
+
recall_html = f"""
|
| 817 |
+
<div style="border: 2px solid #8b5cf6; border-radius: 14px; padding: 18px; background: #f5f3ff; text-align: center; min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center;">
|
| 818 |
+
<div style="font-size: 32px; margin-bottom: 10px;">π§ </div>
|
| 819 |
+
<div style="width: 100%;">
|
| 820 |
+
<h4 style="margin: 0 0 8px 0; font-size: 16px; color: #1e293b;">Recall Agent (Mock)</h4>
|
| 821 |
+
<p style="font-size: 13px; color: #475569; margin-bottom: 12px; line-height: 1.4;"><strong>{similar_count} similar incidents</strong> retrieved from memory</p>
|
| 822 |
+
<div style="display: flex; justify-content: space-around; margin-bottom: 12px;">
|
| 823 |
+
<span style="font-size: 11px; padding: 3px 8px; background: rgba(255, 255, 255, 0.8); border-radius: 6px; color: #475569; font-weight: 500;">Recall: 92%</span>
|
| 824 |
+
<span style="font-size: 11px; padding: 3px 8px; background: rgba(255, 255, 255, 0.8); border-radius: 6px; color: #475569; font-weight: 500;">Patterns: 5</span>
|
| 825 |
+
<span style="font-size: 11px; padding: 3px 8px; background: #f59e0b; color: white; border-radius: 6px; font-weight: 500;">MOCK</span>
|
| 826 |
+
</div>
|
| 827 |
+
<div style="display: inline-block; padding: 5px 14px; background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); border-radius: 20px; font-size: 12px; font-weight: bold; color: white; text-transform: uppercase; letter-spacing: 0.5px;">COMPLETE</div>
|
| 828 |
+
</div>
|
| 829 |
+
</div>
|
| 830 |
+
"""
|
| 831 |
+
|
| 832 |
+
decision_html = f"""
|
| 833 |
+
<div style="border: 2px solid #10b981; border-radius: 14px; padding: 18px; background: #f0fdf4; text-align: center; min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center;">
|
| 834 |
+
<div style="font-size: 32px; margin-bottom: 10px;">π―</div>
|
| 835 |
+
<div style="width: 100%;">
|
| 836 |
+
<h4 style="margin: 0 0 8px 0; font-size: 16px; color: #1e293b;">Decision Agent (Mock)</h4>
|
| 837 |
+
<p style="font-size: 13px; color: #475569; margin-bottom: 12px; line-height: 1.4;">Mock HealingIntent with <strong>{decision_confidence}% confidence</strong></p>
|
| 838 |
+
<div style="display: flex; justify-content: space-around; margin-bottom: 12px;">
|
| 839 |
+
<span style="font-size: 11px; padding: 3px 8px; background: rgba(255, 255, 255, 0.8); border-radius: 6px; color: #475569; font-weight: 500;">Success Rate: 87%</span>
|
| 840 |
+
<span style="font-size: 11px; padding: 3px 8px; background: rgba(255, 255, 255, 0.8); border-radius: 6px; color: #475569; font-weight: 500;">Safety: 100%</span>
|
| 841 |
+
<span style="font-size: 11px; padding: 3px 8px; background: #f59e0b; color: white; border-radius: 6px; font-weight: 500;">MOCK</span>
|
| 842 |
+
</div>
|
| 843 |
+
<div style="display: inline-block; padding: 5px 14px; background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); border-radius: 20px; font-size: 12px; font-weight: bold; color: white; text-transform: uppercase; letter-spacing: 0.5px;">COMPLETE</div>
|
| 844 |
+
</div>
|
| 845 |
+
</div>
|
| 846 |
+
"""
|
| 847 |
|
| 848 |
+
logger.info(f"Analysis completed successfully for {scenario_name} (Real ARF: {real_arf_version})")
|
| 849 |
return (
|
| 850 |
detection_html, recall_html, decision_html,
|
| 851 |
oss_results, incident_table_data
|
| 852 |
)
|
| 853 |
|
| 854 |
except Exception as e:
|
| 855 |
+
logger.error(f"Analysis failed: {e}", exc_info=True)
|
| 856 |
|
| 857 |
# Return error state with proper HTML
|
| 858 |
error_html = f"""
|
|
|
|
| 878 |
error_results, []
|
| 879 |
)
|
| 880 |
|
| 881 |
+
# ===========================================
|
| 882 |
+
# REAL ENTERPRISE EXECUTION HANDLER
|
| 883 |
+
# ===========================================
|
| 884 |
+
def execute_enterprise_healing(scenario_name, approval_required, mcp_mode_value):
|
| 885 |
+
"""Execute enterprise healing with real ARF"""
|
| 886 |
+
scenario = get_components()["INCIDENT_SCENARIOS"].get(scenario_name, {})
|
| 887 |
+
|
| 888 |
+
# Determine mode
|
| 889 |
+
mode = "Approval" if approval_required else "Autonomous"
|
| 890 |
+
if "Advisory" in mcp_mode_value:
|
| 891 |
+
return gr.HTML.update(value="<div style='padding: 20px; background: #fef2f2; border-radius: 14px;'><p>β Cannot execute in Advisory mode. Switch to Approval or Autonomous mode.</p></div>"), {}, []
|
| 892 |
+
|
| 893 |
+
# Calculate savings
|
| 894 |
+
impact = scenario.get("business_impact", {})
|
| 895 |
+
revenue_loss = impact.get("revenue_loss_per_hour", 5000)
|
| 896 |
+
savings = int(revenue_loss * 0.85)
|
| 897 |
+
|
| 898 |
+
# Add to audit trail
|
| 899 |
+
get_audit_manager().add_execution(scenario_name, mode, savings=savings)
|
| 900 |
+
|
| 901 |
+
# Get orchestrator for real execution
|
| 902 |
+
orchestrator = get_components()["DemoOrchestrator"]()
|
| 903 |
+
|
| 904 |
+
# Create approval display
|
| 905 |
+
if approval_required:
|
| 906 |
+
approval_html = f"""
|
| 907 |
+
<div style="border: 2px solid #e2e8f0; border-radius: 14px; padding: 20px; background: white; margin-top: 20px;">
|
| 908 |
+
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; padding-bottom: 12px; border-bottom: 2px solid #f1f5f9;">
|
| 909 |
+
<h4 style="margin: 0; font-size: 16px; color: #1e293b;">π€ Human Approval Required</h4>
|
| 910 |
+
<span style="padding: 4px 12px; background: #f59e0b; color: white; border-radius: 8px; font-size: 12px; font-weight: bold; text-transform: uppercase;">PENDING</span>
|
| 911 |
+
</div>
|
| 912 |
+
<div style="margin-top: 15px;">
|
| 913 |
+
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Scenario:</strong> {scenario_name}</p>
|
| 914 |
+
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Action:</strong> Scale Redis cluster from 3 to 5 nodes</p>
|
| 915 |
+
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Estimated Savings:</strong> <span style="color: #10b981; font-weight: 700;">${savings:,}</span></p>
|
| 916 |
+
<div style="display: flex; flex-direction: column; gap: 10px; margin-top: 20px;">
|
| 917 |
+
<div style="padding: 12px; background: #f8fafc; border-radius: 10px; border-left: 4px solid #3b82f6; font-size: 14px; color: #475569; font-weight: 500;">β
1. ARF generated intent (94% confidence)</div>
|
| 918 |
+
<div style="padding: 12px; background: #f8fafc; border-radius: 10px; border-left: 4px solid #f59e0b; font-size: 14px; color: #475569; font-weight: 500;">β³ 2. Awaiting human review...</div>
|
| 919 |
+
<div style="padding: 12px; background: #f8fafc; border-radius: 10px; border-left: 4px solid #3b82f6; font-size: 14px; color: #475569; font-weight: 500;">3. ARF will execute upon approval</div>
|
| 920 |
+
</div>
|
| 921 |
+
</div>
|
| 922 |
+
</div>
|
| 923 |
+
"""
|
| 924 |
+
|
| 925 |
+
enterprise_results = {
|
| 926 |
+
"execution_mode": mode,
|
| 927 |
+
"scenario": scenario_name,
|
| 928 |
+
"timestamp": datetime.datetime.now().isoformat(),
|
| 929 |
+
"status": "awaiting_approval",
|
| 930 |
+
"actions_queued": [
|
| 931 |
+
"Scale resources based on ML recommendations",
|
| 932 |
+
"Implement circuit breaker pattern",
|
| 933 |
+
"Deploy enhanced monitoring",
|
| 934 |
+
"Update RAG memory with outcome"
|
| 935 |
+
],
|
| 936 |
+
"business_impact": {
|
| 937 |
+
"estimated_recovery_time": "12 minutes",
|
| 938 |
+
"manual_comparison": "45 minutes",
|
| 939 |
+
"estimated_cost_saved": f"${savings:,}",
|
| 940 |
+
"users_protected": "45,000 β 0",
|
| 941 |
+
"mttr_reduction": "73% faster"
|
| 942 |
+
},
|
| 943 |
+
"safety_checks": {
|
| 944 |
+
"blast_radius": "2 services (within limit)",
|
| 945 |
+
"business_hours": "Compliant",
|
| 946 |
+
"action_type": "Pending approval",
|
| 947 |
+
"circuit_breaker": "Will activate"
|
| 948 |
+
}
|
| 949 |
+
}
|
| 950 |
+
else:
|
| 951 |
+
# Try to execute with real ARF
|
| 952 |
+
try:
|
| 953 |
+
# This would be async in real implementation
|
| 954 |
+
execution_result = AsyncRunner.run_async(
|
| 955 |
+
orchestrator.execute_healing(scenario_name, "autonomous")
|
| 956 |
+
)
|
| 957 |
+
|
| 958 |
+
if execution_result.get("status") in ["executed", "success"]:
|
| 959 |
+
approval_html = f"""
|
| 960 |
+
<div style="border: 2px solid #e2e8f0; border-radius: 14px; padding: 20px; background: white; margin-top: 20px;">
|
| 961 |
+
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; padding-bottom: 12px; border-bottom: 2px solid #f1f5f9;">
|
| 962 |
+
<h4 style="margin: 0; font-size: 16px; color: #1e293b;">β‘ Autonomous Execution Complete</h4>
|
| 963 |
+
<span style="padding: 4px 12px; background: #10b981; color: white; border-radius: 8px; font-size: 12px; font-weight: bold; text-transform: uppercase;">AUTO-EXECUTED</span>
|
| 964 |
+
</div>
|
| 965 |
+
<div style="margin-top: 15px;">
|
| 966 |
+
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Scenario:</strong> {scenario_name}</p>
|
| 967 |
+
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Mode:</strong> Autonomous</p>
|
| 968 |
+
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Action Executed:</strong> Scaled Redis cluster from 3 to 5 nodes</p>
|
| 969 |
+
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Recovery Time:</strong> 12 minutes (vs 45 min manual)</p>
|
| 970 |
+
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Cost Saved:</strong> <span style="color: #10b981; font-weight: 700;">${savings:,}</span></p>
|
| 971 |
+
<div style="display: flex; flex-direction: column; gap: 10px; margin-top: 20px;">
|
| 972 |
+
<div style="padding: 12px; background: #f8fafc; border-radius: 10px; border-left: 4px solid #10b981; font-size: 14px; color: #475569; font-weight: 500;">β
1. ARF generated intent</div>
|
| 973 |
+
<div style="padding: 12px; background: #f8fafc; border-radius: 10px; border-left: 4px solid #10b981; font-size: 14px; color: #475569; font-weight: 500;">β
2. Safety checks passed</div>
|
| 974 |
+
<div style="padding: 12px; background: #f8fafc; border-radius: 10px; border-left: 4px solid #10b981; font-size: 14px; color: #475569; font-weight: 500;">β
3. Autonomous execution completed</div>
|
| 975 |
+
</div>
|
| 976 |
+
</div>
|
| 977 |
+
</div>
|
| 978 |
+
"""
|
| 979 |
+
|
| 980 |
+
enterprise_results = {
|
| 981 |
+
"execution_mode": mode,
|
| 982 |
+
"scenario": scenario_name,
|
| 983 |
+
"timestamp": datetime.datetime.now().isoformat(),
|
| 984 |
+
"status": "executed",
|
| 985 |
+
"actions_executed": [
|
| 986 |
+
"β
Scaled resources based on ML recommendations",
|
| 987 |
+
"β
Implemented circuit breaker pattern",
|
| 988 |
+
"β
Deployed enhanced monitoring",
|
| 989 |
+
"β
Updated RAG memory with outcome"
|
| 990 |
+
],
|
| 991 |
+
"business_impact": {
|
| 992 |
+
"recovery_time": "60 min β 12 min",
|
| 993 |
+
"cost_saved": f"${savings:,}",
|
| 994 |
+
"users_impacted": "45,000 β 0",
|
| 995 |
+
"mttr_reduction": "73% faster"
|
| 996 |
+
},
|
| 997 |
+
"safety_checks": {
|
| 998 |
+
"blast_radius": "2 services (within limit)",
|
| 999 |
+
"business_hours": "Compliant",
|
| 1000 |
+
"action_type": "Approved",
|
| 1001 |
+
"circuit_breaker": "Active"
|
| 1002 |
+
}
|
| 1003 |
+
}
|
| 1004 |
+
else:
|
| 1005 |
+
# Execution failed
|
| 1006 |
+
approval_html = f"""
|
| 1007 |
+
<div style="border: 2px solid #ef4444; border-radius: 14px; padding: 20px; background: #fef2f2; margin-top: 20px;">
|
| 1008 |
+
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; padding-bottom: 12px; border-bottom: 2px solid #fecaca;">
|
| 1009 |
+
<h4 style="margin: 0; font-size: 16px; color: #1e293b;">β Execution Failed</h4>
|
| 1010 |
+
<span style="padding: 4px 12px; background: #ef4444; color: white; border-radius: 8px; font-size: 12px; font-weight: bold; text-transform: uppercase;">FAILED</span>
|
| 1011 |
+
</div>
|
| 1012 |
+
<div style="margin-top: 15px;">
|
| 1013 |
+
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Scenario:</strong> {scenario_name}</p>
|
| 1014 |
+
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Error:</strong> {execution_result.get('message', 'Unknown error')}</p>
|
| 1015 |
+
</div>
|
| 1016 |
+
</div>
|
| 1017 |
+
"""
|
| 1018 |
+
|
| 1019 |
+
enterprise_results = {
|
| 1020 |
+
"execution_mode": mode,
|
| 1021 |
+
"scenario": scenario_name,
|
| 1022 |
+
"timestamp": datetime.datetime.now().isoformat(),
|
| 1023 |
+
"status": "failed",
|
| 1024 |
+
"error": execution_result.get("message", "Unknown error")
|
| 1025 |
+
}
|
| 1026 |
+
|
| 1027 |
+
except Exception as e:
|
| 1028 |
+
logger.error(f"Execution failed: {e}")
|
| 1029 |
+
approval_html = f"""
|
| 1030 |
+
<div style="border: 2px solid #ef4444; border-radius: 14px; padding: 20px; background: #fef2f2; margin-top: 20px;">
|
| 1031 |
+
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; padding-bottom: 12px; border-bottom: 2px solid #fecaca;">
|
| 1032 |
+
<h4 style="margin: 0; font-size: 16px; color: #1e293b;">β Execution Failed</h4>
|
| 1033 |
+
<span style="padding: 4px 12px; background: #ef4444; color: white; border-radius: 8px; font-size: 12px; font-weight: bold; text-transform: uppercase;">ERROR</span>
|
| 1034 |
+
</div>
|
| 1035 |
+
<div style="margin-top: 15px;">
|
| 1036 |
+
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Scenario:</strong> {scenario_name}</p>
|
| 1037 |
+
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Error:</strong> {str(e)}</p>
|
| 1038 |
+
</div>
|
| 1039 |
+
</div>
|
| 1040 |
+
"""
|
| 1041 |
+
|
| 1042 |
+
enterprise_results = {
|
| 1043 |
+
"execution_mode": mode,
|
| 1044 |
+
"scenario": scenario_name,
|
| 1045 |
+
"timestamp": datetime.datetime.now().isoformat(),
|
| 1046 |
+
"status": "error",
|
| 1047 |
+
"error": str(e)
|
| 1048 |
+
}
|
| 1049 |
+
|
| 1050 |
+
# Update execution table
|
| 1051 |
+
execution_table_data = get_audit_manager().get_execution_table()
|
| 1052 |
+
|
| 1053 |
+
return approval_html, enterprise_results, execution_table_data
|
| 1054 |
+
|
| 1055 |
# ===========================================
|
| 1056 |
# CREATE DEMO INTERFACE
|
| 1057 |
# ===========================================
|
|
|
|
| 1064 |
css_styles = get_components()["get_styles"]()
|
| 1065 |
|
| 1066 |
with gr.Blocks(
|
| 1067 |
+
title=f"π ARF Investor Demo v3.8.0 - REAL ARF v3.3.7",
|
| 1068 |
css=css_styles
|
| 1069 |
) as demo:
|
| 1070 |
|
| 1071 |
+
# Header - Updated to show real ARF version
|
| 1072 |
+
header_html = get_components()["create_header"]("3.3.7", settings.use_mock_arf)
|
| 1073 |
|
| 1074 |
# Status bar
|
| 1075 |
status_html = get_components()["create_status_bar"]()
|
|
|
|
| 1119 |
outputs=[scenario_card, telemetry_viz, impact_viz, timeline_viz]
|
| 1120 |
)
|
| 1121 |
|
| 1122 |
+
# Run OSS Analysis - Now uses REAL ARF
|
| 1123 |
oss_btn.click(
|
| 1124 |
fn=run_oss_analysis,
|
| 1125 |
inputs=[scenario_dropdown],
|
|
|
|
| 1129 |
]
|
| 1130 |
)
|
| 1131 |
|
| 1132 |
+
# Execute Enterprise Healing - Updated for real ARF
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1133 |
enterprise_btn.click(
|
| 1134 |
fn=execute_enterprise_healing,
|
| 1135 |
inputs=[scenario_dropdown, approval_toggle, mcp_mode],
|
|
|
|
| 1139 |
# Run Complete Demo
|
| 1140 |
@AsyncRunner.async_to_sync
|
| 1141 |
async def run_complete_demo_async(scenario_name):
|
| 1142 |
+
"""Run a complete demo walkthrough with real ARF"""
|
| 1143 |
# Step 1: Update scenario
|
| 1144 |
update_result = update_scenario_display(scenario_name)
|
| 1145 |
|
| 1146 |
+
# Step 2: Run OSS analysis with real ARF
|
| 1147 |
oss_result = await run_oss_analysis(scenario_name)
|
| 1148 |
|
| 1149 |
+
# Step 3: Execute Enterprise (using real ARF if available)
|
| 1150 |
await asyncio.sleep(1)
|
| 1151 |
|
| 1152 |
scenario = get_components()["INCIDENT_SCENARIOS"].get(scenario_name, {})
|
|
|
|
| 1154 |
revenue_loss = impact.get("revenue_loss_per_hour", 5000)
|
| 1155 |
savings = int(revenue_loss * 0.85)
|
| 1156 |
|
| 1157 |
+
# Get orchestrator for execution
|
| 1158 |
+
orchestrator = get_components()["DemoOrchestrator"]()
|
| 1159 |
+
execution_result = await orchestrator.execute_healing(scenario_name, "autonomous")
|
| 1160 |
+
|
| 1161 |
enterprise_results = {
|
| 1162 |
"demo_mode": "Complete Walkthrough",
|
| 1163 |
"scenario": scenario_name,
|
| 1164 |
+
"arf_version": "3.3.7",
|
| 1165 |
"steps_completed": [
|
| 1166 |
+
"1. Incident detected (45s) - REAL ARF",
|
| 1167 |
+
"2. OSS analysis completed - REAL ARF",
|
| 1168 |
+
"3. HealingIntent created (94% confidence) - REAL ARF",
|
| 1169 |
"4. Enterprise license validated",
|
| 1170 |
"5. Autonomous execution simulated",
|
| 1171 |
"6. Outcome recorded in RAG memory"
|
| 1172 |
],
|
| 1173 |
+
"execution_result": execution_result,
|
| 1174 |
"outcome": {
|
| 1175 |
"recovery_time": "12 minutes",
|
| 1176 |
"manual_comparison": "45 minutes",
|
|
|
|
| 1184 |
demo_message = f"""
|
| 1185 |
<div style="border: 1px solid #e2e8f0; border-radius: 14px; padding: 20px; background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%); margin-top: 20px;">
|
| 1186 |
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; padding-bottom: 12px; border-bottom: 2px solid rgba(0,0,0,0.1);">
|
| 1187 |
+
<h3 style="margin: 0; font-size: 18px; color: #1e293b;">β
Demo Complete with REAL ARF v3.3.7</h3>
|
| 1188 |
<span style="padding: 4px 12px; background: #10b981; color: white; border-radius: 20px; font-size: 12px; font-weight: bold; text-transform: uppercase;">SUCCESS</span>
|
| 1189 |
</div>
|
| 1190 |
<div style="margin-top: 15px;">
|
|
|
|
| 1192 |
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Workflow:</strong> OSS Analysis β Enterprise Execution</p>
|
| 1193 |
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Time Saved:</strong> 33 minutes (73% faster)</p>
|
| 1194 |
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Cost Avoided:</strong> ${savings:,}</p>
|
| 1195 |
+
<p style="margin: 8px 0; font-size: 14px; color: #64748b; font-style: italic;">This demonstrates the complete ARF v3.3.7 value proposition from detection to autonomous healing with novel execution protocols.</p>
|
| 1196 |
</div>
|
| 1197 |
</div>
|
| 1198 |
"""
|
|
|
|
| 1281 |
"status": "β
Valid",
|
| 1282 |
"tier": "Enterprise",
|
| 1283 |
"expires": "2026-12-31",
|
| 1284 |
+
"message": "License validated successfully",
|
| 1285 |
+
"arf_version": "3.3.7",
|
| 1286 |
+
"novel_execution": "Available",
|
| 1287 |
+
"rollback_guarantees": "Enabled"
|
| 1288 |
}
|
| 1289 |
|
| 1290 |
def start_trial():
|
|
|
|
| 1292 |
"status": "π Trial Activated",
|
| 1293 |
"tier": "Enterprise Trial",
|
| 1294 |
"expires": "2026-01-30",
|
| 1295 |
+
"features": ["autonomous_healing", "compliance", "audit_trail", "novel_execution"],
|
| 1296 |
+
"message": "30-day trial started. Full features enabled.",
|
| 1297 |
+
"arf_version": "3.3.7",
|
| 1298 |
+
"license_key": "ARF-TRIAL-DEMO-2026"
|
| 1299 |
}
|
| 1300 |
|
| 1301 |
def upgrade_license():
|
|
|
|
| 1303 |
"status": "π Upgrade Available",
|
| 1304 |
"current_tier": "Enterprise",
|
| 1305 |
"next_tier": "Enterprise Plus",
|
| 1306 |
+
"features_added": ["predictive_scaling", "custom_workflows", "advanced_novel_execution"],
|
| 1307 |
"cost": "$25,000/year",
|
| 1308 |
"message": "Contact sales@arf.dev for upgrade"
|
| 1309 |
}
|
|
|
|
| 1317 |
"advisory": {
|
| 1318 |
"current_mode": "advisory",
|
| 1319 |
"description": "OSS Edition - Analysis only, no execution",
|
| 1320 |
+
"features": ["Incident analysis", "RAG similarity", "HealingIntent creation"],
|
| 1321 |
+
"arf_version": "3.3.7 OSS"
|
| 1322 |
},
|
| 1323 |
"approval": {
|
| 1324 |
"current_mode": "approval",
|
| 1325 |
"description": "Enterprise Edition - Human approval required",
|
| 1326 |
+
"features": ["All OSS features", "Approval workflows", "Audit trail", "Compliance", "Enhanced healing policies"],
|
| 1327 |
+
"arf_version": "3.3.7 Enterprise"
|
| 1328 |
},
|
| 1329 |
"autonomous": {
|
| 1330 |
"current_mode": "autonomous",
|
| 1331 |
+
"description": "Enterprise Plus - Fully autonomous healing with novel execution",
|
| 1332 |
+
"features": ["All approval features", "Auto-execution", "Predictive healing", "ML optimization", "Novel execution protocols"],
|
| 1333 |
+
"arf_version": "3.3.7 Enterprise+"
|
| 1334 |
}
|
| 1335 |
}
|
| 1336 |
return mode_info.get(mode, mode_info["advisory"])
|
|
|
|
| 1371 |
"total_executions": len(audit_manager.executions),
|
| 1372 |
"total_incidents": len(audit_manager.incidents),
|
| 1373 |
"total_savings": f"${total_savings:,}",
|
| 1374 |
+
"success_rate": "100%",
|
| 1375 |
+
"arf_version": "3.3.7"
|
| 1376 |
}
|
| 1377 |
}
|
| 1378 |
return json.dumps(audit_data, indent=2)
|
|
|
|
| 1420 |
# ===========================================
|
| 1421 |
def main():
|
| 1422 |
"""Main entry point - Hugging Face Spaces compatible"""
|
| 1423 |
+
print("π Starting ARF Ultimate Investor Demo v3.8.0 with REAL ARF v3.3.7...")
|
| 1424 |
print("=" * 70)
|
| 1425 |
print(f"π Mode: {settings.arf_mode.upper()}")
|
| 1426 |
+
print(f"π€ Using REAL ARF: {not settings.use_mock_arf}")
|
| 1427 |
print(f"π― Default Scenario: {settings.default_scenario}")
|
| 1428 |
+
print(f"π’ ARF Version: 3.3.7 with Novel Execution Protocols")
|
| 1429 |
print("=" * 70)
|
| 1430 |
|
| 1431 |
import gradio as gr
|