Repository navigation
Hold every test to passing on a machine ten times slower, and judge none by a benchmark - #5522
Conversation
…mes slower tests/AGENTS.md held functional tests to giving the same result when the system runs ten times slower, and sent performance to be tested "separately, under controlled conditions". The maintainer's rule now covers every test: "we should never have the timings be a test, we should have a rule that running on a 10x slower machine still passes". So no test asserts a duration. A check of cost compares readings taken in the same run, such as a ratio of a large page's cost to a small one's, or a fitted exponent, so the machine's speed divides out. A deadline was asked to leave "room for slow execution"; it now leaves at least ten times the longest the bounded work takes on the machine it was set on. The section drops "Functional" from its heading, and the two comments that cite it follow. Co-authored-by: Claude Opus 5.5 <[email protected]>
…to check a test Review of the slow-machine rule found four gaps. **Absences.** The commonest violation is a fixed wait before an assertion that something didn't happen, which a slower machine turns into a pass that checks nothing. "Absences" now says to wait for a later event ordered after the moment the forbidden behavior would have happened, and names the events the suite already waits on: the page's sends coming back (`round_trip`), the page taking in what the server holds (`told`), the shared clock's next tick (`ticked`), and a later gesture of the same kind. `test_a_wait_takes_the_suites_deadline` called a sleep "an absence window"; it now says a sleep bounds nothing and points at "Absences". Its check never read sleeps, so only the docstring changes. **Deadlines.** "Ten times the longest the bounded work takes on the machine it was set on" named no machine anyone could measure. It is now CI's runner, whose `test` job records each test's time in its junit results (`leaf-dev suite-profile`), and the per-test hang limit, `faulthandler_timeout`, is named as one such deadline. Its comment in `pyproject.toml` said the slowest test takes under three minutes on CI; sixteen took longer on the 2026-11-05 nightly, the slowest 1,614 s, and the comment now says so. The limit itself is unchanged. **Checking a test.** The section names `--cpu-throttle 10` as the check, and its limits: it slows only Chromium's renderer, and it doesn't reach a page from `browser.unwatched`. "Races" said the option slows every page the browser fixtures open; it now says the pages the `browser` fixture watches. Co-authored-by: Claude Opus 5.5 <[email protected]>
leaf-agent
left a comment
There was a problem hiding this comment.
The new faulthandler_timeout comment contradicts itself: it says the slowest test takes under three minutes on CI's runner, then says sixteen took longer, the slowest 27 minutes. At 27 minutes the 30-minute limit is barely above the test's CI time, not ten times it, so the deadline tests/AGENTS.md now names as "one such deadline" breaks the rule this PR states. A reader can't tell which half is the claim. Since the description says the limit stays put while those tests are shortened, the comment could state three minutes as the target and the sixteen tests as current violations (suggestion inline).
The `faulthandler_timeout` comment read "hung, not slow, while the slowest takes under three minutes", which reads as a claim about today's suite, and carried a dated count of the tests over that bound, which goes stale as they are shortened. It now says the half hour separates a hung test from a slow one as long as every test takes under three minutes on CI's runner. Today's count is in the pull request. Co-authored-by: Claude Opus 5.5 <[email protected]>
The suite's shift watch (`tests/shift_watch.js`) no longer reads content the browser skips: a shut tab's panel, a closed disclosure's content, the contents of an off-screen `content-visibility: auto` box. On the feature gallery that cuts the watch's cost of opening the page by more than half, and every watched test whose page holds shut tabs or folds pays less on each frame it changes. This is the sensor half of what #5522 asks of the longest tests; the other half is the page's own load, below. ## Where a gallery test's time goes Measured on this Mac (one-minute load 6–25 from other sessions), Chromium headless shell, 1200×900, reduced motion, opening the gallery and waiting for `wait_until_ready`, three interleaved rounds per arm: | Arm | Time to ready | The shift watch's complete readings | | --- | --- | --- | | `browser.unwatched` (the page's own work) | 7.0–8.4 s | none | | `browser`, the watch as on `main` | 13.6–16.1 s | 85–99 readings of 5,913 nodes, 6.8–8.5 s | | `browser`, this branch | 9.5–10.9 s | 92–94 readings of at most 2,923 nodes, 3.1 s | All of the sensors' cost was the shift watch's complete reading. On each frame after an announced change, `read()` asked every node for its rect, about fifteen computed-style properties, its visibility and its ancestry, at about 14 µs a node; a CPU profile of a watched load put 8.7 s of its 14.9 s in the watch's frame callback, 7.5 s of it in `read()`. About 3,700 of the gallery's 5,913 nodes stand in skipped content, nearly all in shut tabs. The runtime's own readings already leave skipped content out (`skipped`), because asking about it makes Chrome style and lay out the whole skipped subtree first. The page's own 7–8 s is mostly its 16 live samples: the page presents at about 1.6 s, the samples report ready one after another from about 2.6 s to 6.7–7.6 s, and the page is ready within 0.1 s of the last. Of the long gallery tests on CI's daily run, only `test_the_feature_gallery_exercises_its_core_journeys` runs the shift watch; `test_render_gate.py`, `test_render_pages.py` and `test_render_anchors.py` are marked `shifts_unsurveyed`. Call seconds, `-n0`, base and this branch interleaved over two rounds, then once each with the shift watch removed and with every sensor removed (a scratch switch in `watched`, not committed): | Test | `main` | This branch | No shift watch | No sensors | | --- | --- | --- | --- | --- | | `test_the_feature_gallery_exercises_its_core_journeys` | 63, 63 | 43, 44 | 19 | 20 | | `test_page_fixture_renders[feature-gallery]` | 110, 115 | 116, 110 | 109 | 113 | | `test_an_anchor_written_from_the_mapped_revision_lands_on_the_page[feature-gallery]` | 25, 24 | 25, 24 | 23 | 24 | | `test_real_page_passages_can_be_quoted[feature-gallery]` | 24, 22 | 25, 22 | 22 | 23 | `test_page_fixture_renders[feature-gallery]` spends about 55 s of its 110 s here in seven `wait_until_ready` calls, about 8 s per gallery load, and the rest in its journeys' own probes; on CI's daily runs of November 4 and 5 those seven calls took 292 s and 327 s. So for that test, the longest on CI after the Firefox sweep, the cost is the page's own load, chiefly its live samples, rather than the sensors. ## The change - `everything()`, the population of a complete reading, leaves out nodes in skipped content. A node the last reading read while it was drawn gets one more reading, the one that sees it go. Without it, a fold that shrinks to nothing and moves into a closed `<details>` in one task, as a settled thread does into history, lost the flow credit for the control its shrinking carried, and all six cases of `test_fold_reparenting_keeps_only_its_original_flow_credit` failed. Content is read again from the frame it is drawn; what reveals it, or makes the browser stop drawing it without a scroll, is a DOM write or a `contentvisibilityautostatechange`, both of which the watch has announced since #1951 (the header's list of announcements now names the second). - A layout-shift entry taken at a paint checkpoint now records `held`, the population the reading at that time covers, rather than asking `everything()` again right after `read()`: the second call left out the nodes `read()` had just taken a departure reading of, so a `content-visibility: auto` box carried off screen without input could go unjudged on that path. No control exercises that path with a departure; the change follows from what the population means. - `test_a_control_drawn_out_of_skipped_content_is_watched` holds that a control drawn out of a closed disclosure, a hidden-until-found panel or an off-screen `content-visibility: auto` box, then moved by script, is still reported. With revealed content never read again, all three cases fail. - `test_a_box_the_browser_stops_drawing_without_a_scroll_leaves_no_stale_reading` pushes a drawn `content-visibility: auto` box past the browser's drawing margin with a write above it, so no scroll announces the change. Without the `contentvisibilityautostatechange` announcement the verdict's own complete reading reports "shift watch missed a change to the page's nodes (population)" in 5 runs of 5; with it, 5 of 5 pass. - `skipper` and `skipped` move from `shown-box.js` to `shadow-tree.js`, which imports nothing (`.dependency-cruiser.mjs` holds it to that), so the sensor bundles the runtime's own rule. `shown-box.js` imports `rendering.js`, whose dependencies run code at load, so it can't go into an init script. Every importer names the new home, and `browser/AGENTS.md` gains the owner's row. - `notes/shift-watch-cost.md` records the findings (about 14 µs a node per complete reading; most of the gallery's own time to ready is its live samples arriving), the `leaf-dev probe` command that reproduces the gallery's presented and settled times, and the open design below. `skipper` stays in `shadow-tree.js` beside `excludedByInert` and `nativeLayerHolding`, which also ask the browser about state along the rendered ancestry; a module of its own would add a file and move every importer again. ## Checks run - `uv run pytest tests/browser/test_render_shift_watch.py tests/journeys/test_render_shift_watch.py tests/browser/test_render_words_watch.py tests/browser/test_render_swap_watch.py tests/browser/test_render_write_watch.py tests/browser/test_page_layout_shifts.py tests/journeys/test_page_layout_shifts.py -n 4`, plus the watched gallery journey: 466 passed. The sensors' controls (a real shift, lost typed words, a swap, a needless write) still fail where they should. - The sensor suites with `VERIFY = 1`, which checks every frame for an unannounced change: 459 passed; the four gallery tests above also passed with it before the review follow-up. - The watched browser and smoke files whose pages hold tabs, disclosures, text documents or samples (18 files, 302 tests): 11 failures and 3 errors across 11 tests, the same set with `main`'s watch and with this one; 8 of those 11 tests also fail on CI's November 5 daily run. - `pnpm run test:runtime` (820 passed) and `pnpm run check`. `test_a_pressed_panel_control_keeps_its_face_and_takes_the_next_press[feature-gallery]` fails on this Mac with `main`'s watch and with this one alike ("Resolve thread" shows `cursor: zoom-in` while its gesture travels) and passes on CI's Linux runner, so it is left out of the comparison. Not verified: the rest of `tests/browser` and `tests/journeys`, which run under this sensor; CI's push to `main` is the first run of them all with it. ## What's left - **The page's own load.** Every live sample's child page starts as its sample mounts, below the window or not, and the page reads as arriving until the last has; on the gallery that is 16 Leaf runtimes and about 5 s of every load, which users on leaf.page pay too. Starting a child only as its sample nears the window would cut both, but changes when a sample's state is ready, so it is Max's call. - **The reading still grows with the drawn page.** A page that skips nothing, like the 512-section prose page `leaf-dev scaling` generates, gets nothing from this; #5523 measured the sensors adding about 290 ms to a click there. Reading the full record only for nodes near the window, as the runtime's input work follows the window, would change what a verdict can look back to for a box that jumps into view, so it is in the note as a design for Max. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…ine ten times slower (#5523) Max's rule is that every test still passes on a machine ten times slower than the one it was set on (#5522). Two places this changes broke it. **The scaling journeys' noise floors were milliseconds.** `exponent` leaves out a size whose growth above BASE is under a floor, 10 ms (50 ms for the server's time to answer). On a slower machine every reading grows and the noise with it, so more sizes clear a fixed floor and noise gets fitted; on a faster one, real growth falls under it. A floor is now a share of a reading from the same run: the BASE page's load for the browser's costs (`scaling.floors`, 5%, and 25% for the server's time to answer), and each server path's own reading on the BASE page (`server_scaling.floors`), so a cheap path isn't judged against a dearer one's fixed work. On this Mac the browser's come to 8-10 ms and 39-52 ms. The event answer's size stays 10 KB, since no machine's speed changes it. `exponent` takes the floor from its caller. On the growth test's readings of all four pages, scaled as a machine 10 times faster or slower would scale them, the ms floors fit different sizes to different exponents at each speed (asks' click: none, 0.89 over two sizes, 0.67 over three), and the new floors fit the same sizes to the same exponent at every speed. **The browser growth test's time.** With the suite's health sensors, the growth test's document page took 1,203 s on CI's daily run, and at CPU rate 10 the document and asks pages ran past the 1,800 s per-test limit. #5515 has since moved the test onto `browser.unwatched`, as this branch also did, so that part merged without a change here. On the merged head, the growth test's logic at CPU rate 10 passes the document page in 199 s. The per-test limit stays at 1,800 s. **The playground leave test waited a fixed second.** After two reloads it waited 1,000 ms for a leaving document's post, then read the log to check that leaving recorded nothing. On a slower machine that post could land after the read, and the test would pass without checking. It now leaves one real edit for a third reload and waits for that edit's record, which arrives after anything the two reloads' leaving documents posted, then checks that it is the only new record. With leaving changed to record the drawn default, the test fails (7 records where 5 belong); restored, it passes, also at `--cpu-throttle 10`. The other deadlines leave at least ten times their work's normal duration and are unchanged: `SERVED_TIMEOUT_MS` (120 s) bounds one probe or request; `STATED_TIMEOUT` (120 s) bounds a server start or a short subprocess; `HANDOVER_DEADLINE_MS` (240 s) bounds a corpus handover of 16-18 s; and the lease holder's 60 s in `test_interact_server.py` outlives a nested run that takes 1 s here and 1.9 s on CI. The scaling journeys are the daily gate on the costs #5194 tracks. ## Checks run - `uv run pytest tests/journeys/test_scaling.py -n 2`: all four pages pass, 115-131 s each. - `uv run pytest tests/journeys/test_server_scaling.py -n 2`: eight pass, and `cards`, marked `xfail` because its exponent fits 1.3-1.6 from run to run, passed this run. - The server test's measurement three more times on all nine pages: each run fitted 40 of 48 paths, where a floor of the BASE page's paths together fitted 20 or 21 of the same readings. Outside `cards` the largest exponents were 1.25, 1.11 and 1.13, and `cards`' `delivery` fitted 1.49, 1.51 and 1.47 under either floor. Unfitted are the `revisions` page's five paths, which stay flat as versions accumulate, and `activate` on `threads`, `messages` and `batch`. - The growth test's logic at CPU rate 10, outside pytest (`.tmp/review/growth_check.py` in the worktree), on document and asks: both pass, in 196 s and 254 s. Rerun on document after merging main (4130d3e): passes in 199 s. - After merging main, `uv run --frozen pytest tests/journeys/test_scaling.py -n 2`: all four pages pass, in 250 s. - The same with 100 ms of busy work at the 256 page added to each press, key and wheel step, scaled with the square of the page's size, at rate 1: click, key and scroll fail on prose and document. - The growth test's dumped readings from all four pages, watched and unwatched, with every duration scaled by 0.1 and by 10: the share floors fit the same sizes and exponents at each scale; the ms floors didn't. - `test_a_playground_records_an_edit_made_while_loading_or_as_the_page_leaves`: fails with leaving recording the drawn default, passes restored, and passes with `--cpu-throttle 10`. `test_a_wait_takes_the_suites_deadline` passes. - `pre-commit run --files` on the changed files. ## Not covered `--cpu-throttle` and CDP's `Emulation.setCPUThrottlingRate` slow only Chromium's renderer. Page building, the server, Python and Playwright's driver ran at full speed in the rate-10 runs, so those runs don't show how the server's time to answer, or a journey's setup, behaves on a machine ten times slower. `--cpu-throttle` also doesn't reach a page from `browser.unwatched`, so the rate-10 runs of the growth test wrapped the tab themselves. The rule this follows is in #5522, and the fixed waits before absence assertions are in #5541. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Fifteen tests waited a fixed time, from 50 ms to 11 s, and then asserted that something had not happened: a receipt not sent, a probe not repeated, a pane not scrolled. On a slower machine the unwanted thing can land after the wait, and the test passes with the bug present. `tests/AGENTS.md`'s "Absences", as #5522 rewrites it, says to wait instead for an event the page orders after the moment the unwanted thing would have happened, and then check that it is absent. Fourteen of these tests now do that, and the fifteenth drops its check, since nothing can produce what it checked for. | Test | Waited | Now waits for | |---|---|---| | `test_render_read_state::test_modal_blocks_exposure_until_user_returns_to_threads` | 100 ms | `rendered`, then `round_trip`: the read pass the resize set off has run, and any receipt it sent has come back | | `test_render_read_state::test_oversized_message_needs_contiguous_traversal` | 100 ms | the same, after the scroll | | `test_render_read_state::test_a_page_seat_the_open_panel_stands_over_is_not_read` | 1.5 s | the same, after the scroll | | `test_render_drawing::test_a_second_finger_takes_back_the_stroke_the_first_began` | 100 ms | `rendered`: every repaint the release queued has run | | `test_render_floating_panel::test_writing_reaches_the_field_however_the_panel_stands` | 300 ms | `rendered`: the resume has drawn what it decided | | `test_render_anchors::test_a_failed_deferred_hydration_waits_for_a_user_retry` | 250 ms | the page's clock run a minute forward, past any backoff a retry would wait out, then `rendered`, with the page counting its own `/api/deferred` fetches | | `test_render_startup::test_slow_history_keeps_decisions_safe_and_status_honest[ready]` | 50 ms | the planted fault's `pageerror`, then `rendered` | | `test_render_startup::test_user_view_context_waits_for_a_samples_viewport_allocation` | 11 s | the page's clock run 11 s forward, then a check that the view restoring the frame is the only one sent since it went to zero | | `test_panes::test_reading_keys_follow_the_focused_pane_without_moving_its_sibling`, first press | 250 ms | `scroll_settled` on the pane, then on the document | | the same, second press | 250 ms | the same | | `test_freshness::test_status_changes_coalesce_behind_one_state_read`, two waits | 500 ms each | the second freshness look asked after the change, which the page asks only once it has handled the first, with the page counting its own looks and state reads | | `test_changes_in_place::test_a_to_do_running_on_an_element_marks_it` | 300 ms | `told`: the page has taken in the to-do | | `test_wait::test_the_stop_hook_watch_wakes_the_session_only_for_input` | 1 s | two more passes of the watch over the pending input, with each pass's wait shortened to zero | | `test_site::test_a_page_that_starts_after_a_fault_takes_its_notice_back` | 3 s | the page's clock stepped a second at a time, three times, each step taken with no probe round in flight, with the page counting the probe's own fetches | | `test_site::test_a_probe_in_flight_leaves_a_page_that_started_alone` | 2 s | the page having handled the held probe round's answer | | `test_projected_data::test_data_written_while_a_fresh_revision_starts_shows_once_it_has_started` (renamed from `test_data_written_during_fresh_revision_startup_waits_for_activation`) | 100 ms | nothing: the check is removed (below) | Four of these count requests in the page rather than through Playwright. A route handler's list and a `request` event reach Python on their own schedule, after the page's call, so a count read right after an ordered event could still be missing the request it is checking for. Three of the waits needed more than an ordered event: - **The started-page probe test.** The supervisor sets the timer for its next round only once the last round's answer lands, so a clock run while a round is in flight fires nothing. The test therefore waits until no round is in flight and steps the clock a second at a time, waiting out any round each step starts. It throws its planted fault from a `DOMContentLoaded` listener, because a timer's callback under Playwright's installed clock throws without firing the page's `error` event (measured: the callback ran, the page's `error` listeners saw nothing, and `data-lf-startup-error` stayed unset), and the supervisor would never start. The test first checks that the supervisor recorded the fault in `data-lf-startup-error`. - **Both probe tests** count only the supervisor's probe, which asks for `registry.json` past the cache. The runtime's own read of the same address used to count too, so `handled >= 1` could hold before the held round was answered. Each probe also carries a `Leaf-Test-Probe` header, so the in-flight test's route holds the probe alone; the runtime's read goes through, and the page comes up on its own rather than through a planted `data-lf-upgraded`. - **The deferred-hydration test** runs the page's clock forward, since `rendered` doesn't wait for a timer and a retry on a backoff would come after it. The projected-data test checked, 100 ms after writing data during a fresh revision document's startup, that the update had not painted. That guarded a newer source reading painting into a document that was still activating, a case from before #666, when an activation could hold the page while the new document was already mounted. Since #666 a revision that changes the page's code starts a fresh document. The test holds that document's `registry.json` for all of startup, and widgets import their modules only after it arrives (`widget-loader.js`), so no widget exists to paint the update. No product change short of drawing widgets before their registry can bring the case back. The checks after the release stay: the update shows, and so does the new revision's text. ## Controls For each test, a throwaway product change made the unwanted thing happen, and the converted check caught it. Each browser test ran four ways: as is and with the change, at CPU 1x and at `--cpu-throttle 10`. As is, every run passed; with the change, every run failed at the converted check. None of the changes is committed. | Test | Change | |---|---| | modal | `thread/read.js` reads a message under an open modal | | oversized message | `thread/read.js` takes any traversal as contiguous | | page seat under the panel | `thread/read.js` measures the message without the panel's clip | | second finger | `drawing.js` keeps the stroke when it is dropped | | resume | `drafts.js` reports the writing place unavailable after resuming it | | deferred hydration | `lf-diff.js` retries a failed load on the next task, and separately on a 1.5 s backoff | | post-upgrade fault | `prepaint.js` marks a startup error, a task later, for an error after upgrade | | sample viewport | `user-view.js` reports a zero-sized view | | panes, first press | the `d` key also scrolls the sibling pane two frames later | | panes, second press | the `d` key scrolls the focused pane a further 40 px two frames later | | freshness | `state-feed.js` asks again while a read is in flight | | to-do | `margin-bars.js` marks a to-do's target before it is running | | stop-hook watch | `session.py` wakes on the second pass over pending input (a model test, so no throttle) | | started page's probe | `bootstrap.js` drops both of the probe's `started` checks; over the clock's three steps the count rose from 1 to 4 at 1x and from 2 to 5 at 10x | | in-flight round | `bootstrap.js` acts on a round's answer after the page started; a second document, `?_leaf-recovered=`, was requested | ## What ran Each touched test as is and with its change, at CPU 1x and 10x, one at a time (`uv run --frozen pytest <test> -n0 -q`, then with `--cpu-throttle 10`), from scripts that applied and restored each change, and the projected-data test as is at both. Every touched test together at 51e0bf3, with `-n 2`: 19 passed; the four tests changed since then each passed as is at 1x and 10x, and the freshness and projected-data tests again at 1x after the last change. Not run: Firefox or WebKit, and the rest of each test file. The sleeps removed total about 21 s, 11 s of it in the sample-viewport test; the deferred-hydration test's minute of clock adds about 3 s. The rule is #5522; #5523 holds the fixes to the scaling checks and the playground wait. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…de the rule Max decided two things today. No test passes or fails on a benchmark's reading: a benchmark reports its readings (`leaf-dev scaling`, charted daily) and a reader judges them, which replaces the sentence that let a cost check compare readings from the same run. And the per-test hang limit, `faulthandler_timeout`, stays a guard against a hang outside the ten-times rule, so the rule no longer names it as one of its deadlines and its pyproject comment drops the three-minute condition. The ten-times margin now applies to each deadline that bounds one operation. Co-authored-by: Claude Opus 5.5 <[email protected]>
leaf-agent
left a comment
There was a problem hiding this comment.
The new rule says no test passes or fails on a benchmark's reading, and it gives leaf-dev scaling as the example of a benchmark that only reports. But tests/journeys/test_scaling.py, which was updated on main by #5523 and #5546, still fails on those readings. test_no_cost_grows_faster_than_the_page fits an exponent to the measured costs and ends with assert not failed, failed (via scaling.failures, which fails a slope past SUPERLINEAR). So the suite's own scaling journey breaks the rule as written, and an agent applying this section would either delete that gate or work out for itself that the rule doesn't mean it.
If the growth test is meant to stay (and #5523 made it pass ten times slower), the rule should say what it rules out: an absolute reading, not a ratio between readings that a uniform slowdown leaves unchanged. Suggested wording is inline. If the growth test is instead meant to stop gating, that change belongs with this one, since the prose would describe the code only once it has landed.
#5522 states the rule in tests/AGENTS.md, "Results do not depend on execution speed", so the job's comment and scaling.py's header point there, and dev/AGENTS.md no longer restates it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… nothing on its readings (#5563) Max asked that nothing pass or fail on a benchmark's reading. Two daily journeys did: `tests/journeys/test_scaling.py` failed a browser cost whose growth fitted an exponent past `SUPERLINEAR` (1.5), and `tests/journeys/test_server_scaling.py` did the same for the server's paths. This deletes both. The daily `ci` run now calls the benchmark command itself, in a `scaling` job of its own, and feeds the same chart. ## What the daily run does now The `scaling` job runs only on the schedule, on its own runner, so the suite's three pytest workers no longer share its cores: - `uv run leaf-dev scaling --sizes 64,128,256 --rounds 2`: the four browser pages (asks, document, prose, threads) at the sizes and rounds the deleted test used (`BASE`, 8, is always added). - `uv run leaf-dev scaling --server`: the server's paths on every collection at the command's default sizes and rounds (128 to 1,600, three rounds), as the deleted server test measured them. Each step tees its table, every cost by size with its exponent and a `!` past 1.5, into the job summary, the log, and a `scaling-report-<run>` artifact beside each run's `results.json`. GitHub serves no job summary through its API (the check-run's `output.summary` is empty for an Actions job), so the log and the artifact are where an agent reads it. The chart step reads the browser run's `results.json` and builds the same `customSmallerIsBetter` entries the test wrote: `<axis>: <cost>` at 64 sections, in KB for `event_kb` and ms otherwise, rounded to two places. The `github-action-benchmark` settings are unchanged (`alert-threshold` 150%, `comment-on-alert`). The chart step runs when the browser step produced its readings, whatever the server step did. A crash of the command fails its step, and so the run; no reading does. The command's readings may shift by a step in the chart's first point after this lands, since they are no longer taken beside the suite's other tests on a shared runner. ## References `scaling.py`'s header no longer says the daily suite fails growth, and says where the daily run reports. It and the job's comment point at the rule's home, `tests/AGENTS.md`, "Results do not depend on execution speed", whose rewrite in #5522 says no test passes or fails on a benchmark's reading; #5522 lands after this. `ci.yaml`'s header names the new job. Nothing else in the tree named the deleted tests (`git grep test_scaling test_server_scaling UNHELD scaling-chart`). ## Checks - `leaf-dev scaling asks --sizes 16 --rounds 1` and `leaf-dev scaling --server options --sizes 16 --rounds 1` run, and the chart step's `jq` (with `select(.n == 16)`) turns the browser `results.json` into entries named as the test named them (`asks: load`, `asks: event_kb` in KB, …). - `uv run pre-commit run` on the changed files, including `actionlint`. Not verified: the job on a scheduled run. It runs first at the next 10:47 UTC schedule after landing. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…ling and bench-latency (#5576) Max asked for one benchmark that takes variables, rather than two that each serve pages from this tree and a base, drive inputs, time them and profile them. This replaces `leaf-dev scaling` and `leaf-dev bench-latency` with one `leaf-dev bench`, and deletes both, with every caller cut over and no alias. ``` uv run leaf-dev bench [PAGE ...] [--sizes 32,64,128,256] [--input NAME ...] [--read cpu|paint|server ...] [--rounds N] [--base [REF]] [--browser firefox] [--profile] ``` - **The page** is a generated collection (`COLLECTIONS`, measured at each size beside the BASE page) or any example or the corpus by name. - **The inputs** are one table, `INPUTS`: scaling's click, key, leave, Tab, wheel and revision; bench-latency's comment, card move, agent reply, agent status and stamped revision (`stamp`); and a triple-click selection of the title (`select`), which replaces #5472. A page without what an input needs (an option, a card) reads none of it and the report names it missing. - **The arms** come from `arms.choose_arms`, as before. - **What to read**: `cpu` (scaling's CPU pass), `paint` (bench-latency's time to the painted result, the POST's answer, the server's reading on screen, and the requests and bytes caused), `server` (the in-process server paths, `server_paths.py`, the renamed `server_scaling.py`), for this checkout's generated pages only, as before. Default `cpu` and `paint`, and in Firefox `cpu`. Scaling is the same benchmark over several sizes: with three sizes or more the table gives each reading's exponent, marked `!` past 1.5. Every reading of every page goes in one table, a row per reading and a column per size and arm, and `results.json` keeps each round's readings and the table's lowest (`lowest`), which the daily chart reads. ## Each measurement's method Kept as it was: - CPU: thread ticks (or Firefox's OS count), the load until the main thread goes quiet, idle subtraction, the mean over each input's count, per-window `ready` for inputs that need setup, interleaved rounds and the lowest reading. - Paint: painted.js goals from the input event or the agent's first write, the POST's answer by attempt, request attribution against what the page started while left alone (starters pooled across rounds), long-frame owners, and `--profile`'s trace and attribution. - Server: unchanged code. What changed, each a call Max may reverse: - **Each pass reads a fresh page.** The CPU pass and the paint pass of each round each build and serve the page anew, so no input meets what another pass or round left on it. Scaling served one page through every round, and bench-latency's runs piled up each other's comments, questions and moves. Each pass pays a page build. - **The paint pass starts with the panel folded**, as a page loads, and the reply opens the views it needs. bench-latency opened the Threads view first, a habit from the classic chrome's always-visible thread list (#3100). An open Threads view slows the server's reading on screen: a click's `shown` on the asks page at 128 sections read 59–61 ms with it open and 43–47 ms folded, three fresh pages each, interleaved. - **The paint pass times each input as many times as the CPU pass reads it** (a click four times, a revision twice, the conversation's inputs once) and keeps the median, as scaling read `shown` over four clicks. Every round's samples are in `results.json`. - **One statistic across rounds: the lowest**, for every reading. bench-latency printed median [min-max] over runs. - **Both passes open `browser.tab`'s window**, which reduces motion, as scaling's did; bench-latency's context used no preference, which may be why a card move painted sooner here (not checked). - **`revision` saves only**, inserting a paragraph under the title, as an agent's ordinary save does (scaling's input inserted and then removed one). bench-latency's revision, a save followed at once by `leaf page stamp`, is the `stamp` input, and the note's stamp-route analysis now runs as `leaf-dev bench corpus --read paint --input stamp --base`. - **Targets are found on any page.** The comment selects the first paragraph after the title (the triage board's lede, as before; on the corpus its own lede rather than the triage lede deep inside it). A move takes the first card with a column left of it (`card-tz` on the triage board, bench-latency's first move). The agent's thread is a general one, made at the first reply and taken in by the page before the reply's window opens; bench-latency anchored one on the triage lede before the page loaded. An anchored agent thread made every click on the asks page cost about 70 ms more CPU (13 → 82 ms at 8 sections), so it would have changed every other input's reading. - **Input order**: the page's own inputs, then the two revisions, then the selection, then those that add threads and to-dos. A selection standing on the title holds a revision back (after a triple click on the title, a save left the page on its old revision for 5 s), so the selection follows the revisions. - **`--read paint` also counts requests and bytes**, from the same window, so they have no read of their own. - **`--browser firefox` reads only `cpu`**: the paint pass needs Chrome's DevTools protocol for its requests, and bench-latency ran only in Chromium. - **The daily run takes every input with the default reads** (`leaf-dev bench --sizes 64,128,256 --rounds 2`). Its chart is now "Bench at 64 sections" and holds the load's and each input's main-thread CPU and each gesture's `shown` (`asks: click cpu`, `asks: click shown`, ...); request counts and single paints stay in the summary, the log and the artifact. `gh-pages` holds no reading yet, so the rename loses nothing. - **The reply reads its delivery in parts**: on a page seeded with many events, the first `leaf wait` delivers them all with the question, in parts (14 on the threads page at 64 sections). The reply follows each part's `leaf delivery read <id> --part N`, as the delivery tells an agent to, and joins their text, leaving the seeded threads queued as the page was generated. - **`compare_profiles` is gone**: its side-by-side window and render times repeated what the table and each arm's profile already print. - **Whether an input posts is read from its goals**: an input waits for its POST's answer in the CPU pass where its goals include the server's reading of its event. Whether it paints stays declared (`Input.paints`), since a run refuses `--read paint` with no painting input before it builds a page, and the paint pass skips an input without running its `ready`, whose setup moves the page. ## Equivalence Old and new on the same page, inputs and sizes, back to back on this Mac. The old commands ran from untracked copies of main's `scaling.py` and `bench_latency.py`. **CPU, asks page, lowest of two rounds** (`leaf-dev scaling asks prose --sizes 64,128 --rounds 2` at load 6 against `leaf-dev bench asks prose --sizes 64,128 --rounds 2 --input click --input key --input leave --input tab --input scroll --input revision` at load 4), ms at 8 / 64 / 128 sections: | Reading | scaling | bench | | -------------- | -------------------- | -------------------- | | load | 180 / 388 / 627 | 181 / 404 / 640 | | click | 11.8 / 21.2 / 28.0 | 19.8 / 22.7 / 28.5 | | key | 4.1 / 4.6 / 5.3 | 5.0 / 5.7 / 4.9 | | leave | 11.2 / 28.8 / 48.0 | 16.2 / 30.9 / 40.8 | | Tab | 9.0 / 11.5 / 11.0 | 12.4 / 9.4 / 10.9 | | wheel | 1.2 / 2.5 / 3.9 | 1.5 / 2.4 / 3.3 | | revision | 26.2 / 131.9 / 241.6 | 29.1 / 126.9 / 242.3 | | event | 4.9 / 7.8 / 10.5 | 6.6 / 8.5 / 10.5 | | click `shown` | 28.4 / 28.7 / 29.3 | 29.8 / 30.9 / 32.7 | The prose page reads alike (load 146 / 159 / 172 against 147 / 158 / 168, revision 12.6 / 23.3 / 36.6 against 15.5 / 27.9 / 39.6). A click at 8 sections spreads from 11 to 21 ms between passes on one served page (`cpu_pass` three times on each of two pages read 14.0, 11.4, 16.9 and 18.7, 21.4, 11.8), so its 19.8 is one pass's draw. Two readings sit consistently above scaling's, here and in an independent A/B: `shown` by about 2 ms, and `leave` at 64 sections by about 3 ms. For `shown`, the likely cause is a colder page: scaling clicked for `shown` after its whole CPU pass, and here the first of four clicks on a fresh page reads 40–46 ms and the rest 29–33. The paint tab's instrumentation isn't it: with and without Chrome's network domain and the long-frame observer, three fresh pages each, the medians were 31.7–32.2 and 30.6–32.7 ms. A quick look found no cause for `leave`. **Paint, triage board, three rounds** (`leaf-dev bench-latency --page triage-board --runs 3` against `leaf-dev bench triage-board --read paint --rounds 3 --input comment --input move --input reply --input status --input stamp`, both at load 4), median [min–max] ms over the runs: | Input | bench-latency painted | bench painted | bench-latency Sent | bench `shown` | requests, KB | | ----------------- | --------------------- | ------------- | ------------------ | ------------- | -------------------- | | comment | 51 [49–89] | 73 [71–76] | 66 [66–89] | 93 [92–96] | 1, 5.5 / 1, 5.4 | | move | 11 [10–21] | 11 [10–14] | 32 [26–45] | 33 [32–35] | 1, 6.2 / 1, 6.1 | | reply | 94 [55–176] | 68 [62–72] | | | 2, 4.6 / 2, 4.5 | | status | 79 [56–91] | 110 [91–115] | | | 1, 1.5 / 1, 1.7 | | revision / stamp | 234 [228–277] | 251 [248–264] | | | 2, 160 / 2, 147 | The comment and status differ because every bench round reads a fresh page, so each is the page's first: bench-latency's first run read the comment at 89 ms, the status at 91 and the move at 21, and its later runs, on a page that already held them, 49–51, 56–79 and 10–11. The panel's state doesn't explain the comment: with the Threads view open and folded, three fresh pages each, it painted in 73 and 72 ms; the status read 93 and 114. The stamped revision's bytes differ because it now inserts a paragraph where bench-latency's appended words to the lede. **Server paths** (`leaf-dev scaling --server events options --sizes 128,256` against `leaf-dev bench events options --read server --sizes 128,256`): the same code, reading within 0.5 ms on every path (append on events 1.7 / 6.9 / 12.1 against 1.9 / 7.1 / 12.1). **Selection** (`leaf-dev bench asks document --sizes 512 --input select --read cpu`): 24.9 → 159.2 ms on asks and 31.9 → 45.0 on document, from 8 to 512 sections; #5472 read 26 → 152 and 32 → 40 on main. ## Callers `.github/workflows/ci.yaml` (the daily job is now `bench`, charting the load's and each input's CPU and each gesture's `shown` at 64 sections: the readings it charted under new names, less the server's `event` time and size, plus the new inputs' CPU and the comment's `shown`), root `AGENTS.md` ("Responsiveness" names the command), `tests/AGENTS.md` (the rule #5522 wrote names it), `dev/AGENTS.md`, `browser/AGENTS.md`, `notes/user-feedback-responsiveness.md`, `notes/shift-watch-cost.md`, and comments in `floating.js`, `toc.css`, `test_interact_layer.py`, `painted.js/py`, `main_thread.py`, `profiles.py` and `browser.py`. ## Size and checks `bench.py` is 2,175 lines where `scaling.py` and `bench_latency.py` were 2,241 together; the whole change is +2,257 / −2,315. The two commands shared little code after #5546 (arms, painted.js, profiles), so the saving is one CLI, one orchestration and one report in place of two; what this buys besides is every input on every page, every read on every input, and one place to add the next. The daily job's two steps ran locally at one round and exited 0: `uv run leaf-dev bench --sizes 64,128,256 --rounds 1` in 723 s at load 6–7 over asks, document, prose and threads, and `uv run leaf-dev bench --read server` in 163 s; the chart step's `jq` over their `results.json` gave 56 series (`asks: load cpu` 468.91 ms, ...). The rows page #5567 added, now in `COLLECTIONS` and `AXES`, ran alone in 168 s at load 4–5 (`leaf-dev bench rows --sizes 64,128,256 --rounds 1`, exit 0) and adds 14 series, so the chart holds 70. The job runs two rounds of all five pages, so expect about 30 minutes on this Mac under its 120-minute guard. Also run on this Mac: the equivalence runs above; `--profile` (asks at 16 and 32, the CPU growth listing and the paint attribution); `--base` (triage-board's move and status on the merge base and the head); `--browser firefox`, whose default read is `cpu`; `--read paint --input move --input click` on asks, which names move missing; the reply on threads and messages at 64; the refusals of `--read paint` with no painting input, of `--read server` with `--base` or an authored page, of Firefox with `--read paint` or `--profile`, and of an unknown PAGE; `uv run pre-commit run` on every changed file, including `ty`, `vulture` and `actionlint`. Not verified: the corpus page; WebKit, which the command refuses as before. Supersedes #5472. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…ame whose judgement never completes (#5530) #5803 moved the suite to Playwright 1.65.0, whose Firefox build no longer loses frames. This raises the dev group's Playwright floor to 1.65, since on 1.64.1 the frames Playwright loses would now fail their test (measured below). The `[project]` dependency serves Chrome only and stays at 1.64. `judge_watches` asked each Firefox child frame `wait_for_function("() => true")` with the 120 s suite deadline, and read the timeout as "Playwright lost this frame, nothing to judge". Each lost frame cost the full deadline. The feature gallery's Firefox console test took 1,614 s on [daily run 42014155473](https://github.com/max-sixty/leaf/actions/runs/42014155473), 1.1x under the per-test limit. This PR removes that probe (`_reachable`). Every frame is judged the same way in every engine, through one bounded `wait_for_function` that starts the drain on its first reading and returns when the drain completes. When that deadline expires, the test fails with a note naming the frame, rather than skipping the frame. No wait left in `judge_watches` decides a result by expiring (`tests/AGENTS.md`, "Functional results do not depend on execution speed"; #5522). ## Why frames were lost The frames are lost by Playwright's Firefox (Juggler), not by Leaf. Juggler learns that a frame's navigation has started from an observer whose subject is the frame's docShell, passed as a bare `nsISupports`. Its `FrameTree` read `docShell.browsingContext` without `QueryInterface(Ci.nsIDocShell)`. In one run, the lookup found the frame for the early navigations and returned nothing for the later ones, and those navigation starts were dropped. When the new document's element is inserted, Juggler finds no pending navigation, so it never commits the document, never creates its execution context and never runs init scripts there. Firefox itself loads the document normally, and the sample becomes ready. Why the unqueried read works at first is inferred, not observed: XPConnect reuses an earlier reflector of the docShell that was queried for `nsIDocShell`, until garbage collection frees it. Pages of window samples trigger the loss: 18 `window` samples lost 2 to 11 frames per run, and 12 plain samples lost none. Upstream fixed it in Firefox r1564 ([microsoft/playwright#43494](microsoft/playwright#43494), `const docShell = subject.QueryInterface(Ci.nsIDocShell)`). Playwright 1.65.0 ships r1572. Evidence: - A copy of Juggler patched to log its observer printed `frame=null` without the `QueryInterface`, and the right frame with it, for every lost navigation. A second observer on the same topic fired for all 18 loads. - A plain Playwright page with 12 sandboxed iframes navigated in batches of three lost none. ## Before and after The feature-gallery Firefox console test on this Mac, `-n 0 -p no:randomly`: | Harness | Firefox | Time | Child frames | |---|---|---|---| | main | r1555 (Playwright 1.64.1) | 1,213 s | 10 of 18 timed out at 120 s each; 8 answered in 0.01 s | | main | r1572 (Playwright 1.65.0) | 14 s | 18 answered | | this PR | r1572 | 17 s | all judged; slowest 0.03 s | | this PR on Playwright 1.65.0 | r1572 | 22 s | passes | | this PR | r1555 | fails after 136 s | `Timeout 120000ms exceeded`, "judging the watches in about:blank" | The r1572 rows drive the downloaded r1572 build from this tree's Playwright 1.64.1 client through `executable_path`. ## Control `test_words_in_a_firefox_frame_its_page_hides_fail_when_judged` types words into an opaque Firefox frame, as a sample's is, and then the page hides the frame. A hidden frame paints nothing, so only the judgement reports the loss. With Firefox child frames skipped in `_judge_frame_watches`, the test fails with no finding. `test_health_judgement_releases_a_frame_removed_inside_its_evaluation` now watches the one `wait_for_function` call, since judgement no longer calls `evaluate`. The comment in `input_work_watch.js` no longer cites lost Firefox frames as the reason a port message carries its source as an extra field. A worker, which runs no init script, still reads past that field. ## Checks - `tests/journeys/test_render_gate.py -k firefox_console_warnings`: all 48 corpus pages pass on r1572 (44.75 s, `-n 3`). - `tests/browser/test_render_shift_watch.py -k "frame or deadline"` with `test_a_wait_takes_the_suites_deadline`: 20 passed. - `tests/browser/test_render_words_watch.py -k frame`: 4 passed. - `dev/tests/browser/test_browser_diagnostics.py`: 7 passed. - `pre-commit run --files` on the changed files. - On Playwright 1.65.0's own client, after merging main: the feature-gallery Firefox console test (22 s, `-n 0`), the hidden-frame control and `-k health_judgement` pass. Not verified locally: Linux, and the Firefox browser tests outside the corpus console sweep and the control; the pull request's `test` job runs them. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
A session changing leaf-dev bench or a workflow loads the root file and dev/AGENTS.md, and the rule that no test passes or fails on a reading lives in tests/AGENTS.md. Read alone, the root's budgets led a fresh agent to keep the daily run's growth gates in 3 of 3 runs; with the pointer it turns them into reported readings in 3 of 3, which is what the maintainer chose in #5522.
tests/AGENTS.mdheld functional tests to giving the same result when the system runsten times slower, and sent performance to be tested "separately, under controlled
conditions". Max's rules now cover every test: "we should never have the timings be a
test, we should have a rule that running on a 10x slower machine still passes", and "we
should never pass/fail based on benchmark results".
The section "Functional results do not depend on execution speed" becomes "Results do not
depend on execution speed", and says:
slower than the one it was written on, since CI's runner and a host running other
sessions' suites are both slower than an idle development machine;
benchmark reports its readings (
leaf-dev scaling, charted daily), and a reader judgesthem;
--cpu-throttle 10checks a test against the rule; it slows only Chromium's renderer,not the server, Python or the driver, and doesn't reach a page from
browser.unwatched;on CI's runner, whose
testjob records each test's time in its junit results(
leaf-dev suite-profile)."Absences" now says how to assert that something didn't happen, the commonest violation:
wait for a later event ordered after the moment the forbidden behavior would have
happened, then check it is absent. It names the events the suite already waits on: the
page's sends coming back (
round_trip), the page taking in what the server holds(
told), the shared clock's next tick (ticked), and a later gesture of the same kind."Wait for the operation's own completion signal" already covers a fixed wait before an
assertion that something happened.
Three other places follow:
test_a_wait_takes_the_suites_deadlinecalled a sleep "an absence window"; it now saysa sleep bounds nothing and points at "Absences". Its check never read sleeps, so only
the docstring changes.
faulthandler_timeout's comment inpyproject.tomlsaid the slowest test takes underthree minutes on CI. On the 2026-11-05 nightly, sixteen tests took longer than 180 s,
the slowest 1,614 s. Max decided the half-hour limit stays a guard against a hang,
outside the ten-times rule, and the comment now says so. The limit itself is unchanged.
--cpu-throttleslows every page the browser fixtures open; it now saysthe pages the
browserfixture watches. The two comments that cite the section byheading follow its new name.
dev/AGENTS.mdsays nothing about timing;leaf-dev scaling's own header owns how itmeasures. No eval was run on this wording.
Related: #5563 took the daily growth tests' pass/fail out, so nothing gates on a benchmark's reading; #5523 holds the playground wait and the scaling changes, and #5541 the fixed
waits before absence assertions.