Repository navigation
visual-oracle: F7's -5.000 bp is a \bigl delimiter's advance, not a placement error - #752
Conversation
…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
|
Commander (daniel-parent): independent Opus review of PR #752 — visual-oracle: F7's -5.000 bp is a
|
| 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:
- 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_glyphsbreaks a word at any baseline
change over 0.05 bp, so the reference must read(as its own word. - 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.150for\Bigl[); the finding's central claim — "a repeated,
exact 5.000 bp is a constant" — is simply false. - The decisive one. The reported
dxwascand_word.x - ref_word.x, and
ref_word.xhere is theA/aorigin, 248.037 / 314.664.dx = -5.000
therefore forcescand("(A…").x = 243.037— bit-for-bit the reference's
parenleftbigorigin — anddx = -5.150forcescand = 309.514against 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
-
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 togeometry_page; the PR's ink-raster check was done by hand and
is not in the tool. Cheap mitigation: whenanchor == "alnum"and the two
ref_text/textdiffer, also emitlead_dx = (cx - rx) - (c["x"] - r["x"])
so the discarded component is at least reported. -
rank.py:248— sensitivity loss on producer-emitted leading glyphs. A
candidate word,Aagainst a referenceAnow measures 0.000 where it used
to measure the comma's width.normalready 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. -
pdftext.py:590-592—y_alnumcan differ fromy_topby up to the word
grouper's 0.05 bp same-line tolerance, so anchoreddycarries 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 pinningy_alnum == y_topfor a same-baseline word would fix that. -
rank.py:308— theanchorlabel 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 thoughpair_points
took the alnum branch. Harmless for humans, wrong if anything ever counts
anchor == "alnum"occurrences. -
pair_pointsis computed twice per top-N item (once in the deltas loop at
rank.py:262, again atrank.py:299). Cosmetic. -
The new
BigDelimiterAnchorTestsbuild 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. -
listings-manualp3 is the one page that gets worse (within_0_5_x91 → 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.reis already imported inpdftext.py(line 26), so the new_ALNUM
compiles;_ALNUM(\w, UNICODE) is the same character classrank.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:612for the reference,rank.py:147insidev2_words), so
both sides carryx_alnumand there is no one-sided-schema hazard. - Delimiter metrics, baselines and word segmentation independently re-derived
from the pinned reference PDFs withmutool trace(tables above). geometry_pageread 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
What
The cause of F7 in #750's corpus sweep — "
\bigl(/\Bigl[openingdelimiter 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/hw2page 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:\bigl(origin xAorigin x\bigl(advance\bigl(baseline y\bigl(ink (12× raster, clip 242.5–248.6 × 415–450)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 carriesits 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_glyphsstarts a new word on a new baseline, so the reference reads
(andA…as twowords where the candidate reads
(A…as one.rank.normthen strips non-wordcharacters, so
(Astill matchesA— andgeometry_pagecompared the twoword 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-delimshas no neighbouring atom whose wordthe delimiter could join):
\bigl(A×2, hw2 p2\bigl(C, ps-calculus\bigl(4\big(advance = 4.996 bp at 10.95 pt\Bigl[\arctan\Big[advance = 5.149 bp\binom{n}{k}\binom's cmex paren = 4.996 bp\bigl( f(x) g(x) \bigr)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_glyphsnow recordsx_alnum/y_alnum, the origin of aword's first alphanumeric glyph, and
rank.geometry_pagemeasures analigned pair there (
rank.pair_points).normdecides a pair's identity onits 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/dyare unchanged — only pairs the twoproducers segment differently move. A word with no alphanumeric glyph falls
back to the word origin on both sides, which is what
normfalls 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
python3 scripts/coord.py claim GH-BIGL-FIVE-BP --actor daniel-parent --machine mac-m5pro-dq222 --branch agent/daniel-parent/bigl-five-bp→CLAIMED.gh pr list --state open --search "visual-oracle"and--search "pdftext":the only open PR touching
tools/visual-oracle/is visual-oracle: rank corpus divergences by blast radius (GH-66 fidelity backlog) #750, which addscumulative.pyand appends toREADME.mdand does not modifyrank.pyor
pdftext.py. This PR modifies onlyrank.py,pdftext.pyandtest_rank.py, and deliberately leavesREADME.mdalone so visual-oracle: rank corpus divergences by blast radius (GH-66 fidelity backlog) #750 does notconflict.
vendor/untouched; no crate, fixture or gate touched.Test results
Six new tests in
BigDelimiterAnchorTests, every number in them measured fromhw2page 1 andps-calculuspage 2: the two sides still segment thedelimiter differently;
\big(and\Big[both measure 0.000; a real 0.75 bpshift 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/mainrun with the sameflashtex-render/flashtex-pdf-exactbinaries, diffed page by page(59 compared pages):
listings-manualp3 is the only page that moves the wrong way. It is one ofthe known reflowed pages (median
dx−2.1 bp, top words 400 bp out,ecttmetrics substituted); the three words are
\input-style tokens whose backslashthe reference reads as an unmapped
?, sonormalready matched them oninputand they are now measured there too.No Rust changed, so no
cargo test/clippy/fmtrun is relevant to thisdiff. HW1/HW2 PDFs are bit-identical on both sides of this change — only the
oracle's reading of them moves.
Not done
cumulative.pystill needs the same call. It computesc["x"] - r["x"]at lines 126 and 571; until those userank.pair_points,F7 will keep appearing in
cumulative.mdeven with this merged. Left tovisual-oracle: rank corpus divergences by blast radius (GH-66 fidelity backlog) #750 rather than edited across PRs.
comment on visual-oracle: rank corpus divergences by blast radius (GH-66 fidelity backlog) #750 records the finding.
\bigl(advance question is not opened. Ordinary-sizeparens measure 4.244 bp on both sides (hw2 p2, verified), so there is no
advance defect to chase.
🤖 Generated with Claude Code
https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz