# coa-photo-check

version 1.0 · 2026-09-25 · MIT · from Distru's No Bullshit AI Course (module 05, lesson 7).

Read a COA from a photo with a vision-capable AI, then check what it read with plain code before anyone uses it.

## Files

- `prompt.md`: the prompt to paste with the photo. It lets the AI say UNREADABLE instead of guessing.
- `check.py`: checks the AI's output: every field present and readable, total THC adds up, label matches COA. Standard library only.
- `samples/`: a made-up COA as a clean photo and a blurry one with glare, the real outputs Claude Sonnet 5 gave for each, and a label to compare against.

## Run

```
python3 check.py --self-test
python3 check.py samples/extracted-clean.json samples/label.json        # no flags
python3 check.py samples/extracted-bad-careful.json samples/label.json  # flags the unreadable fields
python3 check.py samples/extracted-bad-naive.json samples/label.json    # flags the misread numbers
```

## What the samples show

We sent both photos to Claude Sonnet 5 (via OpenRouter, about half a cent a photo), with and without the "use UNREADABLE, never guess" instruction:

| | Clean photo | Blurry photo, naive prompt | Blurry photo, careful prompt |
|---|---|---|---|
| THCa | 24.81 % ✓ | 24.91 ✗ | UNREADABLE |
| Total THC | 22.63 % ✓ | 22.53 ✗ | UNREADABLE |
| Total CBD | 0.05 % ✓ | 0.41 ✗ (that is the CBG line) | UNREADABLE |
| Report date | 09/16/2026 ✓ | 09/16/2025 ✗ | 09/16/2026 ✓ |

The naive answer looks perfectly reasonable. `check.py` catches it anyway, because 0.87 + 0.877 × 24.91 is 22.72, not 22.53.

## Before you use it on real COAs

- **The best COA is not a photo.** If the lab sends a PDF, a portal link or a QR code, or the results are in your seed-to-sale system, use that. A photo is the fallback.
- **It reads; it does not verify.** A clean photo of a forged or wrong-batch COA reads perfectly. Check the batch against your inventory and the lab against your approved list.
- **A person decides.** Anything flagged, and anything going onto a label or into Metrc, gets human eyes.
- **Check your state's total THC rule.** The 0.877 conversion is standard, but confirm how your state requires total THC to be calculated and reported.
