Skip to content

measurement: harness project_root, real metrics dirs, readable page counts - #344

Merged
GoKubar merged 1 commit into
mainfrom
agent/linux-parity-measurement/harness-project-root
Sep 14, 2026
Merged

GoKubar merged 1 commit into
mainfrom
agent/linux-parity-measurement/harness-project-root

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

What this is

Measurement-infrastructure only. Five bugs in tools/visual-oracle/rank.py and
tools/real-world-corpus/run.py that made the parity numbers describe the
harness rather than the engine, plus one opt-in flag on flashtex-render they
need. No committed expected data is touched (fixtures/, tests/, refs/
are untouched; git status is clean apart from the five files in this diff).

The five harness bugs

# Bug Effect on the numbers
1 No project_root in the compile request every \includegraphics returned the hard error "no project root was supplied with the request, so image files cannot be read" — 5 of 22 fixtures, and 5 of the 6 page-count mismatches
2 flashtex-render hardcoded Wire { images: false } for --v2 a graphic that resolved perfectly still left no image item in the display list the PDF route reads
3 flashtex-pdf-exact from-v2 called without --project-root the exporter could not read the bytes of an image it was told about
4 --tfm-dirs defaulted to public/lm alone dropped the bundled jknappen/ec (256 .tfm, ectt* included) and amsfonts/symbols: 102 ec_metrics_unavailable across 16 of 22 fixtures, and |dx| ≤ 0.5 bp falls from 73.1% → 61.5%
5 pdf_page_count byte-scanned for /Type /Page finds nothing in an object-stream PDF, i.e. in 21 of 22 references, so rank.py's page comparison was vacuous

Also here: rank.py now fails loudly on font diagnostics the way run.py
already did; it reports within_0_5_x / within_0_5_y separately; it pins
payload.date; and neither it nor run.sh labels a report
origin/agent/mac-render-pipeline/unified @ 9aaec57a regardless of which
binary actually ran.

--images on flashtex-render is off by default, so every existing
caller's --v2 bytes are unchanged.

Proof that the request fix works

Same binary, same document, a scratch fixture holding a real 120×80 PNG:

A  old request (no project_root)          -> error image_unavailable
                                             "no project root was supplied ..."
                                             v2 item kinds: {glyph_run: 22}
B  + payload.project_root                 -> no image diagnostic at all
                                             v2 item kinds: {glyph_run: 22}
C  + display-list-v2-images and --images   -> v2 item kinds: {glyph_run: 22, image: 1}
      image item: format png, 120x80, sha256 7ba3f549...  path "plot.png"

All three parts of the chain are needed; only C actually puts the image on the
page.

What this does not fix

Supplying project_root does not make the corpus's five image fixtures render,
because the corpus contains no image files at all — deliberately. Four
fixtures use graphicx draft and two use the package's demo option, both of
which pdflatex resolves without reading any file. The engine honours neither
(draft is GKey::Unsupported; demo is a package option render-pipeline
never sees), so after this PR the diagnostic changes from blaming the harness
to naming the real gap:

before: image file unavailable: no project root was supplied with the request
after : image file 'plot.png' not found (tried plot.png, plot.png.pdf, ...)

Oracle measurements for whoever picks that up (pdfTeX 3.141592653-2.6-1.40.27,
\linewidth 360 pt):

  • demo: natural 150 pt × 100 pt; height stays 100 pt whatever the requested
    width
    (width=\linewidth → 360 × 100, draft,width=0.6\textwidth → 216.0022 × 100).
  • draft with a missing file: natural size 1 in × 1 in, aspect preserved
    (draft,width=0.8\linewidth → 288.0011 × 288.07976); a LaTeX warning, not
    an error, and the box carries a frame and the filename in \ttfamily.

Verification

  • flashtex-render sha256 8f635baf61a93af91e1e50ce72508e0e37e071f1abff799cc838b7f5e85f57ec, built from this tree.
  • amsmath corpus 59/59 within 0.5 bp.
  • HW1 3 pages, 0 errors, 0 overfull; HW2 3 pages, 0 errors, 0 overfull.
  • cargo test --release on crates/render-pipeline: all green, tabular_oracle 106/106.
  • python3 -m unittest on both tools/visual-oracle (8) and tools/real-world-corpus (6): green.
  • Zero font-failure diagnostics across all 22 fixtures with the three-directory metrics env.
  • No pixel comparison was possible on this host: neither pdftoppm nor Ghostscript is installed, so nothing here is a raster claim.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

…irs and a readable page count

The parity harnesses were measuring themselves in five places. None of this
changes committed expected data; all of it changes what the harnesses report.

1. No `project_root` in the compile request (`rank.py`, `run.py`). The document
   snapshots carry text only, so every `\includegraphics` came back as the hard
   error "no project root was supplied with the request, so image files cannot
   be read" -- a property of the harness, not of the engine. Five of the 22
   corpus fixtures hit it, and they are five of the six page-count mismatches.

2. `--v2` never carried image items. `flashtex-render` hardcoded
   `Wire { images: false }` for its `--v2` side output, so even a graphic that
   resolved left no image item in the display list the PDF route reads. Added
   an opt-in `--images` flag (off by default, so existing callers' `--v2` bytes
   are unchanged) and the matching `display-list-v2-images` capability in both
   harnesses' requests.

3. `flashtex-pdf-exact from-v2` was called without `--project-root`, so the
   exporter could not read the image bytes it was told about.

4. `--tfm-dirs` defaulted to `texmf/fonts/tfm/public/lm` *alone*, dropping the
   bundled `jknappen/ec` (256 files, `ectt*` included) and
   `public/amsfonts/symbols`. Measured on this corpus, that default produces
   102 `ec_metrics_unavailable` diagnostics across 16 of 22 fixtures and drags
   `|dx| <= 0.5 bp` from 73.1% down to 61.5% -- 11.6 points of "engine miss"
   that was the harness's own font configuration. Both harnesses now derive the
   metrics roots with `fontenv.tfm_dirs_for` (new `fontenv.resolve_dirs`:
   explicit flag > exported variable > derivation).

5. `pdf_page_count` scanned raw bytes for `/Type /Page`, which finds nothing in
   an object-stream PDF -- i.e. in every reference pdfTeX has written since
   object compression became the default. It returned None for 21 of 22
   references, so `rank.py`'s page-count comparison was vacuous. It now asks
   `pdftext`, which already parses xref streams and the page tree, and keeps
   the byte scan as the fallback.

Also: `rank.py` now fails loudly on font diagnostics the way `run.py` already
did; reports `within_0_5_x` / `within_0_5_y` separately (the combined figure
hid that horizontal placement is far better than vertical); pins `payload.date`
like `run.py`; and no longer labels every report
"origin/agent/mac-render-pipeline/unified @ 9aaec57" regardless of which
binary ran. `run.sh` defaults to this checkout's own render build for the same
reason.

Measured with flashtex-render sha256
8f635baf61a93af91e1e50ce72508e0e37e071f1abff799cc838b7f5e85f57ec (built from
this tree). Gates: amsmath corpus 59/59 within 0.5 bp; HW1 and HW2 both 3
pages, 0 errors, 0 overfull; `cargo test --release` on crates/render-pipeline
all green including tabular_oracle 106/106; both harness unittest suites green;
`git status` clean apart from these four files. No pixel comparison was
possible on this host: neither pdftoppm nor Ghostscript is installed.

Implementation-Agent: Claude Opus 5 (linux-primary parity-measurement lane)
Commit-Executor: Claude Opus 5 via Claude Code (Cursor quota not used)
Co-Authored-By: Claude Opus 5 <[email protected]>
Co-authored-by: GoKubar <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
@GoKubar
GoKubar marked this pull request as ready for review September 14, 2026 10:10
@GoKubar
GoKubar merged commit b83a123 into main Sep 14, 2026
19 of 20 checks passed
d-q222 added a commit that referenced this pull request Sep 14, 2026
…s and set diagnostics: false in flashtex-render's Wire

Conflict in crates/render-pipeline/src/bin/flashtex-render.rs: main (#344) made
--v2 honour --images; this branch added the Wire.diagnostics field. Resolved
as Wire { images: self.images, device_color, diagnostics: false }.
lib 97/0, compiler_diagnostic_forward 2/0, display_list_delta 3/0, cli_e2e 4/0.

Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
@GoKubar
GoKubar deleted the agent/linux-parity-measurement/harness-project-root branch September 16, 2026 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant