fusiontest 0.2.29__tar.gz → 0.2.30__tar.gz
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.
- {fusiontest-0.2.29 → fusiontest-0.2.30}/PKG-INFO +1 -1
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/cli.py +33 -3
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/core/bugs.py +5 -2
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/core/replay.py +17 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/core/runner.py +124 -1
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest.egg-info/PKG-INFO +1 -1
- {fusiontest-0.2.29 → fusiontest-0.2.30}/pyproject.toml +1 -1
- {fusiontest-0.2.29 → fusiontest-0.2.30}/README.md +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/__init__.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/bench/__init__.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/bench/sites/shop/bugs.js +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/bench/sites/shop/help.html +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/bench/sites/shop/index.html +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/bench/suites/shop-bugs.yaml +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/bench/suites/shop.yaml +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/bench/suites/todomvc.yaml +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/core/__init__.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/core/action_model.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/core/app_errors.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/core/goal_verifier.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/core/netguard.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/core/promise_checker.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/core/reproduce.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/core/screen_parser.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/core/secrets.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/core/shared_traces.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/core/tokens.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/demos/__init__.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/demos/fusiontest_dashboard.yaml +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/demos/github.yaml +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/demos/hacker_news.yaml +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/demos/httpbin.yaml +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/demos/todomvc.yaml +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/demos/wikipedia.yaml +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/desktop/__init__.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/desktop/macos_adapter.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/desktop/playwright_adapter.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/desktop/windows_adapter.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/discovery/__init__.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/discovery/goal_generator.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/guardrails/__init__.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/guardrails/engine.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/mobile/__init__.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/mobile/android_adapter.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/mobile/ios_adapter.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/reporting/__init__.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/reporting/reporter.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/training/__init__.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/training/data_collector.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/training/dataset_builder.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest/training/trainer.py +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest.egg-info/SOURCES.txt +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest.egg-info/dependency_links.txt +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest.egg-info/entry_points.txt +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest.egg-info/not-zip-safe +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest.egg-info/requires.txt +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/fusiontest.egg-info/top_level.txt +0 -0
- {fusiontest-0.2.29 → fusiontest-0.2.30}/setup.cfg +0 -0
|
@@ -66,8 +66,11 @@ def main():
|
|
|
66
66
|
help=f"Where replay recordings are stored (default: {DEFAULT_TRACE_DIR})")
|
|
67
67
|
@click.option("--reverify-every", type=click.IntRange(min=1), default=None,
|
|
68
68
|
help="Re-check a recorded goal with the LLM every N replays (default: 10)")
|
|
69
|
+
@click.option("--deploy", default=None,
|
|
70
|
+
help="Name of the deploy being tested (commit SHA, release…), shown in regression "
|
|
71
|
+
"reports. Default: FUSIONTEST_DEPLOY or the CI's commit SHA")
|
|
69
72
|
def run(goal, goal_file, platform, app, url, locale, backend, headless, output, config_file,
|
|
70
|
-
replay, trace_dir, reverify_every):
|
|
73
|
+
replay, trace_dir, reverify_every, deploy):
|
|
71
74
|
"""Run a FusionTest test — provide goals via --goal or --file."""
|
|
72
75
|
|
|
73
76
|
_load_env()
|
|
@@ -171,6 +174,10 @@ def run(goal, goal_file, platform, app, url, locale, backend, headless, output,
|
|
|
171
174
|
trace_store=_trace_store(Path(trace_dir), bool(replay_cfg.get("shared", True))),
|
|
172
175
|
# 0 = never replay: every goal goes through the LLM and re-records.
|
|
173
176
|
reverify_every=reverify_every if replay else 0,
|
|
177
|
+
# Regression watching: a goal that passed before and fails now is
|
|
178
|
+
# retried in a fresh browser before it's reported as a regression.
|
|
179
|
+
deploy=deploy or _deploy_from_env(),
|
|
180
|
+
fresh_adapter=(lambda: _build_adapter(platform, app, url, True)) if platform == "playwright" else None,
|
|
174
181
|
)
|
|
175
182
|
runner = FusionTestRunner(adapter, runner_cfg)
|
|
176
183
|
|
|
@@ -256,6 +263,23 @@ def run(goal, goal_file, platform, app, url, locale, backend, headless, output,
|
|
|
256
263
|
sys.exit(_exit_code(result))
|
|
257
264
|
|
|
258
265
|
|
|
266
|
+
_DEPLOY_ENV = ("FUSIONTEST_DEPLOY", "GITHUB_SHA", "CI_COMMIT_SHA", "VERCEL_GIT_COMMIT_SHA",
|
|
267
|
+
"RENDER_GIT_COMMIT", "CIRCLE_SHA1", "BITBUCKET_COMMIT", "SOURCE_VERSION")
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
def _deploy_from_env() -> str:
|
|
271
|
+
"""The deploy being tested, from the environment: FUSIONTEST_DEPLOY, else the
|
|
272
|
+
CI or host's commit SHA (shortened to 7 characters)."""
|
|
273
|
+
import os
|
|
274
|
+
import re
|
|
275
|
+
|
|
276
|
+
for name in _DEPLOY_ENV:
|
|
277
|
+
value = os.getenv(name, "").strip()
|
|
278
|
+
if value:
|
|
279
|
+
return value[:7] if re.fullmatch(r"[0-9a-f]{40}", value) else value[:100]
|
|
280
|
+
return ""
|
|
281
|
+
|
|
282
|
+
|
|
259
283
|
def _config_secrets(cfg: dict) -> dict[str, str]:
|
|
260
284
|
"""The config file's `secrets:` block, each value read from the environment
|
|
261
285
|
variable it names when that's set (so the file holds names, not passwords)."""
|
|
@@ -1381,7 +1405,7 @@ def _print_results(result, screenshots: dict[int, Path] | None = None,
|
|
|
1381
1405
|
|
|
1382
1406
|
for i, step in enumerate(result.steps, 1):
|
|
1383
1407
|
if step.success:
|
|
1384
|
-
status_cell = "[green]PASS[/green]"
|
|
1408
|
+
status_cell = "[green]PASS[/green]" + (" [yellow](flaky)[/yellow]" if step.flaky else "")
|
|
1385
1409
|
elif step.infra_error:
|
|
1386
1410
|
status_cell = "[yellow]ERROR[/yellow]"
|
|
1387
1411
|
else:
|
|
@@ -1410,6 +1434,11 @@ def _print_results(result, screenshots: dict[int, Path] | None = None,
|
|
|
1410
1434
|
console.print(f"\n[bold red]Bugs found ({len(result.bugs_detected)})[/bold red]")
|
|
1411
1435
|
for index, bug in enumerate(result.bugs_detected):
|
|
1412
1436
|
console.print(f" {index + 1}. {escape(bug.title)}", soft_wrap=True)
|
|
1437
|
+
if bug.kind == "regression":
|
|
1438
|
+
checked = ("failed again in a fresh session" if bug.reproduced
|
|
1439
|
+
else "not re-checked in a fresh session")
|
|
1440
|
+
console.print(f" [dim]Last worked: {escape(bug.last_good)} · first failed: "
|
|
1441
|
+
f"{escape(bug.first_bad)} · {checked}[/dim]")
|
|
1413
1442
|
if bug_screenshots and index in bug_screenshots:
|
|
1414
1443
|
console.print(f" [dim]screenshot: {escape(str(bug_screenshots[index]))}[/dim]", soft_wrap=True)
|
|
1415
1444
|
|
|
@@ -1421,7 +1450,8 @@ def _print_results(result, screenshots: dict[int, Path] | None = None,
|
|
|
1421
1450
|
console.print(f"[dim]LLM calls: {escape(calls)}[/dim]")
|
|
1422
1451
|
|
|
1423
1452
|
replayed = sum(1 for s in result.steps if s.mode == "replayed")
|
|
1424
|
-
|
|
1453
|
+
# A repair that failed isn't a repair: the recording wasn't replaced.
|
|
1454
|
+
repaired = sum(1 for s in result.steps if s.mode == "repaired" and s.success)
|
|
1425
1455
|
if replayed or repaired:
|
|
1426
1456
|
tokens = result.total_token_usage
|
|
1427
1457
|
console.print(
|
|
@@ -5,7 +5,7 @@ Every reported bug says what kind of bug it is, where, what was expected and
|
|
|
5
5
|
what happened instead, the screen text that proves it, the steps that lead to
|
|
6
6
|
it, and how many fresh sessions it was reproduced in.
|
|
7
7
|
|
|
8
|
-
kind js_exception | http_error | broken_promise | inconsistency
|
|
8
|
+
kind js_exception | http_error | broken_promise | inconsistency | regression
|
|
9
9
|
title one line, e.g. "Broken promise: … (after tap 'Apply coupon', on /cart)"
|
|
10
10
|
steps from the run's start, in plain words; typed secrets stay {{VAR}}
|
|
11
11
|
"""
|
|
@@ -14,7 +14,7 @@ from __future__ import annotations
|
|
|
14
14
|
|
|
15
15
|
from dataclasses import asdict, dataclass, field
|
|
16
16
|
|
|
17
|
-
KINDS = ("js_exception", "http_error", "broken_promise", "inconsistency")
|
|
17
|
+
KINDS = ("js_exception", "http_error", "broken_promise", "inconsistency", "regression")
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
@dataclass
|
|
@@ -29,6 +29,9 @@ class Bug:
|
|
|
29
29
|
steps: list[str] = field(default_factory=list) # to reproduce, from the last page opened
|
|
30
30
|
earlier_steps: int = 0 # steps earlier in the run, before that page was opened (not shown)
|
|
31
31
|
reproduced: int = 0 # fresh sessions it happened again in (0: not checked)
|
|
32
|
+
# Regressions: the deploy (or date) the goal last passed on, and this one.
|
|
33
|
+
last_good: str = ""
|
|
34
|
+
first_bad: str = ""
|
|
32
35
|
# PNG of the screen when it happened again in a fresh session (not in to_dict:
|
|
33
36
|
# uploaded separately).
|
|
34
37
|
screenshot: bytes | None = field(default=None, repr=False, compare=False)
|
|
@@ -51,6 +51,9 @@ class GoalTrace:
|
|
|
51
51
|
evidence: list[str]
|
|
52
52
|
final_url_path: str = ""
|
|
53
53
|
replays_since_verify: int = 0
|
|
54
|
+
# When the goal last passed, and on which deploy (regression watching, ADR-009).
|
|
55
|
+
last_passed_at: str = ""
|
|
56
|
+
last_passed_deploy: str = ""
|
|
54
57
|
|
|
55
58
|
def to_dict(self) -> dict:
|
|
56
59
|
return asdict(self)
|
|
@@ -65,6 +68,8 @@ class GoalTrace:
|
|
|
65
68
|
evidence=list(data.get("evidence", [])),
|
|
66
69
|
final_url_path=data.get("final_url_path", ""),
|
|
67
70
|
replays_since_verify=int(data.get("replays_since_verify", 0)),
|
|
71
|
+
last_passed_at=str(data.get("last_passed_at") or "")[:40],
|
|
72
|
+
last_passed_deploy=str(data.get("last_passed_deploy") or "")[:100],
|
|
68
73
|
)
|
|
69
74
|
|
|
70
75
|
|
|
@@ -123,6 +128,18 @@ def url_path(url: str) -> str:
|
|
|
123
128
|
return urlsplit(url).path.rstrip("/") or "/"
|
|
124
129
|
|
|
125
130
|
|
|
131
|
+
def describe_recorded(action: RecordedAction) -> str:
|
|
132
|
+
"""A recorded action as a step in plain words ("Tap 'Add to cart'")."""
|
|
133
|
+
text = action.action_type[:1].upper() + action.action_type[1:]
|
|
134
|
+
if action.element_label:
|
|
135
|
+
text += f" '{action.element_label}'"
|
|
136
|
+
if action.occurrence:
|
|
137
|
+
text += f" (#{action.occurrence + 1})"
|
|
138
|
+
if action.value and action.action_type in ("type", "select", "press"):
|
|
139
|
+
text += f" with '{action.value}'"
|
|
140
|
+
return text
|
|
141
|
+
|
|
142
|
+
|
|
126
143
|
# ── Recording ────────────────────────────────────────────────────────────────
|
|
127
144
|
|
|
128
145
|
def record_action(action: Action, elements: list[UIElement]) -> RecordedAction:
|
|
@@ -29,6 +29,7 @@ from fusiontest.core.replay import (
|
|
|
29
29
|
GoalTrace,
|
|
30
30
|
RecordedAction,
|
|
31
31
|
TraceStore,
|
|
32
|
+
describe_recorded,
|
|
32
33
|
evidence_present,
|
|
33
34
|
record_action,
|
|
34
35
|
resolve_action,
|
|
@@ -86,6 +87,10 @@ class StepResult:
|
|
|
86
87
|
# Broken promises / inconsistencies confirmed by the PromiseChecker
|
|
87
88
|
# (only with RunnerConfig.detect_bugs).
|
|
88
89
|
findings: list[Finding] = field(default_factory=list)
|
|
90
|
+
# Passed before and failed now; set when the failure was confirmed (ADR-009 §4).
|
|
91
|
+
regression: Bug | None = None
|
|
92
|
+
# Failed, then passed when retried in a fresh session: not a regression.
|
|
93
|
+
flaky: bool = False
|
|
89
94
|
|
|
90
95
|
def to_dict(self) -> dict:
|
|
91
96
|
"""JSON-safe form for reports and the API (screenshots excluded)."""
|
|
@@ -211,6 +216,12 @@ class RunnerConfig:
|
|
|
211
216
|
# bugs seen again every time are reported. None: report without reproducing.
|
|
212
217
|
fresh_adapter: Callable[[], object] | None = None
|
|
213
218
|
reproduce_times: int = 2
|
|
219
|
+
# Regression watching (ADR-009 §4): the deploy being tested (a commit SHA,
|
|
220
|
+
# release name…), stored with each recording when its goal passes. A goal
|
|
221
|
+
# that passed before and now fails is retried in a fresh session
|
|
222
|
+
# (fresh_adapter) and reported as a regression only if it fails again.
|
|
223
|
+
deploy: str = ""
|
|
224
|
+
retry_regressions: bool = True
|
|
214
225
|
|
|
215
226
|
|
|
216
227
|
# ── Runner ─────────────────────────────────────────────────────────────────────
|
|
@@ -246,6 +257,9 @@ class FusionTestRunner:
|
|
|
246
257
|
self._promise_checker: PromiseChecker | None = None
|
|
247
258
|
# Every navigation and executed action of the run, for reproduction.
|
|
248
259
|
self._log: list[LogEntry] = []
|
|
260
|
+
# Set by _execute_goal when a goal with a recording fails: checked once
|
|
261
|
+
# the goal's watchdog is off (a retry can take a while).
|
|
262
|
+
self._suspect: tuple | None = None
|
|
249
263
|
self._step_log = None
|
|
250
264
|
if self.config.step_log_path:
|
|
251
265
|
import pathlib # noqa: PLC0415
|
|
@@ -303,6 +317,7 @@ class FusionTestRunner:
|
|
|
303
317
|
model_goals = [_with_placeholder_hint(g) if resolver.has_templates(g) else g for g in goals]
|
|
304
318
|
reported: set[tuple[str, str]] = set() # bug signatures already suspected
|
|
305
319
|
candidates: list[BugCandidate] = []
|
|
320
|
+
regressions: list[Bug] = []
|
|
306
321
|
self._log = []
|
|
307
322
|
start_url = url or _current_url(self.adapter)
|
|
308
323
|
if start_url: # where a fresh session starts too, so it's not replayed
|
|
@@ -375,6 +390,12 @@ class FusionTestRunner:
|
|
|
375
390
|
if watchdog is not None:
|
|
376
391
|
watchdog.cancel()
|
|
377
392
|
|
|
393
|
+
if self._suspect is not None and not watchdog_fired.is_set() and not app_closed:
|
|
394
|
+
step_result = self._check_regression(step_result, resolver)
|
|
395
|
+
if step_result.regression is not None:
|
|
396
|
+
regressions.append(step_result.regression)
|
|
397
|
+
self._suspect = None
|
|
398
|
+
|
|
378
399
|
self._collect_bugs(step_result, candidates, reported, resolver)
|
|
379
400
|
|
|
380
401
|
# A timed-out goal couldn't be evaluated: record it as an error
|
|
@@ -433,6 +454,9 @@ class FusionTestRunner:
|
|
|
433
454
|
c.bug.reproduced = outcome.sessions if self.config.fresh_adapter else 0
|
|
434
455
|
result.bugs_detected = [c.bug for c in outcome.confirmed]
|
|
435
456
|
result.unconfirmed_bugs = [c.bug for c in outcome.unconfirmed]
|
|
457
|
+
# Regressions are failures of goals that verifiably worked before:
|
|
458
|
+
# reported whether or not bug finding is on.
|
|
459
|
+
result.bugs_detected += regressions
|
|
436
460
|
|
|
437
461
|
result.total_duration_seconds = time.time() - run_start
|
|
438
462
|
result.llm_calls = self._llm_calls()
|
|
@@ -731,11 +755,13 @@ class FusionTestRunner:
|
|
|
731
755
|
key = trace_key(safe_goal, goal_url)
|
|
732
756
|
trace = store.get(key)
|
|
733
757
|
mode = "llm"
|
|
758
|
+
start_at = len(self._log)
|
|
734
759
|
if trace is not None:
|
|
735
760
|
if trace.replays_since_verify < self.config.reverify_every:
|
|
736
761
|
replayed = self._replay(trace, safe_goal, goal_url, resolver)
|
|
737
762
|
if replayed is not None:
|
|
738
763
|
trace.replays_since_verify += 1
|
|
764
|
+
self._stamp_pass(trace)
|
|
739
765
|
store.save(trace)
|
|
740
766
|
return replayed
|
|
741
767
|
logger.info(" Replay diverged — falling back to the LLM to repair the trace")
|
|
@@ -746,9 +772,106 @@ class FusionTestRunner:
|
|
|
746
772
|
step = self._run_goal(goal, safe_goal=safe_goal, navigate_url=goal_url, resolver=resolver)
|
|
747
773
|
step.mode = mode
|
|
748
774
|
if step.success and self._last_recording is not None:
|
|
749
|
-
store.save(
|
|
775
|
+
store.save(self._stamp_pass(
|
|
776
|
+
GoalTrace(key=key, goal=safe_goal, start_url=goal_url, **self._last_recording)))
|
|
777
|
+
elif trace is not None and not step.success and not step.infra_error:
|
|
778
|
+
# It passed before (that's how it got a recording): a regression, or flaky.
|
|
779
|
+
self._suspect = (trace, goal, safe_goal, goal_url, start_at, key)
|
|
780
|
+
return step
|
|
781
|
+
|
|
782
|
+
def _stamp_pass(self, trace: GoalTrace) -> GoalTrace:
|
|
783
|
+
from datetime import datetime, timezone # noqa: PLC0415
|
|
784
|
+
trace.last_passed_at = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M UTC")
|
|
785
|
+
trace.last_passed_deploy = self.config.deploy
|
|
786
|
+
return trace
|
|
787
|
+
|
|
788
|
+
def _check_regression(self, step: StepResult, resolver: SecretResolver) -> StepResult:
|
|
789
|
+
"""A goal that passed before failed: retry it in a fresh session. Passes
|
|
790
|
+
→ flaky (the step passes, marked flaky). Fails again, or can't be
|
|
791
|
+
retried → a regression bug on the step."""
|
|
792
|
+
trace, goal, safe_goal, goal_url, start_at, key = self._suspect
|
|
793
|
+
retried = 0
|
|
794
|
+
if self.config.fresh_adapter is not None and self.config.retry_regressions:
|
|
795
|
+
retry = self._retry_in_fresh_session(goal, safe_goal, goal_url, resolver, start_at)
|
|
796
|
+
if retry is not None and retry.success:
|
|
797
|
+
logger.info(" Passed when retried in a fresh session: flaky, not a regression")
|
|
798
|
+
step.success, step.flaky = True, True
|
|
799
|
+
step.error = f"flaky: failed once ({step.error[:300]}), then passed in a fresh session"
|
|
800
|
+
step.token_usage += retry.token_usage
|
|
801
|
+
store = self.config.trace_store
|
|
802
|
+
if store is not None and self._last_recording is not None:
|
|
803
|
+
store.save(self._stamp_pass(
|
|
804
|
+
GoalTrace(key=key, goal=safe_goal, start_url=goal_url, **self._last_recording)))
|
|
805
|
+
return step
|
|
806
|
+
if retry is not None:
|
|
807
|
+
retried = 1
|
|
808
|
+
step.token_usage += retry.token_usage
|
|
809
|
+
last_good = trace.last_passed_deploy or trace.last_passed_at or "an earlier run"
|
|
810
|
+
first_bad = self.config.deploy or "this run"
|
|
811
|
+
proof = ", showing " + ", ".join(repr(e) for e in trace.evidence) if trace.evidence else ""
|
|
812
|
+
steps = ([step_text("navigate", trace.start_url)] if trace.start_url else []) + [
|
|
813
|
+
describe_recorded(a) for a in trace.actions]
|
|
814
|
+
step.regression = Bug(
|
|
815
|
+
kind="regression",
|
|
816
|
+
title=resolver.redact(f'Regression: "{safe_goal}" stopped working '
|
|
817
|
+
f"(last passed on {last_good})"),
|
|
818
|
+
page=url_path(trace.start_url),
|
|
819
|
+
expected=resolver.redact(f"It passes, as it did on {last_good}{proof}"),
|
|
820
|
+
actual=resolver.redact(step.error or "The goal no longer completes"),
|
|
821
|
+
steps=[resolver.redact(s) for s in steps],
|
|
822
|
+
reproduced=retried,
|
|
823
|
+
last_good=last_good,
|
|
824
|
+
first_bad=first_bad,
|
|
825
|
+
)
|
|
826
|
+
logger.warning(" %s", step.regression.title)
|
|
750
827
|
return step
|
|
751
828
|
|
|
829
|
+
def _retry_in_fresh_session(self, goal: str, safe_goal: str, goal_url: str,
|
|
830
|
+
resolver: SecretResolver, start_at: int) -> StepResult | None:
|
|
831
|
+
"""Re-create the run up to this goal in a fresh session (replaying the
|
|
832
|
+
action log, no LLM), then run the goal again. None if it can't be set up."""
|
|
833
|
+
try:
|
|
834
|
+
adapter = self.config.fresh_adapter()
|
|
835
|
+
except Exception as exc: # noqa: BLE001
|
|
836
|
+
logger.info(" Could not open a fresh session to retry: %s", exc)
|
|
837
|
+
return None
|
|
838
|
+
saved_log, original = list(self._log), self.adapter
|
|
839
|
+
self.adapter = adapter
|
|
840
|
+
try:
|
|
841
|
+
if not self._replay_entries(saved_log[:start_at], resolver):
|
|
842
|
+
logger.info(" Could not re-create the run's earlier steps in a fresh session")
|
|
843
|
+
return None
|
|
844
|
+
self.guardrails.reset_step()
|
|
845
|
+
return self._run_goal(goal, safe_goal=safe_goal, navigate_url=goal_url, resolver=resolver)
|
|
846
|
+
except Exception as exc: # noqa: BLE001 — a retry problem leaves the failure as it was
|
|
847
|
+
logger.info(" Retry in a fresh session failed to run: %s", exc)
|
|
848
|
+
return None
|
|
849
|
+
finally:
|
|
850
|
+
self.adapter, self._log = original, saved_log
|
|
851
|
+
stop = getattr(adapter, "stop", None)
|
|
852
|
+
if callable(stop):
|
|
853
|
+
try:
|
|
854
|
+
stop()
|
|
855
|
+
except Exception: # noqa: BLE001
|
|
856
|
+
pass
|
|
857
|
+
|
|
858
|
+
def _replay_entries(self, entries: list[LogEntry], resolver: SecretResolver) -> bool:
|
|
859
|
+
"""Replay logged navigations and actions on self.adapter (no LLM)."""
|
|
860
|
+
for entry in entries:
|
|
861
|
+
if entry.kind == "navigate":
|
|
862
|
+
if hasattr(self.adapter, "navigate"):
|
|
863
|
+
self.adapter.navigate(entry.url)
|
|
864
|
+
elif entry.action is not None:
|
|
865
|
+
time.sleep(0.8)
|
|
866
|
+
elements, _ = self.adapter.get_screen()
|
|
867
|
+
action = resolve_action(entry.action, elements)
|
|
868
|
+
if action is None:
|
|
869
|
+
return False
|
|
870
|
+
exec_action, blocked = self._bind_secrets(action, resolver)
|
|
871
|
+
if blocked or not self.adapter.execute(exec_action, elements):
|
|
872
|
+
return False
|
|
873
|
+
return True
|
|
874
|
+
|
|
752
875
|
def _collect_bugs(self, step: StepResult, candidates: list[BugCandidate],
|
|
753
876
|
reported: set[tuple[str, str]], resolver: SecretResolver) -> None:
|
|
754
877
|
"""The goal's app errors onto the step, and (with detect_bugs) each new
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|