Skip to content

integration: \Box, math accents, \underbar, frame environment (#532, #534, #541, #544) - #644

Merged
GoKubar merged 36 commits into
mainfrom
agent/kabir-claude/integration-532-534-541-544
Sep 15, 2026
Merged

GoKubar merged 36 commits into
mainfrom
agent/kabir-claude/integration-532-534-541-544

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Integration branch carrying four PRs that all append to the same compiler hub files (parser.rs, supported.rs, vocabulary.rs, the supported-latex inventory and its generated artefacts). Merged one at a time they repeatedly race each other back to CONFLICTING; merging this PR lands all four as a single unit. Each PR is merged with --no-ff, so every contributor's commits and authorship are preserved.

What each PR contributes

Closes #532, closes #534, closes #541, closes #544.

Conflict resolutions

Verification on the combined head

  • cargo test --release --manifest-path crates/compiler/Cargo.toml --no-run — clean compile, run first and separately.
  • Full compiler suite: 70 targets, 829 passed, 0 failed, 10 ignored.
  • apps/mac/scripts/sync-supported-latex.sh --check — bundled copy byte-identical (b879443ce3b6).

Implementation-Agent: fable-integration-2
Commit-Executor: fable-integration-2 (direct; Cursor usage limit)

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

d-q222 and others added 30 commits September 14, 2026 23:16
Real amssymb defines \Box and \square as exact synonyms (amsfonts.sty:152
lets \Box to \square, AMSa slot "03, Ord). The compiler already rendered
\square but diagnosed $\Box$ with a misleading 'is a text command' error,
because 'Box' sat in KNOWN_UNIMPLEMENTED_COMMANDS without ever being a
real text-mode command here.

- math.rs: add ("Box", "□") beside ("square", "□") in COMMAND_GLYPHS,
  so \Box parses to the same open-square glyph with the same Ord class and
  lays out the same (generic LM U+25A1 advance vs msam slot advance agree
  to 0.000219em, sub-pixel at any size).
- vocabulary.rs: drop "Box" from KNOWN_UNIMPLEMENTED_COMMANDS. No test
  references it and 'square'/'blacksquare' show stale entries there are
  harmless, so removing it from the array is enough on its own.
- Regenerate supported-latex.json and docs/user/compiler.md (551 -> 552
  math-mode entries) plus the Mac app's bundled copy via
  render_supported_latex.sh; coverage.md unchanged (math symbols sit
  outside its denominator).

Tests: box_parses_to_squares_open_square_glyph_and_class,
square_keeps_its_package_gate (regression), and
box_and_square_lay_out_the_same_open_square in math.rs
package_gating_tests. Mutation check: with the row reverted the new test
fails with '\Box is not supported in math mode'; restored, all pass.
Full crates/compiler suite: 672 passed, 0 failed.

Nothing under crates/render-pipeline/ touched: \Box reuses \square's
existing generic glyph rendering, no new IR node.

Implementation-Agent: muse-spark-1.3-contributor
Three new Accent variants (Dddot, Ddddot, Mathring) appended to the
enum with command()/glyph()/dispatch arms following the existing
accent_atom pattern. Dddot/Ddddot return None (no triple/quadruple-dot
character in WinAnsi or Symbol, like Check/Breve) and degrade with a
warning; Mathring uses U+00B0 degree sign, the closest real ring-shaped
base-14 glyph (U+02DA exists in none of this compiler's font tables).
Removes the three names from KNOWN_UNIMPLEMENTED_COMMANDS, extends the
supported-LaTeX inventory rows, regenerates supported-latex.json,
coverage.md, docs/user/compiler.md and the Mac bundled copy, and adds
parsing/layout/warning tests parallel to the existing accent tests.

Implementation-Agent: muse-spark-1.3-contributor
The frame environment now parses its body with box_inlines and sets it
as one Inline::ColorBox with an fboxrule frame in the current colour,
sized to its content with fboxsep padding, instead of the
unsupported_feature plain-text fallback. No new box-drawing code: both
layouts already handle ColorBox (the Core 14 layout sets it inline; the
render pipeline draws the shared BoxRec::ColorBox frame rules).

Also truncate block_par_leading in box_inlines, which leaked one entry
per boxed paragraph and broke the one-entry-per-block invariant (same
pattern as argument_inlines).

Implementation-Agent: muse-spark-1.3-contributor
Commit-Executor: muse-spark-1.3-contributor
…-UNDERBAR)

\underbar{text} is a LaTeX2e kernel command (latex.ltx) drawing the same
TeXbook Rule 10 math-rule under an unbreakable hbox as text-mode
\underline. It reuses the existing Inline::Underline path with
UnderlineGeom::MathUnderline, needs no package, and never touches the
render pipeline.

Implementation-Agent: muse-spark-1.3-contributor
…ne (GH-UNDERBAR)

Slice-1 aliased text-mode underbar to underline's geometry and claimed
math-mode underbar raises \@badmath. Both wrong against latex.ltx:

- latex.ltx:619 defines \def\underbar#1{\underline{\sbox\tw@{#1}\dp\tw@\z@\box\tw@}}:
  the Rule 10 construction runs over a depth-zeroed hbox, so the rule sits
  at a fixed 3theta below the baseline (total depth 5theta). pdflatex
  confirms: \underline{y} dp=3.94434pt (d+5theta, d=1.94444pt) vs
  \underbar{y} dp=1.9999pt (5theta); showbox shows the zeroed inner hbox.
  New UnderlineGeom::Underbar ignores box depth; MathUnderline keeps the
  measured content depth (descender-glyph sniff at 0.194444em, pdflatex-
  measured for g/j/p/q/y/Q).
- \@badmath ('Bad math environment delimiter') belongs to \(/\)/[/] only;
  underbar in math mode expands to \underline's \ifmmode branch and works
  (pdflatex: no error for $\underbar{x}$). math.rs now maps underbar to
  Frame::Under like underline, plus inventory/vocabulary sync.

Implementation-Agent: muse-spark-1.3-contributor
…, not Accent

Slice 1 typed these as plain Accent variants. The real source
(amsmath.sty 744-749, TeX Live: {\mathop{\kern\z@#1}\limits^{\vbox...}})
is an operator base with a fixed three/four-dot text box in limits
position, not a \mathaccent (contrast \dot/\ddot, fontmath.ltx
\DeclareMathAccent). Reuse the existing Nucleus::Stacked overset
machinery: script-size dots centred at a fixed height over the base,
Ord class forced for the outer braces. \mathring is a genuine
\DeclareMathAccent (amsmath.sty 793-794): left alone.

Implementation-Agent: muse-spark-1.3-contributor
…d with main's inventory growth

docs/user/compiler.md (generated) conflicted where main's new entries and
this branch's \Box synonym both changed the Supported LaTeX section. Took
main's copy, then regenerated via crates/compiler/scripts/render_supported_latex.sh
so \Box and main's additions both appear (552 math entries); Mac bundled
supported-latex.json synced and --check clean.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
… collided with main's inventory growth

docs/user/compiler.md (generated) conflicted where main's new command
entries and this branch's \dddot/\ddddot/\mathring rows both changed the
Supported LaTeX section. Took main's copy and regenerated via
crates/compiler/scripts/render_supported_latex.sh (554 math entries, both
sides present); Mac bundled supported-latex.json synced, --check clean.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
…llided with main's inventory growth

docs/user/compiler.md (generated) conflicted where main's new entries and
this branch's \underbar rows both changed the Supported LaTeX section.
Took main's copy and regenerated via
crates/compiler/scripts/render_supported_latex.sh (309 text / 552 math
entries, both sides present); Mac bundled supported-latex.json synced,
--check clean.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
…rted-latex docs

crates/compiler/src/parser/colors.rs conflicted because both sides created
the file (main's refactor vs this branch's copy plus frame work); the only
divergence was this branch's explanatory comment on block_par_leading
truncation, which is kept. docs/user/compiler.md (generated) conflicted on
the Supported LaTeX section; took main's copy and regenerated via
crates/compiler/scripts/render_supported_latex.sh (50 environments, frame
row present); Mac bundled supported-latex.json synced, --check clean.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
…rew the inventory

docs/user/compiler.md (generated) conflicted once more after main's page
and paragraph control commands (#568) landed. Took main's copy and
regenerated via crates/compiler/scripts/render_supported_latex.sh so \Box
and main's additions both appear; Mac bundled supported-latex.json synced,
--check clean.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
…in's VSpace pattern break

Generated artefacts (docs/user/compiler.md, supported/supported-latex.json,
coverage.md, Mac bundled copy) conflicted after main's inventory grew; took
main's copies and regenerated so both sides appear, sync --check clean.

Also carries a one-line semantic merge fix main itself needs: #606 added
stretch_pt/shrink_pt to Block::VSpace but left the pattern in
tests/kernel_untested_b.rs:251 as 'Block::VSpace { pt }', which fails
E0027 on current main; widened to 'Block::VSpace { pt, .. }'.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
…in's VSpace pattern break

Generated artefacts (docs/user/compiler.md, supported/supported-latex.json,
coverage.md, Mac bundled copy) conflicted after main's inventory grew; took
main's copies and regenerated so \underbar and main's additions both
appear, sync --check clean. Also the one-line fix current main needs:
tests/kernel_untested_b.rs:251 'Block::VSpace { pt }' fails E0027 after
#606 added stretch_pt/shrink_pt; widened to '{ pt, .. }'.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
…NMENTS; regenerate docs; fix main's VSpace pattern break

crates/compiler/src/vocabulary.rs conflicted because this branch removed
'frame' (implemented here) while main removed samepage/sloppypar
(implemented by #568); kept both removals. Regenerated the supported-latex
artefacts via render_supported_latex.sh; Mac bundled copy sync --check
clean. Also the one-line fix current main needs:
tests/kernel_untested_b.rs:251 'Block::VSpace { pt }' fails E0027 after
#606 added stretch_pt/shrink_pt; widened to '{ pt, .. }'.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
Clean textual merge of current main; regenerated supported-latex artefacts
(no drift, sync --check clean). Carries the one-line semantic fix current
main needs: #606 added stretch_pt/shrink_pt to Block::VSpace but
tests/kernel_untested_b.rs:251 still matched 'Block::VSpace { pt }'
(E0027 on main itself); widened to '{ pt, .. }'.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
…rew the inventory

docs/user/compiler.md (generated) conflicted again; took main's copy and
regenerated via render_supported_latex.sh, sync --check clean. Main's #636
VSpace-pattern fix matches the one this branch already carried.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
 grew the inventory

Generated artefacts conflicted again (docs/user/compiler.md,
supported/supported-latex.json, coverage.md, Mac bundled copy); took
main's copies and regenerated via render_supported_latex.sh so the math
accents and main's additions both appear, sync --check clean.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
 grew the inventory

Generated artefacts (docs/user/compiler.md, coverage.md) conflicted again;
took main's copies and regenerated via render_supported_latex.sh so
\underbar and main's additions both appear, sync --check clean.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
…rew the inventory

docs/user/compiler.md (generated) conflicted again; took main's copy and
regenerated via render_supported_latex.sh so the frame environment and
main's additions both appear, sync --check clean.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
/#635 grew the inventory

docs/user/compiler.md (generated) conflicted again; took main's copy and
regenerated via render_supported_latex.sh so \underbar and main's
additions both appear, sync --check clean.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
…er src-binding break

docs/user/compiler.md (generated) conflicted again; took main's copy and
regenerated via render_supported_latex.sh, sync --check clean. Also carries
the fix current main needs to compile render-pipeline: #623's memoised
SourceIndexes refactor dropped the 'let src' binding in the ListItem arm of
split_at_page_breaks while its own line still calls
list_style_nextline(src, ...) (E0425 at adapter.rs:2788 on main d7b7f9f);
restored the pre-refactor binding from texts.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
…entory growth

docs/user/compiler.md (generated) conflicted again; took main's copy and
regenerated via render_supported_latex.sh so \Box and main's additions
both appear, sync --check clean.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
…OMMANDS

crates/compiler/src/vocabulary.rs conflicted: main still lists dddot,
ddddot and mathring as known-unimplemented while this branch implements
them; kept this branch's removal (they are in the implemented registry).
Regenerated the supported-latex artefacts, sync --check clean.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
Main's #638 rewrote list_style_nextline to read the memoised index, making
the src binding this branch restored (to unbreak d7b7f9f) unused; dropped
it so the merged tree carries no dead binding. Supported-latex artefacts
regenerated, sync --check clean.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
… landed

docs/user/compiler.md (generated) conflicted once more after #540 merged;
took main's copy and regenerated via render_supported_latex.sh, sync
--check clean.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
… landed

docs/user/compiler.md (generated) conflicted once more after #540 merged;
took main's copy and regenerated via render_supported_latex.sh, sync
--check clean.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
… landed

docs/user/compiler.md (generated) conflicted once more after #540 merged;
took main's copy and regenerated via render_supported_latex.sh, sync
--check clean.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
docs/user/compiler.md (generated) conflicted again; took main's copy and
regenerated via render_supported_latex.sh, sync --check clean.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
docs/user/compiler.md (generated) conflicted again; took main's copy and
regenerated via render_supported_latex.sh, sync --check clean.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
docs/user/compiler.md (generated) conflicted again; took main's copy and
regenerated via render_supported_latex.sh, sync --check clean.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
docs/user/compiler.md (generated) conflicted again; took main's copy and
regenerated via render_supported_latex.sh, sync --check clean.

Implementation-Agent: fable-rebase-a
Commit-Executor: fable-rebase-a (direct; Cursor usage limit)
Implementation-Agent: fable-integration-2
Commit-Executor: fable-integration-2 (direct; Cursor usage limit)
Implementation-Agent: fable-integration-2
Commit-Executor: fable-integration-2 (direct; Cursor usage limit)
Resolved math.rs dispatch arm as the union of both sides (Aboxed from main,
underbar from the branch); regenerated supported-latex artefacts.

Implementation-Agent: fable-integration-2
Commit-Executor: fable-integration-2 (direct; Cursor usage limit)
Resolved KNOWN_UNIMPLEMENTED_ENVIRONMENTS as the union of removals (main
removed small/footnotesize, the branch removed frame; only tabbing stays);
regenerated supported-latex artefacts.

Implementation-Agent: fable-integration-2
Commit-Executor: fable-integration-2 (direct; Cursor usage limit)
KNOWN_UNIMPLEMENTED_ENVIRONMENTS resolved as the union of removals: main
removed tabbing (#642) and eqnarray/eqnarray* (#645), this branch removed
frame (#544); none re-added. Generated supported-latex artefacts regenerated
via render_supported_latex.sh, never hand-merged.

Implementation-Agent: fable-integration-2
Commit-Executor: fable-integration-2 (direct; Cursor usage limit)
@GoKubar
GoKubar merged commit 0b7a2b0 into main Sep 15, 2026
10 of 21 checks passed
GoKubar added a commit that referenced this pull request Sep 15, 2026
The Sep 13 baseline no longer describes main: the engine moved ~465
commits (integration queues #644/#646 and today's ~66 merges), and the
digest half of the gate is a hard equality against recorded output, so
every PR was failing on drift this harness did not cause. Verified on
the Sep 14 run of #232: FAIL was 'output changed in 50 place(s)' only;
timings were correctly reported-not-enforced on the foreign runner.

Why re-recording is legitimate rather than gate-disarming:
- This branch adds no engine code (crates/perf-bench, .github, docs
  only), so the tree whose output was recorded IS origin/main's engine,
  byte for byte. The digest drift is main's own, each contributing PR
  individually gated by the pdflatex oracles.
- Same reference host as the Sep 13 recording (linux/x86_64/AMD Ryzen 7
  7800X3D/16cpu), same build profile, recorded by the same procedure
  (README), full 26-case corpus at the current cap policy.
- Old vs new, 267 metrics: 90 digests changed; timings moved with
  main's own optimization work, dominated by the adapt fix (#623):
  synthetic-500kb cold 3434.9 -> 531.5 ms, synthetic-2mb first render
  44513.5 -> 2344.2 ms, math-heavy 184.1 -> 134.5 ms. Improvements of
  that size are exactly what a stale timing baseline can no longer
  calibrate against.

The corpus grew from 12 to 26 recorded cases (article-twocolumn,
input-bibliography and the other real-world fixtures landed on main
after Sep 13); the gate's per-PR --only set is a subset. Known notes
carried in the report, not failures: tikz-heavy PDF export is refused
by the exact route (path_stroke unsupported - a product limitation the
harness reports), siunitx-tables carries an unsupported \SI syntax
diagnostic, unicode-accents reports CJK missing_glyph.

Implementation-Agent: fable-ft070
Commit-Executor: fable-ft070 (direct; Cursor usage limit)
GoKubar added a commit that referenced this pull request Sep 15, 2026
…ession gate (#206)

* 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: follow main's assemble and Capabilities signatures

typeset::assemble grew page_color/default_color (mirrored from the
product path in lib.rs, doc.page_color/doc.default_color), and
v1::Capabilities grew device_color/delta/v2_only, all off in the
harness's fixed capability set.

Implementation-Agent: fable-ft070
Commit-Executor: fable-ft070 (direct; Cursor usage limit)

* perf-bench: recalibrate the committed baseline to current main

The Sep 13 baseline no longer describes main: the engine moved ~465
commits (integration queues #644/#646 and today's ~66 merges), and the
digest half of the gate is a hard equality against recorded output, so
every PR was failing on drift this harness did not cause. Verified on
the Sep 14 run of #232: FAIL was 'output changed in 50 place(s)' only;
timings were correctly reported-not-enforced on the foreign runner.

Why re-recording is legitimate rather than gate-disarming:
- This branch adds no engine code (crates/perf-bench, .github, docs
  only), so the tree whose output was recorded IS origin/main's engine,
  byte for byte. The digest drift is main's own, each contributing PR
  individually gated by the pdflatex oracles.
- Same reference host as the Sep 13 recording (linux/x86_64/AMD Ryzen 7
  7800X3D/16cpu), same build profile, recorded by the same procedure
  (README), full 26-case corpus at the current cap policy.
- Old vs new, 267 metrics: 90 digests changed; timings moved with
  main's own optimization work, dominated by the adapt fix (#623):
  synthetic-500kb cold 3434.9 -> 531.5 ms, synthetic-2mb first render
  44513.5 -> 2344.2 ms, math-heavy 184.1 -> 134.5 ms. Improvements of
  that size are exactly what a stale timing baseline can no longer
  calibrate against.

The corpus grew from 12 to 26 recorded cases (article-twocolumn,
input-bibliography and the other real-world fixtures landed on main
after Sep 13); the gate's per-PR --only set is a subset. Known notes
carried in the report, not failures: tikz-heavy PDF export is refused
by the exact route (path_stroke unsupported - a product limitation the
harness reports), siunitx-tables carries an unsupported \SI syntax
diagnostic, unicode-accents reports CJK missing_glyph.

Implementation-Agent: fable-ft070
Commit-Executor: fable-ft070 (direct; Cursor usage limit)

---------

Co-authored-by: Claude Opus 5 <[email protected]>
GoKubar added a commit that referenced this pull request Sep 15, 2026
…uster 160 -> 88 B) (#232)

* 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

* perf-bench: follow main's assemble and Capabilities signatures

typeset::assemble grew page_color/default_color (mirrored from the
product path in lib.rs, doc.page_color/doc.default_color), and
v1::Capabilities grew device_color/delta/v2_only, all off in the
harness's fixed capability set.

Implementation-Agent: fable-ft070
Commit-Executor: fable-ft070 (direct; Cursor usage limit)

* perf-bench: recalibrate the committed baseline to current main

The Sep 13 baseline no longer describes main: the engine moved ~465
commits (integration queues #644/#646 and today's ~66 merges), and the
digest half of the gate is a hard equality against recorded output, so
every PR was failing on drift this harness did not cause. Verified on
the Sep 14 run of #232: FAIL was 'output changed in 50 place(s)' only;
timings were correctly reported-not-enforced on the foreign runner.

Why re-recording is legitimate rather than gate-disarming:
- This branch adds no engine code (crates/perf-bench, .github, docs
  only), so the tree whose output was recorded IS origin/main's engine,
  byte for byte. The digest drift is main's own, each contributing PR
  individually gated by the pdflatex oracles.
- Same reference host as the Sep 13 recording (linux/x86_64/AMD Ryzen 7
  7800X3D/16cpu), same build profile, recorded by the same procedure
  (README), full 26-case corpus at the current cap policy.
- Old vs new, 267 metrics: 90 digests changed; timings moved with
  main's own optimization work, dominated by the adapt fix (#623):
  synthetic-500kb cold 3434.9 -> 531.5 ms, synthetic-2mb first render
  44513.5 -> 2344.2 ms, math-heavy 184.1 -> 134.5 ms. Improvements of
  that size are exactly what a stale timing baseline can no longer
  calibrate against.

The corpus grew from 12 to 26 recorded cases (article-twocolumn,
input-bibliography and the other real-world fixtures landed on main
after Sep 13); the gate's per-PR --only set is a subset. Known notes
carried in the report, not failures: tikz-heavy PDF export is refused
by the exact route (path_stroke unsupported - a product limitation the
harness reports), siunitx-tables carries an unsupported \SI syntax
diagnostic, unicode-accents reports CJK missing_glyph.

Implementation-Agent: fable-ft070
Commit-Executor: fable-ft070 (direct; Cursor usage limit)

---------

Co-authored-by: Claude Opus 5 <[email protected]>
@GoKubar
GoKubar deleted the agent/kabir-claude/integration-532-534-541-544 branch September 16, 2026 04:17
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.

render-pipeline/compiler: the 'frame' environment is unimplemented

2 participants