Skip to content

Attribute the ten sheets on the wrong page area: the selector is right, 44 sheets are missing - #25

Merged
tannevaled merged 1 commit into
mainfrom
pagearea-selection
Sep 5, 2026
Merged

tannevaled merged 1 commit into
mainfrom
pagearea-selection

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

What this settles

v0.20.0's TestSheetsAgainstPdfium reported ten sheets across three forms opened on the wrong page areaus-uscis__g-1055 6, i-956g 3, i-956 1 — lined up by INDEX. That number cannot attribute what it finds. A sheet the other side opens and this one does not shifts every sheet after it, so a page turn missed in the MIDDLE of a run is reported as a wrong page area on every sheet up to the next boundary. The three forms it names are exactly the three whose sheet counts disagree most.

So the two sequences are now compared by ORDER as well: is every page area this opens one pdfium opens, in the same order?

Over the 559 forms pdfium lays out, nine sequences move at all, and on every one of them one side's is a subsequence of the other's. Not one form is a case where neither is.

559 forms judged, 1 with no dump
3035 sheets lined up by index      same SIZE 100.00%   same PAGE AREA 99.67%
  us-uscis__g-1055  6 of 64      us-uscis__i-956  1 of 14      us-uscis__i-956g  3 of 15
aligned by ORDER instead: 9 forms whose sequence moves at all,
  48 sheets pdfium opens that this does not, 41 this opens that pdfium does not
sheets opened on a page area pdfium does not CHOOSE there: 0 forms

No sheet of the corpus is opened on a page area pdfium does not choose at that point in the order. The ten are the projection of 44 missing sheets on three forms (i-956 3, i-956g 9, g-1055 32) onto an index-aligned comparison. The 41 in the other direction are t657 24e/25e and rc243, the three forms settled in #18 as the form's own scripts.

The new count — forms where NEITHER sequence is a subsequence of the other — is a real wrong choice and t.Errorfs. It is nought.

What changed

  • TestSheetsAgainstPdfium: the order-aligned half, and a doc comment that says why the index-aligned half cannot attribute what it finds and what each half is blind to.
  • subsequence, with a unit test of its own, including the case greedy has to get right: a repeated name where the first match is not the one a later entry needs.
  • doc.go records that WHICH page area each sheet is opened on agrees with pdfium everywhere.

Test and comment only. The package's non-test code changes by ten lines of doc comment, so no layout can have moved. Controls, all unchanged: 3 088 corpus sheets; 81 750 fields and 151 323 draws placed with none left over; x 100.00% under a wrapping container and under a table row, 97.69% under neither.

Gate

gofmt clean, go vet clean, exact 100% statement coverage with XFACORPUS unset, -race, 15 cross-compile targets (linux amd64/arm64/riscv64/loong64/ppc64le/s390x/mips64/386, js/wasm, wasip1/wasm, darwin arm64/amd64, windows/amd64, freebsd/amd64, android/arm64), CGO_ENABLED=0, GOWORK=off, Go 1.27.1 via GOTOOLCHAIN.

Findings, the alignment script and the traces are at /Users/Shared/xfa-pagearea-fix/. Full write-up on #7.

🤖 Generated with Claude Code

v0.20.0 reported ten sheets across three forms opened on the wrong page
area, lined up by INDEX. That number does not attribute what it finds: a
sheet the other side opens and this one does not shifts every sheet after
it, so a page turn missed in the MIDDLE of a run is reported as a wrong
page area on every sheet up to the next boundary.

So the two sequences are compared by ORDER as well. Over the 559 forms
pdfium lays out, nine sequences move at all and on every one of them one
side's is a SUBSEQUENCE of the other's: no sheet of the corpus is opened
on a page area pdfium does not choose at that point in the order. The ten
are the projection of 48 sheets pdfium opens that this does not — 44 of
them on those three forms — and 41 this opens that pdfium does not, all
three of those the forms whose own scripts pdfium runs.

The new count, forms where NEITHER sequence is a subsequence of the
other, is a real wrong choice and fails the test. It is nought.

    3035 sheets by index   same SIZE 100.00%   same PAGE AREA 99.67%
    by ORDER: 9 forms move, 48 sheets pdfium opens that this does not,
              41 this opens that pdfium does not
    opened on a page area pdfium does not CHOOSE there: 0 forms

Test and comment only: the package's non-test code changes by ten lines
of doc comment, so no layout moves. 3 088 corpus sheets, 81 750 fields
and 151 323 draws placed with none left over, x 100.00% under a wrapping
container and under a table row, all unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 9fd176d into main Sep 5, 2026
1 check passed
@tannevaled
tannevaled deleted the pagearea-selection branch September 5, 2026 20:20
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