Skip to content

Dummies: distinct-collection exhaustion message over-promises replay for foreign element generators #212

Description

@Reefact

Problem

When a distinct collection cannot fill its bounded dedup draw, CollectionState.Exhausted (CollectionState.cs:246-254) reports:

> The arbitrary values were seeded with {seed}; reproduce this run with Any.Reproducibly({seed}, ...).

For a collection over a foreign IAny element generator, this promise is false. AnyCollection.Generate() substitutes the ambient source (SourceOrNull ?? AmbientRandomSource.Instance, AnyCollection.cs:149) because AnyDerivation.SourceOf returns null for a foreign generator. The reported seed is the ambient seed that drove the count and layout — but the foreign generator's own draws ignore it, so replaying with that seed reproduces neither the elements nor the shortfall. (The seed is not null guard at :249 is also dead code: SeededRandom.Seed is a non-nullable int and the source is never null there, so the replay sentence is always appended.)

Impact

Minor deviation from ADR-0013, whose decision states the bounded draw "fails explicitly and reproducibly." For every library-sourced or As/Combine-derived element generator the claim holds; only the genuinely-foreign case is affected — a narrow path. But there, a user replays the reported seed, gets different elements, and concludes reproducibility is broken — the exact trust failure the seed reporting is designed to prevent.

Direction

Thread knowledge of whether the element generator carries an IHasRandomSource into the exhaustion message. When it does not, drop or qualify the replay sentence, e.g.:

> The collection's count and layout were seeded with {seed} (Any.Reproducibly({seed}, ...)), but its elements come from a generator that does not draw from this source, so the element sequence is not reproducible from this seed alone.

Remove the dead seed is not null guard while here.

Acceptance criteria

  • The exhaustion message for a foreign element generator no longer claims full Any.Reproducibly replay of the elements.
  • The message for a library-sourced / As-derived element generator is unchanged (it is faithful).
  • The dead null-guard is removed.
  • A test drives a distinct collection to exhaustion with a foreign IAny and asserts the qualified message.

Context

Surfaced by the 2026-07-20 architecture & design audit of the standalone Dummies library (doc/handwritten/for-maintainers/audit/2026-07-20-dummies-architecture-and-design-audit.md, §6 (ADR-0013 compliance); branch claude/dummies-architecture-audit-cru5aq).


Filed from the Claude Code session that produced the 2026-07-20 Dummies architecture & design audit: https://claude.ai/code/session_01GvrWFVoG74xiys3oyEft1G

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions