petter2025 commited on
Commit
49795df
·
verified ·
1 Parent(s): 47c1a9b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +390 -591
app.py CHANGED
@@ -1,17 +1,22 @@
1
  """
2
- 🚀 ARF Ultimate Investor Demo v3.6.0 - PRODUCTION VERSION
3
- Integrated with actual ARF OSS package v3.3.6
4
- From Cost Center to Profit Engine: 5.2× ROI with Autonomous Reliability
5
  """
6
 
7
  import logging
8
- import uuid
9
  import random
10
- from datetime import datetime
11
- from typing import Dict, Any, List, Optional, Tuple
12
  import gradio as gr
 
 
 
 
 
13
 
14
- # Import actual ARF OSS components
15
  try:
16
  from agentic_reliability_framework.arf_core.models.healing_intent import (
17
  HealingIntent,
@@ -26,7 +31,7 @@ except ImportError as e:
26
  logger = logging.getLogger(__name__)
27
  logger.warning(f"⚠️ ARF OSS not available: {e}. Running in simulation mode.")
28
 
29
- # Mock classes for demo
30
  class HealingIntent:
31
  def __init__(self, **kwargs):
32
  self.intent_type = kwargs.get("intent_type", "scale_out")
@@ -36,7 +41,7 @@ except ImportError as e:
36
  return {
37
  "intent_type": self.intent_type,
38
  "parameters": self.parameters,
39
- "created_at": datetime.now().isoformat()
40
  }
41
 
42
  def create_scale_out_intent(resource_type: str, scale_factor: float = 2.0):
@@ -50,9 +55,6 @@ except ImportError as e:
50
  )
51
 
52
  class OSSMCPClient:
53
- def __init__(self):
54
- self.mode = "advisory"
55
-
56
  def analyze_incident(self, metrics: Dict, pattern: str = "") -> Dict:
57
  return {
58
  "status": "analysis_complete",
@@ -62,384 +64,337 @@ except ImportError as e:
62
  "Add circuit breakers",
63
  "Optimize configuration"
64
  ],
65
- "confidence": 0.92,
66
- "pattern_matched": pattern,
67
- "healing_intent": {
68
- "type": "scale_out",
69
- "requires_execution": True
70
- }
71
  }
72
 
73
- # Import our enhanced modules
74
- from core.data_models import (
75
- IncidentDatabase, IncidentScenario, OSSAnalysis,
76
- EnterpriseResults, DemoMode
77
- )
78
- from core.visualizations import EnhancedVisualizationEngine
79
- from core.calculators import EnhancedROICalculator
80
- from demo.orchestrator import DemoOrchestrator
81
- from ui.components import (
82
- create_metric_card,
83
- create_business_impact_section,
84
- create_approval_workflow,
85
- create_roi_comparison_table
86
- )
87
- from ui.styles import CUSTOM_CSS, THEME
88
-
89
  # Configure logging
90
- logging.basicConfig(
91
- level=logging.INFO,
92
- format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
93
- )
94
  logger = logging.getLogger(__name__)
95
 
96
  # ===========================================
97
- # ARF OSS INTEGRATION SERVICE
98
  # ===========================================
99
 
100
- class ARFOSSService:
101
- """Service to integrate with actual ARF OSS package"""
102
-
103
- def __init__(self):
104
- self.oss_client = OSSMCPClient() if ARF_OSS_AVAILABLE else OSSMCPClient()
105
- self.healing_intents = {}
106
-
107
- def analyze_with_arf(self, scenario: IncidentScenario) -> Dict:
108
- """Analyze incident using actual ARF OSS"""
109
- try:
110
- # Convert scenario metrics to ARF format
111
- arf_metrics = self._convert_to_arf_metrics(scenario.metrics)
112
-
113
- # Call actual ARF OSS analysis
114
- analysis_result = self.oss_client.analyze_incident(
115
- metrics=arf_metrics,
116
- pattern=scenario.arf_pattern
117
- )
118
-
119
- # Create healing intent
120
- healing_intent = create_scale_out_intent(
121
- resource_type=self._get_resource_type(scenario.name),
122
- scale_factor=2.0
123
- )
124
-
125
- # Store healing intent for reference
126
- intent_id = str(uuid.uuid4())[:8]
127
- self.healing_intents[intent_id] = {
128
- "intent": healing_intent,
129
- "scenario": scenario.name,
130
- "timestamp": datetime.now()
131
- }
132
-
133
- # Format response
134
- return {
135
- "analysis": " ARF OSS Analysis Complete",
136
- "recommendations": analysis_result.get("recommendations", [
137
- "Implement ARF recommendations",
138
- "Monitor system metrics",
139
- "Apply configuration changes"
140
- ]),
141
- "healing_intent": healing_intent.to_dict(),
142
- "intent_id": intent_id,
143
- "arf_oss_version": "3.3.6",
144
- "mode": "advisory_only",
145
- "requires_execution": True,
146
- "estimated_time": "45-90 minutes",
147
- "engineers_needed": "2-3 engineers"
148
- }
149
-
150
- except Exception as e:
151
- logger.error(f"ARF analysis error: {e}")
152
- return {
153
- "analysis": "⚠️ ARF Analysis (Simulation Mode)",
154
- "recommendations": [
155
- "Increase cache memory allocation",
156
- "Implement cache warming strategy",
157
- "Optimize key patterns",
158
- "Add circuit breaker"
159
- ],
160
- "arf_oss_available": ARF_OSS_AVAILABLE,
161
- "error": str(e) if not ARF_OSS_AVAILABLE else None
162
  }
163
-
164
- def _convert_to_arf_metrics(self, metrics: Dict[str, str]) -> Dict[str, float]:
165
- """Convert demo metrics to ARF-compatible format"""
166
- arf_metrics = {}
167
- for key, value in metrics.items():
168
- try:
169
- # Extract numeric value from string like "18.5% (Critical)"
170
- if isinstance(value, str):
171
- # Get first number in string
172
- import re
173
- numbers = re.findall(r"[-+]?\d*\.\d+|\d+", value)
174
- if numbers:
175
- arf_metrics[key] = float(numbers[0])
176
- else:
177
- arf_metrics[key] = 0.0
178
- else:
179
- arf_metrics[key] = float(value)
180
- except:
181
- arf_metrics[key] = 0.0
182
- return arf_metrics
183
-
184
- def _get_resource_type(self, scenario_name: str) -> str:
185
- """Map scenario to resource type"""
186
- if "Cache" in scenario_name:
187
- return "cache"
188
- elif "Database" in scenario_name:
189
- return "database"
190
- elif "Memory" in scenario_name:
191
- return "memory"
192
- elif "API" in scenario_name:
193
- return "api_gateway"
194
- else:
195
- return "service"
196
 
197
  # ===========================================
198
- # APPLICATION STATE WITH ARF INTEGRATION
199
  # ===========================================
200
 
201
- class ARFDemoState:
202
- """Maintain application state with ARF integration"""
 
203
 
204
- def __init__(self):
205
- self.scenario_db = IncidentDatabase()
206
- self.viz_engine = EnhancedVisualizationEngine()
207
- self.roi_calculator = EnhancedROICalculator()
208
- self.demo_orchestrator = DemoOrchestrator(DemoMode.INVESTOR)
209
- self.arf_service = ARFOSSService()
210
-
211
- self.current_scenario = None
212
- self.approval_required = True
213
- self.arf_analysis_results = {}
214
-
215
- def get_scenario(self, name: str) -> Optional[IncidentScenario]:
216
- """Get scenario by name"""
217
- scenarios = self.scenario_db.get_scenarios()
218
- return scenarios.get(name)
219
 
220
- def get_scenario_names(self) -> List[str]:
221
- """Get all scenario names"""
222
- scenarios = self.scenario_db.get_scenarios()
223
- return list(scenarios.keys())
224
 
225
- def perform_arf_analysis(self, scenario_name: str) -> Dict:
226
- """Perform actual ARF OSS analysis"""
227
- scenario = self.get_scenario(scenario_name)
228
- if not scenario:
229
- return {"error": "Scenario not found"}
230
-
231
- self.current_scenario = scenario
232
- analysis_result = self.arf_service.analyze_with_arf(scenario)
233
- self.arf_analysis_results[scenario_name] = analysis_result
234
-
235
- # Format for display
236
- return {
237
- "status": analysis_result["analysis"],
238
- "recommendations": analysis_result["recommendations"],
239
- "healing_intent": analysis_result.get("healing_intent", {}),
240
- "arf_oss": {
241
- "version": analysis_result.get("arf_oss_version", "3.3.6"),
242
- "available": ARF_OSS_AVAILABLE,
243
- "mode": "advisory_only"
244
- },
245
- "estimated_impact": analysis_result.get("estimated_time", "45-90 minutes"),
246
- "action_required": "Manual implementation required",
247
- "team_effort": analysis_result.get("engineers_needed", "2-3 engineers"),
248
- "total_cost": self._calculate_oss_cost(scenario)
249
- }
250
 
251
- def _calculate_oss_cost(self, scenario: IncidentScenario) -> str:
252
- """Calculate OSS implementation cost"""
253
- impact = scenario.impact
254
- if "Revenue Loss" in impact:
255
- loss = impact["Revenue Loss"]
256
- # Extract hourly rate
257
- try:
258
- hourly_rate = float(''.join(filter(str.isdigit, loss.split('/')[0])))
259
- # Assume 60 minutes resolution for OSS
260
- return f"${hourly_rate:,.0f}"
261
- except:
262
- pass
263
- return "$3,000 - $8,000"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264
 
265
  # ===========================================
266
- # EVENT HANDLERS WITH ARF INTEGRATION
267
  # ===========================================
268
 
269
- class EventHandlers:
270
- """Handle all application events with ARF integration"""
 
 
271
 
272
- def __init__(self, state: ARFDemoState):
273
- self.state = state
 
 
 
 
 
 
 
 
 
 
 
 
274
 
275
- def handle_scenario_change(self, scenario_name: str, viz_type: str) -> tuple:
276
- """Handle scenario change"""
277
- scenario = self.state.get_scenario(scenario_name)
278
- if not scenario:
279
- return {}, {}, self.state.viz_engine.create_interactive_timeline(None)
280
-
281
- self.state.current_scenario = scenario
282
-
283
- # Create visualization
284
- if viz_type == "Interactive Timeline":
285
- viz = self.state.viz_engine.create_interactive_timeline(scenario)
286
- else:
287
- viz = self.state.viz_engine.create_executive_dashboard()
288
-
289
- return scenario.metrics, scenario.impact, viz
290
 
291
- def handle_oss_analysis(self, scenario_name: str) -> Dict:
292
- """Handle OSS analysis using actual ARF"""
293
- logger.info(f"Performing ARF OSS analysis for: {scenario_name}")
294
-
295
- # Use actual ARF OSS package
296
- result = self.state.perform_arf_analysis(scenario_name)
297
-
298
- # Add ARF branding
299
- result["arf_oss_edition"] = {
300
- "version": "3.3.6",
301
- "license": "Apache 2.0",
302
- "mode": "advisory_only",
303
- "execution": "manual_required",
304
- "healing_intent_created": "healing_intent" in result
305
- }
306
-
307
- return result
308
 
309
- def handle_enterprise_execution(self, scenario_name: str,
310
- approval_required: bool) -> tuple:
311
- """Handle enterprise execution (simulated for demo)"""
312
- self.state.approval_required = approval_required
313
-
314
- scenario = self.state.get_scenario(scenario_name)
315
- if not scenario:
316
- # Default results
317
- results = {
318
- "status": "❌ Scenario not found",
319
- "actions_completed": [],
320
- "metrics_improvement": {},
321
- "business_impact": {}
322
- }
323
- else:
324
- # Use enterprise results if available, otherwise simulate
325
- if scenario.enterprise_results:
326
- results = scenario.enterprise_results.to_dict()
327
- else:
328
- results = self._simulate_enterprise_execution(scenario)
329
-
330
- # Update status based on approval
331
- if approval_required:
332
- results["status"] = "✅ Approved and Executed"
333
- results["approval_workflow"] = {
334
- "required": True,
335
- "approved_by": "demo_user",
336
- "timestamp": datetime.now().isoformat()
337
- }
338
- else:
339
- results["status"] = "✅ Auto-Executed"
340
- results["approval_workflow"] = {
341
- "required": False,
342
- "mode": "autonomous",
343
- "safety_guardrails": "active"
344
  }
345
-
346
- # Add ARF Enterprise context
347
- results["arf_enterprise"] = {
348
- "execution_complete": True,
349
- "learning_applied": True,
350
- "audit_trail_created": True,
351
- "compliance_mode": "strict",
352
- "roi_measured": True
353
  }
354
-
355
- # Create approval workflow display
356
- approval_display = create_approval_workflow(approval_required)
357
-
358
- # Configuration
359
- config = {
360
- "approval_required": approval_required,
361
- "compliance_mode": "strict",
362
- "arf_enterprise": True,
363
- "safety_mode": "guardrails_active"
364
- }
365
-
366
- return approval_display, config, results
367
 
368
- def _simulate_enterprise_execution(self, scenario: IncidentScenario) -> Dict:
369
- """Simulate enterprise execution for demo"""
370
- actions = [
371
- "✅ Auto-scaled resources based on ARF healing intent",
372
- "✅ Implemented optimization recommendations",
373
- "✅ Deployed monitoring and alerting",
374
- "✅ Validated recovery with automated testing",
375
- "Updated RAG graph memory with learnings"
376
- ]
377
-
378
- # Calculate improvements based on scenario
379
- improvements = {}
380
- for metric, value in scenario.metrics.items():
381
- if "%" in value or any(x in metric.lower() for x in ['rate', 'load', 'time']):
382
- try:
383
- current = float(''.join(filter(lambda x: x.isdigit() or x == '.', value.split()[0])))
384
- if current < 50: # Low metrics (like cache hit rate)
385
- improved = min(100, current * random.uniform(2.5, 4.0))
386
- else: # High metrics (like database load)
387
- improved = max(0, current * random.uniform(0.3, 0.6))
388
-
389
- if "%" in value:
390
- improvements[metric] = f"{current:.1f}% → {improved:.1f}%"
391
- elif "ms" in metric.lower():
392
- improvements[metric] = f"{current:.0f}ms → {improved:.0f}ms"
393
- else:
394
- improvements[metric] = f"{current:.0f} → {improved:.0f}"
395
- except:
396
- improvements[metric] = f"{value} → Improved"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
397
 
398
  return {
399
- "actions_completed": actions,
400
- "metrics_improvement": improvements,
401
- "business_impact": {
402
- "Recovery Time": f"60 min → {random.randint(5, 15)} min",
403
- "Cost Saved": f"${random.randint(2000, 10000):,}",
404
- "Users Impacted": "45,000 0",
405
- "Revenue Protected": f"${random.randint(1000, 5000):,}",
406
- "MTTR Improvement": f"{random.randint(75, 90)}% reduction"
407
  }
408
  }
409
-
410
- def handle_roi_calculation(self, monthly_incidents: int,
411
- avg_impact: int, team_size: int) -> Dict:
412
- """Handle ROI calculation"""
413
- try:
414
- return self.state.roi_calculator.calculate_comprehensive_roi(
415
- monthly_incidents, avg_impact, team_size
416
- )
417
- except Exception as e:
418
- logger.error(f"ROI calculation error: {e}")
419
- return {"error": "Calculation failed"}
420
-
421
- def handle_next_demo_step(self) -> Dict:
422
- """Get next demo step guidance"""
423
- return self.state.demo_orchestrator.get_next_guidance()
424
 
425
  # ===========================================
426
  # MAIN INTERFACE
427
  # ===========================================
428
 
429
- def create_main_interface():
430
- """Create the main Gradio interface"""
431
 
432
- state = ARFDemoState()
433
- handlers = EventHandlers(state)
 
 
434
 
435
  with gr.Blocks(
436
  title="🚀 ARF Investor Demo v3.6.0",
437
- theme=THEME,
438
- css=CUSTOM_CSS
439
  ) as demo:
440
 
441
- # ============ HEADER WITH ARF VERSION ============
442
- arf_status = "✅ ARF OSS v3.3.6" if ARF_OSS_AVAILABLE else "⚠️ ARF Simulation Mode"
443
 
444
  gr.Markdown(f"""
445
  # 🚀 Agentic Reliability Framework - Investor Demo v3.6.0
@@ -450,134 +405,71 @@ def create_main_interface():
450
  </div>
451
  """)
452
 
453
- # ============ ARF STATUS BADGE ============
454
- if ARF_OSS_AVAILABLE:
455
- gr.Markdown("""
456
- <div style='
457
- background: linear-gradient(135deg, #4ECDC4 0%, #44A08D 100%);
458
- color: white;
459
- padding: 10px 20px;
460
- border-radius: 20px;
461
- display: inline-block;
462
- margin: 10px 0;
463
- font-weight: bold;
464
- '>
465
- ✅ Connected to ARF OSS v3.3.6
466
- </div>
467
- """)
468
-
469
- # ============ PRESENTER GUIDANCE ============
470
- gr.Markdown("### 🎯 Presenter Guidance")
471
- with gr.Row():
472
- next_step_btn = gr.Button("🎬 Next Demo Step", variant="secondary")
473
- quick_demo_btn = gr.Button("⚡ Quick Demo Mode", variant="secondary", size="sm")
474
-
475
- guidance_display = gr.HTML(
476
- value="<div class='presenter-guidance'>Click 'Next Demo Step' for guidance</div>"
477
- )
478
-
479
  # ============ MAIN TABS ============
480
  with gr.Tabs():
481
 
482
  # TAB 1: LIVE INCIDENT DEMO
483
- with gr.TabItem("🔥 Live Incident Demo", id="live-demo"):
484
  with gr.Row():
485
- # Left Panel - Incident Details
486
  with gr.Column(scale=1):
487
  gr.Markdown("### 🎬 Incident Scenario")
488
  scenario_dropdown = gr.Dropdown(
489
- choices=state.get_scenario_names(),
490
  value="Cache Miss Storm",
491
- label="Select critical incident:",
492
- interactive=True
493
  )
494
 
495
  gr.Markdown("### 📊 Current Crisis Metrics")
496
  metrics_display = gr.JSON(
497
- value=state.get_scenario("Cache Miss Storm").metrics,
498
- label="Live Metrics"
499
  )
500
 
501
  gr.Markdown("### 💰 Business Impact")
502
  impact_display = gr.JSON(
503
- value=state.get_scenario("Cache Miss Storm").impact,
504
- label="Impact Analysis"
505
  )
506
 
507
- # Right Panel - Visualization & Actions
508
  with gr.Column(scale=2):
509
- # Visualization Selector
510
- gr.Markdown("### 📈 Incident Visualization")
511
- viz_radio = gr.Radio(
512
- choices=["Interactive Timeline", "Executive Dashboard"],
513
- value="Interactive Timeline",
514
- label="Choose visualization:"
515
- )
516
-
517
- # Visualization Output
518
- timeline_output = gr.Plot(
519
- label="Visualization",
520
- show_label=False
521
- )
522
 
523
- # Action Section with ARF context
524
- gr.Markdown("### 🤖 ARF Analysis & Execution")
525
  with gr.Row():
526
- oss_btn = gr.Button("🆓 Run ARF OSS Analysis", variant="secondary")
527
  enterprise_btn = gr.Button("🚀 Execute Enterprise Healing", variant="primary")
528
 
529
- # Approval Controls
530
- with gr.Row():
531
- approval_toggle = gr.Checkbox(
532
- label="🔐 Require Manual Approval",
533
- value=True,
534
- info="Toggle to show approval workflow vs auto-execution"
535
- )
536
-
537
- # ARF Context Information
538
- if ARF_OSS_AVAILABLE:
539
- gr.Markdown("""
540
- <div style='
541
- background: rgba(78, 205, 196, 0.1);
542
- padding: 10px;
543
- border-radius: 8px;
544
- border-left: 4px solid #4ECDC4;
545
- margin: 10px 0;
546
- font-size: 14px;
547
- '>
548
- <b>ARF OSS v3.3.6 Active</b><br>
549
- • Advisory healing intent creation<br>
550
- • RAG graph memory for pattern recall<br>
551
- • MCP safety layer (advisory mode)<br>
552
- • Apache 2.0 licensed
553
- </div>
554
- """)
555
 
556
- # Approval Workflow Display
557
- approval_display = gr.HTML()
 
 
558
 
559
  # Configuration
560
  config_display = gr.JSON(
561
  label="⚙️ Enterprise Configuration",
562
- value={
563
- "approval_required": True,
564
- "compliance_mode": "strict",
565
- "arf_enterprise": True,
566
- "safety_guardrails": "active"
567
- }
568
  )
569
 
570
  # Results
571
  results_display = gr.JSON(
572
  label="🎯 Execution Results",
573
- value={"status": "Ready for ARF analysis..."}
574
  )
575
 
576
  # TAB 2: BUSINESS IMPACT & ROI
577
- with gr.TabItem("💰 Business Impact & ROI", id="business-roi"):
578
  with gr.Column():
579
  # Business Dashboard
580
- gr.Markdown("### 📊 Executive Business Dashboard")
581
  dashboard_output = gr.Plot()
582
 
583
  # ROI Calculator
@@ -590,7 +482,7 @@ def create_main_interface():
590
  )
591
  impact_slider = gr.Slider(
592
  1000, 50000, value=8500, step=500,
593
- label="Average incident impact ($)"
594
  )
595
  team_slider = gr.Slider(
596
  1, 20, value=5, step=1,
@@ -601,200 +493,113 @@ def create_main_interface():
601
  with gr.Column(scale=2):
602
  roi_output = gr.JSON(
603
  label="Your ROI Analysis",
604
- value={"status": "Adjust sliders and click Calculate"}
605
  )
606
 
607
- # ARF ROI Context
608
- gr.Markdown("""
609
- <div style='
610
- background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
611
- padding: 20px;
612
- border-radius: 10px;
613
- margin: 20px 0;
614
- '>
615
- <h4 style='margin: 0 0 15px 0;'>📈 ARF ROI Measurement (Enterprise)</h4>
616
- <div style='display: grid; grid-template-columns: 1fr 1fr; gap: 15px;'>
617
- <div>
618
- <div style='font-size: 24px; color: #4ECDC4;'>5.2×</div>
619
- <div style='font-size: 12px; color: #666;'>Average ROI</div>
620
- </div>
621
- <div>
622
- <div style='font-size: 24px; color: #4ECDC4;'>2-3 mo</div>
623
- <div style='font-size: 12px; color: #666;'>Payback Period</div>
624
- </div>
625
- <div>
626
- <div style='font-size: 24px; color: #4ECDC4;'>81.7%</div>
627
- <div style='font-size: 12px; color: #666;'>Auto-Heal Rate</div>
628
- </div>
629
- <div>
630
- <div style='font-size: 24px; color: #4ECDC4;'>85%</div>
631
- <div style='font-size: 12px; color: #666;'>MTTR Reduction</div>
632
- </div>
633
- </div>
634
- </div>
635
- """)
636
-
637
  # Capability Comparison
638
- comparison_table = create_roi_comparison_table()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
639
 
640
  # ============ FOOTER ============
641
  gr.Markdown("---")
642
  with gr.Row():
643
  with gr.Column(scale=2):
644
- arf_links = """
645
- **📦 ARF OSS v3.3.6**
646
- <div style='margin-top: 10px;'>
647
- 📚 <b>PyPI:</b> <a href='https://pypi.org/project/agentic-reliability-framework/' target='_blank'>agentic-reliability-framework</a><br>
648
- 💻 <b>GitHub:</b> <a href='https://github.com/petterjuan/agentic-reliability-framework' target='_blank'>petterjuan/agentic-reliability-framework</a><br>
649
- 📄 <b>License:</b> Apache 2.0
650
- </div>
651
- """
652
-
653
- contact_info = """
654
- **📞 Contact & Enterprise**
655
- <div style='margin-top: 10px;'>
656
- 📧 <b>Email:</b> enterprise@arf.dev<br>
657
- 🌐 <b>Website:</b> <a href='https://arf.dev' target='_blank'>https://arf.dev</a><br>
658
- 📚 <b>Docs:</b> <a href='https://docs.arf.dev' target='_blank'>https://docs.arf.dev</a>
659
- </div>
660
- """
661
-
662
- gr.Markdown(f"""
663
- <div style='display: grid; grid-template-columns: 1fr 1fr; gap: 40px;'>
664
- <div>{arf_links}</div>
665
- <div>{contact_info}</div>
666
- </div>
667
  """)
668
-
669
  with gr.Column(scale=1):
670
  gr.Markdown("""
671
- **🎯 Schedule a Demo**
672
- <div style='margin-top: 10px;'>
673
- <a href='https://arf.dev/demo' target='_blank' style='
674
- display: inline-block;
675
- background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
676
- color: white;
677
- padding: 12px 24px;
678
- border-radius: 8px;
679
- text-decoration: none;
680
- font-weight: bold;
681
- text-align: center;
682
- '>Schedule Enterprise Demo →</a>
683
- </div>
684
  """)
685
 
686
  # ============ EVENT HANDLERS ============
687
 
688
- # Scenario changes
689
- scenario_dropdown.change(
690
- handlers.handle_scenario_change,
691
- inputs=[scenario_dropdown, viz_radio],
692
- outputs=[metrics_display, impact_display, timeline_output]
693
- )
 
 
694
 
695
- viz_radio.change(
696
- handlers.handle_scenario_change,
697
- inputs=[scenario_dropdown, viz_radio],
 
698
  outputs=[metrics_display, impact_display, timeline_output]
699
  )
700
 
701
- # OSS Analysis (using actual ARF)
702
  oss_btn.click(
703
- handlers.handle_oss_analysis,
704
  inputs=[scenario_dropdown],
705
  outputs=[results_display]
706
  )
707
 
708
  # Enterprise Execution
709
  enterprise_btn.click(
710
- handlers.handle_enterprise_execution,
711
  inputs=[scenario_dropdown, approval_toggle],
712
  outputs=[approval_display, config_display, results_display]
713
  )
714
 
715
  # Approval toggle updates config
716
  approval_toggle.change(
717
- lambda approval: {
718
- "approval_required": approval,
719
- "compliance_mode": "strict",
720
- "arf_enterprise": True,
721
- "safety_guardrails": "active"
722
- },
723
  inputs=[approval_toggle],
724
  outputs=[config_display]
725
  )
726
 
727
  # ROI Calculation
728
  calculate_btn.click(
729
- handlers.handle_roi_calculation,
730
  inputs=[monthly_slider, impact_slider, team_slider],
731
  outputs=[roi_output]
732
  )
733
 
734
- # Next demo step guidance
735
- next_step_btn.click(
736
- handlers.handle_next_demo_step,
737
- outputs=[guidance_display]
738
- )
739
-
740
- # Quick demo button - runs OSS analysis automatically
741
- quick_demo_btn.click(
742
- lambda scenario: handlers.handle_oss_analysis(scenario),
743
- inputs=[scenario_dropdown],
744
- outputs=[results_display]
745
- )
746
-
747
  # ============ INITIAL LOAD ============
748
-
749
- def load_initial_state():
750
- """Load initial visualizations and data"""
751
- # Get initial scenario
752
- scenario = state.get_scenario("Cache Miss Storm")
753
-
754
- # Create visualizations
755
- timeline_viz = state.viz_engine.create_interactive_timeline(scenario)
756
- dashboard_viz = state.viz_engine.create_executive_dashboard()
757
-
758
- # Get initial guidance
759
- guidance = state.demo_orchestrator.get_next_guidance()
760
-
761
- # Add ARF status
762
- arf_status_html = ""
763
- if ARF_OSS_AVAILABLE:
764
- arf_status_html = """
765
- <div style='
766
- background: rgba(78, 205, 196, 0.1);
767
- padding: 10px;
768
- border-radius: 8px;
769
- border-left: 4px solid #4ECDC4;
770
- margin: 10px 0;
771
- '>
772
- ✅ <b>ARF OSS v3.3.6 Loaded</b> - Real framework analysis available
773
- </div>
774
- """
775
-
776
  return (
777
- scenario.metrics if scenario else {},
778
- scenario.impact if scenario else {},
779
- timeline_viz,
780
- dashboard_viz,
781
- arf_status_html + guidance["html"]
782
  )
783
 
784
  demo.load(
785
- load_initial_state,
786
- outputs=[
787
- metrics_display,
788
- impact_display,
789
- timeline_output,
790
- dashboard_output,
791
- guidance_display
792
- ]
793
  )
794
 
795
  # ============ INSTRUCTIONS ============
796
  gr.Markdown(f"""
797
- <div class='footer'>
798
  🚀 <b>ARF Ultimate Investor Demo v3.6.0</b> | {'✅ Integrated with ARF OSS v3.3.6' if ARF_OSS_AVAILABLE else '⚠️ Running in simulation mode'}
799
  <i>From Cost Center to Profit Engine: 5.2× ROI with Autonomous Reliability</i>
800
  </div>
@@ -803,27 +608,21 @@ def create_main_interface():
803
  return demo
804
 
805
  # ===========================================
806
- # APPLICATION ENTRY POINT
807
  # ===========================================
808
 
809
- def main():
810
- """Main entry point"""
811
  logger.info("=" * 80)
812
  logger.info("🚀 Launching ARF Investor Demo v3.6.0")
813
  logger.info(f"✅ ARF OSS Available: {ARF_OSS_AVAILABLE}")
814
- logger.info("✅ Integrated with actual ARF OSS package")
815
- logger.info("✅ Best practices applied")
816
- logger.info("✅ Investor-grade UX")
817
  logger.info("=" * 80)
818
 
819
- demo = create_main_interface()
820
  demo.launch(
821
  server_name="0.0.0.0",
822
  server_port=7860,
823
  share=False,
824
  debug=False,
825
  show_error=True
826
- )
827
-
828
- if __name__ == "__main__":
829
- main()
 
1
  """
2
+ 🚀 ARF Investor Demo - COMPLETE STANDALONE VERSION
3
+ No module dependencies - Everything in one file
4
+ Works on Hugging Face Spaces
5
  """
6
 
7
  import logging
8
+ import datetime
9
  import random
10
+ import uuid
11
+ from typing import Dict, List, Optional, Any
12
  import gradio as gr
13
+ import plotly.graph_objects as go
14
+ import plotly.express as px
15
+ import pandas as pd
16
+ import numpy as np
17
+ from plotly.subplots import make_subplots
18
 
19
+ # Import ARF OSS if available
20
  try:
21
  from agentic_reliability_framework.arf_core.models.healing_intent import (
22
  HealingIntent,
 
31
  logger = logging.getLogger(__name__)
32
  logger.warning(f"⚠️ ARF OSS not available: {e}. Running in simulation mode.")
33
 
34
+ # Mock classes
35
  class HealingIntent:
36
  def __init__(self, **kwargs):
37
  self.intent_type = kwargs.get("intent_type", "scale_out")
 
41
  return {
42
  "intent_type": self.intent_type,
43
  "parameters": self.parameters,
44
+ "created_at": datetime.datetime.now().isoformat()
45
  }
46
 
47
  def create_scale_out_intent(resource_type: str, scale_factor: float = 2.0):
 
55
  )
56
 
57
  class OSSMCPClient:
 
 
 
58
  def analyze_incident(self, metrics: Dict, pattern: str = "") -> Dict:
59
  return {
60
  "status": "analysis_complete",
 
64
  "Add circuit breakers",
65
  "Optimize configuration"
66
  ],
67
+ "confidence": 0.92
 
 
 
 
 
68
  }
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  # Configure logging
71
+ logging.basicConfig(level=logging.INFO)
 
 
 
72
  logger = logging.getLogger(__name__)
73
 
74
  # ===========================================
75
+ # DATA - Everything in one place
76
  # ===========================================
77
 
78
+ INCIDENT_SCENARIOS = {
79
+ "Cache Miss Storm": {
80
+ "metrics": {
81
+ "Cache Hit Rate": "18.5% (Critical)",
82
+ "Database Load": "92% (Overloaded)",
83
+ "Response Time": "1850ms (Slow)",
84
+ "Affected Users": "45,000"
85
+ },
86
+ "impact": {
87
+ "Revenue Loss": "$8,500/hour",
88
+ "Page Load Time": "+300%",
89
+ "Users Impacted": "45,000"
90
+ },
91
+ "oss_analysis": {
92
+ "status": "✅ ARF OSS Analysis Complete",
93
+ "recommendations": [
94
+ "Increase Redis cache memory allocation",
95
+ "Implement cache warming strategy",
96
+ "Optimize key patterns (TTL adjustments)",
97
+ "Add circuit breaker for database fallback"
98
+ ],
99
+ "estimated_time": "60+ minutes",
100
+ "engineers_needed": "2-3 SREs",
101
+ "manual_effort": "High",
102
+ "arf_oss": True,
103
+ "healing_intent_created": True
104
+ },
105
+ "enterprise_results": {
106
+ "actions_completed": [
107
+ "✅ Auto-scaled Redis: 4GB → 8GB",
108
+ " Deployed cache warming service",
109
+ "✅ Optimized 12 key patterns",
110
+ "✅ Implemented circuit breaker"
111
+ ],
112
+ "metrics_improvement": {
113
+ "Cache Hit Rate": "18.5% 72%",
114
+ "Response Time": "1850ms → 450ms",
115
+ "Database Load": "92% → 45%"
116
+ },
117
+ "business_impact": {
118
+ "Recovery Time": "60 min → 12 min",
119
+ "Cost Saved": "$7,200",
120
+ "Users Impacted": "45,000 → 0"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  }
122
+ }
123
+ },
124
+ "Database Connection Pool Exhaustion": {
125
+ "metrics": {
126
+ "Active Connections": "98/100 (Critical)",
127
+ "API Latency": "2450ms",
128
+ "Error Rate": "15.2%",
129
+ "Queue Depth": "1250"
130
+ },
131
+ "impact": {
132
+ "Revenue Loss": "$4,200/hour",
133
+ "Affected Services": "API Gateway, User Service",
134
+ "SLA Violation": "Yes"
135
+ }
136
+ },
137
+ "Memory Leak in Production": {
138
+ "metrics": {
139
+ "Memory Usage": "96% (Critical)",
140
+ "GC Pause Time": "4500ms",
141
+ "Error Rate": "28.5%",
142
+ "Restart Frequency": "12/hour"
143
+ },
144
+ "impact": {
145
+ "Revenue Loss": "$5,500/hour",
146
+ "Session Loss": "8,500 users",
147
+ "Customer Impact": "High"
148
+ }
149
+ }
150
+ }
 
 
 
 
151
 
152
  # ===========================================
153
+ # VISUALIZATION FUNCTIONS
154
  # ===========================================
155
 
156
+ def create_timeline_visualization():
157
+ """Create interactive timeline"""
158
+ fig = go.Figure()
159
 
160
+ events = [
161
+ {"time": "T-5m", "event": "📉 Cache hit rate drops", "type": "problem"},
162
+ {"time": "T-3m", "event": "🤖 ARF detects pattern", "type": "detection"},
163
+ {"time": "T-2m", "event": "🧠 Analysis complete", "type": "analysis"},
164
+ {"time": "T-1m", "event": "⚡ Healing executed", "type": "action"},
165
+ {"time": "Now", "event": "✅ System recovered", "type": "recovery"}
166
+ ]
 
 
 
 
 
 
 
 
167
 
168
+ colors = {"problem": "red", "detection": "blue", "analysis": "purple",
169
+ "action": "green", "recovery": "lightgreen"}
 
 
170
 
171
+ for event in events:
172
+ fig.add_trace(go.Scatter(
173
+ x=[event["time"]],
174
+ y=[1],
175
+ mode='markers+text',
176
+ marker=dict(size=15, color=colors[event["type"]], symbol='circle'),
177
+ text=[event["event"]],
178
+ textposition="top center",
179
+ name=event["type"].capitalize()
180
+ ))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
 
182
+ fig.update_layout(
183
+ title="<b>Incident Timeline</b>",
184
+ height=400,
185
+ showlegend=True,
186
+ paper_bgcolor='rgba(0,0,0,0)',
187
+ plot_bgcolor='rgba(0,0,0,0)',
188
+ yaxis=dict(showticklabels=False, range=[0.5, 1.5])
189
+ )
190
+
191
+ return fig
192
+
193
+ def create_business_dashboard():
194
+ """Create executive dashboard"""
195
+ fig = make_subplots(
196
+ rows=2, cols=2,
197
+ subplot_titles=('Cost Impact', 'Team Time', 'MTTR Comparison', 'ROI'),
198
+ vertical_spacing=0.15
199
+ )
200
+
201
+ # 1. Cost Impact
202
+ categories = ['Without ARF', 'With ARF Enterprise', 'Savings']
203
+ values = [2.96, 1.0, 1.96]
204
+
205
+ fig.add_trace(
206
+ go.Bar(x=categories, y=values, marker_color=['#FF6B6B', '#4ECDC4', '#45B7D1']),
207
+ row=1, col=1
208
+ )
209
+
210
+ # 2. Team Time
211
+ activities = ['Firefighting', 'Innovation', 'Strategic']
212
+ before = [60, 20, 20]
213
+ after = [10, 60, 30]
214
+
215
+ fig.add_trace(go.Bar(x=activities, y=before, name='Before', marker_color='#FF6B6B'), row=1, col=2)
216
+ fig.add_trace(go.Bar(x=activities, y=after, name='After', marker_color='#4ECDC4'), row=1, col=2)
217
+
218
+ # 3. MTTR Comparison
219
+ mttr_methods = ['Manual', 'Traditional', 'ARF OSS', 'ARF Enterprise']
220
+ mttr_times = [120, 45, 25, 8]
221
+
222
+ fig.add_trace(
223
+ go.Bar(x=mttr_methods, y=mttr_times, marker_color=['#FF6B6B', '#FFE66D', '#45B7D1', '#4ECDC4']),
224
+ row=2, col=1
225
+ )
226
+
227
+ # 4. ROI Gauge
228
+ fig.add_trace(
229
+ go.Indicator(
230
+ mode="gauge+number",
231
+ value=5.2,
232
+ title={'text': "ROI Multiplier"},
233
+ gauge={
234
+ 'axis': {'range': [0, 10]},
235
+ 'bar': {'color': "#4ECDC4"},
236
+ 'steps': [
237
+ {'range': [0, 2], 'color': "lightgray"},
238
+ {'range': [2, 4], 'color': "gray"},
239
+ {'range': [4, 6], 'color': "lightgreen"},
240
+ {'range': [6, 10], 'color': "green"}
241
+ ]
242
+ }
243
+ ),
244
+ row=2, col=2
245
+ )
246
+
247
+ fig.update_layout(
248
+ height=700,
249
+ showlegend=True,
250
+ paper_bgcolor='rgba(0,0,0,0)',
251
+ plot_bgcolor='rgba(0,0,0,0)',
252
+ title_text="<b>Executive Business Dashboard</b>"
253
+ )
254
+
255
+ return fig
256
 
257
  # ===========================================
258
+ # BUSINESS LOGIC
259
  # ===========================================
260
 
261
+ def run_oss_analysis(scenario_name: str):
262
+ """Run OSS analysis"""
263
+ scenario = INCIDENT_SCENARIOS.get(scenario_name, {})
264
+ analysis = scenario.get("oss_analysis", {})
265
 
266
+ if not analysis:
267
+ analysis = {
268
+ "status": "✅ Analysis Complete",
269
+ "recommendations": [
270
+ "Increase resource allocation",
271
+ "Implement monitoring",
272
+ "Add circuit breakers",
273
+ "Optimize configuration"
274
+ ],
275
+ "estimated_time": "45-60 minutes",
276
+ "engineers_needed": "2-3",
277
+ "manual_effort": "Required",
278
+ "arf_oss": ARF_OSS_AVAILABLE
279
+ }
280
 
281
+ # Add ARF context
282
+ analysis["arf_context"] = {
283
+ "oss_available": ARF_OSS_AVAILABLE,
284
+ "version": "3.3.6",
285
+ "mode": "advisory_only",
286
+ "healing_intent": "created" if ARF_OSS_AVAILABLE else "simulated"
287
+ }
 
 
 
 
 
 
 
 
288
 
289
+ return analysis
290
+
291
+ def execute_enterprise_healing(scenario_name: str, approval_required: bool):
292
+ """Execute enterprise healing"""
293
+ scenario = INCIDENT_SCENARIOS.get(scenario_name, {})
294
+ results = scenario.get("enterprise_results", {})
 
 
 
 
 
 
 
 
 
 
 
295
 
296
+ if not results:
297
+ results = {
298
+ "status": " Auto-Executed" if not approval_required else "✅ Approved and Executed",
299
+ "actions_completed": [
300
+ "✅ Auto-scaled resources",
301
+ "✅ Implemented optimization",
302
+ "✅ Deployed monitoring",
303
+ "✅ Validated recovery"
304
+ ],
305
+ "metrics_improvement": {
306
+ "Performance": "Improved",
307
+ "Recovery": "Complete"
308
+ },
309
+ "business_impact": {
310
+ "Cost Saved": f"${random.randint(2000, 8000):,}",
311
+ "Time Saved": f"{random.randint(30, 60)} min → {random.randint(5, 15)} min"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
312
  }
 
 
 
 
 
 
 
 
313
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
314
 
315
+ # Add approval info
316
+ if approval_required:
317
+ approval_html = f"""
318
+ <div style='padding: 15px; background: #f8f9fa; border-radius: 8px; border-left: 4px solid #007bff; margin: 10px 0;'>
319
+ <h4 style='margin: 0 0 10px 0;'>🛡️ Approval Required</h4>
320
+ <p><b>Action:</b> Scale resources for {scenario_name}</p>
321
+ <p><b>Risk:</b> Low (auto-rollback available)</p>
322
+ <p><b>Status:</b> <span style='color: green;'>Approved & Executed</span></p>
323
+ </div>
324
+ """
325
+ else:
326
+ approval_html = f"""
327
+ <div style='padding: 15px; background: #e8f5e8; border-radius: 8px; border-left: 4px solid #28a745; margin: 10px 0;'>
328
+ <h4 style='margin: 0 0 10px 0;'>⚡ Auto-Executed</h4>
329
+ <p><b>Action:</b> Autonomous healing for {scenario_name}</p>
330
+ <p><b>Mode:</b> Fully autonomous (guardrails active)</p>
331
+ <p><b>Status:</b> <span style='color: green;'>Successfully completed</span></p>
332
+ </div>
333
+ """
334
+
335
+ # Add enterprise context
336
+ results["enterprise_context"] = {
337
+ "approval_required": approval_required,
338
+ "compliance_mode": "strict",
339
+ "audit_trail": "created",
340
+ "learning_applied": True,
341
+ "roi_measured": True
342
+ }
343
+
344
+ return approval_html, {"approval_required": approval_required, "compliance_mode": "strict"}, results
345
+
346
+ def calculate_roi(monthly_incidents: int, avg_impact: int, team_size: int):
347
+ """Calculate ROI"""
348
+ try:
349
+ annual_impact = monthly_incidents * 12 * avg_impact
350
+ team_cost = team_size * 150000
351
+ savings = annual_impact * 0.82
352
+
353
+ roi_multiplier = savings / team_cost if team_cost > 0 else 0
354
+
355
+ if roi_multiplier >= 5.0:
356
+ recommendation = "🚀 Excellent fit for ARF Enterprise"
357
+ elif roi_multiplier >= 2.0:
358
+ recommendation = "✅ Good ROI with ARF Enterprise"
359
+ elif roi_multiplier >= 1.0:
360
+ recommendation = "⚠️ Consider ARF OSS edition first"
361
+ else:
362
+ recommendation = "🆓 Start with ARF OSS (free)"
363
 
364
  return {
365
+ "analysis": {
366
+ "your_annual_impact": f"${annual_impact:,.0f}",
367
+ "your_team_cost": f"${team_cost:,.0f}",
368
+ "potential_savings": f"${savings:,.0f}",
369
+ "your_roi_multiplier": f"{roi_multiplier:.1f}×",
370
+ "vs_industry_average": "5.2× average ROI",
371
+ "recommendation": recommendation,
372
+ "payback_period": f"{(team_cost / (savings / 12)):.1f} months" if savings > 0 else "N/A"
373
  }
374
  }
375
+ except Exception as e:
376
+ return {"error": f"Calculation error: {str(e)}"}
 
 
 
 
 
 
 
 
 
 
 
 
 
377
 
378
  # ===========================================
379
  # MAIN INTERFACE
380
  # ===========================================
381
 
382
+ def create_interface():
383
+ """Create the Gradio interface"""
384
 
385
+ custom_css = """
386
+ .gradio-container { max-width: 1200px; margin: auto; }
387
+ h1, h2, h3 { color: #1a365d !important; }
388
+ """
389
 
390
  with gr.Blocks(
391
  title="🚀 ARF Investor Demo v3.6.0",
392
+ theme=gr.themes.Soft(),
393
+ css=custom_css
394
  ) as demo:
395
 
396
+ # ============ HEADER ============
397
+ arf_status = "✅ ARF OSS v3.3.6" if ARF_OSS_AVAILABLE else "⚠️ Simulation Mode"
398
 
399
  gr.Markdown(f"""
400
  # 🚀 Agentic Reliability Framework - Investor Demo v3.6.0
 
405
  </div>
406
  """)
407
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
408
  # ============ MAIN TABS ============
409
  with gr.Tabs():
410
 
411
  # TAB 1: LIVE INCIDENT DEMO
412
+ with gr.TabItem("🔥 Live Incident Demo"):
413
  with gr.Row():
414
+ # Left Panel
415
  with gr.Column(scale=1):
416
  gr.Markdown("### 🎬 Incident Scenario")
417
  scenario_dropdown = gr.Dropdown(
418
+ choices=list(INCIDENT_SCENARIOS.keys()),
419
  value="Cache Miss Storm",
420
+ label="Select critical incident:"
 
421
  )
422
 
423
  gr.Markdown("### 📊 Current Crisis Metrics")
424
  metrics_display = gr.JSON(
425
+ value=INCIDENT_SCENARIOS["Cache Miss Storm"]["metrics"]
 
426
  )
427
 
428
  gr.Markdown("### 💰 Business Impact")
429
  impact_display = gr.JSON(
430
+ value=INCIDENT_SCENARIOS["Cache Miss Storm"]["impact"]
 
431
  )
432
 
433
+ # Right Panel
434
  with gr.Column(scale=2):
435
+ # Visualization
436
+ gr.Markdown("### 📈 Incident Timeline")
437
+ timeline_output = gr.Plot()
 
 
 
 
 
 
 
 
 
 
438
 
439
+ # Action Buttons
 
440
  with gr.Row():
441
+ oss_btn = gr.Button("🆓 Run OSS Analysis", variant="secondary")
442
  enterprise_btn = gr.Button("🚀 Execute Enterprise Healing", variant="primary")
443
 
444
+ # Approval Toggle
445
+ approval_toggle = gr.Checkbox(
446
+ label="🔐 Require Manual Approval",
447
+ value=True,
448
+ info="Toggle to show approval workflow vs auto-execution"
449
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
450
 
451
+ # Approval Display
452
+ approval_display = gr.HTML(
453
+ value="<div style='padding: 10px; background: #f8f9fa; border-radius: 5px;'>Approval status will appear here</div>"
454
+ )
455
 
456
  # Configuration
457
  config_display = gr.JSON(
458
  label="⚙️ Enterprise Configuration",
459
+ value={"approval_required": True, "compliance_mode": "strict"}
 
 
 
 
 
460
  )
461
 
462
  # Results
463
  results_display = gr.JSON(
464
  label="🎯 Execution Results",
465
+ value={"status": "Ready for execution..."}
466
  )
467
 
468
  # TAB 2: BUSINESS IMPACT & ROI
469
+ with gr.TabItem("💰 Business Impact & ROI"):
470
  with gr.Column():
471
  # Business Dashboard
472
+ gr.Markdown("### 📊 Business Health Dashboard")
473
  dashboard_output = gr.Plot()
474
 
475
  # ROI Calculator
 
482
  )
483
  impact_slider = gr.Slider(
484
  1000, 50000, value=8500, step=500,
485
+ label="Avg incident impact ($)"
486
  )
487
  team_slider = gr.Slider(
488
  1, 20, value=5, step=1,
 
493
  with gr.Column(scale=2):
494
  roi_output = gr.JSON(
495
  label="Your ROI Analysis",
496
+ value={"analysis": "Adjust sliders and click 'Calculate My ROI'"}
497
  )
498
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
499
  # Capability Comparison
500
+ gr.Markdown("### 📋 Capability Comparison")
501
+ with gr.Row():
502
+ with gr.Column():
503
+ gr.Markdown("""
504
+ **OSS Edition (Free)**
505
+ - Advisory recommendations only
506
+ - Manual implementation required
507
+ - No auto-healing
508
+ - Community support
509
+ - No ROI measurement
510
+ """)
511
+ with gr.Column():
512
+ gr.Markdown("""
513
+ **Enterprise Edition**
514
+ - Autonomous execution
515
+ - 81.7% auto-heal rate
516
+ - Full audit trails & compliance
517
+ - 24/7 enterprise support
518
+ - 5.2× average ROI
519
+ - 2-3 month payback
520
+ """)
521
 
522
  # ============ FOOTER ============
523
  gr.Markdown("---")
524
  with gr.Row():
525
  with gr.Column(scale=2):
526
+ gr.Markdown("""
527
+ **📞 Contact & Demo**
528
+ 📧 petter2025us@outlook.com
529
+ 🌐 [https://arf.dev](https://arf.dev)
530
+ 📚 [Documentation](https://docs.arf.dev)
531
+ 💻 [GitHub](https://github.com/petterjuan/agentic-reliability-framework)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
532
  """)
 
533
  with gr.Column(scale=1):
534
  gr.Markdown("""
535
+ **🎯 Schedule a Demo**
536
+ (https://calendly.com/petter2025us/30min)
 
 
 
 
 
 
 
 
 
 
 
537
  """)
538
 
539
  # ============ EVENT HANDLERS ============
540
 
541
+ def update_scenario(scenario_name: str):
542
+ """Update when scenario changes"""
543
+ scenario = INCIDENT_SCENARIOS.get(scenario_name, {})
544
+ return (
545
+ scenario.get("metrics", {}),
546
+ scenario.get("impact", {}),
547
+ create_timeline_visualization()
548
+ )
549
 
550
+ # Scenario change
551
+ scenario_dropdown.change(
552
+ update_scenario,
553
+ inputs=[scenario_dropdown],
554
  outputs=[metrics_display, impact_display, timeline_output]
555
  )
556
 
557
+ # OSS Analysis
558
  oss_btn.click(
559
+ run_oss_analysis,
560
  inputs=[scenario_dropdown],
561
  outputs=[results_display]
562
  )
563
 
564
  # Enterprise Execution
565
  enterprise_btn.click(
566
+ execute_enterprise_healing,
567
  inputs=[scenario_dropdown, approval_toggle],
568
  outputs=[approval_display, config_display, results_display]
569
  )
570
 
571
  # Approval toggle updates config
572
  approval_toggle.change(
573
+ lambda approval: {"approval_required": approval, "compliance_mode": "strict"},
 
 
 
 
 
574
  inputs=[approval_toggle],
575
  outputs=[config_display]
576
  )
577
 
578
  # ROI Calculation
579
  calculate_btn.click(
580
+ calculate_roi,
581
  inputs=[monthly_slider, impact_slider, team_slider],
582
  outputs=[roi_output]
583
  )
584
 
 
 
 
 
 
 
 
 
 
 
 
 
 
585
  # ============ INITIAL LOAD ============
586
+ def load_initial():
587
+ """Load initial state"""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
588
  return (
589
+ INCIDENT_SCENARIOS["Cache Miss Storm"]["metrics"],
590
+ INCIDENT_SCENARIOS["Cache Miss Storm"]["impact"],
591
+ create_timeline_visualization(),
592
+ create_business_dashboard()
 
593
  )
594
 
595
  demo.load(
596
+ load_initial,
597
+ outputs=[metrics_display, impact_display, timeline_output, dashboard_output]
 
 
 
 
 
 
598
  )
599
 
600
  # ============ INSTRUCTIONS ============
601
  gr.Markdown(f"""
602
+ <div style='margin-top: 40px; padding-top: 20px; border-top: 1px solid #e2e8f0; color: #718096; font-size: 14px;'>
603
  🚀 <b>ARF Ultimate Investor Demo v3.6.0</b> | {'✅ Integrated with ARF OSS v3.3.6' if ARF_OSS_AVAILABLE else '⚠️ Running in simulation mode'}
604
  <i>From Cost Center to Profit Engine: 5.2× ROI with Autonomous Reliability</i>
605
  </div>
 
608
  return demo
609
 
610
  # ===========================================
611
+ # MAIN
612
  # ===========================================
613
 
614
+ if __name__ == "__main__":
 
615
  logger.info("=" * 80)
616
  logger.info("🚀 Launching ARF Investor Demo v3.6.0")
617
  logger.info(f"✅ ARF OSS Available: {ARF_OSS_AVAILABLE}")
618
+ logger.info("✅ Standalone version - No module dependencies")
 
 
619
  logger.info("=" * 80)
620
 
621
+ demo = create_interface()
622
  demo.launch(
623
  server_name="0.0.0.0",
624
  server_port=7860,
625
  share=False,
626
  debug=False,
627
  show_error=True
628
+ )