refactor(dummies): contextualize replay hints in generation failures#272
Merged
Conversation
Generation-failure messages hardcoded the ambient "reproduce this run with Any.Reproducibly(seed, ...)" instruction even when the failing generator drew from an Any.WithSeed(...) fixed context, which ignores the ambient scope Any.Reproducibly pins — so the printed instruction did not reproduce the run. In a library whose signature strength is diagnostic honesty, that is a confidently misleading hint. Give RandomSource an internal ReplayHint(seed): the ambient source points at Any.Reproducibly(seed, ...); a fixed Any.WithSeed(seed) context names itself and states that it already replays deterministically. Route every failure-message site through it — Combine/As (AnyDerivation.Invoke), distinct-collection exhaustion (CollectionState.Exhausted), and the continuous/decimal interval specs — and remove the dead "seed is not null" guard in Exhausted (SeededRandom.Seed is a non-nullable int). Clarify the AnyGenerationException.Seed doc, which likewise asserted the ambient instruction unconditionally. Add composition tests for the ambient and fixed-context hints and correct the interval-spec exhaustion test, which asserted the inapplicable Any.Reproducibly hint on a WithSeed(...) source. Refs: #211
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactor error messages in generation failures to provide context-aware replay hints. When a generation fails under
Any.Reproducibly(...), the hint directs users to that API; when it fails underAny.WithSeed(...), the hint clarifies that the context already replays deterministically. This eliminates misleading diagnostics that suggested inapplicable replay instructions.Closes #211
Type of change
Changes
RandomSource.ReplayHint(int seed)abstract method to generate context-appropriate replay guidanceReplayHintinAmbientRandomSource(points toAny.Reproducibly(seed, ...))ReplayHintinFixedRandomSource(clarifies deterministic replay viaAny.WithSeed(seed))ContinuousIntervalSpec.Generate()andDecimalIntervalSpec.Generate()to acceptRandomSourceinstead ofRandomandint seed, enabling access to context-aware hintsAnyDouble,AnyDecimal,AnyHalf, andAnySingleto pass_sourcedirectly to interval specsAnyDerivation.Invoke()to usesource.ReplayHint()for consistent messagingCollectionState.Exhausted()to usesource.ReplayHint()instead of hardcoded replay instructionAnyGenerationException.Seeddocumentation to clarify the distinction between ambient and fixed contextsAny.Reproducibly(...)andAny.WithSeed(...)contextsContinuousExclusionNudgeTeststo verify the hint namesAny.WithSeed, not the inapplicableAny.ReproduciblyTesting
dotnet build FirstClassErrors.slndotnet test FirstClassErrors.slnArchitecture decisions
https://claude.ai/code/session_01TypdikCpEjgECvwuwpkrJD