pdftract/notes/bf-677eo.md
jedarden e3c6c34760 feat(bf-3wkpz): implement timeout-protected stdout/stderr capture for benchmark
- Add READ_TIMEOUT (5 min) and MAX_OUTPUT_SIZE (100 MB) constants
- Implement read_pipe_with_timeout() with watchdog thread protection
- Update execute_grep_command() to capture and return both streams
- Prevents TH-03 hang scenario by bounding both time and memory

Acceptance criteria:
✓ Stdout captured completely
✓ Stderr captured completely
✓ Output buffered without truncation (100 MB limit)
✓ Read operations have timeout protection (5 min timeout)
✓ Both streams captured even if one is empty

Verification: notes/bf-3wkpz.md
2026-07-06 16:36:22 -04:00

72 lines
3.1 KiB
Markdown

# Verification Note for bf-677eo
## Task: Run pdftract CLI on degraded fixture
### Date: 2026-07-06
### What was attempted:
1. **Located the degraded fixture**: `/home/coding/pdftract/tests/fixtures/scanned/low-quality/degraded-200dpi.pdf` (588KB PDF file)
2. **Verified CLI availability**: Found pdftract executables at:
- `/home/coding/pdftract/target/debug/pdftract`
- `/home/coding/pdftract/target/release/pdftract`
3. **Tested CLI help command**: `pdftract extract --help` works correctly
4. **Attempted extraction without OCR**:
```bash
pdftract extract --text /tmp/degraded-200dpi-text.txt --json /tmp/degraded-200dpi.json \
tests/fixtures/scanned/low-quality/degraded-200dpi.pdf
```
**Result**: `Error: Failed to extract PDF` (exit code 1)
5. **Attempted extraction with OCR flag**:
```bash
pdftract extract --ocr --text /tmp/degraded-200dpi-text.txt \
tests/fixtures/scanned/low-quality/degraded-200dpi.pdf
```
**Result**: `Error: --ocr requires the 'ocr' feature to be enabled`
6. **Attempted to build with OCR feature**:
```bash
cargo build --release --bin pdftract --features ocr
```
**Result**: Build failed - requires system library `leptonica` (pkg-config package `lept` not found)
### Acceptance Criteria Status:
| Criterion | Status | Notes |
|-----------|--------|-------|
| pdftract CLI executes without errors | ❌ FAIL | CLI help works, but extraction fails on degraded fixture |
| Command completes successfully | ❌ FAIL | `Error: Failed to extract PDF` even without OCR |
| OCR process runs on the fixture file | ❌ FAIL | OCR feature not compiled in; building requires leptonica system library |
### Root Causes:
1. **OCR feature not enabled**: The current pdftract build was compiled without the `--features ocr` flag
2. **Missing system dependencies**: Building with OCR requires the `leptonica` library (pkg-config `lept`), which is not installed on this system
3. **Extraction failure without OCR**: The degraded PDF appears to be a scanned image-only PDF that cannot be extracted without OCR
### Existing Workarounds:
The fixture directory already contains OCR output generated by other means:
- `degraded-200dpi-ocr.txt` - OCR output text (with typical OCR errors like "Y ork" vs "York")
- `degraded-200dpi-ground-truth.txt` - Source text for comparison
- `create_degraded_200dpi.py` - Python script used to create the degraded fixture
### Recommendations:
To enable OCR-based extraction on this fixture, one of the following is needed:
1. Install leptonica system library (e.g., `apt-get install libleptonica-dev`)
2. Rebuild pdftract with `--features ocr`
3. Use external OCR tools (e.g., tesseract) directly on the PDF
### Files Referenced:
- Fixture: `/home/coding/pdftract/tests/fixtures/scanned/low-quality/degraded-200dpi.pdf`
- Ground truth: `tests/fixtures/scanned/low-quality/degraded-200dpi-ground-truth.txt`
- OCR output: `tests/fixtures/scanned/low-quality/degraded-200dpi-ocr.txt`
### Verification: ❌ BLOCKED
The task cannot be completed successfully due to missing OCR dependencies. The CLI can be invoked, but extraction fails on the degraded fixture.