blastproof 0.25.0 → 0.27.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 +15 -6
- package/dist/{chunk-RA4N57HA.js → chunk-DO4WZKLT.js} +51 -4
- package/dist/chunk-DO4WZKLT.js.map +1 -0
- package/dist/cli.js +118 -20
- package/dist/cli.js.map +1 -1
- package/dist/{snapshot-PYB4N7E7.js → snapshot-JISKGGMN.js} +4 -2
- package/package.json +1 -1
- package/dist/chunk-RA4N57HA.js.map +0 -1
- /package/dist/{snapshot-PYB4N7E7.js.map → snapshot-JISKGGMN.js.map} +0 -0
package/README.md
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
[](https://github.com/hamc/blastproof/actions/workflows/ci.yml)
|
|
10
10
|
[](https://github.com/hamc/blastproof/actions/workflows/dogfood.yml)
|
|
11
|
+
[](https://github.com/marketplace/actions/blastproof-e2e-ai-testing)
|
|
11
12
|
[](./LICENSE)
|
|
12
13
|
|
|
13
14
|
**Open-source AI testing agent for pull requests.** Write end-to-end tests as plain English. An agent drives a real browser to run them, selects only the ones your diff can affect, and scores the result before merge.
|
|
@@ -86,7 +87,15 @@ The agent acts on the element it read, not on a search for its name. Each elemen
|
|
|
86
87
|
| `<button aria-label="Delete note">` | an icon-only button with no name |
|
|
87
88
|
| `<select>` with `<option>`s | an ARIA-less custom dropdown |
|
|
88
89
|
|
|
89
|
-
**An editable data grid
|
|
90
|
+
**An editable data grid needs one cell per step.** On a budgeting app's transaction register, a new row shows only the cell that has focus. The date input appears as `textbox [active]: 10/12/2026`, with no name. The empty payee and notes cells are plain `div`s, and the accessibility tree drops them. Each cell becomes a named input only once it is focused. A step asking for four values at once shows the agent one textbox, and it typed the payee into the date. Written one cell per step in keyboard order, the same journey passed:
|
|
91
|
+
|
|
92
|
+
```yaml
|
|
93
|
+
- click "Add New" and verify a new transaction row is open with its date field focused
|
|
94
|
+
- press Tab to move to the payee field, type Fast Internet, and choose "Fast Internet" from the suggestions
|
|
95
|
+
- press Tab three times to move to the payment field, type 12.34, and click "Add"
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
That test failed 3 runs of 3 written as one step, and passed 3 of 3 written this way, on 0.26.0 with `claude-haiku-5.5`. On the app's side, a label on each cell's input makes the one-step version readable too. If your core journey is a row editor, spend one test on it before adopting ([#67](https://github.com/hamc/blastproof/issues/67)).
|
|
90
99
|
|
|
91
100
|
**Run an accessibility checker on your app before installing anything.** The result predicts how well this will work better than anything else you could measure — and the fixes it suggests are worth making regardless of whether you adopt this tool.
|
|
92
101
|
|
|
@@ -106,7 +115,7 @@ If a critical journey needs one of these, that journey stays with your existing
|
|
|
106
115
|
|
|
107
116
|
**Use a seeded database, a staging environment you can reset, or a throwaway account. Do not gate on a run against production data.**
|
|
108
117
|
|
|
109
|
-
Within a step, an action that commits — a click, or pressing Enter — is
|
|
118
|
+
Within a step, an action that commits — a click, or pressing Enter — is not performed twice: the runner refuses the repeat and tells the agent it already did that. This closes the case that used to produce duplicate records, where a submit answered by a redirect came back to a reset form and the agent, seeing no evidence of its own work, refilled it and submitted again. One repeat goes through: the same control pressed again right after itself, with nothing else done in between, when the page changed after the last press — a tour's "Next", a wizard, "load more".
|
|
110
119
|
|
|
111
120
|
It is **not** a guarantee of zero duplicate writes. An agent that reaches the same effect by a genuinely different route — another control that does the same thing — is not caught.
|
|
112
121
|
|
|
@@ -252,7 +261,7 @@ blastproof run --min-score 80 # one failing P2 is tolerated
|
|
|
252
261
|
|
|
253
262
|
The calls that *choose* an action, and the one that drafts a test, are deliberately left free — that latitude is what re-resolves a control after a redesign instead of failing on it.
|
|
254
263
|
|
|
255
|
-
Wiring this into a pipeline, with the gating patterns worth knowing: [Running in CI](./docs/ci.md).
|
|
264
|
+
Wiring this into a pipeline, with the gating patterns worth knowing: [Running in CI](./docs/ci.md). The Action is listed on the GitHub Marketplace as [blastproof e2e AI testing](https://github.com/marketplace/actions/blastproof-e2e-ai-testing).
|
|
256
265
|
|
|
257
266
|
## Without a browser or a key
|
|
258
267
|
|
|
@@ -307,15 +316,15 @@ A merge gate is judged by two numbers. A **false PASS** is a test that passes on
|
|
|
307
316
|
| --- | --- | --- |
|
|
308
317
|
| false FAIL, correct app (40 test runs) | 0 (≤ 8.8%) | 0 (≤ 8.8%) |
|
|
309
318
|
| false PASS, literal bugs (30) | 0 (≤ 11.4%) | 0 (≤ 11.4%) |
|
|
310
|
-
| false PASS, subtle bugs (20) | 0 (≤ 16.
|
|
319
|
+
| false PASS, subtle bugs (20) | 0 of 19 (≤ 16.8%) | 0 (≤ 16.1%) |
|
|
311
320
|
|
|
312
|
-
The bounds are 95% upper bounds: zero errors in 40 runs means "below about 9%", not "never". The first run of this table found a false PASS on Haiku, 2 subtle runs in 20. The confirmation showed order `#BP-1002`, another paragraph mentioned `#BP-1001` as a previous order, and a step checking for `#BP-1001` *in the confirmation* passed. That was fixed in the judge ([#147](https://github.com/hamc/blastproof/issues/147)), and
|
|
321
|
+
The bounds are 95% upper bounds: zero errors in 40 runs means "below about 9%", not "never". The first run of this table found a false PASS on Haiku, 2 subtle runs in 20. The confirmation showed order `#BP-1002`, another paragraph mentioned `#BP-1001` as a previous order, and a step checking for `#BP-1001` *in the confirmation* passed. That was fixed in the judge ([#147](https://github.com/hamc/blastproof/issues/147)). On 0.26.0, Haiku had one false FAIL in 40, in the notes test: the note was listed and counted, but the model had typed it into the empty field again, and the judge read the filled field as a form not yet submitted. One subtle run on Haiku ended incomplete, and is left out of its count.
|
|
313
322
|
|
|
314
323
|
The demo app is small and well labelled, so these numbers flatter. Expect a real application to do worse. The point of this table is that it can be reproduced, and that every change claiming better verdicts has to move it.
|
|
315
324
|
|
|
316
325
|
The same benchmark over seven more models, and why it chose the OpenAI and Ollama defaults, is in [Choosing a model](./docs/configuration.md#choosing-a-model).
|
|
317
326
|
|
|
318
|
-
Measured 2026-10-
|
|
327
|
+
Measured 2026-10-13 on 0.27.0, 5 samples, through OpenRouter. To reproduce:
|
|
319
328
|
|
|
320
329
|
```bash
|
|
321
330
|
npm run build
|
|
@@ -5,6 +5,39 @@ var DEFAULT_MAX_LINES = 200;
|
|
|
5
5
|
function indentOf(line) {
|
|
6
6
|
return line.length - line.trimStart().length;
|
|
7
7
|
}
|
|
8
|
+
var DIALOG_LINE = /^\s*- '?(?:dialog|alertdialog)(?=[\s:"']|$)/;
|
|
9
|
+
var OMITTED_LINE = /^\s*- \.\.\. \(\d+ lines? omitted: max_snapshot_lines is (\d+)\)$/m;
|
|
10
|
+
function snapshotCutAt(snapshot) {
|
|
11
|
+
const match = OMITTED_LINE.exec(snapshot);
|
|
12
|
+
return match ? Number(match[1]) : void 0;
|
|
13
|
+
}
|
|
14
|
+
function linesToKeep(lines, maxLines) {
|
|
15
|
+
const keep = /* @__PURE__ */ new Set();
|
|
16
|
+
const subtreeEnd = (i) => {
|
|
17
|
+
let j = i + 1;
|
|
18
|
+
while (j < lines.length && indentOf(lines[j]) > indentOf(lines[i])) j++;
|
|
19
|
+
return j;
|
|
20
|
+
};
|
|
21
|
+
const ancestors = (i) => {
|
|
22
|
+
const found = [];
|
|
23
|
+
let indent = indentOf(lines[i]);
|
|
24
|
+
for (let j = i - 1; j >= 0 && indent > 0; j--) {
|
|
25
|
+
if (indentOf(lines[j]) < indent) {
|
|
26
|
+
found.unshift(j);
|
|
27
|
+
indent = indentOf(lines[j]);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return found;
|
|
31
|
+
};
|
|
32
|
+
const dialogs = lines.flatMap((line, i) => DIALOG_LINE.test(line) ? [i] : []).reverse();
|
|
33
|
+
const focused = lines.flatMap((line, i) => line.includes("[active]") ? [i] : []);
|
|
34
|
+
for (const anchor of [...dialogs.slice(0, 1), ...focused, ...dialogs.slice(1)]) {
|
|
35
|
+
for (const line of ancestors(anchor)) if (keep.size < maxLines) keep.add(line);
|
|
36
|
+
for (let line = anchor; line < subtreeEnd(anchor) && keep.size < maxLines; line++) keep.add(line);
|
|
37
|
+
}
|
|
38
|
+
for (let line = 0; line < lines.length && keep.size < maxLines; line++) keep.add(line);
|
|
39
|
+
return keep;
|
|
40
|
+
}
|
|
8
41
|
function trimSnapshot(snapshotYaml, maxLines = DEFAULT_MAX_LINES) {
|
|
9
42
|
let lines = snapshotYaml.split("\n").filter((line) => line.trim().length > 0);
|
|
10
43
|
for (let pass = 0; pass < 5; pass++) {
|
|
@@ -26,10 +59,23 @@ function trimSnapshot(snapshotYaml, maxLines = DEFAULT_MAX_LINES) {
|
|
|
26
59
|
lines = kept;
|
|
27
60
|
if (removed === 0) break;
|
|
28
61
|
}
|
|
29
|
-
if (lines.length
|
|
30
|
-
|
|
62
|
+
if (lines.length <= maxLines) return lines.join("\n");
|
|
63
|
+
const keep = linesToKeep(lines, maxLines);
|
|
64
|
+
const out = [];
|
|
65
|
+
let omitted = 0;
|
|
66
|
+
for (let i = 0; i <= lines.length; i++) {
|
|
67
|
+
if (i < lines.length && !keep.has(i)) {
|
|
68
|
+
omitted++;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (omitted > 0) {
|
|
72
|
+
const indent = " ".repeat(indentOf(lines[i - omitted]));
|
|
73
|
+
out.push(`${indent}- ... (${omitted} ${omitted === 1 ? "line" : "lines"} omitted: max_snapshot_lines is ${maxLines})`);
|
|
74
|
+
omitted = 0;
|
|
75
|
+
}
|
|
76
|
+
if (i < lines.length) out.push(lines[i]);
|
|
31
77
|
}
|
|
32
|
-
return
|
|
78
|
+
return out.join("\n");
|
|
33
79
|
}
|
|
34
80
|
async function captureSnapshot(page, options = {}) {
|
|
35
81
|
const raw = await page.locator("body").ariaSnapshot({ mode: "ai" });
|
|
@@ -69,9 +115,10 @@ function indexRefs(snapshot) {
|
|
|
69
115
|
}
|
|
70
116
|
|
|
71
117
|
export {
|
|
118
|
+
snapshotCutAt,
|
|
72
119
|
trimSnapshot,
|
|
73
120
|
captureSnapshot,
|
|
74
121
|
withoutRefs,
|
|
75
122
|
indexRefs
|
|
76
123
|
};
|
|
77
|
-
//# sourceMappingURL=chunk-
|
|
124
|
+
//# sourceMappingURL=chunk-DO4WZKLT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/runner/snapshot.ts"],"sourcesContent":["import type { Page } from 'playwright';\n\nexport interface SnapshotOptions {\n /** Maximum number of snapshot lines sent to the LLM. Default 200. */\n maxLines?: number;\n}\n\nconst DEFAULT_MAX_LINES = 200;\n\nfunction indentOf(line: string): number {\n return line.length - line.trimStart().length;\n}\n\n// A line whose role is a dialog, YAML single-quoted or not.\nconst DIALOG_LINE = /^\\s*- '?(?:dialog|alertdialog)(?=[\\s:\"']|$)/;\nconst OMITTED_LINE = /^\\s*- \\.\\.\\. \\(\\d+ lines? omitted: max_snapshot_lines is (\\d+)\\)$/m;\n\n/**\n * The cap a snapshot was cut at, read from its markers, or `undefined` when\n * nothing was omitted (design keep-the-open-dialog-in-the-snapshot, D3). Read\n * from the text so a step's reason cannot disagree with what the model saw.\n */\nexport function snapshotCutAt(snapshot: string): number | undefined {\n const match = OMITTED_LINE.exec(snapshot);\n return match ? Number(match[1]) : undefined;\n}\n\n/**\n * Which lines of an over-cap snapshot to keep (design\n * keep-the-open-dialog-in-the-snapshot, D1). Frameworks render dialogs, menus\n * and palettes in a portal at the end of `<body>`, so a cut from the top\n * dropped first the element the last action opened (#162). The open dialogs\n * (the last one, on top, first) and the focused element are kept with their\n * subtree and the lines they sit under; the rest of the cap is filled from the\n * top, as before. Never more than `maxLines`.\n */\nfunction linesToKeep(lines: string[], maxLines: number): Set<number> {\n const keep = new Set<number>();\n const subtreeEnd = (i: number): number => {\n let j = i + 1;\n while (j < lines.length && indentOf(lines[j]!) > indentOf(lines[i]!)) j++;\n return j;\n };\n const ancestors = (i: number): number[] => {\n const found: number[] = [];\n let indent = indentOf(lines[i]!);\n for (let j = i - 1; j >= 0 && indent > 0; j--) {\n if (indentOf(lines[j]!) < indent) {\n found.unshift(j);\n indent = indentOf(lines[j]!);\n }\n }\n return found;\n };\n\n const dialogs = lines.flatMap((line, i) => (DIALOG_LINE.test(line) ? [i] : [])).reverse();\n const focused = lines.flatMap((line, i) => (line.includes('[active]') ? [i] : []));\n for (const anchor of [...dialogs.slice(0, 1), ...focused, ...dialogs.slice(1)]) {\n for (const line of ancestors(anchor)) if (keep.size < maxLines) keep.add(line);\n for (let line = anchor; line < subtreeEnd(anchor) && keep.size < maxLines; line++) keep.add(line);\n }\n for (let line = 0; line < lines.length && keep.size < maxLines; line++) keep.add(line);\n return keep;\n}\n\n/**\n * Trims an aria snapshot: drops empty containers (e.g. `- group:` with no children)\n * and caps the line count. Over the cap, each run of omitted lines is replaced in\n * place by a marker naming the setting that cut it (design\n * keep-the-open-dialog-in-the-snapshot, D2). Pure function, exported for tests.\n */\nexport function trimSnapshot(snapshotYaml: string, maxLines: number = DEFAULT_MAX_LINES): string {\n let lines = snapshotYaml.split('\\n').filter((line) => line.trim().length > 0);\n\n // Removing empty containers can empty their parents; iterate until stable (bounded).\n for (let pass = 0; pass < 5; pass++) {\n const kept: string[] = [];\n let removed = 0;\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i]!;\n const isContainer = line.trimEnd().endsWith(':');\n if (isContainer) {\n const next = lines[i + 1];\n const hasChildren = next !== undefined && indentOf(next) > indentOf(line);\n if (!hasChildren) {\n removed++;\n continue;\n }\n }\n kept.push(line);\n }\n lines = kept;\n if (removed === 0) break;\n }\n\n if (lines.length <= maxLines) return lines.join('\\n');\n\n const keep = linesToKeep(lines, maxLines);\n const out: string[] = [];\n let omitted = 0;\n for (let i = 0; i <= lines.length; i++) {\n if (i < lines.length && !keep.has(i)) {\n omitted++;\n continue;\n }\n if (omitted > 0) {\n const indent = ' '.repeat(indentOf(lines[i - omitted]!));\n out.push(`${indent}- ... (${omitted} ${omitted === 1 ? 'line' : 'lines'} omitted: max_snapshot_lines is ${maxLines})`);\n omitted = 0;\n }\n if (i < lines.length) out.push(lines[i]!);\n }\n return out.join('\\n');\n}\n\n/**\n * Captures the current page as a compact accessibility snapshot (design D1),\n * prefixed with the page URL so the model can reason about navigation.\n *\n * Always in AI mode (design act-on-the-element-the-model-read, D3): every\n * element carries the `[ref=…]` an action names it by, and a plain\n * `ariaSnapshot()` invalidates the refs of the last AI-mode one, measured. The\n * `[cursor=pointer]` marker it adds is dropped: it is about the mouse, not the\n * element, and it was most of the growth that was not a ref.\n */\nexport async function captureSnapshot(page: Page, options: SnapshotOptions = {}): Promise<string> {\n const raw = await page.locator('body').ariaSnapshot({ mode: 'ai' });\n return `url: ${page.url()}\\n${trimSnapshot(raw.replace(/ \\[cursor=pointer\\]/g, ''), options.maxLines)}`;\n}\n\nconst REF_MARKER = / \\[ref=[A-Za-z0-9_-]+\\]/g;\n\n/**\n * The snapshot as a reader that chooses no element sees it: the judge and the\n * planner (design act-on-the-element-the-model-read, D3). Refs are ids, not\n * page content, and the judge corpus's stored snapshots have none.\n */\nexport function withoutRefs(snapshot: string): string {\n return snapshot.replace(REF_MARKER, '');\n}\n\n/** What the snapshot line holding a ref shows about its element. */\nexport interface SnapshotElement {\n role: string;\n /** The accessible name, unquoted; absent when the line has none. */\n name?: string;\n /** Inline text after the colon (`- generic [ref=e4]: Promo code`), unquoted. */\n text?: string;\n}\n\n/** Undoes YAML double-quote escaping, the form a name containing `\"` is printed in. */\nfunction unquote(value: string): string {\n const trimmed = value.trim();\n if (trimmed.length >= 2 && trimmed.startsWith('\"') && trimmed.endsWith('\"')) {\n return trimmed.slice(1, -1).replace(/\\\\([\"\\\\])/g, '$1');\n }\n if (trimmed.length >= 2 && trimmed.startsWith(\"'\") && trimmed.endsWith(\"'\")) {\n return trimmed.slice(1, -1).replace(/''/g, \"'\");\n }\n return trimmed;\n}\n\n// `- role \"name\" [attr] [ref=x] [attr]: inline text`, every part after the role optional.\nconst ELEMENT_LINE =\n /^\\s*- ([a-z][a-zA-Z]*)(?: (\"(?:[^\"\\\\]|\\\\.)*\"))?((?: \\[[^\\]]*\\])*)(?::(?: (.*))?)?$/;\n\n/**\n * Each ref in a snapshot, with the role and name its line shows (design\n * act-on-the-element-the-model-read, D2). Read from the snapshot text the model\n * was given, masked as it was, so what is checked and recorded is what the\n * model read and no secret enters the record.\n */\nexport function indexRefs(snapshot: string): Map<string, SnapshotElement> {\n const index = new Map<string, SnapshotElement>();\n for (const raw of snapshot.split('\\n')) {\n // YAML single-quotes a whole entry whose text holds `: `, as in\n // `- 'heading \"Notes on file: 1\" [level=2] [ref=e16]'`.\n const quoted = /^(\\s*- )'((?:[^']|'')*)'(:.*)?$/.exec(raw);\n const line = quoted ? `${quoted[1]}${quoted[2]!.replace(/''/g, \"'\")}${quoted[3] ?? ''}` : raw;\n const match = ELEMENT_LINE.exec(line);\n if (!match) continue;\n const ref = /\\[ref=([A-Za-z0-9_-]+)\\]/.exec(match[3] ?? '')?.[1];\n if (!ref) continue;\n const element: SnapshotElement = { role: match[1]! };\n if (match[2] !== undefined) element.name = unquote(match[2]);\n if (match[4] !== undefined && match[4].trim() !== '') element.text = unquote(match[4]);\n index.set(ref, element);\n }\n return index;\n}\n"],"mappings":";;;AAOA,IAAM,oBAAoB;AAE1B,SAAS,SAAS,MAAsB;AACtC,SAAO,KAAK,SAAS,KAAK,UAAU,EAAE;AACxC;AAGA,IAAM,cAAc;AACpB,IAAM,eAAe;AAOd,SAAS,cAAc,UAAsC;AAClE,QAAM,QAAQ,aAAa,KAAK,QAAQ;AACxC,SAAO,QAAQ,OAAO,MAAM,CAAC,CAAC,IAAI;AACpC;AAWA,SAAS,YAAY,OAAiB,UAA+B;AACnE,QAAM,OAAO,oBAAI,IAAY;AAC7B,QAAM,aAAa,CAAC,MAAsB;AACxC,QAAI,IAAI,IAAI;AACZ,WAAO,IAAI,MAAM,UAAU,SAAS,MAAM,CAAC,CAAE,IAAI,SAAS,MAAM,CAAC,CAAE,EAAG;AACtE,WAAO;AAAA,EACT;AACA,QAAM,YAAY,CAAC,MAAwB;AACzC,UAAM,QAAkB,CAAC;AACzB,Q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k-
|
|
6
|
+
} from "./chunk-DO4WZKLT.js";
|
|
6
7
|
|
|
7
8
|
// src/cli.ts
|
|
8
9
|
import { Command, InvalidArgumentError } from "commander";
|
|
@@ -328,6 +329,16 @@ var RunBudget = class {
|
|
|
328
329
|
if (this.maxDurationMs === void 0) return void 0;
|
|
329
330
|
return Math.max(0, this.maxDurationMs - (this.now() - this.startedAt));
|
|
330
331
|
}
|
|
332
|
+
/**
|
|
333
|
+
* The deadline's stop, for a call its timer aborted (design
|
|
334
|
+
* bound-every-model-call, D3). Not `check()`: a timer can fire a millisecond
|
|
335
|
+
* before the clock `check()` reads has reached the deadline, and that call
|
|
336
|
+
* then left as a timeout, failing a test in the 0.25.0 release workflow.
|
|
337
|
+
*/
|
|
338
|
+
deadlineReached() {
|
|
339
|
+
const configured = this.maxDurationMs ?? 0;
|
|
340
|
+
return new BudgetExhaustedError("duration", Math.max(this.now() - this.startedAt, configured), configured);
|
|
341
|
+
}
|
|
331
342
|
/** Records what a completed model call spent. */
|
|
332
343
|
record(usage) {
|
|
333
344
|
this.calls += 1;
|
|
@@ -679,10 +690,16 @@ function namesAValue(step) {
|
|
|
679
690
|
function namesNoValue(step) {
|
|
680
691
|
return LEADING_VALUE_VERB.test(step) && !namesAValue(step);
|
|
681
692
|
}
|
|
682
|
-
var
|
|
693
|
+
var CHECK_VERB = String.raw`(?:verify|check|confirm|ensure|assert|expect|validate|make\s+sure|see\s+that)\b`;
|
|
694
|
+
var LEADING_CHECK_VERB = new RegExp(String.raw`^\s*(?:(?:then|and)\s+)?` + CHECK_VERB, "i");
|
|
695
|
+
var CHECK_CLAUSE = new RegExp(String.raw`(?:\band\b|\bthen\b|[,;])\s+` + CHECK_VERB, "i");
|
|
683
696
|
function isVerificationStep(step) {
|
|
684
697
|
return LEADING_CHECK_VERB.test(step);
|
|
685
698
|
}
|
|
699
|
+
function hasVerificationClause(step) {
|
|
700
|
+
const unquoted = step.replace(/"[^"]*"|“[^”]*”/g, '""');
|
|
701
|
+
return !isVerificationStep(step) && CHECK_CLAUSE.test(unquoted);
|
|
702
|
+
}
|
|
686
703
|
function entersNamedValue(step) {
|
|
687
704
|
return LEADING_VALUE_VERB.test(step) && namesAValue(step);
|
|
688
705
|
}
|
|
@@ -732,6 +749,14 @@ function identity(action) {
|
|
|
732
749
|
var StepRecovery = class {
|
|
733
750
|
performed = /* @__PURE__ */ new Set();
|
|
734
751
|
history = [];
|
|
752
|
+
/** The last page the model was shown, as given to `observe` (masked, without refs). */
|
|
753
|
+
lastObserved;
|
|
754
|
+
/**
|
|
755
|
+
* The last action that succeeded, with the page it was decided on (design
|
|
756
|
+
* repeat-a-click-that-moves-the-page, D1/D2). A commit that follows itself
|
|
757
|
+
* on a page that moved is a tour's "Next", not a duplicate.
|
|
758
|
+
*/
|
|
759
|
+
lastSuccess;
|
|
735
760
|
/**
|
|
736
761
|
* Everything the model has been allowed to read this step, normalised: the
|
|
737
762
|
* step's own text, plus every snapshot it has been shown, plus every value it
|
|
@@ -760,10 +785,17 @@ var StepRecovery = class {
|
|
|
760
785
|
* D1). Read by the executor too, which refuses `done` in such a step.
|
|
761
786
|
*/
|
|
762
787
|
verifies;
|
|
788
|
+
/**
|
|
789
|
+
* Whether the step acts first and asks for a check after (design
|
|
790
|
+
* judge-a-done-that-closes-a-check, D2). The executor judges a `done` in such
|
|
791
|
+
* a step instead of closing it.
|
|
792
|
+
*/
|
|
793
|
+
checksAfterActing;
|
|
763
794
|
constructor(step) {
|
|
764
795
|
this.step = step;
|
|
765
796
|
this.readable = [normalise(step)];
|
|
766
797
|
this.verifies = isVerificationStep(step);
|
|
798
|
+
this.checksAfterActing = hasVerificationClause(step);
|
|
767
799
|
}
|
|
768
800
|
/**
|
|
769
801
|
* Records a snapshot the model was shown, as a source it may quote from.
|
|
@@ -776,6 +808,7 @@ var StepRecovery = class {
|
|
|
776
808
|
*/
|
|
777
809
|
observe(maskedSnapshot) {
|
|
778
810
|
this.readable.push(normalise(maskedSnapshot));
|
|
811
|
+
this.lastObserved = maskedSnapshot;
|
|
779
812
|
}
|
|
780
813
|
/**
|
|
781
814
|
* Whether anything succeeded during this step (design close-a-step D1).
|
|
@@ -797,6 +830,7 @@ var StepRecovery = class {
|
|
|
797
830
|
/** Records an action that was actually performed and succeeded. */
|
|
798
831
|
record(action, description, result) {
|
|
799
832
|
this.performed.add(identity(action));
|
|
833
|
+
this.lastSuccess = { identity: identity(action), page: this.lastObserved };
|
|
800
834
|
this.history.push({ action: description, result });
|
|
801
835
|
if (action.value) this.readable.push(normalise(action.value));
|
|
802
836
|
}
|
|
@@ -854,9 +888,25 @@ var StepRecovery = class {
|
|
|
854
888
|
repeatedCommitRefusal(action) {
|
|
855
889
|
if (!isCommit(action)) return void 0;
|
|
856
890
|
if (!this.performed.has(identity(action))) return void 0;
|
|
891
|
+
if (this.followsItselfOnAMovedPage(action)) return void 0;
|
|
857
892
|
const target = action.target ? ` on ${action.target.role ?? ""} "${action.target.name ?? ""}"` : "";
|
|
858
893
|
return `refused: this ${action.action}${target} already succeeded earlier in this step, so it was NOT performed again. It is the same control even under a new ref: refs are renumbered when the page changes. Repeating something that commits repeats whatever it changed in the application. If the page no longer shows that it worked, that is normal for a submit answered by a redirect \u2014 check the record of what you have already done. Verify the step's outcome another way, or fail the step.`;
|
|
859
894
|
}
|
|
895
|
+
/**
|
|
896
|
+
* The one repeat performed (design repeat-a-click-that-moves-the-page): the
|
|
897
|
+
* same commit as the last action that succeeded, with nothing in between, on
|
|
898
|
+
* a page that differs from the one that success was decided on. A tour's
|
|
899
|
+
* "Next" or a "load more" needs it (#164). Both measured duplicates did
|
|
900
|
+
* something else in between to restore the form, a `fill` (#124) or a click
|
|
901
|
+
* on "New Issue" (#28), and a press that moved nothing is still refused.
|
|
902
|
+
* Compared exactly on the ref-less text `observe` receives, so a re-render
|
|
903
|
+
* alone is no change.
|
|
904
|
+
*/
|
|
905
|
+
followsItselfOnAMovedPage(action) {
|
|
906
|
+
const last = this.lastSuccess;
|
|
907
|
+
if (last === void 0 || last.identity !== identity(action)) return false;
|
|
908
|
+
return last.page !== void 0 && this.lastObserved !== void 0 && last.page !== this.lastObserved;
|
|
909
|
+
}
|
|
860
910
|
/**
|
|
861
911
|
* Refuses a typed value that came from nowhere the model was entitled to read
|
|
862
912
|
* (design refuse-an-invented-value).
|
|
@@ -899,6 +949,8 @@ var StepRecovery = class {
|
|
|
899
949
|
// src/runner/executor.ts
|
|
900
950
|
var DEFAULT_MAX_ITERATIONS_PER_STEP = 15;
|
|
901
951
|
var SETTLE_TIMEOUT_MS = 2e3;
|
|
952
|
+
var RENDER_WATCH_MS = 3e3;
|
|
953
|
+
var RENDER_POLL_MS = 250;
|
|
902
954
|
async function waitForSettled(page) {
|
|
903
955
|
const deadline = Date.now() + SETTLE_TIMEOUT_MS;
|
|
904
956
|
const urlBefore = page.url();
|
|
@@ -912,7 +964,7 @@ async function waitForSettled(page) {
|
|
|
912
964
|
}
|
|
913
965
|
}
|
|
914
966
|
async function defaultSnapshot(page, maxLines) {
|
|
915
|
-
const { captureSnapshot } = await import("./snapshot-
|
|
967
|
+
const { captureSnapshot } = await import("./snapshot-JISKGGMN.js");
|
|
916
968
|
return captureSnapshot(page, { maxLines });
|
|
917
969
|
}
|
|
918
970
|
function slugify(text) {
|
|
@@ -920,9 +972,20 @@ function slugify(text) {
|
|
|
920
972
|
return slug || "test";
|
|
921
973
|
}
|
|
922
974
|
var NOTHING_DONE_REFUSAL = "refused: nothing succeeded during this step, so it was NOT closed. A step closes on what was done in it, not on being declared finished. If the outcome already holds \u2014 there was nothing left to do \u2014 assert that it holds and let the judgment close the step; an assertion is evidence, a declaration is not. If the step cannot be carried out at all, fail it and say why.";
|
|
975
|
+
var FAIL_ON_A_CHANGING_PAGE = "not accepted yet: the page changed after the snapshot you answered fail on, so it may still have been loading. Decide again on the page as it is now.";
|
|
923
976
|
var VERIFICATION_DONE_REFUSAL = "refused: this step only verifies, so it closes on a passing assertion, not on being declared finished. Assert what the page shows; if it does not show what the step names, fail the step and say why.";
|
|
924
977
|
var StepFailure = class extends Error {
|
|
925
978
|
};
|
|
979
|
+
async function pageChangedWithin(page, takeSnapshot, view, seen, withinMs) {
|
|
980
|
+
const deadline = Date.now() + withinMs;
|
|
981
|
+
while (Date.now() < deadline) {
|
|
982
|
+
await new Promise((resolve2) => setTimeout(resolve2, Math.min(RENDER_POLL_MS, Math.max(0, deadline - Date.now()))));
|
|
983
|
+
const raw = await takeSnapshot(page);
|
|
984
|
+
const current = view(raw);
|
|
985
|
+
if (current !== seen) return { raw, page: current };
|
|
986
|
+
}
|
|
987
|
+
return void 0;
|
|
988
|
+
}
|
|
926
989
|
async function executeTest(page, test, options) {
|
|
927
990
|
const {
|
|
928
991
|
brain,
|
|
@@ -936,6 +999,7 @@ async function executeTest(page, test, options) {
|
|
|
936
999
|
mask = (s) => s,
|
|
937
1000
|
snapshot,
|
|
938
1001
|
maxSnapshotLines,
|
|
1002
|
+
renderWatchMs = RENDER_WATCH_MS,
|
|
939
1003
|
onEvent = () => {
|
|
940
1004
|
}
|
|
941
1005
|
} = options;
|
|
@@ -967,6 +1031,8 @@ async function executeTest(page, test, options) {
|
|
|
967
1031
|
let failedAttempts = 0;
|
|
968
1032
|
let lastResult;
|
|
969
1033
|
let stepFailedReason;
|
|
1034
|
+
let lastSnapshot;
|
|
1035
|
+
let lookedAgain = false;
|
|
970
1036
|
const recovery = new StepRecovery(step);
|
|
971
1037
|
try {
|
|
972
1038
|
while (true) {
|
|
@@ -980,6 +1046,7 @@ async function executeTest(page, test, options) {
|
|
|
980
1046
|
);
|
|
981
1047
|
}
|
|
982
1048
|
const snap = await takeSnapshot(page);
|
|
1049
|
+
lastSnapshot = snap;
|
|
983
1050
|
const maskedSnap = mask(snap);
|
|
984
1051
|
const refs = indexRefs(maskedSnap);
|
|
985
1052
|
const pageSnap = withoutRefs(maskedSnap);
|
|
@@ -1007,6 +1074,8 @@ async function executeTest(page, test, options) {
|
|
|
1007
1074
|
continue;
|
|
1008
1075
|
}
|
|
1009
1076
|
iterations++;
|
|
1077
|
+
let judgingDone = false;
|
|
1078
|
+
const shown = () => judgingDone ? { ...action, action: "done" } : action;
|
|
1010
1079
|
if (action.action === "done") {
|
|
1011
1080
|
if (!recovery.acted || recovery.verifies) {
|
|
1012
1081
|
failedAttempts++;
|
|
@@ -1017,10 +1086,25 @@ async function executeTest(page, test, options) {
|
|
|
1017
1086
|
}
|
|
1018
1087
|
continue;
|
|
1019
1088
|
}
|
|
1020
|
-
|
|
1021
|
-
|
|
1089
|
+
if (!recovery.checksAfterActing) {
|
|
1090
|
+
emitAction(index, action, action.reasoning);
|
|
1091
|
+
break;
|
|
1092
|
+
}
|
|
1093
|
+
judgingDone = true;
|
|
1094
|
+
action = { ...action, action: "assert", expectation: action.reasoning };
|
|
1022
1095
|
}
|
|
1023
1096
|
if (action.action === "fail") {
|
|
1097
|
+
if (!recovery.acted && !lookedAgain) {
|
|
1098
|
+
lookedAgain = true;
|
|
1099
|
+
const moved = await pageChangedWithin(page, takeSnapshot, (snap2) => withoutRefs(mask(snap2)), pageSnap, renderWatchMs);
|
|
1100
|
+
if (moved !== void 0) {
|
|
1101
|
+
lastSnapshot = moved.raw;
|
|
1102
|
+
recovery.observe(moved.page);
|
|
1103
|
+
lastResult = FAIL_ON_A_CHANGING_PAGE;
|
|
1104
|
+
emitAction(index, action, `${action.reasoning} :: ${FAIL_ON_A_CHANGING_PAGE}`);
|
|
1105
|
+
continue;
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1024
1108
|
emitAction(index, action, action.reasoning);
|
|
1025
1109
|
throw new StepFailure(action.reasoning);
|
|
1026
1110
|
}
|
|
@@ -1038,6 +1122,7 @@ async function executeTest(page, test, options) {
|
|
|
1038
1122
|
if (!judgment.pass) {
|
|
1039
1123
|
await waitForSettled(page);
|
|
1040
1124
|
const freshSnap = await takeSnapshot(page);
|
|
1125
|
+
lastSnapshot = freshSnap;
|
|
1041
1126
|
const maskedFresh = withoutRefs(mask(freshSnap));
|
|
1042
1127
|
recovery.observe(maskedFresh);
|
|
1043
1128
|
judgment = await brain.judge(
|
|
@@ -1052,14 +1137,14 @@ async function executeTest(page, test, options) {
|
|
|
1052
1137
|
if (error instanceof RunStoppedError) throw error;
|
|
1053
1138
|
failedAttempts++;
|
|
1054
1139
|
lastResult = `error: ${error instanceof Error ? error.message : String(error)}`;
|
|
1055
|
-
emitAction(index,
|
|
1140
|
+
emitAction(index, shown(), lastResult);
|
|
1056
1141
|
if (failedAttempts >= maxRetries) {
|
|
1057
1142
|
throw new StepFailure(lastResult);
|
|
1058
1143
|
}
|
|
1059
1144
|
continue;
|
|
1060
1145
|
}
|
|
1061
1146
|
const result = judgment.pass ? `ok: assertion passed: ${judgment.reason}` : `assertion failed: ${judgment.reason}`;
|
|
1062
|
-
emitAction(index,
|
|
1147
|
+
emitAction(index, shown(), result);
|
|
1063
1148
|
if (judgment.pass) {
|
|
1064
1149
|
lastResult = result;
|
|
1065
1150
|
break;
|
|
@@ -1114,6 +1199,10 @@ async function executeTest(page, test, options) {
|
|
|
1114
1199
|
} catch (error) {
|
|
1115
1200
|
if (error instanceof RunStoppedError) throw error;
|
|
1116
1201
|
stepFailedReason = mask(error instanceof Error ? error.message : String(error));
|
|
1202
|
+
const cutAt = lastSnapshot === void 0 ? void 0 : snapshotCutAt(lastSnapshot);
|
|
1203
|
+
if (cutAt !== void 0) {
|
|
1204
|
+
stepFailedReason += ` (The page's snapshot was cut at max_snapshot_lines (${cutAt}); what the step looks for may be in the part left out.)`;
|
|
1205
|
+
}
|
|
1117
1206
|
}
|
|
1118
1207
|
for (const entry of recovery.stepHistory()) {
|
|
1119
1208
|
for (const name of referencedEnvVars(entry.action)) usedEarlier.add(name);
|
|
@@ -1881,11 +1970,13 @@ function asProviderRefusal(error) {
|
|
|
1881
1970
|
return new ProviderRefusedError(cause.statusCode, cause.message);
|
|
1882
1971
|
}
|
|
1883
1972
|
function callAbort(budget) {
|
|
1884
|
-
const
|
|
1885
|
-
|
|
1973
|
+
const timeout = budget.callTimeoutMs;
|
|
1974
|
+
const remaining = budget.remainingMs();
|
|
1975
|
+
if (timeout === void 0 && remaining === void 0) return void 0;
|
|
1976
|
+
const byDeadline = remaining !== void 0 && (timeout === void 0 || remaining <= timeout);
|
|
1886
1977
|
const controller = new AbortController();
|
|
1887
|
-
const timer = setTimeout(() => controller.abort(),
|
|
1888
|
-
return { signal: controller.signal, clear: () => clearTimeout(timer) };
|
|
1978
|
+
const timer = setTimeout(() => controller.abort(), byDeadline ? remaining : timeout);
|
|
1979
|
+
return { signal: controller.signal, byDeadline, clear: () => clearTimeout(timer) };
|
|
1889
1980
|
}
|
|
1890
1981
|
function spentAndExplained(error, budget) {
|
|
1891
1982
|
if (!NoObjectGeneratedError.isInstance(error)) return error;
|
|
@@ -1903,7 +1994,7 @@ async function countedGenerate(generate, budget, options) {
|
|
|
1903
1994
|
result = await generate({ ...options, maxOutputTokens: MAX_OUTPUT_TOKENS, abortSignal: abort?.signal });
|
|
1904
1995
|
} catch (error) {
|
|
1905
1996
|
if (abort?.signal.aborted) {
|
|
1906
|
-
budget.
|
|
1997
|
+
if (abort.byDeadline) throw budget.deadlineReached();
|
|
1907
1998
|
if (budget.callTimeoutMs !== void 0) throw new ModelCallTimeoutError(budget.callTimeoutMs);
|
|
1908
1999
|
}
|
|
1909
2000
|
throw asProviderRefusal(withProviderDetail(spentAndExplained(error, budget)));
|
|
@@ -2364,6 +2455,10 @@ function computeScore(results) {
|
|
|
2364
2455
|
if (total === 0) return 100;
|
|
2365
2456
|
return Math.round(100 * passed / total);
|
|
2366
2457
|
}
|
|
2458
|
+
function scoreOf(results, incomplete) {
|
|
2459
|
+
if (incomplete && results.every((result) => result.status === "not-run")) return void 0;
|
|
2460
|
+
return computeScore(results);
|
|
2461
|
+
}
|
|
2367
2462
|
function formatScoreLine(score, results, threshold) {
|
|
2368
2463
|
if (results.length === 0) {
|
|
2369
2464
|
const base = "Score: 100 (no tests executed)";
|
|
@@ -2374,7 +2469,7 @@ function formatScoreLine(score, results, threshold) {
|
|
|
2374
2469
|
}
|
|
2375
2470
|
function formatIncompleteLine(score, reason) {
|
|
2376
2471
|
return `Run incomplete: ${reason}
|
|
2377
|
-
Score over executed tests: ${score} (not a verdict \u2014 exit code 1 regardless of --min-score)
|
|
2472
|
+
` + (score === void 0 ? "Score: none (no test executed before the stop)" : `Score over executed tests: ${score} (not a verdict \u2014 exit code 1 regardless of --min-score)`);
|
|
2378
2473
|
}
|
|
2379
2474
|
function formatSpendLine(spend) {
|
|
2380
2475
|
const calls = spend.maxCalls === void 0 ? `${spend.calls} model call(s)` : `${spend.calls} of ${spend.maxCalls} model call(s)`;
|
|
@@ -2510,7 +2605,7 @@ async function renderHtml(results, skipped, meta) {
|
|
|
2510
2605
|
const generatedAt = (meta.generatedAt ?? /* @__PURE__ */ new Date()).toISOString();
|
|
2511
2606
|
const ordered = [...failures, ...notRun, ...results.filter((r) => r.status === "passed")];
|
|
2512
2607
|
const detail = (await Promise.all(ordered.map((r) => renderTest(r, meta.screenshots, meta.cwd)))).join("\n");
|
|
2513
|
-
const verdict = meta.minScore === void 0 ? "" : meta.score >= meta.minScore ? `<span class="verdict pass">min-score ${meta.minScore}: pass</span>` : `<span class="verdict fail">min-score ${meta.minScore}: FAIL</span>`;
|
|
2608
|
+
const verdict = meta.minScore === void 0 || meta.score === void 0 ? "" : meta.score >= meta.minScore ? `<span class="verdict pass">min-score ${meta.minScore}: pass</span>` : `<span class="verdict fail">min-score ${meta.minScore}: FAIL</span>`;
|
|
2514
2609
|
const banner = meta.incomplete === void 0 ? "" : ` <section class="incomplete">Run stopped: ${escapeHtml(meta.incomplete)}</section>
|
|
2515
2610
|
|
|
2516
2611
|
`;
|
|
@@ -2539,7 +2634,7 @@ async function renderHtml(results, skipped, meta) {
|
|
|
2539
2634
|
<p class="sub">${escapeHtml(generatedAt)} \xB7 ${seconds(meta.durationMs)}${meta.spend ? ` \xB7 ${escapeHtml(formatSpendLine(meta.spend))}` : ""}</p>
|
|
2540
2635
|
|
|
2541
2636
|
${banner} <section class="score">
|
|
2542
|
-
<b>${meta.score}</b>
|
|
2637
|
+
<b>${meta.score ?? "\u2014"}</b>${meta.score === void 0 ? '\n <span class="counts">no score: no test executed</span>' : ""}
|
|
2543
2638
|
${verdict}
|
|
2544
2639
|
<span class="counts">${passed} passed \xB7 ${failures.length} failed${notRun.length > 0 ? ` \xB7 ${notRun.length} not run` : ""}${skipped.length > 0 ? ` \xB7 ${skipped.length} skipped` : ""}</span>
|
|
2545
2640
|
</section>
|
|
@@ -2595,7 +2690,10 @@ function renderJUnit(results, skipped, meta) {
|
|
|
2595
2690
|
'<?xml version="1.0" encoding="UTF-8"?>',
|
|
2596
2691
|
`<testsuite name="blastproof" tests="${results.length + skipped.length}" failures="${failures}" skipped="${skipped.length + notRun.length}" time="${seconds2(meta.durationMs)}">`,
|
|
2597
2692
|
" <properties>",
|
|
2598
|
-
|
|
2693
|
+
// Absent rather than a placeholder (design no-score-when-nothing-ran, D2):
|
|
2694
|
+
// the action reads this property as its `score` output, and an empty output
|
|
2695
|
+
// is how it already says "no score". A sentinel would be a number to compare.
|
|
2696
|
+
...meta.score === void 0 ? [] : [` <property name="score" value="${meta.score}"/>`],
|
|
2599
2697
|
...meta.spend ? [` <property name="llm_calls" value="${meta.spend.calls}"/>`] : [],
|
|
2600
2698
|
// Omitted rather than emitted as zero when no call reported usage: a
|
|
2601
2699
|
// property carrying 0 would be read by a pipeline as "this run spent no
|
|
@@ -2905,9 +3003,9 @@ async function finalize(results, skipped, options, sessionDir, secretsHeld, near
|
|
|
2905
3003
|
if (results.length > 0) printSummary(results);
|
|
2906
3004
|
reportNearMissedSecrets(nearMissedSecrets);
|
|
2907
3005
|
if (spend) console.log(formatSpendLine(spend));
|
|
2908
|
-
const score =
|
|
3006
|
+
const score = scoreOf(results, incomplete !== void 0);
|
|
2909
3007
|
console.log(
|
|
2910
|
-
incomplete ? formatIncompleteLine(score, incomplete.message) : formatScoreLine(
|
|
3008
|
+
incomplete ? formatIncompleteLine(score, incomplete.message) : formatScoreLine(computeScore(results), results, options.minScore)
|
|
2911
3009
|
);
|
|
2912
3010
|
if (options.junit) {
|
|
2913
3011
|
const target = typeof options.junit === "string" ? path9.resolve(options.cwd, options.junit) : path9.join(sessionDir, "junit.xml");
|
|
@@ -2943,7 +3041,7 @@ async function finalize(results, skipped, options, sessionDir, secretsHeld, near
|
|
|
2943
3041
|
if (incomplete) return EXIT_FAILED;
|
|
2944
3042
|
if (reportUnclassified(options, impact)) return EXIT_FAILED;
|
|
2945
3043
|
if (options.minScore !== void 0) {
|
|
2946
|
-
return
|
|
3044
|
+
return computeScore(results) >= options.minScore ? EXIT_OK : EXIT_FAILED;
|
|
2947
3045
|
}
|
|
2948
3046
|
return results.some((result) => result.status === "failed") ? EXIT_FAILED : EXIT_OK;
|
|
2949
3047
|
}
|
|
@@ -3539,7 +3637,7 @@ function parsePositiveNumber(flag) {
|
|
|
3539
3637
|
};
|
|
3540
3638
|
}
|
|
3541
3639
|
var program = new Command();
|
|
3542
|
-
program.name("blastproof").description("Open-source AI testing agent: plain-English YAML tests executed agentically on a real browser.").version("0.
|
|
3640
|
+
program.name("blastproof").description("Open-source AI testing agent: plain-English YAML tests executed agentically on a real browser.").version("0.27.0");
|
|
3543
3641
|
program.command("init").description("Scaffold .blastproof/ (config, tests, sample tests) in the current directory").action(async () => {
|
|
3544
3642
|
try {
|
|
3545
3643
|
const result = await initProject(process.cwd());
|