petter2025 commited on
Commit
ca25698
·
verified ·
1 Parent(s): 9b137fe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +529 -452
app.py CHANGED
@@ -1,6 +1,6 @@
1
  """
2
  🚀 ARF Ultimate Investor Demo v3.8.0 - ENTERPRISE EDITION
3
- COMPLETE FIXED VERSION - All components integrated
4
  """
5
 
6
  import logging
@@ -28,45 +28,17 @@ logger = logging.getLogger(__name__)
28
  # Add parent directory to path
29
  sys.path.insert(0, str(Path(__file__).parent))
30
 
31
- # Import Plotly early to ensure availability
32
  try:
33
  import plotly.graph_objects as go
34
  import plotly.express as px
35
  from plotly.subplots import make_subplots
36
  PLOTLY_AVAILABLE = True
37
  except ImportError:
38
- logger.warning("Plotly not available - visualizations will be simplified")
39
  PLOTLY_AVAILABLE = False
40
 
41
  # ===========================================
42
- # IMPORT MODULAR COMPONENTS
43
- # ===========================================
44
- try:
45
- # Import scenarios from your modular file
46
- from demo.scenarios import INCIDENT_SCENARIOS as SCENARIOS_DATA
47
-
48
- # Import orchestrator
49
- from demo.orchestrator import DemoOrchestrator
50
-
51
- # Import UI components
52
- from ui.components import (
53
- create_header, create_status_bar, create_tab1_incident_demo,
54
- create_tab2_business_roi, create_tab3_audit_trail,
55
- create_tab4_enterprise_features, create_tab5_learning_engine,
56
- create_footer
57
- )
58
-
59
- logger.info("✅ Successfully imported all modular components")
60
-
61
- except ImportError as e:
62
- logger.error(f"Failed to import components: {e}")
63
- logger.error(traceback.format_exc())
64
- # Fallback to inline definitions
65
- SCENARIOS_DATA = {}
66
- DemoOrchestrator = None
67
-
68
- # ===========================================
69
- # ENHANCED SCENARIOS WITH OSS vs ENTERPRISE SEPARATION
70
  # ===========================================
71
  ENHANCED_SCENARIOS = {
72
  "Cache Miss Storm": {
@@ -87,6 +59,16 @@ ENHANCED_SCENARIOS = {
87
  "SLA Violation": "Yes",
88
  "Customer Sat": "-40%"
89
  },
 
 
 
 
 
 
 
 
 
 
90
  # OSS RESULTS - ADVISORY ONLY
91
  "oss_results": {
92
  "status": "✅ OSS Analysis Complete",
@@ -131,12 +113,6 @@ ENHANCED_SCENARIOS = {
131
  "Users Impacted": "45,000 → 0",
132
  "Revenue Protected": "$1,700",
133
  "MTTR Improvement": "80% reduction"
134
- },
135
- "audit_info": {
136
- "execution_id": "exec_001",
137
- "timestamp": datetime.datetime.now().isoformat(),
138
- "approval_required": False,
139
- "success": True
140
  }
141
  }
142
  },
@@ -158,6 +134,15 @@ ENHANCED_SCENARIOS = {
158
  "SLA Violation": "Yes",
159
  "Partner Impact": "3 external APIs"
160
  },
 
 
 
 
 
 
 
 
 
161
  "oss_results": {
162
  "status": "✅ OSS Analysis Complete",
163
  "confidence": 0.82,
@@ -171,14 +156,7 @@ ENHANCED_SCENARIOS = {
171
  ],
172
  "estimated_time": "45+ minutes manually",
173
  "engineers_needed": "1 DBA + 1 Backend Engineer",
174
- "advisory_only": True,
175
- "healing_intent": {
176
- "action": "scale_connection_pool",
177
- "component": "postgresql_database",
178
- "parameters": {"max_connections": 200},
179
- "confidence": 0.82,
180
- "requires_enterprise": True
181
- }
182
  },
183
  "enterprise_results": {
184
  "execution_mode": "Approval Required",
@@ -199,12 +177,6 @@ ENHANCED_SCENARIOS = {
199
  "Cost Saved": "$3,150",
200
  "Failed Transactions": "12,500 → 0",
201
  "SLA Compliance": "Restored to 99.9%"
202
- },
203
- "audit_info": {
204
- "execution_id": "exec_002",
205
- "timestamp": datetime.datetime.now().isoformat(),
206
- "approval_required": True,
207
- "success": True
208
  }
209
  }
210
  },
@@ -226,6 +198,15 @@ ENHANCED_SCENARIOS = {
226
  "Payment Failures": "3.2% of transactions",
227
  "Support Tickets": "+300%"
228
  },
 
 
 
 
 
 
 
 
 
229
  "oss_results": {
230
  "status": "✅ OSS Analysis Complete",
231
  "confidence": 0.79,
@@ -239,14 +220,7 @@ ENHANCED_SCENARIOS = {
239
  ],
240
  "estimated_time": "90+ minutes manually",
241
  "engineers_needed": "2 Java Devs + 1 SRE",
242
- "advisory_only": True,
243
- "healing_intent": {
244
- "action": "scale_memory",
245
- "component": "java_payment_service",
246
- "parameters": {"memory_limit_gb": 4},
247
- "confidence": 0.79,
248
- "requires_enterprise": True
249
- }
250
  },
251
  "enterprise_results": {
252
  "execution_mode": "Autonomous with Rollback",
@@ -267,12 +241,6 @@ ENHANCED_SCENARIOS = {
267
  "Cost Saved": "$4,950",
268
  "Transaction Success": "96.8% → 99.9%",
269
  "User Impact": "8,500 → 0 affected"
270
- },
271
- "audit_info": {
272
- "execution_id": "exec_003",
273
- "timestamp": datetime.datetime.now().isoformat(),
274
- "approval_required": False,
275
- "success": True
276
  }
277
  }
278
  },
@@ -294,6 +262,15 @@ ENHANCED_SCENARIOS = {
294
  "Data Sync Delay": "4+ hours",
295
  "Customer Reports": "Delayed by 6 hours"
296
  },
 
 
 
 
 
 
 
 
 
297
  "oss_results": {
298
  "status": "✅ OSS Analysis Complete",
299
  "confidence": 0.85,
@@ -307,14 +284,7 @@ ENHANCED_SCENARIOS = {
307
  ],
308
  "estimated_time": "75+ minutes manually",
309
  "engineers_needed": "2 Backend Engineers + 1 DevOps",
310
- "advisory_only": True,
311
- "healing_intent": {
312
- "action": "implement_rate_limiting",
313
- "component": "external_api_gateway",
314
- "parameters": {"backoff_strategy": "exponential"},
315
- "confidence": 0.85,
316
- "requires_enterprise": True
317
- }
318
  },
319
  "enterprise_results": {
320
  "execution_mode": "Autonomous",
@@ -335,468 +305,575 @@ ENHANCED_SCENARIOS = {
335
  "Cost Saved": "$3,420",
336
  "SLA Compliance": "Restored within 5 minutes",
337
  "Data Freshness": "4+ hours → <5 minute delay"
338
- },
339
- "audit_info": {
340
- "execution_id": "exec_004",
341
- "timestamp": datetime.datetime.now().isoformat(),
342
- "approval_required": False,
343
- "success": True
344
  }
345
  }
346
  }
347
  }
348
 
349
  # ===========================================
350
- # SIMPLE VISUALIZATION ENGINE (No external dependencies)
351
  # ===========================================
352
- class SimpleVizEngine:
353
- """Simple visualization engine that works without complex imports"""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
354
 
355
  @staticmethod
356
- def create_timeline_plot(scenario_name="Incident"):
357
- """Create a simple timeline plot"""
358
- if not PLOTLY_AVAILABLE:
359
- # Return a placeholder if plotly not available
360
- import matplotlib.pyplot as plt
361
- import io
362
- import base64
363
-
364
- fig, ax = plt.subplots(figsize=(10, 4))
365
- events = ['Detection', 'Analysis', 'Action', 'Recovery']
366
- times = [0, 1, 2, 3]
367
-
368
- ax.plot(times, [1, 1, 1, 1], 'bo-', markersize=10)
369
- for i, (event, t) in enumerate(zip(events, times)):
370
- ax.text(t, 1.1, event, ha='center', fontsize=10)
371
-
372
- ax.set_ylim(0.5, 1.5)
373
- ax.set_xlim(-0.5, 3.5)
374
- ax.set_title(f'Timeline: {scenario_name}')
375
- ax.axis('off')
376
-
377
- buf = io.BytesIO()
378
- plt.savefig(buf, format='png', bbox_inches='tight')
379
- plt.close(fig)
380
- buf.seek(0)
381
-
382
- return f"data:image/png;base64,{base64.b64encode(buf.read()).decode()}"
383
 
384
- # Use Plotly if available
385
- fig = go.Figure()
386
 
387
- events = [
388
- {"time": "T-5m", "event": "Detection", "type": "detection"},
389
- {"time": "T-3m", "event": "OSS Analysis", "type": "analysis"},
390
- {"time": "T-2m", "event": "Enterprise Action", "type": "action"},
391
- {"time": "T-0m", "event": "Recovery", "type": "recovery"}
392
- ]
393
 
394
- for event in events:
395
- fig.add_trace(go.Scatter(
396
- x=[event["time"]],
397
- y=[1],
398
- mode='markers+text',
399
- marker=dict(size=20, color='#4ECDC4'),
400
- text=[event["event"]],
401
- textposition="top center"
402
- ))
403
 
404
- fig.update_layout(
405
- title=f"Timeline: {scenario_name}",
406
- height=300,
407
- showlegend=False,
408
- yaxis=dict(showticklabels=False, range=[0.5, 1.5]),
409
- margin=dict(l=20, r=20, t=40, b=20)
410
- )
411
 
412
- return fig
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
413
 
414
  @staticmethod
415
- def create_dashboard_plot():
416
- """Create simple dashboard plot"""
417
  if not PLOTLY_AVAILABLE:
418
  return None
419
 
420
- fig = make_subplots(rows=1, cols=2, subplot_titles=('Cost Savings', 'MTTR Improvement'))
 
421
 
422
- # Cost savings
423
- fig.add_trace(
424
- go.Bar(x=['Without ARF', 'With ARF'], y=[100, 25], name='Cost'),
425
- row=1, col=1
426
- )
427
 
428
- # MTTR improvement
429
- fig.add_trace(
430
- go.Bar(x=['Manual', 'ARF OSS', 'ARF Enterprise'], y=[120, 25, 8], name='MTTR'),
431
- row=1, col=2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
432
  )
433
 
434
- fig.update_layout(height=400, showlegend=False)
435
  return fig
436
 
437
  # ===========================================
438
- # AUDIT TRAIL MANAGER
439
- # ===========================================
440
- class AuditTrailManager:
441
- def __init__(self):
442
- self.executions = []
443
- self.incidents = []
444
-
445
- def add_execution(self, scenario_name, mode, success=True, savings=0):
446
- entry = {
447
- "id": f"exec_{len(self.executions):03d}",
448
- "time": datetime.datetime.now().strftime("%H:%M"),
449
- "scenario": scenario_name,
450
- "mode": mode,
451
- "status": "✅ Success" if success else "❌ Failed",
452
- "savings": f"${savings:,}",
453
- "details": f"{mode} execution"
454
- }
455
- self.executions.insert(0, entry)
456
- return entry
457
-
458
- def add_incident(self, scenario_name, severity="HIGH"):
459
- entry = {
460
- "id": f"inc_{len(self.incidents):03d}",
461
- "time": datetime.datetime.now().strftime("%H:%M"),
462
- "scenario": scenario_name,
463
- "severity": severity,
464
- "component": ENHANCED_SCENARIOS.get(scenario_name, {}).get("component", "unknown"),
465
- "status": "Analyzed"
466
- }
467
- self.incidents.insert(0, entry)
468
- return entry
469
-
470
- def get_execution_table(self):
471
- return [
472
- [e["time"], e["scenario"], e["mode"], e["status"], e["savings"], e["details"]]
473
- for e in self.executions[:10]
474
- ]
475
-
476
- def get_incident_table(self):
477
- return [
478
- [e["time"], e["component"], e["scenario"], e["severity"], e["status"]]
479
- for e in self.incidents[:15]
480
- ]
481
-
482
- # ===========================================
483
- # CREATE DEMO INTERFACE - FIXED VERSION
484
  # ===========================================
485
  def create_demo_interface():
486
- """Create the demo interface with all fixes applied"""
487
 
488
  import gradio as gr
489
 
490
- # Initialize components
491
- viz_engine = SimpleVizEngine()
492
- audit_manager = AuditTrailManager()
493
-
494
- # Initialize orchestrator if available
495
- orchestrator = None
496
- if DemoOrchestrator:
497
- try:
498
- orchestrator = DemoOrchestrator()
499
- except:
500
- pass
501
 
502
- # Custom CSS for OSS vs Enterprise separation
503
  custom_css = """
504
- .oss-section {
505
- background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%) !important;
506
- border-left: 4px solid #2196f3 !important;
507
- padding: 15px !important;
508
- border-radius: 8px !important;
509
  margin-bottom: 15px !important;
 
 
510
  }
511
- .enterprise-section {
 
 
 
512
  background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%) !important;
513
- border-left: 4px solid #4caf50 !important;
514
  padding: 15px !important;
515
  border-radius: 8px !important;
516
- margin-bottom: 15px !important;
 
517
  }
518
- .critical { color: #d32f2f !important; font-weight: bold; }
519
- .success { color: #388e3c !important; font-weight: bold; }
520
  """
521
 
522
  with gr.Blocks(title="🚀 ARF Investor Demo v3.8.0", css=custom_css) as demo:
523
 
524
- # Use your modular header
525
- create_header("3.3.6", False) # OSS version, Mock mode
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
526
 
527
- # Status bar
528
- create_status_bar()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
529
 
530
  # Tabs
531
  with gr.Tabs():
532
 
533
- # TAB 1: Live Incident Demo (Fixed)
534
  with gr.TabItem("🔥 Live Incident Demo"):
535
- # Get components from your UI module
536
- (scenario_dropdown, scenario_description, metrics_display, impact_display,
537
- timeline_output, oss_btn, enterprise_btn, approval_toggle, demo_btn,
538
- approval_display, config_display, results_display) = create_tab1_incident_demo(
539
- ENHANCED_SCENARIOS, "Cache Miss Storm"
540
- )
541
-
542
- # Add OSS and Enterprise results displays
543
  with gr.Row():
544
- with gr.Column():
545
- gr.Markdown("### 📋 OSS Analysis Results (Advisory Only)")
546
- oss_results = gr.JSON(
547
- value={},
548
- label=""
 
 
 
 
549
  )
 
 
 
 
 
 
 
 
550
 
551
- with gr.Column():
552
- gr.Markdown("### 🎯 Enterprise Execution Results")
553
- enterprise_results = gr.JSON(
554
- value={},
555
- label=""
 
 
 
 
 
 
 
 
 
 
 
556
  )
 
 
 
 
 
 
557
 
558
- # TAB 2: Business Impact & ROI
559
  with gr.TabItem("💰 Business Impact & ROI"):
560
- (dashboard_output, monthly_slider, impact_slider, team_slider,
561
- calculate_btn, roi_output) = create_tab2_business_roi()
562
-
563
- # TAB 3: Audit Trail
564
- with gr.TabItem("📜 Audit Trail & History"):
565
- (refresh_btn, clear_btn, export_btn, execution_table, savings_chart,
566
- incident_table, memory_graph, export_text) = create_tab3_audit_trail()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
567
 
568
- # Other tabs...
569
  with gr.TabItem("🏢 Enterprise Features"):
570
- create_tab4_enterprise_features()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
571
 
572
- with gr.TabItem("🧠 Learning Engine"):
573
- create_tab5_learning_engine()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
574
 
575
  # Footer
576
- create_footer()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
577
 
578
- # ============ EVENT HANDLERS (FIXED) ============
579
 
580
- # Update scenario (FIXED: Proper parameter handling)
581
  def update_scenario(scenario_name):
582
  scenario = ENHANCED_SCENARIOS.get(scenario_name, {})
583
 
584
- # Get timeline plot
585
- if PLOTLY_AVAILABLE:
586
- timeline = viz_engine.create_timeline_plot(scenario_name)
587
- else:
588
- timeline = None
 
 
 
 
589
 
590
  return (
591
- f"### {scenario_name}\n{scenario.get('description', 'No description')}",
592
  scenario.get("metrics", {}),
593
  scenario.get("impact", {}),
594
- timeline if timeline else gr.Plot(visible=False),
595
  {}, # Clear OSS results
596
- {} # Clear Enterprise results
 
597
  )
598
 
599
  scenario_dropdown.change(
600
  fn=update_scenario,
601
  inputs=[scenario_dropdown],
602
  outputs=[scenario_description, metrics_display, impact_display,
603
- timeline_output, oss_results, enterprise_results]
604
- )
605
-
606
- # Run OSS Analysis (FIXED: Proper async handling)
607
- async def run_oss_analysis(scenario_name):
608
- scenario = ENHANCED_SCENARIOS.get(scenario_name, {})
609
-
610
- # Add to audit trail
611
- audit_manager.add_incident(scenario_name, scenario.get("severity", "HIGH"))
612
-
613
- # Get OSS results
614
- oss_result = scenario.get("oss_results", {})
615
-
616
- # Update tables
617
- incident_table_data = audit_manager.get_incident_table()
618
-
619
- return oss_result, incident_table_data
620
-
621
- oss_btn.click(
622
- fn=run_oss_analysis,
623
- inputs=[scenario_dropdown],
624
- outputs=[oss_results, incident_table]
625
- )
626
-
627
- # Execute Enterprise Healing (FIXED: Proper parameter matching)
628
- def execute_enterprise_healing(scenario_name, approval_required):
629
- scenario = ENHANCED_SCENARIOS.get(scenario_name, {})
630
-
631
- # Get enterprise results
632
- enterprise_result = scenario.get("enterprise_results", {})
633
-
634
- # Determine mode
635
- mode = "Approval" if approval_required else "Autonomous"
636
-
637
- # Calculate savings from impact
638
- impact = scenario.get("impact", {})
639
- revenue_loss = impact.get("Revenue Loss", "$0")
640
- try:
641
- savings = int(revenue_loss.replace("$", "").replace(",", "").split("/")[0]) * 0.85
642
- except:
643
- savings = 5000
644
-
645
- # Add to audit trail
646
- audit_manager.add_execution(
647
- scenario_name,
648
- mode,
649
- savings=int(savings)
650
- )
651
-
652
- # Create approval display
653
- if approval_required:
654
- approval_html = f"""
655
- <div class='enterprise-section'>
656
- <h4>✅ Approved & Executed</h4>
657
- <p>Action for <strong>{scenario_name}</strong> was approved by system administrator and executed successfully.</p>
658
- <p><strong>Mode:</strong> Manual Approval</p>
659
- <p><strong>Cost Saved:</strong> ${int(savings):,}</p>
660
- </div>
661
- """
662
- else:
663
- approval_html = f"""
664
- <div class='enterprise-section'>
665
- <h4>⚡ Auto-Executed</h4>
666
- <p>Action for <strong>{scenario_name}</strong> was executed autonomously by ARF Enterprise.</p>
667
- <p><strong>Mode:</strong> Fully Autonomous</p>
668
- <p><strong>Cost Saved:</strong> ${int(savings):,}</p>
669
- </div>
670
- """
671
-
672
- # Update execution table
673
- execution_table_data = audit_manager.get_execution_table()
674
-
675
- return approval_html, enterprise_result, execution_table_data
676
-
677
- enterprise_btn.click(
678
- fn=execute_enterprise_healing,
679
- inputs=[scenario_dropdown, approval_toggle],
680
- outputs=[approval_display, enterprise_results, execution_table]
681
  )
682
 
683
- # Quick Demo (FIXED: Proper async)
684
- async def run_quick_demo():
685
- # Run OSS analysis
686
- scenario = ENHANCED_SCENARIOS["Cache Miss Storm"]
687
- oss_result = scenario.get("oss_results", {})
688
-
689
- # Execute enterprise
690
- enterprise_result = scenario.get("enterprise_results", {})
691
-
692
- # Update audit trail
693
- audit_manager.add_incident("Cache Miss Storm", "CRITICAL")
694
- audit_manager.add_execution("Cache Miss Storm", "Autonomous", savings=7200)
695
-
696
- # Get table data
697
- execution_table_data = audit_manager.get_execution_table()
698
- incident_table_data = audit_manager.get_incident_table()
699
-
700
- # Create approval display
701
- approval_html = """
702
- <div class='enterprise-section'>
703
- <h4>⚡ Quick Demo Completed</h4>
704
- <p>Full OSS analysis → Enterprise execution completed successfully.</p>
705
- <p><strong>Mode:</strong> Autonomous</p>
706
- <p><strong>Cost Saved:</strong> $7,200</p>
707
- </div>
708
- """
709
-
710
- return (
711
- oss_result,
712
- approval_html,
713
- enterprise_result,
714
- execution_table_data,
715
- incident_table_data,
716
- gr.Checkbox.update(value=False)
717
- )
718
-
719
- demo_btn.click(
720
- fn=run_quick_demo,
721
- outputs=[
722
- oss_results,
723
- approval_display,
724
- enterprise_results,
725
- execution_table,
726
- incident_table,
727
- approval_toggle
728
- ]
729
  )
730
 
731
- # ROI Calculator (FIXED)
732
- def calculate_roi(monthly, impact, team):
733
- if orchestrator:
734
- company_data = {
735
- "monthly_incidents": monthly,
736
- "avg_cost_per_incident": impact,
737
- "team_size": team
738
- }
739
- roi_result = orchestrator.calculate_roi(company_data)
740
- else:
741
- # Simple calculation
742
- annual = monthly * 12 * impact
743
- savings = annual * 0.82
744
- team_cost = team * 150000
745
- roi_multiplier = savings / team_cost if team_cost > 0 else 0
746
-
747
- roi_result = {
748
- "annual_impact": annual,
749
- "team_cost": team_cost,
750
- "potential_savings": savings,
751
- "roi_multiplier": roi_multiplier,
752
- "payback_months": (team_cost / (savings / 12)) if savings > 0 else 0
753
- }
754
-
755
- # Format for display
756
- formatted = {
757
- "Annual Impact": f"${roi_result.get('annual_impact', 0):,.0f}",
758
- "Team Cost": f"${roi_result.get('team_cost', 0):,.0f}",
759
- "Potential Savings": f"${roi_result.get('potential_savings', 0):,.0f}",
760
- "ROI Multiplier": f"{roi_result.get('roi_multiplier', 0):.1f}×",
761
- "Payback Period": f"{roi_result.get('payback_months', 0):.1f} months"
762
- }
763
 
764
- # Add dashboard
765
- dashboard = viz_engine.create_dashboard_plot()
766
-
767
- return formatted, dashboard
768
 
769
- calculate_btn.click(
770
- fn=calculate_roi,
771
- inputs=[monthly_slider, impact_slider, team_slider],
772
- outputs=[roi_output, dashboard_output]
773
  )
774
 
775
- # Audit Trail Refresh (FIXED)
776
- def refresh_audit_trail():
777
- return audit_manager.get_execution_table(), audit_manager.get_incident_table()
778
 
779
- refresh_btn.click(
780
- fn=refresh_audit_trail,
781
- outputs=[execution_table, incident_table]
 
782
  )
783
 
784
- # Clear History (FIXED)
785
- def clear_audit_trail():
786
- audit_manager.executions = []
787
- audit_manager.incidents = []
788
- return audit_manager.get_execution_table(), audit_manager.get_incident_table()
789
-
790
- clear_btn.click(
791
- fn=clear_audit_trail,
792
- outputs=[execution_table, incident_table]
793
- )
794
-
795
- # Initialize with first scenario
796
  demo.load(
797
- fn=lambda: update_scenario("Cache Miss Storm"),
798
- outputs=[scenario_description, metrics_display, impact_display,
799
- timeline_output, oss_results, enterprise_results]
800
  )
801
 
802
  return demo
@@ -808,11 +885,11 @@ def main():
808
  """Main entry point"""
809
  print("🚀 Starting ARF Ultimate Investor Demo v3.8.0...")
810
  print("=" * 70)
811
- print("📊 Features:")
812
- print(" • 4 Enhanced Incident Scenarios")
813
- print(" • Clear OSS vs Enterprise Separation")
814
- print(" • Fixed Visualization Engine")
815
- print(" • Working Event Handlers")
816
  print("=" * 70)
817
  print("🌐 Opening web interface...")
818
 
 
1
  """
2
  🚀 ARF Ultimate Investor Demo v3.8.0 - ENTERPRISE EDITION
3
+ UPDATED: Scenario-integrated ROI Calculator + MCP Mode explanations
4
  """
5
 
6
  import logging
 
28
  # Add parent directory to path
29
  sys.path.insert(0, str(Path(__file__).parent))
30
 
31
+ # Import Plotly
32
  try:
33
  import plotly.graph_objects as go
34
  import plotly.express as px
35
  from plotly.subplots import make_subplots
36
  PLOTLY_AVAILABLE = True
37
  except ImportError:
 
38
  PLOTLY_AVAILABLE = False
39
 
40
  # ===========================================
41
+ # ENHANCED SCENARIOS WITH ROI CALCULATION DATA
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  # ===========================================
43
  ENHANCED_SCENARIOS = {
44
  "Cache Miss Storm": {
 
59
  "SLA Violation": "Yes",
60
  "Customer Sat": "-40%"
61
  },
62
+ # ROI CALCULATION DATA (Extracted for calculator)
63
+ "roi_data": {
64
+ "hourly_revenue_loss": 8500,
65
+ "manual_recovery_hours": 1.0, # 60 minutes
66
+ "enterprise_recovery_hours": 0.2, # 12 minutes
67
+ "engineers_required": 4, # 2-3 SREs + 1 DBA
68
+ "engineer_hourly_rate": 150, # $150/hour
69
+ "estimated_monthly_occurrences": 2, # Happens twice monthly on average
70
+ "enterprise_savings_percentage": 0.85 # 85% savings with Enterprise
71
+ },
72
  # OSS RESULTS - ADVISORY ONLY
73
  "oss_results": {
74
  "status": "✅ OSS Analysis Complete",
 
113
  "Users Impacted": "45,000 → 0",
114
  "Revenue Protected": "$1,700",
115
  "MTTR Improvement": "80% reduction"
 
 
 
 
 
 
116
  }
117
  }
118
  },
 
134
  "SLA Violation": "Yes",
135
  "Partner Impact": "3 external APIs"
136
  },
137
+ "roi_data": {
138
+ "hourly_revenue_loss": 4200,
139
+ "manual_recovery_hours": 0.75, # 45 minutes
140
+ "enterprise_recovery_hours": 0.13, # 8 minutes
141
+ "engineers_required": 2, # 1 DBA + 1 Backend Engineer
142
+ "engineer_hourly_rate": 150,
143
+ "estimated_monthly_occurrences": 3,
144
+ "enterprise_savings_percentage": 0.82
145
+ },
146
  "oss_results": {
147
  "status": "✅ OSS Analysis Complete",
148
  "confidence": 0.82,
 
156
  ],
157
  "estimated_time": "45+ minutes manually",
158
  "engineers_needed": "1 DBA + 1 Backend Engineer",
159
+ "advisory_only": True
 
 
 
 
 
 
 
160
  },
161
  "enterprise_results": {
162
  "execution_mode": "Approval Required",
 
177
  "Cost Saved": "$3,150",
178
  "Failed Transactions": "12,500 → 0",
179
  "SLA Compliance": "Restored to 99.9%"
 
 
 
 
 
 
180
  }
181
  }
182
  },
 
198
  "Payment Failures": "3.2% of transactions",
199
  "Support Tickets": "+300%"
200
  },
201
+ "roi_data": {
202
+ "hourly_revenue_loss": 5500,
203
+ "manual_recovery_hours": 1.5, # 90 minutes
204
+ "enterprise_recovery_hours": 0.25, # 15 minutes
205
+ "engineers_required": 3, # 2 Java Devs + 1 SRE
206
+ "engineer_hourly_rate": 150,
207
+ "estimated_monthly_occurrences": 1,
208
+ "enterprise_savings_percentage": 0.79
209
+ },
210
  "oss_results": {
211
  "status": "✅ OSS Analysis Complete",
212
  "confidence": 0.79,
 
220
  ],
221
  "estimated_time": "90+ minutes manually",
222
  "engineers_needed": "2 Java Devs + 1 SRE",
223
+ "advisory_only": True
 
 
 
 
 
 
 
224
  },
225
  "enterprise_results": {
226
  "execution_mode": "Autonomous with Rollback",
 
241
  "Cost Saved": "$4,950",
242
  "Transaction Success": "96.8% → 99.9%",
243
  "User Impact": "8,500 → 0 affected"
 
 
 
 
 
 
244
  }
245
  }
246
  },
 
262
  "Data Sync Delay": "4+ hours",
263
  "Customer Reports": "Delayed by 6 hours"
264
  },
265
+ "roi_data": {
266
+ "hourly_revenue_loss": 3800,
267
+ "manual_recovery_hours": 1.25, # 75 minutes
268
+ "enterprise_recovery_hours": 0.17, # 10 minutes
269
+ "engineers_required": 3, # 2 Backend Engineers + 1 DevOps
270
+ "engineer_hourly_rate": 150,
271
+ "estimated_monthly_occurrences": 4,
272
+ "enterprise_savings_percentage": 0.85
273
+ },
274
  "oss_results": {
275
  "status": "✅ OSS Analysis Complete",
276
  "confidence": 0.85,
 
284
  ],
285
  "estimated_time": "75+ minutes manually",
286
  "engineers_needed": "2 Backend Engineers + 1 DevOps",
287
+ "advisory_only": True
 
 
 
 
 
 
 
288
  },
289
  "enterprise_results": {
290
  "execution_mode": "Autonomous",
 
305
  "Cost Saved": "$3,420",
306
  "SLA Compliance": "Restored within 5 minutes",
307
  "Data Freshness": "4+ hours → <5 minute delay"
 
 
 
 
 
 
308
  }
309
  }
310
  }
311
  }
312
 
313
  # ===========================================
314
+ # MCP MODE EXPLANATIONS
315
  # ===========================================
316
+ MCP_MODE_DESCRIPTIONS = {
317
+ "advisory": {
318
+ "name": "Advisory Mode",
319
+ "icon": "📋",
320
+ "description": "OSS Edition - Analysis only, no execution",
321
+ "purpose": "Analyzes incidents and provides recommendations. Perfect for teams starting with AI reliability.",
322
+ "features": [
323
+ "✅ Incident detection & analysis",
324
+ "✅ RAG similarity search",
325
+ "✅ HealingIntent creation",
326
+ "❌ No action execution",
327
+ "❌ Manual implementation required"
328
+ ],
329
+ "use_case": "Compliance-heavy environments, initial AI adoption phases"
330
+ },
331
+ "approval": {
332
+ "name": "Approval Mode",
333
+ "icon": "🔐",
334
+ "description": "Enterprise - Executes after human approval",
335
+ "purpose": "Balances automation with human oversight. Actions require explicit approval before execution.",
336
+ "features": [
337
+ "✅ All OSS advisory features",
338
+ "✅ Action execution capability",
339
+ "✅ Human-in-the-loop approval",
340
+ "✅ Audit trail & compliance",
341
+ "✅ Rollback capabilities"
342
+ ],
343
+ "use_case": "Regulated industries, critical production systems"
344
+ },
345
+ "autonomous": {
346
+ "name": "Autonomous Mode",
347
+ "icon": "⚡",
348
+ "description": "Enterprise - Fully autonomous execution",
349
+ "purpose": "Maximum efficiency with AI-driven autonomous healing. Self-corrects based on learned patterns.",
350
+ "features": [
351
+ "✅ All approval mode features",
352
+ "✅ Fully autonomous execution",
353
+ "✅ Machine learning optimization",
354
+ "✅ Predictive incident prevention",
355
+ "✅ Continuous learning loop"
356
+ ],
357
+ "use_case": "High-scale systems, mature reliability teams, 24/7 operations"
358
+ }
359
+ }
360
+
361
+ # ===========================================
362
+ # ROI CALCULATOR ENGINE
363
+ # ===========================================
364
+ class ROI_Calculator:
365
+ """Calculates ROI based on scenario data and user inputs"""
366
 
367
  @staticmethod
368
+ def calculate_scenario_roi(scenario_name, monthly_incidents, team_size):
369
+ """Calculate ROI for a specific scenario"""
370
+ scenario = ENHANCED_SCENARIOS.get(scenario_name, {})
371
+ roi_data = scenario.get("roi_data", {})
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
372
 
373
+ if not roi_data:
374
+ return {"error": "No ROI data for this scenario"}
375
 
376
+ # Extract data
377
+ hourly_loss = roi_data.get("hourly_revenue_loss", 0)
378
+ manual_hours = roi_data.get("manual_recovery_hours", 1)
379
+ enterprise_hours = roi_data.get("enterprise_recovery_hours", 0.2)
380
+ monthly_occurrences = roi_data.get("estimated_monthly_occurrences", 2)
381
+ savings_pct = roi_data.get("enterprise_savings_percentage", 0.85)
382
 
383
+ # Calculate costs
384
+ monthly_manual_cost = hourly_loss * manual_hours * monthly_occurrences
385
+ monthly_enterprise_cost = hourly_loss * enterprise_hours * monthly_occurrences
386
+ monthly_savings = monthly_manual_cost - monthly_enterprise_cost
 
 
 
 
 
387
 
388
+ # Annual calculations
389
+ annual_manual_cost = monthly_manual_cost * 12
390
+ annual_enterprise_cost = monthly_enterprise_cost * 12
391
+ annual_savings = monthly_savings * 12
 
 
 
392
 
393
+ # Team costs
394
+ engineer_hourly = roi_data.get("engineer_hourly_rate", 150)
395
+ engineers_needed = roi_data.get("engineers_required", 2)
396
+ team_hourly_cost = engineers_needed * engineer_hourly
397
+ manual_team_cost = team_hourly_cost * manual_hours * monthly_occurrences * 12
398
+
399
+ # Enterprise subscription (simplified)
400
+ enterprise_monthly_cost = 499 # Base subscription
401
+ enterprise_usage_cost = monthly_enterprise_cost * 0.10 # $0.10 per incident
402
+
403
+ # ROI calculation
404
+ total_enterprise_cost = (enterprise_monthly_cost * 12) + (enterprise_usage_cost * 12)
405
+ roi_multiplier = annual_savings / total_enterprise_cost if total_enterprise_cost > 0 else 0
406
+ payback_months = total_enterprise_cost / (annual_savings / 12) if annual_savings > 0 else 0
407
+
408
+ return {
409
+ "scenario": scenario_name,
410
+ "monthly_manual_cost": f"${monthly_manual_cost:,.0f}",
411
+ "monthly_enterprise_cost": f"${monthly_enterprise_cost:,.0f}",
412
+ "monthly_savings": f"${monthly_savings:,.0f}",
413
+ "annual_manual_cost": f"${annual_manual_cost:,.0f}",
414
+ "annual_enterprise_cost": f"${annual_enterprise_cost:,.0f}",
415
+ "annual_savings": f"${annual_savings:,.0f}",
416
+ "enterprise_subscription": f"${enterprise_monthly_cost:,.0f}/month",
417
+ "roi_multiplier": f"{roi_multiplier:.1f}×",
418
+ "payback_months": f"{payback_months:.1f} months",
419
+ "manual_recovery_time": f"{manual_hours*60:.0f} minutes",
420
+ "enterprise_recovery_time": f"{enterprise_hours*60:.0f} minutes",
421
+ "recovery_improvement": f"{(1 - enterprise_hours/manual_hours)*100:.0f}% faster"
422
+ }
423
 
424
  @staticmethod
425
+ def create_comparison_chart(scenario_name):
426
+ """Create ROI comparison chart"""
427
  if not PLOTLY_AVAILABLE:
428
  return None
429
 
430
+ scenario = ENHANCED_SCENARIOS.get(scenario_name, {})
431
+ roi_data = scenario.get("roi_data", {})
432
 
433
+ fig = go.Figure()
 
 
 
 
434
 
435
+ # Manual vs Enterprise cost comparison
436
+ manual_cost = roi_data.get("hourly_revenue_loss", 0) * roi_data.get("manual_recovery_hours", 1)
437
+ enterprise_cost = roi_data.get("hourly_revenue_loss", 0) * roi_data.get("enterprise_recovery_hours", 0.2)
438
+
439
+ fig.add_trace(go.Bar(
440
+ x=['Manual Resolution', 'ARF Enterprise'],
441
+ y=[manual_cost, enterprise_cost],
442
+ name='Cost per Incident',
443
+ marker_color=['#FF6B6B', '#4ECDC4'],
444
+ text=[f'${manual_cost:,.0f}', f'${enterprise_cost:,.0f}'],
445
+ textposition='auto'
446
+ ))
447
+
448
+ fig.update_layout(
449
+ title=f"Cost Comparison: {scenario_name}",
450
+ yaxis_title="Cost ($)",
451
+ showlegend=False,
452
+ height=300
453
  )
454
 
 
455
  return fig
456
 
457
  # ===========================================
458
+ # CREATE DEMO INTERFACE WITH ENHANCEMENTS
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
459
  # ===========================================
460
  def create_demo_interface():
461
+ """Create demo with scenario-integrated ROI calculator and MCP explanations"""
462
 
463
  import gradio as gr
464
 
465
+ # Initialize
466
+ roi_calculator = ROI_Calculator()
 
 
 
 
 
 
 
 
 
467
 
468
+ # Custom CSS for enhancements
469
  custom_css = """
470
+ .mcp-mode-card {
471
+ background: white !important;
472
+ border-radius: 10px !important;
473
+ padding: 20px !important;
 
474
  margin-bottom: 15px !important;
475
+ border-left: 4px solid #4ECDC4 !important;
476
+ box-shadow: 0 2px 8px rgba(0,0,0,0.06) !important;
477
  }
478
+ .mcp-advisory { border-left-color: #2196f3 !important; }
479
+ .mcp-approval { border-left-color: #ff9800 !important; }
480
+ .mcp-autonomous { border-left-color: #4caf50 !important; }
481
+ .roi-highlight {
482
  background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%) !important;
 
483
  padding: 15px !important;
484
  border-radius: 8px !important;
485
+ border-left: 4px solid #4caf50 !important;
486
+ margin: 10px 0 !important;
487
  }
 
 
488
  """
489
 
490
  with gr.Blocks(title="🚀 ARF Investor Demo v3.8.0", css=custom_css) as demo:
491
 
492
+ # Header
493
+ gr.Markdown("""
494
+ <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;">
495
+ <h1 style="margin-bottom: 10px;">🚀 Agentic Reliability Framework</h1>
496
+ <h2 style="color: #4a5568; font-weight: 600; margin-bottom: 20px;">Investor Demo v3.8.0</h2>
497
+
498
+ <div style="display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; margin-bottom: 20px;">
499
+ <div style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 8px 16px; border-radius: 20px; font-weight: 700; font-size: 0.85rem;">
500
+ 🏢 Enterprise Edition
501
+ </div>
502
+ <div style="background: linear-gradient(135deg, #4299e1 0%, #38b2ac 100%); color: white; padding: 8px 16px; border-radius: 20px; font-weight: 700; font-size: 0.85rem;">
503
+ 🆓 OSS v3.3.6
504
+ </div>
505
+ <div style="background: #e8f5e8; color: #2d3748; padding: 8px 16px; border-radius: 20px; font-weight: 600; font-size: 0.85rem;">
506
+ 📈 5.2× ROI
507
+ </div>
508
+ <div style="background: #fff3cd; color: #856404; padding: 8px 16px; border-radius: 20px; font-weight: 600; font-size: 0.85rem;">
509
+ ⚡ 85% MTTR Reduction
510
+ </div>
511
+ </div>
512
+
513
+ <div style="color: #718096; font-size: 16px; max-width: 800px; margin: 0 auto; line-height: 1.6;">
514
+ From <span style="font-weight: 700; color: #4299e1;">OSS Advisory</span>
515
+ to <span style="font-weight: 700; color: #764ba2;">Enterprise Autonomous Healing</span>.
516
+ <span style="color: #4ECDC4; font-weight: 600;"> New: Scenario-integrated ROI Calculator</span>
517
+ </div>
518
+
519
+ <div style="margin-top: 15px; font-size: 0.9rem; color: #FFA726; font-weight: 600;">
520
+ ⚠️ Mock Mode (Enhanced ROI Calculator)
521
+ </div>
522
+ </div>
523
+ """)
524
 
525
+ # Status Bar
526
+ gr.Markdown("""
527
+ <div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-bottom: 25px;">
528
+ <div style="background: white; padding: 20px; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); border-left: 4px solid #4ECDC4;">
529
+ <div style="font-size: 0.9rem; color: #718096; margin-bottom: 5px;">System Status</div>
530
+ <div style="display: flex; align-items: center; gap: 8px;">
531
+ <div style="width: 10px; height: 10px; background: #4ECDC4; border-radius: 50%;"></div>
532
+ <div style="font-weight: 700; color: #2d3748;">Operational</div>
533
+ </div>
534
+ </div>
535
+
536
+ <div style="background: white; padding: 20px; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); border-left: 4px solid #FFA726;">
537
+ <div style="font-size: 0.9rem; color: #718096; margin-bottom: 5px;">Active Scenario</div>
538
+ <div style="font-weight: 700; color: #2d3748; font-size: 1.1rem;">Cache Miss Storm</div>
539
+ </div>
540
+
541
+ <div style="background: white; padding: 20px; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); border-left: 4px solid #42A5F5;">
542
+ <div style="font-size: 0.9rem; color: #718096; margin-bottom: 5px;">MCP Mode</div>
543
+ <div style="font-weight: 700; color: #2d3748; font-size: 1.1rem;">Advisory (OSS)</div>
544
+ </div>
545
+ </div>
546
+ """)
547
 
548
  # Tabs
549
  with gr.Tabs():
550
 
551
+ # TAB 1: Live Incident Demo
552
  with gr.TabItem("🔥 Live Incident Demo"):
 
 
 
 
 
 
 
 
553
  with gr.Row():
554
+ # Left Panel
555
+ with gr.Column(scale=1):
556
+ gr.Markdown("### 🎬 Select Incident Scenario")
557
+
558
+ scenario_dropdown = gr.Dropdown(
559
+ choices=list(ENHANCED_SCENARIOS.keys()),
560
+ value="Cache Miss Storm",
561
+ label="Choose an incident to analyze:",
562
+ interactive=True
563
  )
564
+
565
+ scenario_description = gr.Markdown()
566
+
567
+ gr.Markdown("### 📊 Current Metrics")
568
+ metrics_display = gr.JSON(label="")
569
+
570
+ gr.Markdown("### 💰 Business Impact")
571
+ impact_display = gr.JSON(label="")
572
 
573
+ # Right Panel
574
+ with gr.Column(scale=2):
575
+ gr.Markdown("### 📈 Incident Timeline")
576
+ timeline_output = gr.Plot()
577
+
578
+ gr.Markdown("### ⚡ Take Action")
579
+ with gr.Row():
580
+ oss_btn = gr.Button("🆓 Run OSS Analysis", variant="secondary", size="lg")
581
+ enterprise_btn = gr.Button("🚀 Execute Enterprise Healing", variant="primary", size="lg")
582
+
583
+ with gr.Row():
584
+ approval_toggle = gr.Checkbox(label="🔐 Require Manual Approval", value=True)
585
+ demo_btn = gr.Button("⚡ Quick Demo", variant="secondary", size="sm")
586
+
587
+ approval_display = gr.HTML(
588
+ value="<div style='padding: 15px; background: #f8f9fa; border-radius: 8px; color: #6c757d;'>Approval workflow will appear here after execution</div>"
589
  )
590
+
591
+ gr.Markdown("### 📋 OSS Analysis Results (Advisory Only)")
592
+ oss_results = gr.JSON(label="")
593
+
594
+ gr.Markdown("### 🎯 Enterprise Execution Results")
595
+ enterprise_results = gr.JSON(label="")
596
 
597
+ # TAB 2: Business Impact & ROI (ENHANCED)
598
  with gr.TabItem("💰 Business Impact & ROI"):
599
+ with gr.Column():
600
+ gr.Markdown("### 📊 Executive Dashboard")
601
+ dashboard_output = gr.Plot()
602
+
603
+ gr.Markdown("### 🧮 ROI Calculator (Scenario-Integrated)")
604
+ with gr.Row():
605
+ with gr.Column(scale=1):
606
+ # Scenario selector for ROI
607
+ roi_scenario_dropdown = gr.Dropdown(
608
+ choices=list(ENHANCED_SCENARIOS.keys()),
609
+ value="Cache Miss Storm",
610
+ label="Select scenario for ROI calculation:",
611
+ interactive=True
612
+ )
613
+
614
+ gr.Markdown("#### 📈 Adjust Parameters")
615
+ monthly_slider = gr.Slider(
616
+ 1, 100, value=15, step=1,
617
+ label="Monthly similar incidents:",
618
+ info="How often this type of incident occurs",
619
+ interactive=True
620
+ )
621
+
622
+ team_slider = gr.Slider(
623
+ 1, 20, value=5, step=1,
624
+ label="Reliability team size:",
625
+ info="Engineers available for manual resolution",
626
+ interactive=True
627
+ )
628
+
629
+ calculate_roi_btn = gr.Button(
630
+ "Calculate Scenario ROI",
631
+ variant="primary",
632
+ size="lg"
633
+ )
634
+
635
+ # Show scenario data being used
636
+ gr.Markdown("#### 📊 Using Scenario Data:")
637
+ scenario_data_display = gr.JSON(
638
+ label="Extracted from selected scenario",
639
+ value={}
640
+ )
641
+
642
+ with gr.Column(scale=2):
643
+ gr.Markdown("#### 📈 ROI Analysis Results")
644
+ roi_output = gr.JSON(label="")
645
+
646
+ gr.Markdown("#### 📊 Cost Comparison")
647
+ roi_chart = gr.Plot(label="")
648
+
649
+ # Highlight key metrics
650
+ gr.Markdown("""
651
+ <div class="roi-highlight">
652
+ <h4 style="margin: 0 0 10px 0;">💰 Key Insight</h4>
653
+ <p style="margin: 0;">The ROI calculator now extracts real numbers from your selected incident scenario, showing the actual business impact of ARF Enterprise vs manual resolution.</p>
654
+ </div>
655
+ """)
656
 
657
+ # TAB 4: Enterprise Features (ENHANCED WITH MCP EXPLANATIONS)
658
  with gr.TabItem("🏢 Enterprise Features"):
659
+ with gr.Row():
660
+ # Left Column
661
+ with gr.Column(scale=1):
662
+ gr.Markdown("### 🔐 License Management")
663
+
664
+ license_display = gr.JSON(
665
+ value={
666
+ "status": "Active",
667
+ "tier": "Enterprise",
668
+ "expires": "2024-12-31",
669
+ "mcp_mode": "advisory"
670
+ },
671
+ label="Current License"
672
+ )
673
+
674
+ gr.Markdown("### ⚡ MCP Execution Modes")
675
+
676
+ # MCP Mode Cards with explanations
677
+ for mode_key, mode_info in MCP_MODE_DESCRIPTIONS.items():
678
+ with gr.Column():
679
+ gr.Markdown(f"""
680
+ <div class="mcp-mode-card mcp-{mode_key}">
681
+ <div style="display: flex; align-items: center; gap: 10px; margin-bottom: 10px;">
682
+ <div style="font-size: 1.5rem;">{mode_info['icon']}</div>
683
+ <div>
684
+ <h4 style="margin: 0;">{mode_info['name']}</h4>
685
+ <div style="font-size: 0.9rem; color: #718096;">{mode_info['description']}</div>
686
+ </div>
687
+ </div>
688
+ <div style="margin-bottom: 10px;">
689
+ <strong>Purpose:</strong> {mode_info['purpose']}
690
+ </div>
691
+ <div>
692
+ <strong>Best for:</strong> {mode_info['use_case']}
693
+ </div>
694
+ </div>
695
+ """)
696
+
697
+ # MCP Mode Selector
698
+ gr.Markdown("### ⚙️ Configure MCP Mode")
699
+ mcp_mode = gr.Radio(
700
+ choices=list(MCP_MODE_DESCRIPTIONS.keys()),
701
+ value="advisory",
702
+ label="Execution Mode",
703
+ info="Select the execution mode for demonstration",
704
+ interactive=True
705
+ )
706
+
707
+ mcp_mode_info = gr.JSON(
708
+ label="Selected Mode Details",
709
+ value=MCP_MODE_DESCRIPTIONS["advisory"]
710
+ )
711
+
712
+ # Right Column
713
+ with gr.Column(scale=1):
714
+ gr.Markdown("### 📋 Feature Comparison")
715
+
716
+ features_table = gr.Dataframe(
717
+ headers=["Feature", "OSS", "Starter", "Enterprise"],
718
+ value=[
719
+ ["Autonomous Healing", "❌", "✅ Auto", "✅ AI-Driven"],
720
+ ["MCP Modes", "Advisory only", "Advisory + Approval", "All 3 modes"],
721
+ ["Compliance Automation", "❌", "✅", "✅ SOC2/GDPR"],
722
+ ["Predictive Analytics", "❌", "Basic", "✅ ML-Powered"],
723
+ ["Multi-Cloud Support", "❌", "❌", "✅ Native"],
724
+ ["Audit Trail", "Basic", "✅", "✅ Comprehensive"],
725
+ ["Role-Based Access", "❌", "✅", "✅ Granular"],
726
+ ],
727
+ label="",
728
+ interactive=False
729
+ )
730
+
731
+ gr.Markdown("### 🔗 Integrations")
732
+
733
+ integrations_table = gr.Dataframe(
734
+ headers=["Platform", "Status", "Last Sync"],
735
+ value=[
736
+ ["AWS", "✅ Connected", "5 min ago"],
737
+ ["Azure", "✅ Connected", "8 min ago"],
738
+ ["GCP", "✅ Connected", "3 min ago"],
739
+ ["Datadog", "✅ Connected", "Active"],
740
+ ["PagerDuty", "✅ Connected", "Active"],
741
+ ["ServiceNow", "✅ Connected", "15 min ago"],
742
+ ],
743
+ label="",
744
+ interactive=False
745
+ )
746
 
747
+ # Other tabs...
748
+ with gr.TabItem("📜 Audit Trail & History"):
749
+ with gr.Row():
750
+ with gr.Column():
751
+ gr.Markdown("### 📋 Execution History")
752
+ execution_table = gr.Dataframe(
753
+ headers=["Time", "Scenario", "Mode", "Status", "Savings", "Details"],
754
+ value=[],
755
+ label=""
756
+ )
757
+
758
+ with gr.Column():
759
+ gr.Markdown("### 📊 Incident History")
760
+ incident_table = gr.Dataframe(
761
+ headers=["Time", "Component", "Scenario", "Severity", "Status"],
762
+ value=[],
763
+ label=""
764
+ )
765
 
766
  # Footer
767
+ gr.Markdown("""
768
+ <div style="margin-top: 40px; padding: 30px; background: linear-gradient(135deg, #1a365d 0%, #2d3748 100%); border-radius: 20px; color: white;">
769
+ <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 30px; margin-bottom: 30px;">
770
+ <div>
771
+ <h4 style="color: white; margin-bottom: 15px;">🚀 User Journey</h4>
772
+ <ol style="color: #cbd5e0; padding-left: 20px;">
773
+ <li style="margin-bottom: 8px;">1. Select Incident Scenario</li>
774
+ <li style="margin-bottom: 8px;">2. Calculate Scenario-specific ROI</li>
775
+ <li style="margin-bottom: 8px;">3. Execute Enterprise Healing</li>
776
+ <li style="margin-bottom: 8px;">4. Compare MCP Execution Modes</li>
777
+ <li>5. Explore Audit Trail</li>
778
+ </ol>
779
+ </div>
780
+
781
+ <div>
782
+ <h4 style="color: white; margin-bottom: 15px;">📞 Get Started</h4>
783
+ <ul style="color: #cbd5e0; list-style: none; padding: 0;">
784
+ <li style="margin-bottom: 8px;">📧 sales@arfinvestor.com</li>
785
+ <li style="margin-bottom: 8px;">📚 docs.arfinvestor.com</li>
786
+ <li style="margin-bottom: 8px;">💬 Join Slack Community</li>
787
+ <li>🆓 30-Day Enterprise Trial</li>
788
+ </ul>
789
+ </div>
790
+
791
+ <div>
792
+ <h4 style="color: white; margin-bottom: 15px;">🛡️ Enterprise Grade</h4>
793
+ <ul style="color: #cbd5e0; list-style: none; padding: 0;">
794
+ <li style="margin-bottom: 8px;">✅ SOC 2 Type II</li>
795
+ <li style="margin-bottom: 8px;">✅ GDPR & CCPA</li>
796
+ <li style="margin-bottom: 8px;">✅ ISO 27001</li>
797
+ <li>✅ HIPAA Ready</li>
798
+ </ul>
799
+ </div>
800
+ </div>
801
+
802
+ <div style="border-top: 1px solid #4a5568; padding-top: 20px; text-align: center; color: #a0aec0; font-size: 0.9rem;">
803
+ <p style="margin: 0;">© 2024 Agentic Reliability Framework. Demo v3.8.0 Enterprise Edition.</p>
804
+ <p style="margin: 10px 0 0 0; font-size: 0.8rem;">Enhanced with scenario-integrated ROI calculator and MCP mode explanations</p>
805
+ </div>
806
+ </div>
807
+ """)
808
 
809
+ # ============ EVENT HANDLERS ============
810
 
811
+ # Update scenario (enhanced with ROI data)
812
  def update_scenario(scenario_name):
813
  scenario = ENHANCED_SCENARIOS.get(scenario_name, {})
814
 
815
+ # Extract ROI data for display
816
+ roi_data = scenario.get("roi_data", {})
817
+ display_roi_data = {
818
+ "Hourly Revenue Loss": f"${roi_data.get('hourly_revenue_loss', 0):,.0f}",
819
+ "Manual Recovery Time": f"{roi_data.get('manual_recovery_hours', 1)*60:.0f} minutes",
820
+ "Enterprise Recovery Time": f"{roi_data.get('enterprise_recovery_hours', 0.2)*60:.0f} minutes",
821
+ "Monthly Occurrences": roi_data.get("estimated_monthly_occurrences", 2),
822
+ "Engineers Required": roi_data.get("engineers_required", 2)
823
+ }
824
 
825
  return (
826
+ f"### {scenario_name}\n{scenario.get('description', '')}",
827
  scenario.get("metrics", {}),
828
  scenario.get("impact", {}),
829
+ None, # Placeholder for timeline
830
  {}, # Clear OSS results
831
+ {}, # Clear Enterprise results
832
+ display_roi_data
833
  )
834
 
835
  scenario_dropdown.change(
836
  fn=update_scenario,
837
  inputs=[scenario_dropdown],
838
  outputs=[scenario_description, metrics_display, impact_display,
839
+ timeline_output, oss_results, enterprise_results, scenario_data_display]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
840
  )
841
 
842
+ # Update ROI scenario dropdown
843
+ roi_scenario_dropdown.change(
844
+ fn=lambda name: ENHANCED_SCENARIOS.get(name, {}).get("roi_data", {}),
845
+ inputs=[roi_scenario_dropdown],
846
+ outputs=[scenario_data_display]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
847
  )
848
 
849
+ # Calculate ROI with scenario data
850
+ def calculate_scenario_roi(scenario_name, monthly_incidents, team_size):
851
+ """Calculate ROI using scenario-specific data"""
852
+ roi_result = roi_calculator.calculate_scenario_roi(scenario_name, monthly_incidents, team_size)
853
+ roi_chart_plot = roi_calculator.create_comparison_chart(scenario_name)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
854
 
855
+ return roi_result, roi_chart_plot
 
 
 
856
 
857
+ calculate_roi_btn.click(
858
+ fn=calculate_scenario_roi,
859
+ inputs=[roi_scenario_dropdown, monthly_slider, team_slider],
860
+ outputs=[roi_output, roi_chart]
861
  )
862
 
863
+ # Update MCP mode info
864
+ def update_mcp_mode(mode):
865
+ return MCP_MODE_DESCRIPTIONS.get(mode, {})
866
 
867
+ mcp_mode.change(
868
+ fn=update_mcp_mode,
869
+ inputs=[mcp_mode],
870
+ outputs=[mcp_mode_info]
871
  )
872
 
873
+ # Initialize with first scenario ROI data
 
 
 
 
 
 
 
 
 
 
 
874
  demo.load(
875
+ fn=lambda: ENHANCED_SCENARIOS["Cache Miss Storm"].get("roi_data", {}),
876
+ outputs=[scenario_data_display]
 
877
  )
878
 
879
  return demo
 
885
  """Main entry point"""
886
  print("🚀 Starting ARF Ultimate Investor Demo v3.8.0...")
887
  print("=" * 70)
888
+ print("📊 New Features:")
889
+ print(" • Scenario-integrated ROI Calculator")
890
+ print(" • Extracts revenue loss from incident scenarios")
891
+ print(" • MCP Mode explanations with use cases")
892
+ print(" • 4 Enhanced incident scenarios")
893
  print("=" * 70)
894
  print("🌐 Opening web interface...")
895