blastproof 0.23.0 → 0.24.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 CHANGED
@@ -299,9 +299,30 @@ export ANTHROPIC_API_KEY=...
299
299
  node dist/cli.js run
300
300
  ```
301
301
 
302
+ ### How often a verdict is wrong
303
+
304
+ A merge gate is judged by two numbers. A **false PASS** is a test that passes on an app with the bug it exists to catch. A **false FAIL** is a test that fails on a correct app. `npm run eval:reliability` measures both. It runs the suite above on the demo app as it is, and each test on **mutants**: copies of the app with one bug seeded. A *literal* mutant changes the value a step quotes. A *subtle* one reproduces the shape of a wrong verdict this project has already had, such as the right value in the wrong place, or a success message with no success behind it.
305
+
306
+ | | `claude-haiku-4.5` | `gpt-6-luna` |
307
+ | --- | --- | --- |
308
+ | false FAIL, correct app (40 test runs) | 0 (≤ 8.8%) | 0 (≤ 8.8%) |
309
+ | false PASS, literal bugs (30) | 0 (≤ 11.4%) | 0 (≤ 11.4%) |
310
+ | false PASS, subtle bugs (20) | 0 (≤ 16.1%) | 0 (≤ 16.1%) |
311
+
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 this is the run after the fix.
313
+
314
+ 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
+
316
+ Measured 2026-10-07 on `main` after 0.23.0 with #147's fix, 5 samples, through OpenRouter. To reproduce:
317
+
318
+ ```bash
319
+ npm run build
320
+ EVAL_MODELS=anthropic/claude-haiku-4.5,openai/gpt-6-luna npm run eval:reliability
321
+ ```
322
+
302
323
  ## Development
303
324
 
304
- Built with AI assistance using spec-driven development: every change began as a written proposal with its design rationale, and those documents are kept rather than discarded. `openspec/` holds the reasoning behind each decision, including the alternatives that were rejected and why — start at [`AGENTS.md`](./AGENTS.md) for architecture, conventions and the contribution workflow. Open work lives in [issues](https://github.com/hamc/blastproof/issues).
325
+ Built with AI assistance using spec-driven development: every change began as a written proposal with its design rationale, and those documents are kept rather than discarded. `openspec/` holds the reasoning behind each decision, including the alternatives that were rejected and why — start at [`AGENTS.md`](./AGENTS.md) for architecture, conventions and the contribution workflow. Open work lives in [issues](https://github.com/hamc/blastproof/issues). Where it is heading is on the [roadmap](https://github.com/users/hamc/projects/2): those issues grouped by horizon (now, next, later) and theme, with no dates.
305
326
 
306
327
  ```bash
307
328
  npm install && npm run build && npm test
package/dist/cli.js CHANGED
@@ -609,9 +609,52 @@ async function performResolvedAction(page, action, ctx) {
609
609
  }
610
610
  }
611
611
 
612
+ // src/runner/authoring.ts
613
+ var VALUE_VERBS = ["fill", "enter", "type", "input", "set"];
614
+ var LEADING_VALUE_VERB = new RegExp(`^\\s*(?:${VALUE_VERBS.join("|")})\\b`, "i");
615
+ var CONNECTOR_WORDS = ["with", "to", "as", "using", "into", "from", "in"];
616
+ var CONNECTOR_WORD = new RegExp(`\\b(?:${CONNECTOR_WORDS.join("|")})\\b`, "i");
617
+ var CONNECTOR_SYMBOL = /["'`:=]|\{\{env\./i;
618
+ var PHRASAL_IN = new RegExp(`^(\\s*(?:${VALUE_VERBS.join("|")}))\\s+in\\b`, "i");
619
+ function namesAValue(step) {
620
+ const withoutPhrasal = step.replace(PHRASAL_IN, "$1");
621
+ return CONNECTOR_WORD.test(withoutPhrasal) || CONNECTOR_SYMBOL.test(withoutPhrasal);
622
+ }
623
+ function namesNoValue(step) {
624
+ return LEADING_VALUE_VERB.test(step) && !namesAValue(step);
625
+ }
626
+ var LEADING_CHECK_VERB = /^\s*(?:(?:then|and)\s+)?(?:verify|check|confirm|ensure|assert|expect|validate|make\s+sure|see\s+that)\b/i;
627
+ function isVerificationStep(step) {
628
+ return LEADING_CHECK_VERB.test(step);
629
+ }
630
+ function entersNamedValue(step) {
631
+ return LEADING_VALUE_VERB.test(step) && namesAValue(step);
632
+ }
633
+ function detectMissingValues(tests) {
634
+ const findings = [];
635
+ for (const test of tests) {
636
+ for (const origin of ["setup", "steps"]) {
637
+ const steps = origin === "setup" ? test.setup ?? [] : test.steps;
638
+ steps.forEach((step, position) => {
639
+ if (namesNoValue(step)) {
640
+ findings.push({ test, origin, index: position + 1, step });
641
+ }
642
+ });
643
+ }
644
+ }
645
+ return { findings };
646
+ }
647
+ function suggestValueClause(step) {
648
+ return `${step.trimEnd()} with <value>`;
649
+ }
650
+
612
651
  // src/runner/recovery.ts
613
652
  var COMMIT_ACTIONS = /* @__PURE__ */ new Set(["click", "press"]);
614
653
  var COMMIT_KEYS = /* @__PURE__ */ new Set(["Enter", "NumpadEnter", " ", "Space", "Spacebar"]);
654
+ function isCommit(action) {
655
+ if (!COMMIT_ACTIONS.has(action.action)) return false;
656
+ return action.action !== "press" || COMMIT_KEYS.has(action.value ?? "");
657
+ }
615
658
  var SOURCED_VALUE_ACTIONS = /* @__PURE__ */ new Set(["fill", "select"]);
616
659
  function referencesOnlyNamedVars(value, step) {
617
660
  const named = new Set(referencedEnvVars(step));
@@ -662,9 +705,15 @@ var StepRecovery = class {
662
705
  * stay distinguishable in the one place that decides which secret gets typed.
663
706
  */
664
707
  step;
708
+ /**
709
+ * Whether the step asks only for a check (design a-verification-step-only-looks,
710
+ * D1). Read by the executor too, which refuses `done` in such a step.
711
+ */
712
+ verifies;
665
713
  constructor(step) {
666
714
  this.step = step;
667
715
  this.readable = [normalise(step)];
716
+ this.verifies = isVerificationStep(step);
668
717
  }
669
718
  /**
670
719
  * Records a snapshot the model was shown, as a source it may quote from.
@@ -718,7 +767,7 @@ var StepRecovery = class {
718
767
  * and #28 has now produced one on three applications.
719
768
  */
720
769
  refusalFor(action) {
721
- return this.repeatedCommitRefusal(action) ?? this.redactionLabelRefusal(action) ?? this.unsourcedValueRefusal(action);
770
+ return this.verificationRefusal(action) ?? this.repeatedCommitRefusal(action) ?? this.redactionLabelRefusal(action) ?? this.unsourcedValueRefusal(action);
722
771
  }
723
772
  /**
724
773
  * Refuses a typed value containing a redaction label (design
@@ -739,9 +788,21 @@ var StepRecovery = class {
739
788
  if (!action.value?.includes(REDACTION_PREFIX)) return void 0;
740
789
  return `refused: the value was NOT typed, because it contains a redaction label. ${REDACTION_PREFIX} NAME] stands for the value of {{env.NAME}}, withheld from you; it is never a value the application should receive. To enter an environment value, use the {{env.*}} placeholder this step names. If the step names none, use a value it supplies, or fail the step.`;
741
790
  }
791
+ /**
792
+ * Refuses a commit in a step that only checks (design
793
+ * a-verification-step-only-looks, D2). Without it the agent could make a check
794
+ * true by producing what it checks: a click on "Add to cart" put the message a
795
+ * verification looked for on the page, and the step passed (#139). Navigation
796
+ * stays allowed, since a check may need another page; a link click does not,
797
+ * since a link and a logout item look alike from here and `navigate` covers it.
798
+ * First among the refusals, because it holds whatever was done before.
799
+ */
800
+ verificationRefusal(action) {
801
+ if (!this.verifies || !isCommit(action)) return void 0;
802
+ return "refused: this step only verifies \u2014 it does not ask you to change anything, so clicking or pressing here could make the check pass by producing what it checks. Assert what the page shows. If what the step names is on another page, navigate there. If it is not shown, fail the step.";
803
+ }
742
804
  repeatedCommitRefusal(action) {
743
- if (!COMMIT_ACTIONS.has(action.action)) return void 0;
744
- if (action.action === "press" && !COMMIT_KEYS.has(action.value ?? "")) return void 0;
805
+ if (!isCommit(action)) return void 0;
745
806
  if (!this.performed.has(identity(action))) return void 0;
746
807
  return `refused: this exact action already succeeded earlier in this step, so it was NOT performed again. 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.`;
747
808
  }
@@ -808,6 +869,7 @@ function slugify(text) {
808
869
  return slug || "test";
809
870
  }
810
871
  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.";
872
+ 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.";
811
873
  var StepFailure = class extends Error {
812
874
  };
813
875
  async function executeTest(page, test, options) {
@@ -845,6 +907,7 @@ async function executeTest(page, test, options) {
845
907
  let failure;
846
908
  const boundary = allowedOriginsFor(baseUrl, allowedOrigins);
847
909
  await page.goto(new URL(baseUrl).toString());
910
+ const usedEarlier = /* @__PURE__ */ new Set();
848
911
  for (let index = 0; index < allSteps.length; index++) {
849
912
  const { step, setup } = allSteps[index];
850
913
  const stepStartedAt = Date.now();
@@ -892,9 +955,9 @@ async function executeTest(page, test, options) {
892
955
  }
893
956
  iterations++;
894
957
  if (action.action === "done") {
895
- if (!recovery.acted) {
958
+ if (!recovery.acted || recovery.verifies) {
896
959
  failedAttempts++;
897
- lastResult = NOTHING_DONE_REFUSAL;
960
+ lastResult = recovery.verifies ? VERIFICATION_DONE_REFUSAL : NOTHING_DONE_REFUSAL;
898
961
  emitAction(index, action, lastResult);
899
962
  if (failedAttempts >= maxRetries) {
900
963
  throw new StepFailure(lastResult);
@@ -916,7 +979,8 @@ async function executeTest(page, test, options) {
916
979
  mask(step),
917
980
  mask(expectation),
918
981
  maskedSnap,
919
- recovery.stepHistory()
982
+ recovery.stepHistory(),
983
+ [...usedEarlier]
920
984
  );
921
985
  if (!judgment.pass) {
922
986
  await waitForSettled(page);
@@ -927,7 +991,8 @@ async function executeTest(page, test, options) {
927
991
  mask(step),
928
992
  mask(expectation),
929
993
  maskedFresh,
930
- recovery.stepHistory()
994
+ recovery.stepHistory(),
995
+ [...usedEarlier]
931
996
  );
932
997
  }
933
998
  } catch (error) {
@@ -986,6 +1051,9 @@ async function executeTest(page, test, options) {
986
1051
  if (error instanceof RunStoppedError) throw error;
987
1052
  stepFailedReason = mask(error instanceof Error ? error.message : String(error));
988
1053
  }
1054
+ for (const entry of recovery.stepHistory()) {
1055
+ for (const name of referencedEnvVars(entry.action)) usedEarlier.add(name);
1056
+ }
989
1057
  const status = stepFailedReason ? "failed" : "passed";
990
1058
  stepResults.push({
991
1059
  step: mask(step),
@@ -1533,6 +1601,7 @@ Rules:
1533
1601
  - Pick target elements exclusively from the current snapshot, using their exact role and accessible name. Never invent CSS selectors or guess elements not in the snapshot.
1534
1602
  - Use "navigate" only with a URL or path as value. Use "fill" to type into textboxes/inputs. Use "press" for keyboard keys (value e.g. "Enter"). Use "select" for dropdowns (value = option label).
1535
1603
  - Use "assert" with an expectation to verify page state (visible text, counts, URLs). Assertions never modify the page.
1604
+ - A step that begins with "verify", "check", "confirm", "ensure", "assert", "expect", "validate", "make sure" or "see that" only looks. Never click or press in it: making the page show what the step checks would hide the very thing it checks. Assert what the page shows, navigate if what it names is on another page, or fail. It closes on a passing assertion, never on "done". This is enforced: a click, a press or "done" in such a step is refused.
1536
1605
  - Return "done" when the current step's outcome holds \u2014 including when it already held before you acted, or was achieved by your previous action. "Already true" is done, never failure. Do not return "done" for work belonging to later steps.
1537
1606
  - Return "fail" only when the step's outcome cannot be reached: the element is still absent after retries, the page cannot support the step, or an error blocks progress. Never return "fail" because the work appears to have been done already.
1538
1607
  - If your previous action errored, re-read the fresh snapshot and choose an alternative element or approach. Do not repeat the exact same failing action.
@@ -1565,6 +1634,8 @@ function agentUserPrompt(input) {
1565
1634
  function assertSystemPrompt() {
1566
1635
  return `You are a QA judge. You receive a test step, the model's expectation for the current page, and a page accessibility snapshot. Decide whether the STEP's own outcome holds \u2014 the expectation is the claim the model is offering in support of that, not a substitute question of its own. A claim can be true of the snapshot and still fail the step, if it does not establish what the step actually describes: only pass when the snapshot itself shows the step's outcome, never merely because the expectation offered happens to be true of something else on the page.
1567
1636
 
1637
+ When the step says where its outcome must appear (in the confirmation message, in the list, in the cart, for this order), that place is part of the outcome. Identify the element the step names from the snapshot itself, and look for the value there. The same value elsewhere on the page (another order, another row, another section) does not satisfy the step, even when the expectation describes that other place by the step's words.
1638
+
1568
1639
  A value sitting in a control that was just typed into \u2014 an open dialog's textbox, an unsubmitted form field \u2014 is not the same as a committed outcome. When the step describes an outcome (something now appears in a list, is saved, is confirmed, is created), text visible only inside an editable, not-yet-submitted control does not satisfy it; look for the outcome committed outside that control (the dialog closed, the item is listed on its own, a confirmation appeared). This is specifically about that confusion, not a license to fail anything you are merely unsure about \u2014 if the snapshot plainly shows the step's outcome, pass it.
1569
1640
 
1570
1641
  A step that names an ACTION (submit, click, create, add, ...) is satisfied by evidence the action took effect, not by the action's own control still being on the page. A successful action ordinarily replaces or moves past exactly the form, button or field the step names, so that control's absence is normal evidence of success, not evidence the step is unverifiable \u2014 do not fail such a step only because you can no longer see the thing it names. Fail it instead when the snapshot shows the action did NOT take effect: an error message, a validation warning, or the very same pre-action page still in front of you with nothing changed. A different page, a new state, or the result the action was meant to produce counts as evidence it worked.
@@ -1681,7 +1752,7 @@ var assertJudgmentSchema = z2.object({
1681
1752
  ),
1682
1753
  reason: z2.string().describe("One sentence: whether the snapshot shows that outcome."),
1683
1754
  pass: z2.boolean().describe(
1684
- "Whether the snapshot shows that outcome. The expectation is only a claim offered in support; it never replaces the step. False if any part of the outcome the step asks for is not shown, or cannot be assessed from this snapshot. An action the step names (click, dismiss, submit) is how its outcome is reached, not part of it: an outcome that holds passes whether or not that action was needed. An outcome that is an absence (gone, closed, dismissed, removed) is shown by the thing being absent."
1755
+ "Whether the snapshot shows that outcome. The expectation is only a claim offered in support; it never replaces the step. False if any part of the outcome the step asks for is not shown, or cannot be assessed from this snapshot. An action the step names (click, dismiss, submit) is how its outcome is reached, not part of it: an outcome that holds passes whether or not that action was needed. An outcome that is an absence (gone, closed, dismissed, removed) is shown by the thing being absent. Where the step says the outcome appears (in the confirmation, in the list, for this order) is part of it: a value found only somewhere else on the page is false."
1685
1756
  )
1686
1757
  });
1687
1758
  var generatedTestSchema = z2.object({
@@ -1745,7 +1816,7 @@ function createBrain(model, generate = generateObject, budget) {
1745
1816
  }
1746
1817
  return parsed.data;
1747
1818
  },
1748
- async judge(step, expectation, snapshot, stepHistory) {
1819
+ async judge(step, expectation, snapshot, stepHistory, usedEarlier) {
1749
1820
  const asJudged = stepHistory?.map((entry) => ({
1750
1821
  action: placeholdersAsLabels(entry.action),
1751
1822
  result: placeholdersAsLabels(entry.result)
@@ -1768,18 +1839,20 @@ function createBrain(model, generate = generateObject, budget) {
1768
1839
  `Model returned an invalid assert judgment: ${parsed.error.issues[0]?.message ?? "unknown"}`
1769
1840
  );
1770
1841
  }
1771
- return secretMismatch(placeholdersAsLabels(step), snapshot, asJudged, parsed.data);
1842
+ return secretMismatch(placeholdersAsLabels(step), snapshot, asJudged, usedEarlier ?? [], parsed.data);
1772
1843
  }
1773
1844
  };
1774
1845
  }
1775
- function secretMismatch(judgedStep, snapshot, judgedRecord, judgment) {
1846
+ function secretMismatch(judgedStep, snapshot, judgedRecord, usedEarlier, judgment) {
1776
1847
  if (!judgment.pass) return judgment;
1777
1848
  const onPage = labelledVariables(snapshot);
1778
1849
  const inRecord = labelledVariables((judgedRecord ?? []).map((e) => `${e.action}
1779
1850
  ${e.result}`).join("\n"));
1780
1851
  for (const name of labelledVariables(judgedStep)) {
1781
1852
  const others = onPage.filter((other) => other !== name);
1782
- if (onPage.includes(name) || inRecord.includes(name) || others.length === 0) continue;
1853
+ if (onPage.includes(name) || inRecord.includes(name) || usedEarlier.includes(name) || others.length === 0) {
1854
+ continue;
1855
+ }
1783
1856
  const shown = others.map((other) => redactionLabel(other)).join(", ");
1784
1857
  return {
1785
1858
  ...judgment,
@@ -1866,41 +1939,6 @@ import { mkdir as mkdir4, writeFile as writeFile3 } from "fs/promises";
1866
1939
  import path6 from "path";
1867
1940
  import { stringify } from "yaml";
1868
1941
 
1869
- // src/runner/authoring.ts
1870
- var VALUE_VERBS = ["fill", "enter", "type", "input", "set"];
1871
- var LEADING_VALUE_VERB = new RegExp(`^\\s*(?:${VALUE_VERBS.join("|")})\\b`, "i");
1872
- var CONNECTOR_WORDS = ["with", "to", "as", "using", "into", "from", "in"];
1873
- var CONNECTOR_WORD = new RegExp(`\\b(?:${CONNECTOR_WORDS.join("|")})\\b`, "i");
1874
- var CONNECTOR_SYMBOL = /["'`:=]|\{\{env\./i;
1875
- var PHRASAL_IN = new RegExp(`^(\\s*(?:${VALUE_VERBS.join("|")}))\\s+in\\b`, "i");
1876
- function namesAValue(step) {
1877
- const withoutPhrasal = step.replace(PHRASAL_IN, "$1");
1878
- return CONNECTOR_WORD.test(withoutPhrasal) || CONNECTOR_SYMBOL.test(withoutPhrasal);
1879
- }
1880
- function namesNoValue(step) {
1881
- return LEADING_VALUE_VERB.test(step) && !namesAValue(step);
1882
- }
1883
- function entersNamedValue(step) {
1884
- return LEADING_VALUE_VERB.test(step) && namesAValue(step);
1885
- }
1886
- function detectMissingValues(tests) {
1887
- const findings = [];
1888
- for (const test of tests) {
1889
- for (const origin of ["setup", "steps"]) {
1890
- const steps = origin === "setup" ? test.setup ?? [] : test.steps;
1891
- steps.forEach((step, position) => {
1892
- if (namesNoValue(step)) {
1893
- findings.push({ test, origin, index: position + 1, step });
1894
- }
1895
- });
1896
- }
1897
- }
1898
- return { findings };
1899
- }
1900
- function suggestValueClause(step) {
1901
- return `${step.trimEnd()} with <value>`;
1902
- }
1903
-
1904
1942
  // src/runner/testfile.ts
1905
1943
  import { readFile as readFile3, readdir } from "fs/promises";
1906
1944
  import path5 from "path";
@@ -3363,7 +3401,7 @@ function parsePositiveNumber(flag) {
3363
3401
  };
3364
3402
  }
3365
3403
  var program = new Command();
3366
- program.name("blastproof").description("Open-source AI testing agent: plain-English YAML tests executed agentically on a real browser.").version("0.23.0");
3404
+ program.name("blastproof").description("Open-source AI testing agent: plain-English YAML tests executed agentically on a real browser.").version("0.24.0");
3367
3405
  program.command("init").description("Scaffold .blastproof/ (config, tests, sample tests) in the current directory").action(async () => {
3368
3406
  try {
3369
3407
  const result = await initProject(process.cwd());