Skip to content

fix(test): seed the seed pair selection in the variability tests - #45

Merged
Mearman merged 2 commits into
mainfrom
test/seed-pair-selection
Nov 2, 2026
Merged

Mearman merged 2 commits into
mainfrom
test/seed-pair-selection

Conversation

@Mearman

@Mearman Mearman commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Fixes #42

The multiple seed pair comparison in variability-injection.exp.integration.test.ts and thesis-validation.exp.integration.test.ts chose its ten pairs with Math.random, so the pairs and the path diversity statistics built from them changed on every run. Both now draw the pairs from createSeededRng in proofs/test-utils, the same source the perturbation tests were moved to in 98a0e71, passed into a new selectSeedPair helper next to graph-perturbation.ts.

selectSeedPair picks the second index from the remaining n - 1 positions instead of redrawing on a collision, so each pair costs exactly two draws. It has its own unit test (determinism, distinctness, full coverage of ordered pairs, fewer than two nodes).

For lesmis with seed 1 the ten pairs are identical across three separate runs (same md5 of the printed pair list; the first is Gavroche to Myriel). Typecheck and eslint are clean on the touched files. The two files plus the new unit test pass under the CI command with coverage thresholds zeroed; two of three full runs had timeouts on the large Facebook and CiteSeer tests while the machine's load average was above 370, and the third passed 81 of 81. The timeouts are on tests that do not use the seed pair code.

The only other Math.random uses in the evaluation tests were in the perturbation helpers, already seeded. The remaining uses are in src/algorithms and src/analyzer, which are production code, not test selection, and are left alone.

selectSeedPair draws two distinct nodes from a caller-supplied random source.
It picks the second index from the remaining positions instead of
retrying on a collision, so the number of draws per pair is fixed.
The multiple seed pair comparison chose its pairs with Math.random, so the
pairs, and the path diversity statistics computed from them, differed on
every run. Both copies of the test now draw their pairs from a fixed
seeded generator, as the perturbation tests do.
@Mearman
Mearman marked this pull request as ready for review November 2, 2026 09:36
@Mearman
Mearman merged commit 35b4f69 into main Nov 2, 2026
8 checks passed
@Mearman
Mearman deleted the test/seed-pair-selection branch November 2, 2026 09:38
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 1.4.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Seed the random pair selection in the variability and thesis validation tests

1 participant