UK: structural reforms gated on `*.in_effect=True` silently no-op via `simulation_modifier` path
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
Direzione di ricerca
Inizia da policyengine_uk/reforms/reforms.py e src/policyengine/tax_benefit_models/uk/model.py:187-202; elenca i gate gov.contrib.*.in_effect e traccia quando viene eseguito create_structural_reforms_from_parameters in Microsimulation.init. Confronta il percorso UK con tests/test_us_microsim_structural_reforms.py::test__gov_contrib_gate_runs_cleanly. Il lavoro è completato quando un test di regressione UK dimostra che il gate funziona attraverso il percorso di costruzione previsto, modificando l’implementazione se viene confermato il bug latente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 7
- Fork
- 9
- Merge medio
- 15h 51m
- PR unite (30g)
- 9
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di PolicyEngine/policyengine.py
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
PolicyEngine/policyengine.py#473 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
PolicyEngine/policyengine.py#436 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
PolicyEngine/policyengine.py#408 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
PolicyEngine/policyengine.py#523 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
PolicyEngine/policyengine.py#518 ·
Tutte le issue di PolicyEngine/policyengine.py
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100