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manager for ARF Demo - Enforces clear separation between real OSS and simulated Enterprise
|
| 4 |
+
Ensures the audience always knows what's real vs simulated
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
import logging
|
| 8 |
+
from typing import Dict, Any, Tuple
|
| 9 |
+
from dataclasses import dataclass
|
| 10 |
+
from enum import Enum
|
| 11 |
+
|
| 12 |
+
logger = logging.getLogger(__name__)
|
| 13 |
+
|
| 14 |
+
class SystemMode(Enum):
|
| 15 |
+
"""Clear system mode definitions"""
|
| 16 |
+
REAL_OSS_ADVISORY = "real_oss_advisory" # Real ARF OSS package
|
| 17 |
+
SIMULATED_ENTERPRISE = "simulated_enterprise" # Enterprise simulation
|
| 18 |
+
MOCK_FALLBACK = "mock_fallback" # Mock when nothing is available
|
| 19 |
+
|
| 20 |
+
@dataclass
|
| 21 |
+
class SystemBoundary:
|
| 22 |
+
"""Clear boundary definition with labels"""
|
| 23 |
+
mode: SystemMode
|
| 24 |
+
real_components: list[str]
|
| 25 |
+
simulated_components: list[str]
|
| 26 |
+
oss_license: str
|
| 27 |
+
enterprise_license: str
|
| 28 |
+
execution_allowed: bool
|
| 29 |
+
|
| 30 |
+
def get_display_labels(self) -> Dict[str, str]:
|
| 31 |
+
"""Get clear display labels for UI"""
|
| 32 |
+
base_labels = {
|
| 33 |
+
"system_mode": self.mode.value,
|
| 34 |
+
"oss_status": f"✅ REAL ARF OSS v3.3.7" if self.mode == SystemMode.REAL_OSS_ADVISORY else "⚠️ MOCK ARF",
|
| 35 |
+
"enterprise_status": f"🎭 SIMULATED Enterprise" if self.mode == SystemMode.SIMULATED_ENTERPRISE else "⚠️ MOCK Enterprise",
|
| 36 |
+
"execution_capability": "Advisory Only (Apache 2.0)" if not self.execution_allowed else "Autonomous Execution (Enterprise)",
|
| 37 |
+
"license_display": f"OSS: {self.oss_license} | Enterprise: {self.enterprise_license}",
|
| 38 |
+
"boundary_note": "OSS advises, Enterprise executes" if self.mode == SystemMode.SIMULATED_ENTERPRISE else "Mock mode for demo"
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
# Add color coding
|
| 42 |
+
if self.mode == SystemMode.REAL_OSS_ADVISORY:
|
| 43 |
+
base_labels.update({
|
| 44 |
+
"oss_color": "#10b981", # Green for real
|
| 45 |
+
"enterprise_color": "#f59e0b", # Amber for simulated
|
| 46 |
+
"oss_icon": "✅",
|
| 47 |
+
"enterprise_icon": "🎭"
|
| 48 |
+
})
|
| 49 |
+
else:
|
| 50 |
+
base_labels.update({
|
| 51 |
+
"oss_color": "#64748b", # Gray for mock
|
| 52 |
+
"enterprise_color": "#64748b", # Gray for mock
|
| 53 |
+
"oss_icon": "⚠️",
|
| 54 |
+
"enterprise_icon": "⚠️"
|
| 55 |
+
})
|
| 56 |
+
|
| 57 |
+
return base_labels
|
| 58 |
+
|
| 59 |
+
class BoundaryManager:
|
| 60 |
+
"""Manages system boundaries and ensures clear labeling"""
|
| 61 |
+
|
| 62 |
+
def __init__(self):
|
| 63 |
+
self.current_boundary = None
|
| 64 |
+
self.installation_status = self._check_installation()
|
| 65 |
+
self._initialize_boundary()
|
| 66 |
+
|
| 67 |
+
def _check_installation(self) -> Dict[str, Any]:
|
| 68 |
+
"""Check what's really installed"""
|
| 69 |
+
# Simplified version - in real app this checks actual packages
|
| 70 |
+
try:
|
| 71 |
+
from core.true_arf_oss import TrueARFOSS
|
| 72 |
+
oss_available = True
|
| 73 |
+
except ImportError:
|
| 74 |
+
oss_available = False
|
| 75 |
+
|
| 76 |
+
try:
|
| 77 |
+
from core.enterprise_simulation import EnterpriseFeatureSimulation
|
| 78 |
+
enterprise_available = True
|
| 79 |
+
except ImportError:
|
| 80 |
+
enterprise_available = False
|
| 81 |
+
|
| 82 |
+
return {
|
| 83 |
+
"oss_available": oss_available,
|
| 84 |
+
"enterprise_available": enterprise_available,
|
| 85 |
+
"true_arf_version": "3.3.7" if oss_available else "mock"
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
def _initialize_boundary(self):
|
| 89 |
+
"""Initialize the system boundary based on what's available"""
|
| 90 |
+
installation = self.installation_status
|
| 91 |
+
|
| 92 |
+
if installation["oss_available"]:
|
| 93 |
+
# Real OSS + Simulated Enterprise
|
| 94 |
+
self.current_boundary = SystemBoundary(
|
| 95 |
+
mode=SystemMode.REAL_OSS_ADVISORY,
|
| 96 |
+
real_components=["TrueARFOSS", "Detection Agent", "Recall Agent", "Decision Agent"],
|
| 97 |
+
simulated_components=["EnterpriseExecution", "RollbackGuarantees", "NovelExecutionProtocols"],
|
| 98 |
+
oss_license="Apache 2.0",
|
| 99 |
+
enterprise_license="SIMULATED (requires Commercial)",
|
| 100 |
+
execution_allowed=False # OSS is advisory only
|
| 101 |
+
)
|
| 102 |
+
logger.info("✅ System initialized with REAL ARF OSS + SIMULATED Enterprise")
|
| 103 |
+
|
| 104 |
+
elif installation["enterprise_available"]:
|
| 105 |
+
# Mock OSS + Simulated Enterprise (unlikely but possible)
|
| 106 |
+
self.current_boundary = SystemBoundary(
|
| 107 |
+
mode=SystemMode.SIMULATED_ENTERPRISE,
|
| 108 |
+
real_components=[],
|
| 109 |
+
simulated_components=["EnterpriseFeatures", "ExecutionProtocols"],
|
| 110 |
+
oss_license="MOCK",
|
| 111 |
+
enterprise_license="SIMULATED",
|
| 112 |
+
execution_allowed=True # Simulated execution
|
| 113 |
+
)
|
| 114 |
+
logger.info("⚠️ System initialized with MOCK OSS + SIMULATED Enterprise")
|
| 115 |
+
|
| 116 |
+
else:
|
| 117 |
+
# Complete mock mode
|
| 118 |
+
self.current_boundary = SystemBoundary(
|
| 119 |
+
mode=SystemMode.MOCK_FALLBACK,
|
| 120 |
+
real_components=[],
|
| 121 |
+
simulated_components=["AllComponents"],
|
| 122 |
+
oss_license="MOCK",
|
| 123 |
+
enterprise_license="MOCK",
|
| 124 |
+
execution_allowed=False
|
| 125 |
+
)
|
| 126 |
+
logger.info("⚠️ System initialized in MOCK FALLBACK mode")
|
| 127 |
+
|
| 128 |
+
def get_boundary_badges(self) -> str:
|
| 129 |
+
"""Get HTML badges showing clear boundaries"""
|
| 130 |
+
labels = self.current_boundary.get_display_labels()
|
| 131 |
+
|
| 132 |
+
return f"""
|
| 133 |
+
<div style="display: flex; justify-content: center; gap: 10px; margin-top: 10px; flex-wrap: wrap;">
|
| 134 |
+
<span style="padding: 4px 12px; background: {labels['oss_color']};
|
| 135 |
+
color: white; border-radius: 20px; font-size: 12px; font-weight: bold;
|
| 136 |
+
display: flex; align-items: center; gap: 6px;">
|
| 137 |
+
{labels['oss_icon']} {labels['oss_status']}
|
| 138 |
+
</span>
|
| 139 |
+
<span style="padding: 4px 12px; background: {labels['enterprise_color']};
|
| 140 |
+
color: white; border-radius: 20px; font-size: 12px; font-weight: bold;
|
| 141 |
+
display: flex; align-items: center; gap: 6px;">
|
| 142 |
+
{labels['enterprise_icon']} {labels['enterprise_status']}
|
| 143 |
+
</span>
|
| 144 |
+
<span style="padding: 4px 12px; background: #3b82f6;
|
| 145 |
+
color: white; border-radius: 20px; font-size: 12px; font-weight: bold;">
|
| 146 |
+
{labels['execution_capability']}
|
| 147 |
+
</span>
|
| 148 |
+
</div>
|
| 149 |
+
"""
|
| 150 |
+
|
| 151 |
+
def get_agent_html(self, agent_name: str, is_real: bool = True, status: str = "Active") -> str:
|
| 152 |
+
"""Get agent HTML with clear boundary indicators"""
|
| 153 |
+
icons = {
|
| 154 |
+
"Detection": "🕵️♂️",
|
| 155 |
+
"Recall": "🧠",
|
| 156 |
+
"Decision": "🎯"
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
real_badge = """
|
| 160 |
+
<div style="position: absolute; top: -8px; right: -8px; padding: 2px 8px; background: #10b981;
|
| 161 |
+
color: white; border-radius: 12px; font-size: 10px; font-weight: bold; z-index: 10;
|
| 162 |
+
border: 2px solid white; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
|
| 163 |
+
REAL ARF
|
| 164 |
+
</div>
|
| 165 |
+
""" if is_real else """
|
| 166 |
+
<div style="position: absolute; top: -8px; right: -8px; padding: 2px 8px; background: #f59e0b;
|
| 167 |
+
color: white; border-radius: 12px; font-size: 10px; font-weight: bold; z-index: 10;
|
| 168 |
+
border: 2px solid white; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
|
| 169 |
+
DEMO MODE
|
| 170 |
+
</div>
|
| 171 |
+
"""
|
| 172 |
+
|
| 173 |
+
border_color = "#10b981" if is_real else "#f59e0b"
|
| 174 |
+
background = "#f0fdf4" if is_real else "#fef3c7"
|
| 175 |
+
|
| 176 |
+
return f"""
|
| 177 |
+
<div style="position: relative;">
|
| 178 |
+
{real_badge}
|
| 179 |
+
<div style="border: 3px solid {border_color}; border-radius: 16px; padding: 20px;
|
| 180 |
+
background: {background}; text-align: center; min-height: 200px;
|
| 181 |
+
display: flex; flex-direction: column; align-items: center; justify-content: center;">
|
| 182 |
+
<div style="font-size: 42px; margin-bottom: 15px; opacity: 0.9;">{icons.get(agent_name, '🤖')}</div>
|
| 183 |
+
<div style="width: 100%;">
|
| 184 |
+
<h4 style="margin: 0 0 10px 0; font-size: 18px; color: #1e293b; font-weight: 600;">{agent_name} Agent</h4>
|
| 185 |
+
<p style="font-size: 14px; color: #475569; margin-bottom: 15px; line-height: 1.5;">
|
| 186 |
+
Status: <strong>{status}</strong><br>
|
| 187 |
+
<span style="font-size: 12px; color: {'#059669' if is_real else '#d97706'}">
|
| 188 |
+
{'Running on REAL ARF OSS v3.3.7' if is_real else 'Running in DEMO MODE'}
|
| 189 |
+
</span>
|
| 190 |
+
</p>
|
| 191 |
+
<div style="display: inline-block; padding: 8px 20px; background: linear-gradient(135deg, {border_color} 0%, {border_color}88 100%);
|
| 192 |
+
border-radius: 20px; font-size: 13px; font-weight: bold; color: white;
|
| 193 |
+
text-transform: uppercase; letter-spacing: 0.5px; margin-top: 10px;">
|
| 194 |
+
{'ACTIVE (REAL)' if is_real else 'SIMULATED'}
|
| 195 |
+
</div>
|
| 196 |
+
</div>
|
| 197 |
+
</div>
|
| 198 |
+
</div>
|
| 199 |
+
"""
|
| 200 |
+
|
| 201 |
+
def get_execution_boundary_html(self, action: str, is_simulated: bool = True) -> str:
|
| 202 |
+
"""Get clear execution boundary indicator"""
|
| 203 |
+
if is_simulated:
|
| 204 |
+
return f"""
|
| 205 |
+
<div style="border: 3px dashed #f59e0b; border-radius: 16px; padding: 25px;
|
| 206 |
+
background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
|
| 207 |
+
text-align: center; margin: 20px 0;">
|
| 208 |
+
<div style="font-size: 36px; margin-bottom: 15px;">🎭</div>
|
| 209 |
+
<h4 style="margin: 0 0 12px 0; font-size: 20px; color: #92400e; font-weight: 700;">
|
| 210 |
+
SIMULATED ENTERPRISE EXECUTION
|
| 211 |
+
</h4>
|
| 212 |
+
<p style="font-size: 15px; color: #92400e; margin-bottom: 15px; line-height: 1.6;">
|
| 213 |
+
<strong>Action:</strong> {action}<br>
|
| 214 |
+
<strong>Mode:</strong> Enterprise Simulation (not real execution)<br>
|
| 215 |
+
<strong>Boundary:</strong> OSS advises → Enterprise would execute
|
| 216 |
+
</p>
|
| 217 |
+
<div style="display: inline-block; padding: 10px 24px; background: #92400e;
|
| 218 |
+
border-radius: 20px; font-size: 14px; font-weight: bold; color: white;
|
| 219 |
+
text-transform: uppercase; letter-spacing: 1px;">
|
| 220 |
+
DEMO BOUNDARY
|
| 221 |
+
</div>
|
| 222 |
+
<p style="font-size: 13px; color: #92400e; margin-top: 15px; font-style: italic;">
|
| 223 |
+
In production, Enterprise edition would execute against real infrastructure
|
| 224 |
+
</p>
|
| 225 |
+
</div>
|
| 226 |
+
"""
|
| 227 |
+
else:
|
| 228 |
+
return f"""
|
| 229 |
+
<div style="border: 3px solid #10b981; border-radius: 16px; padding: 25px;
|
| 230 |
+
background: linear-gradient(135deg, #f0fdf4 0%, #bbf7d0 100%);
|
| 231 |
+
text-align: center; margin: 20px 0;">
|
| 232 |
+
<div style="font-size: 36px; margin-bottom: 15px;">⚡</div>
|
| 233 |
+
<h4 style="margin: 0 0 12px 0; font-size: 20px; color: #065f46; font-weight: 700;">
|
| 234 |
+
REAL ENTERPRISE EXECUTION
|
| 235 |
+
</h4>
|
| 236 |
+
<p style="font-size: 15px; color: #065f46; margin-bottom: 15px; line-height: 1.6;">
|
| 237 |
+
<strong>Action:</strong> {action}<br>
|
| 238 |
+
<strong>Mode:</strong> Enterprise Autonomous<br>
|
| 239 |
+
<strong>Boundary:</strong> Real execution with safety guarantees
|
| 240 |
+
</p>
|
| 241 |
+
<div style="display: inline-block; padding: 10px 24px; background: #065f46;
|
| 242 |
+
border-radius: 20px; font-size: 14px; font-weight: bold; color: white;
|
| 243 |
+
text-transform: uppercase; letter-spacing: 1px;">
|
| 244 |
+
ENTERPRISE+
|
| 245 |
+
</div>
|
| 246 |
+
</div>
|
| 247 |
+
"""
|
| 248 |
+
|
| 249 |
+
def get_demo_narrative(self, phase: str) -> str:
|
| 250 |
+
"""Get narrative text for each demo phase"""
|
| 251 |
+
narratives = {
|
| 252 |
+
"introduction": """
|
| 253 |
+
<div style="background: #f8fafc; border-radius: 12px; padding: 20px; margin: 20px 0; border-left: 4px solid #3b82f6;">
|
| 254 |
+
<h4 style="margin: 0 0 10px 0; color: #1e293b;">🎯 Demo Introduction</h4>
|
| 255 |
+
<p style="margin: 0; color: #475569; font-size: 14px; line-height: 1.6;">
|
| 256 |
+
This demo shows the <strong>clear architectural boundary</strong> between ARF OSS (real advisory intelligence)
|
| 257 |
+
and ARF Enterprise (simulated autonomous execution). We're showing what happens in production,
|
| 258 |
+
not hiding behind mock data.
|
| 259 |
+
</p>
|
| 260 |
+
</div>
|
| 261 |
+
""",
|
| 262 |
+
|
| 263 |
+
"oss_analysis": """
|
| 264 |
+
<div style="background: #f0fdf4; border-radius: 12px; padding: 20px; margin: 20px 0; border-left: 4px solid #10b981;">
|
| 265 |
+
<h4 style="margin: 0 0 10px 0; color: #065f46;">🧠 Real OSS Intelligence</h4>
|
| 266 |
+
<p style="margin: 0; color: #047857; font-size: 14px; line-height: 1.6;">
|
| 267 |
+
ARF OSS v3.3.7 is <strong>analyzing the incident in real-time</strong>. This is not a mock - it's the actual
|
| 268 |
+
ARF OSS package running detection, recall, and decision agents. Notice the confidence scores
|
| 269 |
+
and reasoning chain.
|
| 270 |
+
</p>
|
| 271 |
+
</div>
|
| 272 |
+
""",
|
| 273 |
+
|
| 274 |
+
"enterprise_simulation": """
|
| 275 |
+
<div style="background: #fef3c7; border-radius: 12px; padding: 20px; margin: 20px 0; border-left: 4px solid #f59e0b;">
|
| 276 |
+
<h4 style="margin: 0 0 10px 0; color: #92400e;">🎭 Enterprise Simulation Boundary</h4>
|
| 277 |
+
<p style="margin: 0; color: #b45309; font-size: 14px; line-height: 1.6;">
|
| 278 |
+
This is where we <strong>simulate Enterprise execution</strong>. In production, Enterprise would:
|
| 279 |
+
1. Validate safety constraints, 2. Execute with rollback guarantees, 3. Update the learning engine.
|
| 280 |
+
We're showing the value proposition without real infrastructure access.
|
| 281 |
+
</p>
|
| 282 |
+
</div>
|
| 283 |
+
""",
|
| 284 |
+
|
| 285 |
+
"conclusion": """
|
| 286 |
+
<div style="background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%); border-radius: 12px; padding: 20px; margin: 20px 0; border: 2px solid #3b82f6;">
|
| 287 |
+
<h4 style="margin: 0 0 10px 0; color: #1e293b;">✅ Architecture Validated</h4>
|
| 288 |
+
<p style="margin: 0; color: #475569; font-size: 14px; line-height: 1.6;">
|
| 289 |
+
<strong>What we demonstrated:</strong><br>
|
| 290 |
+
• Real ARF OSS intelligence (advisory)<br>
|
| 291 |
+
• Clear execution boundary (OSS vs Enterprise)<br>
|
| 292 |
+
• Simulated Enterprise value proposition<br>
|
| 293 |
+
• Production-ready architecture pattern<br><br>
|
| 294 |
+
This isn't AI theater - it's a production-grade reliability system with honest boundaries.
|
| 295 |
+
</p>
|
| 296 |
+
</div>
|
| 297 |
+
"""
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
return narratives.get(phase, "")
|
| 301 |
+
|
| 302 |
+
def validate_transition(self, from_mode: SystemMode, to_mode: SystemMode) -> Tuple[bool, str]:
|
| 303 |
+
"""Validate mode transitions (e.g., can't go from mock to real execution)"""
|
| 304 |
+
transitions = {
|
| 305 |
+
(SystemMode.REAL_OSS_ADVISORY, SystemMode.SIMULATED_ENTERPRISE): (True, "Valid: Real OSS to Simulated Enterprise"),
|
| 306 |
+
(SystemMode.MOCK_FALLBACK, SystemMode.SIMULATED_ENTERPRISE): (True, "Valid: Mock to Simulated Enterprise"),
|
| 307 |
+
(SystemMode.SIMULATED_ENTERPRISE, SystemMode.REAL_OSS_ADVISORY): (False, "Invalid: Can't go from Enterprise simulation back to OSS in demo"),
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
result = transitions.get((from_mode, to_mode), (True, "Valid transition"))
|
| 311 |
+
return result
|
| 312 |
+
|
| 313 |
+
# Singleton instance
|
| 314 |
+
_boundary_manager = None
|
| 315 |
+
|
| 316 |
+
def get_boundary_manager() -> BoundaryManager:
|
| 317 |
+
"""Get singleton BoundaryManager instance"""
|
| 318 |
+
global _boundary_manager
|
| 319 |
+
if _boundary_manager is None:
|
| 320 |
+
_boundary_manager = BoundaryManager()
|
| 321 |
+
return _boundary_manager
|