UK: structural reforms gated on `*.in_effect=True` silently no-op via `simulation_modifier` path
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
Research direction
Start with policyengine_uk/reforms/reforms.py and src/policyengine/tax_benefit_models/uk/model.py:187-202; enumerate gov.contrib.*.in_effect gates and trace when create_structural_reforms_from_parameters runs in Microsimulation.init. Compare the UK path with tests/test_us_microsim_structural_reforms.py::test__gov_contrib_gate_runs_cleanly. Done means a UK regression test demonstrates the gate works through the intended construction path, with the implementation adjusted if the latent bug is confirmed.
Written by the indexing model from the issue text.
Description
Flagged during subagent review of #300.
The UK model applies reforms via simulation_modifier_from_parameter_values after Microsimulation construction (src/policyengine/tax_benefit_models/uk/model.py:190,198), using p.update() on parameters. This means any UK structural reform that is gated on a *.in_effect=True parameter — where the structural reform class only activates inside Microsimulation.__init__'s call to create_structural_reforms_from_parameters — would silently no-op.
US recently hit this class of bug (#300) when gov.contrib.ctc.*.in_effect=True reforms crashed because the structural reform's variables were registered on the per-sim system but populations were built from the module-level system. The UK variant is subtly different: the structural reform never gets applied at all because p.update() happens post-construction.
Evidence
policyengine_uk/reforms/reforms.pycontains at least onein_effectgate (confirmed via grep).- UK uses
simulation_modifieratsrc/policyengine/tax_benefit_models/uk/model.py:187-202, which runs afterMicrosimulation.__init__has already decided which structural reforms to apply (based on base-parameterin_effect=False).
What to check
- Enumerate UK
gov.contrib.*.in_effectparameters. If any exist and activate structural reforms, this is a real latent bug. - Write a regression test along the lines of
tests/test_us_microsim_structural_reforms.py::test__gov_contrib_gate_runs_cleanlyfor a UK gate. - If confirmed, the fix is to pass UK reforms at
Microsimulation(reform=...)construction time (same pattern US uses) instead of via post-constructionp.update().
Not blocking v4.0.1; file as a v4.0.2 / v4.1 candidate.
- Dominant language
- Python
- Stars
- 8
- Forks
- 9
- Avg merge
- 15h 28m
- Merged PRs (30d)
- 13
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PolicyEngine/policyengine.py
-
Raise the simulation cache memory warning to 16 GiBPossibly taken @anth-volk claimed this 4 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
PolicyEngine/policyengine.py#549 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
PolicyEngine/policyengine.py#473 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
PolicyEngine/policyengine.py#436 · 1 comment ·
Maintainers usually reply within 1 day
-
Certify populace-uk as the UK certified defaultMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
PolicyEngine/policyengine.py#408 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
PolicyEngine/policyengine.py#551 ·
Maintainers usually reply within 1 day
All issues in PolicyEngine/policyengine.py
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
FuRongJun-1999/dsh-memory#56 ·
Maintainers usually reply within 1 day
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
pgadmin-org/pgadmin4#10503 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
521xueweihan/HelloGitHub#3857 ·
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
rai-opensource/spatialmath-python#235 ·
Maintainers usually reply within 1 day
-
needs-ac
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Ikalus1988/MisakaNet#2845 ·
Maintainers usually reply within 1 day