Implement XIC v2 control flow with IF, MATCH, LOOP operations
PHASE A: Safe predicate evaluator (glyphos/control/predicate.py) - AST-based safe expression evaluation - Supports comparisons, boolean ops, attribute access - Helper function: dominant_contains() - Protected against code injection attacks PHASE B: XICContext queue helpers - enqueue_chain(label) for FIFO chain scheduling - pop_next_chain() to get next scheduled chain - jump_to(label) for immediate destination changes PHASE C: Control flow operations (xic_ops.py) - op_IF: Conditional branching with optional else - op_MATCH: Pattern matching against fused fields - op_LOOP: Iterative execution with guardrails - Added to OP_TABLE for operation dispatch PHASE D: Execution loop enhancement (xic_vm.py) - Chain queue scheduling with label matching - Total steps tracking for guardrail enforcement - max_total_steps limit across all operations - Graceful execution stop on guardrail trigger PHASE E: Comprehensive test suite (tests/test_control_flow.py) - 14 unit tests covering all operations - Predicate evaluator tests - IF/MATCH/LOOP operation tests - Queue helper and guardrail tests - All tests passing (14/14) PHASE F: Example programs - demo_control_flow_if.gx.json: IF branching example - demo_control_flow_loop.gx.json: LOOP iteration example PHASE G: Complete documentation - XIC_V2_CONTROL_FLOW_SUMMARY.md: Technical guide - XIC_V2_QUICK_REFERENCE.md: Developer quick reference - FedMart UI and integration documentation Integration points: - FedMart telemetry captures control flow steps - UI dashboard displays control branching - Symbolic pipeline predicate evaluation - 100% backward compatible with XIC v1.5 Test results: 36/36 passing (14 control flow + 12 FedMart + 10 UI) Status: Production ready
This commit is contained in:
@@ -0,0 +1,428 @@
|
||||
/* XIC Pipeline Monitor Stylesheet */
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
||||
background: #1e1e1e;
|
||||
color: #e0e0e0;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.xic-monitor-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100vh;
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
/* Header */
|
||||
.xic-header {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
padding: 20px 30px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.xic-header h1 {
|
||||
font-size: 28px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.header-info {
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.run-status {
|
||||
padding: 8px 16px;
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.run-status.active {
|
||||
background: #4caf50;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.run-status.error {
|
||||
background: #f44336;
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Buttons */
|
||||
.btn-primary, .btn-warning {
|
||||
padding: 10px 20px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: #4caf50;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-primary:hover:not(:disabled) {
|
||||
background: #45a049;
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.btn-warning {
|
||||
background: #ff9800;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-warning:hover:not(:disabled) {
|
||||
background: #e68900;
|
||||
}
|
||||
|
||||
.btn-warning:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
/* Main Content */
|
||||
.xic-main {
|
||||
flex: 1;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
grid-gap: 20px;
|
||||
padding: 30px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.panel {
|
||||
background: #2d2d2d;
|
||||
border: 1px solid #444;
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.panel h2 {
|
||||
font-size: 18px;
|
||||
margin-bottom: 15px;
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 2px solid #667eea;
|
||||
color: #667eea;
|
||||
}
|
||||
|
||||
.panel > :nth-child(2) {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* Timeline */
|
||||
.run-timeline {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.timeline-content {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
max-height: 200px;
|
||||
border: 1px solid #444;
|
||||
border-radius: 4px;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.timeline-step {
|
||||
padding: 8px 12px;
|
||||
margin: 4px 0;
|
||||
background: #3a3a3a;
|
||||
border-left: 3px solid #667eea;
|
||||
border-radius: 3px;
|
||||
font-size: 13px;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.timeline-step:hover {
|
||||
background: #444;
|
||||
}
|
||||
|
||||
.timeline-step.control {
|
||||
border-left-color: #ff9800;
|
||||
}
|
||||
|
||||
.timeline-step.guardrail {
|
||||
border-left-color: #f44336;
|
||||
background: #3a2a2a;
|
||||
}
|
||||
|
||||
.timeline-meta {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
margin-top: 10px;
|
||||
font-size: 13px;
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
/* Heatmap */
|
||||
.heatmap-legend {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-bottom: 15px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.legend-bar {
|
||||
display: flex;
|
||||
width: 200px;
|
||||
height: 20px;
|
||||
background: linear-gradient(90deg, #0066cc 0%, #00cc66 50%, #ff9900 100%);
|
||||
border-radius: 3px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.legend-bar span {
|
||||
position: absolute;
|
||||
font-size: 11px;
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.legend-bar .low { left: 5px; }
|
||||
.legend-bar .mid { left: 50%; transform: translateX(-50%); }
|
||||
.legend-bar .high { right: 5px; }
|
||||
|
||||
#heatmapCanvas {
|
||||
width: 100%;
|
||||
height: 200px;
|
||||
border: 1px solid #444;
|
||||
border-radius: 4px;
|
||||
display: block;
|
||||
margin: 10px 0;
|
||||
background: #1a1a1a;
|
||||
}
|
||||
|
||||
.glyph-details {
|
||||
font-size: 13px;
|
||||
margin-top: 10px;
|
||||
max-height: 100px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.glyph-item {
|
||||
padding: 5px 0;
|
||||
border-bottom: 1px solid #444;
|
||||
}
|
||||
|
||||
.glyph-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
/* Inspector */
|
||||
.inspector-toolbar {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 15px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.inspector-toolbar label {
|
||||
font-weight: 500;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.inspector-toolbar select {
|
||||
flex: 1;
|
||||
padding: 8px 12px;
|
||||
background: #3a3a3a;
|
||||
color: #e0e0e0;
|
||||
border: 1px solid #444;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.inspector-content {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 10px;
|
||||
background: #1a1a1a;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #444;
|
||||
}
|
||||
|
||||
.metric-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 8px 0;
|
||||
border-bottom: 1px solid #3a3a3a;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.metric-row:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.metric-label {
|
||||
font-weight: 500;
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
.metric-value {
|
||||
color: #667eea;
|
||||
font-family: 'Courier New', monospace;
|
||||
}
|
||||
|
||||
/* Guardrail Control */
|
||||
.guardrail-list {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.guardrail-event {
|
||||
padding: 10px;
|
||||
margin: 5px 0;
|
||||
background: #3a2a2a;
|
||||
border-left: 4px solid #f44336;
|
||||
border-radius: 3px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.guardrail-event.warning {
|
||||
border-left-color: #ff9800;
|
||||
background: #3a3a2a;
|
||||
}
|
||||
|
||||
.control-buttons {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.control-buttons button {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* Spec Coverage */
|
||||
.spec-status {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.spec-entry {
|
||||
padding: 12px;
|
||||
background: #3a3a3a;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
border: 1px solid #444;
|
||||
}
|
||||
|
||||
.spec-entry.implemented {
|
||||
border-left: 4px solid #4caf50;
|
||||
}
|
||||
|
||||
.spec-entry.validated {
|
||||
border-left: 4px solid #2196f3;
|
||||
}
|
||||
|
||||
.spec-entry.pending {
|
||||
border-left: 4px solid #ff9800;
|
||||
}
|
||||
|
||||
.spec-entry-name {
|
||||
font-weight: 600;
|
||||
margin-bottom: 5px;
|
||||
color: #e0e0e0;
|
||||
}
|
||||
|
||||
.spec-entry-status {
|
||||
display: inline-block;
|
||||
padding: 2px 8px;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 3px;
|
||||
font-size: 11px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.spec-entry.implemented .spec-entry-status {
|
||||
background: #4caf50;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.spec-entry.validated .spec-entry-status {
|
||||
background: #2196f3;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.spec-entry.pending .spec-entry-status {
|
||||
background: #ff9800;
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Placeholder & Empty States */
|
||||
.placeholder {
|
||||
color: #666;
|
||||
font-style: italic;
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
/* Footer */
|
||||
.xic-footer {
|
||||
background: #1a1a1a;
|
||||
border-top: 1px solid #444;
|
||||
padding: 15px 30px;
|
||||
text-align: center;
|
||||
color: #888;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* Responsive */
|
||||
@media (max-width: 1024px) {
|
||||
.xic-main {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.run-timeline {
|
||||
grid-column: 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Alert styles */
|
||||
.alert {
|
||||
padding: 12px 16px;
|
||||
border-radius: 4px;
|
||||
margin-bottom: 10px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.alert.error {
|
||||
background: #3a2a2a;
|
||||
border-left: 4px solid #f44336;
|
||||
color: #ff6b6b;
|
||||
}
|
||||
|
||||
.alert.warning {
|
||||
background: #3a3a2a;
|
||||
border-left: 4px solid #ff9800;
|
||||
color: #ffb74d;
|
||||
}
|
||||
|
||||
.alert.success {
|
||||
background: #2a3a2a;
|
||||
border-left: 4px solid #4caf50;
|
||||
color: #81c784;
|
||||
}
|
||||
Reference in New Issue
Block a user