# 参与 moonmo

## 获取工作副本

```sh
git clone https://github.com/LP-XXX/moonmo.git
cd moonmo
moon version --all
```

复核尚未推送的本地提交时，在原仓库根目录执行 `git clone . ../moonmo-check`，然后进入该副本。开发需要 MoonBit 和可用的 Native C 工具链。第一次解析工作区依赖需要访问 MoonBit 注册表或使用已有缓存。实时差分脚本使用 Python 3 标准库。仅重新编译 PO 时需要 GNU msgfmt，性能脚本另用 psutil。

## 构建与测试

在仓库根目录执行以下命令。三种后端运行相同的核心测试、示例测试和入库黄金断言。

```sh
moon test --target native
moon test --target wasm
moon test --target wasm-gc
moon check --deny-warn
moon fmt --check
```

## 复现差分结果

```sh
python scripts/plural_samples.py --check
python scripts/oracle_diff.py --check --target native --target wasm --target wasm-gc
python scripts/compare_targets.py
python scripts/fuzz_catalogs.py --seed 20261203 --catalogs 3000
python scripts/mutate_fixtures.py --per-fixture 2048
```

第一条核对复数槽位。第二条将实际 MO 查询与 Python 结果、SPEC 的严格策略行和入库黄金数据核对。第三条比较 Native 与 wasm-gc 完整输出的字节。最后两条使用同一批输入验证三个后端。[语料定义与结果](docs/oracle-diff.md)

修改 PO 或规则采样后，按顺序运行 `python scripts/build_fixtures.py`、`python scripts/plural_samples.py`、`python scripts/oracle_diff.py`，检查生成的 MO、槽位断言和黄金数据的 diff，再执行上述验证。GNU msgfmt 未在 PATH 中时，可在第一条命令后加 `--msgfmt PATH`。[夹具来源与布局](https://github.com/LP-XXX/moonmo/blob/main/fixtures/README.md)

## 提交改动

每次提交围绕一个可独立验证的改动。标题沿用仓库的 `类型: 简短说明`，例如 `test: check plural slots at one million`。有明确轮次的任务在末尾附上该轮标记，例如 `(polish4)`。提交说明可写明复现命令、覆盖目标和结果。涉及公共 API 或目录语义时，先核对冻结规格及对应测试。[SPEC v1.1](SPEC.md)
