## TL;DR
Solid black redaction boxes get OCR'd into garbage characters, and the agent quoted the garbage as if it were clause text. Detect the redaction regions (PDF redaction annotations or solid dark rectangles), mask them before OCR, and add a post-filter that drops blocks with a high junk-character ratio. Redacted content must never enter the extraction at all.

## The symptom
```text
redaction boxes OCR'd as black-bar junk  -  the agent treated the redacted blocks as clause text and quoted them
```

## Steps
### 1. Detect the redaction regions
Check the PDF for redaction annotations directly. On flat scans, find solid dark rectangles: connected components that are large, rectangular, and near-black. Mark each as a redaction zone.
Expected: A list of bounding boxes covering the black bars, separate from text regions.

### 2. Mask the zones before OCR
Paint the redaction zones white (or exclude them from the OCR input) before running the engine. The engine should never see the black bars.
Expected: OCR output contains no junk-character runs where the bars were.

### 3. Post-filter any surviving junk blocks
For text blocks that remain, compute the ratio of non-alphanumeric characters. Blocks that are mostly symbols, box-drawing characters, or single repeated glyphs get dropped as redaction residue.
Expected: No block with a junk ratio above the threshold survives into the extraction.

### 4. Guard the quoting step
Add a rule: quoted clause text must be valid natural language. If a candidate quote fails a basic language check, reject it and flag the region for human review.
Expected: The agent never quotes redaction residue as a term again.

## When to use
- Extracted clauses contain runs of garbage or box characters
- The source document has visible black redaction bars
- The agent quoted something that is clearly not real text

## When not to use
- The document has no redactions (the junk comes from a bad scan, different fix)
- Redactions are done properly at the PDF layer and extract as nothing (already correct)
- The text is hard to read but real (that is a quality problem, not redaction)

## Why it happens
OCR engines try to read everything, including solid black rectangles. A black bar becomes a run of misrecognized glyphs, and downstream the agent cannot tell garbage from a clause it has not seen before. Redaction info is also a privacy boundary: redacted content should never be processed as text, quoted or otherwise.

## Edge cases
- Partial redactions (single words blacked out): mask at the word level so surrounding text still extracts.
- Redaction annotations vs burned-in bars: annotations can be read structurally; burned-in bars need image analysis.
- White-on-white or label redactions ('REDACTED' text): detect the label pattern instead of dark rectangles.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_MLe6byR2cFxoi4Ea0WYz-w
