Kandukuri commited on
Commit
5385772
Β·
1 Parent(s): f0308d3

V3 Premium Dashboard: interactive web UI with session endpoints

Browse files
Files changed (4) hide show
  1. server_v2.py +127 -5
  2. static/app.js +500 -0
  3. static/index.html +157 -0
  4. static/style.css +464 -0
server_v2.py CHANGED
@@ -1,16 +1,20 @@
1
  """
2
- FastAPI server for Repair Strategy System V2.
 
3
  """
4
 
5
  from __future__ import annotations
6
 
7
  import sys
8
  import os
 
9
 
10
  sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
11
 
12
- from typing import Any, Dict, List
13
  from fastapi import FastAPI, HTTPException
 
 
14
  from pydantic import BaseModel
15
 
16
  from env_v2 import RepairEnvV2
@@ -20,11 +24,19 @@ from graders_v2 import GRADERS
20
  import baseline_v2
21
 
22
  app = FastAPI(
23
- title="Repair Strategy System V2",
24
- description="Symptom-based OpenEnv environment for multi-component system repair (Hidden State + Root Cause Inference)",
25
- version="2.0.0",
26
  )
27
 
 
 
 
 
 
 
 
 
28
  # ---------------------------------------------------------------------------
29
  # Request/Response schemas
30
  # ---------------------------------------------------------------------------
@@ -172,6 +184,116 @@ async def run_baseline():
172
  )
173
 
174
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  if __name__ == "__main__":
176
  import uvicorn
177
  uvicorn.run("server_v2:app", host="0.0.0.0", port=8001, reload=False)
 
 
1
  """
2
+ FastAPI server for Repair Strategy System V3.
3
+ Serves the premium web dashboard + JSON API.
4
  """
5
 
6
  from __future__ import annotations
7
 
8
  import sys
9
  import os
10
+ import uuid
11
 
12
  sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
13
 
14
+ from typing import Any, Dict, List, Optional
15
  from fastapi import FastAPI, HTTPException
16
+ from fastapi.staticfiles import StaticFiles
17
+ from fastapi.responses import FileResponse
18
  from pydantic import BaseModel
19
 
20
  from env_v2 import RepairEnvV2
 
24
  import baseline_v2
25
 
26
  app = FastAPI(
27
+ title="RootCauseArena β€” Repair Strategy System V3",
28
+ description="Interactive web dashboard + API for multi-component system repair with hidden state and root-cause inference.",
29
+ version="3.0.0",
30
  )
31
 
32
+ # Serve static assets (CSS, JS)
33
+ _static_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "static")
34
+ if os.path.isdir(_static_dir):
35
+ app.mount("/static", StaticFiles(directory=_static_dir), name="static")
36
+
37
+ # In-memory session store: session_id -> {env, total_reward}
38
+ _sessions: Dict[str, Dict] = {}
39
+
40
  # ---------------------------------------------------------------------------
41
  # Request/Response schemas
42
  # ---------------------------------------------------------------------------
 
184
  )
185
 
186
 
187
+ # ---------------------------------------------------------------------------
188
+ # Dashboard root
189
+ # ---------------------------------------------------------------------------
190
+
191
+ @app.get("/")
192
+ async def serve_dashboard():
193
+ """Serve the interactive web dashboard."""
194
+ index_path = os.path.join(_static_dir, "index.html")
195
+ if os.path.isfile(index_path):
196
+ return FileResponse(index_path, media_type="text/html")
197
+ return {"message": "RootCauseArena V3 API β€” static dashboard not found. Check the /static folder."}
198
+
199
+
200
+ # ---------------------------------------------------------------------------
201
+ # Interactive Session Endpoints
202
+ # ---------------------------------------------------------------------------
203
+
204
+ class SessionStartRequest(BaseModel):
205
+ task_id: str
206
+
207
+ class SessionStepRequest(BaseModel):
208
+ session_id: str
209
+ action_type: str
210
+ target: str
211
+
212
+
213
+ def _obs_to_dict(obs) -> Dict:
214
+ """Convert SymptomObservation to a JSON-serialisable dict."""
215
+ return {
216
+ "metrics": {
217
+ comp: {
218
+ "latency": m.latency,
219
+ "error_rate": m.error_rate,
220
+ "queue_load": m.queue_load,
221
+ "cpu_usage": m.cpu_usage,
222
+ }
223
+ for comp, m in obs.metrics.items()
224
+ },
225
+ "logs": [
226
+ {"timestamp": l.timestamp, "message": l.message, "severity": l.severity}
227
+ for l in obs.logs
228
+ ],
229
+ "step_count": obs.step_count,
230
+ "max_steps": obs.max_steps,
231
+ "inspections_remaining":obs.inspections_remaining,
232
+ }
233
+
234
+
235
+ @app.post("/session/start")
236
+ async def session_start(req: SessionStartRequest):
237
+ """
238
+ Start a new interactive episode. Returns a session_id and the initial observation.
239
+ """
240
+ if req.task_id not in TASKS:
241
+ raise HTTPException(status_code=400, detail=f"Unknown task_id '{req.task_id}'")
242
+
243
+ config = TASKS[req.task_id]
244
+ env = RepairEnvV2(config, seed=42)
245
+ obs = env.reset()
246
+
247
+ sid = str(uuid.uuid4())
248
+ _sessions[sid] = {"env": env, "total_reward": 0.0, "task_id": req.task_id}
249
+
250
+ return {
251
+ "session_id": sid,
252
+ "task_id": req.task_id,
253
+ "observation": _obs_to_dict(obs),
254
+ }
255
+
256
+
257
+ @app.post("/session/step")
258
+ async def session_step(req: SessionStepRequest):
259
+ """
260
+ Advance the session by one step. Returns new observation, reward, done, and success.
261
+ """
262
+ if req.session_id not in _sessions:
263
+ raise HTTPException(status_code=404, detail="Session not found. Start a new session first.")
264
+
265
+ session = _sessions[req.session_id]
266
+ env: RepairEnvV2 = session["env"]
267
+
268
+ # Validate action & target
269
+ try:
270
+ action_type = ActionType(req.action_type)
271
+ target = ComponentTarget(req.target)
272
+ except ValueError as e:
273
+ raise HTTPException(status_code=400, detail=str(e))
274
+
275
+ from models_v2 import Action
276
+ action = Action(action_type=action_type, target=target)
277
+
278
+ obs, reward, done, info = env.step(action)
279
+ session["total_reward"] += reward
280
+
281
+ result = {
282
+ "observation": _obs_to_dict(obs),
283
+ "reward": reward,
284
+ "done": done,
285
+ "success": info.get("success", False),
286
+ "info": str(info.get("reason", "")),
287
+ }
288
+
289
+ if done:
290
+ # Clean up session
291
+ del _sessions[req.session_id]
292
+
293
+ return result
294
+
295
+
296
  if __name__ == "__main__":
297
  import uvicorn
298
  uvicorn.run("server_v2:app", host="0.0.0.0", port=8001, reload=False)
299
+
static/app.js ADDED
@@ -0,0 +1,500 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * RootCauseArena V3 β€” Interactive Dashboard Logic
3
+ */
4
+
5
+ // ═══════════════════════════════════════════════
6
+ // State
7
+ // ═══════════════════════════════════════════════
8
+ const state = {
9
+ sessionId: null,
10
+ tasks: [],
11
+ selectedTask: null,
12
+ selectedTarget: null,
13
+ currentObs: null,
14
+ totalReward: 0,
15
+ running: false,
16
+ startTime: null,
17
+ };
18
+
19
+ // ═══════════════════════════════════════════════
20
+ // DOM refs
21
+ // ═══════════════════════════════════════════════
22
+ const $ = id => document.getElementById(id);
23
+
24
+ const DOM = {
25
+ serverBadge: $('server-status-badge'),
26
+ taskGrid: $('task-grid'),
27
+ statStep: $('stat-step'),
28
+ statReward: $('stat-reward'),
29
+ statInspections:$('stat-inspections'),
30
+ statMax: $('stat-max'),
31
+ progressFill: $('progress-fill'),
32
+ progressPct: $('progress-pct'),
33
+ actionTargets: $('action-targets'),
34
+ actionButtons: $('action-buttons'),
35
+ btnNoOp: $('btn-no-op'),
36
+ btnRunBaseline: $('btn-run-baseline'),
37
+ componentsGrid: $('components-grid'),
38
+ noSessionOvl: $('no-session-overlay'),
39
+ episodeBadge: $('episode-badge'),
40
+ logConsole: $('log-console'),
41
+ btnClearLogs: $('btn-clear-logs'),
42
+ baselineSection:$('baseline-section'),
43
+ baselineTbody: $('baseline-tbody'),
44
+ modalOverlay: $('modal-overlay'),
45
+ modalTitle: $('modal-title'),
46
+ modalBody: $('modal-body'),
47
+ modalConfirm: $('modal-confirm'),
48
+ modalCancel: $('modal-cancel'),
49
+ };
50
+
51
+ // ═══════════════════════════════════════════════
52
+ // Utility
53
+ // ═══════════════════════════════════════════════
54
+ const COMPONENT_ICONS = {
55
+ database: 'πŸ—„οΈ',
56
+ api: '🌐',
57
+ cache: '⚑',
58
+ queue: 'πŸ“¬',
59
+ };
60
+
61
+ const ACTION_LABELS = {
62
+ repair_database: 'πŸ”§ Repair DB',
63
+ restart_service: 'πŸ”„ Restart Service',
64
+ clear_cache: '🧹 Clear Cache',
65
+ scale_up: 'πŸ“ˆ Scale Up',
66
+ inspect_database:'πŸ” Inspect DB',
67
+ inspect_api: 'πŸ” Inspect API',
68
+ inspect_cache: 'πŸ” Inspect Cache',
69
+ inspect_queue: 'πŸ” Inspect Queue',
70
+ };
71
+
72
+ const TARGET_ACTION_MAP = {
73
+ database: ['repair_database', 'inspect_database'],
74
+ api: ['restart_service', 'inspect_api'],
75
+ cache: ['clear_cache', 'inspect_cache'],
76
+ queue: ['scale_up', 'inspect_queue'],
77
+ };
78
+
79
+ function formatReward(r) {
80
+ if (r === null || r === undefined || isNaN(r)) return 'β€”';
81
+ return (r >= 0 ? '+' : '') + r.toFixed(2);
82
+ }
83
+
84
+ function nowStr() {
85
+ if (!state.startTime) return '00:00';
86
+ const s = Math.floor((Date.now() - state.startTime) / 1000);
87
+ return `${String(Math.floor(s / 60)).padStart(2, '0')}:${String(s % 60).padStart(2, '0')}`;
88
+ }
89
+
90
+ // ═══════════════════════════════════════════════
91
+ // Logging
92
+ // ═══════════════════════════════════════════════
93
+ function addLog(message, type = 'info', tag = null) {
94
+ const entry = document.createElement('div');
95
+ entry.className = `log-entry log-${type}`;
96
+
97
+ const tagLabel = tag || type.toUpperCase();
98
+ entry.innerHTML =
99
+ `<span class="log-ts">${nowStr()}</span>` +
100
+ `<span class="log-tag">${tagLabel}</span>` +
101
+ `<span class="log-msg">${message}</span>`;
102
+
103
+ DOM.logConsole.appendChild(entry);
104
+ DOM.logConsole.scrollTop = DOM.logConsole.scrollHeight;
105
+ }
106
+
107
+ function renderEnvLogs(logs) {
108
+ if (!logs || !logs.length) return;
109
+ logs.forEach(l => {
110
+ const t = (l.severity || 'INFO').toLowerCase();
111
+ const type = t === 'error' ? 'error' : t === 'warn' ? 'warn' : 'info';
112
+ addLog(l.message, type, l.severity);
113
+ });
114
+ }
115
+
116
+ // ═══════════════════════════════════════════════
117
+ // Server Health Check
118
+ // ═══════════════════════════════════════════════
119
+ async function checkServerHealth() {
120
+ try {
121
+ const res = await fetch('/health');
122
+ if (res.ok) {
123
+ DOM.serverBadge.querySelector('.status-dot').className = 'status-dot online';
124
+ DOM.serverBadge.querySelector('.status-text').textContent = 'API Online';
125
+ } else { throw new Error(); }
126
+ } catch {
127
+ DOM.serverBadge.querySelector('.status-dot').className = 'status-dot error';
128
+ DOM.serverBadge.querySelector('.status-text').textContent = 'API Offline';
129
+ }
130
+ }
131
+
132
+ // ═══════════════════════════════════════════════
133
+ // Load Tasks
134
+ // ═══════════════════════════════════════════════
135
+ async function loadTasks() {
136
+ try {
137
+ const res = await fetch('/tasks');
138
+ const data = await res.json();
139
+ state.tasks = data.tasks || [];
140
+ renderTaskGrid();
141
+ addLog(`Loaded ${state.tasks.length} missions. Select one to begin.`, 'system', 'SYS');
142
+ } catch (e) {
143
+ addLog('Failed to load tasks from API.', 'error', 'ERR');
144
+ }
145
+ }
146
+
147
+ function renderTaskGrid() {
148
+ DOM.taskGrid.innerHTML = '';
149
+ const taskColors = { easy: '#10b981', medium: '#f59e0b', hard: '#ef4444', extreme: '#8b5cf6' };
150
+
151
+ state.tasks.forEach(task => {
152
+ const diff = (task.difficulty || 'easy').toLowerCase();
153
+ const color = taskColors[diff] || '#3b82f6';
154
+ const card = document.createElement('div');
155
+ card.className = 'task-card';
156
+ card.dataset.taskId = task.task_id;
157
+ card.style.setProperty('--task-color', color);
158
+ card.innerHTML = `
159
+ <div class="task-card-title">${task.task_id.replace('_', ' ').toUpperCase()}</div>
160
+ <div class="task-card-meta">${task.description.slice(0, 55)}…</div>
161
+ <span class="difficulty-badge difficulty-${diff}">${diff}</span>
162
+ `;
163
+ card.addEventListener('click', () => selectTask(task, card));
164
+ DOM.taskGrid.appendChild(card);
165
+ });
166
+ }
167
+
168
+ function selectTask(task, cardEl) {
169
+ if (state.running) return;
170
+ state.selectedTask = task;
171
+ document.querySelectorAll('.task-card').forEach(c => c.classList.remove('active'));
172
+ cardEl.classList.add('active');
173
+ addLog(`Mission selected: <strong>${task.task_id}</strong> (${task.difficulty}) β€” ${task.max_steps} max steps`, 'system', 'SYS');
174
+ showStartModal(task);
175
+ }
176
+
177
+ // ═══════════════════════════════════════════════
178
+ // Start Modal
179
+ // ═══════════════════════════════════════════════
180
+ function showStartModal(task) {
181
+ DOM.modalTitle.textContent = `⚑ Launch: ${task.task_id.replace('_', ' ').toUpperCase()}`;
182
+ DOM.modalBody.innerHTML = `
183
+ <strong>Difficulty:</strong> ${task.difficulty}<br>
184
+ <strong>Max Steps:</strong> ${task.max_steps}<br>
185
+ <strong>Optimal Steps:</strong> ${task.optimal_steps}<br><br>
186
+ ${task.description}<br><br>
187
+ <em>Your goal: Diagnose the hidden root cause and repair the system efficiently.</em>
188
+ `;
189
+ DOM.modalOverlay.style.display = 'flex';
190
+ }
191
+
192
+ DOM.modalConfirm.addEventListener('click', async () => {
193
+ DOM.modalOverlay.style.display = 'none';
194
+ await startSession();
195
+ });
196
+ DOM.modalCancel.addEventListener('click', () => {
197
+ DOM.modalOverlay.style.display = 'none';
198
+ });
199
+
200
+ // ═══════════════════════════════════════════════
201
+ // Session: Start
202
+ // ═══════════════════════════════════════════════
203
+ async function startSession() {
204
+ if (!state.selectedTask) return;
205
+ try {
206
+ addLog(`Initialising environment for: ${state.selectedTask.task_id}…`, 'system', 'SYS');
207
+ const res = await fetch('/session/start', {
208
+ method: 'POST',
209
+ headers: { 'Content-Type': 'application/json' },
210
+ body: JSON.stringify({ task_id: state.selectedTask.task_id }),
211
+ });
212
+ if (!res.ok) throw new Error(await res.text());
213
+ const data = await res.json();
214
+
215
+ state.sessionId = data.session_id;
216
+ state.currentObs = data.observation;
217
+ state.totalReward = 0;
218
+ state.running = true;
219
+ state.startTime = Date.now();
220
+
221
+ DOM.noSessionOvl.style.display = 'none';
222
+ setEpisodeBadge('running', 'RUNNING');
223
+ renderComponents(data.observation);
224
+ updateStats(data.observation);
225
+ buildActionTargets();
226
+ enableActions(true);
227
+
228
+ addLog(`Episode started. Session: ${state.sessionId.slice(0, 8)}…`, 'success', 'START');
229
+ renderEnvLogs(data.observation.logs);
230
+ } catch (e) {
231
+ addLog(`Failed to start session: ${e.message}`, 'error', 'ERR');
232
+ }
233
+ }
234
+
235
+ // ═══════════════════════════════════════════════
236
+ // Session: Step
237
+ // ═══════════════════════════════════════════════
238
+ async function sendAction(actionType) {
239
+ if (!state.running || !state.sessionId || !state.selectedTarget) return;
240
+
241
+ try {
242
+ addLog(`Action: <strong>${actionType}</strong> β†’ ${state.selectedTarget}`, 'warn', 'ACT');
243
+
244
+ const res = await fetch('/session/step', {
245
+ method: 'POST',
246
+ headers: { 'Content-Type': 'application/json' },
247
+ body: JSON.stringify({
248
+ session_id: state.sessionId,
249
+ action_type: actionType,
250
+ target: state.selectedTarget,
251
+ }),
252
+ });
253
+ if (!res.ok) throw new Error(await res.text());
254
+ const data = await res.json();
255
+
256
+ state.currentObs = data.observation;
257
+ state.totalReward += (data.reward || 0);
258
+
259
+ renderComponents(data.observation);
260
+ updateStats(data.observation);
261
+ renderEnvLogs(data.observation.logs);
262
+
263
+ if (data.reward !== 0) {
264
+ addLog(`Reward: ${formatReward(data.reward)} β€” ${data.info || ''}`, data.reward > 0 ? 'success' : 'warn', 'RWD');
265
+ }
266
+
267
+ if (data.done) {
268
+ state.running = false;
269
+ enableActions(false);
270
+ const success = data.success;
271
+ setEpisodeBadge(success ? 'success' : 'failed', success ? 'βœ… RESOLVED' : '❌ FAILED');
272
+ addLog(`Episode complete. Total reward: ${formatReward(state.totalReward)} | ${success ? 'SUCCESS' : 'FAILED'}`, success ? 'success' : 'error', 'END');
273
+ }
274
+ } catch (e) {
275
+ addLog(`Step failed: ${e.message}`, 'error', 'ERR');
276
+ }
277
+ }
278
+
279
+ async function sendNoOp() {
280
+ if (!state.running || !state.sessionId) return;
281
+ // No-op uses database target (arbitrary, action is 'no_op')
282
+ try {
283
+ addLog('Action: <strong>no_op</strong> (Wait)', 'info', 'ACT');
284
+ const res = await fetch('/session/step', {
285
+ method: 'POST',
286
+ headers: { 'Content-Type': 'application/json' },
287
+ body: JSON.stringify({ session_id: state.sessionId, action_type: 'no_op', target: 'database' }),
288
+ });
289
+ if (!res.ok) throw new Error(await res.text());
290
+ const data = await res.json();
291
+
292
+ state.currentObs = data.observation;
293
+ state.totalReward += (data.reward || 0);
294
+ renderComponents(data.observation);
295
+ updateStats(data.observation);
296
+ renderEnvLogs(data.observation.logs);
297
+
298
+ if (data.done) {
299
+ state.running = false;
300
+ enableActions(false);
301
+ const success = data.success;
302
+ setEpisodeBadge(success ? 'success' : 'failed', success ? 'βœ… RESOLVED' : '❌ FAILED');
303
+ addLog(`Episode complete. Total reward: ${formatReward(state.totalReward)}`, success ? 'success' : 'error', 'END');
304
+ }
305
+ } catch (e) {
306
+ addLog(`No-op failed: ${e.message}`, 'error', 'ERR');
307
+ }
308
+ }
309
+
310
+ // ═══════════════════════════════════════════════
311
+ // Render: Components
312
+ // ═══════════════════════════════════════════════
313
+ function renderComponents(obs) {
314
+ const existingCards = {};
315
+ DOM.componentsGrid.querySelectorAll('.component-card').forEach(c => {
316
+ existingCards[c.dataset.comp] = c;
317
+ });
318
+
319
+ const components = ['database', 'api', 'cache', 'queue'];
320
+ components.forEach(compName => {
321
+ const metrics = obs.metrics?.[compName];
322
+ if (!metrics) return;
323
+
324
+ const status = inferStatus(metrics);
325
+ let card = existingCards[compName];
326
+ const isNew = !card;
327
+
328
+ if (isNew) {
329
+ card = document.createElement('div');
330
+ card.className = 'component-card';
331
+ card.dataset.comp = compName;
332
+ DOM.componentsGrid.appendChild(card);
333
+ }
334
+
335
+ card.className = `component-card status-${status}`;
336
+ card.innerHTML = buildComponentHTML(compName, metrics, status);
337
+ });
338
+ }
339
+
340
+ function inferStatus(metrics) {
341
+ if (metrics.error_rate > 0.7 || metrics.latency > 850) return 'down';
342
+ if (metrics.error_rate > 0.25 || metrics.latency > 400) return 'degraded';
343
+ return 'healthy';
344
+ }
345
+
346
+ function buildComponentHTML(name, m, status) {
347
+ const latencyPct = Math.min(m.latency / 1000 * 100, 100);
348
+ const errorPct = m.error_rate * 100;
349
+ const queuePct = Math.min(m.queue_load / 4 * 100, 100);
350
+ const cpuPct = m.cpu_usage;
351
+
352
+ return `
353
+ <div class="comp-header">
354
+ <div class="comp-name">
355
+ <span class="comp-icon">${COMPONENT_ICONS[name] || 'βš™οΈ'}</span>
356
+ ${name}
357
+ </div>
358
+ <span class="comp-status-pill pill-${status}">${status}</span>
359
+ </div>
360
+ <div class="metrics-list">
361
+ <div class="metric-row">
362
+ <div class="metric-header">
363
+ <span class="metric-name">Latency</span>
364
+ <span class="metric-val">${m.latency}ms</span>
365
+ </div>
366
+ <div class="metric-track"><div class="metric-fill fill-latency" style="width:${latencyPct}%"></div></div>
367
+ </div>
368
+ <div class="metric-row">
369
+ <div class="metric-header">
370
+ <span class="metric-name">Error Rate</span>
371
+ <span class="metric-val">${(errorPct).toFixed(1)}%</span>
372
+ </div>
373
+ <div class="metric-track"><div class="metric-fill fill-error" style="width:${errorPct}%"></div></div>
374
+ </div>
375
+ <div class="metric-row">
376
+ <div class="metric-header">
377
+ <span class="metric-name">Queue Load</span>
378
+ <span class="metric-val">${m.queue_load.toFixed(2)}</span>
379
+ </div>
380
+ <div class="metric-track"><div class="metric-fill fill-queue" style="width:${queuePct}%"></div></div>
381
+ </div>
382
+ <div class="metric-row">
383
+ <div class="metric-header">
384
+ <span class="metric-name">CPU</span>
385
+ <span class="metric-val">${m.cpu_usage.toFixed(1)}%</span>
386
+ </div>
387
+ <div class="metric-track"><div class="metric-fill fill-cpu" style="width:${cpuPct}%"></div></div>
388
+ </div>
389
+ </div>
390
+ `;
391
+ }
392
+
393
+ // ═══════════════════════════════════════════════
394
+ // Render: Action UI
395
+ // ═══════════════════════════════════════════════
396
+ function buildActionTargets() {
397
+ DOM.actionTargets.innerHTML = '';
398
+ ['database', 'api', 'cache', 'queue'].forEach(t => {
399
+ const btn = document.createElement('button');
400
+ btn.className = 'target-btn';
401
+ btn.textContent = `${COMPONENT_ICONS[t]} ${t}`;
402
+ btn.dataset.target = t;
403
+ btn.addEventListener('click', () => selectTarget(t, btn));
404
+ DOM.actionTargets.appendChild(btn);
405
+ });
406
+ }
407
+
408
+ function selectTarget(target, btn) {
409
+ if (!state.running) return;
410
+ state.selectedTarget = target;
411
+ document.querySelectorAll('.target-btn').forEach(b => b.classList.remove('selected'));
412
+ btn.classList.add('selected');
413
+ renderActionButtons(target);
414
+ }
415
+
416
+ function renderActionButtons(target) {
417
+ DOM.actionButtons.innerHTML = '';
418
+ const actions = TARGET_ACTION_MAP[target] || [];
419
+ actions.forEach(actionType => {
420
+ const btn = document.createElement('button');
421
+ btn.className = `btn ${actionType.startsWith('inspect') ? 'btn-secondary' : 'btn-primary'}`;
422
+ btn.textContent = ACTION_LABELS[actionType] || actionType;
423
+ btn.addEventListener('click', () => sendAction(actionType));
424
+ DOM.actionButtons.appendChild(btn);
425
+ });
426
+ }
427
+
428
+ function enableActions(enabled) {
429
+ DOM.btnNoOp.disabled = !enabled;
430
+ DOM.actionTargets.querySelectorAll('.target-btn').forEach(b => b.disabled = !enabled);
431
+ }
432
+
433
+ // ═══════════════════════════════════════════════
434
+ // Render: Stats
435
+ // ═══════════════════════════════════════════════
436
+ function updateStats(obs) {
437
+ DOM.statStep.textContent = obs.step_count ?? 'β€”';
438
+ DOM.statReward.textContent = formatReward(state.totalReward);
439
+ DOM.statInspections.textContent = obs.inspections_remaining ?? 'β€”';
440
+ DOM.statMax.textContent = obs.max_steps ?? 'β€”';
441
+
442
+ if (obs.max_steps && obs.step_count !== undefined) {
443
+ const pct = Math.min(obs.step_count / obs.max_steps * 100, 100);
444
+ DOM.progressFill.style.width = `${pct}%`;
445
+ DOM.progressPct.textContent = `${pct.toFixed(0)}%`;
446
+ }
447
+ }
448
+
449
+ function setEpisodeBadge(type, label) {
450
+ DOM.episodeBadge.className = `episode-status-badge ${type}`;
451
+ DOM.episodeBadge.textContent = label;
452
+ }
453
+
454
+ // ═══════════════════════════════════════════════
455
+ // Baseline Agent
456
+ // ═══════════════════════════════════════════════
457
+ DOM.btnRunBaseline.addEventListener('click', async () => {
458
+ DOM.btnRunBaseline.disabled = true;
459
+ DOM.btnRunBaseline.textContent = '⏳ Running…';
460
+ addLog('Dispatching baseline agent across all tasks…', 'system', 'BL');
461
+
462
+ try {
463
+ const res = await fetch('/baseline');
464
+ const data = await res.json();
465
+ DOM.baselineTbody.innerHTML = '';
466
+ data.results.forEach(r => {
467
+ const tr = document.createElement('tr');
468
+ tr.innerHTML = `
469
+ <td>${r.task_id}</td>
470
+ <td>${r.steps_taken}</td>
471
+ <td>${formatReward(r.total_reward)}</td>
472
+ <td>${r.score.toFixed(3)}</td>
473
+ <td>${(r.efficiency * 100).toFixed(1)}%</td>
474
+ <td class="${r.success ? 'result-success' : 'result-fail'}">${r.success ? 'βœ… PASS' : '❌ FAIL'}</td>
475
+ `;
476
+ DOM.baselineTbody.appendChild(tr);
477
+ addLog(`Task <strong>${r.task_id}</strong>: score ${r.score.toFixed(3)} | ${r.success ? 'PASS' : 'FAIL'}`, r.success ? 'success' : 'error', 'BL');
478
+ });
479
+ DOM.baselineSection.style.display = 'flex';
480
+ } catch (e) {
481
+ addLog(`Baseline run failed: ${e.message}`, 'error', 'ERR');
482
+ } finally {
483
+ DOM.btnRunBaseline.disabled = false;
484
+ DOM.btnRunBaseline.textContent = 'πŸ€– Run Baseline Agent';
485
+ }
486
+ });
487
+
488
+ // ═══════════════════════════════════════════════
489
+ // Misc Events
490
+ // ═══════════════════════════════════════════════
491
+ DOM.btnNoOp.addEventListener('click', sendNoOp);
492
+ DOM.btnClearLogs.addEventListener('click', () => { DOM.logConsole.innerHTML = ''; });
493
+
494
+ // ══════════════════════════════════════════════���
495
+ // Boot
496
+ // ═══════════════════════════════════════════════
497
+ (async () => {
498
+ await checkServerHealth();
499
+ await loadTasks();
500
+ })();
static/index.html ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>RootCauseArena β€” Repair Strategy System V3</title>
7
+ <meta name="description" content="An interactive simulation where an AI agent learns to diagnose and repair cascading system failures in real-time." />
8
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
9
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
10
+ <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600&family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet" />
11
+ <link rel="stylesheet" href="/static/style.css" />
12
+ </head>
13
+ <body>
14
+
15
+ <!-- ── HEADER ───────────────────────────────────────────── -->
16
+ <header class="site-header">
17
+ <div class="header-brand">
18
+ <span class="brand-icon">⚑</span>
19
+ <div>
20
+ <h1 class="brand-title">RootCauseArena</h1>
21
+ <p class="brand-subtitle">Repair Strategy System V3 Β· Hidden State Β· Multi-Root</p>
22
+ </div>
23
+ </div>
24
+ <div class="header-status" id="server-status-badge">
25
+ <span class="status-dot"></span>
26
+ <span class="status-text">Connecting…</span>
27
+ </div>
28
+ </header>
29
+
30
+ <!-- ── MAIN LAYOUT ──────────────────────────────────────── -->
31
+ <main class="app-layout">
32
+
33
+ <!-- LEFT: Control Panel -->
34
+ <aside class="panel control-panel">
35
+ <section class="panel-section">
36
+ <h2 class="section-label">Mission Select</h2>
37
+ <div class="task-grid" id="task-grid">
38
+ <!-- Populated by JS -->
39
+ </div>
40
+ </section>
41
+
42
+ <section class="panel-section">
43
+ <h2 class="section-label">Episode Stats</h2>
44
+ <div class="stat-grid">
45
+ <div class="stat-card">
46
+ <span class="stat-value" id="stat-step">β€”</span>
47
+ <span class="stat-label">Step</span>
48
+ </div>
49
+ <div class="stat-card">
50
+ <span class="stat-value" id="stat-reward">β€”</span>
51
+ <span class="stat-label">Reward</span>
52
+ </div>
53
+ <div class="stat-card">
54
+ <span class="stat-value" id="stat-inspections">β€”</span>
55
+ <span class="stat-label">Inspections</span>
56
+ </div>
57
+ <div class="stat-card">
58
+ <span class="stat-value" id="stat-max">β€”</span>
59
+ <span class="stat-label">Max Steps</span>
60
+ </div>
61
+ </div>
62
+ <div class="progress-bar-wrap">
63
+ <div class="progress-bar-label">
64
+ <span>Episode Progress</span>
65
+ <span id="progress-pct">0%</span>
66
+ </div>
67
+ <div class="progress-track">
68
+ <div class="progress-fill" id="progress-fill"></div>
69
+ </div>
70
+ </div>
71
+ </section>
72
+
73
+ <section class="panel-section">
74
+ <h2 class="section-label">Action Console</h2>
75
+ <div class="action-targets" id="action-targets">
76
+ <!-- Populated by JS -->
77
+ </div>
78
+ <div class="action-buttons" id="action-buttons">
79
+ <!-- Populated by JS -->
80
+ </div>
81
+ <button class="btn btn-secondary w-full mt" id="btn-no-op" disabled>
82
+ ⏸ Wait / No-op
83
+ </button>
84
+ </section>
85
+
86
+ <section class="panel-section">
87
+ <button class="btn btn-danger w-full" id="btn-run-baseline">
88
+ πŸ€– Run Baseline Agent
89
+ </button>
90
+ </section>
91
+ </aside>
92
+
93
+ <!-- CENTER: System Grid -->
94
+ <div class="center-column">
95
+ <div class="system-header">
96
+ <h2 class="section-label">System Health Grid</h2>
97
+ <div class="episode-status-badge" id="episode-badge">SELECT A MISSION</div>
98
+ </div>
99
+
100
+ <div class="components-grid" id="components-grid">
101
+ <!-- Component cards injected by JS -->
102
+ <div class="no-session-overlay" id="no-session-overlay">
103
+ <div class="no-session-content">
104
+ <div class="no-session-icon">πŸ› </div>
105
+ <p>Select a mission and press <strong>Start Episode</strong></p>
106
+ </div>
107
+ </div>
108
+ </div>
109
+
110
+ <!-- Baseline Results Table -->
111
+ <div class="baseline-section" id="baseline-section" style="display:none">
112
+ <h2 class="section-label">Baseline Agent Results</h2>
113
+ <table class="results-table" id="baseline-table">
114
+ <thead>
115
+ <tr>
116
+ <th>Task</th>
117
+ <th>Steps</th>
118
+ <th>Reward</th>
119
+ <th>Score</th>
120
+ <th>Efficiency</th>
121
+ <th>Status</th>
122
+ </tr>
123
+ </thead>
124
+ <tbody id="baseline-tbody"></tbody>
125
+ </table>
126
+ </div>
127
+ </div>
128
+
129
+ <!-- RIGHT: Log Console -->
130
+ <aside class="panel log-panel">
131
+ <div class="log-header">
132
+ <h2 class="section-label">Diagnostic Console</h2>
133
+ <button class="btn-icon" id="btn-clear-logs" title="Clear logs">βœ•</button>
134
+ </div>
135
+ <div class="log-console" id="log-console">
136
+ <div class="log-entry log-info">
137
+ <span class="log-ts">00:00</span>
138
+ <span class="log-msg">System initialised. Awaiting mission…</span>
139
+ </div>
140
+ </div>
141
+ </aside>
142
+
143
+ </main>
144
+
145
+ <!-- Start Episode Modal Overlay -->
146
+ <div class="modal-overlay" id="modal-overlay" style="display:none">
147
+ <div class="modal">
148
+ <h3 class="modal-title" id="modal-title">Starting Episode…</h3>
149
+ <p class="modal-body" id="modal-body">Initialising environment, please wait.</p>
150
+ <button class="btn btn-primary" id="modal-confirm">Begin Mission</button>
151
+ <button class="btn btn-ghost" id="modal-cancel">Cancel</button>
152
+ </div>
153
+ </div>
154
+
155
+ <script src="/static/app.js"></script>
156
+ </body>
157
+ </html>
static/style.css ADDED
@@ -0,0 +1,464 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* ═══════════════════════════════════════════════
2
+ RootCauseArena V3 β€” Premium Dark Design System
3
+ ═══════════════════════════════════════════════ */
4
+
5
+ /* ── Design Tokens ── */
6
+ :root {
7
+ --bg-base: #080c14;
8
+ --bg-surface: #0d1525;
9
+ --bg-card: rgba(16, 27, 50, 0.75);
10
+ --bg-card-hover: rgba(22, 38, 68, 0.9);
11
+
12
+ --border: rgba(56, 100, 185, 0.22);
13
+ --border-bright: rgba(56, 150, 255, 0.45);
14
+
15
+ --accent-blue: #3b82f6;
16
+ --accent-purple: #8b5cf6;
17
+ --accent-cyan: #06b6d4;
18
+ --accent-green: #10b981;
19
+ --accent-yellow: #f59e0b;
20
+ --accent-red: #ef4444;
21
+
22
+ --text-primary: #e2e8f0;
23
+ --text-secondary: #7f8fa6;
24
+ --text-muted: #4a5568;
25
+
26
+ --font-ui: 'Inter', system-ui, sans-serif;
27
+ --font-mono: 'JetBrains Mono', 'Courier New', monospace;
28
+
29
+ --radius-sm: 6px;
30
+ --radius-md: 12px;
31
+ --radius-lg: 18px;
32
+
33
+ --shadow-glow-blue: 0 0 20px rgba(59, 130, 246, 0.3);
34
+ --shadow-glow-red: 0 0 20px rgba(239, 68, 68, 0.4);
35
+ --shadow-glow-green: 0 0 20px rgba(16, 185, 129, 0.3);
36
+ --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.5);
37
+
38
+ --transition: 0.2s ease;
39
+ }
40
+
41
+ /* ── Reset & Base ── */
42
+ *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
43
+
44
+ html, body {
45
+ height: 100%;
46
+ overflow: hidden;
47
+ }
48
+
49
+ body {
50
+ background: var(--bg-base);
51
+ color: var(--text-primary);
52
+ font-family: var(--font-ui);
53
+ font-size: 14px;
54
+ line-height: 1.6;
55
+ display: flex;
56
+ flex-direction: column;
57
+ /* Subtle radial glow in the background */
58
+ background-image:
59
+ radial-gradient(ellipse 80% 50% at 20% 20%, rgba(59, 130, 246, 0.05) 0%, transparent 60%),
60
+ radial-gradient(ellipse 60% 40% at 80% 80%, rgba(139, 92, 246, 0.05) 0%, transparent 60%);
61
+ }
62
+
63
+ /* ── Header ── */
64
+ .site-header {
65
+ display: flex;
66
+ align-items: center;
67
+ justify-content: space-between;
68
+ padding: 14px 24px;
69
+ border-bottom: 1px solid var(--border);
70
+ background: rgba(8, 12, 20, 0.9);
71
+ backdrop-filter: blur(12px);
72
+ -webkit-backdrop-filter: blur(12px);
73
+ flex-shrink: 0;
74
+ z-index: 100;
75
+ }
76
+
77
+ .header-brand { display: flex; align-items: center; gap: 14px; }
78
+ .brand-icon { font-size: 28px; filter: drop-shadow(0 0 8px rgba(59,130,246,0.8)); }
79
+ .brand-title {
80
+ font-size: 18px; font-weight: 700; letter-spacing: -0.3px;
81
+ background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
82
+ -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
83
+ }
84
+ .brand-subtitle { font-size: 11px; color: var(--text-secondary); font-family: var(--font-mono); }
85
+
86
+ .header-status {
87
+ display: flex; align-items: center; gap: 8px;
88
+ padding: 6px 14px; border-radius: 20px;
89
+ border: 1px solid var(--border);
90
+ background: var(--bg-card);
91
+ font-size: 12px; font-family: var(--font-mono);
92
+ }
93
+
94
+ .status-dot {
95
+ width: 8px; height: 8px; border-radius: 50%;
96
+ background: var(--accent-yellow);
97
+ animation: pulse 2s ease-in-out infinite;
98
+ }
99
+ .status-dot.online { background: var(--accent-green); }
100
+ .status-dot.error { background: var(--accent-red); animation: none; }
101
+
102
+ /* ── Layout ── */
103
+ .app-layout {
104
+ display: grid;
105
+ grid-template-columns: 280px 1fr 300px;
106
+ gap: 0;
107
+ flex: 1;
108
+ overflow: hidden;
109
+ }
110
+
111
+ .panel {
112
+ background: var(--bg-surface);
113
+ border: 1px solid var(--border);
114
+ overflow-y: auto;
115
+ padding: 16px;
116
+ display: flex;
117
+ flex-direction: column;
118
+ gap: 20px;
119
+ }
120
+ .control-panel { border-left: none; border-top: none; border-bottom: none; }
121
+ .log-panel { border-right: none; border-top: none; border-bottom: none; }
122
+
123
+ /* ── Panel Sections ── */
124
+ .panel-section { display: flex; flex-direction: column; gap: 10px; }
125
+ .section-label {
126
+ font-size: 10px; font-weight: 700; letter-spacing: 1.5px;
127
+ text-transform: uppercase; color: var(--text-muted);
128
+ padding-bottom: 6px; border-bottom: 1px solid var(--border);
129
+ }
130
+
131
+ /* ── Task Selection Cards ── */
132
+ .task-grid { display: flex; flex-direction: column; gap: 8px; }
133
+
134
+ .task-card {
135
+ background: var(--bg-card);
136
+ border: 1px solid var(--border);
137
+ border-radius: var(--radius-md);
138
+ padding: 12px 14px;
139
+ cursor: pointer;
140
+ transition: all var(--transition);
141
+ position: relative;
142
+ overflow: hidden;
143
+ }
144
+ .task-card::before {
145
+ content: '';
146
+ position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
147
+ background: var(--task-color, var(--accent-blue));
148
+ border-radius: 3px 0 0 3px;
149
+ }
150
+ .task-card:hover {
151
+ background: var(--bg-card-hover);
152
+ border-color: var(--border-bright);
153
+ transform: translateX(3px);
154
+ }
155
+ .task-card.active {
156
+ border-color: var(--task-color, var(--accent-blue));
157
+ box-shadow: 0 0 15px rgba(59, 130, 246, 0.15);
158
+ background: var(--bg-card-hover);
159
+ }
160
+ .task-card-title { font-weight: 600; font-size: 13px; }
161
+ .task-card-meta { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
162
+
163
+ .difficulty-badge {
164
+ display: inline-block; font-size: 9px; font-weight: 700; letter-spacing: 1px;
165
+ padding: 2px 7px; border-radius: 10px; text-transform: uppercase; margin-top: 4px;
166
+ }
167
+ .difficulty-easy { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
168
+ .difficulty-medium { background: rgba(245, 158, 11, 0.15); color: var(--accent-yellow); }
169
+ .difficulty-hard { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }
170
+ .difficulty-extreme{ background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); }
171
+
172
+ /* ── Stat Cards ── */
173
+ .stat-grid {
174
+ display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
175
+ }
176
+ .stat-card {
177
+ background: var(--bg-card); border: 1px solid var(--border);
178
+ border-radius: var(--radius-sm); padding: 10px; text-align: center;
179
+ }
180
+ .stat-value {
181
+ display: block; font-family: var(--font-mono); font-size: 22px;
182
+ font-weight: 600; color: var(--accent-blue);
183
+ }
184
+ .stat-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
185
+
186
+ /* ── Progress Bar ── */
187
+ .progress-bar-wrap { margin-top: 6px; }
188
+ .progress-bar-label { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-secondary); margin-bottom: 6px; }
189
+ .progress-track {
190
+ height: 6px; background: rgba(255,255,255,0.06); border-radius: 3px; overflow: hidden;
191
+ }
192
+ .progress-fill {
193
+ height: 100%; width: 0%; border-radius: 3px;
194
+ background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
195
+ transition: width 0.4s ease;
196
+ box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
197
+ }
198
+
199
+ /* ── Action Area ── */
200
+ .action-targets {
201
+ display: flex; flex-wrap: wrap; gap: 6px;
202
+ }
203
+ .target-btn {
204
+ flex: 1 1 calc(50% - 3px); min-width: 0;
205
+ padding: 8px 6px; border-radius: var(--radius-sm);
206
+ background: var(--bg-card); border: 1px solid var(--border);
207
+ color: var(--text-primary); font-family: var(--font-mono); font-size: 11px;
208
+ cursor: pointer; transition: all var(--transition); text-align: center;
209
+ }
210
+ .target-btn:hover { background: var(--bg-card-hover); border-color: var(--border-bright); }
211
+ .target-btn.selected {
212
+ border-color: var(--accent-blue);
213
+ background: rgba(59, 130, 246, 0.12);
214
+ color: var(--accent-blue);
215
+ box-shadow: var(--shadow-glow-blue);
216
+ }
217
+ .target-btn:disabled { opacity: 0.4; cursor: not-allowed; }
218
+
219
+ .action-buttons { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
220
+ .action-buttons button { width: 100%; }
221
+
222
+ /* ── Buttons ── */
223
+ .btn {
224
+ padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
225
+ font-family: var(--font-ui); font-size: 13px; font-weight: 500; cursor: pointer;
226
+ transition: all var(--transition); display: flex; align-items: center; justify-content: center; gap: 6px;
227
+ }
228
+ .btn:disabled { opacity: 0.4; cursor: not-allowed; }
229
+
230
+ .btn-primary {
231
+ background: linear-gradient(135deg, var(--accent-blue), #2563eb);
232
+ color: #fff; border-color: transparent;
233
+ box-shadow: 0 2px 12px rgba(59, 130, 246, 0.3);
234
+ }
235
+ .btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(59, 130, 246, 0.5); }
236
+
237
+ .btn-secondary {
238
+ background: var(--bg-card); color: var(--text-primary); border-color: var(--border);
239
+ }
240
+ .btn-secondary:hover:not(:disabled) { background: var(--bg-card-hover); border-color: var(--border-bright); }
241
+
242
+ .btn-success {
243
+ background: linear-gradient(135deg, var(--accent-green), #059669);
244
+ color: #fff;
245
+ }
246
+ .btn-success:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-glow-green); }
247
+
248
+ .btn-danger {
249
+ background: linear-gradient(135deg, var(--accent-red), #dc2626);
250
+ color: #fff;
251
+ }
252
+ .btn-danger:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-glow-red); }
253
+
254
+ .btn-ghost {
255
+ background: transparent; color: var(--text-secondary); border-color: var(--border);
256
+ }
257
+ .btn-ghost:hover:not(:disabled) { color: var(--text-primary); border-color: var(--border-bright); }
258
+
259
+ .btn-icon {
260
+ background: transparent; border: none; color: var(--text-muted);
261
+ cursor: pointer; font-size: 14px; padding: 4px 6px; border-radius: var(--radius-sm);
262
+ transition: color var(--transition);
263
+ }
264
+ .btn-icon:hover { color: var(--text-primary); }
265
+
266
+ .w-full { width: 100%; }
267
+ .mt { margin-top: 6px; }
268
+
269
+ /* ── Center Column ── */
270
+ .center-column {
271
+ overflow-y: auto; padding: 20px;
272
+ display: flex; flex-direction: column; gap: 20px;
273
+ background: transparent;
274
+ }
275
+
276
+ .system-header {
277
+ display: flex; align-items: center; justify-content: space-between;
278
+ }
279
+
280
+ .episode-status-badge {
281
+ font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
282
+ padding: 4px 12px; border-radius: 20px;
283
+ background: rgba(127, 143, 166, 0.1); color: var(--text-muted);
284
+ border: 1px solid var(--border);
285
+ transition: all var(--transition);
286
+ }
287
+ .episode-status-badge.running { background: rgba(245, 158, 11, 0.1); color: var(--accent-yellow); border-color: var(--accent-yellow); }
288
+ .episode-status-badge.success { background: rgba(16, 185, 129, 0.1); color: var(--accent-green); border-color: var(--accent-green); }
289
+ .episode-status-badge.failed { background: rgba(239, 68, 68, 0.1); color: var(--accent-red); border-color: var(--accent-red); }
290
+
291
+ /* ── Components Grid ── */
292
+ .components-grid {
293
+ display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px;
294
+ position: relative; min-height: 300px;
295
+ }
296
+
297
+ .no-session-overlay {
298
+ position: absolute; inset: 0;
299
+ display: flex; align-items: center; justify-content: center;
300
+ background: rgba(8, 12, 20, 0.6);
301
+ border-radius: var(--radius-lg);
302
+ border: 2px dashed var(--border);
303
+ }
304
+ .no-session-content { text-align: center; color: var(--text-muted); }
305
+ .no-session-icon { font-size: 40px; margin-bottom: 12px; }
306
+
307
+ /* ── Component Cards ── */
308
+ .component-card {
309
+ background: var(--bg-card);
310
+ border: 1px solid var(--border);
311
+ border-radius: var(--radius-lg);
312
+ padding: 20px;
313
+ transition: all 0.3s ease;
314
+ position: relative; overflow: hidden;
315
+ backdrop-filter: blur(6px);
316
+ }
317
+ .component-card::after {
318
+ content: ''; position: absolute; inset: 0;
319
+ background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, transparent 60%);
320
+ pointer-events: none;
321
+ }
322
+
323
+ .component-card.status-healthy {
324
+ border-color: rgba(16, 185, 129, 0.35);
325
+ box-shadow: 0 4px 20px rgba(16, 185, 129, 0.08);
326
+ }
327
+ .component-card.status-degraded {
328
+ border-color: rgba(245, 158, 11, 0.45);
329
+ box-shadow: 0 4px 20px rgba(245, 158, 11, 0.12);
330
+ }
331
+ .component-card.status-down {
332
+ border-color: rgba(239, 68, 68, 0.5);
333
+ box-shadow: 0 4px 20px rgba(239, 68, 68, 0.18);
334
+ animation: card-pulse-danger 2.5s ease-in-out infinite;
335
+ }
336
+
337
+ @keyframes card-pulse-danger {
338
+ 0%, 100% { box-shadow: 0 4px 20px rgba(239, 68, 68, 0.18); }
339
+ 50% { box-shadow: 0 4px 30px rgba(239, 68, 68, 0.4); }
340
+ }
341
+
342
+ .comp-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
343
+ .comp-name {
344
+ font-size: 15px; font-weight: 700; text-transform: capitalize;
345
+ display: flex; align-items: center; gap: 8px;
346
+ }
347
+ .comp-icon { font-size: 18px; }
348
+
349
+ .comp-status-pill {
350
+ font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
351
+ padding: 3px 10px; border-radius: 12px;
352
+ }
353
+ .pill-healthy { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
354
+ .pill-degraded { background: rgba(245, 158, 11, 0.15); color: var(--accent-yellow); }
355
+ .pill-down { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); animation: pill-blink 1.2s steps(2) infinite; }
356
+
357
+ @keyframes pill-blink { 50% { opacity: 0.4; } }
358
+
359
+ /* ── Metrics Bars ── */
360
+ .metrics-list { display: flex; flex-direction: column; gap: 8px; }
361
+ .metric-row { display: flex; flex-direction: column; gap: 3px; }
362
+ .metric-header{ display: flex; justify-content: space-between; font-size: 11px; }
363
+ .metric-name { color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.8px; font-size: 10px; }
364
+ .metric-val { font-family: var(--font-mono); color: var(--text-primary); font-size: 11px; }
365
+ .metric-track {
366
+ height: 4px; background: rgba(255,255,255,0.05); border-radius: 2px; overflow: hidden;
367
+ }
368
+ .metric-fill { height: 100%; border-radius: 2px; transition: width 0.5s ease; }
369
+ .fill-latency { background: var(--accent-cyan); }
370
+ .fill-error { background: var(--accent-red); }
371
+ .fill-queue { background: var(--accent-yellow); }
372
+ .fill-cpu { background: var(--accent-purple); }
373
+
374
+ /* ── Log Console ── */
375
+ .log-header { display: flex; align-items: center; justify-content: space-between; }
376
+ .log-console {
377
+ flex: 1; overflow-y: auto; background: rgba(0,0,0,0.3);
378
+ border: 1px solid var(--border); border-radius: var(--radius-md);
379
+ padding: 12px; font-family: var(--font-mono); font-size: 11.5px;
380
+ display: flex; flex-direction: column; gap: 4px;
381
+ min-height: 0;
382
+ scrollbar-width: thin; scrollbar-color: var(--border) transparent;
383
+ }
384
+ .log-console::-webkit-scrollbar { width: 4px; }
385
+ .log-console::-webkit-scrollbar-track { background: transparent; }
386
+ .log-console::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
387
+
388
+ .log-entry {
389
+ display: flex; gap: 8px; align-items: baseline;
390
+ padding: 4px 6px; border-radius: 4px;
391
+ animation: log-in 0.25s ease;
392
+ border-left: 2px solid transparent;
393
+ }
394
+ @keyframes log-in { from { opacity: 0; transform: translateX(-6px); } }
395
+
396
+ .log-ts { color: var(--text-muted); flex-shrink: 0; font-size: 10px; }
397
+ .log-msg { flex: 1; line-height: 1.5; }
398
+ .log-tag { font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 3px; flex-shrink: 0; }
399
+
400
+ .log-info { border-left-color: var(--accent-blue); }
401
+ .log-info .log-tag { background: rgba(59,130,246,0.15); color: var(--accent-blue); }
402
+
403
+ .log-warn { border-left-color: var(--accent-yellow); }
404
+ .log-warn .log-tag { background: rgba(245,158,11,0.15); color: var(--accent-yellow); }
405
+
406
+ .log-error { border-left-color: var(--accent-red); background: rgba(239,68,68,0.05); }
407
+ .log-error .log-tag { background: rgba(239,68,68,0.15); color: var(--accent-red); }
408
+
409
+ .log-system { border-left-color: var(--accent-purple); }
410
+ .log-system .log-tag { background: rgba(139,92,246,0.15); color: var(--accent-purple); }
411
+
412
+ .log-success { border-left-color: var(--accent-green); }
413
+ .log-success .log-tag { background: rgba(16,185,129,0.15); color: var(--accent-green); }
414
+
415
+ /* ── Baseline Table ── */
416
+ .baseline-section { display: flex; flex-direction: column; gap: 12px; }
417
+ .results-table {
418
+ width: 100%; border-collapse: collapse;
419
+ background: var(--bg-card); border-radius: var(--radius-md); overflow: hidden;
420
+ }
421
+ .results-table th {
422
+ padding: 10px 14px; text-align: left; font-size: 10px; font-weight: 700;
423
+ letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted);
424
+ background: rgba(0,0,0,0.2); border-bottom: 1px solid var(--border);
425
+ }
426
+ .results-table td {
427
+ padding: 10px 14px; font-family: var(--font-mono); font-size: 12px;
428
+ border-bottom: 1px solid rgba(255,255,255,0.04);
429
+ }
430
+ .results-table tr:last-child td { border-bottom: none; }
431
+ .results-table tr:hover td { background: rgba(255,255,255,0.02); }
432
+
433
+ .result-success { color: var(--accent-green); font-weight: 700; }
434
+ .result-fail { color: var(--accent-red); font-weight: 700; }
435
+
436
+ /* ── Modal ── */
437
+ .modal-overlay {
438
+ position: fixed; inset: 0; background: rgba(0,0,0,0.7);
439
+ backdrop-filter: blur(6px); z-index: 1000;
440
+ display: flex; align-items: center; justify-content: center;
441
+ }
442
+ .modal {
443
+ background: var(--bg-surface); border: 1px solid var(--border-bright);
444
+ border-radius: var(--radius-lg); padding: 28px; max-width: 400px; width: 90%;
445
+ box-shadow: 0 20px 60px rgba(0,0,0,0.7);
446
+ animation: modal-in 0.2s ease;
447
+ display: flex; flex-direction: column; gap: 12px;
448
+ }
449
+ @keyframes modal-in { from { opacity: 0; transform: scale(0.95); } }
450
+ .modal-title { font-size: 18px; font-weight: 700; }
451
+ .modal-body { color: var(--text-secondary); font-size: 13px; line-height: 1.6; }
452
+
453
+ /* ── Animations / helpers ── */
454
+ @keyframes pulse {
455
+ 0%, 100% { opacity: 1; }
456
+ 50% { opacity: 0.4; }
457
+ }
458
+
459
+ .shimmer {
460
+ background: linear-gradient(90deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 100%);
461
+ background-size: 200% 100%;
462
+ animation: shimmer 1.5s infinite;
463
+ }
464
+ @keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }