Skip to content

Add per-session seeds and an own deterministic random generator - #7

Merged
holonsoftFounder merged 1 commit into
mainfrom
feature/session-seed
Sep 9, 2026
Merged

Add per-session seeds and an own deterministic random generator#7
holonsoftFounder merged 1 commit into
mainfrom
feature/session-seed

Conversation

@holonsoftFounder

Copy link
Copy Markdown
Member

Summary

  • x.UseSeed(seed) per factory (default stays 1337), CreateSession(recursionLimit, seed) per session.
  • Every data source gets its own stream derived from the session seed and Type.Member (SeedDerivation, FNV-1a), applied once via ISessionSeedable; an explicit SetSeedToRandomValue in the configuration lambda wins. Two members with the same source type no longer correlate, nullable value type sources no longer go null together, a member's values do not depend on which other members exist. Null evaluators of RespectNullableAnnotations, method argument sources, type factories (constructor arguments) and the Random(count) shuffle follow the seed.
  • StableRandom: xoshiro256** seeded through SplitMix64, a Random subclass with every public member overridden, used by DataSourceBase, DefaultRandomNullEvaluator and CollectionContext. The sequence of a seed is defined by our code, not by the runtime. Output pinned by tests, uniformity and range tests included.
  • Breaking: AutoPocoGlobalSettings removed (mutable process-wide state), AutoPocoDefaults holds the constants Seed, NullCreationThreshold, RecursionLimit.
  • Breaking: every generated sequence changed once. All stable-sequence tests regenerated. The shared helper NextReturnsStableElementListInTermsOfTestability now appends the actual values as a ready-to-paste C# literal (CSharpLiteral) to the failure message.
  • Three pre-existing tests only passed by luck of the old stream: two waited at most 21 draws for a 15 percent null, one expected millisecond 999 in 300 draws over a 1000 millisecond window. Fixed with sound bounds.
  • Not done on purpose: a factory-wide default null threshold. The Nullable* constructors chain through plain int parameters, so "explicit 15" and "default 15" cannot be told apart. Per-source thresholds and RespectNullableAnnotations(threshold) cover it.

Test plan

  • 38 new tests: StableRandom pinned output, ranges, uniformity, rejection path, span/array parity, shuffle; SeedDerivation reference values; DataSourceBase session seed semantics; integration for factory seed, session seed, cross-factory equality, per-member independence, nullable independence, explicit seed precedence, shared generation-time source, deterministic Random(count), constructor arguments, nullable annotation patterns
  • dotnet build -c Release zero warnings
  • 797 tests green per framework on net8, net9, net10 (Windows)
  • Two separate processes with seed 2024 print identical data, seed 7 differs

🤖 Generated with Claude Code

UseSeed(seed) sets the seed of a factory, CreateSession(recursionLimit, seed)
gives one session another seed. Every data source gets its own stream derived
from the session seed and the member it feeds (SeedDerivation, FNV-1a over
Type.Member), applied once through ISessionSeedable unless the source got an
explicit seed. Null evaluators of RespectNullableAnnotations, method argument
sources, type factories and the shuffle of Random(count) derive from the seed
too. StableRandom (xoshiro256** seeded through SplitMix64, a Random subclass
with every member overridden) replaces System.Random in DataSourceBase,
DefaultRandomNullEvaluator and CollectionContext, so sequences are defined by
this code alone and stay stable across .NET versions; its output is pinned by
tests. AutoPocoGlobalSettings removed, AutoPocoDefaults holds the constants.
All generated sequences changed once: stable sequence tests regenerated, the
shared test helper now prints the actual values as a C# literal on failure.
Three tests that only passed by luck of the old stream fixed (null loop limit,
time window). README and release notes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@holonsoftFounder
holonsoftFounder merged commit 4ed432b into main Sep 9, 2026
2 checks passed
@holonsoftFounder
holonsoftFounder deleted the feature/session-seed branch September 9, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant