fusiontest 0.2.30__tar.gz → 0.2.32__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.30 → fusiontest-0.2.32}/PKG-INFO +1 -1
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/bench/__init__.py +4 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/cli.py +23 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/core/action_model.py +36 -4
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/core/promise_checker.py +40 -4
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/core/runner.py +20 -1
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/desktop/playwright_adapter.py +31 -20
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest.egg-info/PKG-INFO +1 -1
- {fusiontest-0.2.30 → fusiontest-0.2.32}/pyproject.toml +1 -1
- {fusiontest-0.2.30 → fusiontest-0.2.32}/README.md +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/__init__.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/bench/sites/shop/bugs.js +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/bench/sites/shop/help.html +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/bench/sites/shop/index.html +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/bench/suites/shop-bugs.yaml +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/bench/suites/shop.yaml +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/bench/suites/todomvc.yaml +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/core/__init__.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/core/app_errors.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/core/bugs.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/core/goal_verifier.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/core/netguard.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/core/replay.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/core/reproduce.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/core/screen_parser.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/core/secrets.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/core/shared_traces.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/core/tokens.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/demos/__init__.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/demos/fusiontest_dashboard.yaml +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/demos/github.yaml +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/demos/hacker_news.yaml +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/demos/httpbin.yaml +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/demos/todomvc.yaml +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/demos/wikipedia.yaml +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/desktop/__init__.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/desktop/macos_adapter.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/desktop/windows_adapter.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/discovery/__init__.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/discovery/goal_generator.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/guardrails/__init__.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/guardrails/engine.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/mobile/__init__.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/mobile/android_adapter.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/mobile/ios_adapter.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/reporting/__init__.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/reporting/reporter.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/training/__init__.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/training/data_collector.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/training/dataset_builder.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest/training/trainer.py +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest.egg-info/SOURCES.txt +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest.egg-info/dependency_links.txt +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest.egg-info/entry_points.txt +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest.egg-info/not-zip-safe +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest.egg-info/requires.txt +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/fusiontest.egg-info/top_level.txt +0 -0
- {fusiontest-0.2.30 → fusiontest-0.2.32}/setup.cfg +0 -0
|
@@ -421,6 +421,9 @@ class VariantResult:
|
|
|
421
421
|
tasks_passed: int = 0
|
|
422
422
|
tasks: int = 0
|
|
423
423
|
failed_tasks: list[str] = field(default_factory=list) # "task — why", for diagnosis
|
|
424
|
+
# What the bug reviewer suggested and what became of each suggestion
|
|
425
|
+
# (ReviewDecision dicts plus the task), for diagnosing misses.
|
|
426
|
+
review: list[dict] = field(default_factory=list)
|
|
424
427
|
seconds: float = 0.0
|
|
425
428
|
tokens: int = 0
|
|
426
429
|
error: str = ""
|
|
@@ -447,6 +450,7 @@ def score_variant(suite: BugSuite, variant: Variant, run: RunResult) -> VariantR
|
|
|
447
450
|
unconfirmed=[str(b) for b in getattr(run, "unconfirmed_bugs", [])],
|
|
448
451
|
tasks_passed=sum(s.success for s in run.steps), tasks=len(suite.tasks),
|
|
449
452
|
failed_tasks=[f"{s.goal} — {s.error}" for s in run.steps if not s.success],
|
|
453
|
+
review=[{"task": s.goal, **d} for s in run.steps for d in getattr(s, "review", [])],
|
|
450
454
|
seconds=round(sum(s.duration_seconds for s in run.steps), 2),
|
|
451
455
|
tokens=sum(s.token_usage.total_tokens for s in run.steps),
|
|
452
456
|
error=run.error or next((s.error for s in run.steps if s.infra_error), ""),
|
|
@@ -1133,10 +1133,21 @@ def _print_variants(run) -> None:
|
|
|
1133
1133
|
detail += f" · fooled by {', '.join(v.decoy_trips)}"
|
|
1134
1134
|
if v.unconfirmed:
|
|
1135
1135
|
detail += f" · {len(v.unconfirmed)} not reproduced"
|
|
1136
|
+
dropped = _review_counts(v.review)
|
|
1137
|
+
if dropped:
|
|
1138
|
+
detail += f" · reviewer: {dropped}"
|
|
1136
1139
|
console.print(f" {mark} {v.variant:<10} {detail} "
|
|
1137
1140
|
f"[dim](tasks passed {v.tasks_passed}/{v.tasks})[/dim]")
|
|
1138
1141
|
|
|
1139
1142
|
|
|
1143
|
+
def _review_counts(review: list[dict]) -> str:
|
|
1144
|
+
"""'2 rejected, 1 no_evidence': reviewer suggestions that didn't become reports."""
|
|
1145
|
+
from collections import Counter
|
|
1146
|
+
|
|
1147
|
+
counts = Counter(d.get("outcome") for d in review if d.get("outcome") != "confirmed")
|
|
1148
|
+
return ", ".join(f"{n} {outcome}" for outcome, n in counts.most_common())
|
|
1149
|
+
|
|
1150
|
+
|
|
1140
1151
|
def _pct(x: float | None) -> str:
|
|
1141
1152
|
return "—" if x is None else f"{x:.0%}"
|
|
1142
1153
|
|
|
@@ -1169,6 +1180,18 @@ def _bench_markdown(summaries, runs, spend_line: str, bug_summaries=(), bug_runs
|
|
|
1169
1180
|
f"{sm.reports} | {sm.unconfirmed} | "
|
|
1170
1181
|
f"{sm.errors} | {_cost_cell(bug_runs, sm.suite, sm.backend)} |" for sm in bug_summaries]
|
|
1171
1182
|
lines.append("")
|
|
1183
|
+
# Suggestions that didn't become reports: the place to look when a
|
|
1184
|
+
# planted bug was missed (did the reviewer see it? did the check reject it?).
|
|
1185
|
+
dropped = [(r, v, d) for r in bug_runs for v in r.variants for d in v.review
|
|
1186
|
+
if d.get("outcome") != "confirmed"]
|
|
1187
|
+
if dropped:
|
|
1188
|
+
lines += ["**Reviewer suggestions that didn't become reports**", ""]
|
|
1189
|
+
for r, v, d in dropped:
|
|
1190
|
+
conf = f" ({d['confidence']:.2f})" if d.get("confidence") is not None else ""
|
|
1191
|
+
why = f" — {d['reason'][:200]}" if d.get("reason") else ""
|
|
1192
|
+
lines.append(f"- {r.suite} / {v.variant} / {d.get('task', '')[:60]}: "
|
|
1193
|
+
f"**{d.get('outcome')}**{conf}: {d.get('summary', '')[:200]}{why}")
|
|
1194
|
+
lines.append("")
|
|
1172
1195
|
return "\n".join(lines + [spend_line, ""])
|
|
1173
1196
|
|
|
1174
1197
|
|
|
@@ -162,6 +162,9 @@ _cooldowns_lock = threading.Lock()
|
|
|
162
162
|
_RATE_LIMIT_COOLDOWN_SECONDS = 60.0 # when the provider gives no retry hint
|
|
163
163
|
_BACKEND_ERROR_COOLDOWN_SECONDS = 300.0 # retired model / rejected key
|
|
164
164
|
_MAX_COOLDOWN_SECONDS = 3600.0
|
|
165
|
+
# When every backend is cooling down, wait this long at most for one to recover
|
|
166
|
+
# (a per-minute token limit resets within a minute) rather than fail the call.
|
|
167
|
+
_MAX_COOLDOWN_WAIT_SECONDS = 30.0
|
|
165
168
|
|
|
166
169
|
_RETRY_IN_RE = re.compile(
|
|
167
170
|
r"try again in\s+(?:(?P<h>\d+)h)?(?:(?P<m>\d+)m(?!s))?(?:(?P<s>[\d.]+)s)?(?:(?P<ms>[\d.]+)ms)?",
|
|
@@ -275,6 +278,12 @@ LLM_MAX_OUTPUT_TOKENS = 1024
|
|
|
275
278
|
# chain retries or falls through to the next backend.
|
|
276
279
|
LLM_REQUEST_TIMEOUT_SECONDS = 120
|
|
277
280
|
|
|
281
|
+
# SDK-level retries are off: the OpenAI/Anthropic SDKs otherwise retry a 429
|
|
282
|
+
# twice, sleeping out its retry-after inside the call (measured: 28–45s per
|
|
283
|
+
# Groq call on an 8k tokens/minute tier), so the fallback chain never sees the
|
|
284
|
+
# rate limit and can't switch backend. LLMCaller does its own retries.
|
|
285
|
+
LLM_SDK_MAX_RETRIES = 0
|
|
286
|
+
|
|
278
287
|
|
|
279
288
|
# Page text the action model sees per step (ADR-007 cost work). It needs every
|
|
280
289
|
# clickable element but only the gist of the page — the verifier, which judges
|
|
@@ -568,7 +577,8 @@ class LLMCaller:
|
|
|
568
577
|
"OPENAI_API_KEY is not set. Add it to your .env file or run: "
|
|
569
578
|
"export OPENAI_API_KEY=sk-..."
|
|
570
579
|
)
|
|
571
|
-
client = OpenAI(api_key=api_key, timeout=LLM_REQUEST_TIMEOUT_SECONDS
|
|
580
|
+
client = OpenAI(api_key=api_key, timeout=LLM_REQUEST_TIMEOUT_SECONDS,
|
|
581
|
+
max_retries=LLM_SDK_MAX_RETRIES)
|
|
572
582
|
|
|
573
583
|
elif backend == "claude":
|
|
574
584
|
try:
|
|
@@ -581,7 +591,8 @@ class LLMCaller:
|
|
|
581
591
|
"ANTHROPIC_API_KEY is not set. Add it to your .env file or run: "
|
|
582
592
|
"export ANTHROPIC_API_KEY=sk-ant-..."
|
|
583
593
|
)
|
|
584
|
-
client = anthropic.Anthropic(api_key=api_key, timeout=LLM_REQUEST_TIMEOUT_SECONDS
|
|
594
|
+
client = anthropic.Anthropic(api_key=api_key, timeout=LLM_REQUEST_TIMEOUT_SECONDS,
|
|
595
|
+
max_retries=LLM_SDK_MAX_RETRIES)
|
|
585
596
|
|
|
586
597
|
elif backend == "ollama":
|
|
587
598
|
try:
|
|
@@ -591,7 +602,8 @@ class LLMCaller:
|
|
|
591
602
|
"Ollama backend requires the openai SDK: pip install openai"
|
|
592
603
|
) from err
|
|
593
604
|
base_url = os.getenv("OLLAMA_HOST", "http://localhost:11434") + "/v1"
|
|
594
|
-
client = OpenAI(base_url=base_url, api_key="ollama", timeout=LLM_REQUEST_TIMEOUT_SECONDS
|
|
605
|
+
client = OpenAI(base_url=base_url, api_key="ollama", timeout=LLM_REQUEST_TIMEOUT_SECONDS,
|
|
606
|
+
max_retries=LLM_SDK_MAX_RETRIES)
|
|
595
607
|
|
|
596
608
|
elif backend == "groq":
|
|
597
609
|
try:
|
|
@@ -605,7 +617,7 @@ class LLMCaller:
|
|
|
605
617
|
"then: export GROQ_API_KEY=gsk_..."
|
|
606
618
|
)
|
|
607
619
|
client = OpenAI(base_url="https://api.groq.com/openai/v1", api_key=api_key,
|
|
608
|
-
timeout=LLM_REQUEST_TIMEOUT_SECONDS)
|
|
620
|
+
timeout=LLM_REQUEST_TIMEOUT_SECONDS, max_retries=LLM_SDK_MAX_RETRIES)
|
|
609
621
|
|
|
610
622
|
elif backend == "gemini":
|
|
611
623
|
try:
|
|
@@ -654,8 +666,28 @@ class LLMCaller:
|
|
|
654
666
|
fall through without a cooldown — smaller requests still fit.
|
|
655
667
|
- On other non-transient errors (bad request): raise immediately.
|
|
656
668
|
|
|
669
|
+
When no entry could answer but one comes off a short cooldown soon (a
|
|
670
|
+
per-minute token limit, typically), waits for it once and tries again.
|
|
671
|
+
|
|
657
672
|
Raises LLMUnavailableError when no entry could answer.
|
|
658
673
|
"""
|
|
674
|
+
try:
|
|
675
|
+
return self._call_chain(prompt, request)
|
|
676
|
+
except LLMUnavailableError:
|
|
677
|
+
wait = self._soonest_cooldown()
|
|
678
|
+
if not 0 < wait <= _MAX_COOLDOWN_WAIT_SECONDS:
|
|
679
|
+
raise
|
|
680
|
+
logger.warning("All LLM backends rate-limited — waiting %.0fs for the first to recover.", wait)
|
|
681
|
+
time.sleep(wait)
|
|
682
|
+
return self._call_chain(prompt, request)
|
|
683
|
+
|
|
684
|
+
def _soonest_cooldown(self) -> float:
|
|
685
|
+
"""Seconds until the first cooling-down entry in the chain is usable again."""
|
|
686
|
+
waits = [_cooldown_remaining(b, m) for b, m in self.fallback_chain if not _key_rejected(b)]
|
|
687
|
+
return min(waits, default=0.0)
|
|
688
|
+
|
|
689
|
+
def _call_chain(self, prompt: str, request: LLMRequest) -> tuple[str, TokenUsage]:
|
|
690
|
+
"""One pass over the fallback chain (see _call_llm)."""
|
|
659
691
|
if not self.fallback_chain:
|
|
660
692
|
raise RuntimeError("LLM fallback chain is empty")
|
|
661
693
|
|
|
@@ -147,31 +147,61 @@ def evidence_on_screen(evidence: list[str], transition: Transition) -> bool:
|
|
|
147
147
|
return bool(quotes) and all(q in screens for q in quotes)
|
|
148
148
|
|
|
149
149
|
|
|
150
|
+
@dataclass
|
|
151
|
+
class ReviewDecision:
|
|
152
|
+
"""What happened to one thing the reviewer suggested, so misses can be
|
|
153
|
+
diagnosed: confirmed, rejected by the skeptical check, or dropped."""
|
|
154
|
+
outcome: str # confirmed | rejected | no_evidence | malformed | error
|
|
155
|
+
summary: str
|
|
156
|
+
kind: str = ""
|
|
157
|
+
action: str = ""
|
|
158
|
+
confidence: float | None = None # the skeptical check's, when it ran
|
|
159
|
+
reason: str = "" # its reason, or why it was dropped
|
|
160
|
+
|
|
161
|
+
def to_dict(self) -> dict:
|
|
162
|
+
return {k: v for k, v in self.__dict__.items() if v not in ("", None)}
|
|
163
|
+
|
|
164
|
+
def line(self) -> str:
|
|
165
|
+
conf = f" ({self.confidence:.2f})" if self.confidence is not None else ""
|
|
166
|
+
why = f" — {self.reason}" if self.reason else ""
|
|
167
|
+
return f"{self.outcome}{conf}: {self.summary}{why}"
|
|
168
|
+
|
|
169
|
+
|
|
150
170
|
class PromiseChecker:
|
|
151
|
-
"""Reviews a goal's transitions; returns confirmed findings only.
|
|
171
|
+
"""Reviews a goal's transitions; returns confirmed findings only. Every
|
|
172
|
+
suggestion's fate is kept in last_decisions."""
|
|
152
173
|
|
|
153
174
|
def __init__(self, backend: str, llm: LLMCaller | None = None):
|
|
154
175
|
self.backend = backend
|
|
155
176
|
self._llm = llm or LLMCaller(backend, temperature=0.0)
|
|
156
177
|
self.last_token_usage = TokenUsage()
|
|
178
|
+
self.last_decisions: list[ReviewDecision] = []
|
|
157
179
|
|
|
158
180
|
def check(self, goal: str, transitions: list[Transition]) -> list[Finding]:
|
|
159
181
|
"""Never raises: a checker problem must not change a test result."""
|
|
160
182
|
self.last_token_usage = TokenUsage()
|
|
183
|
+
self.last_decisions = []
|
|
161
184
|
if not transitions:
|
|
162
185
|
return []
|
|
163
186
|
try:
|
|
164
187
|
candidates = self._review(goal, transitions)
|
|
165
188
|
except Exception as exc: # noqa: BLE001
|
|
166
189
|
logger.warning("Promise check failed: %s", exc)
|
|
190
|
+
self.last_decisions.append(ReviewDecision("error", "the review call failed", reason=str(exc)[:200]))
|
|
167
191
|
return []
|
|
168
192
|
confirmed = []
|
|
169
193
|
for finding in candidates:
|
|
194
|
+
decision = ReviewDecision("rejected", finding.summary, kind=finding.kind, action=finding.action)
|
|
170
195
|
try:
|
|
171
|
-
|
|
196
|
+
ok, confidence = self._confirm(finding, transitions[finding.step - 1])
|
|
197
|
+
decision.confidence, decision.reason = confidence, finding.confirmation
|
|
198
|
+
if ok:
|
|
199
|
+
decision.outcome = "confirmed"
|
|
172
200
|
confirmed.append(finding)
|
|
173
201
|
except Exception as exc: # noqa: BLE001
|
|
174
202
|
logger.warning("Promise confirmation failed: %s", exc)
|
|
203
|
+
decision.outcome, decision.reason = "error", f"the confirmation call failed: {exc}"[:200]
|
|
204
|
+
self.last_decisions.append(decision)
|
|
175
205
|
return confirmed
|
|
176
206
|
|
|
177
207
|
# ── Review ────────────────────────────────────────────────────────────────
|
|
@@ -192,10 +222,16 @@ class PromiseChecker:
|
|
|
192
222
|
step = 0
|
|
193
223
|
if kind not in KINDS or not summary or not 1 <= step <= len(transitions):
|
|
194
224
|
logger.info("Promise check: dropped malformed finding %r", item)
|
|
225
|
+
self.last_decisions.append(ReviewDecision(
|
|
226
|
+
"malformed", summary or str(item)[:200], kind=kind,
|
|
227
|
+
reason=f"kind {kind!r}, step {step} of {len(transitions)}"))
|
|
195
228
|
continue
|
|
196
229
|
transition = transitions[step - 1]
|
|
197
230
|
if not evidence_on_screen(evidence, transition):
|
|
198
231
|
logger.info("Promise check: dropped finding, evidence not on screen: %s", summary)
|
|
232
|
+
self.last_decisions.append(ReviewDecision(
|
|
233
|
+
"no_evidence", summary, kind=kind, action=transition.action,
|
|
234
|
+
reason=f"quotes not on that step's screens: {json.dumps(evidence)[:200]}"))
|
|
199
235
|
continue
|
|
200
236
|
findings.append(Finding(kind=kind, summary=summary, step=step, action=transition.action,
|
|
201
237
|
page=_page(transition.before), evidence=evidence,
|
|
@@ -206,7 +242,7 @@ class PromiseChecker:
|
|
|
206
242
|
|
|
207
243
|
# ── Confirmation ──────────────────────────────────────────────────────────
|
|
208
244
|
|
|
209
|
-
def _confirm(self, finding: Finding, transition: Transition) -> bool:
|
|
245
|
+
def _confirm(self, finding: Finding, transition: Transition) -> tuple[bool, float]:
|
|
210
246
|
prompt = "\n".join([
|
|
211
247
|
f"CLAIMED DEFECT ({finding.kind}): {finding.summary}",
|
|
212
248
|
f"EVIDENCE QUOTED: {json.dumps(finding.evidence)}",
|
|
@@ -235,7 +271,7 @@ class PromiseChecker:
|
|
|
235
271
|
ok = bool(defect) and confidence >= CONFIRM_THRESHOLD
|
|
236
272
|
logger.info("Promise check: %s (%.2f) — %s — %s",
|
|
237
273
|
"confirmed" if ok else "rejected", confidence, finding.summary, finding.confirmation)
|
|
238
|
-
return ok
|
|
274
|
+
return ok, confidence
|
|
239
275
|
|
|
240
276
|
|
|
241
277
|
def _review_prompt(goal: str, transitions: list[Transition]) -> str:
|
|
@@ -87,6 +87,9 @@ class StepResult:
|
|
|
87
87
|
# Broken promises / inconsistencies confirmed by the PromiseChecker
|
|
88
88
|
# (only with RunnerConfig.detect_bugs).
|
|
89
89
|
findings: list[Finding] = field(default_factory=list)
|
|
90
|
+
# Everything the bug reviewer suggested for this goal and what became of it
|
|
91
|
+
# (ReviewDecision.to_dict()): confirmed, rejected, or dropped. For diagnosis.
|
|
92
|
+
review: list[dict] = field(default_factory=list)
|
|
90
93
|
# Passed before and failed now; set when the failure was confirmed (ADR-009 §4).
|
|
91
94
|
regression: Bug | None = None
|
|
92
95
|
# Failed, then passed when retried in a fresh session: not a regression.
|
|
@@ -678,7 +681,10 @@ class FusionTestRunner:
|
|
|
678
681
|
last_typed = gr.action.action_type == "type"
|
|
679
682
|
recorded.append(record_action(gr.action, elements)) # placeholders, not values
|
|
680
683
|
last_action_screen = screen_text
|
|
681
|
-
|
|
684
|
+
# Which row the control was in ("Remove" near "Notebook × 1"):
|
|
685
|
+
# with repeated buttons, the model and the verifier can't
|
|
686
|
+
# otherwise tell what an action did.
|
|
687
|
+
action_str = _with_row(str(gr.action), gr.action, elements)
|
|
682
688
|
history.append(action_str) # LLM context — real value ok
|
|
683
689
|
safe_action_str = _redact(action_str)
|
|
684
690
|
step.actions.append(safe_action_str) # stored — secrets masked
|
|
@@ -738,6 +744,7 @@ class FusionTestRunner:
|
|
|
738
744
|
if checker is not None:
|
|
739
745
|
step.findings = checker.check(_safe, transitions)
|
|
740
746
|
step.token_usage += checker.last_token_usage
|
|
747
|
+
step.review = [d.to_dict() for d in getattr(checker, "last_decisions", [])]
|
|
741
748
|
|
|
742
749
|
step.duration_seconds = time.time() - start
|
|
743
750
|
return step
|
|
@@ -1211,6 +1218,18 @@ _PLACEHOLDER_HINT = (
|
|
|
1211
1218
|
)
|
|
1212
1219
|
|
|
1213
1220
|
|
|
1221
|
+
def _with_row(text: str, action: Action, elements: list[UIElement]) -> str:
|
|
1222
|
+
"""Add the row context of the action's element to str(action):
|
|
1223
|
+
'tap on "Remove"' -> 'tap on "Remove" near "Notebook × 1 $8.50"'."""
|
|
1224
|
+
element = next((e for e in elements if e.index == action.element_index), None)
|
|
1225
|
+
if element is None or not element.near or element.near == element.label:
|
|
1226
|
+
return text
|
|
1227
|
+
anchor = f'on "{action.element_label}"'
|
|
1228
|
+
if anchor not in text:
|
|
1229
|
+
return text
|
|
1230
|
+
return text.replace(anchor, f'{anchor} near "{element.near}"', 1)
|
|
1231
|
+
|
|
1232
|
+
|
|
1214
1233
|
def _action_text(action: Action, elements: list[UIElement]) -> str:
|
|
1215
1234
|
"""An executed action for the bug reviewer: control, row context and value."""
|
|
1216
1235
|
element = next((e for e in elements if e.index == action.element_index), None)
|
|
@@ -79,6 +79,23 @@ _PRESS_KEYS = {
|
|
|
79
79
|
# Upper bound for a model-requested "wait" action.
|
|
80
80
|
_MAX_WAIT_SECONDS = 10.0
|
|
81
81
|
|
|
82
|
+
# Waiting for the page to settle. "networkidle" never fires on many real sites
|
|
83
|
+
# (analytics, session replay, polling): measured on fusionleap.io it cost the
|
|
84
|
+
# full timeout on every navigation (10s) and action (3s). Instead, wait until
|
|
85
|
+
# the page's structure and text stop changing for _SETTLE_QUIET_MS. Attribute
|
|
86
|
+
# changes are ignored — CSS animations toggle them constantly.
|
|
87
|
+
_SETTLE_QUIET_MS = 500
|
|
88
|
+
_SETTLE_MAX_MS_NAVIGATE = 5000
|
|
89
|
+
_SETTLE_MAX_MS_ACTION = 3000
|
|
90
|
+
_SETTLE_JS = """([quietMs, maxMs]) => new Promise(resolve => {
|
|
91
|
+
let timer;
|
|
92
|
+
const done = () => { obs.disconnect(); clearTimeout(cap); resolve(); };
|
|
93
|
+
const obs = new MutationObserver(() => { clearTimeout(timer); timer = setTimeout(done, quietMs); });
|
|
94
|
+
obs.observe(document, {subtree: true, childList: true, characterData: true});
|
|
95
|
+
timer = setTimeout(done, quietMs);
|
|
96
|
+
const cap = setTimeout(done, maxMs);
|
|
97
|
+
})"""
|
|
98
|
+
|
|
82
99
|
|
|
83
100
|
# Invalid form fields after user interaction / a submit attempt (see
|
|
84
101
|
# PlaywrightAdapter._validation_messages).
|
|
@@ -250,11 +267,7 @@ class PlaywrightAdapter:
|
|
|
250
267
|
self._page = await context.new_page()
|
|
251
268
|
if url:
|
|
252
269
|
await self._page.goto(url, wait_until="domcontentloaded", timeout=60_000)
|
|
253
|
-
|
|
254
|
-
try:
|
|
255
|
-
await self._page.wait_for_load_state("networkidle", timeout=10_000)
|
|
256
|
-
except Exception:
|
|
257
|
-
pass
|
|
270
|
+
await self._settle(_SETTLE_MAX_MS_NAVIGATE)
|
|
258
271
|
|
|
259
272
|
logger.info(f"PlaywrightAdapter started (browser={self.browser_type}, electron={bool(self.electron_app_path)})")
|
|
260
273
|
|
|
@@ -384,10 +397,7 @@ class PlaywrightAdapter:
|
|
|
384
397
|
self._page = await context.new_page()
|
|
385
398
|
|
|
386
399
|
await self._page.goto(url, wait_until="domcontentloaded", timeout=60_000)
|
|
387
|
-
|
|
388
|
-
await self._page.wait_for_load_state("networkidle", timeout=10_000)
|
|
389
|
-
except Exception:
|
|
390
|
-
pass
|
|
400
|
+
await self._settle(_SETTLE_MAX_MS_NAVIGATE)
|
|
391
401
|
|
|
392
402
|
def get_screen(self) -> tuple[list[UIElement], str]:
|
|
393
403
|
if self._page is not None and self._page.is_closed():
|
|
@@ -654,10 +664,20 @@ class PlaywrightAdapter:
|
|
|
654
664
|
def execute(self, action: Action, elements: list[UIElement]) -> bool:
|
|
655
665
|
return self._run(self.async_execute(action, elements))
|
|
656
666
|
|
|
667
|
+
async def _settle(self, max_ms: int) -> None:
|
|
668
|
+
"""Best-effort wait for the page to load and its content to stop changing."""
|
|
669
|
+
for _ in range(2): # a click that navigates destroys the page mid-wait: retry once
|
|
670
|
+
try:
|
|
671
|
+
await self._page.wait_for_load_state("domcontentloaded", timeout=5000)
|
|
672
|
+
await self._page.evaluate(_SETTLE_JS, [_SETTLE_QUIET_MS, max_ms])
|
|
673
|
+
return
|
|
674
|
+
except Exception: # noqa: BLE001 — a page that won't settle is still usable
|
|
675
|
+
continue
|
|
676
|
+
|
|
657
677
|
async def async_execute(self, action: Action, elements: list[UIElement]) -> bool:
|
|
658
678
|
"""
|
|
659
679
|
Execute an action on the page. Returns True on success.
|
|
660
|
-
All actions wait for the page to settle (
|
|
680
|
+
All actions wait for the page to settle (see _settle).
|
|
661
681
|
"""
|
|
662
682
|
self._last_action = self._describe(action, elements)
|
|
663
683
|
try:
|
|
@@ -684,16 +704,7 @@ class PlaywrightAdapter:
|
|
|
684
704
|
else:
|
|
685
705
|
raise ValueError(f"unsupported action type {action.action_type!r}")
|
|
686
706
|
|
|
687
|
-
|
|
688
|
-
# networkidle as best-effort (SPAs often never reach networkidle)
|
|
689
|
-
try:
|
|
690
|
-
await self._page.wait_for_load_state("domcontentloaded", timeout=5000)
|
|
691
|
-
except Exception:
|
|
692
|
-
pass
|
|
693
|
-
try:
|
|
694
|
-
await self._page.wait_for_load_state("networkidle", timeout=3000)
|
|
695
|
-
except Exception:
|
|
696
|
-
pass # SPA pages often don't reach networkidle — that's OK
|
|
707
|
+
await self._settle(_SETTLE_MAX_MS_ACTION)
|
|
697
708
|
return True
|
|
698
709
|
|
|
699
710
|
except Exception as e:
|
|
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
|