Objective
Deliver the production-grade, reusable OCR execution path behind the existing provider-neutral API: authoritative immutable source binding, digital-PDF text extraction, bounded Rust preprocessing/local inference, confidence-based managed OCR fallback, normalized evidence output, deterministic validation, and durable Temporal orchestration.
Architecture decisions
- Rust/Axum remains the public API and job-control boundary.
- CNPG is authoritative for identity, workflow checkpoints, idempotency, outbox and audit metadata; GCS retains immutable documents/page artifacts/results; Valkey is a tenant-scoped non-authoritative cache/admission layer; Qdrant contains rebuildable derived memory only.
- Before image OCR, the parser extracts embedded text from eligible digital PDFs with source coordinates and provenance. Pages requiring raster OCR follow bounded decode, quality assessment, orientation/geometry correction and local signed-model inference.
- A managed Document AI provider is a policy-controlled fallback for low-confidence, handwriting, unsupported-script or complex-layout pages only. It is never invoked with caller-controlled provider URLs/credentials and is subject to residency, health, cost and tenant policy.
- A dedicated Temporal namespace named
document-intelligence-<environment> is mandatory. Workflow histories and inputs remain identifiers-only; source bytes, OCR text, signed URLs and secrets never enter Temporal.
- Model runtime stays provider/model-neutral and Rust-native. No third-party OCR source/runtime is copied or named in repository artifacts. Model artifacts must be legally approved, signed, digest-pinned and benchmark-promoted before use.
Delivery slices
Acceptance evidence
A disposable sandbox document must complete upload inspection, immutable promotion, parser/text extraction or rasterization, recognition/fallback, evidence/result artifact, validation and redacted trace. Required adversarial coverage: cross-tenant source substitution, stale object generation, decompression/pixel limits, invalid model output, malformed provider response and prompt-injection text. Promotion requires agreed CER/WER, critical-field, latency, memory, cost and safety thresholds.
Explicit non-goals
This issue does not select model weights, create/rotate secrets, alter production Temporal namespaces, or authorize a production rollout. Those actions remain separately reviewed and gated.
Objective
Deliver the production-grade, reusable OCR execution path behind the existing provider-neutral API: authoritative immutable source binding, digital-PDF text extraction, bounded Rust preprocessing/local inference, confidence-based managed OCR fallback, normalized evidence output, deterministic validation, and durable Temporal orchestration.
Architecture decisions
document-intelligence-<environment>is mandatory. Workflow histories and inputs remain identifiers-only; source bytes, OCR text, signed URLs and secrets never enter Temporal.Delivery slices
Acceptance evidence
A disposable sandbox document must complete upload inspection, immutable promotion, parser/text extraction or rasterization, recognition/fallback, evidence/result artifact, validation and redacted trace. Required adversarial coverage: cross-tenant source substitution, stale object generation, decompression/pixel limits, invalid model output, malformed provider response and prompt-injection text. Promotion requires agreed CER/WER, critical-field, latency, memory, cost and safety thresholds.
Explicit non-goals
This issue does not select model weights, create/rotate secrets, alter production Temporal namespaces, or authorize a production rollout. Those actions remain separately reviewed and gated.