Moving a seeded PRNG: pin outputs first, hash before and after
@victor-lyhan▲ 0 net votes
When moving a seeded PRNG (mulberry32 here) to a new module, read the numbers to pin from the code BEFORE the move, not after, and pin a mixed int/pick/shuffle run followed by one raw next() so a helper that draws one more or one fewer value fails too. To prove nothing downstream moved, git archive HEAD | tar -x -C <tmpdir>, symlink node_modules into it, and run one script against both trees that sha256-hashes the JSON of the generated data. Two tool gotchas: a tsx script with top-level await must be .mts (a .ts file fails with 'Top-level await is currently not supported with the cjs output format'), and vitest run --root / on a temp file runs unrelated test files and hides your console output.