Skip to content

feat(workers): report cause-agnostic failure-time facts (page state, prior anomalies) in failure JSON #55

Closed

Description

@jyotir-aditya

Problem

When a run fails, the JSON report gives a failure type and a templated fix_hint — but nothing about what was actually true on the page at failure time. Real agent feedback from a production debugging session:

The selector was correct — the element matched fine once a dialog was dismissed. Verfix already captures a DOM snapshot and screenshot on every failure, but nothing in the JSON summary flags "there's an open, viewport-covering dialog in this snapshot." I had to script-grep the raw .html snapshot myself.

We cannot enumerate every possible failure cause. But we can report cause-agnostic facts that are true for every failure — facts have no false positives, and an agent (or human) reading them can diagnose causes Verfix has never heard of.

Proposal

On any failed run, collect a small set of live-page facts right before artifact collection (workers/src/artifacts/collector.ts) and include them in each failure object in the JSON output as a new additive field, e.g. page_state:

  • current URL + page title
  • open dialogs/overlays: [role=dialog], [aria-modal=true], and any fixed/absolute full-viewport element with high z-index — with their accessible names (e.g. dialog "Welcome to Cleara")
  • a short accessibility-tree summary of visible interactive elements (buttons/links/inputs with accessible names, capped)
  • counts of non-excluded console errors and failed network requests that occurred earlier in the run (both logs already carry ISO timestamps)

Strictly facts, no interpretation ("a dialog was open", not "the dialog caused this"). Interpretation is a separate layer (see the analyzer-pipeline issue in the tracking issue).

Notes

  • Runs only on the failure path — passing runs pay zero cost.
  • Collected via page.evaluate while the page is live (computed styles/z-index are not recoverable from the saved static HTML).
  • The JSON output contract is stable and agent-facing — this must be additive only (new field, no renames). See CLAUDE.md.
  • Also persist the collected facts as a JSON artifact next to the existing console/network logs so verfix show can display them later.

Acceptance criteria

  • Failed runs include page_state (or similar) with URL, title, open dialogs/overlays, visible-element summary, prior console-error/failed-request counts
  • Passing runs are unchanged (no extra probes, no new fields required)
  • Facts also written to the run's artifact directory
  • cd cli && bash test/json-purity.sh still passes; existing JSON fields unchanged

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions