# Validation plan

## Validation objective

Demonstrate that the application detects and physically removes annotated direct identifiers from representative documents while preserving clinically necessary content and refusing to release results when required capabilities or human review are incomplete.

## Test levels

### Unit tests

- Coordinate and box operations
- Text-span to page-region mapping
- Every regular/context rule
- Deduplication across native text and OCR
- Category action and severity policy
- Barcode region conversion
- Public-report exclusion of detected text

### Component tests

- PDF signature detection
- PDF rendering and native token extraction
- Image orientation and metadata removal
- Russian and English OCR availability
- Barcode detection for QR, Data Matrix, PDF417, and common one-dimensional codes
- Raster-only output creation
- Annotation/form/attachment/JavaScript checks

### End-to-end synthetic tests

- Generate a source PDF with synthetic identity data and sensitive metadata.
- Analyze it.
- Require all annotated categories to be found.
- Confirm pages in the test harness.
- Build a cleaned copy.
- Verify that the source hash is unchanged.
- Verify zero extractable output text and zero hidden objects.
- OCR the output and require no residual critical identifier finding.
- Render every output page and visually inspect it.

### Adversarial tests

- Invisible OCR text behind a scan
- White text on white background
- Rotated and skewed images
- Low contrast and compression artifacts
- Very small header/footer identifiers
- Repeated identifiers on multiple pages
- Identifier embedded in a barcode
- Identifier in metadata and filename
- Encrypted, malformed, oversized, and decompression-bomb inputs
- Right-to-left or mixed-script pages
- Handwriting and stamps

## Metrics

Report metrics per identifier category rather than one overall accuracy number:

- True positives
- False negatives
- False positives
- Recall
- Precision
- Documents with at least one miss
- Pages rejected for manual review
- Clinically meaningful fields incorrectly removed
- Median and worst-case processing time

Any missed direct identifier in the locked safety corpus blocks the next release until root cause, corrective action, and full regression re-run are complete.

## Human-factors validation

- Can a non-technical patient understand why a page is blocked?
- Can the patient notice a missed identifier?
- Can the patient add a mask precisely?
- Does changing a mask clearly invalidate page confirmation?
- Can the patient distinguish the source from the cleaned copy?
- Does the interface avoid implying legal certification or complete anonymity?

## Evidence bundle

Each release candidate must archive:

- Source commit identifier
- NPO NT copyright, `AGPL-3.0-only` licence, and exact binary/source mapping
- Dependency lock and software bill of materials
- OCR model names and SHA-256 hashes
- Test command and complete result
- Locked dataset manifest and split hashes
- Per-category metrics
- Rendered visual QA contact sheets
- Known limitations
- Reviewer names and approval records
- Verified source-download location and complete third-party licence bundle
