""" Gradio-only UI components for ARF Ensures full compatibility with app.py """ import gradio as gr from typing import Dict, List, Any from demo.scenarios import INCIDENT_SCENARIOS # ----------------------------- # Header & Status # ----------------------------- def create_header(version="3.3.6", mock_mode=False) -> gr.HTML: mock_text = " ยท MOCK MODE" if mock_mode else "" return gr.HTML(f"""

๐Ÿš€ Agentic Reliability Framework

v{version} (OSS Edition){mock_text}

Production-grade multi-agent AI for autonomous system reliability intelligence

""") def create_status_bar() -> gr.HTML: return gr.HTML("""
โœ… System Online ๐Ÿง  Agentic Core Active ๐Ÿ“ฆ OSS Mode (Advisory Only) ๐Ÿ”’ MCP Safety Enabled ๐Ÿ’ฐ Enterprise ROI: 5.2ร—
""") # ----------------------------- # Tab 1: Live Incident Demo - ENHANCED VERSION # ----------------------------- def create_tab1_incident_demo(scenarios=INCIDENT_SCENARIOS, default_scenario="Cache Miss Storm") -> tuple: """ Create an expressive, comprehensive incident demo tab for ARF. Shows the complete OSS analysis โ†’ Enterprise execution workflow. """ # Left Column: Scenario Selection & Live Visualization with gr.Column(scale=1, variant="panel") as left_col: # Scenario Selection with rich preview scenario_dropdown = gr.Dropdown( choices=list(scenarios.keys()), value=default_scenario, label="๐ŸŽฏ Select Incident Scenario", info="Choose a production incident to analyze", interactive=True, container=False ) # Scenario Card with rich information scenario_card = gr.HTML("""

๐Ÿšจ Cache Miss Storm

HIGH
Component: Redis Cache Cluster
Impact Radius: 85% of users
Revenue Risk: $8,500/hour
Detection Time: 45 seconds
cache redis latency scaling
""") # Live Telemetry Visualization telemetry_header = gr.Markdown("### ๐Ÿ“ˆ Live Telemetry") telemetry_viz = gr.Plot(label="", show_label=False) # Business Impact Visualization impact_header = gr.Markdown("### ๐Ÿ’ฐ Business Impact") impact_viz = gr.Plot(label="", show_label=False) # Middle Column: Agent Workflow with gr.Column(scale=2, variant="panel") as middle_col: # Agent Workflow Header workflow_header = gr.Markdown("## ๐Ÿ”„ ARF Agent Workflow") workflow_subheader = gr.Markdown("### How ARF transforms incidents into autonomous healing") # Agent Status Cards with gr.Row(): detection_agent = gr.HTML("""
๐Ÿ•ต๏ธโ€โ™‚๏ธ

Detection Agent

Anomaly detected: 99.8% confidence

Response: 45s Accuracy: 98.7%
ACTIVE
""") recall_agent = gr.HTML("""
๐Ÿง 

Recall Agent

3 similar incidents found in RAG memory

Recall: 92% Context: 5 patterns
ACTIVE
""") decision_agent = gr.HTML("""
๐ŸŽฏ

Decision Agent

Generating healing intent with 94% confidence

Success Rate: 87% Safety: 100%
ACTIVE
""") # OSS vs Enterprise Boundary Visualization boundary_header = gr.Markdown("### ๐ŸŽญ OSS vs Enterprise: The Safety Boundary") with gr.Row(): oss_section = gr.HTML("""
๐Ÿ†“

OSS Edition

Apache 2.0

Analysis & Advisory Only - No execution, permanently safe

๐Ÿ“ Healing Intent Created

94% confidence

Action: Scale Redis cluster from 3 to 5 nodes

Pattern Match: Similar incident resolved with scaling (87% success rate)

Safety Check: โœ… Passed (blast radius: 2 services)

Estimated Impact: Reduce MTTR from 45min to 12min

๐Ÿšซ OSS STOPS HERE - No execution
""") enterprise_section = gr.HTML("""
๐Ÿ’ฐ

Enterprise Edition

Commercial

Full Execution & Learning - Autonomous healing with safety guarantees

โšก Ready to Execute

AUTONOMOUS

Mode: Autonomous (Requires Enterprise license)

Expected Recovery: 12 minutes (vs 45 min manual)

Cost Saved: $6,375

Users Protected: 45,000 โ†’ 0 impacted

โœ… Enterprise executes with MCP safety
""") # Execution Controls with gr.Row(): with gr.Column(scale=1): oss_btn = gr.Button( "๐Ÿ†“ Run OSS Analysis", variant="secondary", size="lg", elem_classes="oss-btn" ) oss_info = gr.Markdown("*Free, open-source analysis*", elem_classes="button-info") with gr.Column(scale=1): enterprise_btn = gr.Button( "๐Ÿ’ฐ Execute Enterprise Healing", variant="primary", size="lg", elem_classes="enterprise-btn" ) enterprise_info = gr.Markdown("*Requires Enterprise license*", elem_classes="button-info") # Mode Selection & Safety Controls with gr.Row(): with gr.Column(scale=1): approval_toggle = gr.CheckboxGroup( choices=["๐Ÿ‘ค Require Human Approval"], label="Safety Controls", value=[], info="Toggle human oversight" ) with gr.Column(scale=2): mcp_mode = gr.Radio( choices=["๐Ÿ›ก๏ธ Advisory (OSS Only)", "๐Ÿ‘ฅ Approval", "โšก Autonomous"], value="๐Ÿ›ก๏ธ Advisory (OSS Only)", label="MCP Safety Mode", info="Control execution safety level", interactive=True ) # Timeline Visualization timeline_header = gr.Markdown("### โฐ Incident Timeline") timeline_viz = gr.Plot(label="", show_label=False) # Right Column: Results & Metrics with gr.Column(scale=1, variant="panel") as right_col: # Real-time Metrics Dashboard metrics_header = gr.Markdown("## ๐Ÿ“Š Performance Metrics") # Metric Cards Grid with gr.Row(): detection_time = gr.HTML("""
โฑ๏ธ

Detection Time

45s

โ†“ 89% faster than average

""") mttr = gr.HTML("""
โšก

Mean Time to Resolve

12m

โ†“ 73% faster than manual

""") with gr.Row(): auto_heal = gr.HTML("""
๐Ÿค–

Auto-Heal Rate

81.7%

โ†‘ 5.4ร— industry average

""") savings = gr.HTML("""
๐Ÿ’ฐ

Cost Saved

$6.3K

Per incident avoided

""") # Results Display Areas oss_results_header = gr.Markdown("### ๐Ÿ†“ OSS Analysis Results") oss_results_display = gr.JSON( label="", value={ "status": "Analysis Pending", "agents": ["Detection", "Recall", "Decision"], "mode": "Advisory Only", "action": "Generate HealingIntent" }, height=200 ) enterprise_results_header = gr.Markdown("### ๐Ÿ’ฐ Enterprise Results") enterprise_results_display = gr.JSON( label="", value={ "status": "Execution Pending", "requires_license": True, "available_modes": ["Approval", "Autonomous"], "expected_outcome": "12m MTTR, $6.3K saved" }, height=200 ) # Approval Status approval_display = gr.HTML("""

๐Ÿ‘ค Human Approval Status

Not Required

Current Mode: Advisory (OSS Only)

Switch to "Approval" mode to enable human-in-the-loop workflows

1. ARF generates intent
2. Human reviews & approves
3. ARF executes safely
""") # Demo Actions demo_btn = gr.Button( "โ–ถ๏ธ Run Complete Demo Walkthrough", variant="secondary", size="lg", full_width=True ) demo_info = gr.Markdown("*Experience the full ARF workflow from detection to resolution*", elem_classes="demo-info") return ( # Left column returns scenario_dropdown, scenario_card, telemetry_viz, impact_viz, # Middle column returns workflow_header, detection_agent, recall_agent, decision_agent, oss_section, enterprise_section, oss_btn, enterprise_btn, approval_toggle, mcp_mode, timeline_viz, # Right column returns detection_time, mttr, auto_heal, savings, oss_results_display, enterprise_results_display, approval_display, demo_btn ) # ----------------------------- # Tab 2: Business ROI - Updated to match new return signature # ----------------------------- def create_tab2_business_roi(scenarios=INCIDENT_SCENARIOS) -> tuple: dashboard_output = gr.Plot(label="Executive Dashboard", show_label=True) roi_scenario_dropdown = gr.Dropdown( choices=list(scenarios.keys()), value="Cache Miss Storm", label="Scenario for ROI Analysis", info="Select the primary incident type for ROI calculation" ) monthly_slider = gr.Slider( minimum=1, maximum=50, value=15, step=1, label="Monthly Incidents", info="Average number of incidents per month" ) team_slider = gr.Slider( minimum=1, maximum=50, value=5, step=1, label="Team Size", info="Number of engineers on reliability team" ) calculate_btn = gr.Button("๐Ÿ“Š Calculate Comprehensive ROI", variant="primary", size="lg") roi_output = gr.JSON(label="ROI Analysis Results", value={}) roi_chart = gr.Plot(label="ROI Visualization") return (dashboard_output, roi_scenario_dropdown, monthly_slider, team_slider, calculate_btn, roi_output, roi_chart) # ----------------------------- # Tab 3: Enterprise Features - Updated # ----------------------------- def create_tab3_enterprise_features() -> tuple: license_display = gr.JSON( value={"status": "๐Ÿ†“ OSS Mode Active", "features": ["Advisory Analysis", "RAG Memory", "HealingIntent"]}, label="License Status" ) validate_btn = gr.Button("๐Ÿ” Validate License", variant="secondary") trial_btn = gr.Button("๐Ÿ†“ Start 30-Day Trial", variant="secondary") upgrade_btn = gr.Button("๐Ÿš€ Upgrade to Enterprise", variant="primary") mcp_mode = gr.Dropdown( choices=["advisory", "approval", "autonomous"], value="advisory", label="MCP Safety Mode" ) mcp_mode_info = gr.JSON( value={ "current_mode": "advisory", "description": "OSS Edition - Analysis only, no execution", "features": ["Incident analysis", "RAG similarity", "HealingIntent creation"] }, label="Mode Details" ) features_data = [ ["Self-Healing Core", "โœ… Active", "Enterprise"], ["RAG Graph Memory", "โœ… Active", "Both"], ["Predictive Analytics", "๐Ÿ”’ Enterprise", "Enterprise"], ["Audit Trail", "๐Ÿ”’ Enterprise", "Enterprise"], ["Compliance (SOC2)", "๐Ÿ”’ Enterprise", "Enterprise"], ["Multi-Cloud", "๐Ÿ”’ Enterprise", "Enterprise"] ] integrations_data = [ ["Prometheus", "โœ… Connected", "Monitoring"], ["Grafana", "โœ… Connected", "Visualization"], ["Slack", "๐Ÿ”’ Enterprise", "Notifications"], ["PagerDuty", "๐Ÿ”’ Enterprise", "Alerting"], ["Jira", "๐Ÿ”’ Enterprise", "Ticketing"], ["Datadog", "๐Ÿ”’ Enterprise", "Monitoring"] ] features_table = gr.Dataframe( headers=["Feature", "Status", "Edition"], value=features_data, label="Feature Comparison" ) integrations_table = gr.Dataframe( headers=["Integration", "Status", "Type"], value=integrations_data, label="Integration Status" ) return (license_display, validate_btn, trial_btn, upgrade_btn, mcp_mode, mcp_mode_info, features_table, integrations_table) # ----------------------------- # Tab 4: Audit Trail - Updated # ----------------------------- def create_tab4_audit_trail() -> tuple: refresh_btn = gr.Button("๐Ÿ”„ Refresh Audit Trail", variant="secondary") clear_btn = gr.Button("๐Ÿ—‘๏ธ Clear History", variant="secondary") export_btn = gr.Button("๐Ÿ“ฅ Export as JSON", variant="primary") execution_headers = ["Time", "Scenario", "Mode", "Status", "Savings", "Details"] incident_headers = ["Time", "Component", "Scenario", "Severity", "Status"] execution_table = gr.Dataframe( headers=execution_headers, value=[], label="Execution History" ) incident_table = gr.Dataframe( headers=incident_headers, value=[], label="Incident History" ) export_text = gr.JSON( value={"status": "Export ready"}, label="Export Data" ) return (refresh_btn, clear_btn, export_btn, execution_table, incident_table, export_text) # ----------------------------- # Tab 5: Learning Engine - Updated # ----------------------------- def create_tab5_learning_engine() -> tuple: learning_graph = gr.Plot(label="RAG Memory Graph") graph_type = gr.Dropdown( choices=["Incident Patterns", "Action-Outcome Chains", "System Dependencies"], value="Incident Patterns", label="Graph Type" ) show_labels = gr.Checkbox(label="Show Labels", value=True) search_query = gr.Textbox(label="Search Patterns", placeholder="Enter pattern to search...") search_btn = gr.Button("๐Ÿ” Search Patterns", variant="secondary") clear_btn_search = gr.Button("๐Ÿ—‘๏ธ Clear Search", variant="secondary") search_results = gr.JSON( value={"status": "Ready for search"}, label="Search Results" ) stats_display = gr.JSON( value={"patterns": 42, "incidents": 156, "success_rate": "87.3%"}, label="Learning Statistics" ) patterns_display = gr.JSON( value={"common_patterns": ["cache_storm", "db_pool", "memory_leak"]}, label="Pattern Library" ) performance_display = gr.JSON( value={"accuracy": "94.2%", "recall": "89.7%", "precision": "92.1%"}, label="Agent Performance" ) return (learning_graph, graph_type, show_labels, search_query, search_btn, clear_btn_search, search_results, stats_display, patterns_display, performance_display) # ----------------------------- # Footer # ----------------------------- def create_footer() -> gr.HTML: return gr.HTML(""" """)