diff --git "a/app.py" "b/app.py" --- "a/app.py" +++ "b/app.py" @@ -1,8 +1,7 @@ -""" +continue where the previous AI agent left off: """ πŸš€ ARF Ultimate Investor Demo v3.8.0 - ENTERPRISE EDITION -MODULAR VERSION - Fixed with working visualizations and readable theme -ULTIMATE FIXED VERSION with all critical issues resolved -NOW WITH TRUE ARF v3.3.7 INTEGRATION AND WORKING VISUALIZATIONS +ENHANCED VERSION WITH CLEAR BOUNDARIES AND RELIABLE VISUALIZATIONS +Fixed to show clear OSS vs Enterprise boundaries with architectural honesty """ import logging @@ -33,12 +32,207 @@ logger = logging.getLogger(__name__) sys.path.insert(0, str(Path(__file__).parent)) # =========================================== -# ARF INSTALLATION CHECK SYSTEM - NEW +# BOUNDARY MANAGEMENT SYSTEM - NEW CRITICAL ADDITION +# =========================================== +class BoundaryManager: + """Manages clear boundaries between OSS and Enterprise""" + + @staticmethod + def get_system_boundaries() -> Dict[str, Any]: + """Get clear system boundary definitions""" + installation = get_installation_status() + + boundaries = { + "oss": { + "available": installation["oss_installed"], + "version": installation["oss_version"] or "mock", + "license": "Apache 2.0", + "capabilities": ["advisory", "analysis", "reasoning"], + "cannot_do": ["execute", "modify_infrastructure", "autonomous_healing"], + "label": "βœ… REAL ARF OSS" if installation["oss_installed"] else "⚠️ MOCK ARF", + "color": "#10b981" if installation["oss_installed"] else "#64748b", + "icon": "βœ…" if installation["oss_installed"] else "⚠️" + }, + "enterprise": { + "available": installation["enterprise_installed"], + "version": installation["enterprise_version"] or "simulated", + "license": "Commercial" if installation["enterprise_installed"] else "SIMULATED", + "capabilities": ["autonomous_execution", "rollback_guarantees", "novel_protocols"], + "requires": ["infrastructure_access", "safety_controls", "enterprise_license"], + "label": "πŸš€ REAL Enterprise" if installation["enterprise_installed"] else "🎭 SIMULATED Enterprise", + "color": "#8b5cf6" if installation["enterprise_installed"] else "#f59e0b", + "icon": "πŸš€" if installation["enterprise_installed"] else "🎭" + }, + "demo_mode": { + "architecture": "OSS advises β†’ Enterprise executes", + "honesty_level": "Architecturally Honest", + "transparency": "Clear boundaries between real and simulated" + } + } + + return boundaries + + @staticmethod + def get_boundary_badges() -> str: + """Get HTML badges showing clear boundaries""" + boundaries = BoundaryManager.get_system_boundaries() + oss = boundaries["oss"] + enterprise = boundaries["enterprise"] + + return f""" +
+
+ πŸ—οΈ System Architecture Boundaries +
+ +
+
+ {oss['icon']} + {oss['label']} v{oss['version']} +
+ +
β†’
+ +
+ {enterprise['icon']} + {enterprise['label']} +
+
+ +
+ OSS advises ({oss['license']}) β€’ Enterprise executes ({enterprise['license']})
+ Clear separation ensures production safety and architectural honesty +
+
+ """ + + @staticmethod + def create_agent_with_boundary(agent_name: str, status: str, + is_real_arf: bool = True, confidence: float = 0.0) -> str: + """Create agent display with clear boundary indicator""" + icons = { + "Detection": "πŸ•΅οΈβ€β™‚οΈ", + "Recall": "🧠", + "Decision": "🎯" + } + + border_color = "#10b981" if is_real_arf else "#f59e0b" + background = "#f0fdf4" if is_real_arf else "#fef3c7" + badge_text = "REAL ARF" if is_real_arf else "SIMULATED" + + # Confidence bar + confidence_bar = "" + if confidence > 0: + confidence_color = "#10b981" if confidence >= 0.9 else "#f59e0b" if confidence >= 0.7 else "#ef4444" + confidence_bar = f""" +
+
+ Confidence + {confidence:.1%} +
+
+
+
+
+ """ + + return f""" +
+ + +
+ {badge_text} +
+ + +
{icons.get(agent_name, 'πŸ€–')}
+
+ {agent_name} Agent +
+ + +
+ {status} +
+ + {confidence_bar} + + +
+
+ {badge_text} MODE +
+
+
+ """ + + @staticmethod + def create_boundary_indicator(action: str, is_simulated: bool = True) -> str: + """Create clear execution boundary indicator""" + if is_simulated: + return f""" +
+
🎭
+

+ SIMULATED ENTERPRISE EXECUTION +

+

+ Action: {action}
+ Mode: Enterprise Simulation (not real execution)
+ Boundary: OSS advises β†’ Enterprise would execute +

+
+ DEMO BOUNDARY +
+

+ In production, Enterprise edition would execute against real infrastructure +

+
+ """ + else: + return f""" +
+
⚑
+

+ REAL ENTERPRISE EXECUTION +

+

+ Action: {action}
+ Mode: Enterprise Autonomous
+ Boundary: Real execution with safety guarantees +

+
+ ENTERPRISE+ +
+
+ """ + +# =========================================== +# ARF INSTALLATION CHECK SYSTEM - ENHANCED # =========================================== def check_arf_installation(): """ Check if real ARF packages are installed - Returns detailed installation status + Returns detailed installation status with boundary info """ results = { "oss_installed": False, @@ -49,6 +243,11 @@ def check_arf_installation(): "oss_license": "unknown", "execution_allowed": False, "recommendations": [], + "boundaries": { + "oss_can": ["advisory_analysis", "rag_search", "healing_intent"], + "oss_cannot": ["execute", "modify_infra", "autonomous_healing"], + "enterprise_requires": ["license", "infra_access", "safety_controls"] + }, "badges": { "oss": {"text": "⚠️ Mock ARF", "color": "#f59e0b", "icon": "⚠️"}, "enterprise": {"text": "πŸ”’ Enterprise Required", "color": "#64748b", "icon": "πŸ”’"} @@ -119,6 +318,9 @@ def get_installation_badges(): oss_badge = installation["badges"]["oss"] enterprise_badge = installation["badges"]["enterprise"] + # Add boundary context + boundaries = BoundaryManager.get_system_boundaries() + return f"""
+ Architecture: {boundaries['demo_mode']['architecture']} β€’ + Mode: {boundaries['demo_mode']['honesty_level']} +
""" # =========================================== @@ -154,7 +360,7 @@ class AsyncRunner: except Exception as e: logger.error(f"Async execution failed: {e}") # Return error state instead of crashing - return {"error": str(e), "status": "failed"} + return {"error": str(e), "status": "failed", "boundary_note": "Execution boundary reached"} @staticmethod def async_to_sync(async_func): @@ -164,8 +370,8 @@ class AsyncRunner: return AsyncRunner.run_async(async_func(*args, **kwargs)) except Exception as e: logger.error(f"Async to sync conversion failed: {e}") - # Return a sensible fallback - return {"error": str(e), "status": "failed"} + # Return a sensible fallback with boundary context + return {"error": str(e), "status": "failed", "boundary_context": "OSS advisory only - execution requires Enterprise"} return wrapper # =========================================== @@ -179,65 +385,16 @@ class Settings: self.default_scenario = "Cache Miss Storm" self.max_history_items = 100 self.auto_refresh_seconds = 30 + self.show_boundaries = True # NEW: Show clear boundaries + self.architectural_honesty = True # NEW: Be transparent about what's real vs simulated settings = Settings() # =========================================== -# HELPER FUNCTIONS FOR VISUALIZATIONS - FIXED VERSION +# RELIABLE VISUALIZATION HELPERS - ENHANCED WITH BOUNDARIES # =========================================== -def create_empty_plot(title: str): - """Create an empty placeholder plot that actually shows up""" - try: - import plotly.graph_objects as go - - # Create a simple line plot that WILL display - fig = go.Figure() - - # Add sample data so it shows something - fig.add_trace(go.Scatter( - x=[1, 2, 3, 4, 5], - y=[2, 3, 1, 4, 3], - mode='lines+markers', - name='Sample Data', - line=dict(color='#3b82f6', width=2) - )) - - fig.update_layout( - height=300, - title=dict( - text=title, - font=dict(size=14, color='#1e293b'), - x=0.5, - xanchor='center' - ), - paper_bgcolor='white', - plot_bgcolor='white', - xaxis=dict( - title='Time', - gridcolor='#e2e8f0', - showgrid=True, - color='#1e293b' - ), - yaxis=dict( - title='Value', - gridcolor='#e2e8f0', - showgrid=True, - color='#1e293b' - ), - margin=dict(l=50, r=30, t=50, b=50), - showlegend=True - ) - - return fig - except ImportError: - logger.warning("Plotly not available for plots") - return None - except Exception as e: - logger.error(f"Error creating plot: {e}") - return None - -def create_simple_telemetry_plot(scenario_name: str): - """Simple guaranteed-to-work telemetry plot""" +def create_simple_telemetry_plot(scenario_name: str, is_real_arf: bool = True): + """Simple guaranteed-to-work telemetry plot with boundary indicators""" try: import plotly.graph_objects as go @@ -262,7 +419,7 @@ def create_simple_telemetry_plot(scenario_name: str): x=time_points, y=anomaly_values, mode='lines+markers', - name='Anomaly', + name='🚨 Anomaly', line=dict(color='#ef4444', width=3), marker=dict(size=8, color='#ef4444') )) @@ -276,9 +433,15 @@ def create_simple_telemetry_plot(scenario_name: str): annotation_position="top left" ) + # Add boundary indicator in title + boundary_text = "REAL ARF OSS" if is_real_arf else "DEMO SIMULATION" + boundary_color = "#10b981" if is_real_arf else "#f59e0b" + fig.update_layout( title=dict( - text=f'πŸ“ˆ {scenario_name} - Live Telemetry', + text=f'πŸ“ˆ {scenario_name} - Live Telemetry
' + f'' + f'πŸ’Ž {boundary_text}', font=dict(size=16, color='#1e293b') ), height=300, @@ -311,10 +474,87 @@ def create_simple_telemetry_plot(scenario_name: str): return fig except Exception as e: logger.error(f"Error creating telemetry plot: {e}") - return create_empty_plot(f'Telemetry: {scenario_name}') + # Fallback to HTML visualization + return create_html_telemetry_fallback(scenario_name, is_real_arf) -def create_simple_impact_plot(scenario_name: str): - """Simple guaranteed-to-work impact plot""" +def create_html_telemetry_fallback(scenario_name: str, is_real_arf: bool) -> str: + """HTML fallback for telemetry visualization with boundary indicators""" + boundary_color = "#10b981" if is_real_arf else "#f59e0b" + boundary_text = "REAL ARF OSS" if is_real_arf else "DEMO SIMULATION" + + return f""" +
+ + +
+ πŸ’Ž {boundary_text} +
+ +

+ πŸ“ˆ {scenario_name} - Live Telemetry +

+ + +
+ +
+ + +
+ + +
+
+
+
+ 350% spike +
+
+ + +
+ Normal: 100% +
+
+ Warning: 150% +
+
+ Anomaly: 350% +
+
+ + +
+
+
Status
+
+ 🚨 Anomaly Detected +
+
+
+
ARF Mode
+
+ {boundary_text} +
+
+
+
+ """ + +def create_simple_impact_plot(scenario_name: str, is_real_arf: bool = True): + """Simple guaranteed-to-work impact plot with boundary indicators""" try: import plotly.graph_objects as go @@ -332,9 +572,15 @@ def create_simple_impact_plot(scenario_name: str): textposition='auto', )]) + # Add boundary indicator in title + boundary_text = "REAL ARF OSS" if is_real_arf else "DEMO SIMULATION" + boundary_color = "#10b981" if is_real_arf else "#f59e0b" + fig.update_layout( title=dict( - text=f'πŸ’° {scenario_name} - Business Impact', + text=f'πŸ’° {scenario_name} - Business Impact
' + f'' + f'πŸ’Ž {boundary_text} Analysis', font=dict(size=16, color='#1e293b') ), height=300, @@ -359,112 +605,177 @@ def create_simple_impact_plot(scenario_name: str): return fig except Exception as e: logger.error(f"Error creating impact plot: {e}") - return create_empty_plot(f'Impact: {scenario_name}') + # Fallback to HTML visualization + return create_html_impact_fallback(scenario_name, is_real_arf) -def create_simple_timeline_plot(scenario_name: str): - """Simple timeline plot""" +def create_html_impact_fallback(scenario_name: str, is_real_arf: bool) -> str: + """HTML fallback for impact visualization""" + boundary_color = "#10b981" if is_real_arf else "#f59e0b" + boundary_text = "REAL ARF OSS" if is_real_arf else "DEMO SIMULATION" + + impact_map = { + "Cache Miss Storm": {"revenue": 8500, "users": 45000, "recovery": 45}, + "Database Connection Pool Exhaustion": {"revenue": 4200, "users": 25000, "recovery": 35}, + "Kubernetes Memory Leak": {"revenue": 5500, "users": 35000, "recovery": 40}, + "API Rate Limit Storm": {"revenue": 3800, "users": 20000, "recovery": 25}, + "Network Partition": {"revenue": 12000, "users": 75000, "recovery": 60}, + "Storage I/O Saturation": {"revenue": 6800, "users": 30000, "recovery": 50} + } + + impact = impact_map.get(scenario_name, {"revenue": 5000, "users": 30000, "recovery": 30}) + + return f""" +
+ + +
+ πŸ’Ž {boundary_text} +
+ +

+ πŸ’° {scenario_name} - Business Impact +

+ + +
+
+
Revenue Risk
+
+ ${impact['revenue']:,}/hr +
+
+ +
+
Users Affected
+
+ {impact['users']:,} +
+
+ +
+
Manual Recovery
+
+ {impact['recovery']} min +
+
+ +
+
ARF Recovery
+
+ {int(impact['recovery'] * 0.27)} min +
+
+
+ + +
+
+ Analysis Mode: {boundary_text}
+ Confidence: 94% β€’ ROI Impact: 5.2Γ— +
+
+
+ """ + +def create_empty_plot(title: str, is_real_arf: bool = True): + """Create an empty placeholder plot with boundary indicators""" try: import plotly.graph_objects as go - # Timeline events - events = ['Incident Start', 'ARF Detection', 'Analysis', 'Resolution'] - times = [0, 0.75, 2.5, 12] # minutes - colors = ['#ef4444', '#f59e0b', '#3b82f6', '#10b981'] - icons = ['🚨', 'πŸ•΅οΈβ€β™‚οΈ', '🧠', 'βœ…'] + boundary_color = "#10b981" if is_real_arf else "#f59e0b" + boundary_text = "REAL ARF OSS" if is_real_arf else "DEMO SIMULATION" + # Create a simple line plot that WILL display fig = go.Figure() - # Add events as markers - for i, (event, time, color, icon) in enumerate(zip(events, times, colors, icons)): - fig.add_trace(go.Scatter( - x=[time], - y=[1], - mode='markers+text', - marker=dict(size=20, color=color, symbol='circle'), - text=[f'{icon}
{event}
{time} min'], - textposition='top center', - name=event, - hoverinfo='text', - showlegend=False - )) - - # Add connecting line + # Add sample data so it shows something fig.add_trace(go.Scatter( - x=times, - y=[1, 1, 1, 1], - mode='lines', - line=dict(color='#64748b', width=2, dash='dash'), - showlegend=False + x=[1, 2, 3, 4, 5], + y=[2, 3, 1, 4, 3], + mode='lines+markers', + name='Sample Data', + line=dict(color='#3b82f6', width=2) )) fig.update_layout( + height=300, title=dict( - text=f'⏰ {scenario_name} - Incident Timeline', - font=dict(size=16, color='#1e293b') + text=f'{title}
' + f'' + f'πŸ’Ž {boundary_text}', + font=dict(size=14, color='#1e293b'), + x=0.5, + xanchor='center' ), - height=300, paper_bgcolor='white', plot_bgcolor='white', xaxis=dict( - title='Time (minutes)', - range=[-1, max(times) + 2], + title='Time', gridcolor='#e2e8f0', showgrid=True, color='#1e293b' ), yaxis=dict( - showticklabels=False, - range=[0.8, 1.2], + title='Value', + gridcolor='#e2e8f0', + showgrid=True, color='#1e293b' ), - showlegend=False, - margin=dict(l=50, r=30, t=60, b=50) + margin=dict(l=50, r=30, t=50, b=50), + showlegend=True ) - return fig - except Exception as e: - logger.error(f"Error creating timeline plot: {e}") - return create_empty_plot(f'Timeline: {scenario_name}') - -def create_empty_dashboard(): - """Create empty dashboard""" - try: - import plotly.graph_objects as go - fig = go.Figure() - fig.add_annotation( - text="πŸ“Š Dashboard will populate
after ROI calculation", - xref="paper", yref="paper", - x=0.5, y=0.5, showarrow=False, - font=dict(size=16, color="#64748b") - ) - fig.update_layout( - height=700, - paper_bgcolor='white', - plot_bgcolor='white', - xaxis=dict(showgrid=False, zeroline=False, showticklabels=False), - yaxis=dict(showgrid=False, zeroline=False, showticklabels=False), - title="" - ) return fig except ImportError: + logger.warning("Plotly not available for plots") + # Return HTML fallback + return f""" +
+
πŸ“Š
+

+ {title} +

+
+ Visualization requires Plotly
+ Install with: pip install plotly +
+
+ """ + except Exception as e: + logger.error(f"Error creating plot: {e}") return None -def get_inactive_agent_html(agent_name: str, description: str): - """Get HTML for inactive agent state""" +def get_inactive_agent_html(agent_name: str, description: str, is_real_arf: bool = False): + """Get HTML for inactive agent state with boundary indicators""" icons = { "Detection": "πŸ•΅οΈβ€β™‚οΈ", "Recall": "🧠", "Decision": "🎯" } + border_color = "#e2e8f0" + background = "#f8fafc" + badge_text = "INACTIVE" + + if is_real_arf: + border_color = "#10b981" + background = "#f0fdf4" + badge_text = "REAL ARF (INACTIVE)" + return f""" -
+
{icons.get(agent_name, '⏳')}

{agent_name} Agent

{description}

Status: Inactive + Mode: {badge_text}
WAITING
@@ -472,7 +783,7 @@ def get_inactive_agent_html(agent_name: str, description: str): """ # =========================================== -# IMPORT MODULAR COMPONENTS - FIXED VERSION +# IMPORT MODULAR COMPONENTS - ENHANCED WITH BOUNDARIES # =========================================== def import_components() -> Dict[str, Any]: """Safely import all components with proper error handling""" @@ -480,6 +791,7 @@ def import_components() -> Dict[str, Any]: "all_available": False, "error": None, "get_styles": lambda: "", # Default empty styles + "show_boundaries": settings.show_boundaries, # Boundary flag } try: @@ -525,16 +837,28 @@ def import_components() -> Dict[str, Any]: logger.info("βœ… UI components imported successfully") except ImportError as e: logger.error(f"❌ UI components not available: {e}") - # Create minimal UI fallbacks + # Create minimal UI fallbacks with boundary indicators + gr = components["gr"] components.update({ - "create_header": lambda version="3.3.7", mock=False: gr.HTML(f"

πŸš€ ARF v{version} Demo

"), - "create_status_bar": lambda: gr.HTML("
Status Bar
"), + "create_header": lambda version="3.3.7", mock=False: gr.HTML( + f""" +
+

πŸš€ ARF v{version} Demo

+

Clear boundaries: OSS advises β†’ Enterprise executes

+
+ """ + ), + "create_status_bar": lambda: gr.HTML(BoundaryManager.get_boundary_badges()), "create_tab1_incident_demo": lambda *args: [gr.Dropdown()] * 24, "create_tab2_business_roi": lambda *args: [gr.Plot()] * 7, "create_tab3_enterprise_features": lambda: [gr.JSON()] * 8, "create_tab4_audit_trail": lambda: [gr.Button()] * 6, "create_tab5_learning_engine": lambda: [gr.Plot()] * 10, - "create_footer": lambda: gr.HTML("
ARF v3.3.7
"), + "create_footer": lambda: gr.HTML( + "
" + "ARF v3.3.7 β€’ Architecture: OSS advises β†’ Enterprise executes" + "
" + ), }) # Try to import scenarios from demo module @@ -544,7 +868,7 @@ def import_components() -> Dict[str, Any]: logger.info(f"βœ… Loaded {len(INCIDENT_SCENARIOS)} scenarios from demo module") except ImportError as e: logger.warning(f"⚠️ Demo scenarios not available: {e}") - # Create minimal fallback scenarios + # Create minimal fallback scenarios with boundary context components["INCIDENT_SCENARIOS"] = { "Cache Miss Storm": { "component": "Redis Cache Cluster", @@ -553,7 +877,8 @@ def import_components() -> Dict[str, Any]: "business_impact": {"revenue_loss_per_hour": 8500}, "detection_time": "45 seconds", "tags": ["cache", "redis", "latency"], - "metrics": {"affected_users": 45000} + "metrics": {"affected_users": 45000}, + "boundary_note": "OSS analysis only - execution requires Enterprise" } } @@ -571,22 +896,31 @@ def import_components() -> Dict[str, Any]: logger.info("βœ… Falling back to RealARFIntegration") except ImportError as e2: logger.warning(f"⚠️ RealARFIntegration also not available: {e2}") - # Create a minimal mock orchestrator + # Create a minimal mock orchestrator with boundary awareness class MockOrchestrator: async def analyze_incident(self, scenario_name, scenario_data): return { "status": "mock", "scenario": scenario_name, - "message": "Mock analysis (no real ARF available)" + "message": "Mock analysis (no real ARF available)", + "boundary_note": "OSS advisory mode - execution requires Enterprise", + "demo_display": { + "real_arf_version": "mock", + "true_oss_used": False, + "enterprise_simulated": True, + "architectural_boundary": "OSS advises β†’ Enterprise would execute" + } } async def execute_healing(self, scenario_name, mode="autonomous"): return { "status": "mock", "scenario": scenario_name, - "message": "Mock execution (no real ARF available)" + "message": "Mock execution (no real ARF available)", + "boundary_note": "Simulated Enterprise execution - real execution requires infrastructure", + "enterprise_features_used": ["simulated_execution", "mock_rollback", "demo_mode"] } components["DemoOrchestrator"] = MockOrchestrator - logger.info("⚠️ Using mock orchestrator") + logger.info("⚠️ Using mock orchestrator with boundary awareness") # Try to import ROI calculator try: @@ -610,41 +944,128 @@ def import_components() -> Dict[str, Any]: "enterprise_cost": "$625,000", "roi_multiplier": "5.2Γ—", "payback_months": "6.0", - "annual_roi_percentage": "420%" - } + "annual_roi_percentage": "420%", + "boundary_context": "Based on OSS analysis + simulated Enterprise execution" + }, + "boundary_note": "ROI calculation includes OSS advisory value and simulated Enterprise execution benefits" } components["EnhancedROICalculator"] = MockCalculator() - logger.info("⚠️ Using mock ROI calculator") + logger.info("⚠️ Using mock ROI calculator with boundary context") - # Try to import visualization engine + # Try to import visualization engine with boundary awareness try: spec = importlib.util.find_spec("core.visualizations") if spec is not None: from core.visualizations import EnhancedVisualizationEngine - components["EnhancedVisualizationEngine"] = EnhancedVisualizationEngine() - logger.info("βœ… EnhancedVisualizationEngine imported successfully") + # Wrap the visualization engine to add boundary indicators + class BoundaryAwareVisualizationEngine(EnhancedVisualizationEngine): + def create_executive_dashboard(self, data=None, is_real_arf=True): + result = super().create_executive_dashboard(data) + # Add boundary indicator if it's a Plotly figure + if hasattr(result, 'update_layout'): + boundary_color = "#10b981" if is_real_arf else "#f59e0b" + boundary_text = "REAL ARF OSS" if is_real_arf else "SIMULATED" + result.update_layout( + title=f"{result.layout.title.text}
" + f"" + f"πŸ’Ž {boundary_text}" + ) + return result + + def create_telemetry_plot(self, scenario_name, anomaly_detected=True, is_real_arf=True): + return create_simple_telemetry_plot(scenario_name, is_real_arf) + + def create_impact_gauge(self, scenario_name, is_real_arf=True): + return create_simple_impact_plot(scenario_name, is_real_arf) + + def create_timeline_comparison(self, is_real_arf=True): + # Use the simple timeline from original app.py + try: + import plotly.graph_objects as go + + phases = ["Detection", "Analysis", "Decision", "Execution", "Recovery"] + manual_times = [300, 1800, 1200, 1800, 3600] # seconds + arf_times = [45, 30, 60, 720, 0] + + # Convert to minutes for readability + manual_times_min = [t/60 for t in manual_times] + arf_times_min = [t/60 for t in arf_times] + + fig = go.Figure() + + boundary_color = "#10b981" if is_real_arf else "#f59e0b" + boundary_text = "REAL ARF" if is_real_arf else "SIMULATED" + + fig.add_trace(go.Bar( + name='Manual Process', + x=phases, + y=manual_times_min, + marker_color='#ef4444', + text=[f"{t:.0f}m" for t in manual_times_min], + textposition='auto' + )) + + fig.add_trace(go.Bar( + name=f'ARF Autonomous ({boundary_text})', + x=phases, + y=arf_times_min, + marker_color=boundary_color, + text=[f"{t:.0f}m" for t in arf_times_min], + textposition='auto' + )) + + total_manual = sum(manual_times_min) + total_arf = sum(arf_times_min) + + fig.update_layout( + title=f"⏰ Incident Timeline Comparison
" + f"" + f"Total: {total_manual:.0f}m manual vs {total_arf:.0f}m ARF " + f"({((total_manual - total_arf) / total_manual * 100):.0f}% faster)", + barmode='group', + height=400, + plot_bgcolor='rgba(0,0,0,0)', + paper_bgcolor='rgba(0,0,0,0)', + legend=dict( + orientation="h", + yanchor="bottom", + y=1.02, + xanchor="right", + x=1 + ), + yaxis_title="Time (minutes)" + ) + + return fig + except Exception as e: + logger.error(f"Timeline plot failed: {e}") + return create_empty_plot("Timeline Comparison", is_real_arf) + + components["EnhancedVisualizationEngine"] = BoundaryAwareVisualizationEngine() + logger.info("βœ… EnhancedVisualizationEngine imported successfully with boundary awareness") else: raise ImportError("core.visualizations module not found") except ImportError as e: logger.warning(f"⚠️ EnhancedVisualizationEngine not available: {e}") class MockVisualizationEngine: - def create_executive_dashboard(self, data=None): - return create_empty_dashboard() + def create_executive_dashboard(self, data=None, is_real_arf=True): + return create_empty_plot("Executive Dashboard", is_real_arf) - def create_telemetry_plot(self, scenario_name, anomaly_detected=True): - return create_simple_telemetry_plot(scenario_name) + def create_telemetry_plot(self, scenario_name, anomaly_detected=True, is_real_arf=True): + return create_simple_telemetry_plot(scenario_name, is_real_arf) - def create_impact_gauge(self, scenario_name): - return create_simple_impact_plot(scenario_name) + def create_impact_gauge(self, scenario_name, is_real_arf=True): + return create_simple_impact_plot(scenario_name, is_real_arf) - def create_timeline_comparison(self): - return create_simple_timeline_plot("Incident Timeline") + def create_timeline_comparison(self, is_real_arf=True): + return create_empty_plot("Timeline Comparison", is_real_arf) + components["EnhancedVisualizationEngine"] = MockVisualizationEngine() - logger.info("⚠️ Using mock visualization engine") + logger.info("⚠️ Using mock visualization engine with boundary indicators") components["all_available"] = True components["error"] = None - logger.info("βœ… Successfully imported all modular components") + logger.info("βœ… Successfully imported all modular components with boundary awareness") except Exception as e: logger.error(f"❌ CRITICAL IMPORT ERROR: {e}") @@ -652,7 +1073,7 @@ def import_components() -> Dict[str, Any]: components["error"] = str(e) components["all_available"] = False - # Ensure we have minimal components + # Ensure we have minimal components with boundary context if "gr" not in components: try: import gradio as gr @@ -660,13 +1081,14 @@ def import_components() -> Dict[str, Any]: except: pass - # Ensure we have scenarios + # Ensure we have scenarios with boundary notes if "INCIDENT_SCENARIOS" not in components: components["INCIDENT_SCENARIOS"] = { "Cache Miss Storm": { "component": "Redis Cache Cluster", "severity": "HIGH", - "business_impact": {"revenue_loss_per_hour": 8500} + "business_impact": {"revenue_loss_per_hour": 8500}, + "boundary_note": "OSS analysis only - execution requires Enterprise" } } @@ -686,59 +1108,85 @@ def get_components() -> Dict[str, Any]: return _components # =========================================== -# AUDIT TRAIL MANAGER - FIXED VERSION +# AUDIT TRAIL MANAGER - ENHANCED WITH BOUNDARY INFO # =========================================== class AuditTrailManager: - """Enhanced audit trail manager""" + """Enhanced audit trail manager with boundary tracking""" def __init__(self): self.executions = [] self.incidents = [] - logger.info("AuditTrailManager initialized") + self.boundary_crossings = [] + logger.info("AuditTrailManager initialized with boundary tracking") - def add_execution(self, scenario: str, mode: str, success: bool = True, savings: float = 0) -> Dict: - """Add execution to audit trail""" + def add_execution(self, scenario: str, mode: str, success: bool = True, + savings: float = 0, boundary_note: str = "") -> Dict: + """Add execution to audit trail with boundary context""" entry = { "time": datetime.datetime.now().strftime("%H:%M"), "scenario": scenario, "mode": mode, "status": "βœ… Success" if success else "❌ Failed", "savings": f"${savings:,.0f}", - "details": f"{mode} execution at {datetime.datetime.now().isoformat()}" + "details": f"{mode} execution at {datetime.datetime.now().isoformat()}", + "boundary_note": boundary_note or "OSS advisory β†’ Enterprise execution boundary" } self.executions.insert(0, entry) + + # Track boundary crossing + if "Enterprise" in mode or "Autonomous" in mode: + self.boundary_crossings.append({ + "time": datetime.datetime.now().isoformat(), + "boundary": "OSS β†’ Enterprise", + "scenario": scenario, + "note": "Crossed from OSS advisory to Enterprise execution" + }) + return entry - def add_incident(self, scenario: str, severity: str = "HIGH") -> Dict: - """Add incident to audit trail""" + def add_incident(self, scenario: str, severity: str = "HIGH", + boundary_context: str = "") -> Dict: + """Add incident to audit trail with boundary context""" entry = { "time": datetime.datetime.now().strftime("%H:%M"), "scenario": scenario, "severity": severity, "component": get_components()["INCIDENT_SCENARIOS"].get(scenario, {}).get("component", "unknown"), - "status": "Analyzed" + "status": "Analyzed", + "boundary_context": boundary_context or "OSS advisory analysis only" } self.incidents.insert(0, entry) return entry def get_execution_table(self) -> List[List]: - """Get execution table data""" + """Get execution table data with boundary notes""" return [ - [e["time"], e["scenario"], e["mode"], e["status"], e["savings"], e["details"]] + [e["time"], e["scenario"], e["mode"], e["status"], e["savings"], + f"{e['details'][:30]}... {e.get('boundary_note', '')[:20]}..."] for e in self.executions[:10] ] def get_incident_table(self) -> List[List]: - """Get incident table data""" + """Get incident table data with boundary context""" return [ - [e["time"], e["component"], e["scenario"], e["severity"], e["status"]] + [e["time"], e["component"], e["scenario"], e["severity"], + f"{e['status']} ({e.get('boundary_context', 'OSS')})"] for e in self.incidents[:15] ] + def get_boundary_report(self) -> Dict[str, Any]: + """Get report on boundary crossings""" + return { + "total_crossings": len(self.boundary_crossings), + "crossings": self.boundary_crossings[-5:], # Last 5 crossings + "summary": f"{len(self.boundary_crossings)} OSSβ†’Enterprise boundary crossings tracked" + } + def clear(self) -> None: """Clear audit trail""" self.executions = [] self.incidents = [] + self.boundary_crossings = [] def get_audit_manager() -> AuditTrailManager: """Lazy load audit manager singleton""" @@ -748,7 +1196,7 @@ def get_audit_manager() -> AuditTrailManager: return _audit_manager # =========================================== -# HELPER FUNCTIONS +# HELPER FUNCTIONS - ENHANCED WITH BOUNDARY CONTEXT # =========================================== def get_scenario_impact(scenario_name: str) -> float: """Get average impact for a given scenario""" @@ -792,37 +1240,100 @@ def extract_roi_multiplier(roi_result: Dict) -> float: return 5.2 # =========================================== -# VISUALIZATION HELPERS - USING SIMPLE PLOTS +# VISUALIZATION HELPERS - USING SIMPLE PLOTS WITH BOUNDARIES # =========================================== -def create_telemetry_plot(scenario_name: str): +def create_telemetry_plot(scenario_name: str, is_real_arf: bool = True): """Create a telemetry visualization for the selected scenario""" try: - # Use our simple guaranteed plot - return create_simple_telemetry_plot(scenario_name) + # Use our enhanced simple plot with boundary indicators + return create_simple_telemetry_plot(scenario_name, is_real_arf) except Exception as e: logger.error(f"Failed to create telemetry plot: {e}") - return create_simple_telemetry_plot(scenario_name) + return create_simple_telemetry_plot(scenario_name, is_real_arf) -def create_impact_plot(scenario_name: str): +def create_impact_plot(scenario_name: str, is_real_arf: bool = True): """Create a business impact visualization""" try: - # Use our simple guaranteed plot - return create_simple_impact_plot(scenario_name) + # Use our enhanced simple plot with boundary indicators + return create_simple_impact_plot(scenario_name, is_real_arf) except Exception as e: logger.error(f"Failed to create impact plot: {e}") - return create_simple_impact_plot(scenario_name) + return create_simple_impact_plot(scenario_name, is_real_arf) -def create_timeline_plot(scenario_name: str): +def create_timeline_plot(scenario_name: str, is_real_arf: bool = True): """Create an incident timeline visualization""" try: - # Use our simple guaranteed plot - return create_simple_timeline_plot(scenario_name) + # Use simple timeline from original app.py + import plotly.graph_objects as go + + # Timeline events + events = ['Incident Start', 'ARF Detection', 'Analysis', 'Resolution'] + times = [0, 0.75, 2.5, 12] # minutes + colors = ['#ef4444', '#f59e0b', '#3b82f6', '#10b981'] + icons = ['🚨', 'πŸ•΅οΈβ€β™‚οΈ', '🧠', 'βœ…'] + + fig = go.Figure() + + # Add events as markers + for i, (event, time, color, icon) in enumerate(zip(events, times, colors, icons)): + fig.add_trace(go.Scatter( + x=[time], + y=[1], + mode='markers+text', + marker=dict(size=20, color=color, symbol='circle'), + text=[f'{icon}
{event}
{time} min'], + textposition='top center', + name=event, + hoverinfo='text', + showlegend=False + )) + + # Add connecting line + fig.add_trace(go.Scatter( + x=times, + y=[1, 1, 1, 1], + mode='lines', + line=dict(color='#64748b', width=2, dash='dash'), + showlegend=False + )) + + # Add boundary indicator in title + boundary_text = "REAL ARF OSS" if is_real_arf else "DEMO SIMULATION" + boundary_color = "#10b981" if is_real_arf else "#f59e0b" + + fig.update_layout( + title=dict( + text=f'⏰ {scenario_name} - Incident Timeline
' + f'' + f'πŸ’Ž {boundary_text}', + font=dict(size=16, color='#1e293b') + ), + height=300, + paper_bgcolor='white', + plot_bgcolor='white', + xaxis=dict( + title='Time (minutes)', + range=[-1, max(times) + 2], + gridcolor='#e2e8f0', + showgrid=True, + color='#1e293b' + ), + yaxis=dict( + showticklabels=False, + range=[0.8, 1.2], + color='#1e293b' + ), + showlegend=False, + margin=dict(l=50, r=30, t=60, b=50) + ) + + return fig except Exception as e: logger.error(f"Failed to create timeline plot: {e}") - return create_simple_timeline_plot(scenario_name) + return create_empty_plot(f'Timeline: {scenario_name}', is_real_arf) # =========================================== -# SCENARIO UPDATE HANDLER - FIXED WITH WORKING PLOTS +# SCENARIO UPDATE HANDLER - ENHANCED WITH BOUNDARIES # =========================================== def update_scenario_display(scenario_name: str) -> tuple: """Update all scenario-related displays with scenario-specific data""" @@ -830,7 +1341,12 @@ def update_scenario_display(scenario_name: str) -> tuple: impact = scenario.get("business_impact", {}) metrics = scenario.get("metrics", {}) - # Create scenario card HTML + # Get boundary context + boundaries = BoundaryManager.get_system_boundaries() + oss_label = boundaries["oss"]["label"] + enterprise_label = boundaries["enterprise"]["label"] + + # Create scenario card HTML with boundary context scenario_html = f"""
@@ -857,17 +1373,23 @@ def update_scenario_display(scenario_name: str) -> tuple:
{scenario.get('component', 'unknown').split('_')[0] if '_' in scenario.get('component', '') else scenario.get('component', 'unknown')} {scenario.get('severity', 'high').lower()} - production - incident + {oss_label.split(' ')[-1]} + {enterprise_label.split(' ')[-1]} +
+
+
+ Architecture: {oss_label} advises β†’ {enterprise_label} would execute +
""" - # Create visualizations - USING OUR SIMPLE GUARANTEED PLOTS - telemetry_plot = create_simple_telemetry_plot(scenario_name) - impact_plot = create_simple_impact_plot(scenario_name) - timeline_plot = create_simple_timeline_plot(scenario_name) + # Create visualizations with boundary context + is_real_arf = boundaries["oss"]["available"] + telemetry_plot = create_simple_telemetry_plot(scenario_name, is_real_arf) + impact_plot = create_simple_impact_plot(scenario_name, is_real_arf) + timeline_plot = create_timeline_plot(scenario_name, is_real_arf) return ( scenario_html, @@ -877,7 +1399,7 @@ def update_scenario_display(scenario_name: str) -> tuple: ) # =========================================== -# TRUE ARF ANALYSIS HANDLER - UPDATED WITH REAL ARF INDICATORS +# TRUE ARF ANALYSIS HANDLER - ENHANCED WITH BOUNDARY AWARENESS # =========================================== @AsyncRunner.async_to_sync async def run_true_arf_analysis(scenario_name: str): @@ -890,9 +1412,10 @@ async def run_true_arf_analysis(scenario_name: str): if not scenario: raise ValueError(f"Scenario '{scenario_name}' not found") - # Check installation status + # Check installation status and boundaries installation = get_installation_status() real_arf_available = installation["oss_installed"] + boundaries = BoundaryManager.get_system_boundaries() # Use TrueARF337Orchestrator if available orchestrator = get_components()["DemoOrchestrator"]() @@ -903,8 +1426,12 @@ async def run_true_arf_analysis(scenario_name: str): error_msg = analysis.get("message", "Unknown error") raise ValueError(f"Analysis failed: {error_msg}") - # Add to audit trail - get_audit_manager().add_incident(scenario_name, scenario.get("severity", "HIGH")) + # Add to audit trail with boundary context + get_audit_manager().add_incident( + scenario_name, + scenario.get("severity", "HIGH"), + boundary_context=f"OSS analysis via {boundaries['oss']['label']}" + ) # Update incident table incident_table_data = get_audit_manager().get_incident_table() @@ -951,12 +1478,15 @@ async def run_true_arf_analysis(scenario_name: str): "novel_execution": novel_execution, "rollback_guarantee": rollback_guarantee, "agents_executed": ["Detection", "Recall", "Decision"], + "boundary_context": f"Analysis via {boundaries['oss']['label']}", + "execution_boundary": f"Execution requires {boundaries['enterprise']['label']}", "findings": [ f"Anomaly detected with {detection_confidence:.1%} confidence", f"{similar_count} similar incidents found in RAG memory", f"Historical success rate for similar actions: {success_rate:.1%}", f"True ARF OSS package used: βœ… Yes", - f"Enterprise features available: {'βœ… Simulated' if enterprise_simulated else '❌ Not installed'}" + f"Enterprise features available: {'βœ… Simulated' if enterprise_simulated else '❌ Not installed'}", + f"Architectural boundary: OSS advises β†’ Enterprise executes" ], "recommendations": [ "Scale resources based on historical patterns", @@ -965,7 +1495,8 @@ async def run_true_arf_analysis(scenario_name: str): f"Rollback guarantee: {rollback_guarantee}", "Upgrade to Enterprise for autonomous execution" ], - "healing_intent": decision_data + "healing_intent": decision_data, + "architectural_note": "This is the OSS advisory boundary. Execution requires Enterprise edition." } else: # Mock fallback @@ -986,52 +1517,48 @@ async def run_true_arf_analysis(scenario_name: str): "scenario": scenario_name, "confidence": decision_confidence, "agents_executed": ["Detection", "Recall", "Decision"], + "boundary_context": "Mock analysis - real ARF OSS not installed", + "execution_boundary": "Execution requires Enterprise edition", "findings": [ f"Anomaly detected with {detection_confidence:.1%} confidence", f"{similar_count} similar incidents found in RAG memory", f"Historical success rate for similar actions: {success_rate:.1%}", f"Detection time: {detection_time_seconds} seconds", - f"Install agentic-reliability-framework==3.3.7 for true OSS analysis" + f"Install agentic-reliability-framework==3.3.7 for true OSS analysis", + f"Architectural boundary: OSS advises β†’ Enterprise executes" ], "recommendations": [ "Scale resources based on historical patterns", "Implement circuit breaker pattern", "Add enhanced monitoring for key metrics", - "Install true ARF OSS package for production use" + "Install true ARF OSS package for production use", + "Upgrade to Enterprise for autonomous execution" ], "healing_intent": healing_intent, - "install_command": "pip install agentic-reliability-framework==3.3.7" + "install_command": "pip install agentic-reliability-framework==3.3.7", + "architectural_note": "Mock mode demonstrates the architecture. Real OSS provides advisory intelligence." } - # Create agent HTML with real ARF indicators - detection_html = create_agent_html( + # Create agent HTML with clear boundary indicators using BoundaryManager + detection_html = BoundaryManager.create_agent_with_boundary( agent_name="Detection", status=f"Anomaly detected: {detection_confidence:.1%} confidence", - metrics=f""" - Response: {detection_time_seconds:.1f}s - True ARF: {'βœ…' if true_oss_used else '⚠️'} - """, - is_real_arf=true_oss_used + is_real_arf=true_oss_used, + confidence=detection_confidence ) - recall_html = create_agent_html( + recall_html = BoundaryManager.create_agent_with_boundary( agent_name="Recall", status=f"{similar_count} similar incidents found in RAG memory", - metrics=f""" - Recall: 92% - Patterns: {similar_count} - """, - is_real_arf=true_oss_used + is_real_arf=true_oss_used, + confidence=0.92 # Default recall confidence ) - decision_html = create_agent_html( + decision_html = BoundaryManager.create_agent_with_boundary( agent_name="Decision", status=f"Generating healing intent with {decision_confidence:.1%} confidence", - metrics=f""" - Success Rate: {success_rate:.1%} - Enterprise: {'βœ…' if enterprise_simulated else '⚠️'} - """, - is_real_arf=true_oss_used + is_real_arf=true_oss_used, + confidence=decision_confidence ) logger.info(f"Analysis completed successfully for {scenario_name} (True ARF: {real_arf_version})") @@ -1043,23 +1570,22 @@ async def run_true_arf_analysis(scenario_name: str): except Exception as e: logger.error(f"Analysis failed: {e}", exc_info=True) - # Return error state with proper HTML - error_html = f""" -
-
❌
-
-

Analysis Failed

-

Error: {str(e)[:80]}...

-
ERROR
-
-
- """ + # Return error state with boundary context + boundaries = BoundaryManager.get_system_boundaries() + + error_html = BoundaryManager.create_agent_with_boundary( + agent_name="Error", + status=f"Analysis failed: {str(e)[:80]}...", + is_real_arf=False, + confidence=0.0 + ) error_results = { "status": "❌ Analysis Failed", "error": str(e), "scenario": scenario_name, - "suggestion": "Check logs and try again" + "boundary_context": f"OSS advisory via {boundaries['oss']['label']}", + "suggestion": "Check logs and try again. Ensure ARF OSS is installed for real analysis." } return ( @@ -1067,76 +1593,30 @@ async def run_true_arf_analysis(scenario_name: str): error_results, [] ) -def create_agent_html(agent_name: str, status: str, metrics: str, is_real_arf: bool = True): - """Create agent HTML with real ARF indicators""" - icons = { - "Detection": "πŸ•΅οΈβ€β™‚οΈ", - "Recall": "🧠", - "Decision": "🎯" - } - - real_arf_badge = """ - - βœ… REAL ARF - - """ if is_real_arf else """ - - ⚠️ MOCK - - """ - - return f""" -
- {real_arf_badge} -
{icons.get(agent_name, 'πŸ€–')}
-
-

{agent_name} Agent

-

{status}

-
- {metrics} -
-
- {'ACTIVE (REAL)' if is_real_arf else 'MOCK'} -
-
-
- """ - # =========================================== -# ENTERPRISE EXECUTION HANDLER +# ENTERPRISE EXECUTION HANDLER - ENHANCED WITH BOUNDARY CLARITY # =========================================== def execute_enterprise_healing(scenario_name, approval_required, mcp_mode_value): - """Execute enterprise healing with true ARF simulation""" + """Execute enterprise healing with clear boundary indicators""" import gradio as gr scenario = get_components()["INCIDENT_SCENARIOS"].get(scenario_name, {}) + boundaries = BoundaryManager.get_system_boundaries() # Determine mode mode = "Approval" if approval_required else "Autonomous" # OSS can't execute in any mode - only advisory - if "Advisory" in mcp_mode_value: - approval_html = """ -
-
-

❌ OSS Boundary

- OSS ONLY -
-

ARF OSS v3.3.7 is advisory-only. Cannot execute in Advisory mode.

-

Upgrade to Enterprise for:

-
    -
  • Autonomous execution
  • -
  • Novel execution protocols
  • -
  • Rollback guarantees
  • -
  • Deterministic confidence
  • -
-
- """ + if "Advisory" in mcp_mode_value or boundaries["oss"]["available"] and not boundaries["enterprise"]["available"]: + # Show clear OSS boundary + approval_html = BoundaryManager.create_boundary_indicator( + "Scale Redis cluster from 3 to 5 nodes", + is_simulated=True + ) + enterprise_results = { - "status": "❌ OSS Boundary", - "error": "ARF OSS v3.3.7 is advisory-only. Upgrade to Enterprise for execution.", + "status": "❌ OSS Boundary Reached", + "error": f"{boundaries['oss']['label']} is advisory-only. Cannot execute in Advisory mode.", "requires_enterprise": True, "enterprise_features_required": [ "autonomous_execution", @@ -1145,6 +1625,7 @@ def execute_enterprise_healing(scenario_name, approval_required, mcp_mode_value) "deterministic_confidence", "enterprise_mcp_server" ], + "boundary_note": f"Architectural boundary: {boundaries['oss']['label']} advises β†’ {boundaries['enterprise']['label']} executes", "contact": "sales@arf.dev" } execution_table_data = get_audit_manager().get_execution_table() @@ -1155,13 +1636,16 @@ def execute_enterprise_healing(scenario_name, approval_required, mcp_mode_value) revenue_loss = impact.get("revenue_loss_per_hour", get_scenario_impact(scenario_name)) savings = int(revenue_loss * 0.85) - # Add to audit trail - get_audit_manager().add_execution(scenario_name, mode, savings=savings) + # Add to audit trail with boundary context + get_audit_manager().add_execution( + scenario_name, mode, savings=savings, + boundary_note=f"Crossed OSSβ†’Enterprise boundary via {boundaries['enterprise']['label']}" + ) # Get orchestrator for execution simulation orchestrator = get_components()["DemoOrchestrator"]() - # Create approval display + # Create approval display with boundary clarity if approval_required: approval_html = f"""
@@ -1174,13 +1658,25 @@ def execute_enterprise_healing(scenario_name, approval_required, mcp_mode_value)

Mode: Enterprise Approval

Action: Scale Redis cluster from 3 to 5 nodes

Estimated Savings: ${savings:,}

+ +
-
βœ… 1. ARF generated intent (94% confidence)
-
⏳ 2. Awaiting human review (Enterprise feature)
-
3. ARF Enterprise will execute upon approval
+
+ βœ… 1. OSS Analysis Complete ({boundaries['oss']['label']}) +
+
+ ⏳ 2. Awaiting human review ({boundaries['enterprise']['label']}) +
+
+ 3. {boundaries['enterprise']['label']} will execute upon approval +
+
-

Enterprise Features Used: Approval workflows, Audit trail, Compliance checks

+

+ Architecture: {boundaries['oss']['label']} β†’ {boundaries['enterprise']['label']}
+ Boundary: Advisory analysis β†’ Approval workflow β†’ Execution +

@@ -1192,6 +1688,11 @@ def execute_enterprise_healing(scenario_name, approval_required, mcp_mode_value) "scenario": scenario_name, "timestamp": datetime.datetime.now().isoformat(), "enterprise": True, + "boundary_progression": [ + f"OSS advisory complete ({boundaries['oss']['label']})", + f"Enterprise approval pending ({boundaries['enterprise']['label']})", + "Execution queued upon approval" + ], "actions_queued": [ "Scale resources based on ML recommendations", "Implement circuit breaker pattern", @@ -1216,7 +1717,8 @@ def execute_enterprise_healing(scenario_name, approval_required, mcp_mode_value) "audit_trail", "compliance_reporting", "enhanced_safety" - ] + ], + "architectural_note": f"Clear boundary: {boundaries['oss']['label']} advises β†’ {boundaries['enterprise']['label']} executes with approval" } else: # Try to execute with true ARF simulation @@ -1239,13 +1741,25 @@ def execute_enterprise_healing(scenario_name, approval_required, mcp_mode_value)

Action Executed: Scaled Redis cluster from 3 to 5 nodes

Recovery Time: 12 minutes (vs 45 min manual)

Cost Saved: ${savings:,}

+ +
-
βœ… 1. ARF generated intent
-
βœ… 2. Safety checks passed (Enterprise)
-
βœ… 3. Autonomous execution completed (Enterprise+)
+
+ βœ… 1. {boundaries['oss']['label']} generated intent +
+
+ βœ… 2. Safety checks passed ({boundaries['enterprise']['label']}) +
+
+ βœ… 3. Autonomous execution completed ({boundaries['enterprise']['label']}+) +
+
-

Enterprise+ Features Used: Novel execution protocols, Rollback guarantees, Deterministic confidence, Business-aware execution

+

+ Architecture Executed: {boundaries['oss']['label']} β†’ {boundaries['enterprise']['label']}
+ Boundary Crossed: Advisory β†’ Autonomous execution +

@@ -1257,6 +1771,7 @@ def execute_enterprise_healing(scenario_name, approval_required, mcp_mode_value) "scenario": scenario_name, "timestamp": datetime.datetime.now().isoformat(), "enterprise": True, + "boundary_crossed": f"OSS β†’ {boundaries['enterprise']['label']}", "actions_executed": [ "βœ… Scaled resources based on ML recommendations", "βœ… Implemented circuit breaker pattern", @@ -1280,7 +1795,8 @@ def execute_enterprise_healing(scenario_name, approval_required, mcp_mode_value) "novel_execution_protocols", "rollback_guarantees", "business_aware_execution" - ]) + ]), + "architectural_result": f"Successfully crossed OSSβ†’Enterprise boundary: {boundaries['oss']['label']} advised β†’ {boundaries['enterprise']['label']} executed" } else: # Execution failed @@ -1293,7 +1809,9 @@ def execute_enterprise_healing(scenario_name, approval_required, mcp_mode_value)

Scenario: {scenario_name}

Error: {execution_result.get('message', 'Unknown error')}

-

This is a simulation. Real Enterprise execution requires arf_enterprise package.

+

+ Boundary Context: This is a simulation. Real {boundaries['enterprise']['label']} execution requires infrastructure access. +

""" @@ -1306,7 +1824,8 @@ def execute_enterprise_healing(scenario_name, approval_required, mcp_mode_value) "error": execution_result.get("message", "Unknown error"), "simulation": True, "requires_real_enterprise": True, - "suggestion": "Install arf_enterprise package for real execution" + "boundary_context": f"Simulated execution of {boundaries['enterprise']['label']} - real execution requires production infrastructure", + "suggestion": f"Install arf_enterprise package for real {boundaries['enterprise']['label']} execution" } except Exception as e: @@ -1320,7 +1839,9 @@ def execute_enterprise_healing(scenario_name, approval_required, mcp_mode_value)

Scenario: {scenario_name}

Error: {str(e)}

-

This is a simulation. Real execution requires Enterprise license.

+

+ Boundary Context: Failed at OSS→Enterprise boundary. Real execution requires {boundaries['enterprise']['label']} license. +

""" @@ -1333,7 +1854,8 @@ def execute_enterprise_healing(scenario_name, approval_required, mcp_mode_value) "error": str(e), "simulation": True, "requires_enterprise": True, - "suggestion": "Contact sales@arf.dev for Enterprise trial" + "boundary_context": f"Failed crossing OSSβ†’{boundaries['enterprise']['label']} boundary", + "suggestion": f"Contact sales@arf.dev for {boundaries['enterprise']['label']} trial" } # Update execution table @@ -1342,10 +1864,10 @@ def execute_enterprise_healing(scenario_name, approval_required, mcp_mode_value) return gr.HTML.update(value=approval_html), enterprise_results, execution_table_data # =========================================== -# ROI CALCULATION FUNCTION +# ROI CALCULATION FUNCTION - ENHANCED WITH BOUNDARY CONTEXT # =========================================== def calculate_roi(scenario_name, monthly_incidents, team_size): - """Calculate ROI""" + """Calculate ROI with boundary context""" try: logger.info(f"Calculating ROI for {scenario_name}") @@ -1356,6 +1878,9 @@ def calculate_roi(scenario_name, monthly_incidents, team_size): # Get scenario-specific impact avg_impact = get_scenario_impact(scenario_name) + # Get boundary context + boundaries = BoundaryManager.get_system_boundaries() + # Calculate ROI roi_calculator = get_components()["EnhancedROICalculator"] roi_result = roi_calculator.calculate_comprehensive_roi( @@ -1367,16 +1892,31 @@ def calculate_roi(scenario_name, monthly_incidents, team_size): # Extract ROI multiplier for visualization roi_multiplier = extract_roi_multiplier(roi_result) - # Create visualization + # Add boundary context to ROI result + if "summary" in roi_result: + roi_result["summary"]["boundary_context"] = ( + f"Based on {boundaries['oss']['label']} analysis + " + f"{boundaries['enterprise']['label']} simulated execution" + ) + roi_result["summary"]["architecture"] = "OSS advises β†’ Enterprise executes" + + # Create visualization with boundary context viz_engine = get_components()["EnhancedVisualizationEngine"] - chart = viz_engine.create_executive_dashboard({"roi_multiplier": roi_multiplier}) + is_real_arf = boundaries["oss"]["available"] + chart = viz_engine.create_executive_dashboard( + {"roi_multiplier": roi_multiplier}, + is_real_arf=is_real_arf + ) return roi_result, chart except Exception as e: logger.error(f"ROI calculation error: {e}") - # Provide fallback results + # Get boundary context for fallback + boundaries = BoundaryManager.get_system_boundaries() + + # Provide fallback results with boundary context fallback_result = { "status": "βœ… Calculated Successfully", "summary": { @@ -1385,21 +1925,28 @@ def calculate_roi(scenario_name, monthly_incidents, team_size): "enterprise_cost": "$625,000", "roi_multiplier": "5.2Γ—", "payback_months": "6.0", - "annual_roi_percentage": "420%" - } + "annual_roi_percentage": "420%", + "boundary_context": f"Based on {boundaries['oss']['label']} + {boundaries['enterprise']['label']} simulation", + "architecture": "OSS advises β†’ Enterprise executes" + }, + "note": "Using demo calculation - real ROI varies by organization" } - # Always return a valid chart + # Always return a valid chart with boundary context viz_engine = get_components()["EnhancedVisualizationEngine"] - fallback_chart = viz_engine.create_executive_dashboard({"roi_multiplier": 5.2}) + is_real_arf = boundaries["oss"]["available"] + fallback_chart = viz_engine.create_executive_dashboard( + {"roi_multiplier": 5.2}, + is_real_arf=is_real_arf + ) return fallback_result, fallback_chart # =========================================== -# CREATE DEMO INTERFACE - FIXED FOR GRADIO 6.0 +# CREATE DEMO INTERFACE - ENHANCED WITH BOUNDARY AWARENESS # =========================================== def create_demo_interface(): - """Create demo interface using modular components""" + """Create demo interface using modular components with boundary awareness""" import gradio as gr @@ -1413,17 +1960,23 @@ def create_demo_interface(): global _demo_css _demo_css = css_styles + # Get boundary badges for the interface + boundary_badges = BoundaryManager.get_boundary_badges() + # Create interface without css parameter (will be added in launch) with gr.Blocks( title=f"πŸš€ ARF Investor Demo v3.8.0 - TRUE ARF v3.3.7" ) as demo: - # Header - Updated to show true ARF version + # Header - Updated to show true ARF version and boundaries header_html = components["create_header"]("3.3.7", settings.use_true_arf) - # Status bar + # Status bar with boundary badges status_html = components["create_status_bar"]() + # Add boundary badges as a separate element + boundary_display = gr.HTML(value=boundary_badges, visible=settings.show_boundaries) + # ============ 5 TABS ============ with gr.Tabs(elem_classes="tab-nav"): @@ -1469,9 +2022,9 @@ def create_demo_interface(): outputs=[scenario_card, telemetry_viz, impact_viz, timeline_viz] ) - # Run OSS Analysis - Now uses TRUE ARF v3.3.7 + # Run OSS Analysis - Now uses TRUE ARF v3.3.7 with boundary awareness oss_btn.click( - fn=run_true_arf_analysis, # Updated function name + fn=run_true_arf_analysis, # Updated function with boundary awareness inputs=[scenario_dropdown], outputs=[ detection_agent, recall_agent, decision_agent, @@ -1479,24 +2032,24 @@ def create_demo_interface(): ] ) - # Execute Enterprise Healing - Updated for true ARF + # Execute Enterprise Healing - Updated with boundary clarity enterprise_btn.click( fn=execute_enterprise_healing, inputs=[scenario_dropdown, approval_toggle, mcp_mode], outputs=[approval_display, enterprise_results_display, execution_table] ) - # Run Complete Demo + # Run Complete Demo with boundary progression @AsyncRunner.async_to_sync async def run_complete_demo_async(scenario_name): - """Run a complete demo walkthrough with true ARF""" + """Run a complete demo walkthrough with true ARF and boundary awareness""" # Step 1: Update scenario update_result = update_scenario_display(scenario_name) # Step 2: Run true ARF analysis oss_result = await run_true_arf_analysis(scenario_name) - # Step 3: Execute Enterprise (simulation) + # Step 3: Execute Enterprise (simulation) with boundary context await asyncio.sleep(1) scenario = components["INCIDENT_SCENARIOS"].get(scenario_name, {}) @@ -1504,6 +2057,9 @@ def create_demo_interface(): revenue_loss = impact.get("revenue_loss_per_hour", get_scenario_impact(scenario_name)) savings = int(revenue_loss * 0.85) + # Get boundary context + boundaries = BoundaryManager.get_system_boundaries() + # Get orchestrator for execution simulation orchestrator = components["DemoOrchestrator"]() execution_result = await orchestrator.execute_healing(scenario_name, "autonomous") @@ -1514,13 +2070,13 @@ def create_demo_interface(): "arf_version": "3.3.7", "true_oss_used": True, "enterprise_simulated": True, - "steps_completed": [ - "1. Incident detected - TRUE ARF OSS", - "2. OSS analysis completed - TRUE ARF OSS", - "3. HealingIntent created - TRUE ARF OSS", - "4. Enterprise license validated (simulation)", - "5. Autonomous execution simulated (Enterprise+)", - "6. Outcome recorded in RAG memory" + "boundary_progression": [ + f"1. Incident detected - {boundaries['oss']['label']}", + f"2. OSS analysis completed - {boundaries['oss']['label']}", + f"3. HealingIntent created - {boundaries['oss']['label']}", + f"4. Enterprise license validated ({boundaries['enterprise']['label']})", + f"5. Autonomous execution simulated ({boundaries['enterprise']['label']}+)", + f"6. Outcome recorded in RAG memory" ], "execution_result": execution_result, "outcome": { @@ -1530,39 +2086,153 @@ def create_demo_interface(): "users_protected": "45,000", "learning": "Pattern added to RAG memory" }, - "value_proposition": "This demonstrates the complete ARF v3.3.7 value proposition: OSS for advisory analysis + Enterprise for autonomous execution" + "architectural_summary": f"This demonstrates the complete ARF v3.3.7 architecture: {boundaries['oss']['label']} for advisory analysis β†’ {boundaries['enterprise']['label']} for autonomous execution" } - # Create demo completion message + # Create demo completion message with enhanced boundary context demo_message = f""" -
-
-

βœ… Demo Complete with TRUE ARF v3.3.7

- SUCCESS +
+ + +
+
+

+ βœ… Complete Demo: Architecture Validated +

+

+ ARF v3.3.7 β€’ OSS advises β†’ Enterprise executes +

+
+
+ + BOUNDARY VALIDATED + +
+
+ + +
+ +
+
+ + {boundaries['oss']['label']} +
+
+ β€’ Anomaly detected in 45s
+ β€’ 3 similar incidents recalled
+ β€’ 94% confidence healing plan
+ β€’ Apache 2.0 license validated +
+
+ + +
+
+ + {boundaries['enterprise']['label']} +
+
+ β€’ Autonomous execution simulated
+ β€’ Rollback guarantee: 100%
+ β€’ 12min vs 45min recovery
+ β€’ ${savings:,} saved +
+
+
+ + +
+
+ πŸ—οΈ Architecture Flow +
+
+ +
+
OSS Advisory
+
Apache 2.0
+
+ + +
+
+
+ advises
-
-

Scenario: {scenario_name}

-

Workflow: OSS Analysis β†’ Enterprise Execution

-

Time Saved: 33 minutes (73% faster)

-

Cost Avoided: ${savings:,}

-
-

- True ARF v3.3.7 Showcase:
- β€’ OSS: agentic-reliability-framework==3.3.7 (advisory)
- β€’ Enterprise: arf_enterprise (autonomous execution)
- β€’ Clear boundary: OSS advises, Enterprise executes -

-
+
+ + +
+
Enterprise
+
Commercial
+
+
+
+ + +
+
+
+
Time Saved
+
73%
+
+
+
Cost Saved
+
${savings:,}
+
+
+
ROI Multiplier
+
5.2Γ—
+
+
+
+ + +
+
+
βœ…
+
+
+ Architecture Successfully Validated +
+
+ Clear separation maintained: OSS for advisory intelligence, Enterprise for autonomous execution
- """ +
+
+ + +
+ Ready for production? + Install ARF Enterprise β†’ +
+
+""" + # Combine all results return ( - update_result[0], update_result[1], update_result[2], update_result[3], - oss_result[0], oss_result[1], oss_result[2], - oss_result[3], + *update_result, + *oss_result[:3], # detection_agent, recall_agent, decision_agent + oss_result[3], # oss_results_display + enterprise_results, demo_message, - enterprise_results + incident_table, # Will be updated from oss_result[4] + execution_table ) demo_btn.click( @@ -1571,271 +2241,277 @@ def create_demo_interface(): outputs=[ scenario_card, telemetry_viz, impact_viz, timeline_viz, detection_agent, recall_agent, decision_agent, - oss_results_display, approval_display, enterprise_results_display + oss_results_display, + enterprise_results_display, + approval_display, + incident_table, + execution_table ] ) - # ============ TAB 2 HANDLERS ============ - - def calculate_roi(scenario_name, monthly_incidents, team_size): - """Calculate ROI""" - try: - logger.info(f"Calculating ROI for {scenario_name}") - - # Validate inputs - monthly_incidents = int(monthly_incidents) if monthly_incidents else 15 - team_size = int(team_size) if team_size else 5 - - # Get scenario-specific impact - avg_impact = get_scenario_impact(scenario_name) - - # Calculate ROI - roi_calculator = components["EnhancedROICalculator"] - roi_result = roi_calculator.calculate_comprehensive_roi( - monthly_incidents=monthly_incidents, - avg_impact=float(avg_impact), - team_size=team_size - ) - - # Extract ROI multiplier for visualization - roi_multiplier = extract_roi_multiplier(roi_result) - - # Create visualization - viz_engine = components["EnhancedVisualizationEngine"] - chart = viz_engine.create_executive_dashboard({"roi_multiplier": roi_multiplier}) - - return roi_result, chart - - except Exception as e: - logger.error(f"ROI calculation error: {e}") - - # Provide fallback results - fallback_result = { - "status": "βœ… Calculated Successfully", - "summary": { - "your_annual_impact": "$1,530,000", - "potential_savings": "$1,254,600", - "enterprise_cost": "$625,000", - "roi_multiplier": "5.2Γ—", - "payback_months": "6.0", - "annual_roi_percentage": "420%" - } - } - - # Always return a valid chart - viz_engine = components["EnhancedVisualizationEngine"] - fallback_chart = viz_engine.create_executive_dashboard({"roi_multiplier": 5.2}) - - return fallback_result, fallback_chart - + # ROI Calculation calculate_btn.click( fn=calculate_roi, inputs=[roi_scenario_dropdown, monthly_slider, team_slider], outputs=[roi_output, roi_chart] ) - # ============ TAB 3 HANDLERS ============ - - def validate_license(): - installation = get_installation_status() - return { - "status": "βœ… OSS Installed" if installation["oss_installed"] else "⚠️ OSS Not Installed", - "tier": "OSS (Apache 2.0)", - "oss_version": installation["oss_version"] or "Not installed", - "enterprise_installed": installation["enterprise_installed"], - "enterprise_version": installation["enterprise_version"] or "Not installed", - "execution_allowed": installation["execution_allowed"], - "recommendations": installation["recommendations"], - "badges": installation["badges"] - } - - def start_trial(): - return { - "status": "πŸ†“ Trial Available", - "tier": "Enterprise Trial", - "expires": "2026-01-30", - "features": ["autonomous_healing", "compliance", "audit_trail", "novel_execution"], - "message": "30-day Enterprise trial available. Contact sales@arf.dev", - "arf_version": "3.3.7", - "license_key": "ARF-TRIAL-DEMO-2026", - "contact": "sales@arf.dev" - } - - def upgrade_license(): - return { - "status": "πŸš€ Upgrade Available", - "current_tier": "OSS", - "next_tier": "Enterprise Plus", - "features_added": ["predictive_scaling", "custom_workflows", "advanced_novel_execution", "rollback_guarantees"], - "cost": "$25,000/year", - "message": "Contact sales@arf.dev for upgrade to Enterprise", - "value_proposition": "OSS advises, Enterprise executes with guarantees" - } - - validate_btn.click(fn=validate_license, outputs=[license_display]) - trial_btn.click(fn=start_trial, outputs=[license_display]) - upgrade_btn.click(fn=upgrade_license, outputs=[license_display]) - - def update_mcp_mode(mode): - installation = get_installation_status() - mode_info = { - "advisory": { - "current_mode": "advisory", - "description": "OSS Edition - Analysis only, no execution", - "features": ["Incident analysis", "RAG similarity", "HealingIntent creation"], - "arf_version": "3.3.7 OSS", - "package": "agentic-reliability-framework==3.3.7", - "license": "Apache 2.0", - "installed": installation["oss_installed"] - }, - "approval": { - "current_mode": "approval", - "description": "Enterprise Edition - Human approval required", - "features": ["All OSS features", "Approval workflows", "Audit trail", "Compliance", "Enhanced healing policies"], - "arf_version": "3.3.7 Enterprise", - "package": "arf_enterprise", - "license": "Commercial", - "installed": installation["enterprise_installed"] - }, - "autonomous": { - "current_mode": "autonomous", - "description": "Enterprise Plus - Fully autonomous healing with novel execution", - "features": ["All approval features", "Auto-execution", "Predictive healing", "ML optimization", "Novel execution protocols"], - "arf_version": "3.3.7 Enterprise+", - "package": "arf_enterprise[plus]", - "license": "Commercial Plus", - "installed": installation["enterprise_installed"] - } - } - return mode_info.get(mode, mode_info["advisory"]) + # Update ROI scenario + roi_scenario_dropdown.change( + fn=lambda x: get_components()["EnhancedROICalculator"]().calculate_comprehensive_roi(), + inputs=[], + outputs=[roi_output] + ) - mcp_mode_tab3.change( - fn=update_mcp_mode, - inputs=[mcp_mode_tab3], - outputs=[mcp_mode_info] + # Update ROI chart + monthly_slider.change( + fn=lambda x, y: calculate_roi(roi_scenario_dropdown.value, x, y)[1], + inputs=[monthly_slider, team_slider], + outputs=[roi_chart] ) - # ============ TAB 4 HANDLERS ============ + team_slider.change( + fn=lambda x, y: calculate_roi(roi_scenario_dropdown.value, x, y)[1], + inputs=[monthly_slider, team_slider], + outputs=[roi_chart] + ) + # Audit Trail Functions def refresh_audit_trail(): - return get_audit_manager().get_execution_table(), get_audit_manager().get_incident_table() + """Refresh audit trail tables""" + return ( + get_audit_manager().get_execution_table(), + get_audit_manager().get_incident_table() + ) def clear_audit_trail(): + """Clear audit trail""" get_audit_manager().clear() - return get_audit_manager().get_execution_table(), get_audit_manager().get_incident_table() + return [], [] def export_audit_trail(): - try: - # Calculate total savings - total_savings = 0 - audit_manager = get_audit_manager() - for e in audit_manager.executions: - if e['savings'] != '$0': - try: - savings_str = e['savings'].replace('$', '').replace(',', '') - total_savings += int(float(savings_str)) - except: - pass - - audit_data = { - "exported_at": datetime.datetime.now().isoformat(), - "executions": audit_manager.executions[:10], - "incidents": audit_manager.incidents[:15], - "summary": { - "total_executions": len(audit_manager.executions), - "total_incidents": len(audit_manager.incidents), - "total_savings": f"${total_savings:,}", - "success_rate": "100%", - "arf_version": "3.3.7", - "edition": "OSS + Enterprise Simulation" - } + """Export audit trail as JSON""" + audit_data = { + "executions": get_audit_manager().executions, + "incidents": get_audit_manager().incidents, + "boundary_crossings": get_audit_manager().boundary_crossings, + "export_time": datetime.datetime.now().isoformat(), + "arf_version": "3.3.7", + "architecture": "OSS advises β†’ Enterprise executes" + } + return json.dumps(audit_data, indent=2) + + refresh_btn.click( + fn=refresh_audit_trail, + inputs=[], + outputs=[execution_table, incident_table] + ) + + clear_btn.click( + fn=clear_audit_trail, + inputs=[], + outputs=[execution_table, incident_table] + ) + + export_btn.click( + fn=export_audit_trail, + inputs=[], + outputs=[export_text] + ) + + # Enterprise Features + def validate_license(): + """Validate enterprise license with boundary context""" + boundaries = BoundaryManager.get_system_boundaries() + + if boundaries["enterprise"]["available"]: + return { + "status": "βœ… Valid License", + "license_type": "Enterprise", + "version": boundaries["enterprise"]["version"], + "expires": "2025-12-31", + "capabilities": boundaries["enterprise"]["capabilities"], + "boundary_context": f"Real {boundaries['enterprise']['label']} detected" + } + else: + return { + "status": "⚠️ Demo Mode", + "license_type": "Simulated", + "version": boundaries["enterprise"]["version"], + "expires": "Demo only", + "capabilities": boundaries["enterprise"]["capabilities"], + "boundary_context": f"Simulating {boundaries['enterprise']['label']} - requires license", + "contact": "sales@arf.dev" } - return json.dumps(audit_data, indent=2) - except Exception as e: - return json.dumps({"error": f"Export failed: {str(e)}"}, indent=2) - refresh_btn.click(fn=refresh_audit_trail, outputs=[execution_table, incident_table]) - clear_btn.click(fn=clear_audit_trail, outputs=[execution_table, incident_table]) - export_btn.click(fn=export_audit_trail, outputs=[export_text]) + validate_btn.click( + fn=validate_license, + inputs=[], + outputs=[license_display] + ) - # ============ INITIALIZATION WITH EMPTY STATES ============ + # Initialize with boundary badges + demo.load( + fn=lambda: boundary_badges, + inputs=[], + outputs=[boundary_display] + ) - # Initialize with empty scenario display + # Load default scenario demo.load( - fn=lambda: ( - # Empty scenario card - """ -
-
-
πŸ”
-

Select a Scenario

-

Choose an incident scenario from the dropdown to begin analysis

-
-
- """, - # Empty telemetry plot - create_empty_plot("Select a scenario to view telemetry"), - # Empty impact plot - create_empty_plot("Select a scenario to view impact"), - # Empty timeline plot - create_empty_plot("Select a scenario to view timeline") - ), + fn=lambda: update_scenario_display(settings.default_scenario), + inputs=[], outputs=[scenario_card, telemetry_viz, impact_viz, timeline_viz] ) - # Initialize dashboard with empty state + # Load ROI data demo.load( - fn=lambda: create_empty_dashboard(), - outputs=[dashboard_output] + fn=lambda: calculate_roi(settings.default_scenario, 15, 5), + inputs=[], + outputs=[roi_output, roi_chart] ) + + logger.info("βœ… Demo interface created successfully with boundary awareness") return demo -# Global variable for CSS -_demo_css = "" - # =========================================== -# MAIN EXECUTION - HUGGING FACE COMPATIBLE +# LAUNCH FUNCTION - UPDATED FOR SPACES COMPATIBILITY # =========================================== -def main(): - """Main entry point - Hugging Face Spaces compatible""" - print("πŸš€ Starting ARF Ultimate Investor Demo v3.8.0 with TRUE ARF v3.3.7...") - print("=" * 70) - - # Check installation status first - installation = get_installation_status() - print(f"πŸ“¦ Package Status:") - print(f" β€’ ARF OSS: {'βœ… v' + installation['oss_version'] if installation['oss_installed'] else '⚠️ Not installed'}") - print(f" β€’ Enterprise: {'βœ… v' + installation['enterprise_version'] if installation['enterprise_installed'] else '⚠️ Not installed'}") - print(f" β€’ Execution Allowed: {'βœ… Yes' if installation['execution_allowed'] else '❌ No (OSS only)'}") - - print(f"πŸ“Š Mode: {settings.arf_mode.upper()}") - print(f"πŸ€– Using TRUE ARF: {settings.use_true_arf}") - print(f"🎯 Default Scenario: {settings.default_scenario}") - print(f"🏒 ARF Version: 3.3.7 with True OSS + Enterprise Simulation") - print("=" * 70) - - if installation["recommendations"]: - print("πŸ’‘ Recommendations:") - for rec in installation["recommendations"]: - print(f" β€’ {rec}") - print("=" * 70) - - import gradio as gr - - # Create and launch demo - demo = create_demo_interface() - - # Hugging Face Spaces compatible launch WITH CSS for Gradio 6.0 - demo.launch( - server_name="0.0.0.0", - server_port=7860, - share=False, - show_error=True, # Show errors in UI - css=_demo_css # CSS parameter moved here for Gradio 6.0 - ) - +def launch_demo(): + """Launch the demo application with proper configuration""" + try: + logger.info("πŸš€ Starting ARF Ultimate Investor Demo v3.8.0 - ENTERPRISE EDITION") + logger.info(f"πŸ“Š Settings: mode={settings.arf_mode}, use_true_arf={settings.use_true_arf}") + + # Check installation and show boundaries + installation = get_installation_status() + boundaries = BoundaryManager.get_system_boundaries() + + logger.info("=" * 60) + logger.info("πŸ—οΈ SYSTEM ARCHITECTURE BOUNDARIES:") + logger.info(f" OSS: {boundaries['oss']['label']} v{boundaries['oss']['version']}") + logger.info(f" Enterprise: {boundaries['enterprise']['label']} v{boundaries['enterprise']['version']}") + logger.info(f" Mode: {boundaries['demo_mode']['architecture']}") + logger.info(f" Honesty: {boundaries['demo_mode']['honesty_level']}") + logger.info("=" * 60) + + if installation["oss_installed"]: + logger.info("βœ… True ARF OSS detected - using real v3.3.7 integration") + else: + logger.warning("⚠️ ARF OSS not installed - using enhanced mock mode") + logger.info("πŸ’‘ Install: pip install agentic-reliability-framework==3.3.7") + + if installation["enterprise_installed"]: + logger.info("πŸš€ ARF Enterprise detected - real autonomous execution available") + else: + logger.info("🎭 Enterprise not installed - simulating autonomous execution") + logger.info("πŸ’‘ Contact sales@arf.dev for Enterprise trial") + + # Create interface + demo = create_demo_interface() + + # Get CSS styles from components + components = get_components() + css_styles = components["get_styles"]() + + # Configure Gradio launch for Hugging Face Spaces + launch_config = { + "server_name": "0.0.0.0", + "server_port": 7860, + "share": False, # Spaces handles sharing + "favicon_path": None, + "auth": None, + "auth_message": None, + "ssl_verify": True, + "ssl_keyfile": None, + "ssl_certfile": None, + "quiet": False, + "show_error": True, + "debug": False, + "enable_queue": True, + "max_threads": 40, + "theme": "default", + "dark": False, + "show_api": False, + "allowed_paths": None, + "blocked_paths": None, + "app_kwargs": {}, + "root_path": "", + } + + # Update with CSS + if css_styles: + launch_config["css"] = css_styles + + logger.info("βœ… Launch configuration ready") + logger.info("🌐 Starting web server...") + + return demo, launch_config + + except Exception as e: + logger.error(f"❌ Launch failed: {e}", exc_info=True) + + # Create minimal fallback interface + import gradio as gr + + with gr.Blocks(title="ARF Demo - Fallback Mode") as fallback_demo: + gr.HTML(""" +
+

🚨 ARF Demo Failed to Start

+

Error: """ + str(e) + """

+
+

Troubleshooting Steps:

+
    +
  1. Check logs for detailed error
  2. +
  3. Ensure all dependencies are installed
  4. +
  5. Try: pip install agentic-reliability-framework==3.3.7
  6. +
  7. Restart the application
  8. +
+
+
+ """) + + return fallback_demo, {"server_name": "0.0.0.0", "server_port": 7860} -# Hugging Face Spaces entry point +# =========================================== +# MAIN EXECUTION +# =========================================== if __name__ == "__main__": - main() \ No newline at end of file + try: + logger.info("πŸš€ ARF Ultimate Investor Demo v3.8.0 - ENTERPRISE EDITION") + logger.info("=" * 60) + logger.info("Enhanced version with clear boundaries and reliable visualizations") + logger.info("Fixed to show clear OSS vs Enterprise boundaries with architectural honesty") + logger.info("=" * 60) + + # Launch the demo + demo, config = launch_demo() + + # Show startup message + print("\n" + "="*60) + print("πŸš€ ARF Ultimate Investor Demo v3.8.0 - ENTERPRISE EDITION") + print("πŸ“Š Architecture: OSS advises β†’ Enterprise executes") + print("🌐 Starting on http://localhost:7860") + print("="*60 + "\n") + + # Launch with error handling + try: + demo.launch(**config) + except Exception as launch_error: + logger.error(f"❌ Launch error: {launch_error}") + + # Try alternative launch without CSS + if "css" in config: + logger.info("⚠️ Retrying without CSS...") + config.pop("css", None) + demo.launch(**config) + else: + # Last resort: simple launch + demo.launch(server_name="0.0.0.0", server_port=7860) + + except KeyboardInterrupt: + logger.info("πŸ‘‹ Demo stopped by user") + except Exception as e: + logger.error(f"❌ Fatal error: {e}", exc_info=True) + sys.exit(1) \ No newline at end of file