reviewer3: compile FULL source + page-trim PDF (fix pdflatex failures)#86
Merged
Merged
Conversation
…ilures)
The token-based truncation in `prepare_units` cuts the LaTeX-as-md staged file
at a token boundary, which routinely leaves the document mid-environment.
pdflatex on the staged file then "produces no usable PDF" for a fraction of
papers, surfacing as a hard failure in the reviewer3 run.
Switches the reviewer3 system to compile the FULL pre-truncation source
(`u.src_corrupted`) and then trim the rendered PDF to its first N pages.
This matches the `max_pages: 20` convention conference_study/configs/coarse.yaml
already uses for coarse, so reviewer3 sees roughly the same content window
the other systems see.
Three pdflatex robustness fixes layered in:
1. Strip orphan `\input{...}` / `\include{...}` whose target file isn't
bundled. pdflatex aborts hard on a missing \input, killing the compile
for the whole paper even when the body is fine (paper_005 cs_CC had
`\input{mypreamble.tex}`).
2. Inject a defensive preamble of `\providecommand` fallbacks for common
author-defined shortcuts (\bbR, \calA, \bfx, \eps, \vvirg, \ootimes,
etc.). Authors typically define these in private preamble files we
don't have; \providecommand is a no-op when the command is already
defined, so the injection is safe blanket coverage.
3. subprocess.run uses bytes (text=False) instead of text=True so the
pdflatex log's non-UTF-8 accent bytes don't blow up Python's decoder
(paper_009 cs_CC had byte 0xaa at offset ~57k).
Changes
- Reviewer3System.build_jobs threads `u.src_corrupted` (full path) and
`cfg["max_pages"]` into the job payload.
- Reviewer3Job adopts `source` + `max_pages` fields; `_submit` / `_ensure_pdf`
forward them.
- `_ensure_pdf` prefers `source` over `paper` for the compile when set;
caches alongside the source with `.trim.pdf` suffix when trimmed.
- `_trim_pages_to` (in-place) and `_maybe_trim_pages` (for already-PDF inputs)
use pymupdf to cap pages.
- `max_pages: 20` added to all 8 `full_*_reviewer3.yaml` configs.
- run_benchmark.py Config gains `max_pages: int | None = None`.
Smoke-validated on three previously-failing cs_CC papers (2604.19872v1 with
missing \input + custom commands, 2604.24325v1 with same pattern, 2604.24879v1
with non-UTF8 bytes in pdflatex output) — all three now produce 20-page
trimmed PDFs in 2–4s.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Auto-closed: fast-forward push moved this commit onto |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on top of #85.
Problem
The reviewer3 perturbation run hit ~37% per-paper failure rate. Three distinct failure modes:
pdflatex produced no usable PDF(4 cells across cs_CC paper_005, paper_008) — token truncation in `prepare_units` cuts the LaTeX-as-md source mid-environment, so pdflatex fails on the staged file.Fix
Switch the reviewer3 system to compile the full pre-truncation source and trim the rendered PDF to its first N pages — matches the `max_pages: 20` convention coarse already uses.
Three additional pdflatex robustness layers:
Files
Test plan
🤖 Generated with Claude Code