Skip to content

OCR Batch Review Browser Local PostgreSQL Proof

Status: passed on 2026-07-15 against an isolated local PostgreSQL runtime and non-default Gateway table. This is not default-route, production, billable Mistral-provider quality, or provider latency evidence.

Scope

The harness starts Teacher Web, IAM, document-service, docx-import-service, question-bank-service, a Gateway, and separate iam, document, docx_import, and question_bank PostgreSQL databases under a temporary directory. It uses a generated local PDF and a deterministic Mistral-compatible batch server. It does not read or write legacy source, shared databases, default Gateway routes, or public provider accounts.

Teacher Web is opened with the explicit candidate gates teacherExamUtilityGateway=native and teacherExamUtilityOCRMode=mistral-batch. The UI uploads the source through document-service, sends ocrMode=mistral-batch through Gateway, then opens the existing review editor after completion. The harness deliberately reprocesses the job as its owner before browser review save and reload.

Evidence

bash
OCR_REVIEW_BROWSER_LOCAL_POSTGRES_CONFIRM=local-postgres \
make test-ocr-batch-review-browser-local-postgres

Latest artifact root:

text
output/qa/ocr-review-browser-local-postgres-batch-20260715114016/

The current run created docxjob-912676383e38d72ffc718313 and Question Bank row q_0e926ee30dd19a80aefe0afe24be28e8. browser-create/ records the candidate UI, owner-source upload, native OCR create payload with the batch mode, completed detail, and editor link. browser-review/ records the review request, native save response, persisted packagingJson.review.savedAt and edited parseResultJson after reload, and rendered editor.

mistral/requests.jsonl records 12 provider-contract calls over two runs (initial create and owner reprocess): two OCR source uploads, two source signed URL reads, two JSONL input uploads, two /v1/batch/jobs submissions with endpoint=/v1/ocr, two status polls, and two output-file reads. The persisted row has parser_engine=mistral-ocr-batch, an opaque source_media_asset_id, an empty source_storage_key, a reviewer id, and COMPLETED status.

After browser save/reload, the owner approves through candidate exam-import-approval and reads /api/questions/{id}?view=editor through candidate questions-detail. The retained headers prove both Gateway routes. The Question Bank read-back has SINGLE_CHOICE, the browser-edited stem, correct option B, <p>Chọn B.</p>, a canonical answer key, and scoringRuleJson.maxScore=0.75.

Boundaries

The candidate table is copied from deploy/gateway/routes.import-ocr-mathtype-native-localhost-example.json with only temporary runtime ports rewritten. Broad /api/exam-import remains legacy_proxy in deploy/gateway/routes.json.

The same harness verifies that a second teacher in the organization receives 404 for the first teacher's job detail, status, event log, review, approval, and reprocess routes. It also verifies raw storageKey OCR creation fails with OCR_SOURCE_REQUIRED; the browser can supply only the opaque owner source id.

Limits

  • The local batch server is deterministic. This proves request sequencing, source ownership, durable review persistence, and candidate Gateway routing, not Mistral's real recognition quality, availability, cost, or latency.
  • The persisted Question Bank row is proof for this disposable local runtime only. It does not establish deployment, default-route, shared-database, or public-provider behavior.
  • OCR still has no native Word or Markdown artifact-download parity claim.
  • No default-route or production rollout was performed. Rollback remains GATEWAY_ROUTE_TABLE=deploy/gateway/routes.json.
bash
make test-import-pdf-ocr-workflow
make test-import-ocr-mathtype-routes
OCR_BROWSER_MODE=mistral-batch OCR_BROWSER_SELF_TEST=1 make test-ocr-browser
GOTOOLCHAIN=go1.25.11 go test ./services/docx-import-service/internal/http -count=1

Go-platform documentation is generated from repository Markdown.