Skip to content

render-pipeline: a rich \tag is never silently replaced by the automatic equation number (#441; stacked on #711) - #736

Merged
d-q222 merged 2 commits into
mainfrom
agent/daniel-parent/tag-silent-drop
Sep 17, 2026
Merged

d-q222 merged 2 commits into
mainfrom
agent/daniel-parent/tag-silent-drop

Conversation

@d-q222

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

Copy link
Copy Markdown
Contributor

Stacked on #711 (agent/daniel-parent/repin-evidence), whose compiler-node-surface
feature this needs, so the diff carries #711's commit until it lands. One commit is mine:
f72fc306, crates/render-pipeline/src/adapter.rs (+52/-5) and a new
crates/render-pipeline/tests/tag_rich_label.rs.

What

adapter::strip_tag read only a flat Nucleus::Text/Symbol label:

if let Nucleus::Text(s) | Nucleus::Symbol(s) = &a.nucleus { *tag = Some(s.clone()); }
continue;                       // <- the atom is dropped either way

Once vendor/compiler is re-pinned past #470, \tag{hi $x^2$} arrives as
Nucleus::TextRun instead of a flat string. The if let did not match, the atom was
dropped anyway, tag stayed None — and the caller's None arm is the automatic
equation number
. So the tag vanished and a plausible (2)/(3) took its place, with
no diagnostic of any kind.

That is worse than the diagnostic #441 was filed for. The old failure was noisy and the
user knew; this one makes the document wrong in a way that looks right — a reader
cross-referencing "equation (3)" against a source that says \tag{hi $x^2$} has nothing
to notice.

strip_tag now matches the nucleus exhaustively:

nucleus under a \tag before now
Text/Symbol (\tag{hi}) the label unchanged
Space (the compiler's interim 2\quad gap, which spans the command too) dropped dropped, explicitly
TextRun (\tag{hi $x^2$}, \tag{\textbf{A}}) dropped -> automatic number, silently set as the run's text, with a math_limitation at the \tag
anything else dropped -> automatic number, silently no label, display left unnumbered, reason reported

The TextRun arm is behind compiler-node-surface (the feature that presumes the newer
compiler surface — the old pin cannot produce the variant). The text it sets is
math::text_run_reference_text, the same flattening the compiler uses for \eqref to
this tag, so the set label and a reference to it read alike.

This diagnoses and approximates; it does not set the tag as amsmath does. The label
is upright text with a Unicode superscript, not \maketag@@@'s hbox, so it lands
~1.31 bp from pdflatex where a plain tag lands 0.005 bp away. That is exactly what the
math_limitation says.

Why this is a new PR and not part of #585

#585 is the real fix and I did not touch it. But #585 does not close this hole: its
rich-label arm is #[cfg(feature = "compiler-text-run")], and its fallback is still
_ => {} — the same silent drop — whenever that feature is off, which is how #585 lands
and how it stays until vendor/compiler and vendor/math-layout are both re-pinned.
The compiler half (#470) is already on main, so the window between the compiler re-pin
and #585's feature going default is precisely when a \tag{hi $x^2$} silently becomes a
number. This commit closes that window and nothing more.

The two touch the same function, so #585 will conflict here textually. The resolution is
one-directional and small: #585's compiler-text-run arm replaces this one's
compiler-node-surface arm, the Space and _ arms stay, and the notes parameter
stays so the _ arm can still report. I have not pre-empted any of #585's placement,
leqno, own-line, align/gather/multline or \tag* work.

Before / after, all three tag shapes

10 pt article + lmodern + amsmath, one equation each, re-pinned vendor,
compiler-node-surface. x0 in bp; pdflatex is TeX Live 2026 via PyMuPDF.

source pdflatex FlashTeX before FlashTeX after
\tag{hi} (hi) @ 461.433 (hi) @ 461.428 (hi) @ 461.428 (dx 0.005)
\tag{$x^2$} (x2) @ 459.573 (2) @ 464.749, no diagnostic (x²) @ 460.892 (dx 1.319) + math_limitation
\tag{hi $x^2$} (hi @ 447.959, x2) @ 463.461 (3) @ 464.749, no diagnostic (hi @ 449.270, x²) @ 464.767 (dx 1.311 / 1.306) + math_limitation

The diagnostic, at the \tag's own span:

math_limitation: \tag label set as the upright text "(hi x²)": math and font switches
inside a tag are not set as math yet (#441). The automatic equation number does not
replace it.

The existing oracle fixture 15-align-tag-notag-eqref shows the same thing in a real
corpus document — its third align row is \tag{$*$}:

pdflatex   ... 'e' '=' 'f' '(∗)' 'g' '=' 'h' 'B' 'See' '(1)' 'and' '(∗)' ...
before     ... 'e' '=' 'f' '(2)' 'g' '=' 'h' 'B' 'See' '(1)' 'and' '(2)' ...
after      ... 'e' '=' 'f' '(*)' 'g' '=' 'h' 'B' 'See' '(1)' 'and' '(2)' ...

Regression test

crates/render-pipeline/tests/tag_rich_label.rs, four tests. Two of them fail on this
branch with only adapter.rs reverted:

test a_rich_tag_is_never_silently_replaced_by_the_automatic_number ... FAILED
test a_rich_tag_reports_that_its_math_is_set_as_text ... FAILED
test result: FAILED. 2 passed; 2 failed

The first asserts no (<digits>) word survives on a page whose every display is
\tagged — not just (1), because the counter keeps stepping and the substituted
numbers were (2) and (3). The controls pin that a plain \tag{hi} still matches
pdflatex within 0.5 bp and reports nothing, and that an untagged equation still
gets its number.

Overlap check

Vendor gate

git diff --stat origin/main...HEAD | grep -c vendor is 0. The scratch swap used for
every measurement below (runbook §3: compiler, tex-expansion, new bibliography) was
reverted with git checkout -- crates/render-pipeline/vendor && git clean -fd crates/render-pipeline/vendor, and crates/render-pipeline/Cargo.lock was restored too —
the lockfile stanza belongs to the re-pin, not here.

Test results

# crates/render-pipeline, scratch re-pinned vendor, --features compiler-node-surface,linebreak-skip
binaries=106 passed=489 failed=0 ignored=4        (#711 alone: 485/0; +4 is this PR's new file)

# crates/render-pipeline, pinned vendor, default features
binaries=106 passed=469 failed=13 ignored=4       (the same 13 red on main today)

# tests/tag_rich_label.rs, re-pinned vendor
test a_rich_tag_is_never_silently_replaced_by_the_automatic_number ... ok
test a_rich_tag_reports_that_its_math_is_set_as_text ... ok
test a_plain_tag_is_unchanged_and_matches_pdflatex ... ok
test an_untagged_equation_still_gets_its_number ... ok
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

# crates/render-pipeline/fixtures/display-placement/oracle.py check
TOTAL 35/36 within 0.5 bp
  baseline, this branch without the adapter.rs change: TOTAL 35/36 within 0.5 bp
  the one FAIL is 15-align-tag-notag-eqref, unchanged either way: its 4 unaligned
  words are math `*` extracting as `*` where cmsy gives `∗`, and `\eqref` to a
  rich tag (both pre-existing, both #585's)

# crates/compiler/tests/amsmath_corpus/oracle.py check
PASS 22-tag                     words  13 ok  13 unaligned   0 ext cols  0/ 0 worst    0.006
TOTAL 59/59 within 0.5 bp

Not done

🤖 Generated with Claude Code

https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

What changed:
- `crates/render-pipeline/Cargo.toml` declares a new off-by-default feature
  `compiler-node-surface`. It carries no behaviour of its own: every arm it
  adds is the inert answer the pipeline already gave for a compiler node the
  current pin (`c95977d6`) cannot produce.
- The pipeline's exhaustive matches and node constructors now cover main's
  compiler surface behind that feature: `parser::Block::Penalty`/`Tabbing`,
  `parser::Inline::ThePage`/`PageNumbering`/`TabStop`/`TabJump`/`Marginpar`/
  `Penalty`/`PagePenalty`/`Discretionary`, `VSpace`/`HSpace` glue components,
  `math::Nucleus::TextRun`/`SideSet`/`Lap` and `math::Accent::Mathring`
  (compiler #549, #551, #555, #568, #581, #583, #587, #606, #616).
  `adapter::vspace_block` is a new cfg'd constructor beside the existing
  `line_break_inline`; the one open-coded `Inline::LineBreak { .. }` left in
  the `\opening` lowering now goes through `line_break_inline` too.
- `tabbing` is lowered to flush-left paragraphs with one `unsupported_block`
  limitation, the way `LetterBlock` is, so no row is dropped by the re-pin.
- `docs/integration/repin-runbook.md`: the exact re-pin commands, the three
  vendor directories that must move (`compiler`, `tex-expansion`, and a new
  `bibliography`), the lockfile and `#[ignore]` edits `--locked` CI needs, the
  measured test deltas and the PRs the pin unblocks.

No file under `vendor/` is touched: the vendor swap used to measure all of
this was scratch-only and reverted. `git diff --stat origin/main...HEAD`
contains zero `vendor/` paths.

What was run:
Whole `crates/render-pipeline` suite, CARGO_BUILD_JOBS=4, --no-fail-fast:
  origin/main, pinned vendor, feature off:   469 passed, 13 failed
  this branch, pinned vendor, feature off:   469 passed, 13 failed (same 13)
  this branch, vendor re-pinned, feature on: 485 passed, 0 failed
The 13 red-on-main tests (letter_class_geometry x5, frame_env, underline_sout
x4, uline x2, xcolor_oracle) all pass after the re-pin.
Two re-pin-gated #[ignore]s also pass against the re-pinned vendor:
  test frame_draws_a_rule_border_around_its_content ... ok
  test coloneqq_decomposes_like_mathtools ... ok
crates/flashtex-cli against the same re-pinned vendor:
  test result: ok. 58 passed; 0 failed
cargo check --all-targets on this branch at the current pin: 0 errors.

Next step:
The integration lane applies docs/integration/repin-runbook.md section 3 --
swap the three vendor trees, move `compiler-node-surface` (and
`linebreak-skip`) into `default`, refresh both Cargo.locks, drop the two
`#[ignore]`s, update vendor/VENDORING.md.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
…tic equation number (#441)

What changed:
`adapter::strip_tag` read only a flat `Nucleus::Text`/`Symbol` label. Once
`vendor/compiler` is re-pinned past #470, `\tag{hi $x^2$}` arrives as
`Nucleus::TextRun` instead, so the label was dropped and the caller's
`None` arm — the *automatic* equation number — stood in for it. The
document then said `(2)`/`(3)` where the source says `\tag{hi $x^2$}`,
with no diagnostic: wrong in a way that looks right.

`strip_tag` now matches the nucleus exhaustively:
- `Text`/`Symbol`: unchanged.
- `Space`: the compiler's interim 2-quad gap, dropped as before (it spans
  the command too, and is not a label).
- `TextRun` (behind `compiler-node-surface`, the feature that presumes the
  newer compiler): set as the run's text — the same flattening the compiler
  uses for `\eqref` to this tag — with a `math_limitation` at the `\tag`
  saying the nested math is not yet set as math.
- anything else: no label set, the display left unnumbered, and the reason
  reported.

The rich label is an approximation, not the box amsmath builds: it is
~1.31 bp from pdflatex, against 0.005 bp for a plain `\tag{hi}`. PR #585
sets it exactly (0.004 bp measured there); this commit only removes the
silence, and is inert on the default pinned-vendor path.

What was run:
Scratch vendor swap per docs/integration/repin-runbook.md §3 (nothing under
vendor/ is committed; `git diff --stat | grep -c vendor` is 0).

  # crates/render-pipeline, re-pinned vendor, compiler-node-surface+linebreak-skip
  binaries=106 passed=489 failed=0 ignored=4
  # crates/render-pipeline, pinned vendor, default features (main's 13 reds)
  binaries=106 passed=469 failed=13 ignored=4
  # tests/tag_rich_label.rs, re-pinned vendor
  test a_rich_tag_is_never_silently_replaced_by_the_automatic_number ... ok
  test a_rich_tag_reports_that_its_math_is_set_as_text ... ok
  test a_plain_tag_is_unchanged_and_matches_pdflatex ... ok
  test an_untagged_equation_still_gets_its_number ... ok
  test result: ok. 4 passed; 0 failed
  # the same file with this commit's adapter.rs reverted
  test result: FAILED. 2 passed; 2 failed
  # fixtures/display-placement/oracle.py check
  TOTAL 35/36 within 0.5 bp     (baseline without this change: 35/36)
  # crates/compiler/tests/amsmath_corpus/oracle.py check
  PASS 22-tag                     words  13 ok  13 unaligned   0 worst    0.006
  TOTAL 59/59 within 0.5 bp

pdflatex (TeX Live 2026, PyMuPDF), 10pt article + lmodern + amsmath:

  '(hi)'  x0 461.433     FlashTeX 461.428   dx 0.005
  '(x2)'  x0 459.573     FlashTeX 460.892   dx 1.319   (was: "(2)")
  '(hi'   x0 447.959     FlashTeX 449.270   dx 1.311   (was: "(3)")
  'x2)'   x0 463.461     FlashTeX 464.767   dx 1.306

Next step:
#585 replaces the text approximation with `\maketag@@@`'s hbox and adds the
compiler half that makes `\eqref` to a rich tag resolve to the tag rather
than to a stale number; this commit does not touch either.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
d-q222 added a commit that referenced this pull request Sep 16, 2026
…ag-placement-pipeline

What changed:
- #470's compiler `Nucleus::TextRun`/`TextPiece` and math-layout `TextRun`
  have landed on main, so most conflicted hunks were this branch's copy of
  main's material and took main's side:
  - crates/compiler/src/math.rs: 2 of 3 (the `\mathbf` `split_hyphen_runs`
    rewrite and its `-` mathcode comment). The third, `INTERIM_TAG_GAP_EM`'s
    doc comment, is this PR's own commit 1b6f03f and was kept.
  - crates/compiler/src/parser.rs: the `comment_environment` hunk took main.
  - crates/math-layout/src/lib.rs and src/layout.rs: main (`LeftScripts` in
    the import lists; main's removal of `make_text_styled`).
  - crates/compiler/tests/text_runs.rs (add/add): kept this PR's two tag
    tests, which main's side does not have.
- Two hunks needed a real merge rather than a side:
  - crates/compiler/src/parser.rs `multirow_environment`. Main gained #552's
    `\shoveleft`/`\shoveright`, which lifts shove tokens out of each row's
    cells before they are parsed, inside the row loop; this PR pre-parses
    every row up front so it can find each row's `\tag` before numbering.
    The shove lifting now runs as its own `rows.iter_mut()` pass ahead of the
    pre-parse and is zipped into the row loop, so both behaviours survive.
  - crates/render-pipeline/Cargo.toml: union of the feature blocks —
    `compiler-text-run` (this PR) alongside main's `math-font-kerns` and
    `tikz-patterns`.
  - crates/render-pipeline/tests/display_placement.rs module comment: main's
    current statement of what passes (17, 18, nested list 20) plus this PR's
    `compiler-text-run` paragraph; only 15 is still listed as not passing.
- Two silent auto-merge duplications had to be removed by hand; both made the
  tree fail to compile and neither is a behaviour change:
  - crates/math-layout/src/cm.rs: a second copy of
    `fn text_space(&self, size: SizeClass)` (E0201).
  - crates/compiler/src/math.rs: a second copy of the whole 376-line text-run
    reference-text block (16 items, E0428). main's copy is a strict superset
    (it carries the `Nucleus::Lap` and `Nucleus::SideSet` arms), so the
    branch's copy was deleted.
- #736 (`adapter::strip_tag`'s silent-drop fix) is NOT on origin/main yet, so
  this merge did not touch it and nothing of it was undone. This branch's
  `strip_tag` is unchanged: the `Text`/`Symbol` arm, the
  `#[cfg(feature = "compiler-text-run")]` `TextRun` arm and the `_ => {}`
  fallback. The one-directional resolution #736 describes is still owed
  whichever of the two lands second.
- `sh crates/compiler/scripts/render_supported_latex.sh` was re-run; the
  generated artefacts come back identical to main.
- `git diff origin/main` is now exactly this PR's own payload: the compiler
  tag-numbering commit (math.rs, parser.rs, tests/text_runs.rs) and the
  render-pipeline half (Cargo.toml, adapter.rs, incremental.rs, mathtext.rs,
  typeset.rs, tests/display_placement.rs, fixtures 37-48 and their refs).

What was run:
  crates/compiler:
    cargo test --lib
      test result: ok. 412 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
    cargo test --test text_runs
      test result: ok. 16 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
    cargo test            77 "test result: ok." lines, 0 failed
  crates/render-pipeline (pinned vendor, default features):
    cargo build --lib --tests -> Finished
    cargo test --lib
      test result: ok. 164 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out
    cargo test --test display_placement
      test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
    cargo test --no-fail-fast
      binaries=105 passed=469 failed=13 ignored=4
      All 13 failures panic at crates/render-pipeline/src/adapter.rs:1311
      (main's 1308, shifted by this branch), the known stale vendor/compiler
      pin. Same 13 as on main today.

Next step:
- Still blocked on the vendor/compiler + vendor/math-layout re-pin (#711);
  until it moves, `compiler-text-run` cannot go default and fixtures 37-48
  cannot show their end-to-end behaviour.
- Whichever of #585 and #736 lands second still owes the one-directional
  strip_tag resolution #736's body sets out.

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 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent verification — VERIFIED

Reviewed at f72fc306, parent 36dff72e (#711). Worktree ~/flashtex-wt/vrfy-736,
CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-vrfy-736, CARGO_BUILD_JOBS=4,
fetched as git fetch origin pull/736/head:refs/review/pr-736.

The claim I was asked to test hardest is the regression test's strength — that it
really asserts no (<digits>) word survives, and that it really fails on the parent.
Both hold, and the parent's failure output is the exact (2)/(3) the PR describes.


Scratch re-pin (runbook §3, from #711's branch)

$ cd ~/flashtex-wt/vrfy-736
$ NEW=$(git rev-parse origin/main)          # 9c5b028dab1a2a74efb755b2220b35a027ef3364
$ for c in compiler tex-expansion; do
    rm -rf crates/render-pipeline/vendor/$c; mkdir -p crates/render-pipeline/vendor/$c
    git archive "${NEW}:crates/${c}" | tar -x -C crates/render-pipeline/vendor/$c
    echo "$NEW" > crates/render-pipeline/vendor/$c/PIN
  done
$ mkdir -p crates/render-pipeline/vendor/bibliography
$ git archive "${NEW}:crates/bibliography" | tar -x -C crates/render-pipeline/vendor/bibliography
$ echo "$NEW" > crates/render-pipeline/vendor/bibliography/PIN

(Note for anyone repeating this in zsh: "$NEW:crates/$c" is eaten by the :c
history modifier and git archive fails with not a valid object name. Brace it —
"${NEW}:crates/${c}". Worth a line in the runbook.)

1. The four tests pass on the branch

$ cargo test --features compiler-node-surface,linebreak-skip --test tag_rich_label
running 4 tests
test an_untagged_equation_still_gets_its_number ... ok
test a_plain_tag_is_unchanged_and_matches_pdflatex ... ok
test a_rich_tag_is_never_silently_replaced_by_the_automatic_number ... ok
test a_rich_tag_reports_that_its_math_is_set_as_text ... ok

test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.11s

2. They fail on the parent — with the silent (2)/(3)

$ git checkout HEAD~1 -- crates/render-pipeline/src/adapter.rs      # 36dff72e, #711 alone
$ cargo test --features compiler-node-surface,linebreak-skip --test tag_rich_label
running 4 tests
test an_untagged_equation_still_gets_its_number ... ok
test a_plain_tag_is_unchanged_and_matches_pdflatex ... ok
test a_rich_tag_is_never_silently_replaced_by_the_automatic_number ... FAILED
test a_rich_tag_reports_that_its_math_is_set_as_text ... FAILED

---- a_rich_tag_is_never_silently_replaced_by_the_automatic_number stdout ----
panicked at tests/tag_rich_label.rs:83:5:
automatic equation numbers ["(2)", "(3)"] were set for \tag'ged displays:
["Text.", "a", "=", "b", "(hi)", "Text.", "c", "=", "d", "(2)", "Text.", "e", "=", "f", "(3)"]

---- a_rich_tag_reports_that_its_math_is_set_as_text stdout ----
panicked at tests/tag_rich_label.rs:103:5:
assertion `left == right` failed: one note per rich tag, none for the plain one: []
  left: 0
 right: 2

test result: FAILED. 2 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out

Exactly the 2 passed; 2 failed the PR body reports, and the failure message is the
bug: (2) and (3) on the page and an empty diagnostic list. The silence is what
makes this worse than #441's original noisy failure, and the parent run proves it
rather than asserting it.

3. The assertion is as strong as claimed

crates/render-pipeline/tests/tag_rich_label.rs:76-86:

let numbers: Vec<&String> = words.iter()
    .filter(|w| w.starts_with('(') && w.ends_with(')')
             && w[1..w.len() - 1].chars().all(|c| c.is_ascii_digit()) && w.len() > 2)
    .collect();
assert!(numbers.is_empty(), ...);

Any (<digits>) word, not just (1) — which matters, because the counter keeps
stepping and the substituted numbers here are (2) and (3); an == "(1)" test would
have passed on the broken parent. The w.len() > 2 guard is last, so "()" is excluded
without an empty-slice panic, and the byte slice [1..len-1] is always on a char
boundary (( and ) are one byte each), so a label like (x²) cannot panic it. It is
backed by the positive assertions on :88-90 that the label's own text actually reaches
the page, so it cannot be satisfied by numbering breaking — and
an_untagged_equation_still_gets_its_number pins that independently.

The diagnostic test is anchored at the \tag's own span (:110-117), which is the part
that would silently rot if the note were ever moved to the display.

4. "Inert on the default pinned-vendor path" — checked, and true

The _ => arm at adapter.rs:3271 is not feature-gated and changes a previously
silent fall-through into Some(String::new()) + a math_limitation, so I checked that
no default-path input reaches it. With the vendor tree restored to the pinned
c95977d6, default features, rendering \tag{hi} / \tag{$x^2$} / \tag{\textbf{A}}
/ an untagged equation, branch and parent print byte-identical pages:

branch f72fc306: WORDS = ["Text.","a","=","b","(hi)","Text.","c","=","d","($x^2$)","Text.","e","=","f","(\\textbfA)","Text.","g","=","h","(4)"]
parent 36dff72e: WORDS = ["Text.","a","=","b","(hi)","Text.","c","=","d","($x^2$)","Text.","e","=","f","(\\textbfA)","Text.","g","=","h","(4)"]
DIAGS = []   on both

The old pin flattens even a rich label to one Nucleus::Text, so the Text arm still
takes it and the new arms never fire. The claim holds. (Probe file deleted; nothing
committed.)


Notes, not blockers

  • strip_tag's _ arm sets *tag = Some(String::new()), so the caller's Some(t)
    path formats an empty tag. It is deliberate and documented ("left unnumbered"), and
    unreachable today, but it is the one arm no test covers — after the re-pin makes it
    reachable it would be worth a case.
  • The re-pin is #711's, and everything above is scratch. git status clean afterwards:
    crates/render-pipeline/vendor restored, PIN back to c95977d6, no commit, no push.

Verdict

VERIFIED — the regression test asserts what the PR says it asserts, fails on the
parent for the stated reason with the stated output, and the change is genuinely inert
on the default path.

— independently verified by daniel-parent's review lane

@d-q222 d-q222 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent verification round 4 (re-check after #745/#746 churn) — VERIFIED

Head f72fc306, parent 36dff72e (#711's head). Own worktrees, own
CARGO_TARGET_DIRs (target-vr4-736, target-vr4-736base, target-vr4-736repin),
CARGO_BUILD_JOBS=4.

The re-pinned evidence is the whole point of this PR and cannot be produced against the
pinned vendor, so rather than take it on trust I reproduced the re-pin — in a scratch
export outside the repository
, never in a worktree:

$ git archive refs/review/pr-736 | tar -x -C <scratch>
$ git archive origin/main:crates/compiler       | tar -x -C <scratch>/…/vendor/compiler
$ git archive origin/main:crates/tex-expansion  | tar -x -C <scratch>/…/vendor/tex-expansion
$ git archive origin/main:crates/bibliography   | tar -x -C <scratch>/…/vendor/bibliography   # new

exactly the three moves docs/integration/repin-runbook.md §1 prescribes. No
vendor/ directory in the repository or in any worktree was touched
, and the scratch
tree is discarded.


1. Four tests pass on the re-pinned surface

$ cargo test --release --features compiler-node-surface,linebreak-skip --test tag_rich_label
test an_untagged_equation_still_gets_its_number ... ok
test a_rich_tag_reports_that_its_math_is_set_as_text ... ok
test a_rich_tag_is_never_silently_replaced_by_the_automatic_number ... ok
test a_plain_tag_is_unchanged_and_matches_pdflatex ... ok
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s

Matches the PR's claimed 4 passed; 0 failed. (--features compiler-node-surface
alone does not build — one E0063: missing field skip_pt in
parser::Inline — linebreak-skip is required too, which the PR's own command line
already says.)

2. The regression test still fails on the parent, with the literal (2)/(3)

I restored the parent's (36dff72e) two-arm body verbatim into strip_tag
(crates/render-pipeline/src/adapter.rs:3252), changing nothing else:

            if let Nucleus::Text(s) | Nucleus::Symbol(s) = &a.nucleus {
                *tag = Some(s.clone());
            }
$ cargo test --release --features compiler-node-surface,linebreak-skip --test tag_rich_label
test an_untagged_equation_still_gets_its_number ... ok
test a_plain_tag_is_unchanged_and_matches_pdflatex ... ok
test a_rich_tag_reports_that_its_math_is_set_as_text ... FAILED
test a_rich_tag_is_never_silently_replaced_by_the_automatic_number ... FAILED

panicked at tests/tag_rich_label.rs:83:5:
automatic equation numbers ["(2)", "(3)"] were set for \tag'ged displays:
["Text.", "a", "=", "b", "(hi)", "Text.", "c", "=", "d", "(2)", "Text.", "e", "=", "f", "(3)"]

panicked at tests/tag_rich_label.rs:103:5:
assertion `left == right` failed: one note per rich tag, none for the plain one: []

test result: FAILED. 2 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out

["(2)", "(3)"] — the literal numbers the PR says the silent substitution produced,
in the exact positions it describes
: (hi) survives (flat Nucleus::Text), and the
two rich tags become the stepping automatic counter with no diagnostic at all ([]).
2 passed; 2 failed matches the PR's own reverted-adapter.rs run exactly. The
regression test is real and still discriminates after the #745/#746 churn.

3. Inert on the default pinned-vendor path

The whole test file is #![cfg(feature = "compiler-node-surface")]
(tests/tag_rich_label.rs:32), so on the shipped configuration it is not merely
skipped, it does not exist:

$ cargo test --release --test tag_rich_label     # default features, pinned vendor
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

Behaviour, not just tests. strip_tag's new _ => arm is not feature-gated, so it
is live on the default path — it is inert only if the old pin can never hand a
\tag a nucleus that is not Text/Symbol/Space. I tested that rather than assumed
it. Built flashtex-render on the branch and on the parent with default features and
the pinned vendor, and compared full v2 display lists:

% \tag{$x^2$}, \tag{hi $x^2$}, \tag{hi}, plus an untagged control
DEFAULT-VENDOR OUTPUT: IDENTICAL
base   ['a','=','b','(1)','c','=','d','($x^2$)','e','=','f','(hi','$x^2$)','g','=','h','(hi)']
branch ['a','=','b','(1)','c','=','d','($x^2$)','e','=','f','(hi','$x^2$)','g','=','h','(hi)']

% harder shapes: \tag{\textbf{A}}, \tag*{hi}, \tag{\ensuremath{\alpha}},
% \tag{$\frac{1}{2}$}, an align row \tag{$*$}, \tag{\textit{x} $y$}, untagged
t2 IDENTICAL
base   ['a','=','b','(\textbfA)','c','=','d','hi','e','=','f','(\ensuremath\alpha)','i','=','j',
        '($\frac12$)','k','=','l','($*$)','m','=','n','(6)','o','=','p','(\textitx','$y$)','q','=','r','(8)']
branch  … identical …

and the whole corpus:

=== 736 corpus (pinned vendor): identical=21 differs=0 ===

The old compiler flattens every one of these to a single Nucleus::Text (note
($x^2$) — the $…$ survives as literal text), so the Text|Symbol arm always fires
and neither the TextRun nor the _ arm is ever reached. Inert on the default
pinned-vendor path: confirmed empirically, on 7 tag shapes and 21 fixtures.


Findings

  1. crates/render-pipeline/src/adapter.rs:3278 — the _ => arm is live on the
    default path, and the PR body does not say so.
    The body frames the change as
    "behind compiler-node-surface"; only the TextRun arm is. The catch-all arm
    (notes.push(…), *tag = Some(String::new())) compiles unconditionally, so if any
    future compiler surface — not just the re-pin — starts handing \tag a nucleus
    other than Text/Symbol/Space, that arm changes shipped behaviour with no
    feature flag in the way. §3 shows it is unreachable today, which is why this is a
    note rather than a blocker, and the arm is the right safety net to have. But
    "inert" here is an empirical property of the current pin, not a structural
    guarantee, and the body should say which of the two it is claiming.

  2. crates/render-pipeline/tests/tag_rich_label.rs has no default-features
    counterpart.
    Because the file is entirely cfg-gated, the _ => arm from
    finding 1 is covered by nothing on the shipped configuration — the 21-fixture
    comparison in §3 is mine, not a test in the tree. A one-line default-features test
    that a plain \tag{hi} still sets (hi) would pin the inertness the PR relies on.
    Not blocking.

Everything the PR claims reproduced: 4 passed on the re-pin, 2 passed; 2 failed
with adapter.rs reverted, the literal (2)/(3), and inertness on the pinned
vendor. VERIFIED.

— independently verified by daniel-parent's review lane

@d-q222

d-q222 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Commander (daniel-parent), independent Opus review of f72fc306: APPROVE. The PR is behind main, so its CI compiled the new tests out; my merge batch runs them on the merged tree. The \eqref versus label flattening mismatch goes to a follow-up issue. Queued for the next merge batch.

PR #736 review: render-pipeline: a rich \tag is never silently replaced by the automatic number

Reviewer: opus (independent, read-only). Head f72fc306 (verified). Merge base with origin/main 36dff72e; main is 190 commits ahead. Linked issue: #441. Diff: one commit, adapter.rs (+52/-5) and the new tests/tag_rich_label.rs.

Context checked against source

  • On current main, compiler-node-surface is a default feature, and main's re-pinned vendor/compiler emits \tag{..} as text_run_nucleus(pieces), followed by text_space(INTERIM_TAG_GAP_EM) (vendor/compiler/src/math.rs:2387-2408). A label with math or styled pieces arrives as Nucleus::TextRun. The parentheses are already in the pieces for \tag and are absent for \tag*.
  • Main's strip_tag still has only the if let Nucleus::Text | Symbol arm. So the bug the PR describes is live on main today: \tag{hi $x^2$} falls through to the automatic (n) and no diagnostic is emitted. The fix is needed.
  • At the PR head, vendor/compiler is the old pin, which has no TextRun or text_run_reference_text, and compiler-node-surface is not a default feature. The new test file is #![cfg(feature = "compiler-node-surface")], so the PR's own CI compiled these tests out. I therefore merged origin/main into the detached review worktree locally (the merge was clean, nothing was pushed) and ran everything on that merged tree.

MATERIAL findings

None.

The new match handles every nucleus the current compiler produces under a \tag span:

  • Text: the label.
  • Space: the interim gap, ignored.
  • TextRun: set as flattened text, with a math_limitation anchored at the \tag span.
  • Anything else: the display is left unnumbered and a limitation is reported.

Both call sites (the equation path and the align row path) pass the document-level limitations vector, the same pattern every neighbouring diagnostic uses. The \tag* and align paths behave correctly (probe results below).

Non-blocking notes

  1. The "same flattening as \eqref" claim is not accurate. adapter.rs:3263 calls text_run_reference_text(pieces), which has no source. The compiler's \eqref (vendor/compiler/src/parser.rs:6873) uses text_run_reference_text_with_source. Probe: \tag{$\frac{1}{2}$}\label{e} ... \eqref{e} sets the tag as ((1/2)) but the reference as (\frac{1}{2}), so the two read differently. Both are interim approximations until render-pipeline: rich \tag placed as amsmath does — margin, leqno, own line, align/gather/multline (#441 PR 2; needs re-pin past #470) #585, so this does not block. Either pass the source (texts.get(a.span.document.0)) so they match, or reword the comment and the PR text.
  2. Math-only symbol labels paint nothing visible. Probe: \tag{$\alpha$} sets (α) in lmroman10-regular, which has no glyph for α. The page shows (), with a missing_glyph diagnostic next to the math_limitation. It is reported, so not silent, but \tag{$\ast$}, \tag{$\dagger$} and \tag{$\star$} are common in real papers and will likely degrade the same way. This is still strictly better than a wrong (n), and render-pipeline: rich \tag placed as amsmath does — margin, leqno, own line, align/gather/multline (#441 PR 2; needs re-pin past #470) #585 is the real fix. Consider mentioning it in the limitation text.
  3. The _ arm (adapter.rs:3284) sets Some(String::new()), and that is not quite "unnumbered". display_block still builds a zero-width number_box, which sets q = quad and takes the numbered §1199-1202 placement branch. The arm is unreachable with the current compiler, so this does not block. A dedicated "suppress" signal would match the comment. The arm also overwrites a label already found if an unexpected atom follows it. That is harmless today, and if tag.is_none() would guard it.
  4. The PR head is stale (190 behind, stacked on re-pin readiness: the compiler vendor re-pin is now one step (runbook + gated pipeline arms; fixes 13 red tests on main) #711, which has since merged). On the head commit, CI did not exercise tag_rich_label.rs at all. Rebase or merge main so the PR's CI actually runs the four tests, or rely on the integration-branch CI where the feature is default. The merge with main is textually clean.
  5. Test coverage is equation-only. An align row assertion would be cheap, and the code path differs (math_row_of). My probe shows it works: (hi x²) on row 1, (2) on the untagged row 2, and one limitation.
  6. No corpus digests or perf baselines are touched, and none should need re-recording: output changes only for documents with rich \tag labels. None of the perf corpus has one, as far as the unchanged engine performance digests on main suggest. I did not run perf-bench.

Tests run (sequentially, nice -n 15 env CARGO_BUILD_JOBS=3 CARGO_TARGET_DIR=~/flashtex-wt/review-target, from crates/render-pipeline, on PR head + local merge of origin/main)

  • cargo test --locked --test tag_rich_label: 4 passed, 0 failed. Latin Modern is available on this host, so the tests really ran.
  • Mutation check: I restored main's src/adapter.rs (the old strip_tag) and re-ran. a_rich_tag_is_never_silently_replaced_by_the_automatic_number and a_rich_tag_reports_that_its_math_is_set_as_text FAILED, and both controls passed. This confirms the tests discriminate the fix. I restored the file afterwards.
  • Temporary probe test (deleted afterwards), results on the merged tree:
    • \tag{$\alpha$}: words (α), plus math_limitation and missing_glyph U+03B1.
    • \tag*{hi $x^2$}: words hi, x², with no parentheses (correct), plus math_limitation.
    • align with \tag{hi $x^2$} on row 1: (hi x²), row 2 (2), one limitation.
    • \tag{$\frac{1}{2}$} + \eqref: tag ((1/2)), reference (\frac{1}{2}). (see note 1).

VERDICT: APPROVE

@d-q222
d-q222 merged commit 2ab8eb4 into main Sep 17, 2026
21 of 22 checks passed
jay3332 added a commit that referenced this pull request Sep 19, 2026
…470 re-pin (#441)

Brings daniel-parent's `agent/daniel-parent/tag-placement-pipeline` in
against today's `crates/render-pipeline`, 730 commits past its merge base:

- The compiler half of the branch (`1b6f03f2`: a `\tag` in an
  `align`/`gather`/`multline` row replaces its number) is dropped -- main's
  parser already does this (`custom_tag_text`, multline label resolution),
  so `crates/compiler` is untouched.
- The `compiler-text-run` feature is folded into the default
  `compiler-node-surface`: `vendor/compiler` and `vendor/math-layout` carry
  `TextRun`/`TextPiece` already (PIN `0bc4a2c7a`, `456ff1e6`), so the arms
  are live rather than gated off.
- `incremental.rs` (`hash_math`/`shift_math` TextRun arms), the
  `math_grids`/`math_glue_em`/`math_approximations` walks and the
  `line_break_inline` lowering keep main's versions, which already cover
  the branch's.
- The `TextRun` conversion arm replaces main's interim splice (formulas
  spliced into one list at the enclosing style) with math-layout's
  `Nucleus::TextRun`: text pieces in the face their `TextStyle` names
  (`\textbf`/`\emph` with `\check@icr`'s italic correction), formulas as
  their own lists at `\textstyle`.
- `strip_tag` keeps main's `notes` argument and its "never `None`" contract
  (#736); a `TextRun` label now becomes a `TagLabel` carrying the run, set
  by `math_number_box` as `\maketag@@@`'s `\hbox`, and the
  `math_limitation` warning for it goes away. main's multline number move
  in the adapter now carries `number_math` with `number` (the branch had
  no such move, so its tag would have been set as flattened text).
- `rows_block` keeps main's `eqnarray` strut/`\jot` handling around the
  branch's own-line tag placement (`\place@tag`/`\place@tag@gather`).
- Fixtures 47/48 collided with main's `cm-math-roman-boxes`; the branch's
  gather own-line fixtures are 51/52. `display_placement.rs` lists the
  twelve rich-tag fixtures unconditionally.

Measured on this lane's tree (display-placement `oracle.py check`,
pdflatex TeX Live 2026, 0.5 bp): 37-46, 51, 52 all PASS, worst 0.005 bp,
the pre-existing set unchanged; `render-corpus-v2.sh` output for all 71
real-world and divergence fixtures is byte-identical to `c859468d1`'s.

Implementation-Agent: Claude Code (mac-claude-a / lane-tagmath)
Commit-Executor: git via Claude Code
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y1nAv4pEnmMYXgteBoadHn
jay3332 added a commit that referenced this pull request Sep 19, 2026
… of the #736 approximation (#441)

`tag_rich_label.rs`, `tag_eqref_flatten.rs` and `tag_greek_label.rs` were
written for the interim behaviour -- a rich `\tag` set as its flattened text under a
`math_limitation` note, and a `\frac` in a tag falling back to its source
text on both the tag and the `\eqref` -- which the #585 merge replaces.

- `a_rich_tag_reports_that_its_math_is_set_as_text` becomes
  `a_rich_tag_reports_no_limitation`: nothing is approximated, so nothing
  is reported.
- New `a_rich_tag_is_set_where_pdflatex_sets_it`: `\tag{$x^2$}` and
  `\tag{hi $x^2$}` word origins against pdflatex (TeX Live 2026, lmodern:
  `(` 459.564, `x` 463.438, `2` 469.136 raised 3.616 bp; `(hi` 447.949,
  `x` 463.444), within 0.5 bp; the superscript is a raised script run,
  never the text `²`.
- `frac_tag_and_eqref_produce_identical_flattened_text` becomes
  `frac_tag_and_eqref_set_the_same_fraction`: `\tag{$\frac{1}{2}$}` and
  `\eqref` to it stack `1` over `2` at the same offsets from their `(`
  (pdflatex: numerator 5.066 bp in, 3.923 bp up), with no `\frac` on the
  page.

- `tag_greek_label.rs` (GH-805): `\tag{$\alpha$}` no longer needs the text
  face's math-face fallback -- the α is math italic in `\maketag@@@`'s
  box -- so `greek_tag_reports_where_its_alpha_came_from` becomes
  `greek_tag_raises_no_missing_glyph`, and the tag's and `\eqref`'s
  `(`/`α`/`)` are pinned at pdflatex's origins (463.322/467.195/473.605
  and 151.478/155.351/161.761 bp).

The "never the automatic number" regression test keeps its contract.

Implementation-Agent: Claude Code (mac-claude-a / lane-tagmath)
Commit-Executor: git via Claude Code
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y1nAv4pEnmMYXgteBoadHn
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