# Independent numeric verification

Full verification runs 640 numerical checks in each debug/release mode.
This suite is separate from the logical work-budget model. It checks the
actual CLI, including bounded JSON input and public to_number evaluation.

The fixed corpus has 64 decimal families, four equivalent valid forms per
family (256 texts), and 64 invalid texts. Each text exercises both a string
conversion and raw JSON input. Seed: `0x4e554d31`; corpus SHA-256:
`9990622b1c840e5f111fd783344185d38bc40ca850ffd071fa660fe0fb0c11c8`.

## Independent expectations

JavaScript JSON.parse validates numeric grammar and Number supplies a
binary64 conversion independent of the MoonBit normalizer. BigInt-derived
decimal coefficients give exact midpoint and adjacent values near one,
the smallest subnormal/normal values and overflow. Explicit golden values
check ties-to-even predictions before the corpus runs. Seeded coefficients
add other exponent/significand combinations.

Equivalent forms move the decimal point or add zeros while adjusting the
exponent. Every form must agree with its family and the host oracle.
The corpus includes 1,023/1,024/1,025-unit thresholds, long exponent
cancellation and the earlier 65,237-unit overflow regression. All significant
digits are retained. Finite results compare exactly as binary64 values;
the two zero signs are treated as the same JSON value. Non-finite results
must report invalid_value.

A raw request inserts the original numeric token directly into the batch
data field. Parsing and serializing it in the controller first would lose
the long representation and invalidate that check. Malformed raw texts
run separately and must exit 2, print no result and report invalid_json.
The same text passed as a JSON string must convert to null.

The CLI accepts an optional leading UTF-8 BOM as a transport feature.
A leading BOM is therefore not an invalid raw-input example; an internal
BOM remains invalid JSON. String conversion does not remove a BOM inside
its value. Existing CLI integration tests cover the leading transport BOM.

## Bounds, results and failure evidence

The corpus contains 1,861,278 bytes of source text and its longest text has
100,013 UTF-16 units. Generation rejects more than 4 MiB of corpus text or
a text exceeding 200,000 units. Each batch has at most 64 modeled requests,
two recovery neighbors and at most 1 MiB of UTF-8 input. Children have
a 15-second timeout, a 192 MiB Node old-space limit and bounded output.
These test-process settings are not universal production memory guarantees.

Each mode checks 392 finite nonzero results, 80 zero results, 40 non-finite
errors, 64 converted nulls and 64 invalid raw documents. Nine batches
also verify 18 before/after neighbors. Reports bind the executed CLI
SHA-256; full verification selects its own freshly built artifact and
requires equal corpus/outcome summaries across modes.

`_build/numeric-<mode>-summary.json` records the status, counts and
fingerprint. Failure replaces stale success and saves the active input in
`_build/numeric-<mode>-failure.json`. These are diagnostic inputs, not
an automatic replay format. CI retains these reports and failure cases.
Three fake-CLI tests verify rejection of wrong numbers, missing replies
and malformed response JSON.

## Commands

The complete entry point builds both modes and runs this suite:

```sh
node scripts/verify.mjs
```

For focused runs, build the matching CLI first:

```sh
moon build cmd/main --target js
node scripts/numeric-properties.mjs
moon build cmd/main --target js --release
node scripts/numeric-properties.mjs --release
node --test scripts/numeric-properties.test.mjs
```

Standalone runs honor JMES_CLI_PATH; full verification supplies its own
mode-specific path and checks the reported artifact hash.
