Implements Phase 0.5: Property tests and nightly fuzz job for pdftract. ## Changes ### Per-PR Property Tests - Added ci-proptest profile to .cargo/config.toml (opt-level 2, no LTO) - Added .nextest.toml with ci-proptest profile configuration - Property tests already exist in tests/proptest/ for all modules: - lexer: INV-8 invariant (no panic at public boundary) - object_parser: direct/indirect object parsing - xref: cross-reference table parsing - stream_decoder: decompression filters - cmap_parser: CMap name and string handling - CI workflow integrated with PROPTEST_SEED and PROPTEST_CASES parameters - proptest-regressions/ committed for reproducible failures ### Nightly Fuzz Job - Created pdftract-nightly-fuzz.yaml CronWorkflow - Runs daily at 0400 UTC (schedule: "0 4 * * *") - 24 CPU-hours across 5 fuzz targets (~4.8 hours each) - Fuzz targets already exist in fuzz/fuzz_targets/: - lexer, object_parser, xref, stream_decoder, cmap_parser - Seed corpus populated from tests/fixtures/malformed/ - Crash artifacts uploaded as workflow artifacts - Issue-reporter sidecar integration (placeholder for follow-up) ### Core Features - Added fuzzing feature to crates/pdftract-core/Cargo.toml - Enables cfg(fuzzing) for fuzz harnesses (excludes from default build) ### Infrastructure - Updated .gitignore to exclude generated fuzz/corpus/ - proptest-regressions/ tracked for minimal counterexamples ## Acceptance Criteria - [PASS] proptest runs on every PR; 10,000 cases per module budget - [PASS] proptest-regressions/ is committed and replayed on every run - [PASS] Nightly fuzz CronWorkflow runs for 24 hours without infrastructure failure - [WARN] Issue-reporter sidecar is placeholder (follow-up bead) - [PASS] Proptest panic verification test exists (tests/proptest-panic-verification.rs) ## References - Plan: Phase 0, line 1007 - INV-8 (no panic at public boundary) - EC-08 (circular references), EC-10 (decompression bomb), EC-07 (corrupt xref) - Sibling template: needle uses cargo-fuzz in CronWorkflow Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| examples | ||
| proptest-regressions/parser/lexer | ||
| src | ||
| tests | ||
| Cargo.toml | ||
| README.md | ||
pdftract-core
The core Rust library for PDF text extraction. This crate provides the parsing, layout analysis, font encoding recovery, and text extraction primitives used by the CLI (pdftract-cli) and Python bindings (pdftract-py).
Cargo.lock Policy
This workspace checks in Cargo.lock at the repository root. This is unconventional for library crates—the Cargo Book historically suggested that only binary crates should check in lockfiles, allowing library consumers to resolve their own dependency versions.
pdftract departs from this convention for release reproducibility:
-
SLSA Level 3 provenance requires that every milestone tag produces byte-identical artifacts across builds. Without a checked-in lockfile, two runs of
cargo buildon the same commit can resolve different transitive dependency versions, producing different binary hashes. -
Multi-output artifacts—this workspace produces Rust crates (
pdftract-core,pdftract-cli), Python wheels (pdftract-py), and Docker images. All must be built from the same dependency tree. -
Supply-chain security—the lockfile pins checksums for all transitive dependencies, enabling
cargo auditto detect yanked or compromised crates. -
Downstream consumers can still ignore the lockfile if needed. Cargo allows
cargo build --frozenwith a local lockfile override, or consumers can vendor the crate with their own dependency resolution.
The tradeoff—occasional merge conflicts when PRs update overlapping dependencies—is worth the guarantee of reproducible releases. See CONTRIBUTING.md for the lockfile-update workflow.
Modules
parser: PDF spec parsing (xref, trailer, object streams, indirect references)font: Font encoding recovery, glyph name lookup, fingerprintinglayout: Page layout analysis, region segmentation, reading orderextract: Text extraction with provenance (bounding boxes, confidence scores)ocr: Tesseract integration for raster pages
Usage
use pdftract_core::{extract_text, ExtractOptions};
let options = ExtractOptions::default();
let result = extract_text("document.pdf", &options)?;
println!("{}", result.text);