Skip to content

Add package check --json, in the shape page check --json prints - #2684

Merged
max-sixty merged 3 commits into
mainfrom
package-check-json
Oct 12, 2026
Merged

max-sixty merged 3 commits into
mainfrom
package-check-json

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

leaf package check PACKAGE --render --json prints one object, in the shape page check --json prints (#2662):

  • status: the exit status.
  • findings: each finding as a record (code, at, values, severity, text).
  • browser: the gate asked for and the gates that ran, the browser that ran them, and unavailable with the reason where no browser ran.

Without --render it prints {"status": 0, "findings": [], "browser": null}. A package the package check refuses prints status 1 with the refusal as its one package error finding and a null browser, rather than an empty stdout. Without --json, the lines a reader sees are unchanged.

What changed

  • render_gate/command.py: widget_quality_report used to print as it read. It is now widget_quality(package) -> WidgetQuality, a record, plus print_widget_quality(check) for the lines. packages.cmd_package_check prints the lines or the JSON.
  • Worked examples that cannot be drawn become an unreadable-examples error finding (status 1), with the name of the browser that tried. Its words are the line the command printed before: Error: widget examples could not be drawn: ….
  • tests/journeys/test_widget_quality.py::test_package_check_render_reports_findings_as_advice reads codes, elements and first-paint boxes from --json instead of regex-parsing them out of the CLI lines. test_package_check_requires_a_non_empty_widget_description also reads the refusal from --json.
  • references/packages.md, "Seeing it", and the command's help name the flag.

Proof

  • Both tests pass by node id.
  • leaf package check skills/leaf/packages/code-review --render --json prints {"status": 0, "findings": [], "browser": {"asked": ["widget quality"], "ran": ["widget quality"], "browser": "Chrome"}}. Without --json, it prints the same two lines as before.

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

`leaf package check PACKAGE --render --json` prints one object: `status`,
each widget quality finding as a record (`code`, `at`, `values`,
`severity`, `text`), and `browser`, naming the gate asked for and run and
the browser that ran it, or why none could. Without `--render` it prints
the object with no findings and a null `browser`. Without `--json`, the
lines a reader sees are unchanged.

The command boundary now renders a `WidgetQuality` record rather than
printing as it reads. Worked examples that cannot be drawn become an
`unreadable-examples` error finding; its words are the line the command
printed before.

`test_package_check_render_reports_findings_as_advice` reads the records
from `--json` instead of regex-parsing first-paint sizes out of the lines.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@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.

--json still needs an object when package validation fails. check_package runs before the JSON branch, so a package whose registry.json contains { exits 1 with empty stdout and a plain stderr error. That breaks the promised status/findings result for a common check failure. Report the validation refusal as a finding and emit the JSON result on this path.

The unreadable-example result loses the browser that ran. widget_quality catches UnreadablePage after launch and constructs WidgetQuality with its default browser=None. Its JSON then says ran: ["widget quality"], browser: null, and gives no unavailable reason. Preserve the launched browser's name in this error result so the record identifies where the failed drawing happened.

…-json`

`package check --json` now prints its object when the package check
refuses the package, with the refusal as a `package` error finding and
status 1, rather than exiting with empty stdout. Examples that cannot be
drawn keep the name of the browser that tried to draw them. Without
`--json`, output is unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
leaf-agent previously approved these changes Oct 12, 2026
# Conflicts:
#	skills/leaf/scripts/leaf/findings.py
@max-sixty
max-sixty merged commit 5036100 into main Oct 12, 2026
3 checks passed
@max-sixty
max-sixty deleted the package-check-json branch October 12, 2026 23:22
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