Skip to content

Commit 920469f

Browse files
committed
Update PolicyEngine Household API
1 parent eb78e1e commit 920469f

5 files changed

Lines changed: 13 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## [0.15.0] - 2026-04-30
2+
3+
### Added
4+
5+
- Add a `warnings` field to `/calculate` responses when the request mixes single-month input on a MONTH-defined variable with an annual output request. The other 11 months default to 0 in the engine, silently inflating annual sums; the warning explains the issue and points partners to a fix (send a yearly key, or set all 12 monthly keys).
6+
- Reject `/calculate` requests with malformed period keys (e.g. `"not-a-period"`, `"2026/13"`) with a 400 ("Invalid period key") that names the offending key, variable, and entity. Previously these were passed through to the engine and silently ignored, leaving partners with a confusing zero result. Pydantic doesn't validate period-key strings, so this is the first checkpoint that catches them.
7+
8+
### Fixed
9+
10+
- Match the hosted v1 API when partners send a YEAR-period key on a MONTH-defined variable. Numeric values are treated as annual totals: any explicit monthly inputs are subtracted, and the remainder splits evenly across the unset months as a raw float (matching policyengine-core's `set_input_divide_by_period`, which has had this behavior since 2015). Boolean / string / enum values broadcast unchanged across the unset months while explicit monthly values override. The API rejects with a 400 ("Inconsistent input") only when every month of the year is explicit AND those monthlies don't sum to the annual total — partial monthly overrides are silently accepted with the remainder distributed across the unset months, matching v1's exact rule. Negative annual values are accepted (some MONTH-defined numeric variables can legitimately be negative). Output requests echo the partner's original keys. Adds a `warnings` array to the response when partial monthly input is paired with an annual output for the same year and there is no year-key fallback for that variable, so partners see a heads-up that the unset months will read the engine's default (purely additive — v1 has no such warning, the numeric output is unchanged).
11+
12+
113
## [0.14.4] - 2026-04-28
214

315
### Fixed

changelog.d/normalize-annual-keys-on-month-vars.fixed.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog.d/period-shape-warnings.added.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog.d/reject-invalid-period-keys.added.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "policyengine-household-api"
3-
version = "0.14.4"
3+
version = "0.15.0"
44
description = "PolicyEngine Household API"
55
readme = "README.md"
66
authors = [

0 commit comments

Comments
 (0)