mirror of
https://github.com/morluto/rea.git
synced 2026-11-23 15:05:51 +00:00
A reviewer read the test and said it would still pass with `Uint32Array` back at
`ByteEntropyService.ts:258`. That was correct, and I verified it: reverting the counter to
`Uint32Array` left all four cases green. The test pinned the counter type but not the loop that
fills it, so nothing tied the service's census to the exact counter.
The two counting loops were copies of each other — `computeBlockEntropy` and the service each had
their own. They are one function now, `countByteValues(bytes, counts)`, whose `counts` parameter is
`Float64Array`. That makes the counter type part of the signature rather than a local decision: a
narrower bin is a compile error at the call site, which is the guarantee the test was pretending to
give.
With `const counts = new Uint32Array(256);` at that line:
src/application/binaryDiagnostics/ByteEntropyService.ts(282,36): error TS2345:
Argument of type 'Uint32Array<ArrayBuffer>' is not assignable to parameter of type
'Float64Array<ArrayBufferLike>'.
The tests changed to match what they can actually prove:
- a census that lands just under 2^32 and then crosses it in one more chunk, asserting the total
does not wrap;
- two chunks accumulating into one counter, matching how the service counts a stream, compared
against the same bytes counted as one run.
I did not attempt a 4 GiB fixture: the loop is called per chunk, so crossing the boundary with a
counter set near it exercises the same arithmetic without a quarter-hour of I/O.
`src/domain/native/byteEntropy.test.ts` — 5 cases. `tsc` 0 errors.