# Scanner rework status

Progress on the approved scanner/OCR rework. See ADR-007/008/009 in
[DECISIONS.md](DECISIONS.md) for the decisions behind these.

## Done (implemented, unit-tested, build green)

- **OCR eval harness** — `src/eval/`, `npm run eval`, gate in `npm test`. See
  [ocr-eval.md](ocr-eval.md).
- **C# input/capture sidecar** — `native/input-helper/`, `npm run helper:build`.
  Replaces the PowerShell helper on the same JSON protocol; PowerShell remains a
  fallback. Verified end-to-end (spawn, runtime, base64 capture).
- **Layout profiles + OCR preprocessing** — `src/lib/layoutProfile.ts` (pure
  geometry, 16:9 detection), `src/lib/ocrPreprocess.ts` (grayscale + Otsu
  binarize). main.ts crops via the profile and OCRs an upscaled + binarized copy.
- **Card-ready gating** — `src/lib/cardReadyGate.ts` replaces the fixed 280 ms
  settle with change+stability polling; robust to animation.
- **GOOD interop** — `src/lib/goodInterop.ts` (export + best-effort import for
  scanned records).
- **Rescan-merge** — `src/lib/artifactMerge.ts` collapses leveled re-scan
  duplicates by a level-independent identity.
- **Data staleness warning** — `src/lib/dataPackageStatus.ts`, surfaced in the
  Scanner Diagnose data-package line.
- **Lock detection (experimental)** — `src/lib/lockDetection.ts`, pure heuristic,
  not yet wired into capture.

## Remaining — needs the live environment or a UI pass

These cannot be finished/validated without Genshin running at the user's
resolution or without UI work best tested live:

1. **Calibrate IK-style fixed crop coordinates** (ADR-009). The layout module is
   the structure; the exact per-field fractions still come from a
   colour-detected/fallback detail rect. A reference 16:9 screenshot of the
   artifact screen lets us pin exact client-relative crop coordinates.
2. **Validate/tune OCR preprocessing** on real captures — confirm invert +
   threshold + upscale factor help (not hurt) actual Tesseract reads. The
   text-level eval harness cannot measure image preprocessing.
3. **Wire GOOD import** — file-picker IPC + merge imported records into the store
   (the conversion engine is done and tested).
4. **Wire live lock detection** — calibrate crop position/threshold against a
   reference screenshot, then populate a `locked` flag during capture.

## Grow the eval corpus

Every low-confidence review sample already stores its crops + OCR. Confirm/correct
those via `reviewSampleToEvalCase` and commit them into `src/eval/corpus/` so the
harness keeps measuring real-world accuracy across patches. See
[ocr-eval.md](ocr-eval.md).
