Skip to content

render-pipeline: a proof's QED mark is amsthm's \openbox, four rules, not the glyph-less U+220E (#443) - #699

Merged
d-q222 merged 2 commits into
mainfrom
agent/daniel-parent/qed-glyph
Sep 16, 2026
Merged

d-q222 merged 2 commits into
mainfrom
agent/daniel-parent/qed-glyph

Conversation

@d-q222

@d-q222 d-q222 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

What

\begin{proof}...\end{proof} now ends with amsthm's real QED mark, drawn where
pdflatex draws it. Before this the mark was invisible (GH#443):

qed.tex:3:29: warning[missing_glyph] U+220E '∎' has no glyph in lmroman10-regular; nothing drawn for it

The compiler appends \hfill + U+220E (END OF PROOF) at \end{proof}, but
amsthm's \qedsymbol is \openbox, which is not a character at all:

\def\openbox{\leavevmode
  \hbox to.77778em{\hfil\vrule\vbox to.675em{\hrule width.6em\vfil\hrule}\vrule\hfil}}

— an open square .6em wide and .675em tall drawn with four rules at
TeX's default 0.4 pt thickness. U+220E is a filled square, and Latin Modern
has no glyph for it, so nothing was drawn.

  • adapter.rs: new Item::QedBox { style, span }. The compiler's proof-end
    marker is unambiguous — \end{proof} appends an Inline::HFill with no
    leader and an Inline::Text holding U+220E, and gives both the same span
    (the \end{proof} bytes) — so only that pair converts to QedBox. A U+220E
    typed in the source is a lone text inline with its own span and still goes
    through the ordinary text path.
  • typeset.rs: Context::qed_items sets the hbox — a kern for each \hfil,
    four BoxRec::Rules, and a kern pulling the second \hrule back over the
    first. em is the current face's quad (\fontdimen6), which is what amsthm's
    .6/.675/.77778 are of; the 0.4 pt rule thickness is absolute and does
    not scale. Kerns between boxes are not legal break points, so the mark never
    splits across a line.
  • incremental.rs: cache-key hash and span relocation for the new item.

Why

\openbox is rules, not a glyph, so there was no glyph to substitute: any
lookalike from another family (\square, \blacksquare, Latin Modern Math's
U+220E) has different metrics and the wrong fill. Drawing the rules is both the
faithful and the only metric-correct option.

Overlap check

Test results

New crates/render-pipeline/tests/qed_box.rs, measured against
/Library/TeX/texbin/pdflatex (TeX Live 2026). The oracle page carries no
glyph
for the mark, only four stroked segments:

q 1 0 0 1 470.417 657.235 cm []0 d 0 J 0.398 w 0 0 m 0 6.725 l S Q
q 1 0 0 1 470.616 663.761 cm []0 d 0 J 0.398 w 0 0 m 5.978 0 l S Q
q 1 0 0 1 470.616 657.435 cm []0 d 0 J 0.398 w 0 0 m 5.978 0 l S Q
q 1 0 0 1 476.793 657.235 cm []0 d 0 J 0.398 w 0 0 m 0 6.725 l S Q

As filled rectangles in y-down page bp, against what the pipeline now emits
(x, top, width, height; the rule gate is 0.1 bp):

rule pdflatex pipeline max delta
\vrule left 470.218, 128.040, 0.398, 6.725 470.21778, 128.03985, 0.39851, 6.72478 0.00051
\hrule top 470.616, 128.040, 5.978, 0.398 470.61629, 128.03985, 5.97758, 0.39851 0.00051
\hrule bottom 470.616, 134.366, 5.978, 0.398 470.61629, 134.36613, 5.97758, 0.39851 0.00051
\vrule right 476.594, 128.040, 0.398, 6.725 476.59387, 128.03985, 0.39851, 6.72478 0.00051

and the [12pt] class (cmr12, quad 11.74988pt — reading .6em/.675em off the
nominal 12 pt instead would be 0.15/0.17 bp out):

rule pdflatex pipeline max delta
\vrule left 490.935, 129.851, 0.398, 7.902 490.93465, 129.85191, 0.39851, 7.90151 0.00091
\hrule top 491.333, 129.851, 7.024, 0.398 491.33315, 129.85191, 7.02357, 0.39851 0.00091
\hrule bottom 491.333, 137.355, 7.024, 0.398 491.33315, 137.35492, 7.02357, 0.39851 0.00091
\vrule right 498.357, 129.851, 0.398, 7.902 498.35672, 129.85191, 0.39851, 7.90151 0.00091

Every delta is inside the oracle's own 3-decimal rounding. The test also asserts
the page carries no U+220E glyph run, reports no missing_glyph, and that the
box's lowest edge is the last line's baseline (134.765 bp, pdflatex's).

test proof_ends_with_amsthms_open_box_where_pdflatex_draws_it ... ok
test the_open_box_is_measured_in_the_current_fonts_quad ... ok
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

The neighbouring suites:

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out   (amsthm_topsep)
test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out   (layout_cache_keys)
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out   (theorem_head_separator)
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out   (theorem_items)
test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out   (v2_and_math)

And the whole crate, cargo test: everything green except one pre-existing
failure that is already filed as #667 — frame_env's
shared_colorbox_path_draws_border_with_content_inside, a
debug_assert_eq!(leadings.len(), parsed.blocks.len()) at adapter.rs giving
left: 2, right: 1. It is about block_par_leading vs block counts in a
colorbox document and cannot interact with a new inline item.

test result: FAILED. 0 passed; 1 failed; 1 ignored; 0 measured; 0 filtered out   (frame_env, = #667)

End to end on the issue's own repro, which used to warn
missing_glyph U+220E:

flashtex: qed.tex: ok, 1 page, 0 errors, 0 warnings

and the PDF flashtex build writes now holds the four rectangles, against
pdflatex's strokes above:

470.2177829742431640625 657.23536777496337890625 0.39850521087646484375 6.72478199005126953125 re f
470.6162891387939453125 663.56164455413818359375 5.97758388519287109375 0.39850521087646484375 re f
470.6162891387939453125 657.23536777496337890625 5.97758388519287109375 0.39850521087646484375 re f
476.5938730239868164062 657.23536777496337890625 0.39850521087646484375 6.72478199005126953125 re f

Not done

Issue #443 asks for three things; this is item 1, so #443 stays open rather
than being closed by this PR (no duplicate follow-up filed — items 2 and 3 are
already itemised there):

  • \qedhere (item 2) is still error[compiler] \qedhere is not supported in math mode. It needs compiler work, not pipeline work.
  • A proof ending in a display (item 3): amsthm puts the box on the line
    after the display. Untouched here. The ordinary placement — flush right at
    the end of the proof's last text line, falling to its own line when it does
    not fit — needed no work: it is the compiler's \hfill plus the mark's own
    width, and the oracle rows above are exactly that position.
  • The compiler still emits U+220E rather than a dedicated
    Inline::QedSymbol, which is what amsthm: proof's automatic QED is invisible — U+220E has no glyph in Latin Modern; draw amsthm's \openbox with rules; \qedhere unsupported #443 suggests. Deliberate: the pipeline
    builds against the frozen vendor/compiler mirror, so a change in
    crates/compiler would not reach the render path until a re-pin — and would
    break this PR's marker detection when it did. The compiler-side marker and the
    matching adapter arm belong in the same re-pin PR.
  • {\large\begin{proof}...\end{proof}} is not set at \large by this pipeline
    at all (the proof head and body come out at \normalsize), so the size test
    here uses the [12pt] class option instead. Pre-existing and unrelated.

🤖 Generated with Claude Code

https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

… not U+220E

What changed:
`\end{proof}` appends `\hfill` + U+220E (END OF PROOF), but amsthm's
`\qedsymbol` is `\openbox` -- not a character at all:

  \hbox to.77778em{\hfil\vrule\vbox to.675em{\hrule width.6em\vfil\hrule}\vrule\hfil}

an *open* square .6em wide and .675em tall drawn with four rules at TeX's
default 0.4pt thickness. U+220E is a *filled* square and Latin Modern has no
glyph for it, so the mark warned `missing_glyph` and drew nothing (GH#443).

- adapter.rs: new `Item::QedBox { style, span }`. The compiler's proof-end
  marker is unambiguous -- `\end{proof}` emits an `Inline::HFill` with no
  leader and an `Inline::Text` of U+220E with the *same* span -- so only that
  pair converts; a U+220E typed in the source still takes the text path.
- typeset.rs: `Context::qed_items` sets the hbox: a kern per `\hfil`, four
  `BoxRec::Rule`s, and a kern pulling the second `\hrule` back over the first.
  `em` is the face's quad (`\fontdimen6`); the 0.4pt thickness is absolute.
  Kerns between boxes are not break points, so the mark stays on one line.
- incremental.rs: cache-key hash and span relocation for the new item.
- tests/qed_box.rs: the pdflatex oracle's four rules, to 0.1bp, at 10pt and
  12pt.

What was run:
  cargo test --test qed_box --test theorem_head_separator --test theorem_items \
    --test layout_cache_keys --test v2_and_math --test amsthm_topsep
  test proof_ends_with_amsthms_open_box_where_pdflatex_draws_it ... ok
  test the_open_box_is_measured_in_the_current_fonts_quad ... ok
  test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out (qed_box)
  test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out (amsthm_topsep)
  test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out (layout_cache_keys)
  test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out (theorem_head_separator)
  test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out (theorem_items)
  test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out (v2_and_math)

  flashtex build on the issue's repro, was `warning[missing_glyph] U+220E ...`:
  flashtex: qed.tex: ok, 1 page, 0 errors, 0 warnings
  and the PDF now holds, against pdflatex's strokes at 470.417/470.616/476.793:
  470.2177829742431640625 657.23536777496337890625 0.398505210876464843 6.724781990051269 re f
  470.6162891387939453125 663.56164455413818359375 5.977583885192871093 0.398505210876464 re f
  470.6162891387939453125 657.23536777496337890625 5.977583885192871093 0.398505210876464 re f
  476.5938730239868164062 657.23536777496337890625 0.398505210876464843 6.724781990051269 re f

Next step:
`\qedhere` and a proof ending in a display (issue #443 items 2 and 3) are a
compiler lane; the compiler still emits U+220E rather than a dedicated marker
because the pipeline builds against the frozen vendor/compiler mirror.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
…699)

What changed:
This PR (agent/daniel-parent/qed-glyph, #699) intentionally changes how a
proof's QED mark renders: amsthm's `\openbox` (four drawn rules) instead of
the glyph-less U+220E, which has no glyph in the shipped fonts. That is
exactly the rendering path `lecture-notes` exercises, so its 10 output
digests (cold.reply, export.pdf, and 8 warm-scenario reply hashes) change;
every other case's digests, and all `metrics`/`meta`, are untouched.

Re-recorded with the new digest-only merge tool from #770 (see that
PR for the full mechanism and rationale):

  cargo build --release --bin flashtex-perf-bench   # CARGO_TARGET_DIR=target-perfdigest, CARGO_BUILD_JOBS=4
  ./target/release/flashtex-perf-bench --json /tmp/report.json
  python3 crates/perf-bench/scripts/merge_digests.py \
      --baseline crates/perf-bench/baselines/linux-x86_64-ryzen7-7800x3d.json \
      --new-report /tmp/report.json --case lecture-notes \
      --out crates/perf-bench/baselines/linux-x86_64-ryzen7-7800x3d.json

Recorded on macOS/arm64 (not the pinned Ryzen/Linux reference host), which is
fine for digests specifically: they hash only rendered-output bytes, with no
timing/RSS/CPU input, and were independently confirmed portable (a full
26-case, 214-digest recording on this machine matched the committed Linux
baseline byte-for-byte except for these exact 10 entries). `metrics`/`meta`
(host_fingerprint, cpu, build_target, ...) are untouched — this machine's
numbers were never written anywhere near the committed file.

What was run:
- Full-corpus recording (26 cases, release build): 214 digest entries total,
  25 of 26 cases unchanged, only `lecture-notes` differs, in exactly the 10
  keys listed above (diffed independently with a separate script, not just
  the merge tool's own report).
- merge_digests.py's built-in self-check (schema_version/meta/targets/
  unmeasured/every other case/every other field of this case all
  byte-identical before it would write) passed.
- `--print <new report> --baseline <updated baseline>`: no digest mismatch
  reported for any case (the only FAIL shown is an unrelated font-path
  timing warning between two macOS runs' font_dirs, irrelevant to the
  digest gate and irrelevant on CI, where --require-same-host means the
  timing checks never fire on GitHub's runner pool anyway).

Next step:
CI's `engine performance` digest check should now pass on this PR. Timing
metrics/meta remain the original Ryzen/Linux baseline, so --require-same-host
continues to gate correctly wherever it can actually fire.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
@d-q222

d-q222 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

engine performance was failing here because this PR intentionally changes
rendered output, and CI's digest check correctly caught that. Pushed
b140dd7 to re-record the affected digests using the new digest-only tool
from #770 (that PR has the full mechanism/rationale).

Why the new output is correct: this PR changes a proof's QED mark from
the glyph-less U+220E to amsthm's \openbox (four drawn rules), because
U+220E has no glyph in the shipped fonts. lecture-notes is precisely the
document the perf-bench notes already flag as missing that glyph, so it's the
one case whose output should change here — and it's the only one that did.

What changed, exactly: lecture-notes's 10 digests (cold.reply,
export.pdf, and the 8 warm-scenario reply hashes) in
crates/perf-bench/baselines/linux-x86_64-ryzen7-7800x3d.json. Verified:

  • Recorded a full 26-case --release run of this branch's own code on
    macOS/arm64 (--bin flashtex-perf-bench, not memprofile — that bin has
    an unrelated, pre-existing macOS link failure, _malloc_trim is
    glibc-only; noted in perf-bench: digest-only baseline re-record tool (tooling, unbreaking) #770).
  • Diffed that recording against the committed baseline independently (a
    separate script, not the merge tool's own report): 214 total digest
    entries, only lecture-notes differs, in exactly these 10 keys.
  • merge_digests.py --case lecture-notes copied only that case's digests
    in; its own self-check plus an independent post-merge diff both confirm
    schema_version/meta/targets/unmeasured and every other case/field
    are byte-identical to before.
  • metrics/meta (host_fingerprint, cpu, build_target, ...) are untouched —
    they still reflect the pinned Ryzen/Linux reference host, since digests are
    portable but timing numbers are not.

CI should now pass the digest check. --require-same-host timing checks
still never fire on GitHub's runner pool, per the earlier established
findings, so nothing about the timing gate changed here.

@d-q222
d-q222 merged commit 12f2f0b into main Sep 16, 2026
21 of 22 checks passed
d-q222 added a commit that referenced this pull request Sep 16, 2026
… QED-glyph re-record

Merging main brought in #699's own digest re-record (lecture-notes, 10
keys, for the unrelated QED-glyph fix), which conflicted textually with
this branch's own lecture-notes change on the same single-line JSON file.
Re-recorded all 19 previously-changed cases on the fully-merged tree
(main's tip + this branch's fix) rather than hand-resolving the conflict,
so lecture-notes' digests now reflect both fixes composed together
correctly, not just one side. --check: OK, 549 metrics, no regression.
d-q222 added a commit that referenced this pull request Sep 16, 2026
…nd main's #699

Same conflict class as #754's own merge just now: re-recorded all 19
previously-changed cases on the fully-merged tree (main's tip + #754's fix
+ this branch's own text-run fix) rather than hand-resolving the
single-line JSON conflict, so every digest reflects all three changes
composed together. --check: OK, 549 metrics, no regression.
ItsAkilesh pushed a commit to ItsAkilesh/flashtex that referenced this pull request Sep 18, 2026
What changed:
`engine performance` was failing on ~10 open PRs. Two prior lanes established
the CI gate's TIMING checks never fire on GitHub runners (--require-same-host
never matches the pinned linux-x86_64-ryzen7-7800x3d host), so the ONLY thing
that can actually fail is a byte-identical output-digest mismatch against
crates/perf-bench/baselines/linux-x86_64-ryzen7-7800x3d.json. Several open PRs
legitimately change rendered output and trip that correctly - they need their
affected digests re-recorded, but perf-bench had no way to do that without
`--json`/`--update-baseline` overwriting the whole report, including the
Ryzen-only `metrics` and `meta.host_fingerprint`, which would silently destroy
the timing baseline and disable --require-same-host forever.

Adds crates/perf-bench/scripts/merge_digests.py: copies ONLY the named cases'
`digests` from a freshly recorded report into the committed baseline via a
text splice (not a re-serialize), leaving metrics/meta/schema_version/
targets/unmeasured and every non-named case byte-identical - verified both by
construction and by a self-check before it writes. No case list defaults to
"update everything"; every case must be named explicitly with --case, and
zero --case flags is a legitimate no-op, not a shortcut. Refuses to run if
the baseline/new-report case-id sets differ, if a named case is missing from
either, or if a case is repeated on the command line.

Documents the re-record process in crates/perf-bench/README.md: digests are
portable (proven separately: a full macOS/arm64 recording matched the
committed Linux baseline byte-for-byte across all 26 cases/214 digest
entries), metrics/meta are not and must never be regenerated off the pinned
reference host, and a PR author re-recording digests must justify in the PR
why the new rendered output is correct - a digest update is a claim of
intent, which is the entire reason the gate exists.

Applied as a worked example to flash-tex#699 (qed-glyph) in a separate commit/push to
that PR's own branch, not included here.

Known unrelated breakage, noted but not fixed here: perf-bench's separate
`memprofile` bin fails to link on macOS (`_malloc_trim` is glibc-only); the
main `flashtex-perf-bench` binary is unaffected. Worked around throughout by
building with `--bin flashtex-perf-bench`. Confirmed by reproduction:
`cargo build --release --bin memprofile` -> "Undefined symbols ... _malloc_trim
... ld: symbol(s) not found for architecture arm64". Probably worth its own
issue; not filed here to stay in scope.

What was run:
- python3 -m unittest discover -s crates/perf-bench/scripts -p 'test_*.py':
  Ran 6 tests in 0.005s, OK (round-trip identity, single-case merge leaves
  meta/other-case/other-fields untouched, and all three refusal paths:
  mismatched case-id sets, unknown --case, duplicate --case).
- Manual round-trip proof against the real 126 KB committed baseline (self
  vs self, 0 cases): `diff`/`cmp` both report byte-identical.
- Manual one-case proof against a real macOS --release recording of this
  repo's own corpus (case `lecture-notes`, the flash-tex#699 worked example): only
  that case's 10 digest keys changed; independently verified (separate
  script, not the tool's own report) that schema_version/meta/targets/
  unmeasured and every other case/field were untouched.

Next step:
Commander/reviewers hand out the remaining ~6 PRs with legitimate rendering
changes to their respective authors, each re-recording with this tool and
justifying their own case(s) in their own PR.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
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