Skip to content

Collect the suite's browser problems as records, and the health sensors' as data - #2691

Closed
max-sixty wants to merge 2 commits into
package-check-jsonfrom
browser-problem-records
Closed

max-sixty wants to merge 2 commits into
package-check-jsonfrom
browser-problem-records

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

The browser fixture's per-page problem list (page.lf_errors) now holds Finding records (leaf/findings.py, #2662) instead of sentences. Tests read the records by field, and render text only in a failing assertion's message. This is the second follow-up #2662 named. Stacked on #2684 (package check --json, the third follow-up); this PR retargets to main once that merges.

Before and after: one harness entry

A refused event POST, before:

"400 http://127.0.0.1:53111/api/event"

matched by consume_browser_errors(page, "400"), which read a leading 400 . After:

Finding(code="failed-load", values={"status": 400, "url": "http://127.0.0.1:53111/api/event"})

matched by consume_browser_errors(page, {"code": "failed-load", "status": 400}).

A health sensor's report, before, a console sentence that shift_evidence split the JSON back out of:

button#control moved without input by (0, 40)px
shift evidence: {"kind": "passive", "node": "button#control", "comparisons": [...]}

After, a record the shift watch hands over through a binding, which str() still words as above:

Finding(code="moved-without-input",
        values={"node": "button#control", "by": [0, 40], "beside": [],
                "evidence": {"kind": "passive", "node": "button#control", "comparisons": [...]}})

What changed

  • Playwright's events. watched() keeps the record console_finding, window_finding and exception_finding already built, rather than str() of it. These are the same readers the render gate uses. A console entry's record also carries the script that wrote it (url). A recurring ResizeObserver notice is that notice's record with confirmation: "recurred", as the gate reports it, and RECURRING_RESIZE_NOTICE is gone.
  • Sensors hand over data. write_watch.js, shift_watch.js and words_watch.js call a __leafWatchFinding binding with {code, ...values}. Before, they wrote sentences to the console. The new codes are moved-without-input, typing-moved, shift-watch-missed, unchanged-write and words-left-screen. Their words live in leaf/findings.py and are the sentences the sensors used to print. Shift evidence is the evidence field, and shift_evidence() reads it directly.
  • Matching. render_harness.is_problem is the one matcher behind consume_browser_errors and reported_browser_errors. It accepts three forms:
    • a dict {code, ...fields}, each field compared by equality;
    • a function of the record;
    • a string, a fragment of the first line of what the page itself said (said()), for console entries, exceptions and window errors.
      The digit-prefix rule (_names) is gone. Every fragment check over a harness or sensor sentence is now a field check: HTTP statuses, shift nodes and offsets, typed words and their field, unchanged writes. The shift tests' moved_within(place) and names_move read the watch's node names, which place a text node or a shadow-tree node inside its element (#text in button#control). The old substring checks relied on that.
  • Other collectors. collect_page_errors and collect_page_exceptions collect records. The gate's own page-error listener uses collect_page_exceptions. leaf-dev probe, the site verifier, leaf-dev journey, the example previews and the arrangement gate print the records' words where they output, so their output is unchanged.
  • tests/journeys/test_render_commands.py::test_plain_check_reports_page_request_failures_but_ignores_optional_assets still called .startswith on run_page_code's records, which have been Findings since Report render-gate and page-check findings as records, with page check --json #2662. It now reads their fields.
  • tests/AGENTS.md, "Browser errors", says how to name an expected problem.

No user-visible behaviour changes.

Proof

  • Every browser-tier test whose source this changes, by node ID: 422 passed. The touched journeys-tier tests: 48 passed and 4 failed. The 4 failures fail the same way on the base commit, run in a throwaway checkout: test_message_delivery_appearance_and_first_frame[panel*] (appearance changed in the pending states) and test_an_authenticated_navigation_journey_becomes_credential_free_review_evidence (Threads dialog not visible after g Shift+t).
  • tests/browser/test_website_server.py and test_html_control_uses_browser_without_leaf_payload pass. The latter fails only when it shares an xdist worker with a browser-fixture test ("Sync API inside the asyncio loop"), independent of this change.

Left for a follow-up

  • The sensors still name a node with a string grammar (#text in div.cm-line in shadow of leaf-text#field), which moved_within reads by suffix. Reporting the node's element and shadow host as fields would remove that last parse.

This was written by Claude Code on behalf of max-sixty

max-sixty and others added 2 commits October 12, 2026 16:03
…rs' as data

The browser fixture's per-page problem list (`page.lf_errors`) now holds
`Finding` records (`render_gate/findings.py`) instead of sentences: the
console entries, failed responses, exceptions and window errors it takes
from Playwright's events, as the render gate takes them, and the health
sensors' findings. `write_watch.js`, `shift_watch.js` and `words_watch.js`
hand each finding over through a `__leafWatchFinding` binding as
`{code, ...values}`. They no longer write a sentence to the console, and
the shift watch's evidence travels as a field, not as `shift evidence:
{json}` inside one. The sensors' codes are `moved-without-input`,
`typing-moved`, `shift-watch-missed`, `unchanged-write` and
`words-left-screen`, and their words, written once in the findings
module, are the sentences the sensors used to print. A console entry's
record also carries the script that wrote it (`url`).

Tests name an expected problem by its fields, `{"code": "failed-load",
"status": 400}` or a function of the record, or by a fragment of what the
page itself said (`render_harness.is_problem`). The fragment checks over
the harness's and sensors' sentences, about 140 of them, are now field
checks. A recurring ResizeObserver notice is the notice's record with
`confirmation: recurred`, as the gate reports it. `collect_page_errors`
and `collect_page_exceptions` collect records, and `leaf-dev probe`,
`verify-site`, the journey and the example previews render them at their
output. A failing test prints each problem in its words.

No user-visible behaviour changes. `leaf-dev probe`'s `errors` and the
verifier's messages print the same words as before.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	skills/leaf/scripts/leaf/findings.py
#	tests/render_harness.py

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code review found no issue. The PR description says this branch is stacked on #2684 and will be retargeted to main after that merges. I’m withholding approval until that dependency lands and the resulting PR is ready to merge.

@max-sixty
max-sixty deleted the branch package-check-json October 12, 2026 23:22
@max-sixty max-sixty closed this Oct 12, 2026
max-sixty added a commit that referenced this pull request Oct 13, 2026
…rs' as data (#2694)

The browser fixture's per-page problem list (`page.lf_errors`) now holds
`Finding` records (`leaf/findings.py`, #2662) instead of sentences.
Tests read the records by field, and render text only in a failing
assertion's message. This is the second follow-up #2662 named. The
third, `package check --json`, landed in #2684. This replaces #2691,
which closed when its stacked base branch was deleted.

## Before and after: one harness entry

A refused event POST, before:

```python
"400 http://127.0.0.1:53111/api/event"
```

matched by `consume_browser_errors(page, "400")`, which read a leading
`400 `. After:

```python
Finding(code="failed-load", values={"status": 400, "url": "http://127.0.0.1:53111/api/event"})
```

matched by `consume_browser_errors(page, {"code": "failed-load",
"status": 400})`.

A health sensor's report, before, a console sentence that
`shift_evidence` split the JSON back out of:

```
button#control moved without input by (0, 40)px
shift evidence: {"kind": "passive", "node": "button#control", "comparisons": [...]}
```

After, a record the shift watch hands over through a binding, which
`str()` still words as above:

```python
Finding(code="moved-without-input",
        values={"node": "button#control", "by": [0, 40], "beside": [],
                "evidence": {"kind": "passive", "node": "button#control", "comparisons": [...]}})
```

## What changed

- **Playwright's events.** `watched()` keeps the record
`console_finding`, `window_finding` and `exception_finding` already
built, rather than `str()` of it. These are the same readers the render
gate uses. A console entry's record also carries the script that wrote
it (`url`). A recurring ResizeObserver notice is that notice's record
with `confirmation: "recurred"`, as the gate reports it, and
`RECURRING_RESIZE_NOTICE` is gone.
- **Sensors hand over data.** `write_watch.js`, `shift_watch.js` and
`words_watch.js` call a `__leafWatchFinding` binding with `{code,
...values}`. Before, they wrote sentences to the console. The new codes
are `moved-without-input`, `typing-moved`, `shift-watch-missed`,
`unchanged-write` and `words-left-screen`. Their words live in
`leaf/findings.py` and are the sentences the sensors used to print.
Shift evidence is the `evidence` field, and `shift_evidence()` reads it
directly.
- **Matching.** `render_harness.is_problem` is the one matcher behind
`consume_browser_errors` and `reported_browser_errors`. It accepts three
forms:
  - a dict `{code, ...fields}`, each field compared by equality;
  - a function of the record;
- a string, a fragment of the first line of what the page itself said
(`said()`), for console entries, exceptions and window errors.
The digit-prefix rule (`_names`) is gone. Every fragment check over a
harness or sensor sentence is now a field check: HTTP statuses, shift
nodes and offsets, typed words and their field, unchanged writes. The
shift tests' `moved_within(place)` and `names_move` read the watch's
node names, which place a text node or a shadow-tree node inside its
element (`#text in button#control`). The old substring checks relied on
that.
- **Other collectors.** `collect_page_errors` and
`collect_page_exceptions` collect records. The gate's own page-error
listener uses `collect_page_exceptions`. `leaf-dev probe`, the site
verifier, `leaf-dev journey`, the example previews and the arrangement
gate print the records' words where they output, so their output is
unchanged.
-
`tests/journeys/test_render_commands.py::test_plain_check_reports_page_request_failures_but_ignores_optional_assets`
still called `.startswith` on `run_page_code`'s records, which have been
`Finding`s since #2662. It now reads their fields.
- `tests/AGENTS.md`, "Browser errors", says how to name an expected
problem.

No user-visible behaviour changes.

## Proof

- Every browser-tier test whose source this changes, by node ID: 422
passed. The touched journeys-tier tests: 48 passed and 4 failed.
`test_message_delivery_appearance_and_first_frame[panel*]` (appearance
changed in the pending states, a macOS image comparison) fails the same
way on the base commit, run in a throwaway checkout.
`test_an_authenticated_navigation_journey_becomes_credential_free_review_evidence`
also failed on the base: it asserted `get_by_role("dialog")` visible,
which resolves to the 0x0 `.lf-auxiliary-envelope`. It now reads the
`Threads` region inside the envelope, and passes.
- `tests/model/test_chrome_contracts.py` passes; its fake page now holds
records too.
- `tests/browser/test_website_server.py` and
`test_html_control_uses_browser_without_leaf_payload` pass. The latter
fails only when it shares an xdist worker with a browser-fixture test
("Sync API inside the asyncio loop"), independent of this change.

## Left for a follow-up

- The sensors still name a node with a string grammar (`#text in
div.cm-line in shadow of leaf-text#field`), which `moved_within` reads
by suffix. Reporting the node's element and shadow host as fields would
remove that last parse.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants