Repository navigation
Description
Problem
obr_shock accepts periods from 1 to 40 (_OBR_MAX_PERIODS = 40, integration/src/policyengine_macro/core.py:1268-1269; MCP schema mcp_server.py:200, le=40). It then calls run_reform(...) with no start/end (core.py:262-268), so the OBR model always solves its default window, 2025Q1–2027Q4 (12 quarters, obr_macro/reform_analysis.py:613-620).
For periods > 12:
resultshas 12 rows;cumulative_delta_gdp_bn_over_shock_periodssumsrows[:periods], which is the same 12 rows, while the payload echoes"periods": 20;- the caller reads a 20-quarter cumulative figure that covers only 12 quarters.
PolicyEngine/obr-macroeconomic-model#48 makes run_reform warn in this case and record df.attrs["shock_quarters_beyond_horizon"]. That stops it being silent on the model side, but the macro payload still mislabels the sum.
Options
- Cap
periodsat the solved window. Set_OBR_MAX_PERIODS = 12and MCPle=12. This is the smallest change. - Solve the window the caller asks for. Pass
endso that the window coversperiods. The OBR data runs to 2031Q1, so the model supports at most 25 quarters from 2025Q1. Set the cap to 25 and passend = 2025Q1 + periods - 1. This costs one more template build per newend, because the template cache is keyed on (var, start, end, closure). - Keep 40, but carry
shock_quarters_beyond_horizoninto the payload and rename the headline field to "over the solved window".
Evidence on longer windows (6 Nov 2026 sweep)
run_reform machinery, window 2025Q1–2031Q1 (25 quarters):
- CGG solves cleanly over all 25 quarters. A 4-quarter +£1,000m shock gives +£1,000m for q0–q3, then at most £1m of residue. A sustained −£1,000m shock gives −£1,000m ±£1.2m to q24. (The multiplier is the known 1.0 identity, against the OBR's 0.6 tapering to zero.)
- The household channel (
HHDI_ADDFACTOR) is noise-dominated after about q12. A 12-quarter £1,616m/q tax rise lowers GDP by £552m at q11. After the shock ends, GDP does not return toward baseline: it is still −£853m at q24, and the HHDI delta comes back to about −£1.7bn to −£2.2bn in q17–q23. The equal tax cut gives −£217m at q24, the wrong sign. Rise + cut is 125% of the rise's peak, against 10.5% inside the shock window. The likely cause is the undetermined nominal-GDP/investment-deflator pair on the OBR side (OAHHx worsens the company-profits fit (63.3% -> 82.8%): check the FYCPR/OSHH identity obr-macroeconomic-model#42).
Recommendation
Option 1 for now: cap periods at 12, and carry shock_quarters_beyond_horizon into the payload as a guard. Option 2 (a longer window, up to 25 quarters) becomes reasonable once the closure in obr-macroeconomic-model#42 is fixed and a sweep shows the household tail returning toward baseline. obr_score_reform is affected the same way: its default 5-year window (2026Q1–2030Q4) reads household-channel quarters past the reliable range.
🤖 Generated with Claude Code
Activity
vahid-ahmadi commentedon Nov 6, 2026
Triage (6 Nov): no code fix yet. The
/obrworked example is now labelled as a 12-quarter run on draft PR #206 (e493d07). That covers wording only;_OBR_MAX_PERIODSis still 40. Option 1 (cap at 12) is still the recommendation. Note: PolicyEngine/obr-macroeconomic-model#48 cites this issue as a plain "macro#217", which links to the wrong repo.vahid-ahmadi commentedon Nov 25, 2026
Closing: fixed on main by
8ee00681("obr_shock: solve to the last shocked quarter and cap periods at 25"), merged through #200 on 10 Nov.Checked on main
7cce161d(24 Nov):_OBR_MAX_PERIODSis 25, the number of quarters the databank holds from 2025Q1 (it ends 2031Q1), and the MCP schema carriesmaximum: 25.obr_shockpassesendtorun_reform(_obr_window_end), so the solve covers every shocked quarter, and it raises if the model returns fewer rows than shocked quarters. The cumulative figure can no longer sum 12 quarters under a longer label.0e44ec8: a 25-quarterHHDI_ADDFACTORsolve returns 25 rows, all converged.One related bug found while checking, on the short side: a household shock with
periodsbelow 12 raises aTypeError. Fix in #283.🤖 Generated with Claude Code