Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 22, 2025

The PRNG was not being advanced before generating values in the infiniteStream loop, causing inconsistency with the toss mechanism in Tosser.ts.

Changes

  • Added unsafeJump() to Random class: Advances internal RNG by 42 values using unsafeSkipN, matching the jump behavior in Tosser.ts
  • Call unsafeJump() before generate() in infiniteStream: In StreamArbitrary, the PRNG now jumps before each arb.generate() call in the infinite stream generator loop
  • Updated test infrastructure: Added unsafeJump mock to RandomHelpers and updated snapshots for infiniteStream tests reflecting the new value sequences

The jump amount (42) is consistent with existing usage in QualifiedParameters.ts and Tosser.ts. The fix is restricted to the infiniteStream code only, not affecting the general GeneratorArbitrary behavior.

Original prompt

solve #5054 by jumping in the prng before returning on generate


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@changeset-bot
Copy link

changeset-bot bot commented Dec 22, 2025

⚠️ No Changeset found

Latest commit: d506438

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copilot AI changed the title [WIP] Fix PRNG behavior in generate function implementation 🐛 Jump PRNG before generate in GeneratorArbitrary Dec 22, 2025
Copilot AI requested a review from dubzzz December 22, 2025 14:49
// possibly leading from totally different sets of functions.
// In other words: `preBuiltValue !== undefined && context.history.length === 0` is a legit case!
// If we start to mismatch we run a new random value computation
localMrng.unsafeJump();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Restrict the jump to the infiniteStream code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! The PRNG jump is now restricted to the infiniteStream loop in StreamArbitrary.ts (line 33). Changes committed in 57fcb44.

Copilot AI changed the title 🐛 Jump PRNG before generate in GeneratorArbitrary 🐛 Jump PRNG in infiniteStream loop before generate Dec 22, 2025
Copilot AI requested a review from dubzzz December 22, 2025 15:04
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.

2 participants