| """ |
| Enhanced demo orchestrator with real ARF integration patterns |
| """ |
| import streamlit as st |
| import time |
| import json |
| from datetime import datetime |
| from typing import Dict, Any, List, Optional |
|
|
| |
| from .scenarios import get_scenario_data |
| from .mock_arf import ( |
| create_mock_healing_intent, |
| run_rag_similarity_search, |
| calculate_pattern_confidence, |
| simulate_arf_analysis |
| ) |
|
|
| def run_enhanced_incident_demo(scenario_name: str, execution_mode: str = "advisory"): |
| """ |
| Run enhanced incident demo with ARF integration |
| """ |
| |
| scenario = get_scenario_data(scenario_name) |
| if not scenario: |
| st.error(f"Scenario '{scenario_name}' not found") |
| return |
| |
| |
| st.markdown(f"### π₯ {scenario['name']}") |
| st.caption(scenario['description']) |
| |
| |
| col1, col2 = st.columns(2) |
| |
| with col1: |
| st.markdown("#### π Current Metrics") |
| metrics = scenario.get('metrics', {}) |
| |
| |
| metrics_cols = st.columns(2) |
| for idx, (key, value) in enumerate(metrics.items()): |
| with metrics_cols[idx % 2]: |
| if isinstance(value, (int, float)): |
| if key == "cache_hit_rate": |
| st.metric(label=key.replace('_', ' ').title(), |
| value=f"{value}%", |
| delta="-65%" if value < 20 else None) |
| elif key == "database_load": |
| st.metric(label=key.replace('_', ' ').title(), |
| value=f"{value}%", |
| delta="+40%" if value > 80 else None) |
| else: |
| st.metric(label=key.replace('_', ' ').title(), value=str(value)) |
| |
| with col2: |
| st.markdown("#### π° Business Impact") |
| impact = scenario.get('business_impact', {}) |
| |
| if impact.get('revenue_loss_per_hour'): |
| st.metric( |
| label="Revenue Loss/Hour", |
| value=f"${impact['revenue_loss_per_hour']:,.0f}", |
| delta_color="inverse" |
| ) |
| |
| if impact.get('sla_violation'): |
| st.error("β οΈ SLA Violation Detected") |
| |
| if impact.get('affected_users'): |
| st.metric( |
| label="Affected Users", |
| value=f"{impact['affected_users']:,.0f}", |
| delta_color="inverse" |
| ) |
| |
| |
| with st.spinner("π§ ARF Analysis in progress..."): |
| time.sleep(1.5) |
| |
| |
| arf_analysis = simulate_arf_analysis(scenario) |
| |
| |
| similar_incidents = run_rag_similarity_search(scenario) |
| |
| |
| pattern_confidence = calculate_pattern_confidence(scenario, similar_incidents) |
| |
| |
| healing_intent = create_mock_healing_intent( |
| scenario=scenario, |
| similar_incidents=similar_incidents, |
| confidence=pattern_confidence |
| ) |
| |
| |
| from ..ui.components import create_arf_enhanced_timeline |
| create_arf_enhanced_timeline(scenario, [healing_intent]) |
| |
| |
| from ..ui.components import create_healing_intent_visualizer |
| create_healing_intent_visualizer(healing_intent) |
| |
| |
| from ..ui.components import create_rag_similarity_panel |
| create_rag_similarity_panel( |
| query=f"{scenario['name']} - {scenario['description']}", |
| similar_incidents=similar_incidents |
| ) |
| |
| |
| from ..ui.components import create_execution_mode_toggle |
| selected_mode = create_execution_mode_toggle(execution_mode) |
| |
| |
| st.markdown("---") |
| st.markdown("### β‘ Take Action") |
| |
| col1, col2, col3 = st.columns(3) |
| |
| with col1: |
| if st.button("π Run OSS Analysis", use_container_width=True): |
| st.info(""" |
| **OSS Analysis Results:** |
| - Incident identified: Cache miss storm |
| - Recommended action: Scale Redis cluster |
| - Confidence: 85% |
| - Similar incidents found: 3 |
| |
| *Note: OSS edition provides analysis only.* |
| """) |
| |
| with col2: |
| if st.button("π Execute Enterprise Healing", use_container_width=True): |
| if execution_mode == "advisory": |
| st.warning(""" |
| **Enterprise Upgrade Required** |
| |
| To execute healing actions, upgrade to Enterprise Edition: |
| - Autonomous healing capabilities |
| - Approval workflows |
| - Audit trails |
| - Compliance reporting |
| |
| [Upgrade Now](https://arf.dev/enterprise) |
| """) |
| elif execution_mode == "approval": |
| st.success(""" |
| **Healing Action Submitted for Approval** |
| |
| β
HealingIntent created |
| π Sent to approval workflow |
| π€ Awaiting human review |
| π Estimated approval time: 2-5 minutes |
| """) |
| else: |
| st.success(""" |
| **Autonomous Healing Executed** |
| |
| β
Redis cluster scaled from 3 to 5 nodes |
| β
Cache TTL adjusted to 300s |
| β
Database connections optimized |
| β‘ Resolution time: 8.2 minutes |
| π° Cost avoided: $7,225 |
| """) |
| |
| with col3: |
| if st.button("π Require Manual Approval", use_container_width=True): |
| st.info(""" |
| **Approval Workflow Enabled** |
| |
| This incident will require manual approval before execution: |
| 1. SRE team notified via PagerDuty |
| 2. Approval required from team lead |
| 3. Audit trail recorded |
| 4. Compliance checks run |
| |
| *Enterprise feature: Human-in-the-loop safety* |
| """) |