Skip to content

Disallow formula-time randomness#494

Merged
MaxGhenis merged 1 commit into
masterfrom
disallow-formula-randomness
May 17, 2026
Merged

Disallow formula-time randomness#494
MaxGhenis merged 1 commit into
masterfrom
disallow-formula-randomness

Conversation

@MaxGhenis
Copy link
Copy Markdown
Contributor

@MaxGhenis MaxGhenis commented May 17, 2026

Summary

  • make policyengine_core.commons.formulas.random() raise a clear RuntimeError instead of producing formula-time pseudo-random values
  • replace random seed preservation tests with the new no-randomness invariant
  • update stable-seed test wording now that random() is not a supported formula path

Closes #363.
Closes #412.

TDD / verification

  • Confirmed the new random() RuntimeError test failed before the implementation.
  • uv run --no-sync pytest tests/core/commons/test_random_seed.py -q
  • uv run --no-sync pytest tests/core/commons/test_random_seed.py tests/core/test_stable_hash_seed.py -q
  • uv run --no-sync ruff check policyengine_core/commons/formulas.py tests/core/commons/test_random_seed.py tests/core/test_stable_hash_seed.py
  • uv run --no-sync ruff format --check policyengine_core/commons/formulas.py tests/core/commons/test_random_seed.py tests/core/test_stable_hash_seed.py

Review

@MaxGhenis MaxGhenis force-pushed the disallow-formula-randomness branch from c835a3e to 38d0a56 Compare May 17, 2026 13:21
@MaxGhenis MaxGhenis merged commit 4088357 into master May 17, 2026
23 checks passed
@MaxGhenis MaxGhenis deleted the disallow-formula-randomness branch May 17, 2026 13:37
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.

The random() function means that local area microsimulations will never match their calibration Integer Overflow Risk in random()

1 participant