Skip to content

Avoid advancing RNG when creating agg devices#212

Merged
thomasp85 merged 1 commit intor-lib:mainfrom
gjhunt:fix-rng-dev-names
Mar 5, 2026
Merged

Avoid advancing RNG when creating agg devices#212
thomasp85 merged 1 commit intor-lib:mainfrom
gjhunt:fix-rng-dev-names

Conversation

@gjhunt
Copy link
Contributor

@gjhunt gjhunt commented Jan 20, 2026

Summary

This PR replaces RNG-based device naming (sample()) with tempfile()-based names so that creating agg devices no longer advances the global RNG state.

Motivation

Device creation currently mutates .Random.seed, which can be surprising in reproducible workflows. This can also make whitespace semantically meaningful in downstream jupyter contexts, e.g., latest containerized jupyter/datascience-notebook.

Changes

  • Use basename(tempfile()) to generate unique device names without touching RNG state
  • Add tests asserting that agg_capture() and agg_record() do not advance the global RNG

Notes

  • tempfile() does not create files and does not use or modify .Random.seed
  • Behavior is unchanged except for the removal of RNG side effects during device creation

@thomasp85 thomasp85 merged commit 013475a into r-lib:main Mar 5, 2026
13 checks passed
@thomasp85
Copy link
Member

Thanks!

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