Repository navigation
render-pipeline: one page builder for longtable regions and footnote insertions, closing the dropped-footnote-with-floats bug (reconciles #282/#284 with #253) - #343
Merged
GoKubar merged 4 commits intoSep 14, 2026
Conversation
…math Floats: `floatpage::paginate` carries the page builder's `InsertState` (notes charged against `\@colroom`, `\@pageht` counts `\footins`, split and held notes, the `\@doclearpage` notes page) and sets a note column as `\@makecol`: body, `\skip\footins`, `\footnoterule` and notes, then bottom floats. `pagebuild::settle_inserts` factors out sections 1018-1021. `\thanks`: title marks are `\rlap`ped and the notes follow the title's last line; `\@fnsymbol` marks take ts1-lmr TFM metrics. Mark clearance is depth + x-height/4 (rule 18c). A paragraph break in a note sets `\par` and the 1em `\parindent` box. Math in notes uses the `\footnotesize` math fonts (8/6/5, 10/7/5); 9pt keeps body metrics with a diagnostic. Oracle: 15 new pdflatex fixtures (floats t/b/p/h, split, deferred; `\thanks`; report/book chapters; note math; minipage). Rebased from PR #154 onto main 190 commits later. Its first commit (`d7ddf641`, footnotes at the column foot) is already on main; only this one was outstanding. Four places where main had moved: - `Context` gained `multicol::State` on main while this branch gained `rlap_marks`/`math_fonts_sized`; all three are kept. - Inline math. This branch changed `math_box` to take the text size, so a formula in a note is laid out with that size's math fonts; main meanwhile split a formula into `math_pieces` for inline line breaking. The two are orthogonal: `math_box(list, span, false, size)` feeding `math_pieces(rec, size, span)`. The `\LaTeXe` logo's `\varepsilon` -- main's only other `math_box` caller -- passes the surrounding text size, so a logo inside a note follows the note. - `TexMathMetrics::new` gained a `cmex_designs` parameter on main (family 3 at amsfonts' designs rather than `omxcmex.fd`'s `sfixed` 10pt) and `fraktur`/`alphabets` fields. This branch refactored the same function into `at_text_size`, which is what makes 8pt note math possible at all. Merged: `at_text_size(text_pt, cmex_designs, otf, fonts) -> Option<Self>` keeps main's designs switch and both new fields, and `new` delegates to it. - `BoxRec::Rule` gained a `bottom` field on main; the `\parindent` box of a note's paragraph break sets it to 0 (the baseline), and main's `width <= 0 || height <= 0` guard already covers the zero-height rule this branch was skipping with an arm of its own. Footnotes oracle, `vendor/compiler` re-pinned locally to the reconstructed `NEEDS_COMPILER` fixtures -- `\thanks` symbol marks, report/book chapter resets and the `\long` note argument -- are gated rather than merely measured, and they pass. 39 fixtures: 34 gated and matching pdflatex, 5 in `REPORTED` for constructs that are still unimplemented. `cargo test --release` on crates/render-pipeline: 202 passed, 0 failed -- the same count as main, because the 15 new fixtures live inside the existing oracle test rather than adding test functions. Rebase-Agent: Claude Opus 5 (engine lane, linux-primary) Implementation-Agent: Claude Opus 5 (subagent kabir-claude footnotes 2, mac-m5pro-kabir) Commit-Executor: Claude Code direct Git Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
…xact `15-math-note` was in the footnotes oracle's `REPORTED` set -- measured and printed, never asserted -- because "the formula is one rigid box in the justified line, while TeX also stretches its \thickmuskip/\medmuskip", worth up to 1.7 bp on the words after it. Setting the note's math with the \footnotesize math fonts removes that gap: on main the fixture is 395 of 414 words with a worst delta of 0.334 bp and 0 of 1 rules; on this branch it is 414/414, worst 0.005 bp, 1/1 rules -- the same floor as every other exact fixture. A fixture that matches pdflatex should be asserted, so it leaves `REPORTED`. The other four stay: `13-minipage`/`39-minipage-notes` need minipage box layout, `36-math-note-11pt` needs cmr9/cmmi9/cmsy9 that math-layout does not embed, and `38-math-note-fraction` paints the radical and \sum from Latin Modern Math rather than lmsy8/lmex10. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
…ColhT Extends draft #154 (`agent/kabir-claude/footnotes-2` @ 8217e98), which this branch is based on and does not replace. #154 already carries the insertion state through the float paginator; these are the two places its model and pdflatex disagree, both found by ten new fixtures and both measured against local pdflatex (TeX Live 2025). 1. **§1005's shrink allowance.** The box-overflow shortcut fired at `total > \pagegoal`, but TeX only calls a page hopeless once the excess passes what the glue can shrink. A body of `\parskip 0pt plus 1pt` has no shrink, so this never showed without insertions; `\skip\footins`'s `minus 2pt` (and an `h` float's `\intextsep`) supplies some, and the column lost the line TeX keeps. `06-float-page-note` was a body line short on page 1 with the `\footnoterule` 11.36 bp high. 2. **One `\vbox to\@colht`, not a body packed to `\@colroom`.** `\@makecol` attaches the notes to `\box\@cclv` first (the default `build/column/outputbox` plug is `footnotes-floats-legacy`) and only then `\@combinefloats` wraps the floats around that, so the column is top floats, \floatsep between them, \textfloatsep, the body, the \vfil \@outputbox@removebskip lifted off its end, \skip\footins, \footnoterule, the notes, \textfloatsep, the bottom floats, \vskip-\dp, \@textbottom `\@cflt` and `\@cflb` build plain `\vbox`es and only `\@make@normalcolbox` packs `\vbox to\@colht`, so a single glue set ratio covers the body's glue, `\skip\footins` (`plus 4pt minus 2pt`) and both `\textfloatsep`s (`plus 2pt minus 4pt`) together. Setting the body and notes to `\@colroom` on their own and then placing the bottom floats by a rule (flush at `\@colht` with a `\vfil` or `\flushbottom`, natural otherwise) gives `\skip\footins` no share of the slack: on `02-bottom-float-note` the rule, the notes and the bottom float sat 1.276 bp high, and on `08-twocolumn-float-note` the second column's body sat 1.137 bp high from its fourth line down. `pagebuild::make_column` now takes the column's float material (`ColumnFloats`) and returns where it put each float box (`FloatPlacement`), which replaces the `keep_depth` flag and the `text_off` shifting in `floatpage`. `break_pages_inserts` passes an empty `ColumnFloats` and is unchanged. `\@cflt`/`\@cflb`/`\@makecol`/`\@specialoutput` were read from latex.ltx as shipped by TeX Live 2025, and the column order was confirmed against a `\tracingoutput=1` dump of a page carrying a top float, a note and a bottom float. Ten under `fixtures/float-notes/`, with `tools/float-notes-oracle/generate.py` and the `float_notes_oracle` test: top float + note, bottom float + note (notes above the float), a note that defers a float through `\@pageht`, three competing `[t]` floats with notes, a note split under a top float, a `[p]` float page with a note pending, an `h` float with notes, two-column, `\clearpage` with a note and deferred floats, and a page with a top float, a bottom float and three notes. **reference_engine: pdfTeX 3.141592653-2.6-1.40.27 (TeX Live 2025/nixos.org)** — generated on this Linux host, recorded in each expected file's header. Unlike the MacTeX 2026 data under `fixtures/footnotes/` and `fixtures/floats/`, none of which is regenerated here. Implementation-Agent: engine-engineer (kabir-claude float-notes lane) Commit-Executor: engine-engineer (direct git, Cursor usage limit fallback) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
\long \footnote argument reach the pipeline `git archive f9bab2a:crates/compiler` (was `5baa9e6e`, the #250 merge). This is the re-pin the footnote work has been waiting on, and it carries several already-merged compiler changes that were inert without it: * #281 `\thanks` as symbol footnotes, report/book `\chapter` counters and minipage footnote marks -- what `compiler_has_footnote_counters()` probes before the pipeline's footnote oracle asserts its gated fixtures. * #259 a `\footnote` argument parsed as `\long`, so a note may hold a paragraph break. * `~`/`\nobreakspace` (which was unsupported *and silently dropped the space*, and became a literal tilde inside a macro body), text-mode `\,`/`\!`/`\:`/`\;` decaying inside macro bodies, and four amsmath limit operators. The re-pin must land with the pipeline change, not before it: with this vendor and no footnote placement, `page_frame_against_pdflatex` fails `35-article-maketitle-thanks` by ~11.7bp, because the compiler emits `\thanks` as a symbol footnote the pipeline then cannot place. `vendor/compiler`'s own `tests/tabular_corpus` was two batches stale (59 fixtures against main's 106); the export brings it current. The pipeline's `tabular_oracle` reads `crates/compiler/tests/tabular_corpus`, not this copy, so that is tidiness rather than a gate change. No `table.rs` change was needed: `ct::Entry::CMidRule`'s `kern_left`/ `kern_right` arrived in #250, which the previous pin already carried, and `table.rs` already binds them. Implementation-Agent: claude-opus-5 (linux-primary, page-builder lane) Commit-Executor: claude-opus-5 (direct git, Cursor usage limit in effect) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
d-q222
added a commit
that referenced
this pull request
Sep 14, 2026
…section main (#343's re-pin batch) changed the generated counts in docs/user/compiler.md. Regenerated with crates/compiler/scripts/render_supported_latex.sh: 244 text, 546 math (542 on main + \odot \ominus \oslash \bigcirc), 48 environments, 14 packages. supported_latex 8/0; full crates/compiler suite has no failures. Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
d-q222
added a commit
that referenced
this pull request
Sep 14, 2026
…rtefacts main (#343's batch) moved the generated inventory. All four conflicts were generated files: docs/user/compiler.md, crates/compiler/supported/ {supported-latex.json,coverage.md}, and the Mac bundled copy. Regenerated them with crates/compiler/scripts/render_supported_latex.sh and copied the Mac copy byte-for-byte (CompletionTests.testBundledInventoryMatchesTheCompiler). Counts: 253 text, 542 math, 48 environments, 14 packages. cargo test --no-fail-fast -p compiler: every binary ok except robustness::deeply_nested_input_does_not_blow_the_stack (debug-build stack overflow), which fails the same way on main 8f83ab5. Picked up after daniel-vpclaude's handoff. Commit-Executor: daniel-parent (Claude Code, mac-m5pro-dq222) Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
GoKubar
added a commit
that referenced
this pull request
Sep 14, 2026
…ough the accessor `tests/footnotes_oracle.rs` and `tests/float_notes_oracle.rs` arrived on main with the single page builder (#343) and read `&page.items`, which this lane made a method returning `Option<&Vec<Item>>`. Both are unwindowed renders, so they take `resident_items()` -- the accessor that panics on an elided page rather than reading it as empty -- like the other 23 tests this lane converted. Implementation-Agent: claude-opus-5 (engine lane, linux-primary NixOS) Commit-Executor: claude-opus-5 (direct git; Cursor usage limit in effect) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar
added a commit
that referenced
this pull request
Sep 15, 2026
… has no reply (#294) * perf-bench: FT-070 benchmark harness, committed baseline and a >5% gate There was no way to tell whether an engine change made the compiler faster. The numbers that existed came from `examples/stages.rs` and `perf_bench.rs`: macOS-only metadata, one sample per cell, no memory figure, no machine-readable output, and no way to fail a build on a regression. This adds a harness whose output can be argued with. `crates/perf-bench` measures the product path -- the same `protocol::handle_line` the `flashtex-render` worker serves -- over the ten committed real-world fixtures and four generated documents (500 KB, 2 MB, math-heavy, TikZ-heavy; generators committed, not blobs). Per case it reports cold timings with a per-phase split, warm single-keystroke timings, PDF export, peak and steady RSS, and an output digest. `--baseline ... --check` turns the same run into a CI gate. Three rules the harness enforces on itself, because breaking any of them produces numbers that look fine and mean nothing: * No measurement without fonts. Latin Modern and the pinned 12 pt TFM set must load and no render may substitute a face or a metric, or the case produces no timing at all -- a substituted metric is a different workload, not a slower one. The font set is built with `FontSet::with_dirs`, which probes nothing, so this box's TeX Live cannot supply the metrics by accident. The line is drawn at the configuration, not the document: a character with no glyph, or a class command the compiler does not model, is deterministic and identical every run, so the case is measured and the degradation is recorded next to the number. * Cold means cold. Every repetition runs in a child process of its own, so the expander's thread-local cache, the font set's memoised faces and the allocator all start empty, and peak RSS belongs to one document. * Medians, with the spread shown. Nothing comes from one sample; every metric carries n, p25/p75, p95 and MAD, and the table prints the run's own noise estimate per case. The gate is built to survive a shared machine. A metric counts as regressed only when it exceeds both the tolerance and that metric's own measured spread in the baseline, and the comparison warns and stops enforcing timings when the host, build profile, font configuration or peak load differ. Output identity does not depend on the machine -- the fonts come from the repository -- so a changed digest fails everywhere and unconditionally. Baseline, at main 8465bbd on a Ryzen 7 7800X3D: cold HW1 meets its 10 ms target; warm keystroke is 153x over budget at 500 KB and 132x at 2 MB, HW1 PDF export is 5.6x over, and steady memory at 2 MB is 49x over. Full numbers, method and three findings are in docs/evidence/perf-ft070-2026-09-13. The clearest of those findings: typesetting a 2 MB document costs 42.7 s with the document sources attached and 1.04 s without. Two per-formula code paths in render-pipeline's typeset ask a question about the preamble and answer it by searching the entire document, so a document that does not contain the searched string pays a full scan per formula. That crate is another lane's, so this lane has measured and reported it rather than touching it. Gates unchanged (this adds a crate and edits no existing crate's source): amsmath 59/59, HW1/HW2 3 pages with 0 errors and 0 overfull, render-pipeline 170 passed / 0 failed, compiler 395 passed / 0 failed, perf-bench 13 passed. Implementation-Agent: Claude Opus 5 (FT-070 perf lane, linux-primary) Commit-Executor: Claude Opus 5 (direct agent Git execution, per the AGENTS.md Cursor-limit fallback in force on this machine) Co-authored-by: GoKubar <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu * perf-bench: build against current main (assemble colour params, Capabilities fields) `typeset::assemble` grew `page_color`/`default_color` and `v1::Capabilities` grew `device_color`/`delta`/`v2_only` after the harness was written. Pass `None`/`None` and spread the default so the measured path is still the one the committed baselines were recorded against. Reported on PR #206. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu * display list: derive the cluster carets instead of storing them per glyph `Cluster` carried a `Carets { first: Caret, last: Option<Caret> }` — 72 of its 160 bytes — and a text run emits one cluster per glyph, so a 1507-page document held 1.48 million caret pairs. They were never independent data: carets.first == Caret { text_byte: text_start_byte, x: hit_rect.x, top: hit_rect.top, height: hit_rect.height } at all three construction sites (text runs, math, TikZ node text), and `place_item`/`shift_x` moved the rect and both carets by the same offset, so placement preserved it too. Audited over the twelve corpus cases — 1 991 552 clusters — the start caret was byte-identical to the derived one in every single one, the end caret never sat on a cluster other than its run's last, and its top/height always equalled that cluster's hit rect. So `Cluster` keeps the rect and derives both carets, and the one thing that is genuinely not derivable — the end caret's `x` (the TikZ path clamps the hit rect's width to one tick but not the caret) and its text byte — moves to the run as `GlyphRun::end_caret`, one per run instead of 40 bytes per glyph. `Cluster`: 160 -> 88 bytes. This also makes an invariant structural that `join_runs` used to maintain by hand: it cleared the joined-over cluster's trailing caret so that only a run's last cluster carried one. With the caret on the run there is nowhere for a mid-run one to live. Output is unchanged and that is the point of the change: both JSON emitters and the delta digest now call `GlyphRun::carets_of`, which reconstructs the same `Carets` value. `delta::changed_items` compares `end_caret` once per run in place of `carets` per cluster — the same comparison, since the rest of the caret is the cluster bytes and hit rect it already compares. Measured on synthetic-2mb (1507 pages, 1.48M clusters), the perf harness reports identical digests for all three scenarios (cold.reply b0d5e89b71ab0200, warm.type-display-eq 4ec7e38a83002099, warm.type-paragraph 484f07ea71d1b181) and steady RSS 5107 -> 4897 MiB. FT-070. Reported on PR #206. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu * perf-bench: a memory profile that says where the resident bytes went FT-070's memory gap was a single number with no attribution. This adds the instrument, so the breakdown is measured rather than argued about. `render_pipeline::memsize` walks an already-built display list and render cache and charges allocated bytes (capacity, not length — that is what the allocator holds) to named lines, counting each shared `Rc` once so the two totals can be added. It is read-only and touches no render path. `memprofile <case>` renders a corpus case through the product path, runs the warm keystrokes the harness runs, and reports VmRSS, live bytes from a counting global allocator, and the walked breakdown, so the three gaps are separated: live-minus-walked is what the walk cannot reach (font, expander and compiler caches), RSS-minus-live is allocator retention, and a `malloc_trim(0)` probe splits that last one into trimmable and fragmented. It is a second binary because the counting allocator must not be linked into the timing binary, and `main.rs` keeps its own module declarations: every committed baseline was recorded by it exactly as it stands. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu * tests: build the cluster carets through the derived accessor Two tests constructed or read `Cluster.carets` directly. The JSON round-trip test now sets the run's `end_caret` — which also makes it check that both writers agree about *which* cluster shows the end caret, not just about its value — and the joined-fragment test reads `GlyphRun::carets_of`, so it still asserts the property it was written for: a caret never falls outside its own cluster's byte range. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu * display list: materialise a bounded window of pages, not the whole document FT-070's structural half. #232 established that 100 MB over 1507 pages is ~68 KB a page -- less than one page of glyph data at any representation that keeps per-glyph carets and source ranges -- so the target cannot be reached by representation and the document has to stop being resident. `protocol/proposals/display-list-v2-window.md` is the proposal; this is its producer-side prototype. The wire capability is specified and NOT negotiated: `v1.rs` does not accept the name, no consumer sends it, and an unwindowed render -- every render on every route today -- is byte-for-byte unchanged. Where the window belongs. `-only` and `-delta` are serialisation levers: they choose what of an already-built `DisplayList` reaches the consumer, so a `-window` built at that boundary would cut wire bytes and leave resident memory exactly where it is. The window therefore takes effect at `typeset::assemble`, the first point where per-page glyph data exists, and is declared at the protocol boundary because whether a reply covers the whole document is a contract fact, not something a consumer should infer. Layout still runs over the whole document -- page breaking, `\pageref`, floats and contents lists are global and a window over them would change output. Only assembly is windowed. The completeness hazard, and what it forced. The font closure and the `math_resource_profile` / `math_glyph_unmapped` diagnostics are derived during assembly over every block, so a window that assembled only its own blocks would emit a quietly smaller closure and fewer diagnostics. `assemble_windowed` therefore still visits every block in the same order and harvests before it drops: what the window changes is retention, not the traversal. An assembled block reaching no resident page is dropped and never cached. `Page.items: Vec<Item>` becomes `Page.content: PageContent` (`Resident(..)` or `Elided`). Deliberately a breaking change rather than a `resident: bool` beside a retained `items`: the failure mode being designed against is a consumer that reads `items` without checking, and there is now no silent path. `pdf::write_pdf` refuses a windowed list, `v1::fallback` skips an elided page, and `delta` takes no snapshot from one and emits no delta against one (a window and a delta are mutually exclusive in r1, since the delta's `list_digest` binds a digest for every page). On the wire an elided page carries its frame, `"resident": false` and no `items` key at all -- absent, not `[]`, so a consumer that ignored the flag fails to decode rather than painting a blank page. A resident page gains no marker, which is what keeps every existing digest identical. `tests/page_window.rs` is the acceptance gate, and it is equality rather than a digest: over every window position of a 20-page document, each resident page must serialise byte-identically to that page in the unwindowed render, and the documents, fonts, diagnostics and required features must match the complete compile's. A digest would only prove a consumer rebuilt what it was sent; the risk here is a producer sending a correct-looking smaller closure. Measured with `memprofile --window 1:16` against an unwindowed control on the same code path (`--render-only`), 2 MB / 1507 pages: live 1440.7 -> 920.0 MiB, VmRSS 2912.3 -> 2035.8, display list 247.5 -> 2.5. 500 KB / 385 pages: live 363.2 -> 238.1, VmRSS 748.8 -> 541.9. The display list stops scaling with the document, which is the property this is for. What remains is `RenderCache.blocks`, whole-document by design because it is what makes re-materialising a page cheap -- and 2036 MiB is still 20x the 100 MB target. Implementation-Agent: claude-opus-5 (engine lane, linux-primary NixOS) Commit-Executor: claude-opus-5 (direct git; Cursor usage limit in effect) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu * display list: scope the assembled cache to the window, so a scroll stays bounded Without this the window is only a first-render win. `RenderCache.assembled` is append-only -- its sole bound is "clear everything at 50 000 entries" -- so a viewer scrolling a long document accumulates the glyph-level assembly of every page it has passed, and the resident set climbs back to the whole document while the window keeps claiming to be 16 pages. A windowed render now ends by retaining exactly the blocks its resident pages used. `blocks` and `adapted` are deliberately untouched: they are the whole-document layout records that make re-materialising a page cheap, and they are the cache lines the measurements show remaining (160.2 MiB of `BuiltBlock.items` and 73.1 MiB of `ClusterRec` at 2 MB). Bounding those is #232's follow-up 3, not this. An unwindowed render never calls `retain_assembled`, and now also treats every block as wanted whether or not a page placed it -- so a complete compile's cache behaviour is byte-for-byte and entry-for-entry what it was before the window existed, rather than merely equivalent in output. Also: `flashtex-cli`'s `has_content` reads through `Page::items()`, and the proposal now states per section what r1 implements against what it specifies. The gap worth naming is §5.5: the page recipe is NOT retained across requests, so r1 re-runs layout for every window. Serving a scroll without re-layout is the point of retaining it and is r2; the memory this change measures does not depend on it, which is why it is separated rather than bundled in unmeasured. Implementation-Agent: claude-opus-5 (engine lane, linux-primary NixOS) Commit-Executor: claude-opus-5 (direct git; Cursor usage limit in effect) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu * display list: size the page window by the reply limit, not by a memory budget The window lane was written against FT-070's 100 MB target. PR #273 measured something more urgent with the same cause: a 500 KB document has **no reply at all** today. Its `display_list` sibling would be 164 MB against a 16 MiB line limit, so `handle_line` declines it without serialising; the v1 `compile_result` that would carry the pages instead is 20 339 909 bytes for those 385 pages, also over; the request ends `status: failed`. Neither existing sibling capability fixes that, and the reasons are structural. `-delta` needs the full `DisplayList` from `render_cached` before it can diff anything, so it shrinks the wire after the producer has already built and failed to fit the whole document. `-only` empties the v1 `pages` only when a sibling is present, and here the sibling is the 164 MB line that was declined. The window is the only one of the three that makes the producer build less, which is what a size limit actually requires. So `MAX_WINDOW_PAGES` was 512, which is indefensible: at the measured ~426 KB a page that is 218 MB. It is now 64, derived from the arithmetic -- a 16 MiB line carries ~39 pages of that document and the runtime's 8 MiB framed default ~19, both more than a viewer shows and both finite where 1507 pages is not. `PageWindow::fitting(centre, pages, bytes_per_page, limit)` is the widest window a given limit can carry. It takes a measured `bytes_per_page` rather than a constant, because page size varies by an order of magnitude between a title page and a dense one and a constant here would be a guess presented as a bound; the caller supplies the previous reply's `page_bytes` or its own estimate. A page too large for even one to fit still yields a one-page window -- refusing is the protocol's job, not the window's. Nothing calls it until the capability is negotiated. The consequence worth recording is a composition result: `-window` and `-only` are each useless alone at this scale and sufficient together. The v1 payload fails on its own at 385 pages (20.3 MB) and the v2 sibling fails on its own (164 MB), so a consumer that wants large documents to work sends `display-list-v2`, `-only` and `-window` together. That is the first hard reason in this protocol to require two capabilities rather than choose between them. Proposal gains §1.0 for the failure, §1.1 for the memory argument it started from, and the §7 composition rule. `tests/page_window.rs` gains `a_window_is_sized_by_the_reply_limit`, which pins the arithmetic against #273's measured page size rather than against a number invented here. Implementation-Agent: claude-opus-5 (engine lane, linux-primary NixOS) Commit-Executor: claude-opus-5 (direct git; Cursor usage limit in effect) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu * merge main: the new extensible delimiters build on the derived carets and the page's items accessor Three semantic conflicts between this lane and main's `\lVert`/`\rVert` and extensible-delimiter work. The textual merge was clean; none of them is. `typeset.rs`'s stacked-assembly cluster (main's extensible delimiter, one cluster holding the whole Latin Modern Math assembly) set `Cluster.carets` explicitly. #232 removed that field: the carets are derived from `text_start_byte` and `hit_rect` (`Cluster::first_caret`), and the run-level `end_caret` supplies `last` for the final cluster only. The literal it wrote -- `first { text_byte: start, x: g.x, top, height: hh }`, `last: None` -- is exactly what the accessor derives from the `hit_rect { x: g.x, top, width, height: hh }` it sits beside, and the run is built with `end_caret: None`, so dropping the field is value-preserving rather than a behaviour change. `tests/big_delimiter_packages.rs` and `tests/extensible_delimiters.rs` are new on main and read `&page.items`, which this lane made a method returning `Option<&Vec<Item>>`. Both are unwindowed renders, so they take `resident_items()` -- the accessor that panics on an elided page rather than reading it as empty -- like the other 20 tests this lane converted. Builds: `cargo build --tests` clean in render-pipeline, flashtex-cli and perf-bench. Implementation-Agent: claude-opus-5 (engine lane, linux-primary NixOS) Commit-Executor: claude-opus-5 (direct git; Cursor usage limit in effect) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu * display list: negotiate the page window, so the 500 KB document has a reply r1 specified the wire capability and deliberately did not negotiate it, because one of the closures §3 requires whole was not yet whole. This closes that gap and turns the name on, which is what makes the lane's product claim testable rather than argued: the document that returns `status: failed` today now returns a painted window. The gap. `required_features` is derived by classifying items, and it was derived from `resident_page_items()` -- the window's items, not the document's. A document whose only rule sits on page 300 would have announced no `rule` to a consumer windowed on page 1, which is the same failure as a smaller font closure: a consumer negotiating a feature set it cannot paint the rest of the document with. §5.6 already named the rule ("computed during the streaming pass, over every block, not over `pages`"); r1 had not implemented it, and `display.rs` said so in a comment. `assemble_windowed` now harvests `DocumentFeatures` in the same pass that harvests the faces and the diagnostics, from every block including the ones whose only pages are elided, plus the page-level items the block loop cannot see (float images, the `\pagecolor` rule, the document default colour). An unwindowed list still *scans* its own items, so every line on the wire today is byte-for-byte what it was; only a windowed list reads the harvest. `status` too. `v1::fallback` derived `has_content` from the pages it built, and a windowed payload holds only the resident ones, so a window over blank pages of a document carrying an error could have reported `failed` where the unwindowed reply says `recovered`. §4.1 says the window does not change `status`, so the question is now asked of the same whole-document harvest. Negotiation follows `-only`'s pattern exactly. `CAP_WINDOW` is accepted only next to `display-list-v2`, `payload.display_list_window` says where the viewer is, and the name is echoed only on a reply that actually carries a window -- the way `-only` is echoed only when the pages were really elided. Per §7 the window declines `-delta`: a delta binds a digest for every page and a windowed producer has none for a page it never materialised. Per §8 a degenerate window is not an error; the reply is unwindowed and the echo omits the name. One behaviour beyond r1, and it is the one that makes the capability worth having: a window the reply limit still cannot carry is narrowed and served rather than declined. `MAX_WINDOW_PAGES` bounds what a viewer shows, not bytes, so a consumer can legitimately ask for 64 pages of a document whose pages are 426 KB each. Declining that is the `status: failed` this exists to fix, so the producer measures the pages it just built, re-derives the window through the already-present `PageWindow::fitting`, and serves that; the echoed `window` is the authority on what was served, so the narrowing needs no diagnostic (§8). Measured, against the real `synthetic-500kb` corpus case, 385 pages, through the actual `flashtex-render` worker over JSON Lines: today's consumer status failed -- "compile_result would be 20 339 674 bytes for 385 pages, over the 16 777 216-byte reply limit" window 1:16 status recovered, 2 lines, sibling 5 937 794 B, 385 pages / 16 resident / 369 elided window 300:16 status recovered, sibling 6 369 270 B window 1:64 narrowed to 13:40 and served, 15 211 146 B and the §9 equality gate applied to that document rather than to a 20-page stand-in: for windows at 1, 185, 300 and 378, every resident page object is byte-identical to that page in the unwindowed 152 MB render, all 385 page frames match, and `documents`, `fonts`, `diagnostics` and `required_features` are byte-identical. Zero font-failure diagnostics in every run. Tests. `cli_e2e` gains the product bug itself as a regression test: the same three refusals reproduced through `FLASHTEX_MAX_REPLY_BYTES` (the failure is a ratio, not an absolute size), with the limit derived from a measured window and the whole-document size read back out of the producer's own refusal, so nothing is hard-coded to a page size. `page_window` gains the closure test: a document whose only rule is on a late page, windowed on page 1, must still announce `rule` -- and it asserts the resident page carries no rule, so the feature can only have come from the harvest. Reverting the harvest turns that test red with `["glyph_run", "rgba-srgb", "cluster-actualtext"]` against `["glyph_run", "rule", "rgba-srgb", "cluster-actualtext"]`, which is the point. Implementation-Agent: claude-opus-5 (engine lane, linux-primary NixOS) Commit-Executor: claude-opus-5 (direct git; Cursor usage limit in effect) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu * memprofile: build a request the worker accepts, and measure the window on the protocol path `memprofile`'s `request()` built a JSON-RPC 2.0 envelope -- `jsonrpc`, `method`, `params` -- and `protocol::handle_line` requires runtime-v1's `protocol_version` / `type` / `payload`. Every warm keystroke on the default (protocol) path was therefore answered `missing_protocol_version` and rendered nothing, so a default run's warm phase was measuring an empty cache rather than a populated one. The window's published numbers are unaffected: they were measured `--render-only` on both sides, which never builds a request. `crates/perf-bench` proper builds a correct request (`measure.rs:204`), so the digests and the timing gates are unaffected too. What was wrong was memprofile's own default mode, and only its warm phase. With that fixed, `--window` no longer has to imply `--render-only`: the capability is negotiated, so a windowed run can drive the same protocol path the product does, `display_list_window` and all. The comparison rule is unchanged and now stated as "compare like with like" rather than "windowed means render-only". Measured at this commit, release, this machine, zero font diagnostics: synthetic-2mb, --render-only VmRSS 2912.6 -> 2035.9 live 1440.8 -> 920.1 synthetic-2mb, protocol VmRSS 2889.0 -> 2048.5 live 1440.8 -> 920.1 synthetic-500kb, protocol VmRSS 751.3 -> 540.3 live 363.3 -> 238.2 The `--render-only` pair reproduces the r1 table (2912.3 -> 2035.8, 1440.7 -> 920.0) to within 0.1 MiB after the rebase onto current main and the negotiation, which is the point of re-running it. The display list is 2.5 MiB at 385 pages and at 1507, unchanged. The proposal goes to r2: the capability is negotiated, `required_features` is whole-document, `status` is window-independent, and an over-limit window is narrowed and served rather than declined. Implementation-Agent: claude-opus-5 (engine lane, linux-primary NixOS) Commit-Executor: claude-opus-5 (direct git; Cursor usage limit in effect) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu * proposal: r2 records what the producer now does, and what a consumer still has to sign The §9 gate list gains the two tests r2 adds and the equality run against the real 500 KB case rather than a 20-page stand-in. §1.0 gains the measured replies -- the failure and the four windows -- so the section that argues the bug also shows the fix. The measured table notes that the r1 numbers reproduce after the rebase, adds the protocol-path pair the harness fix made measurable, and records the harness fix itself rather than quietly benefiting from it. The co-signer table gains a column. The producer row is signed; the three consumer rows and the Commander row are unchanged in substance but are now explicitly gating the *consumer*, because that is what negotiation changes: no reply on any route is windowed today, and `apps/mac` must not add the name to its capability list until the pane paints an elided page as a placeholder rather than as nothing. Implementation-Agent: claude-opus-5 (engine lane, linux-primary NixOS) Commit-Executor: claude-opus-5 (direct git; Cursor usage limit in effect) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu * protocol: a failed reply echoes no sibling capability `-only` and `-window` are echoed only on a reply that actually carries a sibling line. The over-limit `compile_result` path filtered `display-list-v2` out of the echo but left those two in, so a reply that sent nothing could still have claimed the pages were elided for a sibling, or that a window was served. Reachable only when a windowed or `-only` v1 payload is itself over the limit, which is why it went unnoticed; wrong either way. Implementation-Agent: claude-opus-5 (engine lane, linux-primary NixOS) Commit-Executor: claude-opus-5 (direct git; Cursor usage limit in effect) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu * display list: the comments that said required_features was still the window's Two stale notes left over from r1. `resident_page_items` said deriving a document-wide feature set from it was unreconciled r2 work and the reason the capability was producer-internal; the harvest reconciled it, and the doc now says what the accessor is for instead -- what a list carries, never what the document needs. `negotiate`'s note said "in r1" about the -window/-delta exclusion, which outlived r1. Comments only. The binaries used for the digest and memory runs at this SHA predate these two edits and are unaffected by them. Implementation-Agent: claude-opus-5 (engine lane, linux-primary NixOS) Commit-Executor: claude-opus-5 (direct git; Cursor usage limit in effect) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu * typeset: say which direction the feature harvest can err in The harvest visits every block, including one placed on no page, so it can announce a feature nothing paints. That is the safe direction -- a consumer told to support `rule` when no rule is drawn loses nothing, while a consumer not told is the failure the harvest exists to prevent -- and the §9 equality gate pins the harvest against the unwindowed scan for every document it covers, so an over-announcement surfaces as a windowed reply differing from the unwindowed one rather than passing quietly. Worth saying where the next reader will be standing when a gate fails. Comment only. Implementation-Agent: claude-opus-5 (engine lane, linux-primary NixOS) Commit-Executor: claude-opus-5 (direct git; Cursor usage limit in effect) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu * merge main: the new footnote and float-note oracles read the page through the accessor `tests/footnotes_oracle.rs` and `tests/float_notes_oracle.rs` arrived on main with the single page builder (#343) and read `&page.items`, which this lane made a method returning `Option<&Vec<Item>>`. Both are unwindowed renders, so they take `resident_items()` -- the accessor that panics on an elided page rather than reading it as empty -- like the other 23 tests this lane converted. Implementation-Agent: claude-opus-5 (engine lane, linux-primary NixOS) Commit-Executor: claude-opus-5 (direct git; Cursor usage limit in effect) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu * proposal: the r2 numbers, measured rather than described The memory table stays r1's and now says so, with the r2 re-run of the 2 MB pair beside it: 2919.5 -> 2037.0 MiB VmRSS and 1442.9 -> 922.2 live against r1's 2912.3 -> 2035.8 and 1440.7 -> 920.0, with the display-list and render-cache rows identical to the digit. Reproducing the control after two merges of main is the point of re-running it. The digest gate gets its result: 190 digests over 26 cases, 0 differing, against a control built and run in the same directory from the same merge of main with this lane's changes reverted. Implementation-Agent: claude-opus-5 (engine lane, linux-primary NixOS) Commit-Executor: claude-opus-5 (direct git; Cursor usage limit in effect) Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu * perf-bench: the negotiated window capability stays off in the harness Capabilities gained `window` on this branch; the harness's fixed set keeps it off — the timing and digest gates measure the unwindowed product path, which this branch keeps byte-identical. Implementation-Agent: fable-ft070 Commit-Executor: fable-ft070 (direct; Cursor usage limit) --------- Co-authored-by: Claude Opus 5 <[email protected]>
GoKubar
deleted the
agent/linux-pagebuilder/footnotes-floats-longtable
branch
September 16, 2026 04:17
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.
One page builder that carries longtable regions and footnote insertions, so a page can have a repeating table header and footnotes. Closes the last silent-content-loss bug: on
main, every\footnoteon a page containing a float is dropped.Supersedes #282 and #284 (their branches are untouched), rebased onto
mainf9bab2a7— i.e. onto #253, the longtable page builder that landed in parallel and collided with them.The collision
#253 and #282 were rebased onto the same commit in parallel and both rewrote
floatpage::paginate, leaving two incompatible signatures:main'sregions(longtable\LT@head/\LT@footrepetition) against #282'sbody_blocks/insertionsreturningareas. #282 wrapped the emit loop inif notes { make_column… } else { original loop }, andmain'spending_headlives in that original loop — so the notes path had no longtable awareness at all.The reconciliation is not a signature merge. It is the interleaving.
The design
mainhad already solved this once, for the path without floats:pagebuild::break_pages_inserts_regionscharges\pagegoalwith\ht\LT@footand\skip\footinsplus the notes together, and puts\copy\LT@head/\copy\LT@footinside\box\@cclvbefore\@makecolruns.paginatenow does the same thing, with the floats added, so the two page builders agree construct for construct:\pagegoal, two charges. The cost function takes the region'sreservealongside the insertion state:goal = is.goal - reserve. A continuation foot and a note compete for the same page, exactly as in TeX, andInsertState::appendgets thatreservetoo, so a note must fit above the foot the table is holding back. The §1005 hopeless test readstotal > is.goal - reserve + shrink + 1e-9, keeping render-pipeline: \@makecol packs the whole float+footnote column to \@colht (rebase of #192 onto current main) #284's shrink allowance — which longtable then nulls itself, because\LT@startzeroes\pageshrink(longtable.sty 223).\LT@outputruns before\@makecol. longtable builds\box\@cclvas\vbox{\unvbox\@cclv \copy\LT@foot \vss}and only then calls\@makecol(487-517). So the head and the foot are prepended and appended to the column body, as ordinaryVItem::Boxes, before the column is assembled — the notes are set under the foot, and\@combinefloatswraps the floats around all of it. Because that\vssis inside the body, ahead of\skip\footins, it takes the column's slack and leaves every finite glue at its natural size, which is whyvfilisregion_break || ejected || fired.is_none().\maxdepthis the region-aware one (§987 with longtable.sty 230) on both paths, and aregion_breakstill starts the next column withstart_longtable_column().restarta page when a float changes\@colroom; held-over notes are therefore cloned into the page's insertion state andheldis only cleared once the page is actually settled.settle_insertsis lifted out ofbreak_pages_inserts_regionsso both builders share §1018–§1021 rather than carrying two copies.Is the bug actually closed?
Measured branch against
mainf9bab2a7, same worktree, same build directory, all 22 real-world fixtures plus a float+footnote probe. Page counts identical on all 22. The v2 display list differs in exactly five documents, and every difference is a repair:mainhyperref-tocwarning[unsupported_block] 1 footnote(s) … their text is omitted; note lostlab-reportmath_limitation(9 pt note math on 10.95 pt metrics — the known 11 pt-class limitation,36-math-note-11pt)lmodern-report\footnotes)thesis-chaptererror[compiler] \chapter is not supported …The other 17 are byte-identical. Three real corpus documents were silently losing footnote text on
main.Gates
f9bab2a799-longtable-footnote100-longtable-footnote-after101-longtable-footnotes-three-pagescrates/render-pipelinecargo test --releasecrates/compilercargo test --releaseThe +1 test is this PR's
float_notes_oracle. The footnote oracle's four remaining misses are exactly itsREPORTEDset (13-minipage,36-math-note-11pt,38-math-note-fraction,39-minipage-notes). The tabular gate reads the fixture directory (#251), and all three longtable+footnote fixtures are in it with refs, so 106/106 is an assertion over them and not a hardcoded list. No committed oracle data was regenerated.The vendor re-pin rides with this
vendor/compiler5baa9e6e→f9bab2a7. It must land with the pipeline work, not before: with the new vendor and no footnote placement, the full suite failspage_frame_against_pdflatexon35-article-maketitle-thanksby ~11.7 bp, because the compiler emits\thanksas a symbol footnote the pipeline then cannot place.page_frame_against_pdflatexpasses here. A spot check offootnotes_oracle/tabular_oracle/floats_oracledoes not catch this — the full suite does, and that is what was run.Already merged and inert until this re-pin, so this PR is what makes them reach a user:
\footnoteargument parsed as\long, so a note may hold a paragraph break.\thanksas symbol footnotes, report/book\chaptercounters, minipage footnote marks. This is whatcompiler_has_footnote_counters()probes before the footnote oracle asserts its gated fixtures, and what removesthesis-chapter's\chaptererror above.~/\nobreakspace(previously unsupported and silently deleting the space; a literal tilde inside a macro body), text-mode\,/\!/\:/\;decaying inside macro bodies, and four amsmath limit operators.No
table.rschange was needed.ct::Entry::CMidRule'skern_left/kern_rightarrived in #250, which the previous pin already carried, andtable.rsalready binds them; theE0027reported elsewhere belongs to the different route of repointing the pipeline at the live sibling crates from an older base, not to this re-pin.vendor/compiler's owntests/tabular_corpuswas two batches stale (59 fixtures against main's 106) and the export brings it current — tidiness, not a gate change, sincetabular_oraclereadscrates/compiler/tests/tabular_corpus.🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu