Skip to content

Make six tests pass on a CPU-starved host, and state the speed rule's check as a starved run - #6166

Merged
max-sixty merged 3 commits into
mainfrom
agent-a322a92cf5e9a1e23
Nov 16, 2026
Merged

max-sixty merged 3 commits into
mainfrom
agent-a322a92cf5e9a1e23

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

A macOS nightly run at 4 workers on a 3-core runner (43780587059) failed six tests that pass unloaded. Each relied on one independent clock beating another: the page's timers, its rendering updates, Chromium's own reports, the test's steps. Each now makes that order itself, per Max's direction that tests shouldn't fail whatever the CPU, with the nightly confirming. The commit message gives each cause and fix.

For the reviewer:

  • Product change: lf-text-document uncoloured the runs in view when Chromium reported them skipped as a tab reopened, and a starved host painted the frame that draws them before the report that they draw. A run reported skipped while it stands in view now stays shown.
  • Route change: the trace test scrolls the saved tree by script. Under starvation Chromium dropped the scroll a PageDown on its summary asked for (no scroll event on any box for 30 s, keydown not prevented), so nothing now checks that the key reaches the tree.
  • held_frames' step takes a frame count.
  • tests/AGENTS.md's speed rule now names a starved run, not --cpu-throttle 10.

Starved runs (taskpolicy -b beside busy loops), base → head: stale response 1/6 failed → 8/8 pass; swap transition 10/10 → 10/10; trace 4/4 → 4/4; text-document colour 1/6 → 18/18. The site layout and finger tests didn't reproduce in 3 and 9 starved runs; their fixes follow orders plain in the code, and pass starved (4/4 each, the site's product-route sweep included).

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

… check as a starved run

A macOS nightly at 4 workers on a 3-core runner failed six tests that pass unloaded. Each relied on one independent clock beating another; each now makes that order itself. Every case was run under `taskpolicy -b` beside busy loops in the same band.

- The stale-response test counted state reads while the shared 2 s clock could ask again between the crossed read's answer and the next agreeing news look. The route now holds the crossed read until a look has taken the agreement in, so the clock has no window (base 1 of 6 failed; 8 of 8 pass).
- The swap watch's transition test grew a button whose centred label moved by more than Chrome's 3 px layout-shift threshold per frame only on slow frames. The occupant is now a div whose words sit at its top (base 10 of 10 failed; 10 of 10 pass).
- The trace test sampled each frame of a playback that keeps time by performance.now(), so sparse frames skipped the gaps it checks, and playback could end before the test saw it start. Both playbacks now run on held_frames, whose step takes a frame count. Chromium also dropped the scroll a PageDown on the saved tree's summary asked for, with no scroll on any box, so the tree is scrolled by script (base 4 of 4 failed; 4 of 4 pass).
- lf-text-document: as a tab opens again, Chromium reports the runs in view skipped, then drawn, each in its own task; the widget uncoloured them at the first report, and a starved host painted the frame that draws them before the second. A run reported skipped while it stands in view now stays shown (base 1 of 6 failed; 18 of 18 pass).
- The site layout test read the film after `set_viewport_size` and `wait_until_ready`, before the film's size observer switched it to its phone layout; it and the product-route sweep now use `resized` and `rendered`. Not reproduced in 3 starved runs; the order is plain in the code.
- The finger test read the search mark's box once the live region announced the step, on a 30 ms timer that can fire before the rendering update moving the mark; it waits for `rendered` first. Not reproduced in 9 starved runs; the order is plain in the code.

tests/AGENTS.md's speed rule named `--cpu-throttle 10`, which slows only the renderer's JavaScript. It now says a test makes every order it relies on between independent clocks, and checks the rule with a starved run ("Races"), which CI does in the daily run, not in a landing gate.

> _This was written by Claude Code on behalf of max-sixty_
leaf-agent
leaf-agent previously approved these changes Nov 16, 2026
Main's news answer now carries the user's drafts version (#6124); a fake carries every field the server sends.

> _This was written by Claude Code on behalf of max-sixty_
@max-sixty
max-sixty merged commit e65b850 into main Nov 16, 2026
5 checks passed
@max-sixty
max-sixty deleted the agent-a322a92cf5e9a1e23 branch November 16, 2026 11:48
max-sixty added a commit that referenced this pull request Nov 16, 2026
…t watch judges it at any frame rate (#6169)

The shift watch now credits a node inside a box that a native size
animation is growing or shrinking, so a press-begun transition that
re-centres a button's label passes at every frame rate. Before, at 60
fps each frame moved the label less than the 3 px Chrome reports as a
layout shift, so the watch never judged it. On a starved host one frame
moved it 4 px, Chrome reported the shift, and the watch had no credit
for it, because it credited a size animation's reflow only of boxes
after the animated one.

`innerReflow` in `tests/shift_watch.js` credits the node's move when:

- the move, beyond the node's other credits, lies between the moves of
the box's two edges, beyond the box's own credits;
- those edge moves grow or shrink the box, at one edge or both apart,
rather than carrying it whole;
- the node moves with the box: in its flow, or positioned against a box
at or within it (`unplacedBy`, which `sizeReaches` now shares).

That covers a box growing at its foot, one standing on its foot and
growing at its head, one centred in its parent, and a logical size in a
vertical writing mode. The box's alignment isn't readable (a button
centres its label by no CSS property), so a script move that stays
within the box's growth in the same frame is credited too, as the
sticky-inset credit already allows within its span.

## For the reviewer: a script-started transition still depends on frame
rate

The credit applies only to animations an input began, as the watch's
translation and following-box credits do; the header's scope paragraph
now says so. The swap-watch fixture as it was before #6166 started its
transition from a script, with no input, so it still fails starved and
passes unloaded. browser/AGENTS.md ("The page holds still under the
user's aim") lets news grow a box but keeps reading content still, so
the starved verdict is the one that rule asks for. The 60 fps pass comes
from Chrome's paint signal, which every passive verdict starts from and
which leaves out a frame's move under 3 px. Two ways to close that, both
outside this PR:

- **A.** Credit a passive size animation's inner reflow too. News could
then re-centre a label by animating its box, though not by resizing it
at once, which loosens the rule above.
- **B.** Judge passive motion across frames, so a slow passive layout
animation fails at 60 fps too. That changes how the watch admits a
passive move, and would surface every such animation the suite's pages
now hide.

A width animation that rewraps text, moving words to another line, is
also still uncredited, as it was before.

## Evidence

Scratch fixtures, the button row from the swap-watch test, 4 starved
runs each (`taskpolicy -b` beside self-ending busy loops):

| fixture | base, starved | head, starved | unloaded, both |
|---|---|---|---|
| click starts the height transition | 3 of 4 fail | 0 of 4 fail | pass
|
| script starts it (fixture before #6166) | 4 of 4 fail | 4 of 4 fail |
pass |
| same growth, no transition (control) | 4 of 4 fail | 4 of 4 fail |
fail |

`test_a_size_animation_carries_what_its_box_lays_out` seeks a press's
paused height animation to its end in one frame, so every host sees the
step a starved host does. Words re-centred in a box growing at its foot
or at its head pass; words a script carries farther than the box grew,
and words re-centred by a size change no animation of their box makes,
fail. On the base watch the first two arms fail. Dropping the bound, the
ownership checks or the box's head-edge term each turns the matching
arm.

Focused checks pass, unloaded and the new test starved: the shift
watch's size and animation credit tests, the swap-watch module, and four
real-page fold and growth tests (97 in all). An independent Codex review
found the vertical-writing-mode gap, unmemoised recursion through nested
resizing boxes, a crash path for a box that turns `display: contents`,
and the scope paragraph's overstatement; this PR fixes all four.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Nov 16, 2026
…ved Firefox (#6197)

Max's direction for tests whose result depends on CPU: design them so it
can't, confirm that in the nightly runs, and keep starved runs out of
the merge pipeline. This makes the macOS nightly that run: it now uses
four workers on the runner's three cores, which starves every test. A
trial at four workers ([run
43780587059](https://github.com/max-sixty/leaf/actions/runs/43780587059))
took 4h11m against 4h12m at two, with the CPU at 0% idle throughout and
memory peaking at 7.1 of 7.5 GB, no swap. `tests/AGENTS.md` now names
that job as the slow-machine rule's check.

In a starved Firefox, PageUp in a live log can do nothing: Firefox
applies the key's scroll 280–800 ms late, after the reader's 80 ms wait
for it, and no event says the browser won't scroll, so ending the loss
needs a deadline. Max accepted it as a corner case, so the Firefox cases
of `test_a_page_up_in_a_log_a_stream_feeds_leaves_its_end` whose scroll
the browser applies (PageUp, PageUp on a link, wheel, wheel across) are
now non-strict expected failures; this PR's first CI run lost a wheel
the same way. They pass at normal load, as they did locally here and on
main's last three push runs. `u`, which Leaf's own glide scrolls, stays
a plain case.

To weigh: the trial run at four workers had 30 failures against 21 at
two. #6154, #6155, #6166 and #6169 fixed the load-dependent ones found
then, but the first nightly after this may still turn up more; each is a
test whose result depends on speed.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Nov 17, 2026
…s verdict is the same at any frame rate (#6217)

Max asked why tests still fail only on slow machines when
`tests/AGENTS.md` ("Results do not depend on execution speed") forbids
it. The shift watch started every verdict on movement without input, and
on typing, from a Chrome layout-shift entry. Chrome reports a box only
when it moves at least 3 CSS px between two paints, and never for a
transform. So an animation no input began, moving words in sub-3 px
steps, passed at 60 fps and failed on a starved host, as
`test_a_row_a_transition_grew_keeps_its_size_through_a_swap`'s fixture
did before #6166. The starved verdict is the one `browser/AGENTS.md`
("The page holds still under the user's aim") asks for.

Now the watch judges a run of motion from its own readings. Each frame
compares every protected landmark with where it stood before the run,
crediting the motion owned across it, and a move fails where the next
reading still finds it moved. Typing is judged the same way. The
`shift_watch.js` header's "Runs of motion" describes the model; three
parts of it a reviewer should weigh:

- **Permissions are asked per step.** Append growth, widening and reflow
are asked only of one frame's step, and the run takes away what each
step permitted (append growth's measured carry). Two permitted steps
need not form one permitted transition from the run's first frame to its
last.
- **Scrolls stay on Chrome's report.** A landmark held by a box that
scrolled in a frame (a box fixed to the window ends that walk) is judged
on that step alone, on Chrome's report as before. The watch's comparison
reads a move where a landmark's screen and layout positions both
changed, and in a scrolling frame those can change for different reasons
(a sticky track scrolling inside a page that scrolls past it).
- **Transforms are now judged.** The rule keeps still whatever the user
reads, and the readings include transforms, so a transform that carries
reading content or a control without input fails. Before, Chrome's
signal never saw it, so it passed at every speed.

What still depends on the frame rate, and one false positive this design
admits, are listed in the header and below.

## Evidence

A script-started CSS transition (height pushing words, a button's label
re-centring, and a `translate`) at 0.2 s and 0.6 s, on a light page and
on one with 1,500 paragraphs:

| condition | median frame | base fails | head fails |
|---|---|---|---|
| unloaded | 17–33 ms | 0 of 18 | 12 of 12 |
| `--cpu-throttle` 4, 8, 16, light page | 17 ms | 1 of 36 | 18 of 18 |
| `--cpu-throttle` 4, 8, 16, heavy page | 83–900 ms | 11 of 12 layout, 0
of 6 transform | 18 of 18 |
| `taskpolicy -b` + 14 busy loops | 17–267 ms | 7 of 8 layout, 0 of 4
transform | 6 of 6 |

Base passes the slow layout motion when frames are short and fails it
when they're long; it never sees the transform. Head fails all of them
at every frame time. `--cpu-throttle` doesn't lengthen a light page's
frames.

`test_motion_without_input_fails_at_any_frame_rate` steps the same
animations half a pixel and 16 px a frame, including words that arrive
mid-run, words beside a pane that scrolls, and a window-fixed button
while scroll anchoring moves the page; base passes the half-pixel steps
and the transforms. New append, widening and returning-control cases
hold the per-step rules, and each new case fails on the commit before
its fix. An independent Codex review ran four rounds of browser probes;
every confirmed false positive and negative is fixed or listed under
"Still open". The shift watch's own module passes starved (369 tests,
`taskpolicy -b` beside 14 busy loops).

## What the stricter watch caught across the suite

A full run on an earlier head (`--run-nightly`, Ubuntu, and macOS
starved until cancelled at 4,847 tests) found no product motion. Every
new finding was the watch missing a credit for a native mechanism that
Chrome's report had hidden, or a fixture's own setup, and this PR fixes
each in the watch or the fixture:

- **`position-area` anchoring**: the trace viewer's Image scale menu
catches up with its anchor a frame after a scroll; the anchor credit
read only `anchor()` insets (`test_trace_comparison_*` in
`test_render_playwright_trace.py`).
- **Slots in a closed shadow root**: `assignedSlot` names none from
outside, so the editor's placeholder lost the box whose
`--lf-field-carry` translate carries it, and its slide after a long
draft empties read as a move
(`test_a_long_draft_offers_more_room_at_a_press`).
- **A closed editor's zero box**: typing compared the field with the box
it leaves once its editor closes
(`test_words_a_committed_value_editor_close_retires_only_its_exact_edit`).
- **Mixed scroll frames**: a sticky track scrolling while the page
scrolls past it
(`test_growth_above_the_window_moves_nothing_read_in_a_sidebar_*`,
throttled), now on Chrome's report as described above.
- **Fixtures**: `test_ending_an_animation_after_its_target_detaches` and
the custom-translation coincidence moved a transform with no input as
setup; they now seat it in the markup.

The final run on this head, merged with main ([Ubuntu,
`--run-nightly`](https://github.com/max-sixty/leaf/actions/runs/44007915578)),
passed 8,843 tests and reported no shift-watch finding. Its 18 failures
fail with the base watch too, or on main's latest runs: the render
gate's playground and layout cases (`apparatus among authored`,
overlaps), the reaction trigger's click timeout, the sample controls'
invalid JSON, and the inherited root-summary, card-placement,
focus-ring, close-request and shipped-log cases.
`test_a_reply_written_in_a_card_keeps_its_line_breaks_once_sent[touch]`
fails starved on base and head alike: a sent message moves 84 px when
the server's answer lands after the send's rendering has closed, a
timing race in input ownership that this PR doesn't touch.

## Still open

- **Frame-rate dependence that remains**: a roundtrip Chrome doesn't
report (a transform's, or under 3 px a frame) read once on a starved
host; a landmark's move in frames where a scroll also moves it; a
declared region growing under a pixel a frame.
- **An unrelated Chrome entry admits a scroll's candidate**, as on main:
a frame where the page and a sticky track's own scroller scroll reads as
the track's words moving, and an unrelated layout shift in that frame
admits it. Requiring Chrome's source to match would let the five-source
cap decide which landmarks are judged, which the header rules out.
- **A false positive the readings can't rule out**: a page that writes a
layout in a task before every frame and undoes it in a frame callback
before every paint fails though it never paints the move. No browser
primitive gives painted-state evidence per element short of Chrome's own
report.


> _This was written by Claude Code on behalf of max-sixty_
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