# GNUTranslations differential report

Run `python scripts/oracle_diff.py --check` from the checkout. The default checks native and wasm-gc; add `--target wasm` to check plain Wasm separately. Without `--check`, the script regenerates [golden.json](https://github.com/LP-XXX/moonmo/blob/main/fixtures/oracle/golden.json). The MoonBit test also checks the committed values with no Python process.

Local sample (Windows x64, Python 3.13.5):

```text
140 fixtures, 17612 Oracle rows, 34 SPEC policy rows
native: 17646 rows, 0 diffs
wasm: 17646 rows, 0 diffs
wasm-gc: 17646 rows, 0 diffs
ORACLE DIFF: PASS (0 diffs)
```

The input set contains 108 GNU msgfmt catalogs (36 PO files for 29 languages, each in three layouts), two explicit-empty synthetic catalogs, and 30 defensive fixtures. The common rows exercise load success, the four lookup APIs, raw and structured metadata, missing keys, and empty translations. The original SPEC §6.1 counts remain in place. The first six additions each cover 27 boundary counts. The eight cat PO files each cover 44 counts, contributing 4,560 new Oracle rows across three layouts. The eight book catalogs add another 4,560 rows (570 per language), with 44 counts each including all plural slots. The nine day catalogs add 5,538 Python rows per target. Five cover 44 counts each, es/it/pt cover 47 each and br covers 69. All four million-sensitive rules exercise 999,999, 1,000,000 and 1,000,001. [Fixture and rule provenance](https://github.com/LP-XXX/moonmo/blob/main/fixtures/README.md) Every runtime result is computed from the MO bytes. The checker regenerates Python's answers in memory and compares the ordered rows against both the committed golden file and each target's output.

The 34 policy rows cover 26 load-time rejections plus two checked queries for each of four query-time error fixtures. For these rows, `python` records the observed GNUTranslations outcome and `value` records the required moonmo outcome. For example, Python loads the unsorted catalog, while moonmo must reject it. The missing-form checked query must report `PluralFormOutOfRange`; Python's convenience lookup returns the source plural. The [malformed fixture tests](https://github.com/LP-XXX/moonmo/blob/main/fixtures/malformed/malformed_test.mbt) verify the precise error variants and fields.

## Native and wasm-gc byte comparison

Run `python scripts/compare_targets.py`. Each backend writes its own UTF-8 JSON file from the same ordered queries. The script compares the raw files before decoding and reports the first differing byte offset or a length mismatch. The native CI job runs this gate after its Oracle check.

```text
NATIVE == WASM: PASS (0 diffs), 17646 rows, 1751652 bytes
SHA-256 4dcb91f4178e72e420c9ee078f8de44345a73aab85ef45d49bbe149f706ec64d
```

## Seeded catalogs and byte mutations

From the checkout, run both scripts with Python 3 and Moon on PATH. The defaults run native, wasm-gc and wasm. The archived runs used the fixture bytes at `fb030f6` and seed 20261203 on Windows x64 with Python 3.13.5.

```sh
python scripts/fuzz_catalogs.py --seed 20261203 --catalogs 3000
python scripts/mutate_fixtures.py --per-fixture 2048
```

| Corpus per target | Samples | Result on each of the three targets |
| --- | ---: | --- |
| Random revision-0 catalogs | 3,000 | 111,772 queries matched Python GNUTranslations |
| Random byte mutations, 32 per random catalog | 96,000 | 19,144 accepted and 76,856 typed rejections |
| Distinct mutations per fixture, 140 × 2,048 | 286,720 | 28,631 accepted and 258,089 typed rejections |

The valid random catalogs exercise both byte orders, metadata folding, Unicode, contexts, empty slots and missing keys. The round-4 stream adds 16 edits per catalog while preserving the first 2,000 catalogs and their 16 earlier edits. The fixture script deduplicates structural changes, truncations and scattered edits per original file. Mutation workers check accepted catalogs against their validated raw entries and compare every frame’s acceptance or concrete rejection diagnostic across targets. Both mutation batches finished with zero panics and identical outcome streams. Python supplies the reference for the valid random catalogs.
