| """ |
| Enhanced Demo Guidance System - Manages the psychology and flow of the ARF demo |
| Adds clear narrative phases and boundary awareness |
| """ |
|
|
| from enum import Enum |
| from typing import Dict, List, Any, Optional |
| from dataclasses import dataclass |
| import time |
|
|
| class DemoPhase(Enum): |
| """Phases of the demo narrative with clear boundaries""" |
| INTRODUCTION = "introduction" |
| FAILURE_INJECTION = "failure_injection" |
| REAL_OSS_ANALYSIS = "real_oss_analysis" |
| DECISION_BOUNDARY = "decision_boundary" |
| SIMULATED_ENTERPRISE = "simulated_enterprise" |
| RESOLUTION = "resolution" |
| ARCHITECTURE_REVIEW = "architecture_review" |
|
|
| @dataclass |
| class PhaseContent: |
| """Enhanced content for each demo phase with boundary indicators""" |
| phase: DemoPhase |
| title: str |
| narrative: str |
| key_message: str |
| visual_cue: str |
| duration_seconds: int |
| show_boundary: bool = False |
| boundary_text: Optional[str] = None |
| is_real_arf: bool = False |
| |
| def get_html(self, show_progress: bool = True, current_step: int = 1, total_steps: int = 7) -> str: |
| """Get HTML for this phase with progress indicator""" |
| |
| progress_html = "" |
| if show_progress: |
| progress_percentage = int((current_step / total_steps) * 100) |
| progress_html = f""" |
| <div style="margin-bottom: 20px;"> |
| <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;"> |
| <div style="font-size: 13px; color: #64748b; font-weight: 500;"> |
| Demo Progress: Step {current_step} of {total_steps} |
| </div> |
| <div style="font-size: 13px; color: #3b82f6; font-weight: 600;"> |
| {progress_percentage}% |
| </div> |
| </div> |
| <div style="height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden;"> |
| <div style="width: {progress_percentage}%; height: 100%; |
| background: linear-gradient(90deg, #3b82f6, #8b5cf6); |
| border-radius: 3px; transition: width 0.3s ease;"> |
| </div> |
| </div> |
| </div> |
| """ |
| |
| |
| real_arf_html = "" |
| if self.is_real_arf: |
| real_arf_html = f""" |
| <div style="margin: 15px 0; padding: 10px; background: #f0fdf4; |
| border-radius: 8px; border: 2px solid #10b981;"> |
| <div style="display: flex; align-items: center; gap: 8px;"> |
| <div style="font-size: 20px;">✅</div> |
| <div style="font-weight: 600; color: #065f46;">REAL ARF OSS v3.3.7</div> |
| </div> |
| <div style="font-size: 13px; color: #047857; margin-top: 5px;"> |
| Running actual agentic-reliability-framework==3.3.7 package |
| </div> |
| </div> |
| """ |
| |
| |
| boundary_html = "" |
| if self.show_boundary and self.boundary_text: |
| boundary_html = f""" |
| <div style="margin: 15px 0; padding: 12px; background: #fef3c7; |
| border-radius: 10px; border-left: 4px solid #f59e0b;"> |
| <div style="display: flex; align-items: center; gap: 8px; margin-bottom: 5px;"> |
| <div style="font-size: 20px;">🎭</div> |
| <div style="font-weight: 600; color: #92400e;">Demo Boundary</div> |
| </div> |
| <div style="font-size: 13px; color: #b45309; line-height: 1.5;"> |
| {self.boundary_text} |
| </div> |
| </div> |
| """ |
| |
| return f""" |
| <div style="border: 2px solid #3b82f6; border-radius: 16px; padding: 25px; |
| background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%); |
| box-shadow: 0 8px 32px rgba(59, 130, 246, 0.1); margin: 20px 0;"> |
| <div style="display: flex; align-items: center; gap: 15px; margin-bottom: 20px;"> |
| <div style="font-size: 36px;">{self.visual_cue}</div> |
| <div> |
| <h3 style="margin: 0 0 5px 0; color: #1e293b; font-size: 20px; font-weight: 700;"> |
| {self.title} |
| </h3> |
| <div style="font-size: 14px; color: #64748b;"> |
| Phase: {self.phase.value.replace('_', ' ').title()} |
| </div> |
| </div> |
| </div> |
| |
| {progress_html} |
| |
| <div style="margin-bottom: 20px;"> |
| <div style="font-size: 16px; color: #475569; line-height: 1.6; margin-bottom: 15px;"> |
| {self.narrative} |
| </div> |
| |
| {real_arf_html} |
| {boundary_html} |
| |
| <div style="padding: 15px; background: #f1f5f9; border-radius: 10px; |
| border-left: 4px solid #3b82f6;"> |
| <div style="font-weight: 600; color: #1e293b; margin-bottom: 5px;"> |
| 🎯 Key Message |
| </div> |
| <div style="font-size: 15px; color: #475569; line-height: 1.5;"> |
| {self.key_message} |
| </div> |
| </div> |
| </div> |
| |
| <div style="display: flex; justify-content: space-between; align-items: center; |
| margin-top: 20px; padding-top: 15px; border-top: 1px solid #e2e8f0;"> |
| <div style="font-size: 12px; color: #94a3b8;"> |
| ⏱️ Duration: {self.duration_seconds}s • |
| 🎯 Focus: {self.phase.value.replace('_', ' ').title()} |
| </div> |
| <div style="display: flex; gap: 10px;"> |
| <div style="padding: 4px 10px; background: #e2e8f0; |
| color: #64748b; border-radius: 12px; font-size: 11px; font-weight: 500;"> |
| Phase {current_step} |
| </div> |
| </div> |
| </div> |
| </div> |
| """ |
|
|
| |
| DEMO_FLOW = { |
| DemoPhase.INTRODUCTION: PhaseContent( |
| phase=DemoPhase.INTRODUCTION, |
| title="🚀 Welcome to ARF v3.3.7 - The Architecture Demo", |
| narrative=""" |
| Most AI systems fail silently in production. This one doesn't. We're about to demonstrate |
| a production-grade agentic reliability system with <strong>clear architectural boundaries</strong>. |
| |
| This demo shows: |
| 1. <strong>Real ARF OSS v3.3.7</strong> - Actual advisory intelligence |
| 2. <strong>Simulated Enterprise</strong> - Value proposition without infrastructure access |
| 3. <strong>Clear separation</strong> - Honest boundaries between OSS and Enterprise |
| """, |
| key_message="This isn't AI theater. It's a production-ready system with architectural honesty.", |
| visual_cue="🎭", |
| duration_seconds=30, |
| show_boundary=True, |
| boundary_text="We're simulating Enterprise execution for the demo. Real execution requires production infrastructure.", |
| is_real_arf=False |
| ), |
| |
| DemoPhase.FAILURE_INJECTION: PhaseContent( |
| phase=DemoPhase.FAILURE_INJECTION, |
| title="🚨 Phase 1: Inject Production Failure", |
| narrative=""" |
| We're simulating a <strong>Cache Miss Storm</strong> affecting 45,000 users with $8,500/hour revenue risk. |
| |
| This is how most systems look right before they fail silently. The metrics show: |
| • Cache hit rate dropped from 85% to 18% |
| • Database load increased to 92% |
| • Response time spiked to 1,850ms |
| |
| Notice: No remediation is running yet. We're letting you feel the tension. |
| """, |
| key_message="Failure happens. The question is how quickly and intelligently you respond.", |
| visual_cue="📉", |
| duration_seconds=20, |
| show_boundary=False, |
| is_real_arf=False |
| ), |
| |
| DemoPhase.REAL_OSS_ANALYSIS: PhaseContent( |
| phase=DemoPhase.REAL_OSS_ANALYSIS, |
| title="🧠 Phase 2: Real ARF OSS Intelligence Activates", |
| narrative=""" |
| ARF OSS v3.3.7 is now <strong>analyzing the incident in real-time</strong>. This is not a mock: |
| |
| 1. <strong>Detection Agent</strong> - Finds anomalies with 98.7% confidence |
| 2. <strong>Recall Agent</strong> - Searches RAG memory for similar incidents |
| 3. <strong>Decision Agent</strong> - Generates healing intent with reasoning |
| |
| Watch the confidence scores increase as evidence accumulates. This is <strong>real inference</strong>, |
| not pre-programmed responses. The system is reasoning, not reacting. |
| """, |
| key_message="ARF OSS provides production-grade intelligence. It reasons before it recommends.", |
| visual_cue="🤖", |
| duration_seconds=45, |
| show_boundary=True, |
| boundary_text="This is REAL ARF OSS v3.3.7 (Apache 2.0). It can analyze but not execute.", |
| is_real_arf=True |
| ), |
| |
| DemoPhase.DECISION_BOUNDARY: PhaseContent( |
| phase=DemoPhase.DECISION_BOUNDARY, |
| title="🎯 Phase 3: The Execution Boundary", |
| narrative=""" |
| ARF OSS has created a <strong>HealingIntent with 94% confidence</strong>: |
| • Action: Scale Redis cluster from 3 to 5 nodes |
| • Pattern match: 87% success rate from similar incidents |
| • Safety check: ✅ Passed (blast radius: 2 services) |
| |
| Now we pause intentionally. This is the <strong>architectural boundary</strong>: |
| • <strong>OSS can reason</strong> (Apache 2.0, advisory only) |
| • <strong>Enterprise can execute</strong> (Commercial, with safety guarantees) |
| |
| The system knows what to do, but requires authority to act. |
| """, |
| key_message="Reasoning and authority are not the same thing. This boundary is intentional.", |
| visual_cue="⚖️", |
| duration_seconds=25, |
| show_boundary=True, |
| boundary_text="OSS boundary reached. Execution requires Enterprise edition and infrastructure authority.", |
| is_real_arf=True |
| ), |
| |
| DemoPhase.SIMULATED_ENTERPRISE: PhaseContent( |
| phase=DemoPhase.SIMULATED_ENTERPRISE, |
| title="🏢 Phase 4: Simulated Enterprise Execution", |
| narrative=""" |
| We're now simulating what <strong>ARF Enterprise</strong> would do: |
| |
| 1. <strong>Validate safety constraints</strong> - Business hours, blast radius, rollback plans |
| 2. <strong>Apply novel execution protocols</strong> - Deterministic confidence, not just ML probabilities |
| 3. <strong>Execute with guarantees</strong> - Rollback prepared, circuit breakers set |
| |
| In production, this would execute against real infrastructure (Kubernetes, cloud APIs, etc.). |
| For the demo, we're showing the value proposition without real side effects. |
| """, |
| key_message="Enterprise adds execution authority, not just better intelligence.", |
| visual_cue="⚡", |
| duration_seconds=35, |
| show_boundary=True, |
| boundary_text="SIMULATED EXECUTION - Real Enterprise would execute against production infrastructure.", |
| is_real_arf=False |
| ), |
| |
| DemoPhase.RESOLUTION: PhaseContent( |
| phase=DemoPhase.RESOLUTION, |
| title="✅ Phase 5: Incident Resolution", |
| narrative=""" |
| The simulated execution completes: |
| • <strong>Recovery time:</strong> 12 minutes (vs 45 minutes manual) |
| • <strong>Cost saved:</strong> $6,375 |
| • <strong>Users protected:</strong> 45,000 → 0 impacted |
| • <strong>Learning:</strong> Pattern added to RAG memory |
| |
| System health normalizes. Confidence scores stabilize. The incident is marked as |
| <strong>resolved autonomously</strong>. |
| |
| Key metrics show the impact: |
| • Detection time: 45s (89% faster than average) |
| • Auto-heal rate: 81.7% (5.4× industry average) |
| """, |
| key_message="Autonomous reliability creates measurable business impact.", |
| visual_cue="📊", |
| duration_seconds=30, |
| show_boundary=False, |
| is_real_arf=False |
| ), |
| |
| DemoPhase.ARCHITECTURE_REVIEW: PhaseContent( |
| phase=DemoPhase.ARCHITECTURE_REVIEW, |
| title="🏗️ Phase 6: Architecture Validated", |
| narrative=""" |
| Let's review what we demonstrated: |
| |
| <strong>✅ Real Components (Production-Ready):</strong> |
| • ARF OSS v3.3.7 intelligence engine |
| • Three-agent pattern (Detection, Recall, Decision) |
| • RAG-based similarity search |
| • Confidence scoring and reasoning chains |
| |
| <strong>🎭 Simulated Components (Demo Value):</strong> |
| • Enterprise execution authority |
| • Infrastructure orchestration |
| • Rollback guarantees |
| • Novel execution protocols |
| |
| <strong>🎯 Clear Boundaries (Architectural Honesty):</strong> |
| • OSS advises, Enterprise executes |
| • No hidden automation or deception |
| • Production-ready separation |
| """, |
| key_message="This demo shows production architecture, not just AI capabilities.", |
| visual_cue="💎", |
| duration_seconds=40, |
| show_boundary=True, |
| boundary_text="Architecture validated: OSS for intelligence, Enterprise for execution.", |
| is_real_arf=False |
| ) |
| } |
|
|
| |
| USER_JOURNEY_STEPS = [ |
| { |
| "step": 1, |
| "title": "🎭 Understand the Architecture", |
| "description": "Review the demo flow to understand clear boundaries between OSS and Enterprise", |
| "tab": "All Tabs", |
| "action": "Read the phase guidance", |
| "learning": "See how ARF separates intelligence (OSS) from execution (Enterprise)", |
| "phase": DemoPhase.INTRODUCTION.value, |
| "duration": "30s" |
| }, |
| { |
| "step": 2, |
| "title": "🔥 Experience REAL ARF OSS Analysis", |
| "description": "Select an incident and run OSS analysis to see actual ARF v3.3.7 intelligence", |
| "tab": "Live Incident Demo", |
| "action": "Click 'Run OSS Analysis'", |
| "learning": "See real ARF OSS package analyzing incidents with confidence scores", |
| "phase": DemoPhase.REAL_OSS_ANALYSIS.value, |
| "duration": "45s" |
| }, |
| { |
| "step": 3, |
| "title": "🎯 Observe the Execution Boundary", |
| "description": "Notice where OSS stops and Enterprise would begin", |
| "tab": "Live Incident Demo", |
| "action": "Review HealingIntent and boundary indicators", |
| "learning": "Understand the architectural separation between advisory and execution", |
| "phase": DemoPhase.DECISION_BOUNDARY.value, |
| "duration": "25s" |
| }, |
| { |
| "step": 4, |
| "title": "⚡ Simulate Enterprise Healing", |
| "description": "Experience autonomous healing with simulated execution", |
| "tab": "Live Incident Demo", |
| "action": "Click 'Execute Enterprise Healing'", |
| "learning": "See the Enterprise value proposition without real infrastructure", |
| "phase": DemoPhase.SIMULATED_ENTERPRISE.value, |
| "duration": "35s" |
| }, |
| { |
| "step": 5, |
| "title": "💰 Calculate Your Business ROI", |
| "description": "Adjust the sliders to see potential savings for your organization", |
| "tab": "Business Impact & ROI", |
| "action": "Use sliders then click 'Calculate My ROI'", |
| "learning": "Understand the business case with your specific numbers", |
| "phase": "business_roi", |
| "duration": "60s" |
| }, |
| { |
| "step": 6, |
| "title": "📜 Explore Enterprise-Grade Compliance", |
| "description": "View comprehensive audit trail and compliance features", |
| "tab": "Audit Trail & History", |
| "action": "Check execution and incident history", |
| "learning": "See enterprise-level logging, compliance, and audit capabilities", |
| "phase": "compliance", |
| "duration": "45s" |
| }, |
| { |
| "step": 7, |
| "title": "🧠 Discover the Learning Engine", |
| "description": "Explore pattern detection and similarity search", |
| "tab": "Learning Engine", |
| "action": "Search for similar incidents and view patterns", |
| "learning": "See how ARF learns from past incidents to improve future responses", |
| "phase": "learning", |
| "duration": "50s" |
| } |
| ] |
|
|
| |
| DEMO_TIPS = [ |
| "💎 **Architecture Tip**: Look for the 'REAL ARF' vs 'SIMULATED' indicators to understand boundaries", |
| "🎭 **Demo Tip**: The 'Run Complete Demo' button follows our psychological pacing guide", |
| "⚡ **Enterprise Tip**: Toggle approval mode to see different execution workflows", |
| "📊 **ROI Tip**: Use realistic numbers for your organization in the ROI calculator", |
| "🔍 **Analysis Tip**: Try different incident scenarios to see varied ARF responses", |
| "📜 **Compliance Tip**: Export the audit trail to see comprehensive JSON structure", |
| "🧠 **Learning Tip**: Search for patterns to see how ARF improves over time", |
| "🎯 **Boundary Tip**: Notice where OSS analysis ends and Enterprise execution would begin" |
| ] |
|
|
| |
| QUICK_START_GUIDE = { |
| "for_executives": { |
| "focus": "Business Impact & ROI", |
| "steps": [ |
| "1. Go to 'Business Impact & ROI' tab", |
| "2. Adjust sliders to match your organization", |
| "3. Click 'Calculate My ROI'", |
| "4. Review the 5.2× ROI multiplier", |
| "5. Ask: 'What would 73% faster MTTR mean for us?'" |
| ], |
| "time": "2 minutes", |
| "key_question": "What's the cost of NOT having autonomous reliability?" |
| }, |
| "for_engineers": { |
| "focus": "Real ARF OSS Analysis", |
| "steps": [ |
| "1. Select 'Cache Miss Storm' scenario", |
| "2. Click 'Run OSS Analysis'", |
| "3. Watch the three agents work in real-time", |
| "4. Review the HealingIntent with 94% confidence", |
| "5. Notice the reasoning chain and evidence" |
| ], |
| "time": "3 minutes", |
| "key_question": "How would this intelligence change your on-call experience?" |
| }, |
| "for_architects": { |
| "focus": "Architecture Boundaries", |
| "steps": [ |
| "1. Run the complete demo walkthrough", |
| "2. Look for 'REAL ARF' vs 'SIMULATED' indicators", |
| "3. Notice the execution boundary", |
| "4. Review the architecture validation phase", |
| "5. Ask: 'How would this integrate with our stack?'" |
| ], |
| "time": "4 minutes", |
| "key_question": "Is our current approach proactive or reactive?" |
| } |
| } |
|
|
| def get_phase_content(phase: DemoPhase) -> PhaseContent: |
| """Get content for a specific demo phase""" |
| return DEMO_FLOW.get(phase, DEMO_FLOW[DemoPhase.INTRODUCTION]) |
|
|
| def get_phase_html(phase: DemoPhase, current_step: int = 1) -> str: |
| """Get HTML for a demo phase with progress indicator""" |
| content = get_phase_content(phase) |
| total_steps = len(DEMO_FLOW) |
| |
| |
| phase_order = list(DEMO_FLOW.keys()) |
| step_number = phase_order.index(phase) + 1 if phase in phase_order else current_step |
| |
| return content.get_html( |
| show_progress=True, |
| current_step=step_number, |
| total_steps=total_steps |
| ) |
|
|
| def get_demo_progress(current_phase: DemoPhase) -> Dict[str, Any]: |
| """Get current demo progress information""" |
| phase_order = list(DEMO_FLOW.keys()) |
| current_index = phase_order.index(current_phase) if current_phase in phase_order else 0 |
| |
| return { |
| "current_phase": current_phase.value, |
| "current_step": current_index + 1, |
| "total_steps": len(phase_order), |
| "progress_percentage": int(((current_index + 1) / len(phase_order)) * 100), |
| "next_phase": phase_order[current_index + 1].value if current_index + 1 < len(phase_order) else None, |
| "estimated_time_remaining": sum( |
| DEMO_FLOW[phase].duration_seconds |
| for i, phase in enumerate(phase_order) |
| if i > current_index |
| ) |
| } |
|
|
| def get_quick_start_guide(role: str = "executives") -> Dict[str, Any]: |
| """Get quick start guide for specific role""" |
| return QUICK_START_GUIDE.get(role, QUICK_START_GUIDE["for_executives"]) |
|
|
| |
| class DemoPsychologyController: |
| """Manages the psychological flow of the demo""" |
| |
| def __init__(self): |
| self.current_phase = DemoPhase.INTRODUCTION |
| self.phase_start_time = time.time() |
| self.completed_phases = [] |
| self.user_attention_score = 100 |
| |
| def transition_to_phase(self, phase: DemoPhase) -> Dict[str, Any]: |
| """Transition to a new demo phase with psychological timing""" |
| current_time = time.time() |
| phase_duration = current_time - self.phase_start_time |
| |
| |
| self.user_attention_score = max(60, self.user_attention_score - (phase_duration / 10)) |
| |
| |
| if phase_duration < 10 and self.current_phase != DemoPhase.INTRODUCTION: |
| self.user_attention_score -= 10 |
| |
| |
| self.completed_phases.append(self.current_phase) |
| self.current_phase = phase |
| self.phase_start_time = time.time() |
| |
| |
| self.user_attention_score = min(100, self.user_attention_score + 20) |
| |
| return { |
| "new_phase": phase.value, |
| "previous_phase_duration": int(phase_duration), |
| "user_attention_score": int(self.user_attention_score), |
| "recommended_pause": self._get_recommended_pause(phase), |
| "key_message": DEMO_FLOW[phase].key_message |
| } |
| |
| def _get_recommended_pause(self, phase: DemoPhase) -> str: |
| """Get recommended pause based on phase psychology""" |
| pauses = { |
| DemoPhase.INTRODUCTION: "Pause to set context", |
| DemoPhase.FAILURE_INJECTION: "Let the tension build", |
| DemoPhase.REAL_OSS_ANALYSIS: "Watch the reasoning unfold", |
| DemoPhase.DECISION_BOUNDARY: "Pause intentionally here", |
| DemoPhase.SIMULATED_ENTERPRISE: "Explain the simulation", |
| DemoPhase.RESOLUTION: "Show the impact", |
| DemoPhase.ARCHITECTURE_REVIEW: "Summarize the architecture" |
| } |
| return pauses.get(phase, "Continue") |
| |
| def get_current_guidance(self) -> str: |
| """Get current guidance HTML""" |
| return get_phase_html(self.current_phase, len(self.completed_phases) + 1) |
| |
| def should_speed_up(self) -> bool: |
| """Determine if we should speed up based on attention score""" |
| return self.user_attention_score < 70 |
| |
| def should_slow_down(self) -> bool: |
| """Determine if we should slow down for emphasis""" |
| important_phases = [ |
| DemoPhase.DECISION_BOUNDARY, |
| DemoPhase.ARCHITECTURE_REVIEW |
| ] |
| return self.current_phase in important_phases |
|
|
| |
| _demo_controller = None |
|
|
| def get_demo_controller() -> DemoPsychologyController: |
| """Get singleton demo controller instance""" |
| global _demo_controller |
| if _demo_controller is None: |
| _demo_controller = DemoPsychologyController() |
| return _demo_controller |