---
name: document-ingest
description: Use when Deep Research starts from user-provided PDFs, scanned audit reports, DOCX/PPTX files, images, or internal notes that must become phase0 persisted inputs.
---

# Document Ingest

## Core Rule

User-provided materials are evidence leads, not final evidence. Always persist the original file, extracted text, OCR status, and limitations under `phase0/` before Phase 1 framing depends on them.

## Required Artifacts

- `phase0/inputs/<original-file>` stores the source file copy.
- `phase0/extracted/<stem>.md` stores direct text extraction plus OCR text when available.
- `phase0/extracted/<stem>.ocr.md` stores OCR-only output for scanned PDFs.
- `manifest.json.material_inventory[]` records `copied_to`, `extracted_to`, `ocr_required`, `ocr_status`, and OCR errors if any.

## PDF Handling

- Text PDFs should use direct extraction first.
- If direct extraction is too sparse, run FireRed OCR through the configured LAN endpoint.
- Default endpoint: `http://192.168.50.100:8001`.
- Override endpoint with `DEEP_RESEARCH_OCR_ENDPOINT`.
- Limit page count with `DEEP_RESEARCH_OCR_MAX_PAGES` when testing or when documents are very long.

## Current Boundary

PDF text extraction and scanned-PDF OCR are supported. DOCX, PPTX, image-only batches, table reconstruction, and layout-aware evidence mapping should remain explicit next-step work unless implemented in Python core.

## Quality Notes

- OCR text may contain spacing or line-break errors. Treat it as internal material evidence and verify formal findings against NMPA, FDA, EMA, ICH, WHO, or other authoritative sources.
- If OCR fails, do not block project initialization. Record the failure and continue Phase 1 with a clear limitation.
