Skip to main content

Module seed

Module seed 

Expand description

Deterministic seed derivation.

One study seed fans out into every random decision the framework makes. The fan-out is a pure function of three inputs — the study seed, the TrialNumber, and a Stream tag — so a trial draws the same randomness no matter which worker runs it, in which order, or at what time. The determinism contract states the promise this keeps, and how a seed becomes a draw.

use atune_core::seed::{Stream, seed_for};

// Same inputs, same seed — always, everywhere.
assert_eq!(seed_for(42, 7, Stream::Sampler), seed_for(42, 7, Stream::Sampler));
// Different streams of the same trial never collide.
assert_ne!(seed_for(42, 7, Stream::Sampler), seed_for(42, 7, Stream::Objective));

§Stability

The exact bits produced by seed_for and seed_for_name are a public commitment. They are golden-tested by value; changing either algorithm changes every study’s results and is therefore a breaking change.

The same applies to the RNG: rng_for returns a [ChaCha8Rng] and nothing else. StdRng and SmallRng are forbidden in this crate — their algorithms are explicitly not stability-guaranteed across rand releases, and that exact drift has already broken golden tests elsewhere in this workspace.

Enums§

Stream
Which independent stream of randomness a seed is derived for.

Functions§

rng_for
Builds the pinned RNG for one random stream of one trial.
rng_from_seed
Builds the pinned RNG from an already-derived seed.
seed_for
Derives the seed of one random stream of one trial.
seed_for_name
Derives the seed of one named parameter from a base seed.