Skip to content

Enforce exclusive variable computation modes#495

Merged
MaxGhenis merged 1 commit into
masterfrom
disallow-uprating-formulas
May 17, 2026
Merged

Enforce exclusive variable computation modes#495
MaxGhenis merged 1 commit into
masterfrom
disallow-uprating-formulas

Conversation

@MaxGhenis
Copy link
Copy Markdown
Contributor

@MaxGhenis MaxGhenis commented May 17, 2026

Summary

  • reject variable classes that combine formula, adds/subtracts, and class-level uprating modes
  • make runtime variable.uprating = ... assignments validate the same invariant, rolling back invalid assignments
  • make @uprated fail fast when applied to classes that already define a formula, aggregation metadata, or uprating metadata
  • remove the obsolete formula fallback path in @uprated now that uprating is input-only, and cover the new invariant with tests

Verification

  • red-state check before implementation: new mixed-mode tests failed as expected
  • red-state check for runtime uprating mutation: failed before adding the setter guard
  • uv run --no-sync pytest tests/core/variables/test_variables.py tests/core/test_medium_fixes.py -q
  • uv run --no-sync ruff check policyengine_core/variables/variable.py policyengine_core/commons/formulas.py tests/core/variables/test_variables.py tests/core/test_medium_fixes.py
  • uv run --no-sync ruff format --check policyengine_core/variables/variable.py policyengine_core/commons/formulas.py tests/core/variables/test_variables.py tests/core/test_medium_fixes.py
  • uv run --with towncrier towncrier build --draft --version 3.26.8

Depends on country cleanup/releases before merge:

@MaxGhenis MaxGhenis force-pushed the disallow-uprating-formulas branch from d653834 to 0420970 Compare May 17, 2026 14:16
@MaxGhenis MaxGhenis merged commit addd382 into master May 17, 2026
57 of 69 checks passed
@MaxGhenis MaxGhenis deleted the disallow-uprating-formulas branch May 17, 2026 15:53
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.

1 participant