omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / docs / estimation / RECEIPT_JSON.md
| 1 | # Estimation receipt JSON rules (est-json-1) |
| 2 | |
| 3 | Status: applies to receipts written by `est5`, `est4`, `est3c_eval` and `est_eval` from this |
| 4 | change on. Receipts already committed are never rewritten (a receipt is named by the SHA-256 of |
| 5 | its bytes). No protocol, parameter, data, threshold or verdict rule changes here. |
| 6 | |
| 7 | ## The defect this fixes |
| 8 | |
| 9 | `receipts/est-v5/receipt-7f0bb701...json` is byte-exact to its digest but is not strict JSON |
| 10 | (RFC 8259): `"hi": inf` for the unbounded `n_scored` threshold (3 times) and |
| 11 | `"ten_log_score": nan` for the F1 and E0 baselines, which have no ten-step score (2 times). |
| 12 | Cause: `js_stats` in `tools/estimation/est5.c` printed doubles with `%.17g`, which writes `inf` |
| 13 | and `nan`. `est4.c` (v4) and `est3c_eval.c` (v3) carried the same function; `est_eval.c` printed |
| 14 | several statistics with `%.17g` and no finite check. The same function also wrote a non-finite |
| 15 | statistic value as the finite number `-1.0`. |
| 16 | Strict parsers reject the file. `jq` 1.7 does not (it reads `inf` as 1.797e308 and `nan` as |
| 17 | `null`), so `jq` is not a validator for these receipts; `test_est_json --validate FILE` is. |
| 18 | |
| 19 | ## Rules |
| 20 | |
| 21 | 1. A receipt never contains `inf`, `-inf` or `nan`. Finite measured values stay finite numbers |
| 22 | (`%.17g`, unchanged). |
| 23 | 2. Unbounded threshold: `"lo"` / `"hi"` is `null` and `"lo_unbounded"` / `"hi_unbounded"` is |
| 24 | `true`. Bounded thresholds keep their number and `false`. A NaN threshold is not unbounded: |
| 25 | it is invalid (rule 4). |
| 26 | 3. Unavailable measurement: a baseline (F1, E0) has no ten-step log score. `"ten_log_score"` is |
| 27 | `null` and `"ten_log_score_status"` is `"unavailable"`. A measured ten-step score is a number |
| 28 | with status `"ok"`. v3 receipts have no ten-step field. |
| 29 | A gated statistic with too few steps (regime idle / in-trial) that cannot be computed is |
| 30 | `"value": null` with `"value_status": "unmeasured"`. Finite values have `"value_status": "ok"`. |
| 31 | 4. Unexpected non-finite measured value (mean log score, width80 mean or median, the selected |
| 32 | family's ten-step score, a gated statistic value, a NaN threshold) is written as `null`, its |
| 33 | name is listed in the block's `"invalid_fields"`, a statistic value gets |
| 34 | `"value_status": "invalid"`, and the top level carries `"invalid_measurements": N`. |
| 35 | The scoring decision fails closed: `N > 0` forces the verdict to `HELD_OUT_FAIL` (v3: `FAIL`) |
| 36 | with reason `non-finite measured value (marked invalid in the receipt)`. It can never pass. |
| 37 | The gate itself already failed such a statistic (`band()` in `est3c_common.c` passes only |
| 38 | finite values). For `est_eval.c` a non-finite number is written as `null` and its `ok_*` gate |
| 39 | comparisons are false for NaN, so it fails there too. |
| 40 | 5. New receipts carry `"json_rules": "est-json-1"` (est4, est5, est3c_eval). |
| 41 | 6. Naming is unchanged: `receipt-<sha256 of the receipt bytes>.json`, written once, never |
| 42 | overwritten. |
| 43 | |
| 44 | ## Code |
| 45 | |
| 46 | `c3_json_num`, `c3_json_stats`, `c3_stats_invalid` in `tools/estimation/est3c_common.c` (used by |
| 47 | est3c_eval, est4, est5); `N17` in `tools/estimation/est_eval.c`. |
| 48 | Tests: `make test-est-json` (unit checks, strict validator, plain and ASan/UBSan) and |
| 49 | `make test-est5-tools` (strict parse of the synthetic and the binding-path receipts). |