Repository navigation
Move the before/after image reading into the default package - #3927
Merged
Merged
Conversation
Survey prototype. image-difference.js moves from browser/runtime/ to packages/default/widgets/, imported by lf-shot alone; widget-api.js stops re-exporting its five names, and module-reading.md drops their section. lf-shot's difference reading carries its own description, which lf-visual-review shows instead of calling describeDifference itself. leaf-dev stills and the runtime test load the module from its new path. The kernel's widget-api bundle, which every page that upgrades a widget loads, drops from 38,327 to 19,855 bytes (12,140 to 6,193 gzipped). A page with lf-shot loads the module as one more request instead. What package authors lose: compareImages, compareImagePixels, describeDifference, differenceKind and countAreas leave the public widget API. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…of-core # Conflicts: # dist/kernel/kernel.json
Pages vendored at 24 have an lf-shot that imports compareImages, compareImagePixels and describeDifference from /runtime/widget-api.js, which no longer exports them, so they are refused until re-vendored. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
previously approved these changes
Oct 25, 2026
BlazeDiff and density-clustering serve only image-difference.js, which now lives in the default package, so their bundles move from the core vendor directory to the package's. A page still imports them at /vendor/, which the composed layer answers. leaf-dev stills serves /vendor/ from the default package for the same reason. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Oct 25, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 25, 2026
`leaf-dev stills` couldn't compare base and candidate on a pull request that bumps the page protocol, such as #3927 (24 to 25): every state built on a seeded example (review-a-plan, ship-review, log-retention) failed on the arm whose protocol differs from the checkout's. `page_fixtures._acknowledge_seed` wrote the seed's receipt in-process with the checkout's Leaf, whose admission refuses a page vendored at another protocol: ``` failed plan on base: …/base-plan/page was vendored at page protocol 25 by a newer Leaf …, and this Leaf … speaks protocol 24 ``` ## The fix A `PageFixture` now keeps the runtime and environment `read_fixture` was given, which already chose each arm's package producers and data contracts. `_acknowledge_seed` runs the receipt with that runtime's own Python (`uv run --no-dev --project <runtime>`, as `bin/leaf` does), so the arm that vendored the page admits its receipt, in its own event shape. A fixture read for the checkout, as the render harness's are, now runs the same few lines in a subprocess of the checkout's project: one more subprocess beside the `page init`, `stamp` and `open` calls preparation already makes, and only for a seeded fixture. `leaf-dev preview` reads fixtures for a selected runtime the same way, so its paired previews across a bump get the same fix. ## Checks - `uv run leaf-dev stills origin/image-difference-out-of-core --state plan`, run from a checkout at protocol 24: the base arm failed with the refusal above before the change, and both arms now capture ("1 of 1 states unchanged"). - New dev test `test_a_fixture_acknowledges_its_seed_with_the_runtime_it_was_read_for` builds a seeded example with an extracted payload whose protocol is one ahead and checks that the log ends with the seed's receipt. It fails on main with `EventRefused`. - `test_fixture_captures_use_the_selected_runtime_producer` (both parametrizations), `test_page_fixture_renders[review-a-plan]` and `[ship-review]`, and pre-commit on the changed files pass. > _This was written by Claude Code on behalf of max-sixty_ Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
added a commit
that referenced
this pull request
Nov 22, 2026
This week's duplicate sweep of `dev/`, `build/`, `tests/` and `worker/` (week 47) moves six duplicated helpers onto one home each and moves every caller. Behavior stays the same. The touched model tests, the dev js_facts tests and the Worker's routing, storage and index tests pass. A script compared the old and new outputs of the consolidated `leaf_dev` functions and the seeded-log reads across the corpus, and they match. | Question | Home | Copies removed (introducing PR) | |---|---|---| | Which stylesheets do the core and the bundled packages ship, leaving out vendored files? | new `interact_support.shipped_sheets` | `sheets()` in `test_interface_fonts.py` (#4804) and `test_theme_tokens.py` (#6025). Five inline loops in `test_interact_layer.py` (#3138, #3886) | | Run `tests/js_facts.mjs` | `interact_support.js_facts` (#2666) | its own subprocess call in `dev/tests/test_js_facts.py` (#5118) | | Lowercase hex of bytes in the Worker | `routing.hex`, which is `newSessionId` (#313) renamed, plus a `sha256Hex` in `storage.ts` | the publication-identity and chunk-digest copies in `storage.ts` (#2652) | | Is this pid alive? | `leaf.machine.pid_alive` | `_alive` in `tests/process/test_codex_tool.py` (#3331). `running()` in `test_interact_layer.py` (#1774) | | Read an example's seeded log | `read_event_lines(seed_log(source))` (#4484) | inline parsers in `test_render_pages.py`, `test_interact_product.py` (#924) and `test_render_gate.py` (#509). The last one split lines with `splitlines()`, which also breaks at U+2028 | | Paths of the bundled registries and packages; which registry keys name elements | `leaf.schema.ASSETS` / `BUNDLED_PACKAGES` / `DEFAULT_PACKAGE`, `leaf.registry.contract.is_element_name`, `docs.registries()` | `docs.py`'s own `ASSETS`/`PACKAGES` (#3593) and its `startswith("lf-")` checks (#2660). `logs usage`'s hand-written regex and registry list (#5970). `ROOT / "packages" / "default"` in `stills.py` (#3927) and `test_product_page.py` (#3593) | `is_element_name` and the two checks it replaces give the same answer for every key in the bundled registries today. A selector key such as `lf-options.selected` would have passed the `lf-` prefix test. <details><summary>Sets found and left alone</summary> - **Sets an open PR is changing.** Nothing in this diff overlaps another open PR's hunks. #6732 moves tests out of `test_render_gate.py`, `test_render_pages.py` and `test_interact_layer.py`, but none of the tests changed here. - **Changes to browser tests with nothing run to check them.** The WCAG contrast computation exists as about 11 copies across browser, journey and model tests. Other copies: about 9 `EDITOR_ROOTS` shadow-root keepers, the `/api/interaction` batch predicates, CDP `touch()` closures, one-line patch templates, reply-holding route handlers, and the `data-lf-entry` runtime-module import snippet in `dev/leaf_dev/states.py` and in tests. Each would mean editing browser tests that this sweep can't run on a shared host. They suit a sweep that can run those tests. - **Vendor bundling.** `build/browser/build.mjs` builds signals-core and Lit with esbuild calls that repeat `build/vendor.mjs`'s `bundle()`. Merging them changes build options and needs a full `check:browser` byte comparison, so it was left for a change that runs that. - **Copies that are near but not the same.** `_build.py`'s `check_links` repeats `leaf_website.released_path`, but it also needs the matched page's root and kind. The list of API-key variables an eval drops is repeated across Python and the Promptfoo configs, as subsets and supersets of one another. The Codex token-expiry check has different thresholds, 1 h and 60 s. - **Too small to be worth it.** Picking a free loopback port (`eval_user.py`, `interact_support.available_loopback_port`). The XDG state root in `leaf_dev.state_home` and `leaf.state.state_home`. The `settled` helper in two `tests/runtime` files. </details> Co-authored-by: leaf-agent <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves the before/after image reading out of the core runtime into the default package, and bumps the protocol to 25 because five names leave the public widget API.
Why
browser/runtime/image-difference.js(774 lines) reads a screenshot pair into changed and moved regions. Onlylf-shot,lf-visual-review(throughlf-shot) andleaf-dev stillsuse it, yet it was re-exported fromruntime/widget-api.js, so it shipped in the widget-API bundle that every page with a widget loads, and it sat among the runtime owners that every core change keeps working. Its region reading is experimental (TODO.md), so it belongs with the widget that presents it.What moved
browser/runtime/image-difference.jsmoves whole topackages/default/widgets/image-difference.js.lf-shotimports it relatively.differenceKindandcountAreasare no longer exported, since nothing outside the module calls them.lf-shot'sdifferencereading now carries itsdescriptionin words, solf-visual-reviewreadsentry.difference.descriptioninstead of importingdescribeDifference.widget-api.jsstops re-exportingcompareImages,compareImagePixels,countAreas,describeDifferenceanddifferenceKind. The "Image comparison (experimental)" section leavesskills/leaf/references/module-reading.md.browser/vendor/topackages/default/vendor/(build/vendor.mjs). A page still imports them at/vendor/, which the composed layer answers.leaf-dev stillsserves the module and/vendor/from the default package. The dependency-cruiser closure entry for the module goes, since it's no longer a runtime owner.TODO.md's "consider moving it out of the core" item becomes the remaining work on reading moves.Protocol 24 → 25
A page vendored at 24 has an
lf-shot.jsthat importscompareImages,compareImagePixelsanddescribeDifferencefrom/runtime/widget-api.js. Served by this Leaf, that import fails and the widget doesn't upgrade.layer-registry.md("Page protocol") calls for a bump when a name a vendored module imports is gone. The bump changes$events.protocoland the baseline's number and nothing else; the recordsincevalues stay.Measured
dist/: +27/−49 across 12 files, plus the two vendor bundles and their license files renamed unchanged. The module moves with 2 lines changed.dist/kernel/runtime/widget-api.js, which every widget page loads before it first shows the server's state: 38,368 → 19,896 bytes (12,194 → 6,214 gzipped,gzip -9). A page with anlf-shotstill loads the module, now as its own file from the default package.Checks run
pnpm run test:runtime: 550/550.pnpm run check(after both commits): passes (browser build matches the committed bytes, framework and Worker type checks, Worker tests).uv run pytest tests/model/test_interact_layer.py tests/model/interact_contract/test_layer_contract.py tests/model/test_module_url_delivery.py: 343 passed.uv run pytest dev/tests/model/test_stills.py: 3 passed.leaf-dev stills HEAD~1 --state native-codereads its pair through the moved module. Againstmainthe base arm can't build:page_fixtures._acknowledge_seedwrites the seed's receipt with this checkout's Leaf, which refuses a page the base vendored at 24. That happens across any protocol bump, not only this one.test_render_commands.py::test_a_shot_outlines_and_explains_its_pixel_difference,::test_a_shot_compares_pixels_inside_an_opaque_live_sample,projection/test_visual_review.py::test_visual_review_keeps_the_dashboard_stable_while_inspecting,test_render_export.py::test_an_export_keeps_visual_review_images_and_inspection_offline: 6 passed.