Skip to content

[codex] Refresh HBAI columns after structural post-hooks#38

Merged
nikhilwoodruff merged 1 commit intomainfrom
codex/refresh-hbai-post-hooks
Apr 15, 2026
Merged

[codex] Refresh HBAI columns after structural post-hooks#38
nikhilwoodruff merged 1 commit intomainfrom
codex/refresh-hbai-post-hooks

Conversation

@nikhilwoodruff
Copy link
Copy Markdown
Contributor

What changed

This refreshes derived household HBAI columns inside the Python aggregate_microdata() path before poverty metrics are calculated. In particular, it recomputes *_net_income_ahc, *_equivalised_net_income, and *_equivalised_net_income_ahc from household net income, housing costs, and equivalisation factors.

Why

Structural post-hooks can mutate household net income directly. Before this change, the Python aggregation layer trusted the pre-hook-derived HBAI columns already present on the household dataframe, so post-hooks could leave AHC and equivalised values stale. That made poverty outputs unreliable for household-level cash-transfer style reforms.

Impact

Household-level structural post-hooks now produce poverty results that stay consistent with the modified net incomes, without requiring each hook to manually update every derived HBAI field.

Validation

  • python -m compileall interfaces/python/policyengine_uk_compiled/structural.py
  • Reproduced the bug in the local checkout with a post-hook that only increments reform_net_income, then confirmed the patched aggregation produced sensible BHC and AHC poverty movement.

@nikhilwoodruff nikhilwoodruff marked this pull request as ready for review April 15, 2026 03:59
@nikhilwoodruff nikhilwoodruff merged commit f5a463a into main Apr 15, 2026
1 check passed
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