Skip to content

visual-oracle: F7's -5.000 bp is a \bigl delimiter's advance, not a placement error - #752

Merged
d-q222 merged 1 commit into
mainfrom
agent/daniel-parent/bigl-five-bp
Sep 17, 2026
Merged

d-q222 merged 1 commit into
mainfrom
agent/daniel-parent/bigl-five-bp

Conversation

@d-q222

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

Copy link
Copy Markdown
Contributor

What

The cause of F7 in #750's corpus sweep — "\bigl( / \Bigl[ opening
delimiter beside other math, exactly −5.000 bp, cause not identified" —
and the fix. No rendering behaviour changes; no Rust is touched.

The −5.000 bp is not a rendering defect and not a constant. It is the
advance width of the large delimiter glyph, reported as a placement error
by the oracle's own word grouper.

Measured on fixtures/real-world/hw2 page 1
(\bigl(A\cap B\ne\varnothing\bigr) \Longrightarrow \bigl(A\setminus B\subsetneq A\bigr)),
pdflatex vs flashtex-render --v2 → flashtex-pdf-exact from-v2:

reference (pdflatex) candidate
\bigl( origin x 243.037 243.037 equal
following A origin x 248.037 248.037 equal
\bigl( advance 4.996 4.996 equal
\bigl( baseline y 426.604 (cmex10) 435.483 (math baseline) differs by 8.836
\bigl( ink (12× raster, clip 242.5–248.6 × 415–450) (244.667, 426.167)–(248.583, 439.167) (244.417, 426.250)–(248.583, 439.167) within 0.25 / 0.083 bp

So the delimiter is in exactly the right place. What differs is which word
it lands in. pdfTeX sets \bigl( from cmex10, whose variant glyph carries
its own origin, and emits it on a baseline 8.8 bp above the line; ours is a
LatinModernMath variant sitting on the math baseline. pdftext.words_from_glyphs
starts a new word on a new baseline, so the reference reads ( and A… as two
words where the candidate reads (A… as one. rank.norm then strips non-word
characters, so (A still matches A — and geometry_page compared the two
word origins, which differ by the delimiter's advance.

That also explains why it was never exactly constant, and why the minimal probe
could not reproduce it (u2-manual-delims has no neighbouring atom whose word
the delimiter could join):

F7 witness reported the glyph it is
hw2 p1 \bigl(A ×2, hw2 p2 \bigl(C, ps-calculus \bigl(4 −5.000 / −4.998 / −4.997 \big( advance = 4.996 bp at 10.95 pt
ps-calculus \Bigl[\arctan −5.150 \Big[ advance = 5.149 bp
math-sheet \binom{n}{k} −4.999 \binom's cmex paren = 4.996 bp
math-sheet \bigl( f(x) g(x) \bigr) −3.503 same, partly absorbed by the line median

Does it scale with size? It is a glyph advance, so yes — and that is the
decisive evidence that it was never a 5 pt constant: \Big[ gives 5.149 where
\big( gives 4.996, on the same page of the same document.

The fix

pdftext.words_from_glyphs now records x_alnum/y_alnum, the origin of a
word's first alphanumeric glyph, and rank.geometry_page measures an
aligned pair there (rank.pair_points). norm decides a pair's identity on
its alphanumeric content, so its position is now measured on the same
content. When both sides carry the same leading punctuation the anchor moves
both by the same amount and dx/dy are unchanged — only pairs the two
producers segment differently move. A word with no alphanumeric glyph falls
back to the word origin on both sides, which is what norm falls back to too.

Why

A 10× false positive over the 0.5 bp gate, on the two documents (HW1/HW2) the
corpus treats as its clean baseline, is worse than no measurement: it puts a
non-existent math defect at the top of the fidelity queue. It is also not a
one-off — every large delimiter set from cmex10 beside another atom produces
one, which is exactly the five words F7 recorded across three fixtures.

Overlap check

Test results

python3 -m unittest discover -s tools/visual-oracle -p 'test_*.py'
Ran 21 tests in 0.025s
OK

Six new tests in BigDelimiterAnchorTests, every number in them measured from
hw2 page 1 and ps-calculus page 2: the two sides still segment the
delimiter differently; \big( and \Big[ both measure 0.000; a real 0.75 bp
shift beside the delimiter is still reported and still fails the 0.5 bp gate;
matching leading punctuation changes nothing; a punctuation-only word falls
back to its origin.

Full 22-fixture sweep, this branch and origin/main run with the same
flashtex-render / flashtex-pdf-exact binaries, diffed page by page
(59 compared pages):

aligned / reference_unaligned / candidate_unaligned: identical on all 59 pages
hw1 p2            dx_max 5.000 -> 0.611   within_0_01 139 -> 141
hw2 p1            dx_max 5.000 -> 1.086   within_0_5_x 196 -> 198
hw2 p2            dx_max 4.568 -> 0.432   within_0_5_x 290 -> 291
math-sheet p1     within_0_5_x 133 -> 134  (\binom and \bigl( leave the top list)
ps-calculus p2    within_0_5_x 223 -> 225  (\Bigl[ leaves the top list)
conf-paper p3     dx_max 0.005 -> 0.004
lmodern-report p2 dx_max 0.007 -> 0.006
plain-article p2  dx_max 0.158 -> 0.121
thesis-chapter p3 dx_max 0.041 -> 0.040
inline-math p1    within_0_5_x 676 -> 677
natbib-review p2  within_0_5_x 416 -> 417
listings-manual p1 within_0_01 261 -> 265
listings-manual p3 within_0_5_x 91 -> 88
the other 46 pages: byte-identical geometry

listings-manual p3 is the only page that moves the wrong way. It is one of
the known reflowed pages (median dx −2.1 bp, top words 400 bp out, ectt
metrics substituted); the three words are \input-style tokens whose backslash
the reference reads as an unmapped ?, so norm already matched them on
input and they are now measured there too.

No Rust changed, so no cargo test / clippy / fmt run is relevant to this
diff. HW1/HW2 PDFs are bit-identical on both sides of this change — only the
oracle's reading of them moves.

Not done

🤖 Generated with Claude Code

https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

…tity

What changed:
`pdftext.words_from_glyphs` now records `x_alnum`/`y_alnum`, the origin of a
word's first alphanumeric glyph, and `rank.geometry_page` measures an aligned
pair there (`rank.pair_points`) instead of at the two word origins. Both sides
go through the same function, so a pair that carries the same leading
punctuation is anchored identically and its `dx`/`dy` do not move; only pairs
the two producers segment differently change.

That is F7 of the 2026-09-16 corpus sweep (#750): "`\bigl(` / `\Bigl[` beside
other math, exactly -5.000 bp, cause not identified". The cause is the
measurement. pdfTeX sets `\bigl(` from cmex10, whose variant glyph carries its
own origin, and emits it on a baseline 8.836 bp above the line; ours is a
LatinModernMath variant on the math baseline. `pdftext` splits words on a new
baseline, so the reference reads `(` and `A...` as two words where the
candidate reads `(A...` as one. `rank.norm` strips non-word characters, so `(A`
still matches `A` -- and the word origins then differ by the delimiter's
advance. 4.996 bp is `\big(` at 10.95 pt and 5.149 bp is `\Big[`: the reported
"-5.000" and "-5.150" are two different glyph widths, not one constant.

Measured on fixtures/real-world/hw2 page 1, both PDFs put the delimiter origin
at x=243.037 and `A` at x=248.037, and the delimiter's ink agrees to 0.083 bp
vertically and 0.25 bp horizontally (12x raster, clip 242.5-248.6 x 415-450).
There is no placement error. No rendering code is touched by this commit.

What was run:
python3 -m unittest discover -s tools/visual-oracle -p 'test_*.py'
Ran 21 tests in 0.025s
OK

Full 22-fixture sweep, this branch and origin/main built identically
(flashtex-render + flashtex-pdf-exact from this tree), diffed page by page:
  59 compared pages; `aligned` identical on every page (alignment is unchanged)
  hw1 p2   dx_max 5.000 -> 0.611
  hw2 p1   dx_max 5.000 -> 1.086
  hw2 p2   dx_max 4.568 -> 0.432
  math-sheet p1 / ps-calculus p2: the `\binom`, `\bigl(` and `\Bigl[` outliers
    leave the top list; within_0_5_x 133 -> 134 and 223 -> 225
  conf-paper p3, lmodern-report p2, plain-article p2, thesis-chapter p3:
    dx_max 0.005 -> 0.004, 0.007 -> 0.006, 0.158 -> 0.121, 0.041 -> 0.040
  listings-manual p3 (a reflowed page, median dx -2.1 bp, words 400 bp out):
    within_0_5_x 91 -> 88, from `\input` vs the reference's unmapped `?input`
    now being measured at `i`. The only page that moves the wrong way.

No Rust changed, so no cargo run is relevant to this diff.

Next step:
#750's `cumulative.py` computes `c["x"] - r["x"]` at lines 126 and 571 and needs
the same `rank.pair_points` call before F7 disappears from its report.

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 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Commander (daniel-parent): independent Opus review of e3005ac7, APPROVE. The reviewer proved the withdrawal without using your reasoning: mutool trace on the pinned references shows pdfTeX emits the cmex10 parenleftbig on its own baseline (426.604 vs the line's 435.440 on hw2 p1; 358.474 vs 370.584 on ps-calculus p2), so a 0.05bp baseline-splitting word grouper must read it as a separate word on the reference side only. The reported dx is then arithmetically forced to equal the delimiter's advance — 4.996 for \big(, 5.149 for \Big[, 5.760 for \bigg[ — which forces the candidate's delimiter origin to within 0.002bp of pdflatex's. The reported number was itself the proof there was no placement error. F7's 'exactly −5.000 is a constant' was false and its own table already held the −5.150 counter-example. Non-blocking: the delimiter's position is now measured by nothing, and the anchor label is misreported. Queued to merge first of the four.

PR #752 — visual-oracle: F7's -5.000 bp is a \bigl delimiter's advance, not a placement error

Head SHA: e3005ac7381ad1b5e89a81e9e06bfeb83eb24116 (verified against
gh pr view 752 --json headRefOid). Base main. +172/-3 across
tools/visual-oracle/{pdftext.py,rank.py,test_rank.py}. No Rust, no fixtures,
no evidence files.

Is the F7 withdrawal justified?

Yes — and I can prove it from the reference PDFs alone, without trusting the
PR's candidate-side numbers.

The original finding (PR #750's docs/evidence/corpus-fidelity-2026-09-16T1130Z/README.md
lines 123 and 262-277) claims:

F7 | \bigl( / \Bigl[ opening delimiter beside other math | exactly -5.000 bp
… A repeated, exact 5.000 bp is a constant, not an accumulation of metrics.
… I did not find the cause and did not guess one

Independent verification with mutool trace (MuPDF, not this repo's
pdftext.py) on the pinned pdflatex references:

fixtures/real-world/hw2/HW2-reference.pdf page 1, the
\bigl(A\cap B\ne\varnothing\bigr) display:

glyph font x y_top advance
parenleftbig DXJXEP+CMEX10 @10.909 243.037 426.604 4.996
A HMXYNK+CMMI10 @10.909 248.037 435.440 8.182
parenleftbig (2nd) CMEX10 328.829 426.604 4.996
A CMMI10 333.829 435.440 8.182

fixtures/real-world/ps-calculus/reference.pdf page 2:

source glyph x y_top advance x(next alnum) - x(delim)
\Bigl[\arctan bracketleftBig 309.512 358.474 5.149 a @314.664 → 5.152
\bigl(4 parenleftbig 122.909 78.012 4.996 four @127.909 → 5.000
(\biggl[) bracketleftbigg 344.465 204.966 5.760 u @351.419 → 6.954

Three facts fall straight out, all measured, none taken from the PR:

  1. pdfTeX puts the cmex10 variant on its own baseline — 426.604 against the
    line's 435.440 (8.836 bp) on hw2, 358.474 against 370.584 (12.110 bp) on
    ps-calculus. pdftext.words_from_glyphs breaks a word at any baseline
    change over 0.05 bp, so the reference must read ( as its own word.
  2. The reported deviations are not a constant: 5.000 / 5.152 / 5.758, and
    they track the delimiter glyph's own advance (4.996 / 5.149 / 5.760) to
    within a kern. F7's own table already contained the counter-example it
    dismissed (-5.150 for \Bigl[); the finding's central claim — "a repeated,
    exact 5.000 bp is a constant" — is simply false.
  3. The decisive one. The reported dx was cand_word.x - ref_word.x, and
    ref_word.x here is the A/a origin, 248.037 / 314.664. dx = -5.000
    therefore forces cand("(A…").x = 243.037 — bit-for-bit the reference's
    parenleftbig origin — and dx = -5.150 forces cand = 309.514 against the
    reference's 309.512. So the candidate places the delimiter within 0.002 bp of
    pdflatex. The reported number is itself the proof that there is no
    placement error
    , independent of any raster or ink comparison.

The withdrawal is correct, and the -5.000 was a measurement artefact of the
oracle's own word grouper. The fix (anchor the comparison at the first
alphanumeric glyph, matching what norm already uses for identity) addresses
the actual cause rather than suppressing the symptom.

Material findings

None. I could not construct a scenario in which this change reports a smaller
number for a real geometric defect while the two sides segment a word the same
way, and align_words / the unaligned counts are untouched.

Non-blocking notes

  1. tools/visual-oracle/rank.py:246 (pair_points) — the delimiter's own
    position is now measured by nothing.
    In exactly the F7 configuration the
    reference's standalone ( word stays unaligned (it norms to "(" and has no
    counterpart), and the candidate's ( is now skipped by the anchor. A genuine
    future regression that moved a \bigl( relative to its operand would be
    invisible to geometry_page; the PR's ink-raster check was done by hand and
    is not in the tool. Cheap mitigation: when anchor == "alnum" and the two
    ref_text/text differ, also emit lead_dx = (cx - rx) - (c["x"] - r["x"])
    so the discarded component is at least reported.

  2. rank.py:248 — sensitivity loss on producer-emitted leading glyphs. A
    candidate word ,A against a reference A now measures 0.000 where it used
    to measure the comma's width. norm already matched the pair, so the
    positional signal was the only thing that surfaced a spurious leading glyph.
    That signal was a 10x false-positive generator here, so removing it is the
    right trade, but it is a real loss and is not stated in the README.

  3. pdftext.py:590-592 — y_alnum can differ from y_top by up to the word
    grouper's 0.05 bp same-line tolerance
    , so anchored dy carries up to 0.1 bp
    of new slack between the two sides. This corpus reports vertical findings at
    -0.056 bp (F12) and -0.067 bp (F11), i.e. below that bound. In practice
    pdfTeX emits every glyph of a line on an identical baseline (confirmed above:
    435.440 for all ten glyphs of the hw2 group), so the slack is 0 today — but
    the invariant is undocumented and untested. A test pinning y_alnum == y_top for a same-baseline word would fix that.

  4. rank.py:308 — the anchor label is misleading. It reports "word"
    whenever the anchor point happens to coincide with the word origin, i.e. for
    every word that begins with an alphanumeric glyph, even though pair_points
    took the alnum branch. Harmless for humans, wrong if anything ever counts
    anchor == "alnum" occurrences.

  5. pair_points is computed twice per top-N item (once in the deltas loop at
    rank.py:262, again at rank.py:299). Cosmetic.

  6. The new BigDelimiterAnchorTests build synthetic glyph dicts rather than
    reading the real fixtures, so they pin the arithmetic but not the numbers'
    provenance. I verified every constant they use (243.037, 248.037, 435.440,
    426.604 → 8.836, 4.996, 5.149) against the pinned PDFs and all are correct.

  7. listings-manual p3 is the one page that gets worse (within_0_5_x 91 → 88).
    The PR discloses it and the explanation is plausible (a known reflowed page
    where the reference reads \ as an unmapped ?). Not a blocker, but the
    sweep summary should not be read as a monotone improvement.

What I verified

  • Head SHA matches gh pr view.
  • git diff --stat origin/main...HEAD: 3 files, +172/-3, tools only.
  • python3 -m unittest discover -s tools/visual-oracle -p 'test_*.py' → 21
    tests, OK
    at this SHA.
  • re is already imported in pdftext.py (line 26), so the new _ALNUM
    compiles; _ALNUM (\w, UNICODE) is the same character class rank.norm
    keeps (re.sub(r"[^\w]", …), rank.py:173) — the stated invariant holds,
    including for the ? unmapped-glyph placeholder, which neither accepts.
  • Both word producers go through pdftext.words_from_glyphs
    (pdftext.py:612 for the reference, rank.py:147 inside v2_words), so
    both sides carry x_alnum and there is no one-sided-schema hazard.
  • Delimiter metrics, baselines and word segmentation independently re-derived
    from the pinned reference PDFs with mutool trace (tables above).
  • geometry_page read in full: every downstream statistic (median_shift,
    within_*, reflowed, page_owner, owner_for_word) consumes the same
    anchored deltas; nothing mixes anchored and unanchored coordinates.

VERDICT: APPROVE

@d-q222
d-q222 merged commit 12c463e into main Sep 17, 2026
20 of 21 checks passed
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