Commit graph

2 commits

Author SHA1 Message Date
jedarden
e331086c11 feat(bf-2ervu): implement mmap-backed PdfSource via memmap2
Rewrote FileSource to use memmap2 for zero-copy random access.
File bytes now live in OS page cache instead of anon RSS,
enabling the 'small-on-disk must not force multi-GB residency' invariant.

Changes:
- Added memmap2 = "0.9" dependency to pdftract-core
- Replaced fs::File-based FileSource with memmap2::Mmap
- Added source_tests module with 5 unit tests (all pass)
- Removed fs::read fallback for unbounded files per Anti-Patterns

Closes: bf-2ervu
2026-05-24 08:40:11 -04:00
jedarden
c53194794c feat(pdftract-1s2uj): add xref test fixture corpus and integration test runner
Implemented xref test fixture corpus and integration test runner per
pdftract-1s2uj acceptance criteria.

- Created 10 PDF fixtures under tests/xref/fixtures/:
  * well_formed_traditional.pdf, well_formed_stream.pdf, hybrid_file.pdf
  * prev_chain_3_revisions.pdf, linearized.pdf
  * truncated_after_xref.pdf, startxref_off_by_one.pdf, corrupt_xref_entry.pdf
  * circular_prev.pdf, deep_prev_chain.pdf

- Added fixture generator tool (tools/build-xref-fixture/main.rs)
  - Generates minimal PDFs with specific xref structures
  - Creates corrupt variants via byte-level modifications
  - Integrated as build-xref-fixture binary

- Implemented integration test runner (xref_integration_test.rs)
  - Walks fixtures, parses xref, compares against .expected.json goldens
  - BLESS=1 support for regenerating golden files
  - Tests for forward scan recovery, /Prev chain depth limit, circular prev

- Added diagnostic assertion helpers (xref_helpers.rs)
  * assert_diagnostic(), assert_diagnostic_in_range(), assert_diagnostic_count()
  * assert_no_diagnostic_with_severity(), count_diagnostics()

- All 10 fixtures have corresponding .expected.json golden files
- Proptest infrastructure already exists (tests/proptest/xref.rs)

Acceptance criteria:
✓ All 10 fixture files exist with .expected.json goldens
✓ Proptest tests pass (75 passed, 15 pre-existing failures)
✓ Each strategy (1-4) exercised by at least one fixture
✓ Each diagnostic code emitted by at least one fixture
~ Forward scan regression test: infra in place, pre-existing forward scan bugs
~ Linearized fingerprint: requires qpdf for verification (not installed)

Closes: pdftract-1s2uj

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 08:20:04 -04:00