Skip to content

render-pipeline: the kern reverse lookup accepts amsmath's thin space too - #231

Merged
GoKubar merged 2 commits into
mainfrom
agent/kabir-claude/math-package-gating-pipeline
Sep 14, 2026
Merged

GoKubar merged 2 commits into
mainfrom
agent/kabir-claude/math-package-gating-pipeline

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Pipeline half of the package-gating lane. Compiler half is #230 (based on main, no stacking between the two).

The problem

kern_command_text (adapter.rs) asks text_builtins::text_kern which spelling produced an Inline::Kern amount, so it can recover the control sequence from inside a user macro's replacement. That reverse lookup assumed one amount per spelling.

It is not one. amsmath renews \thinspace/\negthinspace to .1667em against the kernel's .16667em, and \tmspace scales the factor rather than rounding it, so the two really differ. Measured with TeX Live 2025 pdflatex:

box kernel amsmath delta
\hbox{a\,b} 12.22230pt 12.22261pt +20sp at 10pt
\hbox{a\!b} 8.88887pt 8.88857pt −20sp

24sp at 12pt. \:/\; and their negatives are byte-identical under both, and the math-mode \mskip forms do not move at all.

#230 makes the compiler pick one from the document's packages, and gives text_kern the flag as a required parameter — deliberately, because a defaulted one is exactly the silent-kernel-fallback bug that lane exists to close.

What changed

The reverse lookup accepts either definition. It is looking up a spelling for an amount that has already been chosen, and it has no document in scope; the two amounts are disjoint, so no spelling is claimed twice.

Behind the new compiler-package-gating feature, off by default, the same arrangement amsmath-inline, math-glyph-spans and math-class-override already use: the two-argument text_kern exists only in a compiler newer than the committed vendor/compiler pin, and without the feature this calls the one-argument form exactly as before. Turning it on after the re-pin is a one-line default-feature edit.

Gates

crates/render-pipeline cargo test --release, with FLASHTEX_FONT_DIRS/FLASHTEX_TFM_DIRS pointed at the bundled Latin Modern and its three rooted metric trees: 191 passed, 0 failed, identical to a control run of this branch's base in the same worktree — same suite counts, same (empty) failure set.

The feature path cannot be built against the committed vendor pin, so it was built and measured through an uncommitted full vendor swap of #230's crates/compiler/src over vendor/compiler/src, against a control that swaps in #230's base the same way:

gate control with the feature
amsmath corpus 59/59 59/59
amssymb corpus 38/39 (32-braces-narrow, 1.012 bp, fails at the base too) 38/39, same fixture
both corpus output files — byte-identical to the control
HW1 / HW2 3 / 3 pages, 0 errors, 0 overfull 3 / 3 pages, 0 errors, 0 overfull

Zero font diagnostics on every render gate, asserted per fixture. The swap is neutral on its own: the control's numbers are identical to the committed pin's.

Merge order

Safe on its own — the feature is off, so there is no behaviour change. It becomes usable after #230 lands and vendor/compiler is re-pinned past it.

Known gap this does not close

#230 forces the LaTeX kernel's \angle (6.37344pt) and \hbar (5.76172pt) advances for documents that load no amsfonts, but it can only do so through MathAtom::width_em, which this crate reads only as the \varnothing sentinel flag (symbol_atoms). Forcing them in the display list needs two more sentinels on the VARNOTHING_SENTINEL pattern across mathfont.rs, mathtex.rs and typeset.rs. Left out of this PR deliberately: it is a self-contained piece of work and does not belong in a one-function reverse-lookup fix.

Draft; not for merge.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

GoKubar and others added 2 commits September 13, 2026 20:04
… too

Pipeline half of the package-gating lane. Compiler half is a separate PR, also
based on `main`.

`kern_command_text` asks `text_builtins::text_kern` which spelling produced an
`Inline::Kern` amount, to recover the control sequence inside a user macro's
replacement. That lookup assumed one amount per spelling. It is not: amsmath
renews `\thinspace`/`\negthinspace` to `.1667em` against the kernel's
`.16667em` — 20sp apart at 10pt and 24sp at 12pt, measured with TeX Live 2025
pdflatex (`\hbox{a\,b}` 12.22230pt against 12.22261pt, `\hbox{a\!b}` 8.88887
against 8.88857). The compiler now picks one from the document's packages, and
`text_kern` takes the flag as a required parameter so no caller can silently
fall back to the kernel.

This is a reverse lookup of a spelling for an amount already chosen, with no
document in scope, so it accepts either definition; the two amounts are
disjoint, so no spelling is claimed twice.

Behind the new `compiler-package-gating` feature, **off by default**, exactly
like `amsmath-inline` and `math-glyph-spans`: the two-argument `text_kern`
exists only in a compiler newer than the committed `vendor/compiler` pin, and
without the feature this calls the one-argument form as before. Turning it on
after the re-pin is a one-line default-feature edit.

Gates: `crates/render-pipeline` `cargo test --release` with
`FLASHTEX_FONT_DIRS`/`FLASHTEX_TFM_DIRS` pointed at the bundled Latin Modern
and its three rooted metric trees — **191 passed, 0 failed**, identical to a
control run of this branch's base in the same worktree. The feature path was
built and measured through an uncommitted full vendor swap of the compiler
branch: amsmath corpus 59/59, amssymb corpus 38/39 (`32-braces-narrow`, 1.012
bp, fails at the base too), with output files byte-identical to the same swap
of the base and zero font diagnostics.

Implementation-Agent: engine-engineer (Claude Opus 5), linux-primary worktree
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
@GoKubar
GoKubar marked this pull request as ready for review September 14, 2026 01:18
@GoKubar
GoKubar merged commit 0bd9b0c into main Sep 14, 2026
20 checks passed
GoKubar pushed a commit that referenced this pull request Sep 15, 2026
…ositions, new compiler lanes (#246)

The board still said "main ad71b64" with FT-050..055 as the queue. It now
carries the FT-060..067 outcomes, the two standing performance programs
(FT-070 Kabir, FT-071 Mac), the dispositions agreed on issue #2 for the
53 open PRs (Kabir's 2026-09-14T00:10Z triage), the merge order #233 ->
#241 -> #230 -> #231 -> #232, and the three unclaimed compiler lanes
#242/#243/#244 that close the last real-world corpus errors. Historical
rows are kept below.

Implementation-Agent: Claude Code (mac-claude-a)
Commit-Executor: git via Claude Code

Claude-Session: https://claude.ai/code/session_01Y1nAv4pEnmMYXgteBoadHn

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
@GoKubar
GoKubar deleted the agent/kabir-claude/math-package-gating-pipeline 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.

1 participant