You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Give the render probes the one open-root walk their comments already claim (#120)
## Problem
Three comments across the render probes name `OPEN_ROOTS` as the one
answer to which trees are the page, and the identifier does not exist.
The shadow-root walk it names is written out inline six times —
byte-identical — in `words.js` (twice), `widgets.js` (twice),
`framing.js`, and `runtime.js`.
Each of the three comments states the opposite of what the code does:
- `words.js` carried a section note ending "Written once, because it is
one claim about the page and two copies of it are two things to keep
level", sitting above two copies in that same file.
- `framing.js`'s `trappedMargins` opens "Which document each box is in,
imported rather than restated, for the same reason UNMARKABLE_ITEMS
imports its two" — and the next four lines restate it.
- `widgets.js`'s `retiredSlots` says the holders "are found through
OPEN_ROOTS too".
`UNMARKABLE_ITEMS`, `COVERED_WORDS` and `TINY_BOXES` all resolve — the
prose convention is SCREAMING_CASE for a camelCase export, and
`unmarkableItems` really does import `shownBox`/`shownParts` rather than
restate them. `OPEN_ROOTS` is the one reference in the directory with
nothing behind it, so the file that documents the invariant is the file
that breaks it.
## Solution
Extract `openRoots` into `render-checks/open-roots.js` and import it in
the four modules, deleting all six copies. The section note moves to the
new module, where it is now true, and gains the two boundaries a reader
has to know: why this is not the runtime's `shadowRootsIn` (that one
reads the registry's `x-shadow` list and is right to, this one walks so
an undeclared root is still read), and why `standalone.js` keeps a walk
of its own (it is served import-free so a BAKE'd copy can be probed from
a `file://` URL). The three prose references are left spelled
`OPEN_ROOTS`, which is now the same kind of reference as its neighbours.
`PROBE_SOURCES` is glob-built over the directory, so the new module is
served with no change to `render_checks.py` or `http.py`. It is
deliberately not added to `index.js`: it is a helper the probes import,
not a probe the gate calls.
## Testing
No regression test. The change is behaviour-preserving by construction —
six byte-identical expressions replaced by one import of the same
expression — so there is no state in which the old code and the new
disagree, and a test could only assert that the file count is one, which
is what `git` already shows. The probes themselves are covered by the
existing gate suite, and the walk is load-bearing across all of it:
`pageSettled` (`runtime.js`) is the wait almost every render test hangs
on, so a broken walk fails the suite rather than one case.
Run on this branch:
- `tests/test_render_commands.py`, `tests/test_render_export.py` — 32
passed.
- `tests/test_render_gate.py`, `tests/test_render_projection.py`,
`tests/test_render_startup.py` — 182 passed, 4 failed.
- `pre-commit` over the five changed files — prettier, eslint, typos all
pass.
<details><summary>The four failures are the layout regression already
red on main</summary>
They are not this branch's. [`ci` run
33296070275](https://github.com/max-sixty/leaf/actions/runs/33296070275)
on `3d494e1` and [run
33295489155](https://github.com/max-sixty/leaf/actions/runs/33295489155)
on `26feec8` both report the same four from this file, with the same
assertions:
-
`test_a_reader_arrives_at_what_they_left_rather_than_watching_it_arrive`
-
`test_the_render_gate_tells_a_float_in_the_margin_from_one_spilling_out_of_it`
- `test_the_reader_draws_an_edge_to_the_width_they_want[comments]`
-
`test_a_window_with_no_room_for_a_chosen_width_does_not_un_choose_it[comments]`
They belong to a 13-test cluster spanning `test_render_controls.py`,
`test_render_gate.py`, `test_render_options.py`, `test_render_pages.py`
and `test_render_widgets.py`, all reporting sideways document scroll or
a 12–15px offset (`assert -15 == 0`, "the page scrolls sideways with the
tray up"). `tend-ci-fix` runs are in flight for both commits, so this
branch leaves them alone.
</details>
Co-authored-by: leaf-agent <318509791+leaf-agent@users.noreply.github.com>
0 commit comments