test(pdf): two bookmarks on one line, and nothing counts the one that is lost

RED. Measured on R761: 2 763 /Outlines nodes entered the bridge, 2 762 marks
came out, and `unresolved` was 0 -- so one node left no trace in the return
value at all. The lost one is `SVV - Forside`, sharing line 0 with the tree's
own root node `R761 Prosesskoden`. The cause is structural, not an edge value:
the marks are collected in a dict keyed on the destination line index, so a
second bookmark on a line is discarded by `setdefault` in silence. One node
today; a document with several bookmarks per line loses several and reports
none of them.

`outline-collision.pdf` is the fixture no existing one could stand in for --
every other outline fixture puts one bookmark on one line, which is exactly
the case where the defect cannot appear. It is laid out by hand through
`make_fixtures.py` like the other PDF fixtures, and regenerating that file
left every other fixture byte-identical.

The known-negative is in the same commit: `outline-collided.pdf` aside, the
two existing trees must report `collided == 0`, so the counter can be measured
at zero and is not green for an unstated reason.

pytest -q: 2 failed, 1554 passed, 1 skipped.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Kjell Tore Guttormsen 2026-09-10 03:16:14 +02:00
commit 3f8f03cff5
4 changed files with 106 additions and 0 deletions

View file

@ -113,6 +113,23 @@ OUTLINED_TREE = (
("1.2.1 Materialer", 3, 2, 150),
)
#: TWO bookmarks whose destinations resolve to the SAME line, mirroring what
#: R761 carries: its tree's root node `R761 Prosesskoden` and the node
#: `SVV - Forside` both land on line 0. Measured on that document, 2 763 nodes
#: entered the bridge and 2 762 marks came out with `unresolved` at 0 -- the
#: difference was a dict keyed on the line index, dropping the second node with
#: nothing counting it. A one-bookmark-per-line fixture cannot see that.
COLLISION_CONTENTS = (
b"BT /F1 12 Tf 20 170 Td (R761 Prosesskoden) Tj ET\n"
b"BT /F1 12 Tf 20 150 Td (Innledende tekst om grunnlaget.) Tj ET\n",
)
#: Both point at `/XYZ 20 185`, which is above the page's first line.
COLLISION_TREE = (
("R761 Prosesskoden", 1, 0, 185),
("SVV - Forside", 2, 0, 185),
)
#: One resolvable bookmark and one whose `/Dest` names an object that is not a
#: page. A PDF in the wild carries these; R761 carries none of them, so
#: without this fixture the "drop it, count it, do not fabricate a boundary"
@ -608,6 +625,11 @@ if __name__ == "__main__":
(HERE / "outlined-krav.pdf").write_bytes(build_outlined_pdf(OUTLINED_CONTENTS, OUTLINED_TREE))
print("wrote outlined-krav.pdf")
(HERE / "outline-collision.pdf").write_bytes(
build_outlined_pdf(COLLISION_CONTENTS, COLLISION_TREE)
)
print("wrote outline-collision.pdf")
(HERE / "outline-broken-dest.pdf").write_bytes(
build_outlined_pdf(BROKEN_DEST_CONTENT, (("1 Grunnlag", 1, 0, 185),), broken_dest=True)
)