R.1 (backend half) of the staged review-screen plan (Phase 2). Every
transaction now carries source_page/source_bbox - purely additive, so
the frontend's upcoming pdf.js viewer can box the exact printed row a
flagged transaction came from.
Traced extraction_service.py first: the canonical transactions list for
a normal text PDF always comes from pdfplumber (table_extract.py);
Docling's own extract_transactions() only feeds the cross-check
confidence signal, never the returned data. So this only needed to
touch table_extract.py and raw_ocr_extract.py (the OCR pixel-position
fallback), zero changes to engine-selection/cross-check logic.
One shared helper, table_extract._line_bbox(), used by both files
(mirrors how raw_ocr_extract.py already reuses _classify_money/_REF_RE
rather than re-implementing them) instead of two separate
implementations that could drift apart. A new _union_bbox() grows a
transaction's box as narrative lines merge into it, both the trailing
direction (HSBC) and leading direction (RBC).
Docling's own OCR-table-structure path doesn't get a real bbox (a
synthetic row-index, not a pixel position) - those transactions get
source_bbox: null, a graceful no-highlight rather than an error.
Verified: measure.py run before/after, byte-identical pass rate and
field accuracy on all three fixtures. A real /api/process call against
both HSBC and RBC fixtures confirmed every existing field unchanged.
Then the check measure.py can't make at all: rendered both fixtures'
pages for real and drew the reported source_bbox on the actual page
image - every box landed on exactly the right printed row, including
HSBC's trailing-narrative merge correctly widening the box.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>