| """ |
| 🚀 ARF Ultimate Investor Demo v3.8.0 - ENTERPRISE EDITION |
| Main entry point with comprehensive 5-tab interface |
| Uses actual ARF OSS v3.3.6 framework |
| """ |
|
|
| import logging |
| import sys |
| import traceback |
| import json |
| import datetime |
| from pathlib import Path |
| from typing import Dict, List, Any, Optional, Tuple |
|
|
| |
| logging.basicConfig( |
| level=logging.INFO, |
| format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', |
| handlers=[ |
| logging.StreamHandler(sys.stdout), |
| logging.FileHandler('arf_demo.log') |
| ] |
| ) |
| logger = logging.getLogger(__name__) |
|
|
| |
| sys.path.insert(0, str(Path(__file__).parent)) |
|
|
| try: |
| |
| try: |
| from agentic_reliability_framework import __version__ as arf_version |
| from agentic_reliability_framework.arf_core.models.healing_intent import ( |
| HealingIntent, create_scale_out_intent, create_rollback_intent |
| ) |
| from agentic_reliability_framework.arf_core.engine.simple_mcp_client import OSSMCPClient |
| from agentic_reliability_framework.engine.mcp_server import MCPServer, MCPMode |
| |
| ARF_OSS_AVAILABLE = True |
| OSS_VERSION = arf_version |
| logger.info(f"✅ Successfully imported ARF OSS v{OSS_VERSION}") |
| |
| |
| oss_client = OSSMCPClient() |
| |
| except ImportError as e: |
| logger.warning(f"Failed to import ARF OSS: {e}") |
| ARF_OSS_AVAILABLE = False |
| OSS_VERSION = "3.3.6 (Mock)" |
| |
| |
| class HealingIntent: |
| def __init__(self, action: str, component: str, parameters: Dict, **kwargs): |
| self.action = action |
| self.component = component |
| self.parameters = parameters |
| self.justification = kwargs.get('justification', '') |
| self.confidence = kwargs.get('confidence', 0.85) |
| self.similar_incidents = kwargs.get('similar_incidents', []) |
| self.rag_similarity_score = kwargs.get('rag_similarity_score') |
| |
| def to_enterprise_request(self) -> Dict: |
| return { |
| 'action': self.action, |
| 'component': self.component, |
| 'parameters': self.parameters, |
| 'justification': self.justification, |
| 'confidence': self.confidence, |
| 'requires_enterprise': True, |
| 'oss_metadata': { |
| 'similar_incidents_count': len(self.similar_incidents), |
| 'rag_used': self.rag_similarity_score is not None |
| } |
| } |
| |
| def mark_as_oss_advisory(self): |
| return self |
| |
| class OSSMCPClient: |
| def __init__(self): |
| self.mode = "advisory" |
| |
| async def analyze_and_recommend(self, tool_name: str, component: str, |
| parameters: Dict, context: Optional[Dict] = None) -> HealingIntent: |
| |
| similar_incidents = [ |
| {"id": "inc_001", "similarity": 0.78, "resolution": "scaled_out", "component": "redis"}, |
| {"id": "inc_045", "similarity": 0.65, "resolution": "restarted", "component": "database"}, |
| {"id": "inc_089", "similarity": 0.59, "resolution": "circuit_breaker", "component": "api"} |
| ] |
| |
| return HealingIntent( |
| action=tool_name, |
| component=component, |
| parameters=parameters, |
| justification=f"OSS Analysis: Based on {len(similar_incidents)} similar incidents, recommend {tool_name} for {component}", |
| confidence=0.82 + (len(similar_incidents) * 0.01), |
| similar_incidents=similar_incidents, |
| rag_similarity_score=0.72 |
| ) |
| |
| oss_client = OSSMCPClient() |
| |
| MCPMode = type('MCPMode', (), { |
| 'ADVISORY': 'advisory', |
| 'APPROVAL': 'approval', |
| 'AUTONOMOUS': 'autonomous' |
| }) |
| |
| |
| import gradio as gr |
| import plotly.graph_objects as go |
| import plotly.express as px |
| import pandas as pd |
| import numpy as np |
| from plotly.subplots import make_subplots |
| |
| |
| |
| |
| |
| class AuditTrailManager: |
| """Manage audit trail and execution history""" |
| |
| def __init__(self): |
| self.execution_history = [] |
| self.incident_history = [] |
| self._initialize_sample_data() |
| |
| def _initialize_sample_data(self): |
| """Initialize with sample historical data""" |
| base_time = datetime.datetime.now() - datetime.timedelta(hours=2) |
| |
| |
| sample_executions = [ |
| self._create_execution_entry( |
| base_time - datetime.timedelta(minutes=90), |
| "Cache Miss Storm", 4, 7200, "✅ Executed", "Auto-scaled cache" |
| ), |
| self._create_execution_entry( |
| base_time - datetime.timedelta(minutes=75), |
| "Memory Leak", 3, 5200, "✅ Executed", "Fixed memory leak" |
| ), |
| self._create_execution_entry( |
| base_time - datetime.timedelta(minutes=60), |
| "API Rate Limit", 4, 2800, "✅ Executed", "Increased rate limits" |
| ), |
| self._create_execution_entry( |
| base_time - datetime.timedelta(minutes=45), |
| "DB Connection Pool", 4, 3800, "✅ Executed", "Scaled connection pool" |
| ), |
| ] |
| |
| self.execution_history = sample_executions |
| |
| |
| services = ["API Gateway", "Database", "Redis Cache", "Auth Service", "Payment Service"] |
| |
| for i in range(10): |
| incident_time = base_time - datetime.timedelta(minutes=i * 15) |
| self.incident_history.append({ |
| "timestamp": incident_time, |
| "time_str": incident_time.strftime("%H:%M"), |
| "service": services[i % len(services)], |
| "type": "Cache Miss Storm" if i % 3 == 0 else "Memory Leak", |
| "severity": 3 if i % 3 == 0 else 2, |
| "description": f"High latency on {services[i % len(services)]}", |
| "id": f"inc_{i:03d}" |
| }) |
| |
| def _create_execution_entry(self, timestamp, scenario, actions, savings, status, details): |
| """Create an execution history entry""" |
| return { |
| "timestamp": timestamp, |
| "time_str": timestamp.strftime("%H:%M"), |
| "scenario": scenario, |
| "actions": str(actions), |
| "savings": f"${savings:,}", |
| "status": status, |
| "details": details, |
| "id": f"exec_{len(self.execution_history):03d}" |
| } |
| |
| def add_execution(self, scenario: str, actions: List[str], |
| savings: int, approval_required: bool, details: str = ""): |
| """Add new execution to history""" |
| entry = self._create_execution_entry( |
| datetime.datetime.now(), |
| scenario, |
| len(actions), |
| savings, |
| "✅ Approved & Executed" if approval_required else "✅ Auto-Executed", |
| details |
| ) |
| self.execution_history.insert(0, entry) |
| return entry |
| |
| def add_incident(self, scenario_name: str, metrics: Dict): |
| """Add incident to history""" |
| entry = { |
| "timestamp": datetime.datetime.now(), |
| "time_str": datetime.datetime.now().strftime("%H:%M"), |
| "service": "Demo System", |
| "type": scenario_name, |
| "severity": 3, |
| "description": f"Demo incident: {scenario_name}", |
| "id": f"inc_{len(self.incident_history):03d}" |
| } |
| self.incident_history.insert(0, entry) |
| return entry |
| |
| def get_execution_history_table(self, limit: int = 10) -> List[List]: |
| """Get execution history for table display""" |
| return [ |
| [entry["time_str"], entry["scenario"], entry["actions"], |
| entry["status"], entry["savings"], entry["details"]] |
| for entry in self.execution_history[:limit] |
| ] |
| |
| def get_incident_history_table(self, limit: int = 15) -> List[List]: |
| """Get incident history for table display""" |
| return [ |
| [entry["time_str"], entry["service"], entry["type"], |
| f"{entry['severity']}/3", entry["description"]] |
| for entry in self.incident_history[:limit] |
| ] |
| |
| def export_audit_trail(self) -> str: |
| """Export audit trail as JSON""" |
| total_savings = sum( |
| int(e["savings"].replace("$", "").replace(",", "")) |
| for e in self.execution_history |
| if "$" in e["savings"] |
| ) |
| |
| return json.dumps({ |
| "executions": self.execution_history, |
| "incidents": self.incident_history, |
| "exported_at": datetime.datetime.now().isoformat(), |
| "total_executions": len(self.execution_history), |
| "total_incidents": len(self.incident_history), |
| "total_savings": total_savings, |
| "arf_version": OSS_VERSION, |
| "oss_available": ARF_OSS_AVAILABLE |
| }, indent=2, default=str) |
| |
| |
| |
| |
| |
| INCIDENT_SCENARIOS = { |
| "Cache Miss Storm": { |
| "description": "Redis cluster experiencing 80% cache miss rate causing database overload", |
| "severity": "CRITICAL", |
| "metrics": { |
| "Cache Hit Rate": "18.5% (Critical)", |
| "Database Load": "92% (Overloaded)", |
| "Response Time": "1850ms (Slow)", |
| "Affected Users": "45,000", |
| "Eviction Rate": "125/sec" |
| }, |
| "impact": { |
| "Revenue Loss": "$8,500/hour", |
| "Page Load Time": "+300%", |
| "Users Impacted": "45,000", |
| "SLA Violation": "Yes", |
| "Customer Sat": "-40%" |
| }, |
| "oss_analysis": { |
| "status": "✅ ARF OSS Analysis Complete", |
| "recommendations": [ |
| "Increase Redis cache memory allocation", |
| "Implement cache warming strategy", |
| "Optimize key patterns (TTL adjustments)", |
| "Add circuit breaker for database fallback", |
| "Deploy monitoring for cache hit rate trends" |
| ], |
| "estimated_time": "60+ minutes", |
| "engineers_needed": "2-3 SREs + 1 DBA", |
| "manual_effort": "High", |
| "total_cost": "$8,500", |
| "healing_intent": "scale_out_cache" |
| }, |
| "enterprise_results": { |
| "actions_completed": [ |
| "✅ Auto-scaled Redis cluster: 4GB → 8GB", |
| "✅ Deployed intelligent cache warming service", |
| "✅ Optimized 12 key patterns with ML recommendations", |
| "✅ Implemented circuit breaker with 95% success rate", |
| "✅ Validated recovery with automated testing" |
| ], |
| "metrics_improvement": { |
| "Cache Hit Rate": "18.5% → 72%", |
| "Response Time": "1850ms → 450ms", |
| "Database Load": "92% → 45%", |
| "Throughput": "1250 → 2450 req/sec" |
| }, |
| "business_impact": { |
| "Recovery Time": "60 min → 12 min", |
| "Cost Saved": "$7,200", |
| "Users Impacted": "45,000 → 0", |
| "Revenue Protected": "$1,700", |
| "MTTR Improvement": "80% reduction" |
| } |
| } |
| }, |
| "Database Connection Pool Exhaustion": { |
| "description": "Database connection pool exhausted causing API timeouts and user failures", |
| "severity": "HIGH", |
| "metrics": { |
| "Active Connections": "98/100 (Critical)", |
| "API Latency": "2450ms", |
| "Error Rate": "15.2%", |
| "Queue Depth": "1250", |
| "Connection Wait": "45s" |
| }, |
| "impact": { |
| "Revenue Loss": "$4,200/hour", |
| "Affected Services": "API Gateway, User Service, Payment", |
| "SLA Violation": "Yes", |
| "Partner Impact": "3 external APIs" |
| } |
| }, |
| "Memory Leak in Production": { |
| "description": "Java service memory leak causing gradual performance degradation", |
| "severity": "HIGH", |
| "metrics": { |
| "Memory Usage": "96% (Critical)", |
| "GC Pause Time": "4500ms", |
| "Error Rate": "28.5%", |
| "Restart Frequency": "12/hour", |
| "Heap Fragmentation": "42%" |
| }, |
| "impact": { |
| "Revenue Loss": "$5,500/hour", |
| "Session Loss": "8,500 users", |
| "Customer Impact": "High", |
| "Support Tickets": "+300%" |
| } |
| } |
| } |
| |
| |
| |
| |
| |
| class BusinessLogic: |
| """Business logic for the demo""" |
| |
| def __init__(self, audit_manager: AuditTrailManager, oss_client): |
| self.audit_manager = audit_manager |
| self.oss_client = oss_client |
| self.license_info = { |
| "valid": True, |
| "customer_name": "Demo Enterprise Corp", |
| "customer_email": "demo@enterprise.com", |
| "tier": "ENTERPRISE", |
| "expires_at": "2024-12-31T23:59:59", |
| "features": ["autonomous_healing", "compliance", "audit_trail", "multi_cloud"], |
| "max_services": 100, |
| "max_incidents_per_month": 1000, |
| "status": "✅ Active" |
| } |
| |
| async def run_oss_analysis(self, scenario_name: str) -> Dict: |
| """Run OSS analysis using actual ARF framework""" |
| scenario = INCIDENT_SCENARIOS.get(scenario_name, {}) |
| |
| |
| healing_intent = await self.oss_client.analyze_and_recommend( |
| tool_name="scale_out", |
| component="redis_cache", |
| parameters={"scale_factor": 2.0, "resource_type": "memory"}, |
| context={ |
| "incident_type": scenario_name, |
| "metrics": scenario.get("metrics", {}), |
| "severity": scenario.get("severity", "HIGH") |
| } |
| ) |
| |
| |
| analysis = scenario.get("oss_analysis", {}).copy() |
| analysis["healing_intent"] = healing_intent.to_enterprise_request() |
| analysis["arf_oss_version"] = OSS_VERSION |
| analysis["analysis_timestamp"] = datetime.datetime.now().isoformat() |
| |
| |
| self.audit_manager.add_incident(scenario_name, scenario.get("metrics", {})) |
| |
| return analysis |
| |
| def execute_enterprise_healing(self, scenario_name: str, approval_required: bool) -> Tuple[Dict, Dict]: |
| """Execute enterprise healing""" |
| scenario = INCIDENT_SCENARIOS.get(scenario_name, {}) |
| results = scenario.get("enterprise_results", {}).copy() |
| |
| |
| results["enterprise_context"] = { |
| "approval_required": approval_required, |
| "execution_mode": "autonomous" if not approval_required else "approval", |
| "timestamp": datetime.datetime.now().isoformat(), |
| "license_tier": self.license_info["tier"] |
| } |
| |
| |
| savings = 7200 if scenario_name == "Cache Miss Storm" else 4200 |
| |
| |
| self.audit_manager.add_execution( |
| scenario_name, |
| results.get("actions_completed", []), |
| savings, |
| approval_required, |
| f"Healed {scenario_name} incident" |
| ) |
| |
| |
| approval_html = self._create_approval_html(scenario_name, approval_required) |
| |
| return approval_html, results |
| |
| def _create_approval_html(self, scenario_name: str, approval_required: bool) -> str: |
| """Create approval workflow HTML""" |
| if approval_required: |
| return f""" |
| <div style='padding: 20px; background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%); border-radius: 10px; border-left: 4px solid #007bff; margin: 10px 0;'> |
| <div style='display: flex; align-items: center; gap: 10px; margin-bottom: 15px;'> |
| <div style='background: #007bff; color: white; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold;'> |
| 🛡️ |
| </div> |
| <h4 style='margin: 0; color: #1a365d;'>Approval Required</h4> |
| </div> |
| <div style='background: white; padding: 15px; border-radius: 8px; margin-bottom: 10px;'> |
| <div style='display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;'> |
| <div><strong>Action:</strong> Scale resources for {scenario_name}</div> |
| <div><strong>Risk Level:</strong> <span style='color: #28a745;'>Low</span></div> |
| <div><strong>Blast Radius:</strong> Limited to affected service</div> |
| <div><strong>Auto-rollback:</strong> Available</div> |
| </div> |
| </div> |
| <div style='display: flex; justify-content: space-between; align-items: center;'> |
| <div> |
| <div style='font-size: 0.9rem; color: #6c757d;'>Status</div> |
| <div style='font-weight: bold; color: #28a745;'>✅ Approved & Executed</div> |
| </div> |
| <div style='font-size: 0.85rem; color: #6c757d;'> |
| {datetime.datetime.now().strftime("%H:%M:%S")} |
| </div> |
| </div> |
| </div> |
| """ |
| else: |
| return f""" |
| <div style='padding: 20px; background: linear-gradient(135deg, #e8f5e8 0%, #d4edda 100%); border-radius: 10px; border-left: 4px solid #28a745; margin: 10px 0;'> |
| <div style='display: flex; align-items: center; gap: 10px; margin-bottom: 15px;'> |
| <div style='background: #28a745; color: white; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold;'> |
| ⚡ |
| </div> |
| <h4 style='margin: 0; color: #1a365d;'>Auto-Executed</h4> |
| </div> |
| <div style='background: white; padding: 15px; border-radius: 8px; margin-bottom: 10px;'> |
| <div style='display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;'> |
| <div><strong>Action:</strong> Autonomous healing for {scenario_name}</div> |
| <div><strong>Mode:</strong> Fully autonomous</div> |
| <div><strong>Guardrails:</strong> Safety limits active</div> |
| <div><strong>Rollback:</strong> Ready if needed</div> |
| </div> |
| </div> |
| <div style='display: flex; justify-content: space-between; align-items: center;'> |
| <div> |
| <div style='font-size: 0.9rem; color: #6c757d;'>Status</div> |
| <div style='font-weight: bold; color: #28a745;'>✅ Successfully completed</div> |
| </div> |
| <div style='font-size: 0.85rem; color: #6c757d;'> |
| {datetime.datetime.now().strftime("%H:%M:%S")} |
| </div> |
| </div> |
| </div> |
| """ |
| |
| def calculate_roi(self, monthly_incidents: int, avg_impact: int, team_size: int) -> Dict: |
| """Calculate ROI""" |
| try: |
| annual_impact = monthly_incidents * 12 * avg_impact |
| team_cost = team_size * 150000 |
| savings = annual_impact * 0.82 |
| |
| roi_multiplier = savings / team_cost if team_cost > 0 else 0 |
| |
| if roi_multiplier >= 5.0: |
| recommendation = "🚀 Excellent fit for ARF Enterprise" |
| icon = "🚀" |
| color = "#28a745" |
| elif roi_multiplier >= 2.0: |
| recommendation = "✅ Good ROI with ARF Enterprise" |
| icon = "✅" |
| color = "#20c997" |
| elif roi_multiplier >= 1.0: |
| recommendation = "⚠️ Consider ARF OSS edition first" |
| icon = "ℹ️" |
| color = "#ffc107" |
| else: |
| recommendation = "🆓 Start with ARF OSS (free)" |
| icon = "🆓" |
| color = "#6c757d" |
| |
| payback = (team_cost / (savings / 12)) if savings > 0 else 0 |
| |
| return { |
| "analysis": { |
| "your_annual_impact": f"${annual_impact:,.0f}", |
| "your_team_cost": f"${team_cost:,.0f}", |
| "potential_savings": f"${savings:,.0f}", |
| "your_roi_multiplier": f"{roi_multiplier:.1f}×", |
| "vs_industry_average": "5.2× average ROI", |
| "recommendation": f"{icon} {recommendation}", |
| "recommendation_color": color, |
| "payback_period": f"{payback:.1f} months" if savings > 0 else "N/A", |
| "annual_savings_potential": f"${savings - team_cost:,.0f}" if savings > team_cost else "$0" |
| } |
| } |
| except Exception as e: |
| return {"error": f"Calculation error: {str(e)}"} |
| |
| |
| |
| |
| |
| class VisualizationEngine: |
| """Enhanced visualization engine""" |
| |
| @staticmethod |
| def create_incident_timeline() -> go.Figure: |
| """Create interactive incident timeline""" |
| fig = go.Figure() |
| |
| |
| now = datetime.datetime.now() |
| events = [ |
| {"time": now - datetime.timedelta(minutes=25), "event": "📉 Cache hit rate drops to 18.5%", "type": "problem"}, |
| {"time": now - datetime.timedelta(minutes=22), "event": "⚠️ Alert: Database load hits 92%", "type": "alert"}, |
| {"time": now - datetime.timedelta(minutes=20), "event": "🤖 ARF detects pattern", "type": "detection"}, |
| {"time": now - datetime.timedelta(minutes=18), "event": "🧠 Analysis: Cache Miss Storm identified", "type": "analysis"}, |
| {"time": now - datetime.timedelta(minutes=15), "event": "⚡ Healing actions executed", "type": "action"}, |
| {"time": now - datetime.timedelta(minutes=12), "event": "✅ Cache hit rate recovers to 72%", "type": "recovery"}, |
| {"time": now - datetime.timedelta(minutes=10), "event": "📊 System stabilized", "type": "stable"} |
| ] |
| |
| color_map = { |
| "problem": "#FF6B6B", "alert": "#FFA726", "detection": "#42A5F5", |
| "analysis": "#AB47BC", "action": "#66BB6A", "recovery": "#26A69A", |
| "stable": "#2E7D32" |
| } |
| |
| |
| for event in events: |
| fig.add_trace(go.Scatter( |
| x=[event["time"]], |
| y=[1], |
| mode='markers+text', |
| marker=dict( |
| size=20, |
| color=color_map[event["type"]], |
| symbol='circle' if event["type"] in ['problem', 'alert'] else 'diamond', |
| line=dict(width=2, color='white') |
| ), |
| text=[event["event"]], |
| textposition="top center", |
| hoverinfo="text", |
| hovertemplate="<b>%{text}</b><br>%{x|%H:%M:%S}<extra></extra>", |
| showlegend=False |
| )) |
| |
| |
| times = [event["time"] for event in events] |
| fig.add_trace(go.Scatter( |
| x=times, |
| y=[1] * len(times), |
| mode='lines', |
| line=dict(color='rgba(100, 100, 100, 0.3)', width=2, dash='dash'), |
| hoverinfo='none', |
| showlegend=False |
| )) |
| |
| fig.update_layout( |
| title="<b>Incident Timeline - Cache Miss Storm Resolution</b>", |
| xaxis_title="Time →", |
| yaxis=dict( |
| showticklabels=False, |
| range=[0.5, 1.5] |
| ), |
| height=450, |
| showlegend=False, |
| paper_bgcolor='white', |
| plot_bgcolor='white', |
| hovermode='closest', |
| xaxis=dict( |
| tickformat='%H:%M', |
| gridcolor='rgba(200,200,200,0.2)', |
| showgrid=True |
| ), |
| margin=dict(l=50, r=50, t=80, b=50) |
| ) |
| |
| return fig |
| |
| @staticmethod |
| def create_business_dashboard() -> go.Figure: |
| """Create executive business dashboard""" |
| fig = make_subplots( |
| rows=2, cols=2, |
| subplot_titles=('Annual Cost Impact', 'Team Capacity Shift', |
| 'MTTR Comparison', 'ROI Analysis'), |
| vertical_spacing=0.15, |
| horizontal_spacing=0.15 |
| ) |
| |
| |
| categories = ['Without ARF', 'With ARF Enterprise', 'Net Savings'] |
| values = [2960000, 1000000, 1960000] |
| |
| fig.add_trace( |
| go.Bar( |
| x=categories, |
| y=values, |
| marker_color=['#FF6B6B', '#4ECDC4', '#45B7D1'], |
| text=[f'${v/1000000:.1f}M' for v in values], |
| textposition='auto', |
| name='Cost Impact' |
| ), |
| row=1, col=1 |
| ) |
| |
| |
| labels = ['Firefighting', 'Innovation', 'Strategic Work'] |
| before = [60, 20, 20] |
| after = [10, 60, 30] |
| |
| fig.add_trace( |
| go.Bar( |
| x=labels, |
| y=before, |
| name='Before ARF', |
| marker_color='#FF6B6B' |
| ), |
| row=1, col=2 |
| ) |
| |
| fig.add_trace( |
| go.Bar( |
| x=labels, |
| y=after, |
| name='After ARF Enterprise', |
| marker_color='#4ECDC4' |
| ), |
| row=1, col=2 |
| ) |
| |
| |
| mttr_categories = ['Manual', 'Traditional', 'ARF OSS', 'ARF Enterprise'] |
| mttr_values = [120, 45, 25, 8] |
| |
| fig.add_trace( |
| go.Bar( |
| x=mttr_categories, |
| y=mttr_values, |
| marker_color=['#FF6B6B', '#FFE66D', '#45B7D1', '#4ECDC4'], |
| text=[f'{v} min' for v in mttr_values], |
| textposition='auto', |
| name='MTTR' |
| ), |
| row=2, col=1 |
| ) |
| |
| |
| fig.add_trace( |
| go.Indicator( |
| mode="gauge+number+delta", |
| value=5.2, |
| title={'text': "ROI Multiplier"}, |
| delta={'reference': 1.0, 'increasing': {'color': "green"}}, |
| gauge={ |
| 'axis': {'range': [0, 10], 'tickwidth': 1}, |
| 'bar': {'color': "#4ECDC4"}, |
| 'steps': [ |
| {'range': [0, 2], 'color': "lightgray"}, |
| {'range': [2, 4], 'color': "gray"}, |
| {'range': [4, 6], 'color': "lightgreen"}, |
| {'range': [6, 10], 'color': "green"} |
| ], |
| 'threshold': { |
| 'line': {'color': "red", 'width': 4}, |
| 'thickness': 0.75, |
| 'value': 5.2 |
| } |
| } |
| ), |
| row=2, col=2 |
| ) |
| |
| fig.update_layout( |
| height=700, |
| showlegend=True, |
| paper_bgcolor='white', |
| plot_bgcolor='white', |
| title_text="<b>Executive Business Dashboard</b>", |
| barmode='group', |
| margin=dict(l=50, r=50, t=100, b=50) |
| ) |
| |
| return fig |
| |
| @staticmethod |
| def create_execution_history_chart(audit_manager: AuditTrailManager) -> go.Figure: |
| """Create execution history visualization""" |
| executions = audit_manager.execution_history[:10] |
| |
| if not executions: |
| fig = go.Figure() |
| fig.update_layout( |
| title="<b>No execution history yet</b>", |
| height=400, |
| paper_bgcolor='white', |
| plot_bgcolor='white', |
| xaxis_showgrid=True, |
| yaxis_showgrid=True |
| ) |
| return fig |
| |
| |
| scenarios = [e["scenario"] for e in executions] |
| savings = [] |
| for e in executions: |
| try: |
| savings.append(int(e["savings"].replace("$", "").replace(",", ""))) |
| except: |
| savings.append(0) |
| |
| fig = go.Figure(data=[ |
| go.Bar( |
| x=scenarios, |
| y=savings, |
| marker_color='#4ECDC4', |
| text=[f'${s:,.0f}' for s in savings], |
| textposition='outside', |
| name='Cost Saved', |
| hovertemplate="<b>%{x}</b><br>Savings: %{text}<extra></extra>" |
| ) |
| ]) |
| |
| fig.update_layout( |
| title="<b>Execution History - Cost Savings</b>", |
| xaxis_title="Scenario", |
| yaxis_title="Cost Saved ($)", |
| height=500, |
| paper_bgcolor='white', |
| plot_bgcolor='white', |
| showlegend=False, |
| xaxis_showgrid=True, |
| yaxis_showgrid=True, |
| margin=dict(l=50, r=50, t=80, b=100) |
| ) |
| |
| return fig |
| |
| @staticmethod |
| def create_memory_graph(audit_manager: AuditTrailManager) -> go.Figure: |
| """Create incident memory graph""" |
| incidents = audit_manager.incident_history[:15] |
| |
| if not incidents: |
| |
| fig = go.Figure() |
| |
| |
| angles = np.linspace(0, 2*np.pi, 5, endpoint=False) |
| radius = 1 |
| x = radius * np.cos(angles) |
| y = radius * np.sin(angles) |
| |
| fig.add_trace(go.Scatter( |
| x=x, |
| y=y, |
| mode='markers+text', |
| marker=dict(size=30, color=['#FF6B6B', '#4ECDC4', '#45B7D1', '#96CEB4', '#FFE66D']), |
| text=['Cache', 'DB', 'API', 'Auth', 'Payment'], |
| textposition="top center" |
| )) |
| |
| fig.update_layout( |
| title="<b>Incident Memory Graph (Sample)</b>", |
| showlegend=False, |
| height=600, |
| paper_bgcolor='white', |
| plot_bgcolor='white', |
| xaxis=dict(showgrid=False, zeroline=False, showticklabels=False, range=[-1.5, 1.5]), |
| yaxis=dict(showgrid=False, zeroline=False, showticklabels=False, range=[-1.5, 1.5]), |
| margin=dict(l=20, r=20, t=60, b=20) |
| ) |
| return fig |
| |
| |
| nodes = [] |
| for i, incident in enumerate(incidents): |
| nodes.append({ |
| "x": np.cos(2 * np.pi * i / len(incidents)), |
| "y": np.sin(2 * np.pi * i / len(incidents)), |
| "size": 15 + incident["severity"] * 5, |
| "color": "#FF6B6B" if incident["severity"] == 3 else "#FFA726" if incident["severity"] == 2 else "#42A5F5", |
| "label": incident["type"][:15], |
| "service": incident["service"] |
| }) |
| |
| fig = go.Figure() |
| |
| |
| fig.add_trace(go.Scatter( |
| x=[node["x"] for node in nodes], |
| y=[node["y"] for node in nodes], |
| mode='markers+text', |
| marker=dict( |
| size=[node["size"] for node in nodes], |
| color=[node["color"] for node in nodes], |
| line=dict(width=2, color='white') |
| ), |
| text=[node["label"] for node in nodes], |
| textposition="top center", |
| hovertext=[f"Service: {node['service']}" for node in nodes], |
| hoverinfo="text", |
| name="Incidents" |
| )) |
| |
| |
| for i in range(len(nodes)): |
| for j in range(i + 1, len(nodes)): |
| if incidents[i]["type"] == incidents[j]["type"]: |
| fig.add_trace(go.Scatter( |
| x=[nodes[i]["x"], nodes[j]["x"], None], |
| y=[nodes[i]["y"], nodes[j]["y"], None], |
| mode='lines', |
| line=dict(width=1, color='rgba(100, 100, 100, 0.2)'), |
| hoverinfo='none', |
| showlegend=False |
| )) |
| |
| fig.update_layout( |
| title=f"<b>Incident Memory Graph ({len(incidents)} incidents)</b>", |
| showlegend=False, |
| height=600, |
| paper_bgcolor='white', |
| plot_bgcolor='white', |
| xaxis=dict(showgrid=False, zeroline=False, showticklabels=False, range=[-1.5, 1.5]), |
| yaxis=dict(showgrid=False, zeroline=False, showticklabels=False, range=[-1.5, 1.5]), |
| margin=dict(l=50, r=50, t=80, b=50) |
| ) |
| |
| return fig |
| |
| |
| |
| |
| |
| def create_demo_interface(): |
| """Create the 5-tab demo interface""" |
| |
| |
| audit_manager = AuditTrailManager() |
| business_logic = BusinessLogic(audit_manager, oss_client) |
| viz_engine = VisualizationEngine() |
| |
| |
| custom_css = """ |
| .gradio-container { |
| max-width: 1800px !important; |
| margin: auto !important; |
| font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif !important; |
| } |
| h1 { |
| background: linear-gradient(90deg, #1a365d 0%, #2d3748 100%); |
| -webkit-background-clip: text; |
| -webkit-text-fill-color: transparent; |
| background-clip: text; |
| font-weight: 800 !important; |
| font-size: 2.5rem !important; |
| margin-bottom: 0.5rem !important; |
| } |
| .critical { |
| color: #FF6B6B !important; |
| font-weight: 900 !important; |
| } |
| .success { |
| color: #4ECDC4 !important; |
| font-weight: 900 !important; |
| } |
| .tab-nav { |
| background: linear-gradient(90deg, #f8fafc 0%, #ffffff 100%) !important; |
| border-radius: 10px !important; |
| padding: 5px !important; |
| margin-bottom: 20px !important; |
| } |
| .metric-card { |
| background: white !important; |
| border-radius: 10px !important; |
| padding: 20px !important; |
| box-shadow: 0 2px 8px rgba(0,0,0,0.06) !important; |
| border-left: 4px solid #4ECDC4 !important; |
| margin-bottom: 15px !important; |
| } |
| .enterprise-badge { |
| background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important; |
| color: white !important; |
| padding: 8px 16px !important; |
| border-radius: 20px !important; |
| font-weight: 700 !important; |
| font-size: 0.85rem !important; |
| display: inline-block !important; |
| margin: 5px 0 !important; |
| } |
| .oss-badge { |
| background: linear-gradient(135deg, #4299e1 0%, #38b2ac 100%) !important; |
| color: white !important; |
| padding: 8px 16px !important; |
| border-radius: 20px !important; |
| font-weight: 700 !important; |
| font-size: 0.85rem !important; |
| display: inline-block !important; |
| margin: 5px 0 !important; |
| } |
| """ |
| |
| with gr.Blocks( |
| title=f"🚀 ARF Investor Demo v3.8.0", |
| theme=gr.themes.Soft( |
| primary_hue="blue", |
| secondary_hue="teal", |
| font=[gr.themes.GoogleFont("Inter"), "Arial", "sans-serif"] |
| ), |
| css=custom_css |
| ) as demo: |
| |
| |
| gr.Markdown(f""" |
| <div style="text-align: center; padding: 30px 20px 20px 20px; background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%); border-radius: 0 0 20px 20px; margin-bottom: 30px; border-bottom: 3px solid #4ECDC4;"> |
| <h1 style="margin-bottom: 10px;">🚀 Agentic Reliability Framework</h1> |
| <h2 style="color: #4a5568; font-weight: 600; margin-bottom: 20px;">Investor Demo v3.8.0 - Enterprise Edition</h2> |
| |
| <div style="display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; margin-bottom: 20px;"> |
| <div class="enterprise-badge">🏢 Enterprise Features</div> |
| <div class="oss-badge">🆓 OSS v{OSS_VERSION}</div> |
| <div style="background: #e8f5e8; color: #2d3748; padding: 8px 16px; border-radius: 20px; font-weight: 600; font-size: 0.85rem;"> |
| 📈 5.2× Average ROI |
| </div> |
| <div style="background: #fff3cd; color: #856404; padding: 8px 16px; border-radius: 20px; font-weight: 600; font-size: 0.85rem;"> |
| ⚡ 85% MTTR Reduction |
| </div> |
| </div> |
| |
| <div style="color: #718096; font-size: 16px; max-width: 800px; margin: 0 auto; line-height: 1.6;"> |
| Experience the full journey from <span style="font-weight: 700; color: #4299e1;">OSS Advisory</span> |
| to <span style="font-weight: 700; color: #764ba2;">Enterprise Autonomous Healing</span>. |
| See how ARF transforms reliability operations. |
| </div> |
| </div> |
| """) |
| |
| |
| with gr.Row(): |
| with gr.Column(scale=1): |
| status_html = f""" |
| <div class="metric-card"> |
| <div style="display: flex; justify-content: space-between; align-items: center;"> |
| <div> |
| <h4 style="margin: 0 0 5px 0; color: #4a5568;">System Status</h4> |
| <div style="display: flex; align-items: center; gap: 10px;"> |
| <div style="width: 12px; height: 12px; background: #4ECDC4; border-radius: 50%;"></div> |
| <span style="font-weight: 600; color: #2d3748;">Operational</span> |
| </div> |
| </div> |
| <div style="text-align: right;"> |
| <div style="font-size: 0.9rem; color: #718096;">ARF OSS Integration</div> |
| <div style="font-weight: 700; color: {"#4ECDC4" if ARF_OSS_AVAILABLE else "#FF6B6B"}"> |
| {"✅ Connected v" + OSS_VERSION if ARF_OSS_AVAILABLE else "⚠️ Mock Mode"} |
| </div> |
| </div> |
| </div> |
| </div> |
| """ |
| gr.HTML(status_html) |
| |
| with gr.Column(scale=2): |
| performance_html = """ |
| <div class="metric-card"> |
| <div style="display: flex; justify-content: space-between;"> |
| <div> |
| <h4 style="margin: 0 0 5px 0; color: #4a5568;">Performance Metrics</h4> |
| <div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px;"> |
| <div> |
| <div style="font-size: 0.85rem; color: #718096;">Auto-Heal Rate</div> |
| <div style="font-weight: 800; color: #4ECDC4; font-size: 1.2rem;">81.7%</div> |
| </div> |
| <div> |
| <div style="font-size: 0.85rem; color: #718096;">Avg Resolution</div> |
| <div style="font-weight: 800; color: #4ECDC4; font-size: 1.2rem;">8.2 min</div> |
| </div> |
| <div> |
| <div style="font-size: 0.85rem; color: #718096;">Cost Savings</div> |
| <div style="font-weight: 800; color: #4ECDC4; font-size: 1.2rem;">$6.2M/yr</div> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| """ |
| gr.HTML(performance_html) |
| |
| with gr.Column(scale=1): |
| license_html = """ |
| <div class="metric-card"> |
| <h4 style="margin: 0 0 10px 0; color: #4a5568;">License Status</h4> |
| <div style="display: flex; align-items: center; justify-content: space-between;"> |
| <div> |
| <div style="font-weight: 700; color: #4ECDC4; font-size: 1.1rem;">ENTERPRISE</div> |
| <div style="font-size: 0.85rem; color: #718096;">Active • Expires 2024-12-31</div> |
| </div> |
| <div style="background: #e8f5e8; color: #276749; padding: 4px 10px; border-radius: 15px; font-size: 0.8rem; font-weight: 600;"> |
| ✅ Valid |
| </div> |
| </div> |
| </div> |
| """ |
| gr.HTML(license_html) |
| |
| |
| with gr.Tabs(): |
| |
| |
| with gr.TabItem("🔥 Live Incident Demo"): |
| with gr.Row(): |
| |
| with gr.Column(scale=1): |
| gr.Markdown("### 🎬 Incident Scenario") |
| scenario_dropdown = gr.Dropdown( |
| choices=list(INCIDENT_SCENARIOS.keys()), |
| value="Cache Miss Storm", |
| label="Select critical incident:", |
| interactive=True |
| ) |
| |
| scenario_description = gr.Markdown( |
| value=INCIDENT_SCENARIOS["Cache Miss Storm"]["description"] |
| ) |
| |
| gr.Markdown("### 📊 Current Crisis Metrics") |
| metrics_display = gr.JSON( |
| value=INCIDENT_SCENARIOS["Cache Miss Storm"]["metrics"], |
| label="Live Metrics", |
| show_label=True |
| ) |
| |
| gr.Markdown("### 💰 Business Impact") |
| impact_display = gr.JSON( |
| value=INCIDENT_SCENARIOS["Cache Miss Storm"]["impact"], |
| label="Impact Analysis", |
| show_label=True |
| ) |
| |
| |
| with gr.Column(scale=2): |
| gr.Markdown("### 📈 Incident Timeline") |
| timeline_output = gr.Plot( |
| value=viz_engine.create_incident_timeline(), |
| label="", |
| show_label=False |
| ) |
| |
| gr.Markdown("### ⚡ Take Action") |
| with gr.Row(): |
| oss_btn = gr.Button( |
| "🆓 Run OSS Analysis", |
| variant="secondary", |
| size="lg", |
| elem_id="oss_btn" |
| ) |
| enterprise_btn = gr.Button( |
| "🚀 Execute Enterprise Healing", |
| variant="primary", |
| size="lg", |
| elem_id="enterprise_btn" |
| ) |
| |
| with gr.Row(): |
| approval_toggle = gr.Checkbox( |
| label="🔐 Require Manual Approval", |
| value=True, |
| info="Toggle to show approval workflow vs auto-execution", |
| interactive=True |
| ) |
| demo_mode_btn = gr.Button( |
| "⚡ Quick Demo", |
| variant="secondary", |
| size="sm", |
| elem_id="demo_btn" |
| ) |
| |
| approval_display = gr.HTML( |
| value="<div style='padding: 15px; background: #f8f9fa; border-radius: 8px;'>Approval status will appear here after execution</div>" |
| ) |
| |
| config_display = gr.JSON( |
| label="⚙️ Enterprise Configuration", |
| value={"approval_required": True, "compliance_mode": "strict"}, |
| show_label=True |
| ) |
| |
| results_display = gr.JSON( |
| label="🎯 Execution Results", |
| value={"status": "Ready for execution..."}, |
| show_label=True |
| ) |
| |
| |
| with gr.TabItem("💰 Business Impact & ROI"): |
| with gr.Column(): |
| gr.Markdown("### 📊 Executive Business Dashboard") |
| dashboard_output = gr.Plot( |
| value=viz_engine.create_business_dashboard(), |
| label="", |
| show_label=False |
| ) |
| |
| gr.Markdown("### 🧮 Interactive ROI Calculator") |
| with gr.Row(): |
| with gr.Column(scale=1): |
| monthly_slider = gr.Slider( |
| 1, 100, value=15, step=1, |
| label="Monthly incidents", |
| interactive=True |
| ) |
| impact_slider = gr.Slider( |
| 1000, 50000, value=8500, step=500, |
| label="Average incident impact ($)", |
| interactive=True |
| ) |
| team_slider = gr.Slider( |
| 1, 20, value=5, step=1, |
| label="Reliability team size", |
| interactive=True |
| ) |
| calculate_btn = gr.Button( |
| "Calculate My ROI", |
| variant="primary", |
| size="lg" |
| ) |
| |
| with gr.Column(scale=2): |
| roi_output = gr.JSON( |
| label="Your ROI Analysis", |
| value={"analysis": "Adjust sliders and click Calculate"}, |
| show_label=True |
| ) |
| |
| with gr.Row(): |
| with gr.Column(): |
| gr.Markdown(""" |
| **📈 ARF Enterprise ROI Metrics** |
| - **Average ROI:** 5.2× first year |
| - **Payback Period:** 2-3 months |
| - **Auto-Heal Rate:** 81.7% |
| - **MTTR Reduction:** 85% |
| - **Cost Savings:** $6.2M average annually |
| """) |
| with gr.Column(): |
| gr.Markdown(""" |
| **🎯 Business Impact** |
| - **Engineer Time:** 325+ hours reclaimed annually |
| - **SLA Compliance:** 99.9% maintained |
| - **Customer Satisfaction:** +40% improvement |
| - **Revenue Protection:** $8,500+/hour saved |
| - **Innovation Capacity:** 60% increase |
| """) |
| |
| |
| with gr.TabItem("📜 Audit Trail & History"): |
| with gr.Row(): |
| |
| with gr.Column(scale=1): |
| gr.Markdown("### 📋 Execution History (Audit Trail)") |
| |
| with gr.Row(): |
| refresh_btn = gr.Button("🔄 Refresh", variant="secondary", size="sm") |
| clear_btn = gr.Button("🗑️ Clear", variant="stop", size="sm") |
| export_btn = gr.Button("📥 Export", variant="secondary", size="sm") |
| |
| execution_table = gr.Dataframe( |
| headers=["Time", "Scenario", "Actions", "Status", "Savings", "Details"], |
| value=audit_manager.get_execution_history_table(), |
| label="", |
| interactive=False, |
| wrap=True |
| ) |
| |
| gr.Markdown("### 📈 Visual History") |
| execution_chart = gr.Plot( |
| value=viz_engine.create_execution_history_chart(audit_manager), |
| label="", |
| show_label=False |
| ) |
| |
| |
| with gr.Column(scale=1): |
| gr.Markdown("### 📊 Incident History") |
| |
| incident_table = gr.Dataframe( |
| headers=["Time", "Service", "Type", "Severity", "Description"], |
| value=audit_manager.get_incident_history_table(), |
| label="", |
| interactive=False, |
| wrap=True |
| ) |
| |
| gr.Markdown("### 🧠 Memory Graph") |
| memory_graph = gr.Plot( |
| value=viz_engine.create_memory_graph(audit_manager), |
| label="", |
| show_label=False |
| ) |
| |
| gr.Markdown("### 📤 Export & Analytics") |
| export_text = gr.Textbox( |
| label="Full Audit Trail (JSON)", |
| value=audit_manager.export_audit_trail(), |
| lines=8, |
| interactive=False |
| ) |
| |
| |
| with gr.TabItem("🏢 Enterprise Features"): |
| with gr.Row(): |
| |
| with gr.Column(scale=1): |
| gr.Markdown("### 🔐 License Management") |
| |
| license_display = gr.JSON( |
| value=business_logic.license_info, |
| label="License Information", |
| show_label=True |
| ) |
| |
| with gr.Row(): |
| validate_btn = gr.Button("🔍 Validate", variant="secondary") |
| trial_btn = gr.Button("🆓 Start Trial", variant="primary") |
| upgrade_btn = gr.Button("🚀 Upgrade", variant="secondary") |
| |
| gr.Markdown("### ⚡ Feature Matrix") |
| |
| features_data = [ |
| ["🤖 Autonomous Healing", "❌", "✅ Auto", "✅ AI-Driven"], |
| ["📊 Executive Dashboards", "Basic", "Advanced", "✅ Comprehensive"], |
| ["🔐 Compliance Automation", "❌", "✅", "✅ SOC2/GDPR"], |
| ["📈 Predictive Analytics", "❌", "Basic", "✅ ML-Powered"], |
| ["🔄 Auto-Remediation", "Manual", "✅ Auto", "✅ Continuous"], |
| ["🎯 SLA Guarantees", "❌", "❌", "✅ 99.9%"], |
| ["📊 Cost Optimization", "Basic", "Advanced", "✅ AI-Optimized"], |
| ["🔒 Role-Based Access", "❌", "✅", "✅ Granular"], |
| ["📝 Audit Trail", "Basic", "✅", "✅ Comprehensive"], |
| ["🔄 Multi-Cloud", "❌", "❌", "✅ Native"], |
| ] |
| |
| features_table = gr.Dataframe( |
| value=features_data, |
| headers=["Feature", "OSS", "Starter", "Enterprise"], |
| label="", |
| interactive=False, |
| wrap=True |
| ) |
| |
| |
| with gr.Column(scale=1): |
| gr.Markdown("### 📋 Compliance Status") |
| |
| compliance_status = gr.JSON( |
| value={ |
| "SOC2": {"status": "✅ Certified", "expires": "2025-06-30"}, |
| "GDPR": {"status": "✅ Compliant", "last_audit": "2024-10-15"}, |
| "HIPAA": {"status": "🟡 In Progress", "eta": "2024-12-31"}, |
| "ISO27001": {"status": "✅ Certified", "cert_id": "ISO-2024-001"}, |
| "CCPA": {"status": "✅ Compliant", "verified": True} |
| }, |
| label="Compliance Certifications", |
| show_label=True |
| ) |
| |
| gr.Markdown("### 🔗 Integration Hub") |
| |
| integrations_data = [ |
| ["AWS", "CloudWatch, S3, Lambda", "✅ Connected"], |
| ["Azure", "Monitor, Log Analytics", "✅ Connected"], |
| ["GCP", "Operations, BigQuery", "✅ Connected"], |
| ["Datadog", "Metrics, Logs, APM", "✅ Connected"], |
| ["New Relic", "Full-stack", "✅ Connected"], |
| ["PagerDuty", "Incident Response", "✅ Connected"], |
| ["ServiceNow", "ITSM & CMDB", "✅ Connected"], |
| ["Slack", "Notifications", "✅ Connected"], |
| ] |
| |
| integrations_table = gr.Dataframe( |
| value=integrations_data, |
| headers=["Platform", "Services", "Status"], |
| label="", |
| interactive=False, |
| wrap=True |
| ) |
| |
| |
| with gr.TabItem("🧠 Learning Engine"): |
| with gr.Row(): |
| |
| with gr.Column(scale=2): |
| gr.Markdown("### 🧠 Incident Memory Graph") |
| |
| memory_graph_plot = gr.Plot( |
| value=viz_engine.create_memory_graph(audit_manager), |
| label="", |
| show_label=False |
| ) |
| |
| with gr.Row(): |
| graph_type = gr.Radio( |
| choices=["Force Directed", "Hierarchical", "Timeline"], |
| value="Force Directed", |
| label="Graph Type", |
| interactive=True |
| ) |
| show_weights = gr.Checkbox(label="Show Edge Weights", value=True, interactive=True) |
| |
| gr.Markdown("### 🔍 Similarity Search") |
| |
| search_query = gr.Textbox( |
| label="Search for similar incidents", |
| placeholder="Describe incident or paste metrics...", |
| lines=2, |
| interactive=True |
| ) |
| |
| with gr.Row(): |
| search_btn = gr.Button("🔍 Search", variant="primary") |
| clear_search_btn = gr.Button("Clear", variant="secondary") |
| |
| search_results = gr.Dataframe( |
| headers=["Incident", "Similarity", "Resolution", "Actions"], |
| value=[], |
| label="", |
| interactive=False, |
| wrap=True |
| ) |
| |
| |
| with gr.Column(scale=1): |
| gr.Markdown("### 📊 Learning Statistics") |
| |
| learning_stats = gr.JSON( |
| value={ |
| "total_incidents": len(audit_manager.incident_history), |
| "resolved_automatically": len([e for e in audit_manager.execution_history if "Executed" in e["status"]]), |
| "patterns_detected": 5, |
| "confidence_threshold": 0.85, |
| "memory_size": f"{len(audit_manager.incident_history) * 0.5:.1f} KB", |
| "similar_incidents_found": 12 |
| }, |
| label="Learning Engine Statistics", |
| show_label=True |
| ) |
| |
| gr.Markdown("### 🎯 Pattern Detection") |
| |
| pattern_analysis = gr.JSON( |
| value={ |
| "most_common": "Cache Miss Storm", |
| "frequency": "45% of incidents", |
| "avg_resolution_time": "8.2 minutes", |
| "success_rate": "92%", |
| "recommendations": [ |
| "Implement proactive cache monitoring", |
| "Add circuit breaker for database fallback", |
| "Optimize cache TTL settings" |
| ] |
| }, |
| label="Pattern Analysis", |
| show_label=True |
| ) |
| |
| |
| |
| |
| def update_scenario(scenario_name): |
| scenario = INCIDENT_SCENARIOS.get(scenario_name, {}) |
| return ( |
| f"### {scenario_name}\n{scenario.get('description', 'No description')}", |
| scenario.get("metrics", {}), |
| scenario.get("impact", {}), |
| viz_engine.create_incident_timeline() |
| ) |
| |
| scenario_dropdown.change( |
| fn=update_scenario, |
| inputs=[scenario_dropdown], |
| outputs=[scenario_description, metrics_display, impact_display, timeline_output] |
| ) |
| |
| |
| async def run_oss_analysis(scenario_name): |
| analysis = await business_logic.run_oss_analysis(scenario_name) |
| incident_table_data = audit_manager.get_incident_history_table() |
| memory_plot = viz_engine.create_memory_graph(audit_manager) |
| return analysis, incident_table_data, memory_plot |
| |
| oss_btn.click( |
| fn=run_oss_analysis, |
| inputs=[scenario_dropdown], |
| outputs=[results_display, incident_table, memory_graph] |
| ) |
| |
| |
| def execute_healing(scenario_name, approval_required): |
| approval_html, results = business_logic.execute_enterprise_healing(scenario_name, approval_required) |
| execution_table_data = audit_manager.get_execution_history_table() |
| execution_chart_plot = viz_engine.create_execution_history_chart(audit_manager) |
| return approval_html, results, execution_table_data, execution_chart_plot |
| |
| enterprise_btn.click( |
| fn=execute_healing, |
| inputs=[scenario_dropdown, approval_toggle], |
| outputs=[approval_display, results_display, execution_table, execution_chart] |
| ) |
| |
| |
| async def run_quick_demo(): |
| |
| analysis = await business_logic.run_oss_analysis("Cache Miss Storm") |
| |
| |
| approval_html, results = business_logic.execute_enterprise_healing("Cache Miss Storm", False) |
| |
| |
| execution_table_data = audit_manager.get_execution_history_table() |
| incident_table_data = audit_manager.get_incident_history_table() |
| execution_chart_plot = viz_engine.create_execution_history_chart(audit_manager) |
| memory_plot = viz_engine.create_memory_graph(audit_manager) |
| |
| return ( |
| analysis, |
| approval_html, |
| results, |
| execution_table_data, |
| incident_table_data, |
| execution_chart_plot, |
| memory_plot, |
| gr.Checkbox.update(value=False) |
| ) |
| |
| demo_mode_btn.click( |
| fn=run_quick_demo, |
| outputs=[ |
| results_display, |
| approval_display, |
| results_display, |
| execution_table, |
| incident_table, |
| execution_chart, |
| memory_graph, |
| approval_toggle |
| ] |
| ) |
| |
| |
| def calculate_roi(monthly, impact, team): |
| return business_logic.calculate_roi(monthly, impact, team) |
| |
| calculate_btn.click( |
| fn=calculate_roi, |
| inputs=[monthly_slider, impact_slider, team_slider], |
| outputs=[roi_output] |
| ) |
| |
| |
| def refresh_audit_trail(): |
| execution_table_data = audit_manager.get_execution_history_table() |
| incident_table_data = audit_manager.get_incident_history_table() |
| execution_chart_plot = viz_engine.create_execution_history_chart(audit_manager) |
| memory_plot = viz_engine.create_memory_graph(audit_manager) |
| export_data = audit_manager.export_audit_trail() |
| return execution_table_data, incident_table_data, execution_chart_plot, memory_plot, export_data |
| |
| refresh_btn.click( |
| fn=refresh_audit_trail, |
| outputs=[execution_table, incident_table, execution_chart, memory_graph, export_text] |
| ) |
| |
| |
| def clear_audit_trail(): |
| audit_manager.execution_history = [] |
| audit_manager.incident_history = [] |
| audit_manager._initialize_sample_data() |
| return refresh_audit_trail() |
| |
| clear_btn.click( |
| fn=clear_audit_trail, |
| outputs=[execution_table, incident_table, execution_chart, memory_graph, export_text] |
| ) |
| |
| |
| def update_export(): |
| return audit_manager.export_audit_trail() |
| |
| export_btn.click( |
| fn=update_export, |
| outputs=[export_text] |
| ) |
| |
| |
| def validate_license(): |
| business_logic.license_info["last_validated"] = datetime.datetime.now().isoformat() |
| business_logic.license_info["validation_code"] = "VAL-2024-001" |
| return business_logic.license_info |
| |
| validate_btn.click( |
| fn=validate_license, |
| outputs=[license_display] |
| ) |
| |
| def start_trial(): |
| business_logic.license_info["tier"] = "TRIAL" |
| business_logic.license_info["expires_at"] = (datetime.datetime.now() + datetime.timedelta(days=30)).isoformat() |
| business_logic.license_info["status"] = "🆓 Trial Active (30 days)" |
| return business_logic.license_info |
| |
| trial_btn.click( |
| fn=start_trial, |
| outputs=[license_display] |
| ) |
| |
| def upgrade_license(): |
| business_logic.license_info["tier"] = "PLATFORM" |
| business_logic.license_info["status"] = "🚀 Upgraded to Platform Edition" |
| return business_logic.license_info |
| |
| upgrade_btn.click( |
| fn=upgrade_license, |
| outputs=[license_display] |
| ) |
| |
| |
| def search_similar_incidents(query): |
| if not query.strip(): |
| return [] |
| |
| |
| results = [ |
| ["Cache Miss Storm", "92%", "✅ Resolved", "Scale cache + circuit breaker"], |
| ["Database Connection Pool", "78%", "✅ Resolved", "Increase pool size"], |
| ["Memory Leak", "65%", "⚠️ Pending", "Restart + monitoring"], |
| ["API Rate Limit", "58%", "✅ Resolved", "Increase limits + caching"], |
| ] |
| |
| return results |
| |
| search_btn.click( |
| fn=search_similar_incidents, |
| inputs=[search_query], |
| outputs=[search_results] |
| ) |
| |
| clear_search_btn.click( |
| fn=lambda: [], |
| outputs=[search_results] |
| ) |
| |
| |
| def update_graph_view(graph_type, show_weights): |
| return viz_engine.create_memory_graph(audit_manager) |
| |
| graph_type.change( |
| fn=update_graph_view, |
| inputs=[graph_type, show_weights], |
| outputs=[memory_graph_plot] |
| ) |
| |
| show_weights.change( |
| fn=update_graph_view, |
| inputs=[graph_type, show_weights], |
| outputs=[memory_graph_plot] |
| ) |
| |
| |
| demo.load( |
| fn=lambda: ( |
| viz_engine.create_business_dashboard(), |
| viz_engine.create_incident_timeline(), |
| viz_engine.create_execution_history_chart(audit_manager), |
| viz_engine.create_memory_graph(audit_manager), |
| audit_manager.export_audit_trail() |
| ), |
| outputs=[dashboard_output, timeline_output, execution_chart, memory_graph, export_text] |
| ) |
| |
| |
| gr.Markdown(""" |
| <div style="margin-top: 40px; padding: 30px; background: linear-gradient(135deg, #1a365d 0%, #2d3748 100%); border-radius: 20px; color: white;"> |
| <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 30px; margin-bottom: 30px;"> |
| <div> |
| <h4 style="color: white; margin-bottom: 15px;">🚀 Experience the Journey</h4> |
| <ul style="list-style: none; padding: 0; margin: 0; color: #cbd5e0;"> |
| <li style="margin-bottom: 10px;">1. <strong>Start with OSS</strong> - Get recommendations</li> |
| <li style="margin-bottom: 10px;">2. <strong>Calculate ROI</strong> - See your savings</li> |
| <li style="margin-bottom: 10px;">3. <strong>Execute Healing</strong> - Experience autonomy</li> |
| <li style="margin-bottom: 10px;">4. <strong>View Audit Trail</strong> - Track everything</li> |
| <li>5. <strong>Explore Features</strong> - See enterprise power</li> |
| </ul> |
| </div> |
| <div> |
| <h4 style="color: white; margin-bottom: 15px;">📞 Get Started</h4> |
| <ul style="list-style: none; padding: 0; margin: 0; color: #cbd5e0;"> |
| <li style="margin-bottom: 10px;">📧 <strong>Contact:</strong> sales@arfinvestor.com</li> |
| <li style="margin-bottom: 10px;">📚 <strong>Docs:</strong> docs.arfinvestor.com</li> |
| <li style="margin-bottom: 10px;">💬 <strong>Slack:</strong> Join 2,500+ engineers</li> |
| <li style="margin-bottom: 10px;">🆓 <strong>Trial:</strong> 30-day enterprise trial</li> |
| <li>🚀 <strong>Demo:</strong> Live demo available</li> |
| </ul> |
| </div> |
| <div> |
| <h4 style="color: white; margin-bottom: 15px;">🛡️ Trust & Security</h4> |
| <ul style="list-style: none; padding: 0; margin: 0; color: #cbd5e0;"> |
| <li style="margin-bottom: 10px;">✅ SOC 2 Type II Certified</li> |
| <li style="margin-bottom: 10px;">✅ GDPR & CCPA Compliant</li> |
| <li style="margin-bottom: 10px;">✅ ISO 27001 Certified</li> |
| <li style="margin-bottom: 10px;">✅ HIPAA Ready</li> |
| <li>✅ Enterprise-grade Security</li> |
| </ul> |
| </div> |
| </div> |
| |
| <div style="border-top: 1px solid #4a5568; padding-top: 20px; text-align: center; color: #a0aec0; font-size: 0.9rem;"> |
| <p style="margin: 0 0 10px 0;">© 2024 Agentic Reliability Framework. Demo v3.8.0 Enterprise Edition.</p> |
| <p style="margin: 0; font-size: 0.8rem;">This demonstration uses ARF OSS v{OSS_VERSION}. Actual enterprise features require license activation.</p> |
| </div> |
| </div> |
| """.format(OSS_VERSION=OSS_VERSION)) |
| |
| return demo |
| |
| return create_demo_interface() |
|
|
| except Exception as e: |
| logger.error(f"Failed to create demo: {e}") |
| logger.error(traceback.format_exc()) |
| |
| |
| import gradio as gr |
| |
| with gr.Blocks(title="🚀 ARF Demo - Error") as demo: |
| gr.Markdown(f""" |
| # ⚠️ ARF Demo Initialization Error |
| |
| Failed to initialize the demo: |
| |
| ```python |
| {str(e)} |
| ``` |
| |
| Please check the logs for details. |
| """) |
| |
| return demo |
|
|
|
|
| def main(): |
| """Main entry point""" |
| print("🚀 Starting ARF Ultimate Investor Demo v3.8.0...") |
| print("=" * 70) |
| print("📊 Features:") |
| print(" • 5 Comprehensive Tabs with User-Focused Journey") |
| print(" • Live Incident Demo with OSS Analysis") |
| print(" • Business Impact & ROI Calculator") |
| print(" • Audit Trail & History with Memory Graph") |
| print(" • Enterprise Features & License Management") |
| print(" • Learning Engine with Pattern Detection") |
| print("=" * 70) |
| print(f"\n📦 Using ARF OSS v{OSS_VERSION if 'OSS_VERSION' in locals() else '3.3.6'}") |
| print("🌐 Opening web interface at http://localhost:7860...") |
| |
| demo = create_demo_interface() |
| demo.launch( |
| server_name="0.0.0.0", |
| server_port=7860, |
| share=False, |
| debug=False, |
| show_error=True |
| ) |
|
|
|
|
| if __name__ == "__main__": |
| main() |