tripwire-e2e 0.1.0 → 0.2.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.
- package/README.md +201 -169
- package/operators/_util.js +14 -1
- package/operators/dead-control.js +23 -23
- package/operators/hide-control.js +3 -3
- package/operators/index.js +81 -77
- package/operators/label-swap.js +1 -1
- package/operators/missing-row-action.js +24 -24
- package/operators/rendered-item-drop.js +31 -0
- package/operators/rendered-item-dup.js +20 -0
- package/operators/rendered-number-drift.js +24 -0
- package/package.json +1 -1
- package/src/agent.js +1 -1
- package/src/browser/mutate.js +156 -113
- package/src/browser/recorder.js +102 -80
- package/src/cli.js +41 -37
- package/src/commands/check.js +24 -7
- package/src/commands/coverage.js +110 -0
- package/src/commands/doctor.js +28 -0
- package/src/commands/fix.js +13 -4
- package/src/commands/run.js +370 -310
- package/src/commands/sabotage.js +85 -74
- package/src/kane.js +158 -150
- package/src/mutant.js +26 -26
- package/src/orphans.js +40 -0
- package/src/profile.js +13 -1
- package/src/proxy.js +292 -289
- package/src/report.js +183 -182
package/src/report.js
CHANGED
|
@@ -1,182 +1,183 @@
|
|
|
1
|
-
// Static HTML report and README badge, built from .tripwire/ state. No server, no external assets.
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import AdmZip from 'adm-zip';
|
|
5
|
-
import { readLedger, latest, lastRunId, score, perTest } from './ledger.js';
|
|
6
|
-
|
|
7
|
-
const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
8
|
-
const slug = (s) => s.replace(/[^\w.-]+/g, '_').slice(0, 80);
|
|
9
|
-
const readJson = (f, d) => { try { return JSON.parse(fs.readFileSync(f, 'utf8')); } catch { return d; } };
|
|
10
|
-
const readLines = (f) => (fs.existsSync(f) ? fs.readFileSync(f, 'utf8').split('\n').filter(Boolean).map((l) => JSON.parse(l)) : []);
|
|
11
|
-
|
|
12
|
-
// The last screenshot of a test inside an evidence pack (the page as it was when the run ended).
|
|
13
|
-
export function lastScreenshot(pack) {
|
|
14
|
-
if (!pack || !fs.existsSync(pack)) return null;
|
|
15
|
-
try {
|
|
16
|
-
const zip = new AdmZip(pack);
|
|
17
|
-
// Kane writes steps/<ordinal>-<id>/screenshot.jpg (older packs: .png)
|
|
18
|
-
const shots = zip.getEntries().map((e) => e.entryName).filter((n) => /\/steps\/[^/]+\/screenshot\.(png|jpe?g)$/.test(n));
|
|
19
|
-
if (!shots.length) return null;
|
|
20
|
-
const ord = (n) => Number((n.match(/\/steps\/(\d+)/) || [])[1] || 0);
|
|
21
|
-
shots.sort((a, b) => ord(a) - ord(b));
|
|
22
|
-
return zip.getEntry(shots[shots.length - 1]).getData();
|
|
23
|
-
} catch { return null; }
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// File extension from the image's magic bytes.
|
|
27
|
-
export const imageExt = (buf) => (buf[0] === 0x89 && buf[1] === 0x50 ? 'png' : 'jpg');
|
|
28
|
-
|
|
29
|
-
export function badge(scoreValue) {
|
|
30
|
-
const label = 'tripwire';
|
|
31
|
-
const value = scoreValue === null || scoreValue === undefined ? 'n/a' : `${Math.round(scoreValue)}%`;
|
|
32
|
-
const color = scoreValue === null || scoreValue === undefined ? '#9f9f9f' : scoreValue >= 80 ? '#2e7d32' : scoreValue >= 60 ? '#b26a00' : '#c62828';
|
|
33
|
-
const lw = 58, vw = 8 + value.length * 7.5;
|
|
34
|
-
return `<svg xmlns="http://www.w3.org/2000/svg" width="${lw + vw}" height="20" role="img" aria-label="${label}: ${value}"><title>${label}: ${value}</title><rect width="${lw}" height="20" fill="#444"/><rect x="${lw}" width="${vw}" height="20" fill="${color}"/><g fill="#fff" font-family="Verdana,DejaVu Sans,sans-serif" font-size="11" text-anchor="middle"><text x="${lw / 2}" y="14">${label}</text><text x="${lw + vw / 2}" y="14">${value}</text></g></svg>`;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function writeReport(dir) {
|
|
38
|
-
const out = path.join(dir, 'report');
|
|
39
|
-
const shotsDir = path.join(out, 'shots');
|
|
40
|
-
fs.mkdirSync(shotsDir, { recursive: true });
|
|
41
|
-
const all = readLedger(dir);
|
|
42
|
-
const runId = lastRunId(all);
|
|
43
|
-
const rows = latest(all, runId);
|
|
44
|
-
const s = score(rows);
|
|
45
|
-
// the same run before any proven fix: what the agent's first-draft suite caught on its own
|
|
46
|
-
const firstDraft = score(latest(all.filter((r) => !r.fixed), runId));
|
|
47
|
-
const fixedCount = rows.filter((r) => r.fixed).length;
|
|
48
|
-
const tests = perTest(rows);
|
|
49
|
-
const baseline = readJson(path.join(dir, 'baseline.json'), { tests: [] });
|
|
50
|
-
const summary = readJson(path.join(dir, 'runs', runId || '-', 'summary.json'), {});
|
|
51
|
-
const fixes = readLines(path.join(dir, 'fixes.jsonl'));
|
|
52
|
-
const equivalents = readJson(path.join(dir, 'equivalents.json'), []);
|
|
53
|
-
const lessons = fs.existsSync(path.join(dir, 'lessons.md')) ? fs.readFileSync(path.join(dir, 'lessons.md'), 'utf8') : '';
|
|
54
|
-
const coverage = readJson(path.join(dir, 'coverage.json'), null);
|
|
55
|
-
|
|
56
|
-
// score history: one point per run (first-draft vs now)
|
|
57
|
-
const runs = [...new Set(all.map((r) => r.run))];
|
|
58
|
-
const history = runs.map((r) => ({ run: r, ...score(latest(all, r)) })).filter((h) => h.score !== null);
|
|
59
|
-
|
|
60
|
-
const shot = (row) => {
|
|
61
|
-
const run = row.status === 'killed' ? row.runs?.find((x) => x.code === 1) : row.status === 'masked' ? null : row.runs?.find((x) => x.code === 0 && x.fired);
|
|
62
|
-
const buf = lastScreenshot(run?.pack);
|
|
63
|
-
if (!buf) return '';
|
|
64
|
-
const name = `${slug(row.id)}.${imageExt(buf)}`;
|
|
65
|
-
fs.writeFileSync(path.join(shotsDir, name), buf);
|
|
66
|
-
return `<figure><img src="shots/${esc(name)}" alt="The broken page as the test left it" loading="lazy"><figcaption>The broken app at the end of ${esc(run.test)}. The test still passed.</figcaption></figure>`;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
// Kane triages each failed replay on its own. Tripwire knows the app was broken on purpose,
|
|
70
|
-
// so it can show how that triage read a real product bug.
|
|
71
|
-
const triage = (r) => {
|
|
72
|
-
const t = r.runs?.find((x) => x.kaneTriage)?.kaneTriage;
|
|
73
|
-
if (!t) return '';
|
|
74
|
-
const product = t.family === 'product_bug' || t.confirmed;
|
|
75
|
-
return `<p class="triage">Kane's triage of the failure: <strong>${esc((t.family || '').replace(/_/g, ' '))}</strong>${t.category ? ` / ${esc(t.category.replace(/_/g, ' '))}` : ''}${t.confidence ? ` (${Math.round(t.confidence * 100)}%)` : ''}. ${product ? 'It identified a product bug.' : 'The app really was broken: this was a product bug.'}</p>`;
|
|
76
|
-
};
|
|
77
|
-
const triaged = rows.filter((r) => r.status === 'killed' && r.runs?.some((x) => x.kaneTriage));
|
|
78
|
-
const triagedAsTest = triaged.filter((r) => { const t = r.runs.find((x) => x.kaneTriage).kaneTriage; return !(t.family === 'product_bug' || t.confirmed); });
|
|
79
|
-
|
|
80
|
-
const byStatus = (st) => rows.filter((r) => r.status === st);
|
|
81
|
-
const fixFor = new Map(fixes.filter((f) => f.result === 'killed').map((f) => [f.id, f]));
|
|
82
|
-
const card = (r, withShot) => `
|
|
83
|
-
<article class="mutant ${r.status}">
|
|
84
|
-
<header><span class="pill ${r.status}">${esc(r.status.replace('-', ' '))}</span><span class="op">${esc(r.family)} · ${esc(r.operator)}</span></header>
|
|
85
|
-
<h3>${esc(r.describe)}</h3>
|
|
86
|
-
${r.expect ? `<p class="expect">A good test would: ${esc(r.expect.charAt(0).toLowerCase() + r.expect.slice(1))}.</p>` : ''}
|
|
87
|
-
<p class="meta">Tests that walked past it: ${(r.touches_tests || []).map((t) => `<code>${esc(t)}</code>`).join(' ')}</p>
|
|
88
|
-
${r.
|
|
89
|
-
${
|
|
90
|
-
${
|
|
91
|
-
${
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
<
|
|
102
|
-
<
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
.
|
|
109
|
-
.
|
|
110
|
-
.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
.
|
|
114
|
-
.mutant
|
|
115
|
-
.
|
|
116
|
-
.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
.
|
|
121
|
-
.
|
|
122
|
-
.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
<div
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
<div class="count
|
|
131
|
-
<div class="count
|
|
132
|
-
<div class="count
|
|
133
|
-
|
|
134
|
-
</
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
<
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
<
|
|
147
|
-
|
|
148
|
-
</
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
<
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
<
|
|
160
|
-
<
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
<
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
<
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
fs.writeFileSync(path.join(out, '
|
|
180
|
-
fs.writeFileSync(path.join(out, '
|
|
181
|
-
|
|
182
|
-
|
|
1
|
+
// Static HTML report and README badge, built from .tripwire/ state. No server, no external assets.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import AdmZip from 'adm-zip';
|
|
5
|
+
import { readLedger, latest, lastRunId, score, perTest } from './ledger.js';
|
|
6
|
+
|
|
7
|
+
const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
8
|
+
const slug = (s) => s.replace(/[^\w.-]+/g, '_').slice(0, 80);
|
|
9
|
+
const readJson = (f, d) => { try { return JSON.parse(fs.readFileSync(f, 'utf8')); } catch { return d; } };
|
|
10
|
+
const readLines = (f) => (fs.existsSync(f) ? fs.readFileSync(f, 'utf8').split('\n').filter(Boolean).map((l) => JSON.parse(l)) : []);
|
|
11
|
+
|
|
12
|
+
// The last screenshot of a test inside an evidence pack (the page as it was when the run ended).
|
|
13
|
+
export function lastScreenshot(pack) {
|
|
14
|
+
if (!pack || !fs.existsSync(pack)) return null;
|
|
15
|
+
try {
|
|
16
|
+
const zip = new AdmZip(pack);
|
|
17
|
+
// Kane writes steps/<ordinal>-<id>/screenshot.jpg (older packs: .png)
|
|
18
|
+
const shots = zip.getEntries().map((e) => e.entryName).filter((n) => /\/steps\/[^/]+\/screenshot\.(png|jpe?g)$/.test(n));
|
|
19
|
+
if (!shots.length) return null;
|
|
20
|
+
const ord = (n) => Number((n.match(/\/steps\/(\d+)/) || [])[1] || 0);
|
|
21
|
+
shots.sort((a, b) => ord(a) - ord(b));
|
|
22
|
+
return zip.getEntry(shots[shots.length - 1]).getData();
|
|
23
|
+
} catch { return null; }
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// File extension from the image's magic bytes.
|
|
27
|
+
export const imageExt = (buf) => (buf[0] === 0x89 && buf[1] === 0x50 ? 'png' : 'jpg');
|
|
28
|
+
|
|
29
|
+
export function badge(scoreValue) {
|
|
30
|
+
const label = 'tripwire';
|
|
31
|
+
const value = scoreValue === null || scoreValue === undefined ? 'n/a' : `${Math.round(scoreValue)}%`;
|
|
32
|
+
const color = scoreValue === null || scoreValue === undefined ? '#9f9f9f' : scoreValue >= 80 ? '#2e7d32' : scoreValue >= 60 ? '#b26a00' : '#c62828';
|
|
33
|
+
const lw = 58, vw = 8 + value.length * 7.5;
|
|
34
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${lw + vw}" height="20" role="img" aria-label="${label}: ${value}"><title>${label}: ${value}</title><rect width="${lw}" height="20" fill="#444"/><rect x="${lw}" width="${vw}" height="20" fill="${color}"/><g fill="#fff" font-family="Verdana,DejaVu Sans,sans-serif" font-size="11" text-anchor="middle"><text x="${lw / 2}" y="14">${label}</text><text x="${lw + vw / 2}" y="14">${value}</text></g></svg>`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function writeReport(dir) {
|
|
38
|
+
const out = path.join(dir, 'report');
|
|
39
|
+
const shotsDir = path.join(out, 'shots');
|
|
40
|
+
fs.mkdirSync(shotsDir, { recursive: true });
|
|
41
|
+
const all = readLedger(dir);
|
|
42
|
+
const runId = lastRunId(all);
|
|
43
|
+
const rows = latest(all, runId);
|
|
44
|
+
const s = score(rows);
|
|
45
|
+
// the same run before any proven fix: what the agent's first-draft suite caught on its own
|
|
46
|
+
const firstDraft = score(latest(all.filter((r) => !r.fixed), runId));
|
|
47
|
+
const fixedCount = rows.filter((r) => r.fixed).length;
|
|
48
|
+
const tests = perTest(rows);
|
|
49
|
+
const baseline = readJson(path.join(dir, 'baseline.json'), { tests: [] });
|
|
50
|
+
const summary = readJson(path.join(dir, 'runs', runId || '-', 'summary.json'), {});
|
|
51
|
+
const fixes = readLines(path.join(dir, 'fixes.jsonl'));
|
|
52
|
+
const equivalents = readJson(path.join(dir, 'equivalents.json'), []);
|
|
53
|
+
const lessons = fs.existsSync(path.join(dir, 'lessons.md')) ? fs.readFileSync(path.join(dir, 'lessons.md'), 'utf8') : '';
|
|
54
|
+
const coverage = readJson(path.join(dir, 'coverage.json'), null);
|
|
55
|
+
|
|
56
|
+
// score history: one point per run (first-draft vs now)
|
|
57
|
+
const runs = [...new Set(all.map((r) => r.run))];
|
|
58
|
+
const history = runs.map((r) => ({ run: r, ...score(latest(all, r)) })).filter((h) => h.score !== null);
|
|
59
|
+
|
|
60
|
+
const shot = (row) => {
|
|
61
|
+
const run = row.status === 'killed' ? row.runs?.find((x) => x.code === 1) : row.status === 'masked' ? null : row.runs?.find((x) => x.code === 0 && x.fired);
|
|
62
|
+
const buf = lastScreenshot(run?.pack);
|
|
63
|
+
if (!buf) return '';
|
|
64
|
+
const name = `${slug(row.id)}.${imageExt(buf)}`;
|
|
65
|
+
fs.writeFileSync(path.join(shotsDir, name), buf);
|
|
66
|
+
return `<figure><img src="shots/${esc(name)}" alt="The broken page as the test left it" loading="lazy"><figcaption>The broken app at the end of ${esc(run.test)}. The test still passed.</figcaption></figure>`;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// Kane triages each failed replay on its own. Tripwire knows the app was broken on purpose,
|
|
70
|
+
// so it can show how that triage read a real product bug.
|
|
71
|
+
const triage = (r) => {
|
|
72
|
+
const t = r.runs?.find((x) => x.kaneTriage)?.kaneTriage;
|
|
73
|
+
if (!t) return '';
|
|
74
|
+
const product = t.family === 'product_bug' || t.confirmed;
|
|
75
|
+
return `<p class="triage">Kane's triage of the failure: <strong>${esc((t.family || '').replace(/_/g, ' '))}</strong>${t.category ? ` / ${esc(t.category.replace(/_/g, ' '))}` : ''}${t.confidence ? ` (${Math.round(t.confidence * 100)}%)` : ''}. ${product ? 'It identified a product bug.' : 'The app really was broken: this was a product bug.'}</p>`;
|
|
76
|
+
};
|
|
77
|
+
const triaged = rows.filter((r) => r.status === 'killed' && r.runs?.some((x) => x.kaneTriage));
|
|
78
|
+
const triagedAsTest = triaged.filter((r) => { const t = r.runs.find((x) => x.kaneTriage).kaneTriage; return !(t.family === 'product_bug' || t.confirmed); });
|
|
79
|
+
|
|
80
|
+
const byStatus = (st) => rows.filter((r) => r.status === st);
|
|
81
|
+
const fixFor = new Map(fixes.filter((f) => f.result === 'killed').map((f) => [f.id, f]));
|
|
82
|
+
const card = (r, withShot) => `
|
|
83
|
+
<article class="mutant ${r.status}">
|
|
84
|
+
<header><span class="pill ${r.status}">${esc(r.status.replace('-', ' '))}</span><span class="op">${esc(r.family)} · ${esc(r.operator)}</span></header>
|
|
85
|
+
<h3>${esc(r.describe)}</h3>
|
|
86
|
+
${r.expect ? `<p class="expect">A good test would: ${esc(r.expect.charAt(0).toLowerCase() + r.expect.slice(1))}.</p>` : ''}
|
|
87
|
+
<p class="meta">Tests that walked past it: ${(r.touches_tests || []).map((t) => `<code>${esc(t)}</code>`).join(' ')}</p>
|
|
88
|
+
${r.suspectedEquivalent ? `<p class="warn">Suspected equivalent: ${esc(r.suspectedEquivalent)} If a person agrees, add it to <code>.tripwire/equivalents.json</code> with the reason; it then leaves the score and is listed below.</p>` : ''}
|
|
89
|
+
${r.status === 'masked' ? `<p class="warn">With healing off, <code>${esc(r.killed_by)}</code> failed. With Kane's default healing it re-authored its steps and <strong>passed on the broken app</strong>.</p>` : ''}
|
|
90
|
+
${triage(r)}
|
|
91
|
+
${fixFor.has(r.id) ? `<p class="fixed">Fixed by <code>tripwire fix</code>: clean run passed, mutant run failed (${esc(fixFor.get(r.id).proof?.clean?.session || '')} / ${esc(fixFor.get(r.id).proof?.mutant?.session || '')}).</p>` : ''}
|
|
92
|
+
${withShot ? shot(r) : ''}
|
|
93
|
+
<details><summary>Mutant id</summary><code>${esc(r.id)}</code></details>
|
|
94
|
+
</article>`;
|
|
95
|
+
|
|
96
|
+
const pct = (v) => (v === null || v === undefined ? '–' : `${v}%`);
|
|
97
|
+
const minutes = Math.round(rows.reduce((a, r) => a + (r.runs || []).reduce((b, x) => b + (x.durationMs || 0), 0), 0) / 600) / 100;
|
|
98
|
+
const perMutant = rows.length ? Math.round((minutes * 60) / rows.length) : 0;
|
|
99
|
+
|
|
100
|
+
const html = `<!doctype html>
|
|
101
|
+
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
|
102
|
+
<title>Tripwire report</title>
|
|
103
|
+
<style>
|
|
104
|
+
:root{--bg:#f6f5f1;--surface:#fff;--ink:#1c1b19;--muted:#66625b;--line:#e2ded5;--killed:#2e7d32;--survived:#c62828;--masked:#8e24aa;--nr:#6d6d6d;--accent:#2f5d50}
|
|
105
|
+
@media (prefers-color-scheme:dark){:root{--bg:#141412;--surface:#1d1c1a;--ink:#ecebe7;--muted:#a19d95;--line:#33312d;--killed:#66bb6a;--survived:#ef5350;--masked:#ce93d8;--nr:#9e9e9e;--accent:#7fb7a5}}
|
|
106
|
+
*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--ink);font:16px/1.55 system-ui,-apple-system,"Segoe UI",sans-serif}
|
|
107
|
+
main{max-width:1040px;margin:0 auto;padding:32px 16px 80px}h1{font-size:1.5rem;margin:0}h2{font-size:1.15rem;margin:40px 0 12px}h3{font-size:1rem;margin:8px 0}
|
|
108
|
+
.top{display:flex;flex-wrap:wrap;gap:24px;align-items:flex-end;justify-content:space-between;border-bottom:1px solid var(--line);padding-bottom:24px}
|
|
109
|
+
.score{font-size:3.5rem;font-weight:700;line-height:1}.sub{color:var(--muted)}
|
|
110
|
+
.counts{display:flex;flex-wrap:wrap;gap:8px}.count{background:var(--surface);border:1px solid var(--line);border-radius:8px;padding:8px 14px;min-width:110px}.count b{display:block;font-size:1.4rem}
|
|
111
|
+
.count.killed b{color:var(--killed)}.count.survived b{color:var(--survived)}.count.masked b{color:var(--masked)}.count.nr b{color:var(--nr)}
|
|
112
|
+
table{width:100%;border-collapse:collapse;background:var(--surface);border:1px solid var(--line);border-radius:8px;overflow:hidden}th,td{text-align:left;padding:10px 12px;border-bottom:1px solid var(--line);vertical-align:top}th{font-size:.85rem;color:var(--muted)}
|
|
113
|
+
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:12px}
|
|
114
|
+
.mutant{background:var(--surface);border:1px solid var(--line);border-left:4px solid var(--nr);border-radius:8px;padding:14px}
|
|
115
|
+
.mutant.survived{border-left-color:var(--survived)}.mutant.masked{border-left-color:var(--masked)}.mutant.killed{border-left-color:var(--killed)}
|
|
116
|
+
.pill{font-size:.75rem;font-weight:600;text-transform:uppercase;letter-spacing:.04em;margin-right:8px}.pill.survived{color:var(--survived)}.pill.masked{color:var(--masked)}.pill.killed{color:var(--killed)}.pill.not-reached,.pill.error{color:var(--nr)}
|
|
117
|
+
.op{font-size:.8rem;color:var(--muted)}.expect,.meta{color:var(--muted);font-size:.9rem;margin:4px 0}.warn{color:var(--masked);font-size:.9rem}.triage{font-size:.85rem;color:var(--muted);border-left:2px solid var(--line);padding-left:8px}.fixed{color:var(--killed);font-size:.9rem}
|
|
118
|
+
figure{margin:10px 0 0}img{max-width:100%;border:1px solid var(--line);border-radius:6px}figcaption{font-size:.8rem;color:var(--muted)}
|
|
119
|
+
details{margin-top:8px;font-size:.8rem;color:var(--muted)}code{font-family:ui-monospace,Consolas,monospace;font-size:.85em;word-break:break-all}
|
|
120
|
+
.bar{height:8px;background:var(--line);border-radius:4px;overflow:hidden;min-width:80px}.bar i{display:block;height:100%;background:var(--killed)}
|
|
121
|
+
.history{display:flex;gap:16px;flex-wrap:wrap}.history div{background:var(--surface);border:1px solid var(--line);border-radius:8px;padding:8px 14px}
|
|
122
|
+
.lessons{white-space:pre-wrap;background:var(--surface);border:1px solid var(--line);border-radius:8px;padding:14px;font-size:.9rem}
|
|
123
|
+
.note{color:var(--muted);font-size:.9rem;max-width:70ch}
|
|
124
|
+
</style></head><body><main>
|
|
125
|
+
<section class="top">
|
|
126
|
+
<div><h1>Tripwire</h1><p class="sub">Would the tests fail if the app were broken? Run ${esc(runId || '–')}${summary.commit ? ` · commit ${esc(summary.commit)}` : ''}</p>
|
|
127
|
+
<div class="score" aria-label="mutation score">${pct(s.score)}</div><p class="sub">of reachable bugs caught (killed ÷ killed + survived + masked)</p>
|
|
128
|
+
${fixedCount ? `<p class="sub"><strong>${pct(firstDraft.score)}</strong> for the first-draft suite → <strong>${pct(s.score)}</strong> after <code>tripwire fix</code> strengthened ${fixedCount} test${fixedCount > 1 ? 's' : ''}, each proven by Kane: pass on the real app, fail on the broken one.</p>` : ''}</div>
|
|
129
|
+
<div class="counts">
|
|
130
|
+
<div class="count killed"><b>${s.killed}</b>killed</div>
|
|
131
|
+
<div class="count survived"><b>${s.survived}</b>survived</div>
|
|
132
|
+
<div class="count masked"><b>${s.masked}</b>masked by heal</div>
|
|
133
|
+
<div class="count nr"><b>${s['not-reached']}</b>not reached</div>
|
|
134
|
+
</div>
|
|
135
|
+
</section>
|
|
136
|
+
|
|
137
|
+
${history.length > 1 ? `<h2>Score over time</h2><div class="history">${history.map((h, i) => `<div><b>${pct(h.score)}</b><br><span class="sub">${i === 0 ? 'first run' : esc(h.run.slice(5, 16).replace('T', ' '))}</span></div>`).join('')}</div>` : ''}
|
|
138
|
+
|
|
139
|
+
<h2>Bugs the suite walked past (${s.survived})</h2>
|
|
140
|
+
${s.survived ? `<div class="grid">${byStatus('survived').map((r) => card(r, true)).join('')}</div>` : '<p class="note">None. Every mutant that fired was caught.</p>'}
|
|
141
|
+
|
|
142
|
+
<h2>Masked by healing (${s.masked})</h2>
|
|
143
|
+
<p class="note">Strict replay caught these, but Kane's default adaptive healing re-authored the failing steps and the run passed on the broken app. Run suites that guard releases with <code>--no-adaptive-heal</code>, or gate on <code>metrics.heal.healed_tests</code>.</p>
|
|
144
|
+
${s.masked ? `<div class="grid">${byStatus('masked').map((r) => card(r, false)).join('')}</div>` : ''}
|
|
145
|
+
|
|
146
|
+
<h2>Per test</h2>
|
|
147
|
+
<table><thead><tr><th>Test</th><th>Mutants touched</th><th>Killed</th><th>Walked past</th><th>Score</th><th>Assertions</th></tr></thead><tbody>
|
|
148
|
+
${tests.map((t) => { const b = baseline.tests?.find((x) => x.test === t.test); return `<tr><td><code>${esc(t.test)}</code></td><td>${t.touched}</td><td>${t.killed}</td><td>${t.survivedPast + t.masked}</td><td><div class="bar" title="${t.score ?? '–'}%"><i style="width:${t.score ?? 0}%"></i></div>${t.score ?? '–'}%</td><td>${b?.testsWithoutChecks ? '<strong style="color:var(--survived)">none</strong>' : 'yes'}</td></tr>`; }).join('')}
|
|
149
|
+
</tbody></table>
|
|
150
|
+
|
|
151
|
+
${coverage ? `<h2>Acceptance criteria</h2><p class="note">Kane reports a criterion as proven or owed. Tripwire adds a third state: <b>proven but unguarded</b>, where the tests that check it pass on the real app but a bug that broke it got past them.</p><table><thead><tr><th>Criterion</th><th>Kane</th><th>Tripwire</th><th>Bugs that got past</th></tr></thead><tbody>${coverage.map((c) => `<tr><td>${esc(c.criterion)}</td><td>${esc(c.kane)}</td><td><strong class="${c.state === 'proven but unguarded' ? 'warn' : ''}">${esc(c.state)}</strong></td><td>${(c.escaped || []).map(esc).join('<br>')}</td></tr>`).join('')}</tbody></table>` : ''}
|
|
152
|
+
|
|
153
|
+
${triaged.length ? `<h2>How Kane's triage read the planted bugs</h2>
|
|
154
|
+
<p class="note">Every mutant below was a real break in the app. Kane triaged ${triaged.length} of the failing runs; it attributed <strong>${triagedAsTest.length}</strong> of them to the test rather than the product (typically "locator rot": the page changed, so the recording looks stale). From inside a single run a broken app and an outdated test look alike; Tripwire is the outside reference that tells them apart. Treat a triage of "automation bug" on a release branch as a prompt to look, not as a reason to re-record.</p>` : ''}
|
|
155
|
+
|
|
156
|
+
<h2>Caught (${s.killed})</h2>
|
|
157
|
+
<details><summary>Show all ${s.killed} killed mutants</summary><div class="grid">${byStatus('killed').map((r) => card(r, false)).join('')}</div></details>
|
|
158
|
+
|
|
159
|
+
<h2>Not reached (${s['not-reached']})</h2>
|
|
160
|
+
<p class="note">The mutant never fired during any test, so it says nothing about the assertions. It usually means no test exercises that path (for example, no test ever submits invalid input). Not counted in the score.</p>
|
|
161
|
+
<details><summary>Show</summary><ul>${byStatus('not-reached').map((r) => `<li>${esc(r.describe)}</li>`).join('')}</ul></details>
|
|
162
|
+
|
|
163
|
+
${byStatus('error').length ? `<h2>Errors (${byStatus('error').length})</h2><p class="note">Kane exited 2 (error) or 3 (timeout) twice. Never counted as kills.</p><ul>${byStatus('error').map((r) => `<li>${esc(r.describe)}</li>`).join('')}</ul>` : ''}
|
|
164
|
+
|
|
165
|
+
<h2>Excluded as equivalent (${equivalents.length})</h2>
|
|
166
|
+
${equivalents.length ? `<ul>${equivalents.map((e) => `<li><code>${esc(e.id)}</code> – ${esc(e.reason)}${e.approvedBy ? ` (approved by ${esc(e.approvedBy)})` : ''}</li>`).join('')}</ul>` : '<p class="note">None. Mutants are excluded only with a human-approved reason in <code>.tripwire/equivalents.json</code>.</p>'}
|
|
167
|
+
|
|
168
|
+
${fixes.length ? `<h2>Strengthened tests (${fixes.filter((f) => f.result === 'killed').length} of ${fixes.length} attempts)</h2><table><thead><tr><th>Mutant</th><th>Test</th><th>Result</th><th>Attempts</th></tr></thead><tbody>${fixes.map((f) => `<tr><td>${esc(f.describe)}</td><td><code>${esc(f.test || '')}</code></td><td>${esc(f.result)}</td><td>${f.attempts}</td></tr>`).join('')}</tbody></table>` : ''}
|
|
169
|
+
|
|
170
|
+
${lessons ? `<h2>Lessons for the test-writing agent</h2><div class="lessons">${esc(lessons)}</div>` : ''}
|
|
171
|
+
|
|
172
|
+
<h2>Cost</h2>
|
|
173
|
+
<p>${rows.length} mutants · ${minutes} minutes of Kane runs (${perMutant}s per mutant)${summary.creditsUsed !== null && summary.creditsUsed !== undefined ? ` · ${summary.creditsUsed} credits` : ''}. Replays run from Kane's cache with healing off.</p>
|
|
174
|
+
|
|
175
|
+
<h2>What this does not measure</h2>
|
|
176
|
+
<p class="note">Tripwire mutates traffic and the rendered page, not source code. It tells you whether the suite notices breakage a user would see. It does not replace unit-level mutation testing, and it cannot see server-side effects that never reach the browser.</p>
|
|
177
|
+
</main></body></html>`;
|
|
178
|
+
|
|
179
|
+
fs.writeFileSync(path.join(out, 'index.html'), html);
|
|
180
|
+
fs.writeFileSync(path.join(out, 'badge.svg'), badge(s.score));
|
|
181
|
+
fs.writeFileSync(path.join(out, 'score.json'), JSON.stringify({ run: runId, ...s }, null, 2));
|
|
182
|
+
return path.join(out, 'index.html');
|
|
183
|
+
}
|