Skip to content

render-pipeline: \colon keeps its punctuation class through the atom-class re-read - #181

Closed
GoKubar wants to merge 1 commit into
mainfrom
agent/kabir-claude/math-symbols-pipeline
Closed

GoKubar wants to merge 1 commit into
mainfrom
agent/kabir-claude/math-symbols-pipeline

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Pipeline half of the math-symbol lane. Compiler half is #180 (agent/kabir-claude/math-symbols-compiler). Both are based on main independently — no stacking; either can merge first, and neither changes the other's behaviour until vendor/compiler is re-pinned.

What changed

One arm, in typeset::class_override_of:

"colon" => ml::AtomClass::Punct,

The compiler carries \colon's \mathpunct class as the crate-private MathAtom::class_override, so the pipeline re-reads the control word at the atom's span (pin d416472a), exactly as it already does for \bot/\bigtriangleup/\mathpunct. Without an arm there the compiler's : atom falls back to math-layout's default_class, which classifies : as \mathrel — the class the character has (fontmath.ltx 385), not the one \colon declares (fontmath.ltx 400). f\colon A then gets the relation's 5mu on both sides instead of 3mu after the colon only.

Measured

TeX Live 2025 pdflatex against flashtex-render, on a 12pt fixture holding $f\colon A\to B$, $g\colon X\to Y$, $a:b$, $c:d$, the eight largesymbols operators and \neg/\lnot, with vendor/compiler locally swapped to #180's branch (uncommitted, as the vendoring rules require):

worst word displacement
with this arm 0.006 bp
without it 4.647 bp per \colon; 9.303 bp by the second formula on the line

4.647 bp is the 7mu the class decides (10mu relation − 3mu punctuation = 4.667pt at 12pt).

Tests

crates/render-pipeline/tests/math_symbols.rs gains:

  • colon_is_punctuation_where_a_bare_colon_is_a_relation — a unit test over class_override_of itself. No compiler dependency, runs now, passes.
  • colon_gets_thin_space_after_only_end_to_end — the spacing assertion, #[ignore]d with the exact reason: the pinned vendor/compiler has no \colon arm at all and still emits the literal text \colon, so there is no : atom for the class to land on. Verified that it passes with the vendor swapped to compiler: \colon as math punctuation, \mathbb as a real msbm alphabet, the largesymbols operators and \neg #180; un-ignoring it is the acceptance check for the re-pin.

Gates

Run with the pinned vendor, i.e. exactly what this branch commits. Fonts come from a symlink-free flat copy of the repo's own apps/mac/Fonts plus its bundled texmf TFMs, and every gate run was asserted to report zero font_unavailable / required_metrics_unavailable diagnostics before its numbers were used — on NixOS, symlinked texmf-dist path components make the rooted TFM reader fall back to OpenType MATH metrics silently, and two builds sharing that fallback agree perfectly on wrong geometry.

gate main this branch
crates/render-pipeline cargo test --release --no-fail-fast 170 passed, 0 failed, 1 ignored 171 passed, 0 failed, 2 ignored
amsmath corpus (amsmath_corpus/oracle.py check) 59/59 59/59, per-fixture identical
amssymb corpus (amssymb_corpus/oracle.py check) 38/39 38/39, per-fixture identical
real-world corpus (10 fixtures × 2 producers) — no behavioural change: status, pages, error/warning counts and exact diagnostic message sets identical
HW1 / HW2 (render) 3 / 3 pages 3 / 3 pages, 0 errors, 0 overfull
crates/paragraph-layout cargo test --test hyphenation_oracle 5 passed 5 passed, incl. thirty_paragraphs_break_like_pdflatex

Run crates/render-pipeline's cargo test with no FLASHTEX_* exports: several tests (mathbb_paints_from_new_computer_modern_when_bundled, mathcal_…, varnothing_…, cm_less_symbols_…) render a deliberate without-NewCM control and fail if an exported FLASHTEX_FONT_DIRS leaks a font directory into it. With FLASHTEX_FONT_DIRS+FLASHTEX_TFM_DIRS+FLASHTEX_LM_DIR exported, main itself reports 8 failures; with the CI triple, 17. The oracle harnesses set their own environment per subprocess and are unaffected.

Pre-existing and identical on both sides: 32-braces-narrow (amssymb, brace extents, worst 1.012 bp), and the real-world corpus's 3 ec_metrics_unavailable + 3 font_outline_substituted (the bundled Fonts dir ships no lmmono*.otf and no ectt* T1 typewriter metrics).

Correction to a measurement from the inline-math-expansion lane

crates/render-pipeline/tests/microtype_math.rs on agent/kabir-claude/math-inline-expansion @ df1bbae6 #[ignore]s operators_functions_and_spacing_commands with the reason "the compiler drops \mathbb{Z} and sets \colon as the literal characters". The \colon half is right and is what this PR + #180 fix. The \mathbb{Z} half is not: on current main with the pinned vendor, $\mathbb{Z} a$ … $\mathbb{W} f$ renders within 0.013 bp of pdflatex. That claim was most likely measured on the metrics fallback described above, where every face degrades at once.

Re-measuring that fixture with #180 + this PR: paragraph 2 — the one holding $h\colon A\to B$ and $A=B=\mathbb{Z}$ — now starts at pdflatex's own line origin (198.403 vs 198.404 bp) and ends within 0.003 bp, and every remaining outlier is in paragraph 1: \sin / \cos / \lim / \log, the operator-name spacing that lane already attributes to #177. Once both land, that #[ignore] reason should be narrowed to #177 alone. I have not touched that branch or its fixtures — inline-math microtype is a fenced lane.

Follow-up this PR does not take

\bigsqcup (cmex10 "46, U+2A06) and \biguplus ("55, U+2A04) are the only two largesymbols operators #180 leaves out, because each also needs a cm::symbol_slot + default_class row in crates/math-layout — which crates/render-pipeline vendors. Whoever takes them should land the math-layout rows, the compiler COMMAND_GLYPHS rows and the lm_math::ADVANCES entries (both 833 in the bundled latinmodern-math.otf) together. #180's description lists the other 105 unsupported kernel/plain math commands the sweep found, tiered by what each needs.

Resume notes

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

…class re-read

The compiler carries `\colon`'s `\mathpunct` class as the crate-private
`MathAtom::class_override`, so the pipeline re-reads the control word at the
atom's span (`typeset::class_override_of`, pin `d416472a`) exactly as it does
for `\bot`/`\bigtriangleup`. Without an arm there, the compiler's `:` atom
falls back to math-layout's `default_class`, which has `:` as `\mathrel`
(`fontmath.ltx` 385) — the class the *character* has, not the one `\colon`
declares (`fontmath.ltx` 400). `f\colon A` then got the relation's 5mu on
both sides instead of 3mu after the colon only.

Measured end to end against TeX Live 2025 pdflatex on a 12pt fixture holding
`$f\colon A\to B$`, `$g\colon X\to Y$`, `$a:b$`, `$c:d$`, the eight
`largesymbols` operators and `\neg`/`\lnot`, with `vendor/compiler` locally
swapped to agent/kabir-claude/math-symbols-compiler (uncommitted, as the
vendoring rules require):

* with this arm: every word within **0.006 bp** of pdflatex;
* without it: every word after each `\colon` is **4.647 bp** out, 9.303 bp by
  the second formula on the line — the 7mu (10mu relation − 3mu punctuation)
  the class decides, 4.667pt at 12pt.

`crates/render-pipeline/tests/math_symbols.rs` gains the unit test over
`class_override_of` itself (no compiler dependency, runs now) and the
end-to-end spacing assertion, `#[ignore]`d with the exact reason: the pinned
`vendor/compiler` has no `\colon` arm at all and still emits the literal text
`\colon`, so there is no `:` atom for the class to land on. Verified that the
ignored test passes with the vendor swapped in.

Gates (NixOS, TeX Live 2025, pinned vendor as committed; fonts from a
symlink-free flat copy of the repo's own `apps/mac/Fonts` + its bundled
`texmf` TFMs, after confirming every gate run reports **zero**
`font_unavailable` / `required_metrics_unavailable` diagnostics — an earlier
round of these numbers was measured on the OpenType-MATH fallback and is
superseded):

- `crates/render-pipeline` `cargo test --release --no-fail-fast` (no
  FLASHTEX_* exports; the tests do their own font discovery and several
  assert a no-NewCM control that an exported FLASHTEX_FONT_DIRS breaks):
  **171 passed, 0 failed, 2 ignored**, against 170/0/1 on main.
- amsmath corpus (`crates/compiler/tests/amsmath_corpus/oracle.py check`):
  **59/59** within 0.5 bp, per-fixture identical to main.
- amssymb corpus: **38/39**, per-fixture identical to main; `32-braces-narrow`
  (brace extents, worst 1.012 bp) fails on main too.
- real-world corpus (`tools/real-world-corpus/run.sh --no-oracle`, 10
  fixtures x 2 producers): no behavioural change — status, page counts,
  error/warning counts and the exact diagnostic message sets identical.
  hw1 3 pages, hw2 3 pages (render), 0 errors and 0 overfull. The 3
  `ec_metrics_unavailable` and 3 `font_outline_substituted` are pre-existing
  and identical on both sides: the bundled `Fonts` dir ships no `lmmono*.otf`
  and no `ectt*` T1 typewriter metrics.
- `crates/paragraph-layout` `cargo test --test hyphenation_oracle`: 5 passed,
  including `thirty_paragraphs_break_like_pdflatex` (the HW1/HW2 line-break
  oracle).

Implementation-Agent: kabir-claude (engine-engineer, linux-primary)
Commit-Executor: kabir-claude direct git (Cursor usage limit fallback)

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
Co-authored-by: GoKubar <[email protected]>
@GoKubar

GoKubar commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded — the work is already on main.

Replacement: \colon arms are on main in crates/compiler/src/math.rs and typeset.rs

Closed by the integration lane while clearing a 219-PR backlog (112 of them drafts). If this is wrong, reopen it and tell me — I would rather be corrected than leave stale work buried.

— orchestrator-astra (Commander)

@GoKubar GoKubar closed this Sep 15, 2026
@GoKubar
GoKubar deleted the agent/kabir-claude/math-symbols-pipeline branch September 16, 2026 04:18
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