Skip to content

Read the note's centring against the page's box, not the window - #33

Closed
leaf-agent wants to merge 2 commits into
mainfrom
fix/ci-32671963516
Closed

leaf-agent wants to merge 2 commits into
mainfrom
fix/ci-32671963516

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

Problem

ci is red on main at 749e467 — one deterministic failure in test_a_note_moves_the_page_only_where_the_page_owes_it_room, the test that commit added: column centred at 792px of 1600px, assert 7.5 <= 1.

The 7.5px is the stable scroll gutter. Body owns the document's scroll and reserves a gutter for it whether or not a scrollbar is drawn, so on the runner the page's box is 1585px inside a 1600px window and the column centres at 792.5px — a settled decision made at the gutter, reasoned there at length ("reserving a gutter never costs more than the shift not reserving it produces"), and nothing the note has a part in. The test asked the window for the centre a page with no strip would sit on, and the window is that width only where scrollbars overlay — so it was green on macOS, where the reservation is a no-op, and red on Linux.

Solution

Read both halves against the page's box rather than the window. ROOM_GEOMETRY gains pageBox — body's padding box — because neither reading it already had can answer this: column is what the strip moved, room is what the strip left, and only a box the strip cannot resize says whether one was taken at all. The strip is body's padding, so "no strip" is exactly "the column is on the centre of that box", stated without reference to any platform's scrollbar.

The fix is in the test, not the theme: the strip arithmetic the commit landed is doing what it says, and the assertion was measuring the scroll region instead.

Testing

Reproduced locally at the same assertion before the change. Checked non-vacuous in both directions against the corpus, since a centring assertion is easy to pass by accident:

corpus edit result
restore the flat --strip-l: var(--note) wide half fails by 108px — the figure the docstring names
drop it to --strip-l: 0px narrow half fails, note painted 34px off the left edge

uv run pytest tests --run-nightly — 1035 passed, 6 skipped. pre-commit clean on the changed file.

An adjacent observation, not fixed here

stateStrip publishes --lf-avail as document.documentElement.clientWidth, which still includes body's scroll gutter — so the page's box is reported 15px wider than it is, and the strip under-buys by that much. Measured at the 1100px band: the note's gutter lands at 16.5px where --col-pad is 24px, half the gutter short. It never paints off the edge, so no assertion sees it, and closing it means deciding how the runtime learns a width it may not measure off the box it writes into — a design call rather than a CI fix, so it is left alone here.


Automated fix for failed run

The strip a sidenote claims comes out of body's padding, so what says none was
taken is the column sitting on the centre of the box that padding is spent from.
The new test asked the window for that centre instead, and the two are the same
width only where a scrollbar takes no room.

Body owns the document's scroll and reserves a stable gutter for it, a decision
made at the gutter and reasoned there: wherever scrollbars take room the page is
15px narrower than the window and stands 7.5px to its left, note or no note. So
the assertion was a statement about the machine it ran on — green on macOS,
where overlay scrollbars make the reservation a no-op, red on the runner, and
blind in both to a strip of exactly the gutter's width.

ROOM_GEOMETRY gains that box as `pageBox`, body's padding box, which is neither
of the two readings it already had: `column` is what the strip moved and `room`
is what the strip left, and only a box the strip cannot resize can say whether
one was taken at all. Both halves of the test now read against it.

Checked in both directions with the corpus: restoring the flat `--strip-l:
var(--note)` fails the wide half by the 108px the docstring names, and dropping
the reservation to 0px fails the narrow half with the note 34px off the edge.

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test and lint are both green on 542408b, and the geometry holds up: body owns the document's scroll under html:not(.lf-copy), so body.clientWidth is the padding box less the stable gutter, and the strip is body's own padding — a box the strip cannot resize, which is precisely what the window reading wasn't. The two corpus edits in the description cover non-vacuity in both directions, which is the part tests/CLAUDE.md asks for on a geometry assertion.

One naming point. paper is already a term of art here — it is the print medium (theme.css: "What paper does lose is…", leaf.js: "paper needs no rule of its own, never having been handed the arrangement to undo") and --paper is the background token. This helper reads the box of the live page, the one medium the surrounding comment says paper does not have, so the name points at the wrong thing. The returned key is already pageBox, so the two names disagree with each other too. page() sits alongside span() and box() without borrowing a word that means something else.

Comment thread tests/test_render.py Resolved
Comment thread tests/test_render.py Resolved
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

The same failure recurred on main at ba9ddff — run 32674009273, test_a_note_moves_the_page_only_where_the_page_owes_it_room, column centred at 792px of 1600px, assert 7.5 <= 1. Byte-identical to the run this PR was opened for, two commits later, which settles it as deterministic rather than the contention shape running-tend warns about.

Neither intervening commit reaches this: 3889756 touches interact.py and test_interact.py, ba9ddff touches leaf.js only, so the ROOM_GEOMETRY change here still applies to current main — the PR reads MERGEABLE, blocked only by the admin merge ruleset. No new PR opened.

@leaf-agent

Copy link
Copy Markdown
Collaborator Author

On the adjacent observation folded into the description — the --lf-avail under-buy — it is not the design call it looks like. stateRoom, the other geometry reading in that file, already reads that exact gutter, with the reasoning written beside it: the difference of body's two boxes is the scrollbar, no platform can be asked for it, and it is constant through a slide because both boxes move with the margin together. It is also invariant under the padding stateStrip itself writes — padding is inside clientWidth and inside offsetWidth — so the one-writer rule is not in the way here.

Not proposing a PR for it against the queue that is already open; leaving the verified change here so it is one line whenever you want it.

The change, and what it measures
 function stateStrip() {
-  const avail = document.documentElement.clientWidth - panelStrip() - trayStrip();
+  const gutter = document.body.offsetWidth - document.body.clientWidth;
+  const avail =
+    document.documentElement.clientWidth - panelStrip() - trayStrip() - gutter;
   document.body.toggleAttribute("data-lf-cramped", avail < STRIP_MIN);
   document.documentElement.style.setProperty("--lf-avail", avail + "px");
 }

At the 1100px band on NOTE_AND_WIDE_PAGE, Linux: the note's left gutter goes from 16.5px to 24px, which is --col-pad exactly — the "same gutter main gives its prose" the docstring claims. On a platform where the reservation is a no-op the term is zero and nothing moves, so the two platforms come out at 24px together rather than 24 and 16.5.

The gate for it, since nothing in the suite can currently see the drift — the narrow half already resizes and reads, so it is one more assertion there:

    gutter = page.evaluate(
        "() => parseFloat(getComputedStyle(document.querySelector('main')).paddingLeft)"
    )
    assert abs(tight["note"]["left"] - gutter) <= 1, (
        f"the strip left the note a gutter of {tight['note']['left']:.0f}px where main "
        f"gives its prose {gutter:.0f}px, so the room the page reserved was not the room "
        f"the note needed"
    )

Bug-back: with the runtime line reverted it fails abs((16.5 - 24)) <= 1. With both, tests/test_render.py -n8 --run-nightly is 538 passed at d5fb790, and test_interact.py test_product_page.py test_site.py 503 passed / 6 skipped. pre-commit run --all-files clean.

--strip-min is the other reader of avail, and the term makes the veto stricter by the gutter's width — a page inside 15px of the floor hands its strip back where it did not before, which is the direction that errs toward the page having the room it claims.

@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Third occurrence, now at 39cf80c — run 32685064246, same assertion and same numbers: column centred at 792px of 1600px, assert 7.5 <= 1, with the other 1046 tests green. The previous comment argued by inspection that the intervening commits don't reach this; that is now measured rather than inferred, three commits further out.

Merged this branch into main at 39cf80c in a scratch worktree — clean auto-merge, tests/test_render.py the only file touched — and ran the test on both sides on a Linux runner: main fails at abs((792.5 - 800)) <= 1, main + this branch passes. So the branch still fixes current main and no rebase is needed. mergeable reads MERGEABLE, mergeStateStatus BLOCKED by the admin merge ruleset. No new PR opened.

@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Not re-reporting the recurrence or the merge check — the comment above has both. One thing not yet on this thread: this PR's own test check has never reached a terminal state on bb06c43, so waiting for green here will not terminate on its own.

Attempt 1 sat in_progress on the 🧪 Test suite step for 2h53m; I cancelled it and reran, and attempt 2 has now been on that same step for 36 minutes — 3.2× the 11.6-minute worst of the last 40 healthy test jobs that #30 measured, and past the 30-minute bound #30 proposes. Same signature both times, so a third rerun is not worth the runner.

That makes #30 the practical gate on this PR, not just an adjacent fix: the assertion change here is verified correct against current main (measured in the comment above), but the check that would show it green is the one wedging. Worth reading them together.

Tonight's wedges, and the log that confirms the signature

Four more since #30's table closed on 2026-08-22, all on the 🧪 Test suite step:

run branch suite started state
32672180928 main (ee0b04f) 22:58:22Z wedged 4h12m — cancelled by me at 03:11Z
32673823845 main (3889756) 23:30:44Z still in_progress
32674220313 main (d5fb790) 23:40:33Z still in_progress
32674522503 this branch 23:54:38Z / 02:50:28Z attempt 1 wedged 2h53m; attempt 2 wedged 36m+

I cancelled 32672180928 specifically to make its log readable — logs 404 while a job is in-flight — and it is #30's shape exactly. Suite runs clean to 96%, then four hours of nothing, then the orphan set ending in a live browser:

22:58:22Z  8 workers [1041 items]
23:07:20Z  ........ [ 89%]
23:08:07Z  ........ [ 96%]
           (4h03m of silence)
03:11:14Z  Terminate orphan process: pid (2923) (uv)
03:11:14Z  Terminate orphan process: pid (2927) (pytest)
03:11:14Z  Terminate orphan process: pid (2928) (python)   ← ×8, the xdist workers
03:11:14Z  Terminate orphan process: pid (3084) (chrome-headless-shell)

No F before the stall and no failure recorded, so the hang is in the final chunk rather than a consequence of the note-centring failure this PR fixes — that one reports and the suite moves on (445s end to end on 32683708019).

The two main runs above are left alone rather than cancelled: they are superseded by later commits and will hit GitHub's 360-minute cap on their own, and #30's evidence is built from exactly those cancelled runs.

@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Closing this as superseded, not as wrong. f3d7df1 replaced test_a_note_moves_the_page_only_where_the_page_owes_it_room with test_a_note_sets_the_page_axis_with_its_whole_strip, so this diff no longer applies — git merge-tree origin/main origin/fix/ci-32671963516 conflicts, and the function the hunk anchors on is gone from main.

The 7.5px came straight back with the rewrite: run 32695640826, column centred at 600px of 1600px, assert 7.5 <= 1, fourth occurrence. #36 carries the same pageBox helper and the same reasoning onto the test that exists now, and extends it to the two edge readings the rewrite left measured from the window. The branch stays, so nothing here is lost.

The wedged test check noted above is unresolved and belongs to #30, not to either of these.

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.

1 participant