File size: 10,893 Bytes
7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 666a364 7ebbb94 666a364 7ebbb94 666a364 7ebbb94 666a364 7ebbb94 9df0ac4 7ebbb94 666a364 7ebbb94 666a364 7ebbb94 666a364 7ebbb94 666a364 7ebbb94 666a364 7ebbb94 9df0ac4 7ebbb94 9df0ac4 7ebbb94 9df0ac4 7ebbb94 666a364 3f5fadf 7ebbb94 9df0ac4 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 f61cb1c 7ebbb94 3f5fadf 7ebbb94 666a364 7ebbb94 666a364 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 3f5fadf 7ebbb94 666a364 7ebbb94 666a364 7ebbb94 7587a30 7ebbb94 666a364 7587a30 7ebbb94 7587a30 3f5fadf 7ebbb94 3f5fadf 5eed037 7342596 7ebbb94 7342596 5eed037 7ebbb94 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | # agentic_reliability_framework/app.py (OSS-ONLY VERSION)
"""
Agentic Reliability Framework - OSS Edition DEMO
Demo application showing OSS advisory capabilities
NOTES:
- OSS edition: Advisory only, no execution
- HealingIntent creation only, no execution
- In-memory storage only, no persistence
"""
import asyncio
import datetime
import logging
import sys
from typing import Optional, Dict, Any
import gradio as gr
import numpy as np
# Import OSS components directly
from agentic_reliability_framework.arf_core.models.healing_intent import (
HealingIntent,
create_rollback_intent,
create_restart_intent,
create_scale_out_intent,
)
from agentic_reliability_framework.arf_core.engine.simple_mcp_client import OSSMCPClient
logger = logging.getLogger(__name__)
# ============================================================================
# DEMO SCENARIOS FOR OSS EDITION
# ============================================================================
DEMO_SCENARIOS = {
"π OSS Demo - Latency Spike": {
"component": "api-service",
"latency": 250.0,
"error_rate": 0.15,
"story": """
**OSS ADVISORY DEMO: Latency Spike Detection**
This is the OSS edition showing advisory capabilities only.
π **What OSS detects:**
- Latency spike from 85ms to 250ms (294% increase)
- Error rate at 15% (above 5% threshold)
- Pattern matches historical incidents
π€ **What OSS recommends:**
- Create HealingIntent for container restart
- Confidence: 85% (based on similar incidents)
- Advisory only - requires Enterprise for execution
πΌ **Enterprise Upgrade Benefits:**
- Autonomous execution of HealingIntent
- Approval workflows for safety
- Learning engine for continuous improvement
- Persistent storage for incident history
"""
},
"π OSS Demo - Error Rate Increase": {
"component": "database-service",
"latency": 120.0,
"error_rate": 0.25,
"story": """
**OSS ADVISORY DEMO: Error Rate Analysis**
OSS edition analyzes patterns and creates HealingIntent.
π **OSS Analysis:**
- Error rate at 25% (critical threshold: 15%)
- Moderate latency increase
- Database connection pattern detected
π€ **OSS Recommendation:**
- Create HealingIntent for rollback to previous version
- Confidence: 78% (based on RAG similarity)
- Advisory analysis complete
π **OSS Safety:**
- No execution capability (safety feature)
- Creates intent for Enterprise execution
- Full audit trail when upgraded
"""
},
}
# ============================================================================
# OSS-ONLY APPLICATION LOGIC
# ============================================================================
async def analyze_with_oss(
component: str,
latency: float,
error_rate: float,
scenario_name: str = "OSS Demo"
) -> Dict[str, Any]:
"""
OSS-only analysis: Creates HealingIntent, never executes
This is the core OSS capability: analyze and recommend.
"""
try:
# Create OSS MCP client (advisory only)
client = OSSMCPClient()
# Based on metrics, decide which HealingIntent to create
healing_intent = None
if error_rate > 0.2:
# High error rate β recommend rollback
healing_intent = create_rollback_intent(
component=component,
revision="previous",
justification=f"High error rate ({error_rate*100:.1f}%) detected in {component}",
incident_id=f"oss_demo_{datetime.datetime.now().timestamp()}"
)
action = "rollback"
elif latency > 200:
# High latency β recommend restart
healing_intent = create_restart_intent(
component=component,
justification=f"High latency ({latency:.0f}ms) detected in {component}",
incident_id=f"oss_demo_{datetime.datetime.now().timestamp()}"
)
action = "restart_container"
else:
# Scale out recommendation
healing_intent = create_scale_out_intent(
component=component,
scale_factor=2,
justification=f"Performance degradation in {component}",
incident_id=f"oss_demo_{datetime.datetime.now().timestamp()}"
)
action = "scale_out"
# Get OSS MCP analysis (advisory only)
mcp_result = await client.execute_tool({
"tool": action,
"component": component,
"parameters": {},
"justification": healing_intent.justification,
"metadata": {
"scenario": scenario_name,
"latency": latency,
"error_rate": error_rate,
"oss_edition": True
}
})
return {
"status": "OSS_ADVISORY_COMPLETE",
"healing_intent": healing_intent.to_enterprise_request(),
"oss_analysis": mcp_result,
"confidence": healing_intent.confidence,
"requires_enterprise": True,
"message": f"β
OSS analysis complete. Created HealingIntent for {action} on {component}.",
"enterprise_upgrade_url": "https://arf.dev/enterprise",
"enterprise_features": [
"Autonomous execution",
"Approval workflows",
"Learning engine",
"Persistent storage",
"Audit trails",
"Compliance reporting"
]
}
except Exception as e:
logger.error(f"OSS analysis error: {e}", exc_info=True)
return {
"status": "OSS_ERROR",
"message": f"β OSS analysis failed: {str(e)}",
"requires_enterprise": False
}
# ============================================================================
# SIMPLE OSS DEMO UI
# ============================================================================
def create_oss_demo_ui():
"""Create simple OSS demo UI"""
with gr.Blocks(title="π§ ARF OSS Edition - Advisory Demo", theme="soft") as demo:
gr.Markdown("""
# π§ Agentic Reliability Framework - OSS Edition
**Advisory Analysis Only - Apache 2.0 Licensed**
_OSS creates HealingIntent recommendations. Enterprise executes them._
---
**OSS Capabilities:**
β
Anomaly detection & pattern recognition
β
HealingIntent creation (advisory only)
β
RAG similarity search (in-memory)
β
Safety validation & guardrails
**Enterprise Upgrade Required For:**
π§ Actual tool execution
π Learning from outcomes
πΎ Persistent storage
π Audit trails & compliance
""")
with gr.Row():
with gr.Column(scale=1):
gr.Markdown("### π Demo Input")
scenario = gr.Dropdown(
choices=list(DEMO_SCENARIOS.keys()),
value="π OSS Demo - Latency Spike",
label="Demo Scenario"
)
component = gr.Textbox(
value="api-service",
label="Component",
interactive=True
)
latency = gr.Slider(
minimum=10, maximum=1000, value=250,
label="Latency (ms)",
info="P99 latency in milliseconds"
)
error_rate = gr.Slider(
minimum=0, maximum=1, value=0.15, step=0.01,
label="Error Rate",
info="Error rate (0.0 to 1.0)"
)
analyze_btn = gr.Button("π€ Analyze with OSS", variant="primary")
with gr.Column(scale=2):
gr.Markdown("### π OSS Analysis Results")
scenario_story = gr.Markdown(
value=DEMO_SCENARIOS["π OSS Demo - Latency Spike"]["story"]
)
output = gr.JSON(
label="OSS Analysis Output",
value={}
)
def update_scenario(scenario_name):
"""Update UI when scenario changes"""
scenario_data = DEMO_SCENARIOS.get(scenario_name, {})
return {
scenario_story: gr.update(value=scenario_data.get("story", "")),
component: gr.update(value=scenario_data.get("component", "api-service")),
latency: gr.update(value=scenario_data.get("latency", 100)),
error_rate: gr.update(value=scenario_data.get("error_rate", 0.05)),
}
async def analyze_oss_async(component, latency, error_rate, scenario_name):
"""Async analysis handler"""
result = await analyze_with_oss(component, latency, error_rate, scenario_name)
return result
# Connect events
scenario.change(
fn=update_scenario,
inputs=[scenario],
outputs=[scenario_story, component, latency, error_rate]
)
analyze_btn.click(
fn=analyze_oss_async,
inputs=[component, latency, error_rate, scenario],
outputs=[output]
)
# Footer with upgrade info
gr.Markdown("""
---
**Upgrade to Enterprise Edition:**
| Feature | OSS Edition | Enterprise Edition |
|---------|-------------|-------------------|
| Execution | β Advisory only | β
Autonomous + Approval |
| Storage | β οΈ In-memory only | β
Persistent (Neo4j, PostgreSQL) |
| Learning | β None | β
Continuous learning engine |
| Audit | β None | β
Full audit trails (SOC2, HIPAA) |
| Support | β Community | β
24/7 Enterprise support |
**Contact:** enterprise@petterjuan.com | **Website:** https://arf.dev
""")
return demo
# ============================================================================
# MAIN ENTRY POINT
# ============================================================================
def main():
"""Main entry point for OSS demo"""
logging.basicConfig(level=logging.INFO)
logger.info("=" * 60)
logger.info("Starting ARF OSS Edition - Advisory Demo")
logger.info("=" * 60)
demo = create_oss_demo_ui()
demo.launch(
server_name="0.0.0.0",
server_port=7860,
share=False,
show_error=True
)
if __name__ == "__main__":
main() |