Update ui/components.py
Browse files- ui/components.py +129 -304
ui/components.py
CHANGED
|
@@ -1157,318 +1157,143 @@ def update_performance_metrics(scenario_name: str, scenarios=INCIDENT_SCENARIOS)
|
|
| 1157 |
return detection_time_html, recall_quality_html, confidence_score_html, sequencing_stage_html
|
| 1158 |
|
| 1159 |
# 2. Update create_tab1_incident_demo to use the SAME variable names:
|
| 1160 |
-
|
|
|
|
| 1161 |
"""
|
| 1162 |
-
|
| 1163 |
-
|
|
|
|
|
|
|
|
|
|
| 1164 |
"""
|
|
|
|
| 1165 |
|
| 1166 |
-
#
|
| 1167 |
-
|
| 1168 |
-
|
| 1169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1170 |
|
| 1171 |
-
|
| 1172 |
-
|
| 1173 |
-
|
| 1174 |
-
|
| 1175 |
-
|
| 1176 |
-
|
| 1177 |
-
|
| 1178 |
-
|
| 1179 |
-
|
| 1180 |
-
|
| 1181 |
-
|
| 1182 |
-
|
| 1183 |
-
|
| 1184 |
-
|
| 1185 |
-
|
| 1186 |
-
|
| 1187 |
-
|
| 1188 |
-
|
| 1189 |
-
|
| 1190 |
-
|
| 1191 |
-
|
| 1192 |
-
|
| 1193 |
-
|
| 1194 |
-
|
| 1195 |
-
|
| 1196 |
-
|
| 1197 |
-
|
| 1198 |
-
|
| 1199 |
-
|
| 1200 |
-
|
| 1201 |
-
|
| 1202 |
-
|
| 1203 |
-
|
| 1204 |
-
|
| 1205 |
-
|
| 1206 |
-
|
| 1207 |
-
|
| 1208 |
-
|
| 1209 |
-
|
| 1210 |
-
|
| 1211 |
-
|
| 1212 |
-
<span style="padding: 3px 8px; background: #f1f5f9; border-radius: 6px; font-size: 11px; color: #475569; font-weight: 500;">{default_scenario_data.get('component', 'unknown').split('_')[0]}</span>
|
| 1213 |
-
<span style="padding: 3px 8px; background: #f1f5f9; border-radius: 6px; font-size: 11px; color: #475569; font-weight: 500;">variance</span>
|
| 1214 |
-
<span style="padding: 3px 8px; background: #f1f5f9; border-radius: 6px; font-size: 11px; color: #475569; font-weight: 500;">production</span>
|
| 1215 |
-
<span style="padding: 3px 8px; background: #f1f5f9; border-radius: 6px; font-size: 11px; color: #475569; font-weight: 500;">pattern</span>
|
| 1216 |
-
</div>
|
| 1217 |
-
</div>
|
| 1218 |
-
</div>
|
| 1219 |
-
""")
|
| 1220 |
-
|
| 1221 |
-
# Visualization section
|
| 1222 |
-
with gr.Row():
|
| 1223 |
-
with gr.Column(scale=1):
|
| 1224 |
-
telemetry_header = gr.Markdown("### π Live Telemetry")
|
| 1225 |
-
telemetry_viz = gr.Plot(
|
| 1226 |
-
label="",
|
| 1227 |
-
show_label=False,
|
| 1228 |
-
elem_id="telemetry_plot"
|
| 1229 |
-
)
|
| 1230 |
-
|
| 1231 |
-
with gr.Column(scale=1):
|
| 1232 |
-
impact_header = gr.Markdown("### π° Business Impact")
|
| 1233 |
-
impact_viz = gr.Plot(
|
| 1234 |
-
label="",
|
| 1235 |
-
show_label=False,
|
| 1236 |
-
elem_id="impact_plot"
|
| 1237 |
-
)
|
| 1238 |
-
|
| 1239 |
-
# Middle Column: Process Workflow (NOT Agent Workflow)
|
| 1240 |
-
with gr.Column(scale=2, variant="panel") as middle_col:
|
| 1241 |
-
# ============ OBSERVATION GATE PLACEHOLDER ============
|
| 1242 |
-
observation_gate_placeholder = create_observation_gate_placeholder()
|
| 1243 |
-
|
| 1244 |
-
# ============ SEQUENCING VISUALIZATION ============
|
| 1245 |
-
sequencing_header = gr.Markdown("### π Sequencing Logic: Dampening β Concurrency β Observe β Scale")
|
| 1246 |
-
sequencing_panel = create_sequencing_visualization()
|
| 1247 |
-
|
| 1248 |
-
# Process Workflow Header (NOT Agent Workflow)
|
| 1249 |
-
workflow_header = gr.Markdown("## π Policy Process Workflow")
|
| 1250 |
-
workflow_subheader = gr.Markdown("### How the system transforms variance into policy execution")
|
| 1251 |
-
|
| 1252 |
-
# Process Status Cards (NOT Agent Status Cards)
|
| 1253 |
-
with gr.Row():
|
| 1254 |
-
detection_process = create_detection_display()
|
| 1255 |
-
recall_process = create_recall_display()
|
| 1256 |
-
decision_process = create_decision_display()
|
| 1257 |
-
|
| 1258 |
-
# Mode Selection & Safety Controls
|
| 1259 |
-
with gr.Row():
|
| 1260 |
-
with gr.Column(scale=1):
|
| 1261 |
-
approval_toggle = gr.CheckboxGroup(
|
| 1262 |
-
choices=["π€ Require Human Approval"],
|
| 1263 |
-
label="Safety Controls",
|
| 1264 |
-
value=[],
|
| 1265 |
-
info="Toggle human oversight"
|
| 1266 |
-
)
|
| 1267 |
-
|
| 1268 |
-
with gr.Column(scale=2):
|
| 1269 |
-
mcp_mode = gr.Radio(
|
| 1270 |
-
choices=["π‘οΈ Advisory (OSS Only)", "π₯ Approval", "β‘ Autonomous"],
|
| 1271 |
-
value="π‘οΈ Advisory (OSS Only)",
|
| 1272 |
-
label="Policy Safety Mode",
|
| 1273 |
-
info="Control execution safety level",
|
| 1274 |
-
interactive=True
|
| 1275 |
-
)
|
| 1276 |
-
|
| 1277 |
-
# OSS vs Enterprise Boundary Visualization
|
| 1278 |
-
boundary_header = gr.Markdown("### π Policy vs Execution: The Safety Boundary")
|
| 1279 |
-
|
| 1280 |
-
with gr.Row():
|
| 1281 |
-
oss_section = create_oss_advisory_section()
|
| 1282 |
-
|
| 1283 |
-
enterprise_section = gr.HTML("""
|
| 1284 |
-
<div style="padding: 25px; border-radius: 16px; margin-bottom: 15px; flex: 1; min-height: 320px;
|
| 1285 |
-
background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%); border: 2px solid #10b981;">
|
| 1286 |
-
<div style="display: flex; align-items: center; gap: 10px; margin-bottom: 20px; padding-bottom: 15px; border-bottom: 2px solid rgba(16, 185, 129, 0.2);">
|
| 1287 |
-
<div style="font-size: 32px;">π°</div>
|
| 1288 |
-
<div>
|
| 1289 |
-
<h3 style="margin: 0 0 5px 0; font-size: 20px; color: #1e293b;">Execution Edition</h3>
|
| 1290 |
-
<p style="margin: 0; font-size: 14px; color: #64748b;">Full Execution & Learning - Commercial</p>
|
| 1291 |
-
</div>
|
| 1292 |
-
<div style="margin-left: auto; padding: 6px 14px; background: rgba(255, 255, 255, 0.9);
|
| 1293 |
-
border-radius: 10px; font-size: 11px; font-weight: bold; color: #475569;">
|
| 1294 |
-
REQUIRES LICENSE
|
| 1295 |
-
</div>
|
| 1296 |
-
</div>
|
| 1297 |
-
|
| 1298 |
-
<div style="background: white; border-radius: 12px; padding: 20px; box-shadow: 0 4px 12px rgba(0,0,0,0.05); margin-bottom: 20px;">
|
| 1299 |
-
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; padding-bottom: 12px; border-bottom: 1px solid #f1f5f9;">
|
| 1300 |
-
<h4 style="margin: 0; font-size: 16px; color: #1e293b;">β‘ Ready to Execute</h4>
|
| 1301 |
-
<span style="padding: 6px 12px; background: #10b981; color: white; border-radius: 8px; font-size: 12px; font-weight: bold; text-transform: uppercase;">AUTONOMOUS</span>
|
| 1302 |
-
</div>
|
| 1303 |
-
|
| 1304 |
-
<div style="margin-bottom: 15px;">
|
| 1305 |
-
<div style="display: flex; align-items: center; gap: 10px; margin-bottom: 10px;">
|
| 1306 |
-
<div style="width: 24px; height: 24px; background: #3b82f6; color: white; border-radius: 50%;
|
| 1307 |
-
display: flex; align-items: center; justify-content: center; font-size: 12px;">
|
| 1308 |
-
βοΈ
|
| 1309 |
-
</div>
|
| 1310 |
-
<div>
|
| 1311 |
-
<div style="font-size: 14px; color: #475569; font-weight: 500;">Mode</div>
|
| 1312 |
-
<div style="font-size: 13px; color: #1e293b;">Autonomous (Requires Enterprise license)</div>
|
| 1313 |
-
</div>
|
| 1314 |
-
</div>
|
| 1315 |
-
|
| 1316 |
-
<div style="display: flex; align-items: center; gap: 10px; margin-bottom: 10px;">
|
| 1317 |
-
<div style="width: 24px; height: 24px; background: #10b981; color: white; border-radius: 50%;
|
| 1318 |
-
display: flex; align-items: center; justify-content: center; font-size: 12px;">
|
| 1319 |
-
β‘
|
| 1320 |
-
</div>
|
| 1321 |
-
<div>
|
| 1322 |
-
<div style="font-size: 14px; color: #475569; font-weight: 500;">Expected Recovery</div>
|
| 1323 |
-
<div style="font-size: 13px; color: #1e293b;">12 minutes (vs 45 min manual)</div>
|
| 1324 |
-
</div>
|
| 1325 |
-
</div>
|
| 1326 |
-
|
| 1327 |
-
<div style="display: flex; align-items: center; gap: 10px; margin-bottom: 10px;">
|
| 1328 |
-
<div style="width: 24px; height: 24px; background: #f59e0b; color: white; border-radius: 50%;
|
| 1329 |
-
display: flex; align-items: center; justify-content: center; font-size: 12px;">
|
| 1330 |
-
π°
|
| 1331 |
-
</div>
|
| 1332 |
-
<div>
|
| 1333 |
-
<div style="font-size: 14px; color: #475569; font-weight: 500;">Cost Avoided</div>
|
| 1334 |
-
<div style="font-size: 13px; color: #10b981; font-weight: 700;">$6,375</div>
|
| 1335 |
-
</div>
|
| 1336 |
-
</div>
|
| 1337 |
-
|
| 1338 |
-
<div style="display: flex; align-items: center; gap: 10px;">
|
| 1339 |
-
<div style="width: 24px; height: 24px; background: #8b5cf6; color: white; border-radius: 50%;
|
| 1340 |
-
display: flex; align-items: center; justify-content: center; font-size: 12px;">
|
| 1341 |
-
π₯
|
| 1342 |
-
</div>
|
| 1343 |
-
<div>
|
| 1344 |
-
<div style="font-size: 14px; color: #475569; font-weight: 500;">Users Protected</div>
|
| 1345 |
-
<div style="font-size: 13px; color: #1e293b;">45,000 β 0 impacted</div>
|
| 1346 |
-
</div>
|
| 1347 |
-
</div>
|
| 1348 |
-
</div>
|
| 1349 |
-
</div>
|
| 1350 |
-
|
| 1351 |
-
<!-- Enterprise Boundary -->
|
| 1352 |
-
<div style="text-align: center;">
|
| 1353 |
-
<div style="height: 2px; background: linear-gradient(90deg, transparent, #10b981, transparent); margin: 8px 0;"></div>
|
| 1354 |
-
<div style="padding: 10px; background: #dcfce7; color: #166534; border-radius: 10px;
|
| 1355 |
-
font-size: 14px; font-weight: bold; display: inline-block; border: 2px solid #10b981;">
|
| 1356 |
-
β
Enterprise executes with MCP safety
|
| 1357 |
-
</div>
|
| 1358 |
-
<div style="height: 2px; background: linear-gradient(90deg, transparent, #10b981, transparent); margin: 8px 0;"></div>
|
| 1359 |
-
|
| 1360 |
-
<div style="margin-top: 15px; padding: 12px; background: rgba(255, 255, 255, 0.8); border-radius: 10px;">
|
| 1361 |
-
<div style="font-size: 13px; color: #475569; font-weight: 500;">
|
| 1362 |
-
Enterprise edition adds execution, learning, and safety guarantees.
|
| 1363 |
-
</div>
|
| 1364 |
-
<div style="font-size: 12px; color: #64748b; margin-top: 5px;">
|
| 1365 |
-
MCP safety modes: Advisory β Approval β Autonomous
|
| 1366 |
-
</div>
|
| 1367 |
-
</div>
|
| 1368 |
-
</div>
|
| 1369 |
-
</div>
|
| 1370 |
-
""")
|
| 1371 |
-
|
| 1372 |
-
# Execution Controls
|
| 1373 |
-
with gr.Row():
|
| 1374 |
-
with gr.Column(scale=1):
|
| 1375 |
-
oss_btn = gr.Button(
|
| 1376 |
-
"π Run Policy Analysis",
|
| 1377 |
-
variant="secondary",
|
| 1378 |
-
size="lg"
|
| 1379 |
-
)
|
| 1380 |
-
oss_info = gr.Markdown("*Free, policy-only analysis*")
|
| 1381 |
-
|
| 1382 |
-
with gr.Column(scale=1):
|
| 1383 |
-
enterprise_btn = gr.Button(
|
| 1384 |
-
"π° Execute Enterprise Healing",
|
| 1385 |
-
variant="primary",
|
| 1386 |
-
size="lg"
|
| 1387 |
-
)
|
| 1388 |
-
enterprise_info = gr.Markdown("*Requires Enterprise license*")
|
| 1389 |
-
|
| 1390 |
-
# Timeline visualization
|
| 1391 |
-
timeline_header = gr.Markdown("### β° Incident Timeline")
|
| 1392 |
-
timeline_viz = gr.Plot(
|
| 1393 |
-
create_timeline_comparison_plot(),
|
| 1394 |
-
label="",
|
| 1395 |
-
show_label=False,
|
| 1396 |
-
elem_id="timeline_plot"
|
| 1397 |
-
)
|
| 1398 |
-
|
| 1399 |
-
# Right Column: Results & Metrics
|
| 1400 |
-
with gr.Column(scale=1, variant="panel") as right_col:
|
| 1401 |
-
# Real-time Metrics Dashboard
|
| 1402 |
-
metrics_header = gr.Markdown("## π Performance Metrics")
|
| 1403 |
-
|
| 1404 |
-
# Metric Cards Grid - MUST MATCH app.py demo_btn.click() expectations!
|
| 1405 |
-
detection_time = gr.HTML()
|
| 1406 |
-
recall_quality = gr.HTML() # Changed from mttr to match demo_btn.click()
|
| 1407 |
-
confidence_score = gr.HTML() # Changed from auto_heal to match demo_btn.click()
|
| 1408 |
-
sequencing_stage = gr.HTML() # Changed from savings to match demo_btn.click()
|
| 1409 |
-
|
| 1410 |
-
# Results Display Areas
|
| 1411 |
-
oss_results_header = gr.Markdown("### π Policy Analysis Results")
|
| 1412 |
-
oss_results_display = gr.JSON(
|
| 1413 |
-
label="",
|
| 1414 |
-
value={
|
| 1415 |
-
"status": "Analysis Pending",
|
| 1416 |
-
"processes": ["Detection", "Recall", "Decision"],
|
| 1417 |
-
"mode": "Advisory Only",
|
| 1418 |
-
"action": "Generate Formal HealingIntent"
|
| 1419 |
-
},
|
| 1420 |
-
height=200
|
| 1421 |
-
)
|
| 1422 |
-
|
| 1423 |
-
enterprise_results_header = gr.Markdown("### π° Execution Results")
|
| 1424 |
-
enterprise_results_display = gr.JSON(
|
| 1425 |
-
label="",
|
| 1426 |
-
value={
|
| 1427 |
-
"status": "Execution Pending",
|
| 1428 |
-
"requires_license": True,
|
| 1429 |
-
"available_modes": ["Approval", "Autonomous"],
|
| 1430 |
-
"expected_outcome": "12m MTTR, $6.3K saved"
|
| 1431 |
-
},
|
| 1432 |
-
height=200
|
| 1433 |
-
)
|
| 1434 |
-
|
| 1435 |
-
# Approval Status
|
| 1436 |
-
approval_display = gr.HTML("""
|
| 1437 |
-
<div style="border: 2px solid #e2e8f0; border-radius: 14px; padding: 20px; background: white; margin-top: 20px;">
|
| 1438 |
-
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; padding-bottom: 12px; border-bottom: 2px solid #f1f5f9;">
|
| 1439 |
-
<h4 style="margin: 0; font-size: 16px; color: #1e293b;">π€ Human Approval Status</h4>
|
| 1440 |
-
<span style="padding: 4px 12px; background: #10b981; color: white; border-radius: 8px; font-size: 12px; font-weight: bold; text-transform: uppercase;">Not Required</span>
|
| 1441 |
-
</div>
|
| 1442 |
-
<div style="margin-top: 15px;">
|
| 1443 |
-
<p style="margin: 8px 0; font-size: 14px; color: #475569;"><strong>Current Mode:</strong> Advisory (Policy Only)</p>
|
| 1444 |
-
<p style="margin: 8px 0; font-size: 14px; color: #475569; font-style: italic;">Switch to "Approval" mode to enable human-in-the-loop workflows</p>
|
| 1445 |
-
<div style="display: flex; flex-direction: column; gap: 10px; margin-top: 20px;">
|
| 1446 |
-
<div style="padding: 12px; background: #f8fafc; border-radius: 10px; border-left: 4px solid #3b82f6; font-size: 14px; color: #475569; font-weight: 500;">1. System generates formal HealingIntent</div>
|
| 1447 |
-
<div style="padding: 12px; background: #f8fafc; border-radius: 10px; border-left: 4px solid #3b82f6; font-size: 14px; color: #475569; font-weight: 500;">2. Human reviews & approves contraindications</div>
|
| 1448 |
-
<div style="padding: 12px; background: #f8fafc; border-radius: 10px; border-left: 4px solid #3b82f6; font-size: 14px; color: #475569; font-weight: 500;">3. System executes with sequencing constraints</div>
|
| 1449 |
-
</div>
|
| 1450 |
-
</div>
|
| 1451 |
-
</div>
|
| 1452 |
-
""")
|
| 1453 |
-
|
| 1454 |
-
# Demo Actions
|
| 1455 |
-
demo_btn = gr.Button(
|
| 1456 |
-
"βΆοΈ Run Complete Walkthrough",
|
| 1457 |
-
variant="secondary",
|
| 1458 |
-
size="lg"
|
| 1459 |
-
)
|
| 1460 |
-
demo_info = gr.Markdown("*Experience the full workflow from detection to resolution*")
|
| 1461 |
|
| 1462 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1463 |
return (
|
| 1464 |
-
# Left column returns (5 values)
|
| 1465 |
scenario_dropdown, historical_panel, scenario_card, telemetry_viz, impact_viz,
|
| 1466 |
-
|
| 1467 |
-
|
| 1468 |
-
|
| 1469 |
approval_toggle, mcp_mode, timeline_viz,
|
| 1470 |
-
|
| 1471 |
-
detection_time, recall_quality, confidence_score, sequencing_stage, # Changed to match app.py
|
| 1472 |
oss_results_display, enterprise_results_display, approval_display, demo_btn
|
| 1473 |
)
|
| 1474 |
# -----------------------------
|
|
|
|
| 1157 |
return detection_time_html, recall_quality_html, confidence_score_html, sequencing_stage_html
|
| 1158 |
|
| 1159 |
# 2. Update create_tab1_incident_demo to use the SAME variable names:
|
| 1160 |
+
|
| 1161 |
+
def create_tab1_incident_demo():
|
| 1162 |
"""
|
| 1163 |
+
Creates Live Demo Tab components with psychological advantage baked in.
|
| 1164 |
+
Returns EXACTLY 26 values matching app.py expectations.
|
| 1165 |
+
|
| 1166 |
+
Canonical Question: "What should we do right now?" (Policy advice only)
|
| 1167 |
+
No business metrics allowed in this tab.
|
| 1168 |
"""
|
| 1169 |
+
import gradio as gr
|
| 1170 |
|
| 1171 |
+
# 1. Core Scenario Selection (Psychological: User controls context)
|
| 1172 |
+
scenario_dropdown = gr.Dropdown(
|
| 1173 |
+
choices=["Retry Storm Amplification", "Cascading Dependency Failure",
|
| 1174 |
+
"Partial Regional Outage", "Latent Configuration Drift"],
|
| 1175 |
+
value="Retry Storm Amplification",
|
| 1176 |
+
label="Select Incident Scenario",
|
| 1177 |
+
info="Choose the operational context for policy evaluation"
|
| 1178 |
+
)
|
| 1179 |
|
| 1180 |
+
# 2. Historical Evidence Panel (DOMINANT VISUALLY - psychological advantage)
|
| 1181 |
+
historical_panel = gr.DataFrame(
|
| 1182 |
+
value=[
|
| 1183 |
+
["2024-03-15", "US-East", "Retry Storm", "Dampen β Observe β Scale", "Contained in 42s"],
|
| 1184 |
+
["2024-02-28", "EU-West", "Cascading Failure", "Dampen β Isolate β Repair", "Contained in 3m 18s"],
|
| 1185 |
+
["2024-01-12", "AP-South", "Config Drift", "Observe β Diagnose β Fix", "Prevented outage"]
|
| 1186 |
+
],
|
| 1187 |
+
headers=["Date", "Environment", "Pattern", "Sequence Applied", "Outcome"],
|
| 1188 |
+
label="π Historical Evidence Dominates Models",
|
| 1189 |
+
interactive=False,
|
| 1190 |
+
height=200
|
| 1191 |
+
)
|
| 1192 |
+
|
| 1193 |
+
# 3. Scenario Context Card
|
| 1194 |
+
scenario_card = gr.Markdown("""
|
| 1195 |
+
### Scenario Context: Retry Storm Amplification
|
| 1196 |
+
**What we're seeing:** Client retries triggering backend amplification (8x retry multiplier)
|
| 1197 |
+
**Current state:** 42% error rate, rising at 3.2%/minute
|
| 1198 |
+
**Risk profile:** Service degradation β Partial outage in 8-12 minutes
|
| 1199 |
+
""")
|
| 1200 |
+
|
| 1201 |
+
# 4. Telemetry Visualization (Psychological: Show what's knowable)
|
| 1202 |
+
telemetry_viz = gr.Plot(
|
| 1203 |
+
value=create_telemetry_plot(),
|
| 1204 |
+
label="Real-time Telemetry: Error Rate & Load"
|
| 1205 |
+
)
|
| 1206 |
+
|
| 1207 |
+
# 5. Business Impact Visualization (Psychological: Show consequences)
|
| 1208 |
+
impact_viz = gr.Plot(
|
| 1209 |
+
value=create_impact_plot(),
|
| 1210 |
+
label="Predicted Impact Trajectory"
|
| 1211 |
+
)
|
| 1212 |
+
|
| 1213 |
+
# 6. OBSERVATION GATE (CRITICAL PSYCHOLOGICAL ELEMENT)
|
| 1214 |
+
observation_gate_placeholder = create_observation_gate_placeholder()
|
| 1215 |
+
|
| 1216 |
+
# 7. SEQUENCING VISUALIZATION (Policy, not reaction)
|
| 1217 |
+
sequencing_panel = create_sequencing_visualization()
|
| 1218 |
+
|
| 1219 |
+
# 8. Workflow Header
|
| 1220 |
+
workflow_header = gr.Markdown("### Policy Execution Sequence")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1221 |
|
| 1222 |
+
# 9-11. PROCESS DISPLAYS (Doctrinal: "Process" not "Agent")
|
| 1223 |
+
detection_process = create_detection_display("DETECTION_PROCESS")
|
| 1224 |
+
recall_process = create_recall_display("RECALL_PROCESS")
|
| 1225 |
+
decision_process = create_decision_display("DECISION_PROCESS")
|
| 1226 |
+
|
| 1227 |
+
# 12-14. OSS/Enterprise Boundary
|
| 1228 |
+
oss_section = gr.Markdown("#### π Open Source Capabilities")
|
| 1229 |
+
enterprise_section = gr.Markdown("#### π Enterprise Governance")
|
| 1230 |
+
oss_btn = gr.Button("View OSS Implementation", variant="secondary", size="sm")
|
| 1231 |
+
enterprise_btn = gr.Button("Requires Enterprise License", variant="secondary", size="sm")
|
| 1232 |
+
|
| 1233 |
+
# 15-17. Approval & MCP
|
| 1234 |
+
approval_toggle = gr.Checkbox(
|
| 1235 |
+
label="Manual Approval Required",
|
| 1236 |
+
value=True,
|
| 1237 |
+
info="Policy: Human approval required for scaling actions during retry storms"
|
| 1238 |
+
)
|
| 1239 |
+
mcp_mode = gr.Radio(
|
| 1240 |
+
choices=["Policy Evaluation", "Manual Control", "Full Autonomous"],
|
| 1241 |
+
value="Policy Evaluation",
|
| 1242 |
+
label="Execution Mode"
|
| 1243 |
+
)
|
| 1244 |
+
timeline_viz = gr.Plot(value=create_timeline_plot())
|
| 1245 |
+
|
| 1246 |
+
# 18-21. PERFORMANCE METRICS (CRITICAL: Must match app.py indices 18-21)
|
| 1247 |
+
detection_time = gr.Number(
|
| 1248 |
+
value=2.8,
|
| 1249 |
+
label="Detection Time (seconds)",
|
| 1250 |
+
precision=1
|
| 1251 |
+
)
|
| 1252 |
+
|
| 1253 |
+
# INDEX 19: MUST BE recall_quality (not mttr)
|
| 1254 |
+
recall_quality = gr.Number(
|
| 1255 |
+
value=0.92,
|
| 1256 |
+
label="Recall Quality Score",
|
| 1257 |
+
precision=2,
|
| 1258 |
+
info="Historical match confidence"
|
| 1259 |
+
)
|
| 1260 |
+
|
| 1261 |
+
# INDEX 20: MUST BE confidence_score (not auto_heal)
|
| 1262 |
+
confidence_score = gr.Number(
|
| 1263 |
+
value=0.65,
|
| 1264 |
+
label="System Confidence",
|
| 1265 |
+
precision=2,
|
| 1266 |
+
info="Policy execution confidence < 70% triggers observation gate"
|
| 1267 |
+
)
|
| 1268 |
+
|
| 1269 |
+
# INDEX 21: MUST BE sequencing_stage (not savings)
|
| 1270 |
+
sequencing_stage = gr.Textbox(
|
| 1271 |
+
value="Dampening",
|
| 1272 |
+
label="Current Sequencing Stage",
|
| 1273 |
+
info="Policy: Dampen β Observe β Concurrent Fix β Scale"
|
| 1274 |
+
)
|
| 1275 |
+
|
| 1276 |
+
# 22-24. Results Displays
|
| 1277 |
+
oss_results_display = gr.Markdown("### OSS Results Will Appear Here")
|
| 1278 |
+
enterprise_results_display = gr.Markdown("### Enterprise Results Will Appear Here")
|
| 1279 |
+
approval_display = gr.Markdown("**Status:** Awaiting manual approval per policy")
|
| 1280 |
+
|
| 1281 |
+
# 25. DEMO BUTTON (CRITICAL: Index 25 must be demo_btn)
|
| 1282 |
+
demo_btn = gr.Button(
|
| 1283 |
+
"βΆοΈ Run Complete Walkthrough",
|
| 1284 |
+
variant="primary",
|
| 1285 |
+
size="lg",
|
| 1286 |
+
elem_id="demo_primary_btn"
|
| 1287 |
+
)
|
| 1288 |
+
|
| 1289 |
+
# RETURN EXACTLY 26 VALUES IN CORRECT ORDER
|
| 1290 |
return (
|
|
|
|
| 1291 |
scenario_dropdown, historical_panel, scenario_card, telemetry_viz, impact_viz,
|
| 1292 |
+
observation_gate_placeholder, sequencing_panel, workflow_header,
|
| 1293 |
+
detection_process, recall_process, decision_process,
|
| 1294 |
+
oss_section, enterprise_section, oss_btn, enterprise_btn,
|
| 1295 |
approval_toggle, mcp_mode, timeline_viz,
|
| 1296 |
+
detection_time, recall_quality, confidence_score, sequencing_stage, # β CORRECT VARIABLES
|
|
|
|
| 1297 |
oss_results_display, enterprise_results_display, approval_display, demo_btn
|
| 1298 |
)
|
| 1299 |
# -----------------------------
|