- Public, versioned State (algorithm identity "xoshiro256**", schema
version 1, four words in s0..s3 order) so consumers can define their
own wire format.
- restore() validates version and rejects the absorbing all-zero state
without touching the current stream; from_state() builds a generator
from saved state.
- bounded(n): unbiased rejection sampling in [0, n). Documented
zero-bound policy: n == 0 and n == 1 return 0 without consuming
randomness.
- 7 new tests freeze raw/bounded/state outputs for seed 42 (portable
across targets), verify save/restore suffix equality, invalid-state
rejection, zero/one bounds, large non-power-of-two ranges,
independent interleaved streams and discard equivalence.
The Windows read_file_bounded path was implemented together with #3 using
a single CreateFileW handle. This adds the #9 acceptance coverage and
documents the contract:
- The size is checked before allocation and every chunk is re-checked, so
growth after the initial size check still fails with limit_exceeded and
never returns partial contents.
- Windows shares read/write/delete, so another process may append,
rename or replace the path while a background read is pending; the
read continues from the opened handle and sees one coherent version.
- Tests: empty, binary, Unicode path, exact limit, over limit before
reading, and (POSIX) a stream that grows past the limit mid-read.
- AccountLedger: caller-keyed accounts (owner, balance, capacity) with
atomic multi-account reserve, release without ownership change and
transfer to the destination (next) owner.
- Explicit outcomes for insufficient balance, capacity exhaustion,
overflow, unknown account/operation, invalid phase and limits.
- Every committed phase is recorded by operation id, so repeated
requests replay the recorded outcome instead of applying twice;
failed attempts change nothing and remain retryable.
- State is a plain value: save()/restore() survive a partially completed
transfer and replay applies exactly once after restore.
- 11 tests: conservation, last-unit contention, atomic multi-key failure,
cancellation before pickup and during delivery, restore/replay,
overflow, operation-id conflict, account/operation limits and invalid
restore state.
- IdSequence<Tag, Rep> is per-instance, copyable and restorable, so two
worlds in one process allocate independently and a saved high-water
mark replays exactly.
- next()/next_batch() check exhaustion before mutating; failed requests
leave the sequence and application records untouched. Batches are
all-or-nothing.
- High-water only moves forward: erased records keep their ids retired.
- Fixed-width Rep (default uint64_t) plus an explicit exhausted flag make
saved state canonical and portable; restore() rejects impossible state.
- 10 standalone tests cover independence, erase/restore, copy replay,
atomic batches, exhaustion, final-boundary batches and invalid state.