# AI answer snapshot diff tool

This dependency-free Python utility compares two dated, **synthetic** answer snapshots. It joins records on the stable key `prompt_id` + `engine`, then emits row-level changes for availability, brand mention, recommendation label, rank, citation-domain additions/removals, and missing or new prompt-engine records. It does not call an AI provider, fetch citations, or claim live engine behavior.

Run the exact byte-match contract from this directory:

```sh
python3 diff_answers.py before.json after.json > generated-diff.csv
cmp --silent generated-diff.csv expected-diff.csv
```

Exit code `0` means the generated bytes—including order and line endings—match the checked-in expected output. The fixtures are deliberately small so every row can be reviewed. `null` ranks and empty citation arrays are meaningful values, not missing test data: an unavailable answer has no measured rank or citation domains.

The tool reports differences, not causes. A changed recommendation label may reflect coding policy, retrieval, model routing, or an actual answer change. Preserve the raw snapshots, collection timestamps, visible model/settings, locale, and provenance beside any production export. A prompt-set gap means a record exists in only one snapshot; do not silently convert it into a zero.
