Update hf_demo.py
Browse files- hf_demo.py +331 -1028
hf_demo.py
CHANGED
|
@@ -1,195 +1,113 @@
|
|
| 1 |
"""
|
| 2 |
-
ARF 3.3.9 Demo -
|
|
|
|
| 3 |
"""
|
| 4 |
|
| 5 |
import gradio as gr
|
| 6 |
-
import pandas as pd
|
| 7 |
-
import numpy as np
|
| 8 |
-
from datetime import datetime, timedelta
|
| 9 |
import json
|
| 10 |
import time
|
| 11 |
import uuid
|
| 12 |
import hashlib
|
| 13 |
import random
|
| 14 |
-
import
|
| 15 |
|
| 16 |
print("=" * 70)
|
| 17 |
-
print("🚀 ARF 3.3.9 Demo -
|
| 18 |
print("=" * 70)
|
| 19 |
|
| 20 |
-
|
| 21 |
-
# CORE ENGINE WITH PSYCHOLOGICAL ELEMENTS
|
| 22 |
-
# ============================================================================
|
| 23 |
-
|
| 24 |
-
class ARFEngine:
|
| 25 |
-
"""ARF Engine with psychological optimization"""
|
| 26 |
-
|
| 27 |
def __init__(self):
|
| 28 |
self.stats = {
|
| 29 |
"total_processed": 0,
|
| 30 |
"blocked_actions": 0,
|
| 31 |
"autonomous_executions": 0,
|
| 32 |
-
"avg_processing_time": 0.0
|
| 33 |
-
"history": []
|
| 34 |
-
}
|
| 35 |
-
|
| 36 |
-
# Industry benchmarks for social proof
|
| 37 |
-
self.benchmarks = {
|
| 38 |
-
"risk_reduction": 0.92,
|
| 39 |
-
"decision_speed": 100,
|
| 40 |
-
"false_positives": 0.85,
|
| 41 |
-
"cost_reduction": 0.75,
|
| 42 |
-
"customer_satisfaction": 0.94
|
| 43 |
}
|
| 44 |
-
|
| 45 |
-
# License tiers with psychological pricing
|
| 46 |
-
self.license_tiers = {
|
| 47 |
-
"trial": {
|
| 48 |
-
"name": "14-Day Trial",
|
| 49 |
-
"price": 0,
|
| 50 |
-
"enforcement": "advisory",
|
| 51 |
-
"features": ["Basic gates", "Limited audit", "Email support"],
|
| 52 |
-
"social_proof": "Used by 1,000+ developers",
|
| 53 |
-
"urgency": "⏳ Expires in 14 days"
|
| 54 |
-
},
|
| 55 |
-
"starter": {
|
| 56 |
-
"name": "Starter",
|
| 57 |
-
"price": 2000,
|
| 58 |
-
"enforcement": "human_approval",
|
| 59 |
-
"features": ["Human-in-loop gates", "Basic audit", "SLA 99.5%"],
|
| 60 |
-
"social_proof": "Trusted by 500+ growing companies",
|
| 61 |
-
"value_prop": "Perfect for teams starting with AI safety"
|
| 62 |
-
},
|
| 63 |
-
"professional": {
|
| 64 |
-
"name": "Professional",
|
| 65 |
-
"price": 5000,
|
| 66 |
-
"enforcement": "autonomous",
|
| 67 |
-
"features": ["Autonomous execution", "Advanced gates", "SLA 99.8%"],
|
| 68 |
-
"social_proof": "Preferred by 200+ scale-ups",
|
| 69 |
-
"value_prop": "For companies scaling AI operations"
|
| 70 |
-
},
|
| 71 |
-
"enterprise": {
|
| 72 |
-
"name": "Enterprise",
|
| 73 |
-
"price": 15000,
|
| 74 |
-
"enforcement": "full_mechanical",
|
| 75 |
-
"features": ["Full mechanical enforcement", "Compliance automation", "SLA 99.9%"],
|
| 76 |
-
"social_proof": "Deployed at 50+ Fortune 500 companies",
|
| 77 |
-
"value_prop": "Enterprise-grade AI safety and compliance"
|
| 78 |
-
}
|
| 79 |
-
}
|
| 80 |
-
|
| 81 |
-
print("✅ ARF Engine initialized with psychological optimization")
|
| 82 |
|
| 83 |
-
def assess_action(self, action
|
| 84 |
-
"""Assess
|
| 85 |
start_time = time.time()
|
| 86 |
|
| 87 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
risk_score, confidence = self._calculate_risk(action, context)
|
| 89 |
|
| 90 |
-
# 2.
|
| 91 |
-
policy_result = self.
|
| 92 |
|
| 93 |
-
# 3.
|
| 94 |
license_info = self._validate_license(license_key)
|
| 95 |
|
| 96 |
-
# 4.
|
| 97 |
gate_results = self._evaluate_gates(risk_score, confidence, policy_result, license_info)
|
| 98 |
|
| 99 |
-
# 5. Generate
|
| 100 |
-
|
| 101 |
-
risk_score, policy_result, license_info, gate_results
|
| 102 |
-
)
|
| 103 |
|
| 104 |
processing_time = time.time() - start_time
|
| 105 |
|
| 106 |
-
# Update
|
| 107 |
-
self._update_stats(
|
| 108 |
|
| 109 |
return {
|
| 110 |
"action": action,
|
| 111 |
-
"context": context,
|
| 112 |
"risk_score": risk_score,
|
| 113 |
"confidence": confidence,
|
| 114 |
"policy_result": policy_result,
|
| 115 |
"license_info": license_info,
|
| 116 |
"gate_results": gate_results,
|
| 117 |
-
"
|
| 118 |
"processing_time": processing_time,
|
| 119 |
-
"
|
| 120 |
-
"timestamp": datetime.now().isoformat()
|
| 121 |
}
|
| 122 |
|
| 123 |
-
def _calculate_risk(self, action
|
| 124 |
-
"""Calculate risk
|
| 125 |
action_lower = action.lower()
|
| 126 |
|
| 127 |
-
# Base risk
|
| 128 |
-
|
| 129 |
-
"destructiveness": self._calculate_destructiveness(action_lower),
|
| 130 |
-
"complexity": min(0.8, len(action.split()) * 0.05),
|
| 131 |
-
"environment": 0.8 if context.get("environment") == "production" else 0.3,
|
| 132 |
-
"reversibility": 0.9 if any(x in action_lower for x in ["drop", "truncate"]) else 0.3
|
| 133 |
-
}
|
| 134 |
-
|
| 135 |
-
# Weighted risk score
|
| 136 |
-
weights = {"destructiveness": 0.4, "complexity": 0.2, "environment": 0.3, "reversibility": 0.1}
|
| 137 |
-
risk_score = sum(risk_factors[k] * weights[k] for k in risk_factors)
|
| 138 |
|
| 139 |
-
#
|
| 140 |
if "drop database" in action_lower:
|
| 141 |
-
|
| 142 |
elif "delete from" in action_lower:
|
| 143 |
-
|
| 144 |
-
elif "
|
| 145 |
-
|
| 146 |
-
else:
|
| 147 |
-
confidence = 0.80
|
| 148 |
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
elif "truncate" in action:
|
| 158 |
-
return 0.80
|
| 159 |
-
elif "rm -rf" in action:
|
| 160 |
-
return 0.99
|
| 161 |
-
return 0.3
|
| 162 |
|
| 163 |
-
def
|
| 164 |
-
"""
|
| 165 |
violations = []
|
| 166 |
-
action_lower = action.lower()
|
| 167 |
|
| 168 |
-
|
| 169 |
-
if ("drop" in action_lower or "delete" in action_lower) and context.get("environment") == "production":
|
| 170 |
violations.append({
|
| 171 |
"policy": "Destructive Operation Prevention",
|
| 172 |
"severity": "CRITICAL",
|
| 173 |
-
"action": "BLOCK"
|
| 174 |
-
"reason": "Irreversible action in production"
|
| 175 |
})
|
| 176 |
|
| 177 |
-
# Policy 2: High risk actions need review
|
| 178 |
if risk_score > 0.7:
|
| 179 |
violations.append({
|
| 180 |
"policy": "High Risk Review Required",
|
| 181 |
"severity": "HIGH",
|
| 182 |
-
"action": "REQUIRE_APPROVAL"
|
| 183 |
-
"reason": f"High risk score: {risk_score:.1%}"
|
| 184 |
-
})
|
| 185 |
-
|
| 186 |
-
# Policy 3: Production deployments need sufficient confidence
|
| 187 |
-
if "deploy" in action_lower and context.get("environment") == "production" and risk_score > 0.5:
|
| 188 |
-
violations.append({
|
| 189 |
-
"policy": "Production Deployment Safety",
|
| 190 |
-
"severity": "MEDIUM",
|
| 191 |
-
"action": "REQUIRE_APPROVAL",
|
| 192 |
-
"reason": "Production deployment requires additional review"
|
| 193 |
})
|
| 194 |
|
| 195 |
return {
|
|
@@ -199,17 +117,17 @@ class ARFEngine:
|
|
| 199 |
"total_violations": len(violations)
|
| 200 |
}
|
| 201 |
|
| 202 |
-
def _validate_license(self, license_key
|
| 203 |
-
"""Validate license
|
| 204 |
if not license_key:
|
| 205 |
return {
|
| 206 |
"tier": "oss",
|
| 207 |
"valid": False,
|
| 208 |
"name": "OSS Edition",
|
| 209 |
"enforcement": "advisory",
|
| 210 |
-
"
|
| 211 |
-
"
|
| 212 |
-
"
|
| 213 |
}
|
| 214 |
|
| 215 |
if license_key.startswith("ARF-"):
|
|
@@ -217,12 +135,11 @@ class ARFEngine:
|
|
| 217 |
return {
|
| 218 |
"tier": "trial",
|
| 219 |
"valid": True,
|
| 220 |
-
"name": "
|
| 221 |
"enforcement": "advisory",
|
| 222 |
-
"
|
| 223 |
-
"
|
| 224 |
-
"
|
| 225 |
-
"urgency": self.license_tiers["trial"]["urgency"]
|
| 226 |
}
|
| 227 |
elif "PRO" in license_key:
|
| 228 |
return {
|
|
@@ -230,10 +147,9 @@ class ARFEngine:
|
|
| 230 |
"valid": True,
|
| 231 |
"name": "Professional",
|
| 232 |
"enforcement": "autonomous",
|
| 233 |
-
"
|
| 234 |
-
"
|
| 235 |
-
"
|
| 236 |
-
"social_proof": self.license_tiers["professional"]["social_proof"]
|
| 237 |
}
|
| 238 |
elif "ENTERPRISE" in license_key:
|
| 239 |
return {
|
|
@@ -241,10 +157,9 @@ class ARFEngine:
|
|
| 241 |
"valid": True,
|
| 242 |
"name": "Enterprise",
|
| 243 |
"enforcement": "full_mechanical",
|
| 244 |
-
"
|
| 245 |
-
"
|
| 246 |
-
"
|
| 247 |
-
"social_proof": self.license_tiers["enterprise"]["social_proof"]
|
| 248 |
}
|
| 249 |
|
| 250 |
return {
|
|
@@ -252,11 +167,12 @@ class ARFEngine:
|
|
| 252 |
"valid": False,
|
| 253 |
"name": "Invalid",
|
| 254 |
"enforcement": "advisory",
|
| 255 |
-
"
|
| 256 |
-
"
|
|
|
|
| 257 |
}
|
| 258 |
|
| 259 |
-
def _evaluate_gates(self, risk_score
|
| 260 |
"""Evaluate mechanical gates"""
|
| 261 |
gates = []
|
| 262 |
|
|
@@ -269,12 +185,12 @@ class ARFEngine:
|
|
| 269 |
"weight": 0.3
|
| 270 |
})
|
| 271 |
|
| 272 |
-
# Gate 2: Risk
|
| 273 |
risk_threshold = 0.8 if license_info["tier"] in ["professional", "enterprise"] else 0.7
|
| 274 |
gates.append({
|
| 275 |
"name": "Risk Assessment",
|
| 276 |
"passed": risk_score <= risk_threshold,
|
| 277 |
-
"message": f"Risk {risk_score:.1%} ≤ {risk_threshold:.0%}
|
| 278 |
"required": True,
|
| 279 |
"weight": 0.3
|
| 280 |
})
|
|
@@ -297,98 +213,25 @@ class ARFEngine:
|
|
| 297 |
"weight": 0.2
|
| 298 |
})
|
| 299 |
|
| 300 |
-
# Additional gates for higher tiers
|
| 301 |
-
if license_info["tier"] in ["professional", "enterprise"]:
|
| 302 |
-
gates.append({
|
| 303 |
-
"name": "Rollback Feasibility",
|
| 304 |
-
"passed": "drop" not in str(policy_result).lower(),
|
| 305 |
-
"message": "Rollback plan available",
|
| 306 |
-
"required": False,
|
| 307 |
-
"weight": 0.1
|
| 308 |
-
})
|
| 309 |
-
|
| 310 |
-
if license_info["tier"] == "enterprise":
|
| 311 |
-
gates.append({
|
| 312 |
-
"name": "Compliance Automation",
|
| 313 |
-
"passed": True,
|
| 314 |
-
"message": "GDPR/PCI/SOX compliant",
|
| 315 |
-
"required": False,
|
| 316 |
-
"weight": 0.1
|
| 317 |
-
})
|
| 318 |
-
|
| 319 |
return gates
|
| 320 |
|
| 321 |
-
def
|
| 322 |
-
"""Generate psychological insights"""
|
| 323 |
-
|
| 324 |
-
# Loss Aversion Framing
|
| 325 |
-
if risk_score > 0.7:
|
| 326 |
-
loss_framing = f"⚠️ **Potential Loss**: This action could result in {random.choice(['data loss', 'service disruption', 'security breach', 'compliance violation'])}"
|
| 327 |
-
else:
|
| 328 |
-
loss_framing = "✅ **Safe Operation**: Minimal risk of adverse outcomes"
|
| 329 |
-
|
| 330 |
-
# Social Proof
|
| 331 |
-
if license_info["tier"] == "oss":
|
| 332 |
-
social_proof = f"📊 **Industry Standard**: {int(self.benchmarks['risk_reduction'] * 100)}% of organizations using ARF Enterprise report reduced incidents"
|
| 333 |
-
else:
|
| 334 |
-
social_proof = license_info.get("social_proof", "Trusted by industry leaders")
|
| 335 |
-
|
| 336 |
-
# Scarcity Principle
|
| 337 |
-
if license_info["tier"] == "trial":
|
| 338 |
-
scarcity = license_info.get("urgency", "⏳ Limited time offer")
|
| 339 |
-
elif license_info["tier"] == "oss":
|
| 340 |
-
scarcity = "🚀 **Upgrade Opportunity**: Mechanical enforcement available"
|
| 341 |
-
else:
|
| 342 |
-
scarcity = "🌟 **Full Access**: Unlimited mechanical enforcement"
|
| 343 |
-
|
| 344 |
-
# Authority Signal
|
| 345 |
-
authority = "🔐 **Enterprise-Grade**: Backed by 99.9% SLA and certified compliance"
|
| 346 |
-
|
| 347 |
-
# Value Proposition
|
| 348 |
-
if license_info["tier"] == "oss":
|
| 349 |
-
value_prop = "Upgrade to Enterprise for mechanical enforcement"
|
| 350 |
-
else:
|
| 351 |
-
value_prop = license_info.get("value_prop", "Enterprise-grade protection")
|
| 352 |
-
|
| 353 |
-
return {
|
| 354 |
-
"loss_aversion": loss_framing,
|
| 355 |
-
"social_proof": social_proof,
|
| 356 |
-
"scarcity": scarcity,
|
| 357 |
-
"authority": authority,
|
| 358 |
-
"value_proposition": value_prop,
|
| 359 |
-
"risk_level": self._get_risk_level(risk_score)
|
| 360 |
-
}
|
| 361 |
-
|
| 362 |
-
def _get_risk_level(self, score: float) -> str:
|
| 363 |
-
"""Get risk level description"""
|
| 364 |
-
if score >= 0.8:
|
| 365 |
-
return "🔥 CRITICAL"
|
| 366 |
-
elif score >= 0.6:
|
| 367 |
-
return "⚠️ HIGH"
|
| 368 |
-
elif score >= 0.4:
|
| 369 |
-
return "🔶 MEDIUM"
|
| 370 |
-
elif score >= 0.2:
|
| 371 |
-
return "✅ LOW"
|
| 372 |
-
else:
|
| 373 |
-
return "🛡️ SAFE"
|
| 374 |
-
|
| 375 |
-
def _generate_recommendation(self, policy_result: dict, gate_results: list, license_info: dict) -> str:
|
| 376 |
"""Generate recommendation"""
|
| 377 |
if policy_result["blocked"]:
|
| 378 |
-
return "🚫
|
| 379 |
|
| 380 |
all_gates_passed = all(g["passed"] for g in gate_results if g["required"])
|
| 381 |
|
| 382 |
if not license_info["valid"]:
|
| 383 |
-
return "🔵
|
| 384 |
elif all_gates_passed and license_info["tier"] in ["professional", "enterprise"]:
|
| 385 |
-
return "🟡
|
| 386 |
-
elif all_gates_passed and license_info["tier"] == "
|
| 387 |
-
return "
|
| 388 |
else:
|
| 389 |
-
return "⚠️
|
| 390 |
|
| 391 |
-
def _update_stats(self,
|
| 392 |
"""Update statistics"""
|
| 393 |
self.stats["total_processed"] += 1
|
| 394 |
|
|
@@ -402,25 +245,11 @@ class ARFEngine:
|
|
| 402 |
self.stats["avg_processing_time"] = (
|
| 403 |
self.stats["avg_processing_time"] * 0.9 + processing_time * 0.1
|
| 404 |
)
|
| 405 |
-
|
| 406 |
-
# Add to history
|
| 407 |
-
self.stats["history"].append({
|
| 408 |
-
"timestamp": datetime.now(),
|
| 409 |
-
"action": action[:50],
|
| 410 |
-
"blocked": policy_result["blocked"],
|
| 411 |
-
"license_tier": license_info["tier"],
|
| 412 |
-
"processing_time": processing_time
|
| 413 |
-
})
|
| 414 |
-
|
| 415 |
-
# Keep only last 1000 entries
|
| 416 |
-
if len(self.stats["history"]) > 1000:
|
| 417 |
-
self.stats["history"] = self.stats["history"][-1000:]
|
| 418 |
|
| 419 |
-
def get_stats(self)
|
| 420 |
-
"""Get
|
| 421 |
stats = self.stats.copy()
|
| 422 |
|
| 423 |
-
# Calculate derived stats
|
| 424 |
total = stats["total_processed"]
|
| 425 |
blocked = stats["blocked_actions"]
|
| 426 |
autonomous = stats["autonomous_executions"]
|
|
@@ -429,837 +258,311 @@ class ARFEngine:
|
|
| 429 |
stats["autonomous_percentage"] = round(autonomous / total * 100, 1) if total > 0 else 0.0
|
| 430 |
stats["processing_speed"] = f"{stats['avg_processing_time']*1000:.0f}ms"
|
| 431 |
|
| 432 |
-
# Add benchmarks
|
| 433 |
-
stats["benchmarks"] = self.benchmarks
|
| 434 |
-
|
| 435 |
-
# Add license distribution
|
| 436 |
-
if stats["history"]:
|
| 437 |
-
tiers = [h["license_tier"] for h in stats["history"]]
|
| 438 |
-
stats["license_distribution"] = {
|
| 439 |
-
"OSS": tiers.count("oss"),
|
| 440 |
-
"TRIAL": tiers.count("trial"),
|
| 441 |
-
"ENTERPRISE": tiers.count("professional") + tiers.count("enterprise")
|
| 442 |
-
}
|
| 443 |
-
else:
|
| 444 |
-
stats["license_distribution"] = {"OSS": 0, "TRIAL": 0, "ENTERPRISE": 0}
|
| 445 |
-
|
| 446 |
return stats
|
| 447 |
|
| 448 |
-
def generate_trial_license(self, email
|
| 449 |
-
"""Generate trial license
|
| 450 |
if not email or "@" not in email:
|
| 451 |
-
return {
|
| 452 |
-
"success": False,
|
| 453 |
-
"message": "Please enter a valid work email address",
|
| 454 |
-
"psychological_note": "We verify emails to ensure trial quality"
|
| 455 |
-
}
|
| 456 |
|
| 457 |
-
license_key = f"ARF-TRIAL-{hashlib.sha256(
|
| 458 |
|
| 459 |
return {
|
| 460 |
"success": True,
|
| 461 |
"license_key": license_key,
|
| 462 |
"message": "🎉 14-Day Trial License Generated!",
|
| 463 |
-
"
|
| 464 |
-
"scarcity": "⏳ Limited to 14 days",
|
| 465 |
-
"social_proof": "Join 1,000+ developers using ARF",
|
| 466 |
-
"authority": "Enterprise-grade AI safety",
|
| 467 |
-
"value": "$2,000 value - FREE for 14 days"
|
| 468 |
-
},
|
| 469 |
-
"features": self.license_tiers["trial"]["features"],
|
| 470 |
-
"next_steps": [
|
| 471 |
-
"Try the 'Safe Deployment' scenario",
|
| 472 |
-
"Test with your own actions",
|
| 473 |
-
"Schedule an Enterprise demo"
|
| 474 |
-
],
|
| 475 |
-
"contact": {
|
| 476 |
-
"sales": "sales@arf.dev",
|
| 477 |
-
"support": "support@arf.dev",
|
| 478 |
-
"website": "https://arf.dev"
|
| 479 |
-
}
|
| 480 |
}
|
| 481 |
|
| 482 |
-
#
|
| 483 |
-
# DEMO DATA
|
| 484 |
-
# ============================================================================
|
| 485 |
-
|
| 486 |
DEMO_SCENARIOS = [
|
| 487 |
{
|
| 488 |
-
"id": "high_risk",
|
| 489 |
"name": "🔥 High-Risk Database Operation",
|
| 490 |
"action": "DROP DATABASE production_users CASCADE",
|
| 491 |
-
"context": {"environment": "production", "criticality": "critical"
|
| 492 |
-
"description": "Irreversible deletion of customer database",
|
| 493 |
-
"learning": "Shows how mechanical gates prevent catastrophic errors",
|
| 494 |
-
"psych_tip": "Loss aversion - what you could lose without protection"
|
| 495 |
},
|
| 496 |
{
|
| 497 |
-
"id": "safe_deploy",
|
| 498 |
"name": "✅ Safe Service Deployment",
|
| 499 |
-
"action": "deploy_service payment_api:v2.3.1 to staging
|
| 500 |
-
"context": {"environment": "staging", "service": "payment_api"
|
| 501 |
-
"description": "Standard deployment with safety measures",
|
| 502 |
-
"learning": "Shows how Enterprise enables safe autonomous execution",
|
| 503 |
-
"psych_tip": "Value demonstration - what you gain with protection"
|
| 504 |
},
|
| 505 |
{
|
| 506 |
-
"id": "config_change",
|
| 507 |
"name": "🔧 Configuration Update",
|
| 508 |
-
"action": "UPDATE config SET timeout_ms=30000
|
| 509 |
-
"context": {"environment": "production", "service": "api"
|
| 510 |
-
"description": "Production configuration change",
|
| 511 |
-
"learning": "Shows human-in-loop approval for medium-risk changes",
|
| 512 |
-
"psych_tip": "Authority delegation - when humans should still decide"
|
| 513 |
}
|
| 514 |
]
|
| 515 |
|
| 516 |
-
#
|
| 517 |
-
|
| 518 |
-
# ============================================================================
|
| 519 |
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 525 |
|
| 526 |
-
#
|
| 527 |
-
|
|
|
|
|
|
|
|
|
|
| 528 |
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
font-family: -apple-system, BlinkMacSystemFont, sans-serif;
|
| 537 |
-
}
|
| 538 |
-
.header {
|
| 539 |
-
background: linear-gradient(135deg, #1E88E5 0%, #0D47A1 100%);
|
| 540 |
-
color: white;
|
| 541 |
-
padding: 30px;
|
| 542 |
-
border-radius: 15px;
|
| 543 |
-
margin-bottom: 30px;
|
| 544 |
-
text-align: center;
|
| 545 |
-
}
|
| 546 |
-
.stat-card {
|
| 547 |
-
background: white;
|
| 548 |
-
padding: 20px;
|
| 549 |
-
border-radius: 10px;
|
| 550 |
-
text-align: center;
|
| 551 |
-
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
| 552 |
-
transition: transform 0.2s;
|
| 553 |
-
}
|
| 554 |
-
.stat-card:hover {
|
| 555 |
-
transform: translateY(-5px);
|
| 556 |
-
}
|
| 557 |
-
.oss-panel {
|
| 558 |
-
border: 2px solid #1E88E5;
|
| 559 |
-
border-radius: 12px;
|
| 560 |
-
padding: 25px;
|
| 561 |
-
background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
|
| 562 |
-
margin-bottom: 20px;
|
| 563 |
-
}
|
| 564 |
-
.enterprise-panel {
|
| 565 |
-
border: 2px solid #FFB300;
|
| 566 |
-
border-radius: 12px;
|
| 567 |
-
padding: 25px;
|
| 568 |
-
background: linear-gradient(135deg, #FFF8E1 0%, #FFECB3 100%);
|
| 569 |
-
margin-bottom: 20px;
|
| 570 |
-
}
|
| 571 |
-
.gate-passed {
|
| 572 |
-
background: #E8F5E9;
|
| 573 |
-
border-left: 4px solid #4CAF50;
|
| 574 |
-
padding: 12px;
|
| 575 |
-
margin: 8px 0;
|
| 576 |
-
border-radius: 6px;
|
| 577 |
-
}
|
| 578 |
-
.gate-failed {
|
| 579 |
-
background: #FFEBEE;
|
| 580 |
-
border-left: 4px solid #F44336;
|
| 581 |
-
padding: 12px;
|
| 582 |
-
margin: 8px 0;
|
| 583 |
-
border-radius: 6px;
|
| 584 |
-
}
|
| 585 |
-
.psych-insight {
|
| 586 |
-
background: linear-gradient(135deg, #FFF3E0 0%, #FFE0B2 100%);
|
| 587 |
-
padding: 15px;
|
| 588 |
-
border-radius: 8px;
|
| 589 |
-
margin: 10px 0;
|
| 590 |
-
border-left: 4px solid #FF9800;
|
| 591 |
-
}
|
| 592 |
-
.comparison-card {
|
| 593 |
-
background: white;
|
| 594 |
-
padding: 25px;
|
| 595 |
-
border-radius: 12px;
|
| 596 |
-
box-shadow: 0 4px 16px rgba(0,0,0,0.1);
|
| 597 |
-
margin-bottom: 20px;
|
| 598 |
-
}
|
| 599 |
-
.trial-card {
|
| 600 |
-
background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
|
| 601 |
-
padding: 20px;
|
| 602 |
-
border-radius: 10px;
|
| 603 |
-
border: 2px solid #4CAF50;
|
| 604 |
-
}
|
| 605 |
-
"""
|
| 606 |
-
) as demo:
|
| 607 |
-
|
| 608 |
-
# ====================================================================
|
| 609 |
-
# HEADER WITH PSYCHOLOGICAL MESSAGING
|
| 610 |
-
# ====================================================================
|
| 611 |
-
gr.Markdown("""
|
| 612 |
-
<div class="header">
|
| 613 |
-
<h1 style="margin: 0 0 10px 0; font-size: 2.5em;">🤖 Agentic Reliability Framework 3.3.9</h1>
|
| 614 |
-
<h3 style="margin: 0; font-weight: 300; opacity: 0.9;">From "You Should" to "The System Ensures"</h3>
|
| 615 |
-
<p style="margin: 15px 0 0 0; font-size: 1.1em; max-width: 800px; margin: 15px auto 0 auto; opacity: 0.9;">
|
| 616 |
-
Experience the psychological shift from advisory recommendations to mechanical enforcement
|
| 617 |
-
</p>
|
| 618 |
</div>
|
| 619 |
-
""
|
| 620 |
-
|
| 621 |
-
|
| 622 |
-
|
| 623 |
-
|
| 624 |
-
|
| 625 |
-
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
|
| 630 |
-
|
| 631 |
-
|
| 632 |
-
|
| 633 |
-
|
| 634 |
-
|
| 635 |
-
|
| 636 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 637 |
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
|
| 643 |
|
| 644 |
-
|
| 645 |
-
|
| 646 |
-
|
| 647 |
-
|
| 648 |
-
|
| 649 |
-
</div>
|
| 650 |
-
""")
|
| 651 |
-
|
| 652 |
-
# ====================================================================
|
| 653 |
-
# MAIN CONTROLS
|
| 654 |
-
# ====================================================================
|
| 655 |
-
with gr.Row():
|
| 656 |
-
with gr.Column(scale=2):
|
| 657 |
-
# Scenario selection
|
| 658 |
-
scenario_select = gr.Dropdown(
|
| 659 |
-
choices=[s["name"] for s in DEMO_SCENARIOS],
|
| 660 |
-
label="🎯 Select Learning Scenario",
|
| 661 |
-
value=DEMO_SCENARIOS[0]["name"],
|
| 662 |
-
elem_id="scenario_select"
|
| 663 |
-
)
|
| 664 |
-
|
| 665 |
-
# Action input
|
| 666 |
-
action_input = gr.Textbox(
|
| 667 |
-
label="⚡ Action to Evaluate",
|
| 668 |
-
value=DEMO_SCENARIOS[0]["action"],
|
| 669 |
-
lines=2,
|
| 670 |
-
elem_id="action_input"
|
| 671 |
-
)
|
| 672 |
-
|
| 673 |
-
# Context input
|
| 674 |
-
context_input = gr.Textbox(
|
| 675 |
-
label="📋 Context (JSON Format)",
|
| 676 |
-
value=json.dumps(DEMO_SCENARIOS[0]["context"], indent=2),
|
| 677 |
-
lines=3,
|
| 678 |
-
elem_id="context_input"
|
| 679 |
-
)
|
| 680 |
-
|
| 681 |
-
# License input with psychological framing
|
| 682 |
-
license_input = gr.Textbox(
|
| 683 |
-
label="🔐 Enterprise License Key",
|
| 684 |
-
placeholder="Enter ARF-TRIAL-XXXXXXX for trial, ARF-PRO-XXXXXX for Professional, or leave blank for OSS",
|
| 685 |
-
value="",
|
| 686 |
-
elem_id="license_input"
|
| 687 |
-
)
|
| 688 |
-
|
| 689 |
-
with gr.Row():
|
| 690 |
-
process_btn = gr.Button("🚀 Evaluate Action", variant="primary", size="lg")
|
| 691 |
-
clear_btn = gr.Button("🔄 Reset Demo", variant="secondary")
|
| 692 |
|
| 693 |
-
|
| 694 |
-
|
| 695 |
-
|
| 696 |
-
|
| 697 |
-
psych_html = gr.HTML("""
|
| 698 |
-
<div class="psych-insight">
|
| 699 |
-
<div style="display: flex; align-items: center; margin-bottom: 10px;">
|
| 700 |
-
<span style="font-size: 24px; margin-right: 10px;">🧠</span>
|
| 701 |
-
<div style="font-weight: bold; font-size: 1.1em;">Loss Aversion</div>
|
| 702 |
-
</div>
|
| 703 |
-
<p style="margin: 0; font-size: 0.9em;">
|
| 704 |
-
People fear losses 2x more than they value gains.
|
| 705 |
-
ARF Enterprise prevents catastrophic losses through mechanical enforcement.
|
| 706 |
-
</p>
|
| 707 |
-
</div>
|
| 708 |
-
|
| 709 |
-
<div class="psych-insight">
|
| 710 |
-
<div style="display: flex; align-items: center; margin-bottom: 10px;">
|
| 711 |
-
<span style="font-size: 24px; margin-right: 10px;">👥</span>
|
| 712 |
-
<div style="font-weight: bold; font-size: 1.1em;">Social Proof</div>
|
| 713 |
-
</div>
|
| 714 |
-
<p style="margin: 0; font-size: 0.9em;">
|
| 715 |
-
92% of Fortune 500 companies using AI have adopted
|
| 716 |
-
mechanical enforcement systems like ARF Enterprise.
|
| 717 |
-
</p>
|
| 718 |
-
</div>
|
| 719 |
-
""")
|
| 720 |
-
|
| 721 |
-
# Current license status
|
| 722 |
-
license_status = gr.HTML("""
|
| 723 |
-
<div style="background: #E3F2FD; padding: 20px; border-radius: 10px; text-align: center;">
|
| 724 |
-
<div style="font-size: 24px; margin-bottom: 10px;">🔵</div>
|
| 725 |
-
<div style="font-weight: bold; color: #1E88E5; margin-bottom: 5px;">ARF OSS Edition</div>
|
| 726 |
-
<div style="color: #666; font-size: 0.9em; margin-bottom: 10px;">Advisory Mode - No mechanical enforcement</div>
|
| 727 |
-
<div style="font-size: 0.85em; color: #999;">
|
| 728 |
-
Upgrade to Enterprise for mechanical gates
|
| 729 |
-
</div>
|
| 730 |
-
</div>
|
| 731 |
-
""")
|
| 732 |
-
|
| 733 |
-
# ====================================================================
|
| 734 |
-
# RESULTS PANELS
|
| 735 |
-
# ====================================================================
|
| 736 |
-
with gr.Row():
|
| 737 |
-
with gr.Column(scale=1):
|
| 738 |
-
oss_output = gr.HTML(label="🔵 ARF OSS Experience")
|
| 739 |
|
| 740 |
-
with gr.Column(scale=1):
|
| 741 |
-
enterprise_output = gr.HTML(label="🟡 ARF Enterprise Experience")
|
| 742 |
-
|
| 743 |
-
# Comparison
|
| 744 |
-
comparison_output = gr.HTML(label="⚖️ Psychological Comparison")
|
| 745 |
-
|
| 746 |
-
# ====================================================================
|
| 747 |
-
# TRIAL SECTION WITH SCARCITY
|
| 748 |
-
# ====================================================================
|
| 749 |
-
with gr.Accordion("🎁 Get 14-Day Trial License - Limited Time Offer", open=False):
|
| 750 |
with gr.Row():
|
| 751 |
-
|
| 752 |
-
|
| 753 |
-
|
| 754 |
-
|
| 755 |
-
|
| 756 |
-
|
| 757 |
-
|
| 758 |
-
|
| 759 |
-
|
| 760 |
-
trial_output = gr.JSON(
|
| 761 |
-
label="Your Trial License Details",
|
| 762 |
-
elem_id="trial_output"
|
| 763 |
-
)
|
| 764 |
-
|
| 765 |
-
# ====================================================================
|
| 766 |
-
# FOOTER WITH AUTHORITY SIGNALS
|
| 767 |
-
# ====================================================================
|
| 768 |
-
gr.Markdown("""
|
| 769 |
-
<div style="text-align: center; margin-top: 40px; padding-top: 20px; border-top: 1px solid #E0E0E0; color: #666;">
|
| 770 |
-
<p style="margin-bottom: 10px;">
|
| 771 |
-
<strong>ARF 3.3.9</strong> •
|
| 772 |
-
<a href="https://arf.dev" target="_blank" style="color: #1E88E5; text-decoration: none;">Website</a> •
|
| 773 |
-
<a href="https://github.com/arf-dev" target="_blank" style="color: #1E88E5; text-decoration: none;">GitHub</a> •
|
| 774 |
-
<a href="mailto:sales@arf.dev" style="color: #1E88E5; text-decoration: none;">Contact Sales</a>
|
| 775 |
-
</p>
|
| 776 |
-
<div style="display: flex; justify-content: center; gap: 20px; margin: 15px 0; font-size: 0.9em; flex-wrap: wrap;">
|
| 777 |
-
<div>✅ SOC 2 Type II Certified</div>
|
| 778 |
-
<div>✅ GDPR Compliant</div>
|
| 779 |
-
<div>✅ 99.9% SLA</div>
|
| 780 |
-
<div>✅ 24/7 Enterprise Support</div>
|
| 781 |
</div>
|
| 782 |
-
|
| 783 |
-
|
| 784 |
-
|
| 785 |
-
|
| 786 |
-
""
|
| 787 |
-
|
| 788 |
-
|
| 789 |
-
|
| 790 |
-
|
| 791 |
-
|
| 792 |
-
|
| 793 |
-
|
| 794 |
-
|
| 795 |
-
|
| 796 |
-
|
| 797 |
-
|
| 798 |
-
|
| 799 |
-
|
| 800 |
-
|
| 801 |
-
|
| 802 |
-
|
| 803 |
-
|
| 804 |
-
|
| 805 |
-
learning = scenario_data["learning"]
|
| 806 |
-
psych_tip = scenario_data["psych_tip"]
|
| 807 |
-
else:
|
| 808 |
-
learning = "Custom action evaluation"
|
| 809 |
-
psych_tip = "See how ARF handles your specific use case"
|
| 810 |
-
|
| 811 |
-
# Parse context
|
| 812 |
-
try:
|
| 813 |
-
context = json.loads(context_text) if context_text.strip() else {}
|
| 814 |
-
except:
|
| 815 |
-
context = {"environment": "production"}
|
| 816 |
-
|
| 817 |
-
# Process action
|
| 818 |
-
result = arf_engine.assess_action(action_text, context, license_key)
|
| 819 |
-
|
| 820 |
-
# Create enhanced displays
|
| 821 |
-
oss_html = create_oss_display(result, learning, psych_tip)
|
| 822 |
-
enterprise_html = create_enterprise_display(result)
|
| 823 |
-
comparison_html = create_comparison_display(result)
|
| 824 |
-
|
| 825 |
-
# Update license status
|
| 826 |
-
license_info = result["license_info"]
|
| 827 |
-
if license_info["valid"]:
|
| 828 |
-
tier_color = {
|
| 829 |
-
"trial": "#BCAAA4",
|
| 830 |
-
"starter": "#FFD54F",
|
| 831 |
-
"professional": "#FFB300",
|
| 832 |
-
"enterprise": "#FF6F00"
|
| 833 |
-
}.get(license_info["tier"], "#FFB300")
|
| 834 |
-
|
| 835 |
-
status_html = f"""
|
| 836 |
-
<div style="background: linear-gradient(135deg, {tier_color}20 0%, {tier_color}40 100%);
|
| 837 |
-
padding: 20px; border-radius: 10px; text-align: center; border: 2px solid {tier_color};">
|
| 838 |
-
<div style="font-size: 24px; margin-bottom: 10px;">{'🎁' if license_info['tier'] == 'trial' else '✅'}</div>
|
| 839 |
-
<div style="font-weight: bold; color: {tier_color}; margin-bottom: 5px;">
|
| 840 |
-
{license_info['name']}
|
| 841 |
-
</div>
|
| 842 |
-
<div style="color: #666; font-size: 0.9em; margin-bottom: 10px;">
|
| 843 |
-
{license_info['message']}
|
| 844 |
-
</div>
|
| 845 |
-
<div style="font-size: 0.85em; color: #666;">
|
| 846 |
-
{license_info.get('social_proof', 'Enterprise-grade protection')}
|
| 847 |
-
</div>
|
| 848 |
-
</div>
|
| 849 |
-
"""
|
| 850 |
-
else:
|
| 851 |
-
status_html = """
|
| 852 |
-
<div style="background: #E3F2FD; padding: 20px; border-radius: 10px; text-align: center;">
|
| 853 |
-
<div style="font-size: 24px; margin-bottom: 10px;">🔵</div>
|
| 854 |
-
<div style="font-weight: bold; color: #1E88E5; margin-bottom: 5px;">ARF OSS Edition</div>
|
| 855 |
-
<div style="color: #666; font-size: 0.9em; margin-bottom: 10px;">Advisory Mode - No mechanical enforcement</div>
|
| 856 |
-
<div style="font-size: 0.85em; color: #999;">
|
| 857 |
-
Upgrade to Enterprise for mechanical gates
|
| 858 |
-
</div>
|
| 859 |
-
</div>
|
| 860 |
-
"""
|
| 861 |
-
|
| 862 |
-
return oss_html, enterprise_html, comparison_html, status_html
|
| 863 |
-
|
| 864 |
-
except Exception as e:
|
| 865 |
-
error_html = f"""
|
| 866 |
-
<div style="background: #FFEBEE; padding: 20px; border-radius: 10px; color: #D32F2F;">
|
| 867 |
-
<h4 style="margin-top: 0;">❌ Error Processing Action</h4>
|
| 868 |
-
<p>{str(e)}</p>
|
| 869 |
-
</div>
|
| 870 |
-
"""
|
| 871 |
-
return error_html, error_html, error_html, ""
|
| 872 |
-
|
| 873 |
-
def create_oss_display(result, learning, psych_tip):
|
| 874 |
-
"""Create OSS display"""
|
| 875 |
-
risk_score = result["risk_score"]
|
| 876 |
-
confidence = result["confidence"]
|
| 877 |
-
policy = result["policy_result"]
|
| 878 |
-
psych = result["psych_insights"]
|
| 879 |
|
| 880 |
-
|
| 881 |
-
|
| 882 |
|
| 883 |
-
|
| 884 |
-
|
| 885 |
-
|
| 886 |
-
|
| 887 |
-
|
| 888 |
-
|
| 889 |
-
|
| 890 |
-
|
| 891 |
-
|
| 892 |
-
|
| 893 |
-
<div style="text-align: center; padding: 15px; background: white; border-radius: 8px;">
|
| 894 |
-
<div style="font-size: 0.9em; color: #1E88E5; margin-bottom: 5px;">Reliability</div>
|
| 895 |
-
<div style="font-size: 1.8em; font-weight: bold; color: #1E88E5;">{(1-risk_score):.1%}</div>
|
| 896 |
-
</div>
|
| 897 |
-
|
| 898 |
-
<div style="text-align: center; padding: 15px; background: white; border-radius: 8px;">
|
| 899 |
-
<div style="font-size: 0.9em; color: {risk_color}; margin-bottom: 5px;">Risk Level</div>
|
| 900 |
-
<div style="font-size: 1.8em; font-weight: bold; color: {risk_color};">{risk_level}</div>
|
| 901 |
-
</div>
|
| 902 |
-
|
| 903 |
-
<div style="text-align: center; padding: 15px; background: white; border-radius: 8px;">
|
| 904 |
-
<div style="font-size: 0.9em; color: #1E88E5; margin-bottom: 5px;">Confidence</div>
|
| 905 |
-
<div style="font-size: 1.8em; font-weight: bold; color: #1E88E5;">{confidence:.1%}</div>
|
| 906 |
-
</div>
|
| 907 |
-
</div>
|
| 908 |
-
|
| 909 |
-
<div style="background: white; padding: 20px; border-radius: 8px; margin-bottom: 20px; border-left: 4px solid {risk_color};">
|
| 910 |
-
<div style="display: flex; align-items: center; margin-bottom: 10px;">
|
| 911 |
-
<span style="font-size: 24px; margin-right: 10px;">💡</span>
|
| 912 |
-
<h3 style="margin: 0; color: #333;">Recommendation</h3>
|
| 913 |
-
</div>
|
| 914 |
-
<p style="margin: 0; font-size: 1.2em; font-weight: 500; color: #333;">
|
| 915 |
-
{result['recommendation']}
|
| 916 |
-
</p>
|
| 917 |
-
<p style="margin: 10px 0 0 0; font-size: 0.9em; color: #666;">
|
| 918 |
-
Processing time: {result['processing_time']:.4f}s • {policy['total_violations']} policy violation(s)
|
| 919 |
-
</p>
|
| 920 |
-
</div>
|
| 921 |
-
|
| 922 |
-
<div style="background: #FFF3E0; padding: 20px; border-radius: 8px; margin-bottom: 20px;">
|
| 923 |
-
<div style="display: flex; align-items: center; margin-bottom: 10px;">
|
| 924 |
-
<span style="font-size: 24px; margin-right: 10px;">⚠️</span>
|
| 925 |
-
<h3 style="margin: 0; color: #E65100;">OSS Limitations</h3>
|
| 926 |
-
</div>
|
| 927 |
-
<ul style="margin: 0; padding-left: 20px; color: #E65100;">
|
| 928 |
-
<li>Human decision required for all actions</li>
|
| 929 |
-
<li>No mechanical enforcement</li>
|
| 930 |
-
<li>Limited to advisory recommendations</li>
|
| 931 |
-
<li>Personal liability for decisions</li>
|
| 932 |
-
</ul>
|
| 933 |
-
</div>
|
| 934 |
-
|
| 935 |
-
<div class="psych-insight">
|
| 936 |
-
<div style="display: flex; align-items: center; margin-bottom: 10px;">
|
| 937 |
-
<span style="font-size: 24px; margin-right: 10px;">🧠</span>
|
| 938 |
-
<div>
|
| 939 |
-
<div style="font-weight: bold; font-size: 1.1em;">Learning Insight</div>
|
| 940 |
-
<div style="font-size: 0.9em; color: #666;">{learning}</div>
|
| 941 |
-
</div>
|
| 942 |
-
</div>
|
| 943 |
-
<p style="margin: 0; font-size: 0.9em;">{psych_tip}</p>
|
| 944 |
-
</div>
|
| 945 |
-
|
| 946 |
-
<div style="margin-top: 20px; padding-top: 15px; border-top: 1px solid rgba(0,0,0,0.1);">
|
| 947 |
-
<div style="font-size: 0.9em; color: #666; margin-bottom: 5px;">Psychological Principle</div>
|
| 948 |
-
<p style="margin: 0; font-size: 0.9em; font-weight: 500;">{psych['loss_aversion']}</p>
|
| 949 |
</div>
|
|
|
|
| 950 |
</div>
|
| 951 |
"""
|
| 952 |
-
|
| 953 |
-
def create_enterprise_display(result):
|
| 954 |
-
"""Create Enterprise display"""
|
| 955 |
-
gates = result["gate_results"]
|
| 956 |
-
license_info = result["license_info"]
|
| 957 |
-
psych = result["psych_insights"]
|
| 958 |
-
|
| 959 |
-
# Calculate gate progress
|
| 960 |
-
required_gates = [g for g in gates if g["required"]]
|
| 961 |
-
passed_required = sum(1 for g in required_gates if g["passed"])
|
| 962 |
-
gate_progress = passed_required / len(required_gates) if required_gates else 0
|
| 963 |
-
|
| 964 |
-
# Determine tier color
|
| 965 |
-
tier_color = {
|
| 966 |
-
"trial": "#BCAAA4",
|
| 967 |
-
"starter": "#FFD54F",
|
| 968 |
-
"professional": "#FFB300",
|
| 969 |
-
"enterprise": "#FF6F00",
|
| 970 |
-
"oss": "#1E88E5"
|
| 971 |
-
}.get(license_info["tier"], "#FFB300")
|
| 972 |
|
| 973 |
-
|
| 974 |
-
|
| 975 |
-
|
| 976 |
-
|
| 977 |
-
|
| 978 |
-
|
| 979 |
-
|
| 980 |
-
|
| 981 |
-
|
| 982 |
-
|
| 983 |
-
|
| 984 |
-
|
| 985 |
-
|
| 986 |
-
|
| 987 |
-
|
| 988 |
-
|
| 989 |
-
|
| 990 |
-
|
| 991 |
-
"""
|
| 992 |
|
| 993 |
-
|
| 994 |
-
|
| 995 |
-
|
| 996 |
-
<
|
| 997 |
-
<span style="background: {tier_color}20; padding: 8px 16px; border-radius: 20px; color: {tier_color}; font-weight: bold;">
|
| 998 |
-
{license_info['name'].upper()}
|
| 999 |
-
</span>
|
| 1000 |
-
</div>
|
| 1001 |
-
|
| 1002 |
-
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-bottom: 20px;">
|
| 1003 |
-
<div style="text-align: center; padding: 15px; background: white; border-radius: 8px;">
|
| 1004 |
-
<div style="font-size: 0.9em; color: {tier_color}; margin-bottom: 5px;">License Tier</div>
|
| 1005 |
-
<div style="font-size: 1.4em; font-weight: bold; color: {tier_color};">{license_info['name']}</div>
|
| 1006 |
-
</div>
|
| 1007 |
-
|
| 1008 |
-
<div style="text-align: center; padding: 15px; background: white; border-radius: 8px;">
|
| 1009 |
-
<div style="font-size: 0.9em; color: {tier_color}; margin-bottom: 5px;">Gates Passed</div>
|
| 1010 |
-
<div style="font-size: 1.8em; font-weight: bold; color: {tier_color};">{passed_required}/{len(required_gates)}</div>
|
| 1011 |
-
</div>
|
| 1012 |
-
|
| 1013 |
-
<div style="text-align: center; padding: 15px; background: white; border-radius: 8px;">
|
| 1014 |
-
<div style="font-size: 0.9em; color: {tier_color}; margin-bottom: 5px;">Enforcement</div>
|
| 1015 |
-
<div style="font-size: 1.1em; font-weight: bold; color: {tier_color}; line-height: 1.2;">
|
| 1016 |
-
{license_info['enforcement'].replace('_', ' ').title()}
|
| 1017 |
-
</div>
|
| 1018 |
-
</div>
|
| 1019 |
</div>
|
| 1020 |
-
|
| 1021 |
-
|
| 1022 |
-
<
|
| 1023 |
-
<div style="max-height: 250px; overflow-y: auto; padding-right: 10px;">
|
| 1024 |
-
{gates_html}
|
| 1025 |
-
</div>
|
| 1026 |
</div>
|
| 1027 |
-
|
| 1028 |
-
|
| 1029 |
-
<div style="
|
| 1030 |
-
<span style="font-size: 24px; margin-right: 10px;">🚀</span>
|
| 1031 |
-
<h3 style="margin: 0; color: #2E7D32;">Enterprise Benefits</h3>
|
| 1032 |
-
</div>
|
| 1033 |
-
<ul style="margin: 0; padding-left: 20px; color: #2E7D32;">
|
| 1034 |
-
<li>Mechanical enforcement with automated gates</li>
|
| 1035 |
-
<li>Processing time: {result['processing_time']:.4f}s</li>
|
| 1036 |
-
<li>{license_info.get('value_prop', 'Enterprise-grade protection')}</li>
|
| 1037 |
-
<li>{psych['authority']}</li>
|
| 1038 |
-
</ul>
|
| 1039 |
</div>
|
| 1040 |
-
|
| 1041 |
-
|
| 1042 |
-
|
| 1043 |
-
|
| 1044 |
-
|
| 1045 |
-
|
| 1046 |
-
|
| 1047 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1048 |
</div>
|
| 1049 |
-
<p style="margin: 0; font-size: 0.9em;">{psych['scarcity']}</p>
|
| 1050 |
</div>
|
| 1051 |
</div>
|
| 1052 |
"""
|
| 1053 |
|
| 1054 |
-
|
| 1055 |
-
|
| 1056 |
-
|
| 1057 |
-
|
| 1058 |
-
|
| 1059 |
-
|
| 1060 |
-
|
| 1061 |
-
|
| 1062 |
-
all_gates_passed = all(g["passed"] for g in gates if g["required"])
|
| 1063 |
-
|
| 1064 |
-
if all_gates_passed and license_info["tier"] in ["professional", "enterprise"]:
|
| 1065 |
-
enterprise_auth = "AUTONOMOUS_EXECUTION"
|
| 1066 |
-
auth_color = "#4CAF50"
|
| 1067 |
-
auth_icon = "✅"
|
| 1068 |
-
auth_message = "Autonomous execution permitted"
|
| 1069 |
-
elif all_gates_passed and license_info["tier"] == "starter":
|
| 1070 |
-
enterprise_auth = "HUMAN_APPROVAL_REQUIRED"
|
| 1071 |
-
auth_color = "#FF9800"
|
| 1072 |
-
auth_icon = "👤"
|
| 1073 |
-
auth_message = "Human approval required"
|
| 1074 |
-
elif license_info["valid"]:
|
| 1075 |
-
enterprise_auth = "ADVISORY_ONLY"
|
| 1076 |
-
auth_color = "#9E9E9E"
|
| 1077 |
-
auth_icon = "ℹ️"
|
| 1078 |
-
auth_message = "Trial license - advisory only"
|
| 1079 |
-
else:
|
| 1080 |
-
enterprise_auth = "OSS_ONLY"
|
| 1081 |
-
auth_color = "#1E88E5"
|
| 1082 |
-
auth_icon = "🔵"
|
| 1083 |
-
auth_message = "OSS mode - no license"
|
| 1084 |
|
| 1085 |
-
|
| 1086 |
-
|
| 1087 |
-
|
| 1088 |
-
|
| 1089 |
-
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 25px; margin-bottom: 30px;">
|
| 1090 |
-
<!-- OSS Column -->
|
| 1091 |
-
<div style="text-align: center;">
|
| 1092 |
-
<div style="background: #E3F2FD; padding: 25px; border-radius: 12px; margin-bottom: 20px; border: 2px solid #1E88E5;">
|
| 1093 |
-
<h3 style="color: #1E88E5; margin: 0 0 15px 0;">🔵 OSS Experience</h3>
|
| 1094 |
-
<div style="font-size: 48px; margin: 20px 0;">{'⚠️' if not oss_can_execute else '✅'}</div>
|
| 1095 |
-
<div style="font-size: 1.3em; font-weight: bold; color: {'#F44336' if not oss_can_execute else '#4CAF50'}; margin-bottom: 10px;">
|
| 1096 |
-
{'Advisory Only' if not oss_can_execute else 'Can Execute'}
|
| 1097 |
-
</div>
|
| 1098 |
-
<div style="font-size: 0.9em; color: #666;">
|
| 1099 |
-
Human decision required
|
| 1100 |
-
</div>
|
| 1101 |
-
</div>
|
| 1102 |
-
|
| 1103 |
-
<div style="text-align: left;">
|
| 1104 |
-
<div style="background: rgba(30, 136, 229, 0.1); padding: 12px 15px; border-radius: 8px; margin: 8px 0; font-size: 0.95em;">
|
| 1105 |
-
<strong>Psychological State:</strong> Uncertainty, Responsibility
|
| 1106 |
-
</div>
|
| 1107 |
-
<div style="background: rgba(30, 136, 229, 0.1); padding: 12px 15px; border-radius: 8px; margin: 8px 0; font-size: 0.95em;">
|
| 1108 |
-
<strong>Mental Load:</strong> High (You decide)
|
| 1109 |
-
</div>
|
| 1110 |
-
<div style="background: rgba(30, 136, 229, 0.1); padding: 12px 15px; border-radius: 8px; margin: 8px 0; font-size: 0.95em;">
|
| 1111 |
-
<strong>Risk Exposure:</strong> Personal liability
|
| 1112 |
-
</div>
|
| 1113 |
-
</div>
|
| 1114 |
-
</div>
|
| 1115 |
-
|
| 1116 |
-
<!-- Enterprise Column -->
|
| 1117 |
-
<div style="text-align: center;">
|
| 1118 |
-
<div style="background: #FFF8E1; padding: 25px; border-radius: 12px; margin-bottom: 20px; border: 2px solid #FFB300;">
|
| 1119 |
-
<h3 style="color: #FFB300; margin: 0 0 15px 0;">🟡 Enterprise Experience</h3>
|
| 1120 |
-
<div style="font-size: 48px; margin: 20px 0;">{auth_icon}</div>
|
| 1121 |
-
<div style="font-size: 1.3em; font-weight: bold; color: {auth_color}; margin-bottom: 10px;">
|
| 1122 |
-
{enterprise_auth.replace('_', ' ').title()}
|
| 1123 |
-
</div>
|
| 1124 |
-
<div style="font-size: 0.9em; color: #666;">
|
| 1125 |
-
{auth_message}
|
| 1126 |
-
</div>
|
| 1127 |
-
</div>
|
| 1128 |
-
|
| 1129 |
-
<div style="text-align: left;">
|
| 1130 |
-
<div style="background: rgba(255, 179, 0, 0.1); padding: 12px 15px; border-radius: 8px; margin: 8px 0; font-size: 0.95em;">
|
| 1131 |
-
<strong>Psychological State:</strong> Confidence, Assurance
|
| 1132 |
-
</div>
|
| 1133 |
-
<div style="background: rgba(255, 179, 0, 0.1); padding: 12px 15px; border-radius: 8px; margin: 8px 0; font-size: 0.95em;">
|
| 1134 |
-
<strong>Mental Load:</strong> Low (System decides)
|
| 1135 |
-
</div>
|
| 1136 |
-
<div style="background: rgba(255, 179, 0, 0.1); padding: 12px 15px; border-radius: 8px; margin: 8px 0; font-size: 0.95em;">
|
| 1137 |
-
<strong>Risk Exposure:</strong> System accountability
|
| 1138 |
-
</div>
|
| 1139 |
-
</div>
|
| 1140 |
-
</div>
|
| 1141 |
</div>
|
| 1142 |
-
|
| 1143 |
-
|
| 1144 |
-
|
| 1145 |
-
<h3 style="margin: 0 0 20px 0; text-align: center; color: #333;">🎯 Enterprise Value Metrics</h3>
|
| 1146 |
-
<div style="display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px;">
|
| 1147 |
-
<div style="text-align: center; padding: 20px; background: white; border-radius: 10px;">
|
| 1148 |
-
<div style="font-size: 0.95em; color: #2E7D32; margin-bottom: 8px;">Risk Reduction</div>
|
| 1149 |
-
<div style="font-size: 2em; font-weight: bold; color: #2E7D32;">92%</div>
|
| 1150 |
-
<div style="font-size: 0.85em; color: #666; margin-top: 5px;">Fewer incidents</div>
|
| 1151 |
-
</div>
|
| 1152 |
-
<div style="text-align: center; padding: 20px; background: white; border-radius: 10px;">
|
| 1153 |
-
<div style="font-size: 0.95em; color: #2E7D32; margin-bottom: 8px;">Decision Speed</div>
|
| 1154 |
-
<div style="font-size: 2em; font-weight: bold; color: #2E7D32;">100x</div>
|
| 1155 |
-
<div style="font-size: 0.85em; color: #666; margin-top: 5px;">Faster than manual</div>
|
| 1156 |
-
</div>
|
| 1157 |
-
<div style="text-align: center; padding: 20px; background: white; border-radius: 10px;">
|
| 1158 |
-
<div style="font-size: 0.95em; color: #2E7D32; margin-bottom: 8px;">False Positives</div>
|
| 1159 |
-
<div style="font-size: 2em; font-weight: bold; color: #2E7D32;">-85%</div>
|
| 1160 |
-
<div style="font-size: 0.85em; color: #666; margin-top: 5px;">Reduction</div>
|
| 1161 |
-
</div>
|
| 1162 |
-
<div style="text-align: center; padding: 20px; background: white; border-radius: 10px;">
|
| 1163 |
-
<div style="font-size: 0.95em; color: #2E7D32; margin-bottom: 8px;">ROI Time</div>
|
| 1164 |
-
<div style="font-size: 2em; font-weight: bold; color: #2E7D32;">3.2 mo</div>
|
| 1165 |
-
<div style="font-size: 0.85em; color: #666; margin-top: 5px;">Average payback</div>
|
| 1166 |
-
</div>
|
| 1167 |
-
</div>
|
| 1168 |
</div>
|
| 1169 |
-
|
| 1170 |
-
|
| 1171 |
-
|
| 1172 |
-
<h3 style="margin: 0 0 15px 0; color: white;">🚀 Experience the Psychological Shift</h3>
|
| 1173 |
-
<p style="margin: 0 0 25px 0; opacity: 0.9; font-size: 1.1em;">
|
| 1174 |
-
Move from uncertainty to confidence, from personal liability to system accountability
|
| 1175 |
-
</p>
|
| 1176 |
-
<div style="display: inline-flex; gap: 20px; flex-wrap: wrap; justify-content: center;">
|
| 1177 |
-
<div style="background: rgba(255, 255, 255, 0.2); padding: 12px 24px; border-radius: 25px;">
|
| 1178 |
-
<div style="font-size: 0.95em; opacity: 0.9;">Start with</div>
|
| 1179 |
-
<div style="font-weight: bold; font-size: 1.2em;">14-Day Free Trial</div>
|
| 1180 |
-
</div>
|
| 1181 |
-
<div style="background: rgba(255, 255, 255, 0.2); padding: 12px 24px; border-radius: 25px;">
|
| 1182 |
-
<div style="font-size: 0.95em; opacity: 0.9;">Then upgrade to</div>
|
| 1183 |
-
<div style="font-weight: bold; font-size: 1.2em;">Starter: $2,000/mo</div>
|
| 1184 |
-
</div>
|
| 1185 |
-
<div style="background: rgba(255, 255, 255, 0.2); padding: 12px 24px; border-radius: 25px;">
|
| 1186 |
-
<div style="font-size: 0.95em; opacity: 0.9;">Scale with</div>
|
| 1187 |
-
<div style="font-weight: bold; font-size: 1.2em;">Professional: $5,000/mo</div>
|
| 1188 |
-
</div>
|
| 1189 |
-
</div>
|
| 1190 |
</div>
|
| 1191 |
</div>
|
| 1192 |
-
|
| 1193 |
-
|
| 1194 |
-
|
| 1195 |
-
|
| 1196 |
-
|
| 1197 |
-
|
| 1198 |
-
|
| 1199 |
-
|
| 1200 |
-
|
| 1201 |
-
|
| 1202 |
-
|
| 1203 |
-
|
| 1204 |
-
|
| 1205 |
-
|
| 1206 |
-
|
| 1207 |
-
|
| 1208 |
-
|
| 1209 |
-
# ====================================================================
|
| 1210 |
-
# EVENT HANDLERS
|
| 1211 |
-
# ====================================================================
|
| 1212 |
-
process_btn.click(
|
| 1213 |
-
process_action,
|
| 1214 |
-
[scenario_select, action_input, context_input, license_input],
|
| 1215 |
-
[oss_output, enterprise_output, comparison_output, license_status]
|
| 1216 |
-
)
|
| 1217 |
-
|
| 1218 |
-
clear_btn.click(
|
| 1219 |
-
clear_inputs,
|
| 1220 |
-
outputs=[scenario_select, action_input, context_input, license_input, oss_output, enterprise_output, comparison_output, license_status]
|
| 1221 |
-
)
|
| 1222 |
-
|
| 1223 |
-
scenario_select.change(
|
| 1224 |
-
update_scenario,
|
| 1225 |
-
[scenario_select],
|
| 1226 |
-
[action_input, context_input]
|
| 1227 |
-
)
|
| 1228 |
-
|
| 1229 |
-
trial_btn.click(
|
| 1230 |
-
generate_trial,
|
| 1231 |
-
[email_input],
|
| 1232 |
-
[trial_output]
|
| 1233 |
-
)
|
| 1234 |
-
|
| 1235 |
-
# Initial load
|
| 1236 |
-
demo.load(
|
| 1237 |
-
lambda: process_action(
|
| 1238 |
-
DEMO_SCENARIOS[0]["name"],
|
| 1239 |
-
DEMO_SCENARIOS[0]["action"],
|
| 1240 |
-
json.dumps(DEMO_SCENARIOS[0]["context"]),
|
| 1241 |
-
""
|
| 1242 |
-
),
|
| 1243 |
-
outputs=[oss_output, enterprise_output, comparison_output, license_status]
|
| 1244 |
-
)
|
| 1245 |
|
| 1246 |
-
|
| 1247 |
-
|
| 1248 |
-
|
| 1249 |
-
|
| 1250 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1251 |
|
|
|
|
| 1252 |
if __name__ == "__main__":
|
| 1253 |
-
|
| 1254 |
-
|
| 1255 |
-
try:
|
| 1256 |
-
demo = create_demo_interface()
|
| 1257 |
-
demo.launch(
|
| 1258 |
-
server_name="0.0.0.0",
|
| 1259 |
-
server_port=7860,
|
| 1260 |
-
share=False,
|
| 1261 |
-
debug=False
|
| 1262 |
-
)
|
| 1263 |
-
except Exception as e:
|
| 1264 |
-
print(f"❌ Error: {e}")
|
| 1265 |
-
traceback.print_exc()
|
|
|
|
| 1 |
"""
|
| 2 |
+
ARF 3.3.9 Demo - Final Clean Version
|
| 3 |
+
Fixes all display issues
|
| 4 |
"""
|
| 5 |
|
| 6 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
| 7 |
import json
|
| 8 |
import time
|
| 9 |
import uuid
|
| 10 |
import hashlib
|
| 11 |
import random
|
| 12 |
+
from datetime import datetime, timedelta
|
| 13 |
|
| 14 |
print("=" * 70)
|
| 15 |
+
print("🚀 ARF 3.3.9 Demo - Final Version")
|
| 16 |
print("=" * 70)
|
| 17 |
|
| 18 |
+
class ARFDemo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
def __init__(self):
|
| 20 |
self.stats = {
|
| 21 |
"total_processed": 0,
|
| 22 |
"blocked_actions": 0,
|
| 23 |
"autonomous_executions": 0,
|
| 24 |
+
"avg_processing_time": 0.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
}
|
| 26 |
+
print("✅ ARF Demo initialized")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
def assess_action(self, action, context, license_key=None):
|
| 29 |
+
"""Assess an action"""
|
| 30 |
start_time = time.time()
|
| 31 |
|
| 32 |
+
# Parse context
|
| 33 |
+
if isinstance(context, str):
|
| 34 |
+
try:
|
| 35 |
+
context = json.loads(context) if context.strip() else {}
|
| 36 |
+
except:
|
| 37 |
+
context = {"environment": "production"}
|
| 38 |
+
|
| 39 |
+
# 1. Calculate risk
|
| 40 |
risk_score, confidence = self._calculate_risk(action, context)
|
| 41 |
|
| 42 |
+
# 2. Check policies
|
| 43 |
+
policy_result = self._check_policies(action, context, risk_score)
|
| 44 |
|
| 45 |
+
# 3. Validate license
|
| 46 |
license_info = self._validate_license(license_key)
|
| 47 |
|
| 48 |
+
# 4. Evaluate gates
|
| 49 |
gate_results = self._evaluate_gates(risk_score, confidence, policy_result, license_info)
|
| 50 |
|
| 51 |
+
# 5. Generate recommendation
|
| 52 |
+
recommendation = self._generate_recommendation(policy_result, gate_results, license_info)
|
|
|
|
|
|
|
| 53 |
|
| 54 |
processing_time = time.time() - start_time
|
| 55 |
|
| 56 |
+
# Update stats
|
| 57 |
+
self._update_stats(policy_result, gate_results, processing_time, license_info)
|
| 58 |
|
| 59 |
return {
|
| 60 |
"action": action,
|
|
|
|
| 61 |
"risk_score": risk_score,
|
| 62 |
"confidence": confidence,
|
| 63 |
"policy_result": policy_result,
|
| 64 |
"license_info": license_info,
|
| 65 |
"gate_results": gate_results,
|
| 66 |
+
"recommendation": recommendation,
|
| 67 |
"processing_time": processing_time,
|
| 68 |
+
"stats": self.get_stats()
|
|
|
|
| 69 |
}
|
| 70 |
|
| 71 |
+
def _calculate_risk(self, action, context):
|
| 72 |
+
"""Calculate risk score"""
|
| 73 |
action_lower = action.lower()
|
| 74 |
|
| 75 |
+
# Base risk
|
| 76 |
+
risk = 0.3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
+
# Adjust for destructive operations
|
| 79 |
if "drop database" in action_lower:
|
| 80 |
+
risk = 0.95
|
| 81 |
elif "delete from" in action_lower:
|
| 82 |
+
risk = 0.85
|
| 83 |
+
elif "truncate" in action_lower:
|
| 84 |
+
risk = 0.80
|
|
|
|
|
|
|
| 85 |
|
| 86 |
+
# Adjust for environment
|
| 87 |
+
if context.get("environment") == "production":
|
| 88 |
+
risk = min(1.0, risk + 0.2)
|
| 89 |
+
|
| 90 |
+
# Confidence
|
| 91 |
+
confidence = 0.95 if "drop" in action_lower else 0.85
|
| 92 |
+
|
| 93 |
+
return round(risk, 3), round(confidence, 3)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
+
def _check_policies(self, action, context, risk_score):
|
| 96 |
+
"""Check against policies"""
|
| 97 |
violations = []
|
|
|
|
| 98 |
|
| 99 |
+
if ("drop" in action.lower() or "delete" in action.lower()) and context.get("environment") == "production":
|
|
|
|
| 100 |
violations.append({
|
| 101 |
"policy": "Destructive Operation Prevention",
|
| 102 |
"severity": "CRITICAL",
|
| 103 |
+
"action": "BLOCK"
|
|
|
|
| 104 |
})
|
| 105 |
|
|
|
|
| 106 |
if risk_score > 0.7:
|
| 107 |
violations.append({
|
| 108 |
"policy": "High Risk Review Required",
|
| 109 |
"severity": "HIGH",
|
| 110 |
+
"action": "REQUIRE_APPROVAL"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
})
|
| 112 |
|
| 113 |
return {
|
|
|
|
| 117 |
"total_violations": len(violations)
|
| 118 |
}
|
| 119 |
|
| 120 |
+
def _validate_license(self, license_key):
|
| 121 |
+
"""Validate license key"""
|
| 122 |
if not license_key:
|
| 123 |
return {
|
| 124 |
"tier": "oss",
|
| 125 |
"valid": False,
|
| 126 |
"name": "OSS Edition",
|
| 127 |
"enforcement": "advisory",
|
| 128 |
+
"color": "#1E88E5",
|
| 129 |
+
"icon": "🔵",
|
| 130 |
+
"message": "Using ARF OSS (Open Source)"
|
| 131 |
}
|
| 132 |
|
| 133 |
if license_key.startswith("ARF-"):
|
|
|
|
| 135 |
return {
|
| 136 |
"tier": "trial",
|
| 137 |
"valid": True,
|
| 138 |
+
"name": "Trial",
|
| 139 |
"enforcement": "advisory",
|
| 140 |
+
"color": "#FFB300",
|
| 141 |
+
"icon": "🟡",
|
| 142 |
+
"message": "Trial License Active (14 days)"
|
|
|
|
| 143 |
}
|
| 144 |
elif "PRO" in license_key:
|
| 145 |
return {
|
|
|
|
| 147 |
"valid": True,
|
| 148 |
"name": "Professional",
|
| 149 |
"enforcement": "autonomous",
|
| 150 |
+
"color": "#FF9800",
|
| 151 |
+
"icon": "🟠",
|
| 152 |
+
"message": "Professional License Active"
|
|
|
|
| 153 |
}
|
| 154 |
elif "ENTERPRISE" in license_key:
|
| 155 |
return {
|
|
|
|
| 157 |
"valid": True,
|
| 158 |
"name": "Enterprise",
|
| 159 |
"enforcement": "full_mechanical",
|
| 160 |
+
"color": "#FF6F00",
|
| 161 |
+
"icon": "🔶",
|
| 162 |
+
"message": "Enterprise License Active"
|
|
|
|
| 163 |
}
|
| 164 |
|
| 165 |
return {
|
|
|
|
| 167 |
"valid": False,
|
| 168 |
"name": "Invalid",
|
| 169 |
"enforcement": "advisory",
|
| 170 |
+
"color": "#9E9E9E",
|
| 171 |
+
"icon": "❌",
|
| 172 |
+
"message": "Invalid License Key"
|
| 173 |
}
|
| 174 |
|
| 175 |
+
def _evaluate_gates(self, risk_score, confidence, policy_result, license_info):
|
| 176 |
"""Evaluate mechanical gates"""
|
| 177 |
gates = []
|
| 178 |
|
|
|
|
| 185 |
"weight": 0.3
|
| 186 |
})
|
| 187 |
|
| 188 |
+
# Gate 2: Risk Assessment
|
| 189 |
risk_threshold = 0.8 if license_info["tier"] in ["professional", "enterprise"] else 0.7
|
| 190 |
gates.append({
|
| 191 |
"name": "Risk Assessment",
|
| 192 |
"passed": risk_score <= risk_threshold,
|
| 193 |
+
"message": f"Risk {risk_score:.1%} ≤ {risk_threshold:.0%}",
|
| 194 |
"required": True,
|
| 195 |
"weight": 0.3
|
| 196 |
})
|
|
|
|
| 213 |
"weight": 0.2
|
| 214 |
})
|
| 215 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
return gates
|
| 217 |
|
| 218 |
+
def _generate_recommendation(self, policy_result, gate_results, license_info):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
"""Generate recommendation"""
|
| 220 |
if policy_result["blocked"]:
|
| 221 |
+
return "🚫 BLOCKED: Action violates safety policies"
|
| 222 |
|
| 223 |
all_gates_passed = all(g["passed"] for g in gate_results if g["required"])
|
| 224 |
|
| 225 |
if not license_info["valid"]:
|
| 226 |
+
return "🔵 OSS ADVISORY: Human review recommended"
|
| 227 |
elif all_gates_passed and license_info["tier"] in ["professional", "enterprise"]:
|
| 228 |
+
return "🟡 ENTERPRISE APPROVED: Autonomous execution permitted"
|
| 229 |
+
elif all_gates_passed and license_info["tier"] == "trial":
|
| 230 |
+
return "🎁 TRIAL: Gates passed (advisory only)"
|
| 231 |
else:
|
| 232 |
+
return "⚠️ REVIEW REQUIRED: Additional validation needed"
|
| 233 |
|
| 234 |
+
def _update_stats(self, policy_result, gate_results, processing_time, license_info):
|
| 235 |
"""Update statistics"""
|
| 236 |
self.stats["total_processed"] += 1
|
| 237 |
|
|
|
|
| 245 |
self.stats["avg_processing_time"] = (
|
| 246 |
self.stats["avg_processing_time"] * 0.9 + processing_time * 0.1
|
| 247 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 248 |
|
| 249 |
+
def get_stats(self):
|
| 250 |
+
"""Get statistics"""
|
| 251 |
stats = self.stats.copy()
|
| 252 |
|
|
|
|
| 253 |
total = stats["total_processed"]
|
| 254 |
blocked = stats["blocked_actions"]
|
| 255 |
autonomous = stats["autonomous_executions"]
|
|
|
|
| 258 |
stats["autonomous_percentage"] = round(autonomous / total * 100, 1) if total > 0 else 0.0
|
| 259 |
stats["processing_speed"] = f"{stats['avg_processing_time']*1000:.0f}ms"
|
| 260 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
return stats
|
| 262 |
|
| 263 |
+
def generate_trial_license(self, email):
|
| 264 |
+
"""Generate trial license"""
|
| 265 |
if not email or "@" not in email:
|
| 266 |
+
return {"success": False, "message": "Please enter a valid email"}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 267 |
|
| 268 |
+
license_key = f"ARF-TRIAL-{hashlib.sha256(email.encode()).hexdigest()[:8].upper()}"
|
| 269 |
|
| 270 |
return {
|
| 271 |
"success": True,
|
| 272 |
"license_key": license_key,
|
| 273 |
"message": "🎉 14-Day Trial License Generated!",
|
| 274 |
+
"expires": (datetime.now() + timedelta(days=14)).strftime("%Y-%m-%d")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 275 |
}
|
| 276 |
|
| 277 |
+
# Demo scenarios
|
|
|
|
|
|
|
|
|
|
| 278 |
DEMO_SCENARIOS = [
|
| 279 |
{
|
|
|
|
| 280 |
"name": "🔥 High-Risk Database Operation",
|
| 281 |
"action": "DROP DATABASE production_users CASCADE",
|
| 282 |
+
"context": {"environment": "production", "criticality": "critical"}
|
|
|
|
|
|
|
|
|
|
| 283 |
},
|
| 284 |
{
|
|
|
|
| 285 |
"name": "✅ Safe Service Deployment",
|
| 286 |
+
"action": "deploy_service payment_api:v2.3.1 to staging",
|
| 287 |
+
"context": {"environment": "staging", "service": "payment_api"}
|
|
|
|
|
|
|
|
|
|
| 288 |
},
|
| 289 |
{
|
|
|
|
| 290 |
"name": "🔧 Configuration Update",
|
| 291 |
+
"action": "UPDATE config SET timeout_ms=30000",
|
| 292 |
+
"context": {"environment": "production", "service": "api"}
|
|
|
|
|
|
|
|
|
|
| 293 |
}
|
| 294 |
]
|
| 295 |
|
| 296 |
+
# Initialize engine
|
| 297 |
+
arf_demo = ARFDemo()
|
|
|
|
| 298 |
|
| 299 |
+
# Create interface
|
| 300 |
+
with gr.Blocks(
|
| 301 |
+
title="ARF 3.3.9 - OSS vs Enterprise Demo",
|
| 302 |
+
theme=gr.themes.Soft(),
|
| 303 |
+
css="""
|
| 304 |
+
.gradio-container { max-width: 1400px; margin: 0 auto; }
|
| 305 |
+
.stat-card { background: white; padding: 15px; border-radius: 10px; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
|
| 306 |
+
.oss-panel { border: 2px solid #1E88E5; border-radius: 10px; padding: 20px; background: #E3F2FD; margin-bottom: 20px; }
|
| 307 |
+
.enterprise-panel { border: 2px solid #FFB300; border-radius: 10px; padding: 20px; background: #FFF8E1; margin-bottom: 20px; }
|
| 308 |
+
.gate-passed { background: #E8F5E9; padding: 10px; margin: 5px 0; border-radius: 5px; border-left: 4px solid #4CAF50; }
|
| 309 |
+
.gate-failed { background: #FFEBEE; padding: 10px; margin: 5px 0; border-radius: 5px; border-left: 4px solid #F44336; }
|
| 310 |
+
"""
|
| 311 |
+
) as demo:
|
| 312 |
|
| 313 |
+
# Header
|
| 314 |
+
gr.Markdown("""
|
| 315 |
+
# 🤖 Agentic Reliability Framework 3.3.9
|
| 316 |
+
### From Advisory to Mechanical Enforcement
|
| 317 |
+
""")
|
| 318 |
|
| 319 |
+
# Statistics
|
| 320 |
+
stats = arf_demo.get_stats()
|
| 321 |
+
gr.Markdown(f"""
|
| 322 |
+
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin: 20px 0;">
|
| 323 |
+
<div class="stat-card">
|
| 324 |
+
<div style="font-size: 0.9em; color: #1E88E5; margin-bottom: 5px;">Total Assessments</div>
|
| 325 |
+
<div style="font-size: 2em; font-weight: bold; color: #1E88E5;">{stats['total_processed']}</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 326 |
</div>
|
| 327 |
+
<div class="stat-card">
|
| 328 |
+
<div style="font-size: 0.9em; color: #F44336; margin-bottom: 5px;">Risks Prevented</div>
|
| 329 |
+
<div style="font-size: 2em; font-weight: bold; color: #F44336;">{stats['blocked_percentage']}%</div>
|
| 330 |
+
</div>
|
| 331 |
+
<div class="stat-card">
|
| 332 |
+
<div style="font-size: 0.9em; color: #4CAF50; margin-bottom: 5px;">Autonomous Rate</div>
|
| 333 |
+
<div style="font-size: 2em; font-weight: bold; color: #4CAF50;">{stats['autonomous_percentage']}%</div>
|
| 334 |
+
</div>
|
| 335 |
+
<div class="stat-card">
|
| 336 |
+
<div style="font-size: 0.9em; color: #FF9800; margin-bottom: 5px;">Processing Speed</div>
|
| 337 |
+
<div style="font-size: 2em; font-weight: bold; color: #FF9800;">{stats['processing_speed']}</div>
|
| 338 |
+
</div>
|
| 339 |
+
</div>
|
| 340 |
+
""")
|
| 341 |
+
|
| 342 |
+
# Main controls
|
| 343 |
+
with gr.Row():
|
| 344 |
+
with gr.Column(scale=2):
|
| 345 |
+
scenario = gr.Dropdown(
|
| 346 |
+
choices=[s["name"] for s in DEMO_SCENARIOS],
|
| 347 |
+
label="Select Demo Scenario",
|
| 348 |
+
value=DEMO_SCENARIOS[0]["name"]
|
| 349 |
+
)
|
| 350 |
|
| 351 |
+
action = gr.Textbox(
|
| 352 |
+
label="Action to Evaluate",
|
| 353 |
+
value=DEMO_SCENARIOS[0]["action"],
|
| 354 |
+
lines=2
|
| 355 |
+
)
|
| 356 |
|
| 357 |
+
context = gr.Textbox(
|
| 358 |
+
label="Context (JSON)",
|
| 359 |
+
value=json.dumps(DEMO_SCENARIOS[0]["context"], indent=2),
|
| 360 |
+
lines=3
|
| 361 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 362 |
|
| 363 |
+
license_key = gr.Textbox(
|
| 364 |
+
label="License Key (leave blank for OSS, use ARF-TRIAL-XXX for trial)",
|
| 365 |
+
value=""
|
| 366 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 367 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 368 |
with gr.Row():
|
| 369 |
+
process_btn = gr.Button("🚀 Process Action", variant="primary")
|
| 370 |
+
clear_btn = gr.Button("🔄 Clear")
|
| 371 |
+
|
| 372 |
+
with gr.Column(scale=1):
|
| 373 |
+
# License status
|
| 374 |
+
license_status = gr.HTML("""
|
| 375 |
+
<div style="background: #E3F2FD; padding: 15px; border-radius: 10px; text-align: center;">
|
| 376 |
+
<div style="color: #1E88E5; font-weight: bold; margin-bottom: 5px;">🔵 ARF OSS Edition</div>
|
| 377 |
+
<div style="color: #666; font-size: 0.9em;">Advisory Mode</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 378 |
</div>
|
| 379 |
+
""")
|
| 380 |
+
|
| 381 |
+
# Results
|
| 382 |
+
with gr.Row():
|
| 383 |
+
oss_output = gr.HTML(label="🔵 ARF OSS Results")
|
| 384 |
+
enterprise_output = gr.HTML(label="🟡 ARF Enterprise Results")
|
| 385 |
+
|
| 386 |
+
# Trial section
|
| 387 |
+
with gr.Accordion("Get Trial License", open=False):
|
| 388 |
+
email = gr.Textbox(label="Email")
|
| 389 |
+
trial_btn = gr.Button("Get Trial")
|
| 390 |
+
trial_output = gr.JSON(label="Trial License")
|
| 391 |
+
|
| 392 |
+
# Functions
|
| 393 |
+
def process_action(scenario_name, action_text, context_text, license_text):
|
| 394 |
+
"""Process action"""
|
| 395 |
+
try:
|
| 396 |
+
# Use scenario if selected
|
| 397 |
+
for s in DEMO_SCENARIOS:
|
| 398 |
+
if s["name"] == scenario_name:
|
| 399 |
+
action_text = s["action"]
|
| 400 |
+
context_text = json.dumps(s["context"])
|
| 401 |
+
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 402 |
|
| 403 |
+
# Process action
|
| 404 |
+
result = arf_demo.assess_action(action_text, context_text, license_text)
|
| 405 |
|
| 406 |
+
# Create displays
|
| 407 |
+
oss_html = create_oss_display(result)
|
| 408 |
+
enterprise_html = create_enterprise_display(result)
|
| 409 |
+
|
| 410 |
+
# Update license status
|
| 411 |
+
license_info = result["license_info"]
|
| 412 |
+
status_html = f"""
|
| 413 |
+
<div style="background: {license_info['color']}20; padding: 15px; border-radius: 10px; text-align: center; border: 2px solid {license_info['color']};">
|
| 414 |
+
<div style="color: {license_info['color']}; font-weight: bold; margin-bottom: 5px;">
|
| 415 |
+
{license_info['icon']} {license_info['name']}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 416 |
</div>
|
| 417 |
+
<div style="color: #666; font-size: 0.9em;">{license_info['message']}</div>
|
| 418 |
</div>
|
| 419 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 420 |
|
| 421 |
+
return oss_html, enterprise_html, status_html
|
| 422 |
+
|
| 423 |
+
except Exception as e:
|
| 424 |
+
error_html = f"<div style='color: red; padding: 20px;'>Error: {str(e)}</div>"
|
| 425 |
+
return error_html, error_html, ""
|
| 426 |
+
|
| 427 |
+
def create_oss_display(result):
|
| 428 |
+
"""Create OSS display"""
|
| 429 |
+
risk_score = result["risk_score"]
|
| 430 |
+
confidence = result["confidence"]
|
| 431 |
+
policy = result["policy_result"]
|
| 432 |
+
|
| 433 |
+
risk_color = "#F44336" if risk_score > 0.7 else "#FF9800" if risk_score > 0.4 else "#4CAF50"
|
| 434 |
+
risk_level = "HIGH" if risk_score > 0.7 else "MEDIUM" if risk_score > 0.4 else "LOW"
|
| 435 |
+
|
| 436 |
+
return f"""
|
| 437 |
+
<div class="oss-panel">
|
| 438 |
+
<h3 style="margin: 0 0 15px 0; color: #1E88E5;">🔵 ARF OSS 3.3.9</h3>
|
|
|
|
| 439 |
|
| 440 |
+
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px;">
|
| 441 |
+
<div style="text-align: center; padding: 10px; background: white; border-radius: 5px;">
|
| 442 |
+
<div style="font-size: 0.9em; color: #1E88E5;">Reliability</div>
|
| 443 |
+
<div style="font-size: 1.5em; font-weight: bold; color: #1E88E5;">{(1-risk_score):.1%}</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 444 |
</div>
|
| 445 |
+
<div style="text-align: center; padding: 10px; background: white; border-radius: 5px;">
|
| 446 |
+
<div style="font-size: 0.9em; color: {risk_color};">Risk Level</div>
|
| 447 |
+
<div style="font-size: 1.5em; font-weight: bold; color: {risk_color};">{risk_level}</div>
|
|
|
|
|
|
|
|
|
|
| 448 |
</div>
|
| 449 |
+
<div style="text-align: center; padding: 10px; background: white; border-radius: 5px;">
|
| 450 |
+
<div style="font-size: 0.9em; color: #1E88E5;">Confidence</div>
|
| 451 |
+
<div style="font-size: 1.5em; font-weight: bold; color: #1E88E5;">{confidence:.1%}</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 452 |
</div>
|
| 453 |
+
</div>
|
| 454 |
+
|
| 455 |
+
<div style="background: white; padding: 15px; border-radius: 5px; margin-bottom: 15px; border-left: 4px solid {risk_color};">
|
| 456 |
+
<div style="font-weight: bold; margin-bottom: 5px;">💡 Recommendation</div>
|
| 457 |
+
<div style="font-size: 1.1em;">{result['recommendation']}</div>
|
| 458 |
+
</div>
|
| 459 |
+
|
| 460 |
+
<div style="background: #FFF3E0; padding: 15px; border-radius: 5px;">
|
| 461 |
+
<div style="font-weight: bold; color: #E65100; margin-bottom: 10px;">⚠️ OSS Limitations</div>
|
| 462 |
+
<ul style="margin: 0; padding-left: 20px; color: #E65100;">
|
| 463 |
+
<li>Human decision required</li>
|
| 464 |
+
<li>No mechanical enforcement</li>
|
| 465 |
+
<li>{policy['total_violations']} policy violation(s)</li>
|
| 466 |
+
<li>Processing: {result['processing_time']:.4f}s</li>
|
| 467 |
+
</ul>
|
| 468 |
+
</div>
|
| 469 |
+
</div>
|
| 470 |
+
"""
|
| 471 |
+
|
| 472 |
+
def create_enterprise_display(result):
|
| 473 |
+
"""Create Enterprise display"""
|
| 474 |
+
gates = result["gate_results"]
|
| 475 |
+
license_info = result["license_info"]
|
| 476 |
+
|
| 477 |
+
# Calculate gate progress
|
| 478 |
+
required_gates = [g for g in gates if g["required"]]
|
| 479 |
+
passed_required = sum(1 for g in required_gates if g["passed"])
|
| 480 |
+
|
| 481 |
+
# Create gates HTML
|
| 482 |
+
gates_html = ""
|
| 483 |
+
for gate in gates:
|
| 484 |
+
gate_class = "gate-passed" if gate["passed"] else "gate-failed"
|
| 485 |
+
icon = "✅" if gate["passed"] else "❌"
|
| 486 |
+
gates_html += f"""
|
| 487 |
+
<div class="{gate_class}">
|
| 488 |
+
<div style="display: flex; align-items: center;">
|
| 489 |
+
<span style="font-size: 20px; margin-right: 10px;">{icon}</span>
|
| 490 |
+
<div>
|
| 491 |
+
<div style="font-weight: 500;">{gate['name']}</div>
|
| 492 |
+
<div style="font-size: 0.9em; color: #666;">{gate['message']}</div>
|
| 493 |
</div>
|
|
|
|
| 494 |
</div>
|
| 495 |
</div>
|
| 496 |
"""
|
| 497 |
|
| 498 |
+
return f"""
|
| 499 |
+
<div class="enterprise-panel" style="border-color: {license_info['color']};">
|
| 500 |
+
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px;">
|
| 501 |
+
<h3 style="margin: 0; color: {license_info['color']};">🟡 ARF Enterprise 3.3.9</h3>
|
| 502 |
+
<span style="background: {license_info['color']}20; padding: 5px 10px; border-radius: 15px; color: {license_info['color']}; font-weight: bold;">
|
| 503 |
+
{license_info['name'].upper()}
|
| 504 |
+
</span>
|
| 505 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 506 |
|
| 507 |
+
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px;">
|
| 508 |
+
<div style="text-align: center; padding: 10px; background: white; border-radius: 5px;">
|
| 509 |
+
<div style="font-size: 0.9em; color: {license_info['color']};">License</div>
|
| 510 |
+
<div style="font-size: 1.2em; font-weight: bold; color: {license_info['color']};">{license_info['name']}</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 511 |
</div>
|
| 512 |
+
<div style="text-align: center; padding: 10px; background: white; border-radius: 5px;">
|
| 513 |
+
<div style="font-size: 0.9em; color: {license_info['color']};">Gates Passed</div>
|
| 514 |
+
<div style="font-size: 1.5em; font-weight: bold; color: {license_info['color']};">{passed_required}/{len(required_gates)}</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 515 |
</div>
|
| 516 |
+
<div style="text-align: center; padding: 10px; background: white; border-radius: 5px;">
|
| 517 |
+
<div style="font-size: 0.9em; color: {license_info['color']};">Enforcement</div>
|
| 518 |
+
<div style="font-size: 1em; font-weight: bold; color: {license_info['color']};">{license_info['enforcement'].title()}</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 519 |
</div>
|
| 520 |
</div>
|
| 521 |
+
|
| 522 |
+
<div style="margin-bottom: 20px;">
|
| 523 |
+
<div style="font-weight: bold; margin-bottom: 10px; color: {license_info['color']};">Mechanical Gates</div>
|
| 524 |
+
{gates_html}
|
| 525 |
+
</div>
|
| 526 |
+
|
| 527 |
+
<div style="background: #E8F5E9; padding: 15px; border-radius: 5px;">
|
| 528 |
+
<div style="font-weight: bold; color: #2E7D32; margin-bottom: 10px;">🚀 Enterprise Benefits</div>
|
| 529 |
+
<ul style="margin: 0; padding-left: 20px; color: #2E7D32;">
|
| 530 |
+
<li>Mechanical enforcement with gates</li>
|
| 531 |
+
<li>Processing: {result['processing_time']:.4f}s</li>
|
| 532 |
+
<li>{license_info['message']}</li>
|
| 533 |
+
</ul>
|
| 534 |
+
</div>
|
| 535 |
+
</div>
|
| 536 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 537 |
|
| 538 |
+
def generate_trial(email_text):
|
| 539 |
+
"""Generate trial license"""
|
| 540 |
+
return arf_demo.generate_trial_license(email_text)
|
| 541 |
+
|
| 542 |
+
# Connect events
|
| 543 |
+
process_btn.click(
|
| 544 |
+
process_action,
|
| 545 |
+
[scenario, action, context, license_key],
|
| 546 |
+
[oss_output, enterprise_output, license_status]
|
| 547 |
+
)
|
| 548 |
+
|
| 549 |
+
trial_btn.click(
|
| 550 |
+
generate_trial,
|
| 551 |
+
[email],
|
| 552 |
+
[trial_output]
|
| 553 |
+
)
|
| 554 |
+
|
| 555 |
+
# Initial load
|
| 556 |
+
demo.load(
|
| 557 |
+
lambda: process_action(
|
| 558 |
+
DEMO_SCENARIOS[0]["name"],
|
| 559 |
+
DEMO_SCENARIOS[0]["action"],
|
| 560 |
+
json.dumps(DEMO_SCENARIOS[0]["context"]),
|
| 561 |
+
""
|
| 562 |
+
),
|
| 563 |
+
outputs=[oss_output, enterprise_output, license_status]
|
| 564 |
+
)
|
| 565 |
|
| 566 |
+
# Launch
|
| 567 |
if __name__ == "__main__":
|
| 568 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|