blastproof 0.22.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
@@ -210,7 +210,7 @@ Common flags — `blastproof <command> --help` has the full list:
210
210
  | `--write` | `plan` only — persist drafts instead of previewing |
211
211
  | `--max-llm-calls` · `--max-tokens` · `--max-duration` | [Bound what a run may spend](./docs/configuration.md#budget--bounding-what-a-run-spends) |
212
212
 
213
- Exit codes: **0** pass, **1** the gate failed, **2** usage or config error.
213
+ Exit codes: **0** pass, **1** the gate failed or the run stopped (its budget, or the model provider refusing a call: `Run incomplete:`), **2** usage or config error.
214
214
 
215
215
  **Generated drafts are never executed and never affect the score.** An unreviewed model-written test in the merge path fails in two directions: a hallucinated expectation blocks a correct PR, and a credulous one waves a broken change through while looking like coverage. `plan` makes the gap visible with a draft to review; it does not make an uncovered route safe.
216
216
 
@@ -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
@@ -219,7 +219,9 @@ function describeLimit(limit, observed, configured) {
219
219
  return `deadline exceeded: reached the configured maximum of ${(configured / 1e3).toFixed(0)}s (elapsed ${(observed / 1e3).toFixed(1)}s)`;
220
220
  }
221
221
  }
222
- var BudgetExhaustedError = class extends Error {
222
+ var RunStoppedError = class extends Error {
223
+ };
224
+ var BudgetExhaustedError = class extends RunStoppedError {
223
225
  limit;
224
226
  observed;
225
227
  configured;
@@ -231,6 +233,30 @@ var BudgetExhaustedError = class extends Error {
231
233
  this.configured = configured;
232
234
  }
233
235
  };
236
+ function refusalRemedy(statusCode) {
237
+ if (statusCode === void 0) {
238
+ return "The provider could not be reached after 3 attempts: check llm.base_url and the network, then run again.";
239
+ }
240
+ if (statusCode === 401 || statusCode === 403) {
241
+ return "Check the API key in the variable named by llm.api_key_env, then run again.";
242
+ }
243
+ if (statusCode === 402) return "Add credit to the provider account, then run again.";
244
+ if (statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500) {
245
+ return "The provider was unavailable after 3 attempts: run again later.";
246
+ }
247
+ return void 0;
248
+ }
249
+ var ProviderRefusedError = class extends RunStoppedError {
250
+ statusCode;
251
+ constructor(statusCode, detail) {
252
+ const status = statusCode === void 0 ? "no response" : `HTTP ${statusCode}`;
253
+ const remedy = refusalRemedy(statusCode);
254
+ const separator = /[.!?]$/.test(detail.trim()) ? " " : ". ";
255
+ super(`model provider refused the request (${status}): ${detail}${remedy ? `${separator}${remedy}` : ""}`);
256
+ this.name = "ProviderRefusedError";
257
+ this.statusCode = statusCode;
258
+ }
259
+ };
234
260
  var RunBudget = class {
235
261
  maxCalls;
236
262
  maxTokens;
@@ -583,9 +609,52 @@ async function performResolvedAction(page, action, ctx) {
583
609
  }
584
610
  }
585
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
+
586
651
  // src/runner/recovery.ts
587
652
  var COMMIT_ACTIONS = /* @__PURE__ */ new Set(["click", "press"]);
588
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
+ }
589
658
  var SOURCED_VALUE_ACTIONS = /* @__PURE__ */ new Set(["fill", "select"]);
590
659
  function referencesOnlyNamedVars(value, step) {
591
660
  const named = new Set(referencedEnvVars(step));
@@ -600,11 +669,13 @@ function describeAction(action) {
600
669
  return `${action.action}${target}${value}`;
601
670
  }
602
671
  function identity(action) {
672
+ const role = action.target?.role ?? "";
673
+ const name = action.target?.name ?? "";
603
674
  return JSON.stringify([
604
675
  action.action,
605
- action.target?.role ?? "",
606
- action.target?.name ?? "",
607
- action.target?.text ?? "",
676
+ role,
677
+ normalise(name),
678
+ role || name ? "" : action.target?.text ?? "",
608
679
  action.value ?? ""
609
680
  ]);
610
681
  }
@@ -634,9 +705,15 @@ var StepRecovery = class {
634
705
  * stay distinguishable in the one place that decides which secret gets typed.
635
706
  */
636
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;
637
713
  constructor(step) {
638
714
  this.step = step;
639
715
  this.readable = [normalise(step)];
716
+ this.verifies = isVerificationStep(step);
640
717
  }
641
718
  /**
642
719
  * Records a snapshot the model was shown, as a source it may quote from.
@@ -690,7 +767,7 @@ var StepRecovery = class {
690
767
  * and #28 has now produced one on three applications.
691
768
  */
692
769
  refusalFor(action) {
693
- return this.repeatedCommitRefusal(action) ?? this.redactionLabelRefusal(action) ?? this.unsourcedValueRefusal(action);
770
+ return this.verificationRefusal(action) ?? this.repeatedCommitRefusal(action) ?? this.redactionLabelRefusal(action) ?? this.unsourcedValueRefusal(action);
694
771
  }
695
772
  /**
696
773
  * Refuses a typed value containing a redaction label (design
@@ -711,9 +788,21 @@ var StepRecovery = class {
711
788
  if (!action.value?.includes(REDACTION_PREFIX)) return void 0;
712
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.`;
713
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
+ }
714
804
  repeatedCommitRefusal(action) {
715
- if (!COMMIT_ACTIONS.has(action.action)) return void 0;
716
- if (action.action === "press" && !COMMIT_KEYS.has(action.value ?? "")) return void 0;
805
+ if (!isCommit(action)) return void 0;
717
806
  if (!this.performed.has(identity(action))) return void 0;
718
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.`;
719
808
  }
@@ -780,6 +869,7 @@ function slugify(text) {
780
869
  return slug || "test";
781
870
  }
782
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.";
783
873
  var StepFailure = class extends Error {
784
874
  };
785
875
  async function executeTest(page, test, options) {
@@ -817,6 +907,7 @@ async function executeTest(page, test, options) {
817
907
  let failure;
818
908
  const boundary = allowedOriginsFor(baseUrl, allowedOrigins);
819
909
  await page.goto(new URL(baseUrl).toString());
910
+ const usedEarlier = /* @__PURE__ */ new Set();
820
911
  for (let index = 0; index < allSteps.length; index++) {
821
912
  const { step, setup } = allSteps[index];
822
913
  const stepStartedAt = Date.now();
@@ -854,7 +945,7 @@ async function executeTest(page, test, options) {
854
945
  iterationsLeft: maxIterationsPerStep - iterations
855
946
  });
856
947
  } catch (error) {
857
- if (error instanceof BudgetExhaustedError) throw error;
948
+ if (error instanceof RunStoppedError) throw error;
858
949
  failedAttempts++;
859
950
  lastResult = `error: ${error instanceof Error ? error.message : String(error)}`;
860
951
  if (failedAttempts >= maxRetries) {
@@ -864,9 +955,9 @@ async function executeTest(page, test, options) {
864
955
  }
865
956
  iterations++;
866
957
  if (action.action === "done") {
867
- if (!recovery.acted) {
958
+ if (!recovery.acted || recovery.verifies) {
868
959
  failedAttempts++;
869
- lastResult = NOTHING_DONE_REFUSAL;
960
+ lastResult = recovery.verifies ? VERIFICATION_DONE_REFUSAL : NOTHING_DONE_REFUSAL;
870
961
  emitAction(index, action, lastResult);
871
962
  if (failedAttempts >= maxRetries) {
872
963
  throw new StepFailure(lastResult);
@@ -882,23 +973,37 @@ async function executeTest(page, test, options) {
882
973
  }
883
974
  if (action.action === "assert") {
884
975
  const expectation = action.expectation ?? action.reasoning;
885
- let judgment = await brain.judge(
886
- mask(step),
887
- mask(expectation),
888
- maskedSnap,
889
- recovery.stepHistory()
890
- );
891
- if (!judgment.pass) {
892
- await waitForSettled(page);
893
- const freshSnap = await takeSnapshot(page);
894
- const maskedFresh = mask(freshSnap);
895
- recovery.observe(maskedFresh);
976
+ let judgment;
977
+ try {
896
978
  judgment = await brain.judge(
897
979
  mask(step),
898
980
  mask(expectation),
899
- maskedFresh,
900
- recovery.stepHistory()
981
+ maskedSnap,
982
+ recovery.stepHistory(),
983
+ [...usedEarlier]
901
984
  );
985
+ if (!judgment.pass) {
986
+ await waitForSettled(page);
987
+ const freshSnap = await takeSnapshot(page);
988
+ const maskedFresh = mask(freshSnap);
989
+ recovery.observe(maskedFresh);
990
+ judgment = await brain.judge(
991
+ mask(step),
992
+ mask(expectation),
993
+ maskedFresh,
994
+ recovery.stepHistory(),
995
+ [...usedEarlier]
996
+ );
997
+ }
998
+ } catch (error) {
999
+ if (error instanceof RunStoppedError) throw error;
1000
+ failedAttempts++;
1001
+ lastResult = `error: ${error instanceof Error ? error.message : String(error)}`;
1002
+ emitAction(index, action, lastResult);
1003
+ if (failedAttempts >= maxRetries) {
1004
+ throw new StepFailure(lastResult);
1005
+ }
1006
+ continue;
902
1007
  }
903
1008
  const result = judgment.pass ? `ok: assertion passed: ${judgment.reason}` : `assertion failed: ${judgment.reason}`;
904
1009
  emitAction(index, action, result);
@@ -943,9 +1048,12 @@ async function executeTest(page, test, options) {
943
1048
  }
944
1049
  }
945
1050
  } catch (error) {
946
- if (error instanceof BudgetExhaustedError) throw error;
1051
+ if (error instanceof RunStoppedError) throw error;
947
1052
  stepFailedReason = mask(error instanceof Error ? error.message : String(error));
948
1053
  }
1054
+ for (const entry of recovery.stepHistory()) {
1055
+ for (const name of referencedEnvVars(entry.action)) usedEarlier.add(name);
1056
+ }
949
1057
  const status = stepFailedReason ? "failed" : "passed";
950
1058
  stepResults.push({
951
1059
  step: mask(step),
@@ -1044,12 +1152,24 @@ async function runJourney(...args) {
1044
1152
  try {
1045
1153
  return await executeTest(...args);
1046
1154
  } catch (error) {
1047
- if (error instanceof BudgetExhaustedError) throw error;
1155
+ if (error instanceof RunStoppedError) throw error;
1048
1156
  throw new AuthError(
1049
1157
  `Authentication could not run: ${error instanceof Error ? error.message : String(error)}`
1050
1158
  );
1051
1159
  }
1052
1160
  }
1161
+ async function verifyJudgment(brain, verify, snapshot, maskText, maxRetries = 3) {
1162
+ let lastError = "";
1163
+ for (let attempt = 0; attempt < maxRetries; attempt++) {
1164
+ try {
1165
+ return await brain.judge(verify, verify, await snapshot());
1166
+ } catch (error) {
1167
+ if (error instanceof RunStoppedError) throw error;
1168
+ lastError = error instanceof Error ? error.message : String(error);
1169
+ }
1170
+ }
1171
+ throw new AuthError(`Authentication could not be verified: ${maskText(lastError)}`);
1172
+ }
1053
1173
  async function fromSteps(options) {
1054
1174
  const { auth, baseUrl, browser, brain, maxRetries, snapshot, timeoutMs, maxSnapshotLines, onEvent, mask } = options;
1055
1175
  const steps = auth.steps;
@@ -1087,7 +1207,13 @@ async function fromSteps(options) {
1087
1207
  );
1088
1208
  }
1089
1209
  if (auth.verify) {
1090
- const judgment = await brain.judge(auth.verify, auth.verify, mask.mask(await takeSnapshot(page)));
1210
+ const judgment = await verifyJudgment(
1211
+ brain,
1212
+ auth.verify,
1213
+ async () => mask.mask(await takeSnapshot(page)),
1214
+ (text) => mask.mask(text),
1215
+ maxRetries
1216
+ );
1091
1217
  if (!judgment.pass) {
1092
1218
  throw new AuthError(`Authentication could not be verified: ${mask.mask(judgment.reason)}`);
1093
1219
  }
@@ -1459,7 +1585,7 @@ warning: ${findings.length} file(s) changed in the working tree are not in the d
1459
1585
  }
1460
1586
 
1461
1587
  // src/llm/brain.ts
1462
- import { generateObject } from "ai";
1588
+ import { APICallError, generateObject, RetryError } from "ai";
1463
1589
 
1464
1590
  // src/llm/prompts.ts
1465
1591
  function agentSystemPrompt() {
@@ -1475,6 +1601,7 @@ Rules:
1475
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.
1476
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).
1477
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.
1478
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.
1479
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.
1480
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.
@@ -1507,10 +1634,14 @@ function agentUserPrompt(input) {
1507
1634
  function assertSystemPrompt() {
1508
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.
1509
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
+
1510
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.
1511
1640
 
1512
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.
1513
1642
 
1643
+ An outcome may already hold before this step acts: an earlier step, or the application itself, got there first. A step asking for something to be gone, closed or dismissed is satisfied by that thing being absent from the snapshot. It does not also require the thing to have been there, or this step to have removed it, and a different element that is present (another dialog, another banner) is not the one the step names. Whether the step's action ran is not what you decide: judge the state the step asks for.
1644
+
1514
1645
  You may also be shown the actions already performed in this step, with their results. That record tells you what was ATTEMPTED and what it produced \u2014 for instance that a navigation was performed and which URL the server ultimately served, or that a form was submitted. Use it to avoid concluding that something never happened when the page simply cannot show it any more: a navigation the server redirected does not leave the browser at the path that was requested, and that is what success looks like, not failure.
1515
1646
 
1516
1647
  The record is not evidence that the step's outcome holds. An action reported as \`ok\` establishes that it ran and what it returned; whether the thing the step describes is now TRUE is still decided by the snapshot alone. Never pass a step because the record shows an action succeeded while the snapshot does not show the outcome.
@@ -1616,9 +1747,12 @@ function parseAgentAction(value) {
1616
1747
  return parsedAgentActionSchema.safeParse(value);
1617
1748
  }
1618
1749
  var assertJudgmentSchema = z2.object({
1619
- reason: z2.string().describe("One sentence: what the STEP requires to be true now, and whether the snapshot shows it."),
1750
+ outcome: z2.string().describe(
1751
+ 'The state the STEP asks for, rewritten as a sentence about the page with its action removed: "click Save and verify the note is listed" becomes "the note is listed"; "open the Account menu and verify it shows the email" becomes "the Account menu shows the email".'
1752
+ ),
1753
+ reason: z2.string().describe("One sentence: whether the snapshot shows that outcome."),
1620
1754
  pass: z2.boolean().describe(
1621
- "Whether the snapshot shows the STEP's own 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."
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."
1622
1756
  )
1623
1757
  });
1624
1758
  var generatedTestSchema = z2.object({
@@ -1647,13 +1781,20 @@ function withProviderDetail(error) {
1647
1781
  error.message = `${error.message} \u2014 provider said: ${detail}`;
1648
1782
  return error;
1649
1783
  }
1784
+ function asProviderRefusal(error) {
1785
+ const cause = RetryError.isInstance(error) ? error.lastError : error;
1786
+ if (!APICallError.isInstance(cause)) return error;
1787
+ if (cause.statusCode !== void 0 && cause.statusCode < 400) return error;
1788
+ withProviderDetail(cause);
1789
+ return new ProviderRefusedError(cause.statusCode, cause.message);
1790
+ }
1650
1791
  async function countedGenerate(generate, budget, options) {
1651
1792
  budget.check();
1652
1793
  let result;
1653
1794
  try {
1654
1795
  result = await generate(options);
1655
1796
  } catch (error) {
1656
- throw withProviderDetail(error);
1797
+ throw asProviderRefusal(withProviderDetail(error));
1657
1798
  }
1658
1799
  budget.record(result.usage);
1659
1800
  return result;
@@ -1675,7 +1816,7 @@ function createBrain(model, generate = generateObject, budget) {
1675
1816
  }
1676
1817
  return parsed.data;
1677
1818
  },
1678
- async judge(step, expectation, snapshot, stepHistory) {
1819
+ async judge(step, expectation, snapshot, stepHistory, usedEarlier) {
1679
1820
  const asJudged = stepHistory?.map((entry) => ({
1680
1821
  action: placeholdersAsLabels(entry.action),
1681
1822
  result: placeholdersAsLabels(entry.result)
@@ -1698,20 +1839,23 @@ function createBrain(model, generate = generateObject, budget) {
1698
1839
  `Model returned an invalid assert judgment: ${parsed.error.issues[0]?.message ?? "unknown"}`
1699
1840
  );
1700
1841
  }
1701
- return secretMismatch(placeholdersAsLabels(step), snapshot, asJudged, parsed.data);
1842
+ return secretMismatch(placeholdersAsLabels(step), snapshot, asJudged, usedEarlier ?? [], parsed.data);
1702
1843
  }
1703
1844
  };
1704
1845
  }
1705
- function secretMismatch(judgedStep, snapshot, judgedRecord, judgment) {
1846
+ function secretMismatch(judgedStep, snapshot, judgedRecord, usedEarlier, judgment) {
1706
1847
  if (!judgment.pass) return judgment;
1707
1848
  const onPage = labelledVariables(snapshot);
1708
1849
  const inRecord = labelledVariables((judgedRecord ?? []).map((e) => `${e.action}
1709
1850
  ${e.result}`).join("\n"));
1710
1851
  for (const name of labelledVariables(judgedStep)) {
1711
1852
  const others = onPage.filter((other) => other !== name);
1712
- 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
+ }
1713
1856
  const shown = others.map((other) => redactionLabel(other)).join(", ");
1714
1857
  return {
1858
+ ...judgment,
1715
1859
  pass: false,
1716
1860
  reason: `The step names ${redactionLabel(name)}, which appears neither on the page nor in this step's actions, while the page shows ${shown}: a different secret cannot satisfy it. (The judge had said: ${judgment.reason})`
1717
1861
  };
@@ -1795,41 +1939,6 @@ import { mkdir as mkdir4, writeFile as writeFile3 } from "fs/promises";
1795
1939
  import path6 from "path";
1796
1940
  import { stringify } from "yaml";
1797
1941
 
1798
- // src/runner/authoring.ts
1799
- var VALUE_VERBS = ["fill", "enter", "type", "input", "set"];
1800
- var LEADING_VALUE_VERB = new RegExp(`^\\s*(?:${VALUE_VERBS.join("|")})\\b`, "i");
1801
- var CONNECTOR_WORDS = ["with", "to", "as", "using", "into", "from", "in"];
1802
- var CONNECTOR_WORD = new RegExp(`\\b(?:${CONNECTOR_WORDS.join("|")})\\b`, "i");
1803
- var CONNECTOR_SYMBOL = /["'`:=]|\{\{env\./i;
1804
- var PHRASAL_IN = new RegExp(`^(\\s*(?:${VALUE_VERBS.join("|")}))\\s+in\\b`, "i");
1805
- function namesAValue(step) {
1806
- const withoutPhrasal = step.replace(PHRASAL_IN, "$1");
1807
- return CONNECTOR_WORD.test(withoutPhrasal) || CONNECTOR_SYMBOL.test(withoutPhrasal);
1808
- }
1809
- function namesNoValue(step) {
1810
- return LEADING_VALUE_VERB.test(step) && !namesAValue(step);
1811
- }
1812
- function entersNamedValue(step) {
1813
- return LEADING_VALUE_VERB.test(step) && namesAValue(step);
1814
- }
1815
- function detectMissingValues(tests) {
1816
- const findings = [];
1817
- for (const test of tests) {
1818
- for (const origin of ["setup", "steps"]) {
1819
- const steps = origin === "setup" ? test.setup ?? [] : test.steps;
1820
- steps.forEach((step, position) => {
1821
- if (namesNoValue(step)) {
1822
- findings.push({ test, origin, index: position + 1, step });
1823
- }
1824
- });
1825
- }
1826
- }
1827
- return { findings };
1828
- }
1829
- function suggestValueClause(step) {
1830
- return `${step.trimEnd()} with <value>`;
1831
- }
1832
-
1833
1942
  // src/runner/testfile.ts
1834
1943
  import { readFile as readFile3, readdir } from "fs/promises";
1835
1944
  import path5 from "path";
@@ -2577,7 +2686,7 @@ X ${r.summary} (${r.file})`);
2577
2686
  }
2578
2687
  if (notRun.length > 0) {
2579
2688
  console.log(`
2580
- ${notRun.length} test(s) not run (run stopped by its budget or deadline):`);
2689
+ ${notRun.length} test(s) not run (run stopped: ${notRun[0].reason}):`);
2581
2690
  for (const r of notRun) console.log(` - ${r.summary} (${r.file})`);
2582
2691
  }
2583
2692
  }
@@ -2902,7 +3011,7 @@ ${results.length} test file(s) could not be parsed:`);
2902
3011
  onEvent: printEvent
2903
3012
  });
2904
3013
  } catch (error) {
2905
- if (error instanceof BudgetExhaustedError) {
3014
+ if (error instanceof RunStoppedError) {
2906
3015
  incomplete = error;
2907
3016
  } else if (error instanceof AuthError) {
2908
3017
  console.error(`error: ${error.message}`);
@@ -2932,7 +3041,7 @@ ${results.length} test file(s) could not be parsed:`);
2932
3041
  if (!streaming) for (const line of lines) console.log(line);
2933
3042
  return { index, result };
2934
3043
  } catch (error) {
2935
- if (error instanceof BudgetExhaustedError) {
3044
+ if (error instanceof RunStoppedError) {
2936
3045
  stoppedBy ??= error;
2937
3046
  if (!streaming) for (const line of lines) console.log(line);
2938
3047
  return { index, stopped: error };
@@ -3116,7 +3225,7 @@ async function planCommand(options) {
3116
3225
  onEvent: printAuthEvent
3117
3226
  });
3118
3227
  } catch (error) {
3119
- if (error instanceof BudgetExhaustedError) {
3228
+ if (error instanceof RunStoppedError) {
3120
3229
  incomplete = error;
3121
3230
  } else if (error instanceof AuthError) {
3122
3231
  console.error(`error: ${error.message}`);
@@ -3144,7 +3253,7 @@ async function planCommand(options) {
3144
3253
  timeoutMs: config.browser.timeout_ms
3145
3254
  });
3146
3255
  } catch (error) {
3147
- if (error instanceof BudgetExhaustedError) {
3256
+ if (error instanceof RunStoppedError) {
3148
3257
  incomplete = error;
3149
3258
  break;
3150
3259
  }
@@ -3198,7 +3307,7 @@ ${renderTestYaml(draft, { route, base })}`);
3198
3307
  if (incomplete) {
3199
3308
  console.log(`Stopped: ${incomplete.message}`);
3200
3309
  if (notAttempted.length > 0) {
3201
- console.log("Not attempted (run out of budget):");
3310
+ console.log("Not attempted (run stopped):");
3202
3311
  for (const route of notAttempted) console.log(` ${route}`);
3203
3312
  }
3204
3313
  }
@@ -3292,7 +3401,7 @@ function parsePositiveNumber(flag) {
3292
3401
  };
3293
3402
  }
3294
3403
  var program = new Command();
3295
- program.name("blastproof").description("Open-source AI testing agent: plain-English YAML tests executed agentically on a real browser.").version("0.22.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");
3296
3405
  program.command("init").description("Scaffold .blastproof/ (config, tests, sample tests) in the current directory").action(async () => {
3297
3406
  try {
3298
3407
  const result = await initProject(process.cwd());