faultmesh 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +61 -19
  2. package/dist/dashboard/app.js +1906 -139
  3. package/dist/dashboard/index.html +393 -99
  4. package/dist/dashboard/styles.css +1191 -23
  5. package/dist/engine/ControlApi.d.ts +13 -1
  6. package/dist/engine/ControlApi.js +304 -14
  7. package/dist/engine/FaultMeshProxy.d.ts +2 -0
  8. package/dist/engine/FaultMeshProxy.js +41 -5
  9. package/dist/engine/TelemetryHub.d.ts +1 -0
  10. package/dist/engine/TelemetryHub.js +3 -0
  11. package/dist/engine/ToxicPipeline.d.ts +5 -4
  12. package/dist/engine/ToxicPipeline.js +17 -4
  13. package/dist/healer/AiHealer.d.ts +30 -0
  14. package/dist/healer/AiHealer.js +188 -0
  15. package/dist/healer/AutoHealer.d.ts +24 -0
  16. package/dist/healer/AutoHealer.js +503 -0
  17. package/dist/healer/DiffGenerator.d.ts +10 -0
  18. package/dist/healer/DiffGenerator.js +63 -0
  19. package/dist/healer/DiffUtil.d.ts +6 -0
  20. package/dist/healer/DiffUtil.js +67 -0
  21. package/dist/healer/transformers/ExpressTransformers.d.ts +43 -0
  22. package/dist/healer/transformers/ExpressTransformers.js +228 -0
  23. package/dist/healer/transformers/FastApiTransformers.d.ts +19 -0
  24. package/dist/healer/transformers/FastApiTransformers.js +93 -0
  25. package/dist/healer/transformers/GoTransformers.d.ts +19 -0
  26. package/dist/healer/transformers/GoTransformers.js +106 -0
  27. package/dist/healer/types.d.ts +59 -0
  28. package/dist/healer/types.js +1 -0
  29. package/dist/redteam/EccAgentBridge.d.ts +20 -0
  30. package/dist/redteam/EccAgentBridge.js +303 -0
  31. package/dist/redteam/RedTeamEngine.d.ts +56 -0
  32. package/dist/redteam/RedTeamEngine.js +709 -0
  33. package/dist/redteam/types.d.ts +117 -0
  34. package/dist/redteam/types.js +5 -0
  35. package/dist/scorer/ResilienceScorer.d.ts +5 -0
  36. package/dist/scorer/ResilienceScorer.js +323 -7
  37. package/dist/scorer/SecurityAuditor.d.ts +8 -0
  38. package/dist/scorer/SecurityAuditor.js +471 -69
  39. package/dist/scorer/TrafficStormAuditor.d.ts +5 -0
  40. package/dist/scorer/TrafficStormAuditor.js +328 -69
  41. package/dist/server.js +17 -10
  42. package/dist/types.d.ts +7 -3
  43. package/package.json +2 -1
@@ -17,7 +17,16 @@
17
17
  <span class="app-tagline">Automated API Resilience &amp; Security Audit Engine</span>
18
18
  </div>
19
19
  <div class="header-right">
20
- <span class="proxy-status">Proxy on <strong>127.0.0.1:3001</strong> &rarr; Target on <strong>127.0.0.1:4000</strong></span>
20
+ <div class="target-url-control">
21
+ <label for="targetUrlInput" class="target-label">Target API:</label>
22
+ <input type="text" id="targetUrlInput" class="input-target-url" value="http://127.0.0.1:5050" placeholder="http://localhost:8000" spellcheck="false" title="Target backend URL to audit and proxy">
23
+ <button id="btnSetTargetUrl" class="btn-target-apply" type="button" title="Switch the proxy target backend">Set</button>
24
+ <div class="target-quick-pills" style="display: flex; gap: 3px; margin-left: 4px;">
25
+ <button id="btnTarget5050" class="btn-text btn-sm" style="font-size: 10px; font-family: var(--font-mono); padding: 2px 5px; border: 1px solid var(--border-default); border-radius: 3px;" type="button" title="Target real Express vulnerable backend with source code">:5050 (Sample App)</button>
26
+ <button id="btnTarget4000" class="btn-text btn-sm" style="font-size: 10px; font-family: var(--font-mono); padding: 2px 5px; border: 1px solid var(--border-default); border-radius: 3px;" type="button" title="Target internal mock echo server">:4000 (Mock Echo)</button>
27
+ </div>
28
+ </div>
29
+ <span class="proxy-status">Proxy: <strong>:3001</strong></span>
21
30
  <button id="themeToggle" class="btn-text">Switch Theme</button>
22
31
  </div>
23
32
  </div>
@@ -38,47 +47,214 @@
38
47
  <span class="suite-badge">PRIMARY AUDIT SUITE</span>
39
48
  </div>
40
49
  <h2 id="diagHeaderTitle">Automated API Resilience Benchmark</h2>
41
- <p id="diagHeaderSubtitle">Automated 5-point test suite evaluating client resilience against network delay, throttling, cuts, corruptions, and 503 outages.</p>
50
+ <p id="diagHeaderSubtitle">Automated 10-point test suite evaluating client resilience against network delay, throttling, cuts, corruptions, 503 outages, jitter, circuit breakers, and starvation.</p>
42
51
  </div>
43
52
 
44
53
  <div class="diag-tabs">
45
- <button id="tabResilience" class="diag-tab active" type="button">Network Resilience (5 Checks)</button>
46
- <button id="tabSecurity" class="diag-tab" type="button">Security &amp; Protocol (7 Checks)</button>
47
- <button id="tabStorm" class="diag-tab" type="button">Traffic Storms &amp; DoS (4 Checks)</button>
54
+ <button id="tabResilience" class="diag-tab active" type="button">Network Resilience (10 Checks)</button>
55
+ <button id="tabSecurity" class="diag-tab" type="button">Security &amp; Protocol (14 Checks)</button>
56
+ <button id="tabStorm" class="diag-tab" type="button">Traffic Storms &amp; DoS (8 Checks)</button>
57
+ <button id="tabRedTeam" class="diag-tab diag-tab-redteam" type="button">Red Chaos Team (Agentic)</button>
48
58
  </div>
49
59
  </div>
50
60
 
51
- <!-- Audit Banner: Score Summary & Action Runner -->
52
- <div class="audit-banner">
53
- <div class="score-summary">
54
- <div class="score-pill">
55
- <span id="scoreValue" class="score-number">--</span>
56
- <span id="scoreGrade" class="score-label">UNTESTED</span>
61
+ <!-- Standard 32-Check Audit Panel (Resilience, Security, Traffic Storm) -->
62
+ <div id="standardAuditPanel">
63
+ <!-- Audit Banner: Score Summary & Action Runner -->
64
+ <div class="audit-banner">
65
+ <div class="score-summary">
66
+ <div class="score-pill">
67
+ <span id="scoreValue" class="score-number">--</span>
68
+ <span id="scoreGrade" class="score-label">UNTESTED</span>
69
+ </div>
70
+ <div class="score-text">
71
+ <strong id="scoreTitle">Ready to evaluate</strong>
72
+ <p id="scoreSubtitle">Select a target profile and click "Run Benchmark" to execute the 10 resilience checks below.</p>
73
+ </div>
57
74
  </div>
58
- <div class="score-text">
59
- <strong id="scoreTitle">Ready to evaluate</strong>
60
- <p id="scoreSubtitle">Select a target profile and click "Run Benchmark" to execute all 5 checks below.</p>
75
+
76
+ <div class="diagnostics-actions">
77
+ <div class="export-btn-group" id="exportGroup" style="display: none;">
78
+ <button id="btnOpenHealer" class="btn-secondary btn-healer-trigger" type="button" title="Scan and automatically heal backend source code">Auto-Heal Codebase</button>
79
+ <button id="btnExportMd" class="btn-secondary btn-export" type="button" title="Download formatted Markdown scorecard">Export Markdown</button>
80
+ <button id="btnExportJson" class="btn-secondary btn-export" type="button" title="Download raw JSON scorecard">Export JSON</button>
81
+ </div>
82
+ <select id="testTargetProfile" class="form-input select-profile" title="Target App Profile">
83
+ <option value="resilient">Target: Resilient App (Grade A)</option>
84
+ <option value="fragile">Target: Fragile App (Grade F)</option>
85
+ </select>
86
+ <button id="btnRunDiagnostics" class="btn-primary btn-run-diagnostics">Run 10-Point Resilience Benchmark</button>
61
87
  </div>
62
88
  </div>
63
89
 
64
- <div class="diagnostics-actions">
65
- <select id="testTargetProfile" class="form-input select-profile" title="Target App Profile">
66
- <option value="resilient">Target: Resilient App (Grade A)</option>
67
- <option value="fragile">Target: Fragile App (Grade F)</option>
68
- </select>
69
- <button id="btnRunDiagnostics" class="btn-primary btn-run-diagnostics">Run 5-Point Benchmark</button>
90
+ <!-- Test Checklist & Results Area (Informs all checks upfront!) -->
91
+ <div class="checklist-container">
92
+ <div class="checklist-header">
93
+ <span class="checklist-title">Verification Criteria</span>
94
+ <span id="checklistCountTag" class="count-tag">5 checks ready</span>
95
+ </div>
96
+
97
+ <div id="diagnosticsResults" class="test-results-list">
98
+ <!-- Populated by JS upfront and updated on run -->
99
+ </div>
70
100
  </div>
71
101
  </div>
72
102
 
73
- <!-- Test Checklist & Results Area (Informs all checks upfront!) -->
74
- <div class="checklist-container">
75
- <div class="checklist-header">
76
- <span class="checklist-title">Verification Criteria</span>
77
- <span id="checklistCountTag" class="count-tag">5 checks ready</span>
103
+ <!-- Autonomous Red Chaos Team Engine Panel -->
104
+ <div id="redTeamPanel" class="redteam-panel" style="display: none;">
105
+ <!-- 1. Red Squadron Persona Badges -->
106
+ <div class="redteam-squadron-header">
107
+ <div class="squadron-title-group">
108
+ <span class="squadron-badge">AGENTIC SQUADRON</span>
109
+ <h4>Autonomous Red Team Agent Personas</h4>
110
+ </div>
111
+ <span class="squadron-status-tag">5 Active Personas Armed</span>
78
112
  </div>
79
113
 
80
- <div id="diagnosticsResults" class="test-results-list">
81
- <!-- Populated by JS upfront and updated on run -->
114
+ <div id="redTeamPersonasGrid" class="redteam-personas-grid">
115
+ <div class="persona-card" data-persona="security-reviewer">
116
+ <div class="persona-top">
117
+ <span class="persona-callsign">VULN-HUNTER</span>
118
+ <span class="persona-role-tag">Security</span>
119
+ </div>
120
+ <strong class="persona-name">Security Reviewer</strong>
121
+ <p class="persona-desc">Probes host poisoning, IP spoofing, path traversal, broken auth crashes, and secret leakage.</p>
122
+ </div>
123
+ <div class="persona-card" data-persona="silent-failure-hunter">
124
+ <div class="persona-top">
125
+ <span class="persona-callsign">SILENT-TRAPPER</span>
126
+ <span class="persona-role-tag">Silent Failure</span>
127
+ </div>
128
+ <strong class="persona-name">Silent Failure Hunter</strong>
129
+ <p class="persona-desc">Detects swallowed exceptions, truncated JSON streams, and unhandled socket drops.</p>
130
+ </div>
131
+ <div class="persona-card" data-persona="performance-optimizer">
132
+ <div class="persona-top">
133
+ <span class="persona-callsign">SURGE-STORMER</span>
134
+ <span class="persona-role-tag">Performance</span>
135
+ </div>
136
+ <strong class="persona-name">Performance Optimizer</strong>
137
+ <p class="persona-desc">Dispatches slowloris drips, 1.5MB buffer overflows, and avalanche concurrency bursts.</p>
138
+ </div>
139
+ <div class="persona-card" data-persona="gan-adversary">
140
+ <div class="persona-top">
141
+ <span class="persona-callsign">MUTANT-PROBER</span>
142
+ <span class="persona-role-tag">Adversarial GAN</span>
143
+ </div>
144
+ <strong class="persona-name">Adversarial GAN Mutant</strong>
145
+ <p class="persona-desc">Fires catastrophic ReDoS backtracking probes and transactional duplicate race conditions.</p>
146
+ </div>
147
+ <div class="persona-card" data-persona="network-troubleshooter">
148
+ <div class="persona-top">
149
+ <span class="persona-callsign">NET-FRACTURER</span>
150
+ <span class="persona-role-tag">Transport</span>
151
+ </div>
152
+ <strong class="persona-name">Network Troubleshooter</strong>
153
+ <p class="persona-desc">Injects latency jitter spikes (&plusmn;250ms), 16 kbps bandwidth caps, and gateway timeout hangs.</p>
154
+ </div>
155
+ </div>
156
+
157
+ <!-- 2. Campaign Mission Control Bar -->
158
+ <div class="redteam-control-bar">
159
+ <div class="redteam-config-group">
160
+ <label for="redTeamIntensitySelect">Assault Intensity:</label>
161
+ <select id="redTeamIntensitySelect" class="form-input redteam-select">
162
+ <option value="sustained" selected>Sustained Assault (5 Coordinated Waves - Recommended)</option>
163
+ <option value="stealth">Stealth Reconnaissance (Targeted Probes, Low Concurrency)</option>
164
+ <option value="avalanche">Chaos Avalanche (Aggressive Multi-Threaded Stress)</option>
165
+ </select>
166
+ </div>
167
+
168
+ <div class="redteam-btn-group">
169
+ <button id="btnLaunchRedTeam" class="btn-primary btn-redteam-launch" type="button">Launch Red Team Assault</button>
170
+ <button id="btnAbortRedTeam" class="btn-danger-outline btn-redteam-abort" type="button" style="display: none;">Abort Mission</button>
171
+ </div>
172
+ </div>
173
+
174
+ <!-- 3. Real-time Tactical Assault HUD -->
175
+ <div id="redTeamHud" class="redteam-hud" style="display: none;">
176
+ <!-- 5-Phase Breadcrumb Pipeline -->
177
+ <div class="redteam-phase-pipeline">
178
+ <div class="phase-step" data-phase="recon"><span class="phase-dot"></span> 1. Recon</div>
179
+ <div class="phase-step" data-phase="weaponize"><span class="phase-dot"></span> 2. Weaponize</div>
180
+ <div class="phase-step" data-phase="assault"><span class="phase-dot"></span> 3. Compound Assault</div>
181
+ <div class="phase-step" data-phase="debrief"><span class="phase-dot"></span> 4. Blast Radius</div>
182
+ <div class="phase-step" data-phase="complete"><span class="phase-dot"></span> 5. Mission Debrief</div>
183
+ </div>
184
+
185
+ <!-- Progress Bar & Wave Subtitle -->
186
+ <div class="redteam-progress-bar-wrapper">
187
+ <div class="redteam-progress-info">
188
+ <strong id="redTeamCurrentWaveText">Standby...</strong>
189
+ <span id="redTeamProgressPercent">0%</span>
190
+ </div>
191
+ <div class="redteam-track">
192
+ <div id="redTeamProgressBar" class="redteam-bar" style="width: 0%;"></div>
193
+ </div>
194
+ </div>
195
+
196
+ <!-- Telemetry Counters Bar -->
197
+ <div class="redteam-telemetry-strip">
198
+ <div class="telemetry-pill">
199
+ <span class="telemetry-label">Probes Sent:</span>
200
+ <span id="redTeamProbesCount" class="telemetry-val">0</span>
201
+ </div>
202
+ <div class="telemetry-pill pill-critical">
203
+ <span class="telemetry-label">Critical Breaches:</span>
204
+ <span id="redTeamCritCount" class="telemetry-val">0</span>
205
+ </div>
206
+ <div class="telemetry-pill pill-high">
207
+ <span class="telemetry-label">High Breaches:</span>
208
+ <span id="redTeamHighCount" class="telemetry-val">0</span>
209
+ </div>
210
+ <div class="telemetry-pill">
211
+ <span class="telemetry-label">Medium Breaches:</span>
212
+ <span id="redTeamMedCount" class="telemetry-val">0</span>
213
+ </div>
214
+ </div>
215
+
216
+ <!-- Live Tactical Monospace Console Log -->
217
+ <div class="redteam-console-wrapper">
218
+ <div class="console-header">
219
+ <span>LIVE TACTICAL TELEMETRY STREAM</span>
220
+ <span id="redTeamActivePersonaPill" class="active-persona-pill">Awaiting Launch</span>
221
+ </div>
222
+ <div id="redTeamConsoleLogs" class="redteam-terminal-log">
223
+ <div class="terminal-line text-muted">&gt; Red Chaos Team Engine standby. Ready to deploy autonomous agent personas against target.</div>
224
+ </div>
225
+ </div>
226
+ </div>
227
+
228
+ <!-- 4. Post-Campaign Mission Debrief Dossier -->
229
+ <div id="redTeamDossier" class="redteam-dossier" style="display: none;">
230
+ <div class="dossier-header-bar">
231
+ <div class="dossier-score-badge">
232
+ <span id="dossierScoreVal" class="dossier-score-num">--</span>
233
+ <span id="dossierGradeVal" class="dossier-grade-tag">GRADE --</span>
234
+ </div>
235
+ <div class="dossier-summary-col">
236
+ <h3 id="dossierTitle">Mission Debrief: Target Evaluated</h3>
237
+ <p id="dossierSummaryText">Campaign concluded. Review discovered vulnerabilities and system blast radius below.</p>
238
+ </div>
239
+ <div class="dossier-action-col">
240
+ <button id="btnAutoHealBreaches" class="btn-primary btn-autoheal-breaches" type="button" title="Open Auto-Healer to repair all discovered breaches">Auto-Heal Discovered Breaches</button>
241
+ <div class="dossier-export-group">
242
+ <button id="btnExportDossierMd" class="btn-secondary btn-sm" type="button">Export Markdown</button>
243
+ <button id="btnExportDossierJson" class="btn-secondary btn-sm" type="button">Export JSON</button>
244
+ </div>
245
+ </div>
246
+ </div>
247
+
248
+ <!-- Breaches Findings List -->
249
+ <div class="dossier-findings-section">
250
+ <div class="findings-header">
251
+ <span class="findings-title">Discovered Breaches &amp; Exploit Proofs</span>
252
+ <span id="dossierFindingsCount" class="count-tag">0 breaches</span>
253
+ </div>
254
+ <div id="dossierFindingsList" class="dossier-findings-list">
255
+ <!-- Populated by JS -->
256
+ </div>
257
+ </div>
82
258
  </div>
83
259
  </div>
84
260
 
@@ -96,16 +272,15 @@
96
272
  </div>
97
273
 
98
274
  <div class="columns-grid">
99
-
100
- <!-- Left Column: All Rule Adders & Active State -->
101
- <div class="column">
102
- <section class="section-box">
275
+ <!-- Left Column: Presets, Custom Rule Builder, and Active Rules -->
276
+ <div class="column" id="leftWorkbenchCol">
277
+ <!-- 1. 1-Click Quick Presets Card -->
278
+ <section class="section-box presets-card">
103
279
  <div class="section-header">
104
280
  <h2>Network Fault Simulator (Manual Injections)</h2>
105
281
  <p>Inject real-world network conditions into all traffic passing through <strong>http://localhost:3001</strong>.</p>
106
282
  </div>
107
283
 
108
- <!-- 1-Click Presets -->
109
284
  <div class="adder-subgroup">
110
285
  <div class="subgroup-label">1-Click Quick Presets</div>
111
286
  <div class="scenario-table">
@@ -117,6 +292,14 @@
117
292
  <button id="btnPresetSlowMobile" class="btn-secondary" title="Activate rule and send test request">Enable &amp; Test</button>
118
293
  </div>
119
294
 
295
+ <div class="scenario-row">
296
+ <div class="scenario-desc">
297
+ <strong>Packet Jitter Spike</strong>
298
+ <span>400ms base delay with &plusmn;250ms fluctuating variance.</span>
299
+ </div>
300
+ <button id="btnPresetJitter" class="btn-secondary" title="Activate rule and send test request">Enable &amp; Test</button>
301
+ </div>
302
+
120
303
  <div class="scenario-row">
121
304
  <div class="scenario-desc">
122
305
  <strong>Connection Drop</strong>
@@ -125,6 +308,14 @@
125
308
  <button id="btnPresetDisconnect" class="btn-secondary" title="Activate rule and send test request">Enable &amp; Test</button>
126
309
  </div>
127
310
 
311
+ <div class="scenario-row">
312
+ <div class="scenario-desc">
313
+ <strong>Rate Limit Surge (429)</strong>
314
+ <span>Forces HTTP 429 with Retry-After header to test client backoff.</span>
315
+ </div>
316
+ <button id="btnPresetRateLimit" class="btn-secondary" title="Activate rule and send test request">Enable &amp; Test</button>
317
+ </div>
318
+
128
319
  <div class="scenario-row">
129
320
  <div class="scenario-desc">
130
321
  <strong>Server Outage (503)</strong>
@@ -133,6 +324,14 @@
133
324
  <button id="btnPresetOutage" class="btn-secondary" title="Activate rule and send test request">Enable &amp; Test</button>
134
325
  </div>
135
326
 
327
+ <div class="scenario-row">
328
+ <div class="scenario-desc">
329
+ <strong>Gateway Timeout (504)</strong>
330
+ <span>2000ms upstream hang followed by HTTP 504 Gateway Timeout.</span>
331
+ </div>
332
+ <button id="btnPresetGatewayTimeout" class="btn-secondary" title="Activate rule and send test request">Enable &amp; Test</button>
333
+ </div>
334
+
136
335
  <div class="scenario-row">
137
336
  <div class="scenario-desc">
138
337
  <strong>Corrupted Response</strong>
@@ -142,49 +341,59 @@
142
341
  </div>
143
342
  </div>
144
343
  </div>
344
+ </section>
145
345
 
146
- <!-- Custom Rule Builder -->
147
- <div class="adder-subgroup custom-rule-section">
148
- <div class="subgroup-label">Custom Rule Builder</div>
149
- <form id="customRuleForm" class="form-layout">
150
- <div class="form-row">
151
- <div class="form-field">
152
- <label for="ruleTypeSelect">Condition</label>
153
- <select id="ruleTypeSelect" class="form-input">
154
- <option value="latency">Add Network Delay (Latency)</option>
155
- <option value="bandwidth">Limit Bandwidth (Speed Throttling)</option>
156
- <option value="cut">Drop Connection Mid-Download</option>
157
- <option value="corrupt">Corrupt Data (Truncate JSON)</option>
158
- <option value="status">Force HTTP Status Code</option>
159
- </select>
160
- </div>
346
+ <!-- 2. Custom Rule Builder Card -->
347
+ <section class="section-box custom-rule-card">
348
+ <div class="section-header">
349
+ <h2>Custom Rule Builder</h2>
350
+ <p>Configure granular network latency, bandwidth limits, cuts, corruption, or HTTP status codes.</p>
351
+ </div>
161
352
 
162
- <div class="form-field">
163
- <label for="ruleDirectionSelect">Direction</label>
164
- <select id="ruleDirectionSelect" class="form-input">
165
- <option value="downstream">Responses (to client)</option>
166
- <option value="upstream">Requests (to server)</option>
167
- </select>
168
- </div>
353
+ <form id="customRuleForm" class="form-layout">
354
+ <div class="form-row">
355
+ <div class="form-field">
356
+ <label for="ruleTypeSelect">Condition</label>
357
+ <select id="ruleTypeSelect" class="form-input">
358
+ <option value="latency">Add Network Delay (Latency)</option>
359
+ <option value="bandwidth">Limit Bandwidth (Speed Throttling)</option>
360
+ <option value="cut">Drop Connection Mid-Download</option>
361
+ <option value="corrupt">Corrupt Data (Truncate JSON)</option>
362
+ <option value="status">Force HTTP Status Code</option>
363
+ </select>
169
364
  </div>
170
365
 
171
- <div id="dynamicRuleInputs" class="dynamic-row">
172
- <!-- Rendered by JS -->
366
+ <div class="form-field">
367
+ <label for="ruleDirectionSelect">Direction</label>
368
+ <select id="ruleDirectionSelect" class="form-input">
369
+ <option value="downstream">Responses (to client)</option>
370
+ <option value="upstream">Requests (to server)</option>
371
+ </select>
173
372
  </div>
174
373
 
175
- <button type="submit" class="btn-secondary btn-full">Add &amp; Activate Rule</button>
176
- </form>
177
- </div>
374
+ <div class="form-field">
375
+ <label for="rulePathPattern">Path Filter (Optional)</label>
376
+ <input type="text" id="rulePathPattern" class="form-input" placeholder="e.g. /api/checkout (blank = all)" title="Only inject fault when request path matches this pattern">
377
+ </div>
378
+ </div>
379
+
380
+ <div id="dynamicRuleInputs" class="dynamic-row">
381
+ <!-- Rendered by JS -->
382
+ </div>
383
+
384
+ <button type="submit" class="btn-secondary btn-full">Add &amp; Activate Rule</button>
385
+ </form>
178
386
  </section>
179
387
 
180
- <!-- Current Active Rules -->
181
- <section class="section-box">
388
+ <!-- 3. Current Active Simulation Rules Card -->
389
+ <section class="section-box active-rules-card">
182
390
  <div class="section-header header-with-badge">
183
391
  <div>
184
392
  <h2>Active Simulation Rules</h2>
185
393
  <p>Rules currently altering traffic passing through the proxy.</p>
186
394
  </div>
187
395
  <div style="display: flex; align-items: center; gap: 8px;">
396
+ <span id="activeRulesIndicator" class="active-rules-pill">Traffic: Normal</span>
188
397
  <span id="activeRulesCount" class="count-tag">0 active</span>
189
398
  <button id="btnClearAllRules" class="btn-remove btn-sm" title="Clear all active rules">Reset All</button>
190
399
  </div>
@@ -196,8 +405,9 @@
196
405
  </section>
197
406
  </div>
198
407
 
199
- <!-- Right Column: Response Inspector -->
200
- <div class="column">
408
+ <!-- Right Column: Response Inspector and Live Traffic Log -->
409
+ <div class="column" id="rightWorkbenchCol">
410
+ <!-- 1. Response Inspector Card (Height matched to Presets Card) -->
201
411
  <section id="responseInspector" class="section-box response-inspector-card">
202
412
  <div class="section-header header-with-action">
203
413
  <div>
@@ -212,6 +422,8 @@
212
422
  <select id="testEndpointSelect" class="form-input inspector-select">
213
423
  <option value="/api/data">GET /api/data (Normal API)</option>
214
424
  <option value="/api/users">GET /api/users (User Records)</option>
425
+ <option value="/api/profile">GET /api/profile (Protected Profile)</option>
426
+ <option value="/api/checkout">GET /api/checkout (Idempotent Action)</option>
215
427
  <option value="/api/crash">GET /api/crash (Crashing Server 500)</option>
216
428
  </select>
217
429
  <button id="btnSendTestRequest" class="btn-primary">Send Test Request</button>
@@ -227,18 +439,16 @@
227
439
  <span class="meta-label">Time:</span>
228
440
  <span id="respDuration" class="response-meta">-- ms</span>
229
441
  </div>
230
- <div class="meta-item">
231
- <span id="respAppliedRule" class="response-meta-rule">Rule: None</span>
232
- </div>
233
- <div class="meta-item" style="margin-left: auto;">
234
- <span id="activeRulesIndicator" class="active-rules-pill">Traffic: Normal</span>
442
+ <div class="meta-item meta-item-applied">
443
+ <span class="meta-label">Injected:</span>
444
+ <span id="respAppliedRule" class="response-meta-rule">None</span>
235
445
  </div>
236
446
  </div>
237
447
 
238
448
  <!-- Feedback Status Text -->
239
449
  <div id="testFeedback" class="test-status-text">Click "Send Test Request" or enable any scenario on the left to inspect responses.</div>
240
450
 
241
- <!-- Formatted Response Payload Viewer -->
451
+ <!-- Formatted Response Payload Viewer (Expands to fill height) -->
242
452
  <div class="response-body-wrapper">
243
453
  <pre id="responseBodyViewer" class="response-body-pre">(No response received yet. Select an endpoint above or click "Enable &amp; Test" on any scenario on the left.)</pre>
244
454
  </div>
@@ -248,43 +458,127 @@
248
458
  <span>Terminal: <code>curl -i http://localhost:3001/api/data</code></span>
249
459
  </div>
250
460
  </section>
251
- </div>
252
461
 
462
+ <!-- 2. Live Traffic Log Card (Starts at Custom Rule, Ends at Active Rules) -->
463
+ <section class="section-box live-log-card">
464
+ <div class="section-header header-with-action">
465
+ <div>
466
+ <h2>Live Traffic Log</h2>
467
+ <p>Real-time HTTP requests routed through proxy (<code>127.0.0.1:3001</code>).</p>
468
+ </div>
469
+ <button id="btnClearLog" class="btn-text">Clear Log</button>
470
+ </div>
471
+
472
+ <div class="table-container log-table-container">
473
+ <table class="log-table">
474
+ <thead>
475
+ <tr>
476
+ <th style="width: 80px;">Method</th>
477
+ <th>Path</th>
478
+ <th style="width: 90px;">Status</th>
479
+ <th>Applied Rule</th>
480
+ <th style="width: 90px; text-align: right;">Time</th>
481
+ </tr>
482
+ </thead>
483
+ <tbody id="activityFeed">
484
+ <tr>
485
+ <td colspan="5" class="table-empty">Listening for requests through http://127.0.0.1:3001...</td>
486
+ </tr>
487
+ </tbody>
488
+ </table>
489
+ </div>
490
+ </section>
491
+ </div>
253
492
  </div>
254
493
 
255
- <!-- ====================================================================
256
- BOTTOM FULL-WIDTH SECTION: LIVE TRAFFIC LOG
257
- ==================================================================== -->
258
- <section class="section-box full-width-log-section">
259
- <div class="section-header header-with-action">
260
- <div>
261
- <h2>Live Traffic Log</h2>
262
- <p>Real-time HTTP requests routed through proxy (<code>127.0.0.1:3001</code>).</p>
494
+ </main>
495
+
496
+ <!-- Auto-Healer Modal Dialog -->
497
+ <div id="healerModal" class="modal-backdrop" style="display: none;">
498
+ <div class="modal-dialog">
499
+ <div class="modal-header">
500
+ <div class="modal-title-group">
501
+ <span class="modal-badge">AGENTIC AUTO-HEALER</span>
502
+ <h3>Automated Code Remediation</h3>
263
503
  </div>
264
- <button id="btnClearLog" class="btn-text">Clear Log</button>
504
+ <button id="btnCloseHealer" class="btn-text btn-modal-close" type="button" title="Close modal">&times;</button>
265
505
  </div>
266
506
 
267
- <div class="table-container full-width-table-container">
268
- <table class="log-table">
269
- <thead>
270
- <tr>
271
- <th style="width: 80px;">Method</th>
272
- <th>Path</th>
273
- <th style="width: 90px;">Status</th>
274
- <th>Applied Rule</th>
275
- <th style="width: 90px; text-align: right;">Time</th>
276
- </tr>
277
- </thead>
278
- <tbody id="activityFeed">
279
- <tr>
280
- <td colspan="5" class="table-empty">Listening for requests through http://127.0.0.1:3001...</td>
281
- </tr>
282
- </tbody>
283
- </table>
284
- </div>
285
- </section>
507
+ <div class="modal-body">
508
+ <p class="modal-intro">
509
+ The Auto-Healer scans your backend project, detects missing resilience &amp; security protections, and generates reviewable Git patches with zero unwanted disk modifications.
510
+ </p>
286
511
 
287
- </main>
512
+ <div class="healer-config-row">
513
+ <div style="display: flex; justify-content: space-between; align-items: center;">
514
+ <label for="healerProjectDir">Target Service / Backend Directory:</label>
515
+ <span class="healer-dir-hint" style="font-size: 11px; color: var(--text-muted);">Default: <code>examples/vulnerable-backend</code></span>
516
+ </div>
517
+ <div class="healer-input-group">
518
+ <input type="text" id="healerProjectDir" class="form-input" value="examples/vulnerable-backend" placeholder="e.g. examples/vulnerable-backend or ./backend" spellcheck="false">
519
+ <button id="btnHealerScan" class="btn-primary" type="button">Scan Codebase</button>
520
+ </div>
521
+ <div class="healer-presets-pills" style="display: flex; gap: 8px; margin-top: 2px;">
522
+ <button type="button" class="btn-text btn-dir-preset" id="btnDirPresetSample" style="font-size: 11px; text-decoration: underline; padding: 0;">Target Sample Backend (examples/vulnerable-backend)</button>
523
+ <span style="color: var(--text-subtle);">|</span>
524
+ <button type="button" class="btn-text btn-dir-preset" id="btnDirPresetRoot" style="font-size: 11px; text-decoration: underline; padding: 0;">Custom Path</button>
525
+ </div>
526
+ </div>
527
+
528
+ <div class="healer-engine-bar">
529
+ <button id="btnToggleAiSettings" class="btn-text btn-engine-toggle" type="button">Configure AI Healer (Local LLM / Cloud AI Providers)</button>
530
+ <span id="healerEngineBadge" class="engine-badge codemod">Engine: CodeMod + AI Hybrid</span>
531
+ </div>
532
+
533
+ <div id="healerAiSettingsPanel" class="healer-ai-panel" style="display: none;">
534
+ <div class="ai-config-grid">
535
+ <div class="ai-config-item">
536
+ <label for="healerEngineMode">Remediation Mode:</label>
537
+ <select id="healerEngineMode" class="form-input select-healer-engine">
538
+ <option value="hybrid">Hybrid (Deterministic CodeMod + AI Agent)</option>
539
+ <option value="codemod">Deterministic AST CodeMod Only (Fast, Free)</option>
540
+ <option value="ai">AI Healer Agent Only (Universal Multi-Language)</option>
541
+ </select>
542
+ </div>
543
+ <div class="ai-config-item">
544
+ <label for="healerAiProvider">AI Provider:</label>
545
+ <select id="healerAiProvider" class="form-input select-ai-provider">
546
+ <option value="ollama">Local Offline LLM (http://127.0.0.1:11434)</option>
547
+ <option value="custom">Custom Inference / HTTP Endpoint</option>
548
+ <option value="openai">OpenAI-Compatible API</option>
549
+ <option value="anthropic">Anthropic API</option>
550
+ <option value="gemini">Google Gemini API</option>
551
+ </select>
552
+ </div>
553
+ <div class="ai-config-item" id="aiKeyGroup" style="display: none;">
554
+ <label for="healerAiKey">API Key:</label>
555
+ <input type="password" id="healerAiKey" class="form-input" placeholder="sk-..." spellcheck="false">
556
+ </div>
557
+ <div class="ai-config-item" id="aiEndpointGroup">
558
+ <label for="healerAiEndpoint">Endpoint URL:</label>
559
+ <input type="text" id="healerAiEndpoint" class="form-input" value="http://127.0.0.1:11434" placeholder="http://127.0.0.1:11434" spellcheck="false">
560
+ </div>
561
+ </div>
562
+ </div>
563
+
564
+ <div id="healerScanStatus" class="healer-status-bar" style="display: none;"></div>
565
+
566
+ <div id="healerDiffContainer" class="healer-diff-wrapper" style="display: none;"></div>
567
+
568
+ <div id="healerActionsBar" class="healer-actions-bar" style="display: none;">
569
+ <label class="backup-checkbox-label">
570
+ <input type="checkbox" id="healerBackupCheck" checked>
571
+ Create automatic backup in <code>.faultmesh-backup/</code>
572
+ </label>
573
+ <div class="healer-btn-group">
574
+ <button id="btnHealerApply" class="btn-primary" type="button">Apply Remedies to Codebase</button>
575
+ <button id="btnHealerResetSample" class="btn-secondary" type="button" title="Restore sample backend to its unhealed state to test auto-healing again">Reset Sample to Vulnerable</button>
576
+ <button id="btnHealerRollback" class="btn-secondary" type="button" style="display: none;">Rollback Last Patch</button>
577
+ </div>
578
+ </div>
579
+ </div>
580
+ </div>
581
+ </div>
288
582
 
289
583
  <script src="app.js"></script>
290
584
  </body>