A Broken Bookmark Chain Vanished in the Merge: pypdf Dropped the Orphan Row, and the 404-Shaped /First Did Too — After Both Breaks Were Proven on Disk

The numbers that define today's run: both break shapes persisted on disk, both merged files read back with the broken row silently gone, and no page_match entry was repaired. Day 39 showed that a bookmark /Next cycle is untied harmlessly by pypdf's merge. Today we asked the harder question: what does a actually broken outline — a child cut off from its parent chain, and a parent whose /First points at an object that does not exist — do in the same merge? Both break shapes were injected into source A's outline, and following this run's method, each saved source was read back before merging to prove the break had persisted: the cut chain showed NullObject where the child pointer used to be, and the dangling /First made pypdf's raw read-back log "Object 9999 0 not defined." — hard evidence the break was on disk, not just in memory. Only then was each merged. In both cases the merged file read back 3 of 4 rows at their offset-predicted pages, and the orphaned row was simply gone — no error, no warning in the own-result table, just a missing child.

The two break shapes (written first, run second)

Source A carries 3 pages and 2 rows: A Doc Chapter (depth 1, page 1) and A Doc Section (depth 2, page 2). Two breaks were injected:

loop-1 (chain-break): A Doc Chapter/First+Last -> NULL — the section is cut from its parent chain, unreachable on a normal walk

loop-2 (dangling-first): A Doc Chapter/First -> IndirectObject(9999, 0) — the parent points at a nonexistent object

Source B is the clean 3-page/2-row file, so the offset formula puts B at +3.

A+cyclic / B+clean, read back step by step — loop-1 (chain-break)

Merged outline rowdepthpageexpected (offset)text matchpage_match
A Doc Chapter111yestrue
B Doc Chapter144yestrue
B Doc Section255yestrue

The row that disappeared:

titleexpected depthexpected pagereason
A Doc Section22bookmark missing in merged outline (parent chain broken)

Persistence proof (read back from the saved broken source before merging):

chapter /Firstchapter /Lastprobe warningsconclusion
NullObjectNullObject—yes — broken state proven on disk

A+broken / B+clean, read back step by step — loop-2 (dangling-first)

Merged outline rowdepthpageexpected (offset)text matchpage_match
A Doc Chapter111yestrue
B Doc Chapter144yestrue
B Doc Section255yestrue

The row that disappeared:

titleexpected depthexpected pagereason
A Doc Section22bookmark missing in merged outline (parent chain broken)

Persistence proof:

chapter /Firstchapter /Lastprobe warningsconclusion
None—Object 9999 0 not defined. · Overwriting cache for 0 9999yes — broken state proven on disk

What this changes about the "outline survived" question

Day 39's cycle test answered: a loop, yes, untied harmlessly. Today's test answers the other half: a broken parent chain is not untied, it is pruned — silently. The merged file has one less row than either source put in, and the merged row count alone does not tell you which source it came from unless the clean-source benchmark is compared beforehand, and the readback is compared per-row against it. This is the first shape in the run method where a check table that only asks "do the rows that exist match" can report all true while an entire branch of the outline has evaporated — the all_pages_match field MUST include the missing-row scan, and today's broken_parent_links field is that scan, reported empty never.

Both break shapes: the broken state survived to disk (proven by raw probe), the merge pruned the orphan row silently, and the bench-comparison caught the disappearance.
A · broken chain (proven on disk) A Doc Section — orphaned / dangling B · clean, offset +3 Merged read-back (both shapes): A Doc Chapter d1 p1 ✓ · B Doc Chapter d1 p4 ✓ · B Doc Section d2 p5 ✓ A Doc Section: not in the tree — pruned by the merge, silently page_match stays true on every surviving row; the truth lives in the missing-row scan

Quick FAQ

Does a broken bookmark chain survive a pypdf merge?

In our run, no — the orphan row is pruned and the merged file is short one row, with no error or warning surfaced through the API. The detectable evidence is the row-count mismatch against the clean-source benchmark, which is why a full missing-row scan precedes any page_match verdict.

Is a silent pruned row a false pass?

Not on this page — because the missing-row scan ran first. But it is exactly the shape of a false pass on a weaker bench: if today's table had only asked "do the rows that exist match," it would have read true while an entire branch was gone.

What about level-3 breaks, or breaks in the clean source instead?

Not run. The two shapes above are exactly what was executed; the rest stays on the not-run list.

What we could NOT test — the list stays honest

- Breaks injected into a level-3 row, or into nested children beyond depth 2 — not run. Reason: today's bench shapes breaks at depth 1–2 only.

- A break in source B instead of A, so the pruned row sits on the +3 side — not run. Reason: both loops put the break in A, offset 0, on purpose.

- Breaks caused by the merge step itself (both sources' outlines referencing shared objects) — not run. Reason: today's breaks are injected into one source before the merge.

- Tools other than pypdf append — not run.

Decision rule this run supports

- The orphan row of a broken outline is pruned by pypdf's merge, not preserved — treat "outline survived" as a count question first, then a per-row page question.

- A broken state, proven to be on disk beforehand, still vanishes in the merge — proof-of-persistence and result-verification are separate steps, each required.

- If all_pages_match comes back true on a merge, the next question is "compared against what row set": the count of surviving members minus those in the benchmark, checked as missing, and only then true.

This page pays the "broken outline" promise left on the nested-merge run, using the same depth-stack method as the day-36/37 nesting work and the same proof-of-persistence discipline first run on the cycle page. Bookmark pdf2mdtool.com — the level-3-chain and merge-caused-break shapes stay queued.