Skip to content

Have every lf-shot say how its pair differs, and outline where with outlines - #1385

Merged
max-sixty merged 19 commits into
mainfrom
lf-shot-diff-region
Sep 28, 2026
Merged

max-sixty merged 19 commits into
mainfrom
lf-shot-diff-region

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

A handoff page once shipped an lf-shot pair whose two sides matched in every part its prose described, under an alt claiming the thread card changed. Nothing on the page said so: a reader of one side of the divider, or an agent screenshotting the page, cannot tell where a pair differs, or that it differs nowhere. lf-shot now compares its two images and says so on its rail, and with outlines it also outlines each changed region on both frames.

What the reader sees

Every pair's rail reads "identical", "only slight changes" (no pixel moved far: a redrawn shadow, a small contrast shift, re-encoding), or "changed throughout" (strong changes over half the image or more, such as a photo turned black and white) when it has nothing to point at. The first two take the warning style, since they are what a handoff gets wrong. A pair with outlines also outlines each region that changed, over both frames at the same place, and the rail counts them ("3 changed areas"). The motivating pair now reads "only slight changes": its thread card differed only by a shadow redrawn by 1–9 levels.

outlines is a boolean attribute, coded positively like collapsed and multiple; packages.md ("A widget") now states that rule for widget flags. authoring-evidence.md tells an author to add it and check an outline stands where the prose puts the change; to leave it off where most outlines would mark what the pair is not about, such as live data between captures that cannot be retaken; and, for a pair reading "only slight changes", to name the change in the prose.

The rule and its one home

skills/leaf/assets/runtime/image-difference.js owns what counts as a difference, with its measurements in the header: a pixel differs on any channel, alpha included; 8px squares where some pixel moved 48+ levels are strong, and strong squares within 3 squares join into one region; a slight square joins only as a strong region's edge. differenceKind and describeDifference give the reading its kind and its words. leaf-dev stills loads the same module into its browser and crops each changed state to the union of its regions, so the widget and the stills tool cannot disagree.

Visual review sets outlines on the shots it builds, states the reading in its case line ("Case 1 of 3 · Changed · 4 changed areas (1 outside the focus)"), and hides the marks on its focus crop, whose coordinates they do not share.

Fixed on the way

  • media.js read node.matches on anything in a click's path, and an element with id="matches" made window.matches a node without the method, so a click threw.
  • A composed-tree climb took a detached <a> subtree's root host (its URL's host name) for a node and threw on getRootNode. Main's shadowHost(root) (Stop composed tree walks at the document root #1376) covers it; tests/runtime/shadow-climb.test.mjs pins the <a> case and anchor-controls.js now uses the same helper.

Measured

Guidance A/Bs, ×3 runs per arm, both arms run together:

  • evals/shot-pair-outlined (a header-only change, kept): against this branch's earlier wording, where every pair drew outlines unless it set no-outlines, 0 of 3 base runs wrote outlines and 3 of 3 candidate runs did; the judgment passed in both arms, so it measures that the guidance names the attribute a page now needs. shot-pair-live-data (a header restyle over live data that cannot be recaptured) ran as the guardrail: every run in both arms left the pair without outlines, the base with no-outlines, so it no longer told the wordings apart and was dropped. Two candidate runs failed its regex only by nesting the images inside lf-shot, since the eval's child cannot read the registry. $4.46.
  • The no-outlines wording, against the branch before it: shot-pair-live-data went from 0 of 3 to 3 of 3, every base run already pointing its prose at the header but having no attribute to set; shot-pair-differs and shot-pair-matches held, and no run put the flag on them. $6.75, plus $6.78 for a first draft named unmarked that also hid the "identical" reading (0 to 2 of 3).
  • Replacing authoring-evidence.md's "a screenshot of the page cannot show that the two sides match" with the rail's reading: no change on shot-pair-matches (3 of 3 both arms) or shot-pair-differs (2 of 3 both), since the cold cases never render a page. $3.35. Main has since dropped both cases (Drop the five eval cases that never told two wordings apart #1382).

The pixel rule, on the thread-card pair: redrawn shadows moved at most 20 levels (mostly 1), an 8% contrast change 17, palette quantization 35, the grown card 227. Text going from #333 to #555 moves 34 levels, so it reads "only slight changes" with no outline, and the guidance has the author name such a change in the prose. Node timings: 2880×1800 all changed 64ms, 2880×8000 192ms, one pair per frame after presentation.

The everyday gate passes: 1426 of 1428 on the last full run, whose two test_interact_contract.py failures (a preview's contract, a revendoring race) pass on rerun, alone and as a file, and touch nothing here; 169 runtime tests. Two nightly render tests fail on this branch and on its merge base: test_visual_review_gallery_gives_a_laptop_to_the_evidence and test_the_versions_menu_uses_the_banner_panel_and_its_doors_edge.

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

🤖 Generated with Claude Code

max-sixty and others added 17 commits September 27, 2026 14:16
A handoff page shipped an lf-shot whose before and after were the same picture
in every part its prose described. The page shows each spot from one side of the
divider, so neither its author nor a screenshot of the page could tell.

Once the page presents, lf-shot now compares its two images pixel for pixel and
outlines each changed region over both frames, at the same place, and the rail
between the labels counts the regions or reads "identical". The rule for what
counts as a difference, and how changed pixels gather into regions, lives in one
runtime module, `runtime/image-difference.js`, exported through widget-api as
`compareImages`. It imports nothing, so `scripts/stills.py` loads it into its
browser and crops each changed state to the union of the same regions, in place
of its own PIL mask; its diff.png outlines the regions instead of painting
pixels.

visual-review's compare mode offsets the marks below its frame labels and hides
them on a focus crop, which shows another part of the frame.

authoring-evidence.md no longer says a screenshot of the page cannot show that
two sides match; it says to check that the outlines stand where the prose puts
the change.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
lf-shot exposes its reading as `difference`, a promise of the regions or null for
a refused pair. visual-review hides the rail outside Flip and opens each case on
its focus crop, so a focus authored on an area that did not change showed no
outline and no count. The case's position line now states the reading in every
view ("5 changed areas, 2 outside the focus", or "identical"). The focus crop
still hides the outlines: drawn in crop coordinates they stand outside the frame
that clips them, which the render gate rightly reads as boxes the user can't see.

Pairs compare one per frame, so a visual-review run of large captures does not
hold input in one long task after presentation. A shot disconnected at
presentation still gets its marks.

The feature gallery's shot scenario names the outlines and count, and a second
pair shows the "identical" reading. The eval record notes the unchanged A/B for
the guidance edit.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…click's path

A pair whose sides differ by a contrast or palette shift, lossy encoding, or a
redrawn shadow edge differs in nearly every pixel by a few levels, so the exact
rule outlined the whole frame, and a real change beside that noise merged into
one frame-sized region. Measured on the thread card pair: its shadow edges moved
by at most 20 levels, an 8% contrast change by 17, palette quantization by 35,
and the card that grew by 227.

A region is now faint when no pixel in it moved 48 levels in any channel.
Strong cells join first, faint cells beside a strong change join it as its edge,
and the faint cells left join only one another, so noise never merges a real
change into the frame. A region inside another of its kind is dropped.
`describeDifference`, beside the rule, says what the regions add up to ("1
changed area, faint throughout", "2 faint changes", "identical"), and both
lf-shot's rail and visual-review's position line use it; the latter counts only
visible changes outside the focus. lf-shot dashes a faint outline; stills.py
draws one paler.

media.js asked every node in a click's composed path for `matches`, which ends
at the window, where an element with `id="matches"` stands in for the method. A
page with a "matches" section threw on every click; it now asks only elements.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…hroughout" by area

Review of the faint/visible split found the containment filter dropping real
changes: it compared bounding boxes, so a strong region inside another strong
region's box (a button inside a restyled header-and-sidebar L, or the 3x2 change
the visual-review gallery has outside its focus) vanished, and "throughout" was
read off the box too, so a thin border ring counted as the whole image.

A strong region is never dropped now; only a slight region inside a larger box
is, and the check walks larger boxes first, so a page of equal specks compares
none. "Throughout" means the region's squares cover half the image's. "Faint"
claimed a perception the rule does not measure (text from #333 to #555 moves 34
levels and is plainly visible), so the kind is `slight` and the docs say how far
pixels moved rather than what a reader sees. The symmetric joins scan only later
neighbours without allocating, and a square stops measuring once it is strong:
2880x1800 all-changed went from 159 to 87 ms in Node.

visual-review puts "(N outside the focus)" beside the description it qualifies,
which the gallery's case 1 exercises again. stills.py crops to the strong
regions when there are any.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	dev/leaf_dev/stills.py
# Conflicts:
#	dev/leaf_dev/stills.py
… top

The thread card pair drew a dashed outline around the top of the card, where the
only difference is its shadow redrawn by 1 level in most pixels and 9 at most: an
outline there sends the reader to look for a change nobody can see. And a colour
image turned black and white read as three strong regions around its most
saturated parts, when the change is the whole image.

A region is now drawn only around pixels that moved 48 levels; slight squares
join a drawn region as its edge and are otherwise left out, so there is no
second kind of outline. Where strong squares cover half the image, the reading is
`throughout` and names no regions. The rail reads a count, "changed
throughout", "only slight changes", or "identical", and visual-review's position
line and stills.py follow the same reading.

While the preview page was open, a click threw `getRootNode is not a function`
from `upFrom`, and the Leaves tray tests failed with the same error on main.
`upFrom` took `getRootNode().host` for a shadow host, but the root of a detached
subtree is an element, and an `<a>` answers `host` with its URL's host name.
`shadowHost` in shadow.js answers only for a shadow root, by node type so a
sample frame's root counts, and every climb that read `.host` uses it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	evals/README.md
A pair captured over live data outlines every figure that moved, and the
one change the prose is about becomes one outline in ten. `unmarked` hides
the outlines and the rail's reading in CSS, so a revision turns them off
and on in place; the widget still compares the pair and `difference` still
settles. authoring-evidence.md says when to set it, and
shot-pair-live-data scores that (0 of 3 to 2 of 3); shot-pair-differs now
fails an unmarked pair. The shot test also checks the attribute hides and
restores both.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	evals/README.md
#	skills/leaf/assets/runtime/passages.js
#	skills/leaf/assets/runtime/shadow.js
`unmarked` read as Leaf's passage marks, and it hid the rail's reading
with the outlines, so a pair marked over live data whose change never
took hid the "identical" that would have caught it. `no-outlines` hides
the outlines and the count they make up; "identical", "only slight
changes" and "changed throughout" stay on the rail.

The rail's reading now carries its kind, from image-difference.js's
`differenceKind`, which `describeDifference` words. The kind attribute
had written "identical" for every reading without regions, so "changed
throughout" took the warning style; the warning now marks "identical"
and "only slight changes", the two with nothing to point at.

A revision replaces an upgraded shot whose attributes changed, so the
widget header no longer claims the switch turns in place, and the test
checks the attribute at load rather than removing it live.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	evals/shot-pair-differs/case.yaml
…tively

A boolean attribute can only say "present", so `no-outlines` named the
feature by its absence, unlike every other widget flag (`collapsed`,
`multiple`, `review`). A shot now outlines its changed regions, and counts
them on its rail, only with `outlines`; without it, the rail still reads
"identical", "only slight changes" or "changed throughout", so a pair with
nothing to point at says so on every page. packages.md states the rule:
a flag names what its presence turns on, and the default is its absence.

Visual review sets `outlines` on the shots it builds, keeping its marks.
authoring-evidence.md now tells an author to add `outlines`, and to leave
it off where most outlines would mark what the pair is not about. The
gallery shows one pair with and without it, and an identical pair; the
shot test reads the default and the flag.

shot-pair-outlined (a header-only change) is added for the new clause;
shot-pair-live-data now fails a pair that asks for outlines.

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

authoring-evidence.md sent a pair reading "only slight changes" to be
recaptured or disowned, which is wrong for a deliberate small edit such as
a contrast fix; the author now names the change in the prose, or says only
redrawing changed. The shot test now reads "only slight changes" as well as
"identical" on a pair without `outlines`.

evals/README.md was removed on main (#1371), and this branch's merges had
brought it back; its rows for this branch go in the PR description. The
outlined case's comment now says the base had no attribute to write, and its
regex skips quoted attribute values. Comments that still said every pair
draws outlines, the registry's doubled citation, and packages.md's flag rule
("what its presence means", which also covers state flags) are corrected.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty max-sixty changed the title Say on every lf-shot where its pair differs, and outline the changes with outlines Have every lf-shot say how its pair differs, and outline where with outlines Sep 28, 2026
leaf-agent
leaf-agent previously approved these changes Sep 28, 2026

@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 lint check fails because Prettier rewrites the new gallery paragraph. The suggested wrapping matches the CI output; until it is committed, this head cannot pass the required lint check.

Comment thread examples/developer/feature-gallery.html Resolved
@leaf-agent
leaf-agent dismissed their stale review September 28, 2026 07:20

CI lint failed: Prettier rewrites the new gallery paragraph.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
leaf-agent previously approved these changes Sep 28, 2026
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 03efab7 into main Sep 28, 2026
5 checks passed
@max-sixty
max-sixty deleted the lf-shot-diff-region branch September 28, 2026 08:00
max-sixty added a commit that referenced this pull request Sep 28, 2026
Much of `leaf_dev` was written in one day by agents whose reviewers
hunted for every way a verdict could be wrong. Each finding became more
code: extra states, extra flags, signal handling, and docstrings that
list edge cases. This cuts that back across the package. Where a guard
stays, it stops a silent false green; the rest goes, since whoever reads
a command's output can read a log.

It removes 3,817 lines and adds 1,055.

## What each command does now

- **`ci-failures [REF]`** prints `clear` (exit 0) only when every failed
branch job failed only with pytest ids that also fail in the same job on
the merge base with the local `main`. Anything else is `not clear` (exit
1), listed with the branch and base links for each job:
  - a step with no ids
  - a missing report
  - a cancelled or still-running job
  - no base run

These are gone: step-name matching, the ranked job states, and `--run`.
A job the queue cancelled before it got a runner reads `cancelled before
a runner`. `ci.yaml`'s job-named report artifacts stay.
- **`bugback NODEID...`** has one mode, and node ids are required. It
reverts every path outside `tests/`, `dev/`, the manifests and the locks
to the merge base, in a scratch worktree at HEAD. It runs the ids before
and after the revert and reports `caught` or `blind` for each. Committed
bundles revert with their sources, so it no longer rebuilds them. These
are gone:
  - `--flip` and `--base`
  - automatic test selection
  - generator rebuilds
  - `npm ci`
  - `sweep()`

It still refuses a selection that collects nothing, and it still reads
each test's outcome from a report rather than the terminal.
- **`suite.py`** reads outcomes from pytest's own `--junitxml`, so
pytest-reportlog is no longer a dependency. `ci-failures` shares its
junit reader. The outcomes are passed, failed, error, skipped and not
run. When a test's call fails and its teardown also errors, the call's
failure is what's reported. This matters because `clean_browser()`
asserts at teardown after every browser test. Ctrl-C reaches pytest the
way it does in a terminal. These are gone:
  - the SIGINT→GRACE→SIGKILL process-group machinery and `stoppable()`
  - the 20-minute timeout
  - re-collecting a broken tree leniently
- **`flake`** no longer voids a run when the tree is edited mid-run,
since that failure shows as red rather than as a false green. Its table
counts every outcome.
- **`bench-check`** reports each arm's wall time as median (min–max),
alternating the arms. The in-process `sys.monitoring` tracer
(`tracer/traced_leaf.py`) and its phase and CPU tables are gone.
`leaf-dev profile` says where a browser transition spends its time.
- **`delivery-ab`** no longer runs the `/api/state` sampler thread or
the banner metrics built on it (`quiet`/`late`). It reports each
comment's route, and its woken, pickup, claim, reply, done and turn
times.
- **`guidance-ab`** no longer has a SIGTERM handler or process-group
killing.
- **`probe`** keeps `press`, `click`, `focus` and `drive`, the steps
sessions use. `hover`, `scroll`, `wait`, `type` and `--dark` are gone.
`--shot` captures the viewport.
- **`stills`** no longer writes its HTML report. It prints each changed
or failed state, and it keeps #1385's region reading through
`image-difference.js`.
- **`site`**:
- `--serve` is gone; `npm run dev --prefix worker` builds and serves the
site.
  - It drops guards for inputs no caller produces.
- It reuses `harness.environment()` and
`page_fixtures.package_selection_args`.
- **`record-demo`** stages in a temporary directory, uses
`browser.chrome()`, and folds `record_demo_browser.js` into one inline
evaluate.
- **`verify-site`** reads the host's addresses with
`psutil.net_if_addrs()` rather than parsing `ip -j`, so the `wrangler`
pass also runs on a Mac. It launches Chrome through `browser.chrome()`.
These are gone:
  - the classifier for replies that never drew
  - the requested-vs-built release check
  - the human-readable timing printout

Every check between a broken release and production stays.
`publish-site` now also deploys when `browser.py` changes.
- **`preview`** no longer confirms the checkout with a `--root` call,
caps slot names at 64 characters, or holds the slot-discard lock. A
runtime edit still leaves an agent's own revision of a `--user` preview
alone, and a fixture edit over such a revision is still refused.
- **`harness`** no longer has `loaded_memory`. The isolated home and
`CLAUDE_CODE_DISABLE_AUTO_MEMORY` already rule auto-memory out.

`dev/AGENTS.md`, `tests/AGENTS.md`, the `developing-leaf` and
`running-tend` skills, and `TODO.md` now describe the commands as they
are. `test_website_server.py`'s stand-in obligations are keyed by
`input`, the field the code reads, so the deploy gate's not-working and
dropped cases now reach the check.

## Checks

- **Each changed command, run for real:**
- `bugback` read a real fix's test as caught and an unrelated test as
blind.
- `flake` ran 18 copies of each of `test_read_state.py`'s 4 tests; every
copy passed.
- `ci-failures` ran on a red main commit, three red PR heads, three
green PR heads, and a main commit whose nightly was cancelled before it
got a runner.
  - `bench-check`, `bench-latency` and `profile` each completed a run.
  - `probe` ran on both arms; a failing step was named.
- `stills` read 15 of 15 states unchanged against main, and 5 changed
against `39fe35ce1^`, with crops and outlines.
  - `site` built the same file list as the base.
  - `record-demo` produced stills pixel-identical to the base's.
  - `fetch-previews` downloaded previews identical to the base's.
  - `verify-site` ran a release pass against https://leaf.page.
  - `corpus` and `keydocs` reproduce the committed files.
- **Not run:** `delivery-ab` and `guidance-ab`, whose children cost
money, and `verify-site wrangler`, since Docker here can't pull images.
- **Tests:**
  - pre-commit passes on every changed file.
- These all pass: `tests/test_website_server.py` and
`tests/test_interact_preview.py` (105 tests), and
`tests/test_interact_product.py`, `tests/test_product_page.py` and
`tests/test_interact_document.py`.
- Of `tests/test_site.py`, all but three pass. The three are layout
tests, and they fail the same way on main's nightly:
    - `test_published_product_page_renders[event-log]`
    - `test_published_product_page_renders[examples]`
-
`test_the_public_catalog_paints_in_its_final_position_before_leaf_loads`
- The nightly preview tests
`test_a_failed_preview_bootstrap_hears_the_replacement_server[*]` fail
with main's `preview.py` swapped in too, and on main's nightly
(3421114).

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

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

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