From 63be6bc75766596778c1c67e635c9914f26dfdde Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Thu, 19 Nov 2026 09:50:54 +0000 Subject: [PATCH 1/4] NZ: read owner payments as interest only, add a terminal gate checkpoint, pin the real CREATE inventory Interim New Zealand data changes for one measurement run on the pinned populace-us donor (ruling d3058, rule 1 and two run aids). No shared source module changes and no kernel implementation hash moves. - Rule 1: the pinned donor carries no mortgage principal, so both NZ money declarations route household.mortgage_principal pending, the Accommodation Supplement owner payments read annual mortgage interest x 1/52, and the concept mapping lists the principal concept as unmapped with its reason. Generated NZ resources drop the column. - Checkpoint: NZ's entitlement declaration adds nz.gates.terminal, so a run keeps the terminal gate closure's manifest when export.prepare refuses. - D4: the attempt-7 CREATE inventory on donor 48b9d479 becomes a test fixture, replacing the circular composition helper; three columns the donor staging will add are declared as an explicit gap. Co-Authored-By: Claude Opus 5.5 --- .../nz-gate-report-checkpoint.changed.md | 1 + .../nz-mortgage-principal-pending.changed.md | 1 + docs/concept-coverage/axiom-nz.md | 2 +- .../microcosm/build/nz/concept_mapping.json | 8 +- .../microcosm/build/nz/entitlement_graph.json | 3 +- .../microcosm/build/nz/export_contract.json | 3 - .../build/nz/export_replay_bindings.json | 2 +- .../build/nz/money_normalization.json | 14 +- .../nz/money_normalization_hold_fixed.json | 12 +- .../src/microcosm/build/nz/scenarios.json | 115 --------- .../microcosm/build/nz/transport_graph.json | 18 -- .../shared/test_nz_money_normalization.py | 15 +- .../shared/test_nz_transport_declarations.py | 231 ++++++++++++++---- .../shared/test_transport_evidence_kernels.py | 5 +- ...create_inventory_populace_us_48b9d479.json | 1 + ..._populace_us_48b9d479.json.provenance.json | 20 ++ .../tests/golden/nz_country_spec.json | 18 +- .../adapters/axiom_concept_mappings/nz.json | 8 +- .../engine_free/shared/test_group_encode.py | 5 +- .../golden/concept-coverage/axiom-nz.json | 8 +- tools/build_nz_entitlement_graph.py | 9 +- tools/build_nz_transport_graph.py | 2 - 22 files changed, 279 insertions(+), 222 deletions(-) create mode 100644 changelog.d/nz-gate-report-checkpoint.changed.md create mode 100644 changelog.d/nz-mortgage-principal-pending.changed.md create mode 100644 packages/microcosm-build/tests/fixtures/nz/create_inventory_populace_us_48b9d479.json create mode 100644 packages/microcosm-build/tests/fixtures/nz/create_inventory_populace_us_48b9d479.json.provenance.json diff --git a/changelog.d/nz-gate-report-checkpoint.changed.md b/changelog.d/nz-gate-report-checkpoint.changed.md new file mode 100644 index 0000000000..cfcdbf2818 --- /dev/null +++ b/changelog.d/nz-gate-report-checkpoint.changed.md @@ -0,0 +1 @@ +New Zealand's entitlement declaration adds `nz.gates.terminal` to its checkpoints (ruling d3058), so a run keeps the manifest of the terminal gate closure (the calibration diagnostics, the six evidence nodes and the battery) when `export.prepare` refuses on a blocking gate report. No gate changes, and no node key moves. A run now writes three extension checkpoint manifests instead of two. The cell diagnostics collector feeds the terminal battery, so it now executes inside the `nz.gates.terminal` checkpoint, and the third manifest records it from the store. One trade-off follows: if the calibration diagnostics or one of the six evidence nodes raises, the run stops before the collector runs, and the cell diagnostics manifest that the old order kept is not written. diff --git a/changelog.d/nz-mortgage-principal-pending.changed.md b/changelog.d/nz-mortgage-principal-pending.changed.md new file mode 100644 index 0000000000..708e53de1f --- /dev/null +++ b/changelog.d/nz-mortgage-principal-pending.changed.md @@ -0,0 +1 @@ +Route New Zealand's household mortgage principal `pending` in both money declarations and read the Accommodation Supplement owner payments as annual mortgage interest scaled by 1/52, because the pinned populace-us donor carries no principal (interim, ruling d3058, for a first measurement run). The concept mapping lists `fact:household.mortgage_principal` as unmapped with its reason, and no generated NZ resource reads the column. Owners' costs are understated further, beyond MC8's rates and insurance gap. diff --git a/docs/concept-coverage/axiom-nz.md b/docs/concept-coverage/axiom-nz.md index a2564100d0..fb2ea208fb 100644 --- a/docs/concept-coverage/axiom-nz.md +++ b/docs/concept-coverage/axiom-nz.md @@ -34,7 +34,6 @@ Engine version `6fe181fc4c65763150fe97501ef3443774e64869`; concept schema `5a556 | `fact:household.tenure` | `accommodation_supplement_costs_are_homeownership` (Family)
`accommodation_supplement_has_accommodation_costs` (Family)
`accommodation_supplement_owns_premises_and_not_joint_owner_with_resident` (Family)
`accommodation_supplement_rent_paid_to_kainga_ora` (Family)
`accommodation_supplement_rent_paid_to_registered_community_housing_provider_social_housing` (Family) | | `fact:household.rent` | `accommodation_supplement_weekly_rent_paid` (Family) | | `fact:household.mortgage_interest` | `accommodation_supplement_owner_weekly_required_payments` (Family) | -| `fact:household.mortgage_principal` | `accommodation_supplement_owner_weekly_required_payments` (Family) | ## Concepts no engine input takes @@ -45,6 +44,7 @@ Engine version `6fe181fc4c65763150fe97501ef3443774e64869`; concept schema `5a556 | `fact:person.usual_weekly_hours` | rulespec-nz at 6fe181f has no input that takes hours worked: the work-hours inputs are threshold statuses no transform can compute from hours, namely acc_self_employed_more_than_30_hours_per_week (regulations/acc/earners_levy.yaml, reg 6, which also needs self-employment hours alone), jobseeker_in_full_time_employment (main_benefits/entitlement.yaml, s 21), acc_weekly_compensation_is_full_time_earner and the Family-level in_work_tax_credit_normally_full_time_earner; the remaining hours_per_week inputs are childcare, programme-participation or work-capacity hours. | | `fact:person.weeks_worked` | rulespec-nz at 6fe181f has no input the concept determines: the closest, in_work_tax_credit_weekly_periods (Family, income_tax/family_scheme/tax_credits.yaml, s MD 10(2)), counts weeks in which the person or their partner meets the earner requirement, which needs the union of two partners' work weeks that no group rule gives (reference_member drops a working partner; sum_over_members double-counts and adds children's weeks), and minimum_family_tax_credit_weekly_periods and minimum_family_full_time_earner_weeks count only weeks as a full-time earner. | | `fact:person.educational_attainment` | rulespec-nz at 6fe181f has no input for completed education: no rule or input name mentions a qualification, degree, diploma or attainment level; the education inputs are current enrollment or school attendance (this mapping binds some of them to education_enrollment and enrolled_full_time); and young_person_is_study_ready is what youth_young_parent_payment/core.yaml calls an agency-adjudicated composite input (s 50). | +| `fact:household.mortgage_principal` | The only input that would take it, accommodation_supplement_owner_weekly_required_payments (Family) in statutes/social_security/accommodation_supplement/core.yaml, reads mortgage interest alone for now: the pinned PolicyEngine-US donor carries no mortgage principal (its mapping reads principal only inside the non-invertible mortgage_payments sum), so money_normalization.json routes household.mortgage_principal pending and no transport node reads it. This is an interim flexibility under ruling d3058 for a first measurement run. Once a donor carries principal, or the build derives it from the donor's mortgage balance, interest, origination year and an assumed term, the candidate is to restore scaled_sum over mortgage_interest and mortgage_principal with factor 1/52 (approximate). | | `fact:household.property_tax` | The only rates input, rr_rates_payable_before_rebate (Person) in statutes/rates_rebates/rates_rebate.yaml, cannot be bound at 6fe181f, because the dense engine could not compile that module and nz.json lists it only under cli_walk_inputs, which the adapter's surface loader does not read; once the module compiles, allocate_to_reference_person of property_tax is the candidate (approximate, because the ratepayer need not be the reference person). | | `fact:household.source_household_id` | Original donor household lineage is build provenance and weight diagnostic support, not a rulespec-nz legal input. | diff --git a/packages/microcosm-build/src/microcosm/build/nz/concept_mapping.json b/packages/microcosm-build/src/microcosm/build/nz/concept_mapping.json index b8c29d586f..6665f482be 100644 --- a/packages/microcosm-build/src/microcosm/build/nz/concept_mapping.json +++ b/packages/microcosm-build/src/microcosm/build/nz/concept_mapping.json @@ -643,18 +643,17 @@ { "canonical_input": "nz:statutes/social_security/accommodation_supplement/core#input.accommodation_supplement_owner_weekly_required_payments", "concepts": [ - "fact:household.mortgage_interest", - "fact:household.mortgage_principal" + "fact:household.mortgage_interest" ], "engine_entity": "Family", "engine_input": "accommodation_supplement_owner_weekly_required_payments", "group_rule": "allocate_to_reference_unit", "module": "nz/statutes/social_security/accommodation_supplement/core.yaml", - "note": "Consumed in nz/statutes/social_security/accommodation_supplement/core.yaml by accommodation_supplement_weekly_accommodation_costs (source: Social Security Act 2018 s 65AAA definition of accommodation costs), whose first branch returns it when accommodation_supplement_owns_premises_and_not_joint_owner_with_resident holds; the result feeds the Schedule 4 Part 7 weekly formula, so the value is weekly although the rule declares period Year. Read as the household's annual mortgage interest plus mortgage principal repaid, summed and scaled by 1/52 (one scaled_sum, since a binding takes one transform), on the family that contains the household reference person and zero on the household's other families. Differences: the module does not define the owner's payments; rates (property tax), insurance and other home payments are not added, which understates owners' costs (method card MC8); the concept is what the household repaid in the year, not what the mortgage requires; and a second family in an owner-occupied household gets zero.", + "note": "Consumed in nz/statutes/social_security/accommodation_supplement/core.yaml by accommodation_supplement_weekly_accommodation_costs (source: Social Security Act 2018 s 65AAA definition of accommodation costs), whose first branch returns it when accommodation_supplement_owns_premises_and_not_joint_owner_with_resident holds; the result feeds the Schedule 4 Part 7 weekly formula, so the value is weekly although the rule declares period Year. Read as the household's annual mortgage interest scaled by 1/52, on the family that contains the household reference person and zero on the household's other families. Differences: the module does not define the owner's payments; mortgage principal repaid is left out for now, because the pinned PolicyEngine-US donor carries none and money normalization routes it pending (an interim flexibility under ruling d3058 so a first measurement run can go ahead; fact:household.mortgage_principal is listed as unmapped); rates (property tax), insurance and other home payments are not added either; both omissions understate owners' costs (method card MC8); the concept is the interest the household paid in the year, not what the mortgage requires; and a second family in an owner-occupied household gets zero.", "relation": "approximate", "transform": { "factor": 0.019230769230769232, - "kind": "scaled_sum" + "kind": "scale" } }, { @@ -1510,6 +1509,7 @@ "input_declaration": "usage_inferred", "structural_inputs": [], "unmapped": { + "fact:household.mortgage_principal": "The only input that would take it, accommodation_supplement_owner_weekly_required_payments (Family) in statutes/social_security/accommodation_supplement/core.yaml, reads mortgage interest alone for now: the pinned PolicyEngine-US donor carries no mortgage principal (its mapping reads principal only inside the non-invertible mortgage_payments sum), so money_normalization.json routes household.mortgage_principal pending and no transport node reads it. This is an interim flexibility under ruling d3058 for a first measurement run. Once a donor carries principal, or the build derives it from the donor's mortgage balance, interest, origination year and an assumed term, the candidate is to restore scaled_sum over mortgage_interest and mortgage_principal with factor 1/52 (approximate).", "fact:household.property_tax": "The only rates input, rr_rates_payable_before_rebate (Person) in statutes/rates_rebates/rates_rebate.yaml, cannot be bound at 6fe181f, because the dense engine could not compile that module and nz.json lists it only under cli_walk_inputs, which the adapter's surface loader does not read; once the module compiles, allocate_to_reference_person of property_tax is the candidate (approximate, because the ratepayer need not be the reference person).", "fact:household.source_household_id": "Original donor household lineage is build provenance and weight diagnostic support, not a rulespec-nz legal input.", "fact:person.educational_attainment": "rulespec-nz at 6fe181f has no input for completed education: no rule or input name mentions a qualification, degree, diploma or attainment level; the education inputs are current enrollment or school attendance (this mapping binds some of them to education_enrollment and enrolled_full_time); and young_person_is_study_ready is what youth_young_parent_payment/core.yaml calls an agency-adjudicated composite input (s 50).", diff --git a/packages/microcosm-build/src/microcosm/build/nz/entitlement_graph.json b/packages/microcosm-build/src/microcosm/build/nz/entitlement_graph.json index ca788217cd..cf5369a269 100644 --- a/packages/microcosm-build/src/microcosm/build/nz/entitlement_graph.json +++ b/packages/microcosm-build/src/microcosm/build/nz/entitlement_graph.json @@ -1030,7 +1030,8 @@ "artifact_name": "bands" }, "checkpoints": [ - "nz.as.bands" + "nz.as.bands", + "nz.gates.terminal" ], "gate_evidence": [ { diff --git a/packages/microcosm-build/src/microcosm/build/nz/export_contract.json b/packages/microcosm-build/src/microcosm/build/nz/export_contract.json index 726367ccc9..a16d09483c 100644 --- a/packages/microcosm-build/src/microcosm/build/nz/export_contract.json +++ b/packages/microcosm-build/src/microcosm/build/nz/export_contract.json @@ -137,7 +137,6 @@ "main_benefit_receiving_new_zealand_superannuation", "main_benefit_receiving_veterans_pension", "mortgage_interest", - "mortgage_principal", "nonfarm_self_employment_income", "nz_super_all_shared_adults_are_exempt_dependent_children_or_temporary_visitors", "nz_super_birth_year", @@ -387,7 +386,6 @@ "donor_support_stratum", "household_region_code", "mortgage_interest", - "mortgage_principal", "property_tax", "rent", "source_household_id", @@ -558,7 +556,6 @@ "donor_support_stratum", "household_region_code", "mortgage_interest", - "mortgage_principal", "property_tax", "rent", "source_household_id", diff --git a/packages/microcosm-build/src/microcosm/build/nz/export_replay_bindings.json b/packages/microcosm-build/src/microcosm/build/nz/export_replay_bindings.json index dcd95b15c2..281b867a23 100644 --- a/packages/microcosm-build/src/microcosm/build/nz/export_replay_bindings.json +++ b/packages/microcosm-build/src/microcosm/build/nz/export_replay_bindings.json @@ -1,4 +1,4 @@ { - "export_contract_sha256": "4d388236cc3d3382501f5cfae8eae44b661fba6919681965eaa3fe4e032efe86", + "export_contract_sha256": "3fb78dd3a6d1b0f59b6a2df8883f1a175b07a2a2f57f35c1eb89a8802c983993", "axiom_input_closure_sha256": "acd994081b81c21f7b8da4ba80648d92cfd7ddd849db8bfa1db98c2fa2fe3b2e" } diff --git a/packages/microcosm-build/src/microcosm/build/nz/money_normalization.json b/packages/microcosm-build/src/microcosm/build/nz/money_normalization.json index 270d21bffb..e60aa91809 100644 --- a/packages/microcosm-build/src/microcosm/build/nz/money_normalization.json +++ b/packages/microcosm-build/src/microcosm/build/nz/money_normalization.json @@ -49,7 +49,6 @@ ], "household": [ "mortgage_interest", - "mortgage_principal", "property_tax" ] }, @@ -97,7 +96,7 @@ "central": "donor_cy2024_to_ty2027_central", "high": "donor_cy2024_to_ty2027_high" }, - "disclosure": "Mortgage interest, mortgage principal and property tax age by AWE growth. Max's ruling d1981 (2026-10-26) adopts this as an interim convention and pre-declares a hold-fixed sensitivity (factor 1), which no profile here carries yet (G8-w3)." + "disclosure": "Mortgage interest and property tax age by AWE growth. Max's ruling d1981 (2026-10-26) adopts this as an interim convention and pre-declares a hold-fixed sensitivity (factor 1), which no profile here carries yet (G8-w3)." } }, "cents_suffix": "_cents", @@ -119,6 +118,15 @@ } } }, - "pending": {}, + "pending": { + "household": { + "mortgage_principal": { + "awaits": [ + "Rule 1 (d3058): a donor release that carries household mortgage principal, or a declared derivation from the donor's mortgage balance, interest, origination year and an assumed term" + ], + "reason": "The pinned PolicyEngine-US donor carries no mortgage principal, and the US concept mapping reads it only inside the non-invertible mortgage_payments sum, so CREATE cannot stage it. Under ruling d3058 the build adds this flexibility so a first measurement run can go ahead: no node reads the column, the Accommodation Supplement owner payments read mortgage interest alone, and owners' costs are understated beyond MC8's rates and insurance gap. The column returns to the normalized roster, aged with owner_housing_costs, once it has a producer." + } + } + }, "notes": "The rate is the IRS 2024 yearly average for the New Zealand dollar, quoted in NZD per USD, so a donor amount is multiplied by it. Calendar-2024 money is a declared convention covering flows and asset stocks; the donor monetary basis has not been authenticated against a producing manifest. The US build's PERIOD = 2024 and the exporter's _time_period write provide model-period lineage evidence. Money normalization refuses a donor whose recorded _time_period differs from calendar 2024 (G8-w H1); this runtime check is a consistency check, not authentication. No donor file is opened to establish this declaration. Variants V1 and V2 age with their own aging_index profile (G8-w H2). public_pension_income is dropped at CREATE and is not declared." } diff --git a/packages/microcosm-build/src/microcosm/build/nz/money_normalization_hold_fixed.json b/packages/microcosm-build/src/microcosm/build/nz/money_normalization_hold_fixed.json index a7b5cd192d..d496f3dda5 100644 --- a/packages/microcosm-build/src/microcosm/build/nz/money_normalization_hold_fixed.json +++ b/packages/microcosm-build/src/microcosm/build/nz/money_normalization_hold_fixed.json @@ -49,7 +49,6 @@ ], "household": [ "mortgage_interest", - "mortgage_principal", "property_tax" ] }, @@ -103,6 +102,15 @@ } } }, - "pending": {}, + "pending": { + "household": { + "mortgage_principal": { + "awaits": [ + "Rule 1 (d3058): a donor release that carries household mortgage principal, or a declared derivation from the donor's mortgage balance, interest, origination year and an assumed term" + ], + "reason": "The pinned PolicyEngine-US donor carries no mortgage principal, and the US concept mapping reads it only inside the non-invertible mortgage_payments sum, so CREATE cannot stage it. Under ruling d3058 the build adds this flexibility so a first measurement run can go ahead: no node reads the column, the Accommodation Supplement owner payments read mortgage interest alone, and owners' costs are understated beyond MC8's rates and insurance gap. The column returns to the normalized roster, aged with owner_housing_costs, once it has a producer." + } + } + }, "notes": "The rate is the IRS 2024 yearly average for the New Zealand dollar, quoted in NZD per USD, so a donor amount is multiplied by it. Calendar-2024 money is a declared convention covering flows and asset stocks; the donor monetary basis has not been authenticated against a producing manifest. The US build's PERIOD = 2024 and the exporter's _time_period write provide model-period lineage evidence. Money normalization refuses a donor whose recorded _time_period differs from calendar 2024 (G8-w H1); this runtime check is a consistency check, not authentication. No donor file is opened to establish this declaration. Variants V1 and V2 age with their own aging_index profile (G8-w H2). public_pension_income is dropped at CREATE and is not declared." } diff --git a/packages/microcosm-build/src/microcosm/build/nz/scenarios.json b/packages/microcosm-build/src/microcosm/build/nz/scenarios.json index b74dde0fc3..ab704bb3e8 100644 --- a/packages/microcosm-build/src/microcosm/build/nz/scenarios.json +++ b/packages/microcosm-build/src/microcosm/build/nz/scenarios.json @@ -829,7 +829,6 @@ "tenure", "rent", "mortgage_interest", - "mortgage_principal", "property_tax", "as_area", "as_area_alt" @@ -1819,7 +1818,6 @@ "tenure", "rent", "mortgage_interest", - "mortgage_principal", "property_tax", "as_area", "as_area_alt" @@ -2809,7 +2807,6 @@ "tenure", "rent", "mortgage_interest", - "mortgage_principal", "property_tax", "as_area", "as_area_alt" @@ -4561,7 +4558,6 @@ "entity": "household", "columns": [ "mortgage_interest", - "mortgage_principal", "property_tax" ] } @@ -4621,12 +4617,6 @@ "dtype": "float64", "rewrite": true }, - { - "entity": "household", - "column": "mortgage_principal", - "dtype": "float64", - "rewrite": true - }, { "entity": "household", "column": "property_tax", @@ -4678,11 +4668,6 @@ "column": "mortgage_interest_cents", "dtype": "int64" }, - { - "entity": "household", - "column": "mortgage_principal_cents", - "dtype": "int64" - }, { "entity": "household", "column": "property_tax_cents", @@ -4883,7 +4868,6 @@ "tenure", "rent", "mortgage_interest", - "mortgage_principal", "property_tax" ] } @@ -7944,7 +7928,6 @@ "tenure", "rent", "mortgage_interest", - "mortgage_principal", "property_tax", "as_area", "as_area_alt" @@ -9227,7 +9210,6 @@ "entity": "household", "columns": [ "mortgage_interest", - "mortgage_principal", "property_tax" ] } @@ -9287,12 +9269,6 @@ "dtype": "float64", "rewrite": true }, - { - "entity": "household", - "column": "mortgage_principal", - "dtype": "float64", - "rewrite": true - }, { "entity": "household", "column": "property_tax", @@ -9344,11 +9320,6 @@ "column": "mortgage_interest_cents", "dtype": "int64" }, - { - "entity": "household", - "column": "mortgage_principal_cents", - "dtype": "int64" - }, { "entity": "household", "column": "property_tax_cents", @@ -9549,7 +9520,6 @@ "tenure", "rent", "mortgage_interest", - "mortgage_principal", "property_tax" ] } @@ -12610,7 +12580,6 @@ "tenure", "rent", "mortgage_interest", - "mortgage_principal", "property_tax", "as_area", "as_area_alt" @@ -13893,7 +13862,6 @@ "entity": "household", "columns": [ "mortgage_interest", - "mortgage_principal", "property_tax" ] } @@ -13953,12 +13921,6 @@ "dtype": "float64", "rewrite": true }, - { - "entity": "household", - "column": "mortgage_principal", - "dtype": "float64", - "rewrite": true - }, { "entity": "household", "column": "property_tax", @@ -14010,11 +13972,6 @@ "column": "mortgage_interest_cents", "dtype": "int64" }, - { - "entity": "household", - "column": "mortgage_principal_cents", - "dtype": "int64" - }, { "entity": "household", "column": "property_tax_cents", @@ -14215,7 +14172,6 @@ "tenure", "rent", "mortgage_interest", - "mortgage_principal", "property_tax" ] } @@ -17276,7 +17232,6 @@ "tenure", "rent", "mortgage_interest", - "mortgage_principal", "property_tax", "as_area", "as_area_alt" @@ -18559,7 +18514,6 @@ "entity": "household", "columns": [ "mortgage_interest", - "mortgage_principal", "property_tax" ] } @@ -18619,12 +18573,6 @@ "dtype": "float64", "rewrite": true }, - { - "entity": "household", - "column": "mortgage_principal", - "dtype": "float64", - "rewrite": true - }, { "entity": "household", "column": "property_tax", @@ -18676,11 +18624,6 @@ "column": "mortgage_interest_cents", "dtype": "int64" }, - { - "entity": "household", - "column": "mortgage_principal_cents", - "dtype": "int64" - }, { "entity": "household", "column": "property_tax_cents", @@ -18881,7 +18824,6 @@ "tenure", "rent", "mortgage_interest", - "mortgage_principal", "property_tax" ] } @@ -21942,7 +21884,6 @@ "tenure", "rent", "mortgage_interest", - "mortgage_principal", "property_tax", "as_area", "as_area_alt" @@ -23225,7 +23166,6 @@ "entity": "household", "columns": [ "mortgage_interest", - "mortgage_principal", "property_tax" ] } @@ -23285,12 +23225,6 @@ "dtype": "float64", "rewrite": true }, - { - "entity": "household", - "column": "mortgage_principal", - "dtype": "float64", - "rewrite": true - }, { "entity": "household", "column": "property_tax", @@ -23342,11 +23276,6 @@ "column": "mortgage_interest_cents", "dtype": "int64" }, - { - "entity": "household", - "column": "mortgage_principal_cents", - "dtype": "int64" - }, { "entity": "household", "column": "property_tax_cents", @@ -23547,7 +23476,6 @@ "tenure", "rent", "mortgage_interest", - "mortgage_principal", "property_tax" ] } @@ -26608,7 +26536,6 @@ "tenure", "rent", "mortgage_interest", - "mortgage_principal", "property_tax", "as_area", "as_area_alt" @@ -27891,7 +27818,6 @@ "entity": "household", "columns": [ "mortgage_interest", - "mortgage_principal", "property_tax" ] } @@ -27951,12 +27877,6 @@ "dtype": "float64", "rewrite": true }, - { - "entity": "household", - "column": "mortgage_principal", - "dtype": "float64", - "rewrite": true - }, { "entity": "household", "column": "property_tax", @@ -28008,11 +27928,6 @@ "column": "mortgage_interest_cents", "dtype": "int64" }, - { - "entity": "household", - "column": "mortgage_principal_cents", - "dtype": "int64" - }, { "entity": "household", "column": "property_tax_cents", @@ -28213,7 +28128,6 @@ "tenure", "rent", "mortgage_interest", - "mortgage_principal", "property_tax" ] } @@ -31270,7 +31184,6 @@ "tenure", "rent", "mortgage_interest", - "mortgage_principal", "property_tax", "as_area", "as_area_alt" @@ -32553,7 +32466,6 @@ "entity": "household", "columns": [ "mortgage_interest", - "mortgage_principal", "property_tax" ] } @@ -32613,12 +32525,6 @@ "dtype": "float64", "rewrite": true }, - { - "entity": "household", - "column": "mortgage_principal", - "dtype": "float64", - "rewrite": true - }, { "entity": "household", "column": "property_tax", @@ -32670,11 +32576,6 @@ "column": "mortgage_interest_cents", "dtype": "int64" }, - { - "entity": "household", - "column": "mortgage_principal_cents", - "dtype": "int64" - }, { "entity": "household", "column": "property_tax_cents", @@ -32875,7 +32776,6 @@ "tenure", "rent", "mortgage_interest", - "mortgage_principal", "property_tax" ] } @@ -35936,7 +35836,6 @@ "tenure", "rent", "mortgage_interest", - "mortgage_principal", "property_tax", "as_area", "as_area_alt" @@ -37219,7 +37118,6 @@ "entity": "household", "columns": [ "mortgage_interest", - "mortgage_principal", "property_tax" ] } @@ -37279,12 +37177,6 @@ "dtype": "float64", "rewrite": true }, - { - "entity": "household", - "column": "mortgage_principal", - "dtype": "float64", - "rewrite": true - }, { "entity": "household", "column": "property_tax", @@ -37336,11 +37228,6 @@ "column": "mortgage_interest_cents", "dtype": "int64" }, - { - "entity": "household", - "column": "mortgage_principal_cents", - "dtype": "int64" - }, { "entity": "household", "column": "property_tax_cents", @@ -37541,7 +37428,6 @@ "tenure", "rent", "mortgage_interest", - "mortgage_principal", "property_tax" ] } @@ -40602,7 +40488,6 @@ "tenure", "rent", "mortgage_interest", - "mortgage_principal", "property_tax", "as_area", "as_area_alt" diff --git a/packages/microcosm-build/src/microcosm/build/nz/transport_graph.json b/packages/microcosm-build/src/microcosm/build/nz/transport_graph.json index af33c941a1..fee4434179 100644 --- a/packages/microcosm-build/src/microcosm/build/nz/transport_graph.json +++ b/packages/microcosm-build/src/microcosm/build/nz/transport_graph.json @@ -444,7 +444,6 @@ "entity": "household", "columns": [ "mortgage_interest", - "mortgage_principal", "property_tax" ] } @@ -504,12 +503,6 @@ "dtype": "float64", "rewrite": true }, - { - "entity": "household", - "column": "mortgage_principal", - "dtype": "float64", - "rewrite": true - }, { "entity": "household", "column": "property_tax", @@ -561,11 +554,6 @@ "column": "mortgage_interest_cents", "dtype": "int64" }, - { - "entity": "household", - "column": "mortgage_principal_cents", - "dtype": "int64" - }, { "entity": "household", "column": "property_tax_cents", @@ -763,7 +751,6 @@ "tenure", "rent", "mortgage_interest", - "mortgage_principal", "property_tax" ] } @@ -3823,7 +3810,6 @@ "tenure", "rent", "mortgage_interest", - "mortgage_principal", "property_tax", "as_area", "as_area_alt" @@ -4186,7 +4172,6 @@ "entity": "household", "columns": [ "mortgage_interest", - "mortgage_principal", "property_tax", "tenure" ] @@ -4464,7 +4449,6 @@ "columns": [ "household_region_code", "mortgage_interest", - "mortgage_principal", "property_tax", "rent", "tenure" @@ -4886,7 +4870,6 @@ "donor_support_stratum", "household_region_code", "mortgage_interest", - "mortgage_principal", "property_tax", "rent", "source_household_id", @@ -5159,7 +5142,6 @@ "donor_support_stratum", "household_region_code", "mortgage_interest", - "mortgage_principal", "property_tax", "rent", "source_household_id", diff --git a/packages/microcosm-build/tests/engine_free/shared/test_nz_money_normalization.py b/packages/microcosm-build/tests/engine_free/shared/test_nz_money_normalization.py index e2697efd70..e6ec11a8fe 100644 --- a/packages/microcosm-build/tests/engine_free/shared/test_nz_money_normalization.py +++ b/packages/microcosm-build/tests/engine_free/shared/test_nz_money_normalization.py @@ -196,16 +196,25 @@ def test_normalized_routes_follow_the_design_table_and_the_concept_schema(): ("person", "private_pension_income"): "pensions", ("person", "liquid_financial_assets"): "consumer_prices", ("household", "mortgage_interest"): "owner_housing_costs", - ("household", "mortgage_principal"): "owner_housing_costs", ("household", "property_tax"): "owner_housing_costs", } rosters = money_column_rosters(declaration) assert {key for key, (route, _) in rosters.items() if route != "normalized"} == { ("person", "employment_income"), ("household", "rent"), + ("household", "mortgage_principal"), } - assert {route for route, _ in rosters.values()} == {"normalized", "quantile_mapped"} - assert declaration["pending"] == {} + assert {route for route, _ in rosters.values()} == { + "normalized", + "quantile_mapped", + "pending", + } + # Rule 1 (d3058): the pinned donor carries no principal, so it waits. + assert set(declaration["pending"]) == {"household"} + assert set(declaration["pending"]["household"]) == {"mortgage_principal"} + route, awaits = rosters["household", "mortgage_principal"] + assert route == "pending" + assert awaits[0].startswith("Rule 1 (d3058):") assert rosters["person", "employment_income"][1][0].startswith("P1:") assert rosters["household", "rent"][1][0].startswith("C1:") assert rosters["person", "liquid_financial_assets"] == ("normalized", ()) diff --git a/packages/microcosm-build/tests/engine_free/shared/test_nz_transport_declarations.py b/packages/microcosm-build/tests/engine_free/shared/test_nz_transport_declarations.py index bebab374de..62678ee2ca 100644 --- a/packages/microcosm-build/tests/engine_free/shared/test_nz_transport_declarations.py +++ b/packages/microcosm-build/tests/engine_free/shared/test_nz_transport_declarations.py @@ -676,47 +676,50 @@ def test_nz_executable_support_keeps_region99_separate_from_ta999(): } -def _nz_composition_spec_and_config(): - """Supply synthetic engine refs and CREATE's inventory. +# D4 (d3058): CREATE's inventory on the pinned donor, as the transport store +# records it. prepare_create_outputs declares every non-structural column of +# the CREATE frame with its dtype (transport/cli.py), and +# prepare_transport_build passes all of them as create_outputs. +_CREATE_INVENTORY = ( + paths_for("microcosm-build").tests + / "fixtures/nz/create_inventory_populace_us_48b9d479.json" +) +# The graph reads these, and CREATE on the pinned donor does not give them yet. +# d3058 rules 2, 4 and 5 stage them in the donor reader; that change must +# refresh the fixture from its CREATE probe and empty this mapping. +_AWAITING_DONOR_STAGING = { + ("household", "tenure"): "string", + ("person", "enrolled_full_time"): "bool", + ("person", "legal_marital_status"): "string", +} - The packaged graph declares every money producer, and the packaged - bindings carry the engine pins, so the compiler checks the complete - packaged node and population structure with no synthetic node or pin. The - synthetic engine refs certify no runtime result. CREATE's inventory holds - canonical concepts and unit outputs only: no bridge or region column - enters as a root. - """ - from microcosm.graph import Owned - spec = _spec() - resources = spec["resources"] - compose.validate_transport_activation(spec) +@cache +def _real_create_inventory(): + rows = json.loads(_CREATE_INVENTORY.read_bytes())["columns"] + inventory = {(row["entity"], row["column"]): row["dtype"] for row in rows} + assert len(inventory) == len(rows), "a CREATE inventory column repeats" + return inventory - rows = _instantiated_nz_rows(spec) - produced = { - (output["entity"], output["column"]) - for row in rows - for output in row.get("outputs", ()) - if not output.get("rewrite") - } - needed = { - (item["entity"], column) - for row in rows - for item in row.get("inputs", ()) - for column in item["columns"] - } - produced - assert needed.isdisjoint(_BRIDGE_AND_REGION), sorted(needed & _BRIDGE_AND_REGION) - from microcosm.frame import EntitySchema + +def _canonical_dtypes(): + """Each carried concept's column dtype, as CREATE would declare it.""" from microcosm.frame.concepts import CONCEPTS, TransportRule - from microcosm.frame.unit_construction import BenefitUnitRule kinds = {"int": "int64", "float": "float64", "bool": "bool", "str": "string"} - inventory = { + return { (item.entity, item.name): "Int64" if item.nullable else kinds[item.dtype] for item in CONCEPTS if item.transport is not TransportRule.DROP } - rule = BenefitUnitRule.from_spec(resources["benefit_unit_rule"]) + + +def _structural_and_unit_columns(spec): + """CREATE's structural ids and memberships, and its non-concept outputs.""" + from microcosm.frame import EntitySchema + from microcosm.frame.unit_construction import BenefitUnitRule + + rule = BenefitUnitRule.from_spec(spec["resources"]["benefit_unit_rule"]) schema = EntitySchema(group_entities=("household", rule.entity)) automatic = { (schema.person_entity, schema.person_id_column), @@ -726,19 +729,59 @@ def _nz_composition_spec_and_config(): ), *((group, schema.id_column(group)) for group in schema.group_entities), } - # CLI preparation excludes these columns; frame projection carries them. - # A node must not name them as data reads that require a column owner. - needed -= automatic - inventory.update( - { - ("household", "donor_support_stratum"): "string", - (rule.entity, rule.household_column): "int64", - (rule.entity, rule.head_column): "int64", - (rule.entity, rule.source_household_column): "string", - } - ) + unit = { + ("household", "donor_support_stratum"): "string", + (rule.entity, rule.household_column): "int64", + (rule.entity, rule.head_column): "int64", + (rule.entity, rule.source_household_column): "string", + } + return automatic, unit + + +def _nz_root_reads(spec): + """The columns the instantiated rows read and no node produces. + + CLI preparation excludes the structural columns and frame projection + carries them, so a node must not name them as reads that need an owner. + """ + rows = _instantiated_nz_rows(spec) + produced = { + (output["entity"], output["column"]) + for row in rows + for output in row.get("outputs", ()) + if not output.get("rewrite") + } + needed = { + (item["entity"], column) + for row in rows + for item in row.get("inputs", ()) + for column in item["columns"] + } - produced + assert needed.isdisjoint(_BRIDGE_AND_REGION), sorted(needed & _BRIDGE_AND_REGION) + automatic, _ = _structural_and_unit_columns(spec) + return needed - automatic + + +def _nz_composition_spec_and_config(): + """Supply synthetic engine refs and CREATE's real inventory. + + The packaged graph declares every money producer, and the packaged + bindings carry the engine pins, so the compiler checks the complete + packaged node and population structure with no synthetic node or pin. The + synthetic engine refs certify no runtime result. CREATE's outputs are the + inventory the pinned donor gave, plus the columns awaiting donor staging + at their concept dtypes. No bridge or region column enters as a root. + """ + from microcosm.graph import Owned + + spec = _spec() + resources = spec["resources"] + compose.validate_transport_activation(spec) + needed = _nz_root_reads(spec) + inventory = {**_real_create_inventory(), **_AWAITING_DONOR_STAGING} assert needed <= inventory.keys(), ( - "The declaration reads donor columns outside the canonical concepts and actual CREATE/unit outputs", + "The declaration reads donor columns that neither the real CREATE " + "inventory nor the declared staging gap holds", sorted(needed - inventory.keys()), ) config = compose.TransportGraphConfig( @@ -747,13 +790,111 @@ def _nz_composition_spec_and_config(): for row in resources["axiom_rules_bindings"]["bindings"] }, create_outputs=tuple( - Owned(entity, column, inventory[entity, column]) - for entity, column in sorted(needed) + Owned(entity, column, dtype) + for (entity, column), dtype in sorted(inventory.items()) ), ) return spec, config +def test_nz_reads_exactly_the_real_create_inventory_and_the_declared_staging_gap(): + """D4: the graph's donor roots, checked against the pinned donor's CREATE. + + Attempt 7 refused at graph compile on columns CREATE never gave, because + the inventory above used to be built from the graph's own reads. Compile + names only the first unowned read (graph decl.py reader_of), so the gap is + pinned here as an exact set. + """ + real = _real_create_inventory() + assert real.keys().isdisjoint(_AWAITING_DONOR_STAGING) + assert _nz_root_reads(_spec()) - real.keys() == set(_AWAITING_DONOR_STAGING) + + +def test_the_staging_gap_declares_the_canonical_concept_dtypes(): + canonical = _canonical_dtypes() + assert _AWAITING_DONOR_STAGING == { + key: canonical[key] for key in _AWAITING_DONOR_STAGING + } + + +def test_every_real_create_column_is_a_canonical_concept_or_unit_output(): + canonical = _canonical_dtypes() + _, unit = _structural_and_unit_columns(_spec()) + real = _real_create_inventory() + assert real.keys() <= canonical.keys() | unit.keys(), sorted( + real.keys() - canonical.keys() - unit.keys() + ) + assert {key: real[key] for key in unit} == unit + # The one dtype gap: the concept schema says the reference person is never + # null, but CREATE emits nullable Int64. Graph compile checks dtypes on + # rewrites, row masks and the mass partition (microcosm.graph.decl), and + # the NZ graph compiles with this gap; a new gap fails here. + assert { + key for key in real.keys() & canonical.keys() if real[key] != canonical[key] + } == {("household", "reference_person_id")} + + +def test_the_create_inventory_fixture_is_the_pinned_donors_stored_payload(): + """A donor re-pin or a CREATE change must refresh the fixture.""" + provenance = json.loads( + _CREATE_INVENTORY.with_name( + _CREATE_INVENTORY.name + ".provenance.json" + ).read_text() + ) + assert ( + sha256(_CREATE_INVENTORY.read_bytes()).hexdigest() + == provenance["payload_sha256"] + ) + spec = _spec() + donor = spec["resources"]["transport_inputs"]["donor"] + fields = ("sha256", "size_bytes", "revision") + assert {key: provenance["donor"][key] for key in fields} == { + key: donor[key] for key in fields + } + (create,) = ( + row + for row in spec["resources"]["transport_graph"]["nodes"] + if row.get("structural") == "create" + ) + assert create["kernel"] == provenance["create_kernel"] + + +def test_nz_refuses_the_real_inventory_alone_at_graph_compile(): + """Without the staged columns, NZ cannot compose on the pinned donor.""" + import dataclasses + + from microcosm.graph import GraphError + + spec, config = _nz_composition_spec_and_config() + real = dataclasses.replace( + config, + create_outputs=tuple( + owned + for owned in config.create_outputs + if (owned.entity, owned.column) not in _AWAITING_DONOR_STAGING + ), + ) + missing = "|".join( + re.escape(f"{entity}.{column}") for entity, column in _AWAITING_DONOR_STAGING + ) + with pytest.raises(GraphError, match=rf"reads ({missing}), which no node owns"): + compose.compose_transport_graph(spec, real) + + +def test_nz_checkpoints_keep_the_gate_report_before_export(): + """d3058: a run that export.prepare refuses still writes the gate closure. + + Extension checkpoints write their manifests before export.prepare runs + (transport/cli.py). entitlement.py appends the cell diagnostics collector + after the declared entries. + """ + assert compose.transport_endpoints(_spec())["checkpoints"] == ( + "nz.as.bands", + "nz.gates.terminal", + "nz.as.bands.cell_diagnostics", + ) + + def test_nz_terminal_filter_keeps_the_skeletons_predecessors_and_ancestry(): from microcosm.graph import compile_graph diff --git a/packages/microcosm-build/tests/engine_free/shared/test_transport_evidence_kernels.py b/packages/microcosm-build/tests/engine_free/shared/test_transport_evidence_kernels.py index 2a89ce08c5..3e96f22df9 100644 --- a/packages/microcosm-build/tests/engine_free/shared/test_transport_evidence_kernels.py +++ b/packages/microcosm-build/tests/engine_free/shared/test_transport_evidence_kernels.py @@ -2821,12 +2821,15 @@ def test_the_nz_roster_classes(self, nz_spec) -> None: assert counts == { "closure_default": 92, "derived": 323, - "normalized": 11, + # Rule 1 (d3058): mortgage principal is pending, so no node reads + # it and the roster leaves it out. + "normalized": 10, "copied": 3, "quantile_mapped": 2, "structural": 6, } classes = {(row["entity"], row["column"]): row["class"] for row in roster} + assert ("household", "mortgage_principal") not in classes assert classes["household", "rent"] == "quantile_mapped" assert classes["person", "liquid_financial_assets"] == "normalized" derived = [row for row in roster if row["class"] == "derived"] diff --git a/packages/microcosm-build/tests/fixtures/nz/create_inventory_populace_us_48b9d479.json b/packages/microcosm-build/tests/fixtures/nz/create_inventory_populace_us_48b9d479.json new file mode 100644 index 0000000000..33bc9bf906 --- /dev/null +++ b/packages/microcosm-build/tests/fixtures/nz/create_inventory_populace_us_48b9d479.json @@ -0,0 +1 @@ +{"columns":[{"column":"age","dtype":"int64","entity":"person"},{"column":"sex","dtype":"string","entity":"person"},{"column":"employment_income","dtype":"float64","entity":"person"},{"column":"nonfarm_self_employment_income","dtype":"float64","entity":"person"},{"column":"farm_self_employment_income","dtype":"float64","entity":"person"},{"column":"interest_income","dtype":"float64","entity":"person"},{"column":"dividend_income","dtype":"float64","entity":"person"},{"column":"rental_income","dtype":"float64","entity":"person"},{"column":"realized_capital_gains","dtype":"float64","entity":"person"},{"column":"private_pension_income","dtype":"float64","entity":"person"},{"column":"usual_weekly_hours","dtype":"float64","entity":"person"},{"column":"has_disability","dtype":"bool","entity":"person"},{"column":"partner_person_id","dtype":"Int64","entity":"person"},{"column":"parent_1_person_id","dtype":"Int64","entity":"person"},{"column":"parent_2_person_id","dtype":"Int64","entity":"person"},{"column":"liquid_financial_assets","dtype":"float64","entity":"person"},{"column":"take_up_seed","dtype":"float64","entity":"person"},{"column":"reference_person_id","dtype":"Int64","entity":"household"},{"column":"rent","dtype":"float64","entity":"household"},{"column":"mortgage_interest","dtype":"float64","entity":"household"},{"column":"property_tax","dtype":"float64","entity":"household"},{"column":"source_household_id","dtype":"string","entity":"household"},{"column":"donor_support_stratum","dtype":"string","entity":"household"},{"column":"family_household_id","dtype":"int64","entity":"family"},{"column":"family_head_person_id","dtype":"int64","entity":"family"},{"column":"family_source_household_id","dtype":"string","entity":"family"}]} \ No newline at end of file diff --git a/packages/microcosm-build/tests/fixtures/nz/create_inventory_populace_us_48b9d479.json.provenance.json b/packages/microcosm-build/tests/fixtures/nz/create_inventory_populace_us_48b9d479.json.provenance.json new file mode 100644 index 0000000000..2ca6bdeac6 --- /dev/null +++ b/packages/microcosm-build/tests/fixtures/nz/create_inventory_populace_us_48b9d479.json.provenance.json @@ -0,0 +1,20 @@ +{ + "awaiting_donor_staging": "household.tenure, person.enrolled_full_time and person.legal_marital_status are read by the NZ graph but absent here; ruling d3058 rules 2, 4 and 5 stage them. test_nz_transport_declarations.py declares them in _AWAITING_DONOR_STAGING until that staging lands.", + "captured": { + "commit": "67ab33e8a3fb0679dee1d3c842df2c80d4c8fbd0", + "date": "2026-11-16", + "how": "NZ step 4 attempt 7: prepare_create_outputs on the pinned donor; that run then refused at graph compile, because the NZ graph needed columns this inventory lacks" + }, + "create_kernel": "transport.create@1", + "donor": { + "revision": "populace-us-2024-buildp-sparse-rmloss100-cae8640-20260728T011454Z", + "sha256": "48b9d479fb4fd1c3537f9383ce4697d130b6f618658409d74f6233c43b994c7e", + "size_bytes": 462915783 + }, + "kind": "nz_create_inventory_fixture", + "note": "Two of create@1's hashed modules, build/country_spec.py and build/reference_factors.py, changed additively between the capture commit and 402c3587df, so the store's inventory key differs; no column-producing module changed (frame/transport.py, frame/concepts.py, transport/population_kernels.py, the US concept mapping). At 402c3587df, under the locked numpy 2.4.6, pandas 3.0.3 and tables 3.11.1, create@1's implementation hash is 02279dc47292426997e1d4f477411b860475c00d299cd508f41f21fbf5ae0677.", + "payload_format": "microcosm.transport.create-inventory/1 store payload: CREATE's non-structural output columns with dtypes (transport/cli.py prepare_create_outputs)", + "payload_sha256": "305107d61aacfbeebfb1c693dc9440f652441d273257a0460e1f7291203d6b6d", + "refresh": "Rerun prepare_create_outputs(spec, sources, resume='forbid') on the pinned donor and replace both files whenever the donor pin or CREATE's staging changes; the staging change must also empty _AWAITING_DONOR_STAGING.", + "schema_version": 1 +} diff --git a/packages/microcosm-build/tests/golden/nz_country_spec.json b/packages/microcosm-build/tests/golden/nz_country_spec.json index 211f04bfb3..27c4577db5 100644 --- a/packages/microcosm-build/tests/golden/nz_country_spec.json +++ b/packages/microcosm-build/tests/golden/nz_country_spec.json @@ -1,6 +1,6 @@ { "country": "nz", - "fingerprint": "8367a4578c093d50af51a4ece40b03e5cb814d09d8c05712c316cd3c29d2b435", + "fingerprint": "4214fdfade3c910bf8d8180c3d65e1953dbdbb3190642fed6e095b461bf88fd1", "gate_ids": [ "calibration_per_family_fit", "demography_per_family_fit", @@ -50,13 +50,13 @@ "calibration_bindings.json": "26983da893770a7ea915d9eee70c47f310654ffe0fdffcc0327ac5a34c01bf50", "calibration_settings.json": "56e4d1da8468245da6bd41daf263425cc65e4e9c9f11ff45eee459d3aed1989e", "chronicle_feed.json": "598f4f50c0e68e28e7824470e262815bae88344c2ab7248339034841054dbffc", - "concept_mapping.json": "1645d1974fd24e754361bb585cff2bff8905c1f742014c126cb4ed818227774b", + "concept_mapping.json": "1d527c093870839cf535f34f8b4d4ad477547ed1aa57d7acb35087ce0ec974e8", "country_package.json": "53deee4d1ff74730a7ef0743c3ab9e42ee3352b41c2df6ae516b4283833b5d84", "currency_bridge.json": "ddf6fdb30ce2b930496fcfe18e1c2848443ae0a5dbb4100e109403ec3620c6aa", "earnings_bands.json": "7c9f6ae99bf4346fba0ae315037b3d65b59472cd588a1573e7a3f3091c168342", - "entitlement_graph.json": "991c41aa78d64e04ccbdb6f846ee2bc4a0152e102a8dc241d2b1e725cb2300d3", - "export_contract.json": "4d388236cc3d3382501f5cfae8eae44b661fba6919681965eaa3fe4e032efe86", - "export_replay_bindings.json": "1618f9935a12ff6128f542c76521fd1140c52448077168d483e7e56a4773f5ed", + "entitlement_graph.json": "89ac989202d339f681131c7083437333de5d40bc8d14ab69f1ce6ea494aa2d99", + "export_contract.json": "3fb78dd3a6d1b0f59b6a2df8883f1a175b07a2a2f57f35c1eb89a8802c983993", + "export_replay_bindings.json": "bc2e8b8a838e02b76955cf22b735bfc172495b6918d3b7f6594da67d0a02a136", "family_reconciliation.json": "20e3f9f3ce6266d57828d721c99d15bd3642e6c6314a7076ec38972de02bc69e", "gap_annualisation.json": "54762c18c549d2f1f35a630358080e3d581abab901b52a62b4f279830f3f8536", "gates.json": "4bc5b4ebb2e8a2114d74b7d403e1f2f334913e4446159546aa12ffb5c0c8e201", @@ -67,8 +67,8 @@ "income_diagnostic_references.json": "2a050e0ce4cdf5a338c1722604879fa911f2fe845654ff5780511af435fac494", "income_measurements.json": "21e05023240c3dfdc2e61685a4de0a9e219215bd0c43f93963d95d466dd8b0e1", "mass_references.json": "1c1e7e6e1af8917917fc84072ed39b4298ad0444f04906fa6a594ebc2e48a926", - "money_normalization.json": "34fc0aaa77a188cb05801c640e5862cae9072be3f83d6533b5c8439227beb443", - "money_normalization_hold_fixed.json": "7ad09195e5504bb22fe40e05d290c07d08b7802bafb6a111dd13f218007fb7e2", + "money_normalization.json": "008a411162f8394766b870b83f593efa40ea8c58dd058522d005d1480180b2f1", + "money_normalization_hold_fixed.json": "35f688c9510b9b9cbb2697163ff16c63d72dbe0e6954161df9f9fba152d98354", "msd_benefit_rates_20260401.json": "1d03bcbe2ff34a27e6efe42e69871a71271c4e16fe9e3327f79acb8dba7d6b26", "msd_pre_activation_reconciliation.json": "c2cec585b5714ab7ab5505581e890aa6393d7750668802386bef6a4e5d58682c", "precal_references.json": "ace08337205f64437d9dce0524d52689eeb0310ad6b7c4d2896e9bfa0536284b", @@ -82,7 +82,7 @@ "release_contract.json": "6cd5e3a4a2bf30e4025e04e964c393b24040937d13db7e6a07b3966a55f3b114", "rent_bands.json": "1feccbe80fe662bf14a11ab1a3a4047dd8cf62d0f813112aa2aa248799e620ed", "reporting_classifiers.json": "60f0936a9cab3776affda81e2612174dbc2192947630e9cc037b9b11277ca4d2", - "scenarios.json": "c6b797a7175cbc7e23972e467e28be8a3a5cca914e657ead52bcd5508b284539", + "scenarios.json": "86e102bb3f301ee78238f020fef0839dbbad54b367b7b1e9ce7824956f2d1135", "source_stages.json": "cc82c68878ac0fc07ecbd796c1a66de6f34786ef8785125046425c37f26aff31", "spec/bundle.yaml": "e9716ce827e9006d4efdc392e7aaf9cbc33c16112a8fbc423e8f3e74ec506d8e", "spec/catalogs.yaml": "3ab2025af39cba93ead707b9463e428430a45b30696a43d0906cbcd97ed36631", @@ -92,7 +92,7 @@ "spec/vintages.yaml": "1ecc1a3f952bd25b834c394314e8c933ddb5b095fd64ba492dddb03e3cdd803e", "target_references.json": "6af5258a4e3451d7742ab9f3b454fec9e0bd7cf320fab6e784ff002a8be211c8", "transport_atomic_geography_support.json": "53465827f67c87aaf5a06c305c082cbf1e6cdf28f3843e853d1e012635517d10", - "transport_graph.json": "1fc558bedfd88d16f31afd86b148c810be33c11ffb2851379ea7358d3e9c6257", + "transport_graph.json": "4ada151226baf62377dd8da64314563cb15e0fd4caa6c757b4d0754b451271da", "transport_inputs.json": "16d3957214d6305e3d3f41fe6343143a411d6055c75c43d3f171db3ee659ec2d" }, "resources": [ diff --git a/packages/microcosm-frame/src/microcosm/frame/adapters/axiom_concept_mappings/nz.json b/packages/microcosm-frame/src/microcosm/frame/adapters/axiom_concept_mappings/nz.json index 613f3e1e21..69668231b8 100644 --- a/packages/microcosm-frame/src/microcosm/frame/adapters/axiom_concept_mappings/nz.json +++ b/packages/microcosm-frame/src/microcosm/frame/adapters/axiom_concept_mappings/nz.json @@ -643,18 +643,17 @@ { "canonical_input": "nz:statutes/social_security/accommodation_supplement/core#input.accommodation_supplement_owner_weekly_required_payments", "concepts": [ - "fact:household.mortgage_interest", - "fact:household.mortgage_principal" + "fact:household.mortgage_interest" ], "engine_entity": "Family", "engine_input": "accommodation_supplement_owner_weekly_required_payments", "group_rule": "allocate_to_reference_unit", "module": "nz/statutes/social_security/accommodation_supplement/core.yaml", - "note": "Consumed in nz/statutes/social_security/accommodation_supplement/core.yaml by accommodation_supplement_weekly_accommodation_costs (source: Social Security Act 2018 s 65AAA definition of accommodation costs), whose first branch returns it when accommodation_supplement_owns_premises_and_not_joint_owner_with_resident holds; the result feeds the Schedule 4 Part 7 weekly formula, so the value is weekly although the rule declares period Year. Read as the household's annual mortgage interest plus mortgage principal repaid, summed and scaled by 1/52 (one scaled_sum, since a binding takes one transform), on the family that contains the household reference person and zero on the household's other families. Differences: the module does not define the owner's payments; rates (property tax), insurance and other home payments are not added, which understates owners' costs (method card MC8); the concept is what the household repaid in the year, not what the mortgage requires; and a second family in an owner-occupied household gets zero.", + "note": "Consumed in nz/statutes/social_security/accommodation_supplement/core.yaml by accommodation_supplement_weekly_accommodation_costs (source: Social Security Act 2018 s 65AAA definition of accommodation costs), whose first branch returns it when accommodation_supplement_owns_premises_and_not_joint_owner_with_resident holds; the result feeds the Schedule 4 Part 7 weekly formula, so the value is weekly although the rule declares period Year. Read as the household's annual mortgage interest scaled by 1/52, on the family that contains the household reference person and zero on the household's other families. Differences: the module does not define the owner's payments; mortgage principal repaid is left out for now, because the pinned PolicyEngine-US donor carries none and money normalization routes it pending (an interim flexibility under ruling d3058 so a first measurement run can go ahead; fact:household.mortgage_principal is listed as unmapped); rates (property tax), insurance and other home payments are not added either; both omissions understate owners' costs (method card MC8); the concept is the interest the household paid in the year, not what the mortgage requires; and a second family in an owner-occupied household gets zero.", "relation": "approximate", "transform": { "factor": 0.019230769230769232, - "kind": "scaled_sum" + "kind": "scale" } }, { @@ -1510,6 +1509,7 @@ "input_declaration": "usage_inferred", "structural_inputs": [], "unmapped": { + "fact:household.mortgage_principal": "The only input that would take it, accommodation_supplement_owner_weekly_required_payments (Family) in statutes/social_security/accommodation_supplement/core.yaml, reads mortgage interest alone for now: the pinned PolicyEngine-US donor carries no mortgage principal (its mapping reads principal only inside the non-invertible mortgage_payments sum), so money_normalization.json routes household.mortgage_principal pending and no transport node reads it. This is an interim flexibility under ruling d3058 for a first measurement run. Once a donor carries principal, or the build derives it from the donor's mortgage balance, interest, origination year and an assumed term, the candidate is to restore scaled_sum over mortgage_interest and mortgage_principal with factor 1/52 (approximate).", "fact:household.property_tax": "The only rates input, rr_rates_payable_before_rebate (Person) in statutes/rates_rebates/rates_rebate.yaml, cannot be bound at 6fe181f, because the dense engine could not compile that module and nz.json lists it only under cli_walk_inputs, which the adapter's surface loader does not read; once the module compiles, allocate_to_reference_person of property_tax is the candidate (approximate, because the ratepayer need not be the reference person).", "fact:household.source_household_id": "Original donor household lineage is build provenance and weight diagnostic support, not a rulespec-nz legal input.", "fact:person.educational_attainment": "rulespec-nz at 6fe181f has no input for completed education: no rule or input name mentions a qualification, degree, diploma or attainment level; the education inputs are current enrollment or school attendance (this mapping binds some of them to education_enrollment and enrolled_full_time); and young_person_is_study_ready is what youth_young_parent_payment/core.yaml calls an agency-adjudicated composite input (s 50).", diff --git a/packages/microcosm-frame/tests/engine_free/shared/test_group_encode.py b/packages/microcosm-frame/tests/engine_free/shared/test_group_encode.py index fd1acf89e3..3ab5d4534c 100644 --- a/packages/microcosm-frame/tests/engine_free/shared/test_group_encode.py +++ b/packages/microcosm-frame/tests/engine_free/shared/test_group_encode.py @@ -1400,8 +1400,9 @@ def test_hand_computed_households_get_the_supplement_inputs(self) -> None: assert table[name].tolist() == expected, name income = self.OWN_WEEKLY_INCOME amounts = { - # (15,600 + 5,200) / 52, on the family holding the reference person. - "accommodation_supplement_owner_weekly_required_payments": [400.0, 0, 0], + # 15,600 / 52, interest only: the 5,200 of principal is unmapped + # (d3058) and not read. On the family holding the reference person. + "accommodation_supplement_owner_weekly_required_payments": [300.0, 0, 0], # 15,600 / 52. "accommodation_supplement_weekly_rent_paid": [0, 0, 300.0], # Summed over each family's members. diff --git a/packages/microcosm-frame/tests/golden/concept-coverage/axiom-nz.json b/packages/microcosm-frame/tests/golden/concept-coverage/axiom-nz.json index c609adf45d..5873a9d4e6 100644 --- a/packages/microcosm-frame/tests/golden/concept-coverage/axiom-nz.json +++ b/packages/microcosm-frame/tests/golden/concept-coverage/axiom-nz.json @@ -7,13 +7,6 @@ "name": "accommodation_supplement_owner_weekly_required_payments" } ], - "fact:household.mortgage_principal": [ - { - "entity": "Family", - "module": "nz/statutes/social_security/accommodation_supplement/core.yaml", - "name": "accommodation_supplement_owner_weekly_required_payments" - } - ], "fact:household.reference_person_id": [ { "entity": "Family", @@ -4289,6 +4282,7 @@ ], "unknown_inputs": [], "unmapped_concepts": { + "fact:household.mortgage_principal": "The only input that would take it, accommodation_supplement_owner_weekly_required_payments (Family) in statutes/social_security/accommodation_supplement/core.yaml, reads mortgage interest alone for now: the pinned PolicyEngine-US donor carries no mortgage principal (its mapping reads principal only inside the non-invertible mortgage_payments sum), so money_normalization.json routes household.mortgage_principal pending and no transport node reads it. This is an interim flexibility under ruling d3058 for a first measurement run. Once a donor carries principal, or the build derives it from the donor's mortgage balance, interest, origination year and an assumed term, the candidate is to restore scaled_sum over mortgage_interest and mortgage_principal with factor 1/52 (approximate).", "fact:household.property_tax": "The only rates input, rr_rates_payable_before_rebate (Person) in statutes/rates_rebates/rates_rebate.yaml, cannot be bound at 6fe181f, because the dense engine could not compile that module and nz.json lists it only under cli_walk_inputs, which the adapter's surface loader does not read; once the module compiles, allocate_to_reference_person of property_tax is the candidate (approximate, because the ratepayer need not be the reference person).", "fact:household.source_household_id": "Original donor household lineage is build provenance and weight diagnostic support, not a rulespec-nz legal input.", "fact:person.educational_attainment": "rulespec-nz at 6fe181f has no input for completed education: no rule or input name mentions a qualification, degree, diploma or attainment level; the education inputs are current enrollment or school attendance (this mapping binds some of them to education_enrollment and enrolled_full_time); and young_person_is_study_ready is what youth_young_parent_payment/core.yaml calls an agency-adjudicated composite input (s 50).", diff --git a/tools/build_nz_entitlement_graph.py b/tools/build_nz_entitlement_graph.py index 43b44a121f..5c862882d5 100644 --- a/tools/build_nz_entitlement_graph.py +++ b/tools/build_nz_entitlement_graph.py @@ -665,7 +665,14 @@ def documents(nz=NZ): "baseline_scenario": "S0", }, "package": {"id": "nz.package", "artifact_name": "bands"}, - "checkpoints": ["nz.as.bands"], + # d3058: the nz.gates.terminal checkpoint writes the manifest of the + # terminal gate closure (calibration diagnostics, the six evidence + # nodes and the battery) before export.prepare refuses on a blocking + # gate report; no gate changes. entitlement.py appends the cell + # diagnostics collector after these entries, but the collector + # feeds the terminal battery, so it executes inside the + # nz.gates.terminal checkpoint. + "checkpoints": ["nz.as.bands", "nz.gates.terminal"], # R2C-29 (G8-x1): R2C-3's VSI, VEX and VPT evidence is each variant's # own gap, which exists only when that variant's calibration and # entitlement branch ran. diff --git a/tools/build_nz_transport_graph.py b/tools/build_nz_transport_graph.py index a4259d978f..0c38a7b753 100644 --- a/tools/build_nz_transport_graph.py +++ b/tools/build_nz_transport_graph.py @@ -157,7 +157,6 @@ def raw_slices(): "tenure", "rent", "mortgage_interest", - "mortgage_principal", "property_tax", ], "family": [ @@ -1260,7 +1259,6 @@ def documents(): "tenure", "rent", "mortgage_interest", - "mortgage_principal", "property_tax", ] ) From 358e9432a8caa452b0639b6dd3c420748122e426 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Thu, 19 Nov 2026 23:58:26 +0000 Subject: [PATCH 2/4] Say which nodes the terminal checkpoint adds in the changelog The terminal gate closure also holds two evidence nodes the calibration checkpoint already records, so name the six that no earlier checkpoint records instead of calling them the closure's six. Co-Authored-By: Claude Opus 5.5 --- changelog.d/nz-gate-report-checkpoint.changed.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/nz-gate-report-checkpoint.changed.md b/changelog.d/nz-gate-report-checkpoint.changed.md index cfcdbf2818..2bcffd87b5 100644 --- a/changelog.d/nz-gate-report-checkpoint.changed.md +++ b/changelog.d/nz-gate-report-checkpoint.changed.md @@ -1 +1 @@ -New Zealand's entitlement declaration adds `nz.gates.terminal` to its checkpoints (ruling d3058), so a run keeps the manifest of the terminal gate closure (the calibration diagnostics, the six evidence nodes and the battery) when `export.prepare` refuses on a blocking gate report. No gate changes, and no node key moves. A run now writes three extension checkpoint manifests instead of two. The cell diagnostics collector feeds the terminal battery, so it now executes inside the `nz.gates.terminal` checkpoint, and the third manifest records it from the store. One trade-off follows: if the calibration diagnostics or one of the six evidence nodes raises, the run stops before the collector runs, and the cell diagnostics manifest that the old order kept is not written. +New Zealand's entitlement declaration adds `nz.gates.terminal` to its checkpoints (ruling d3058), so a run keeps the manifest of the terminal gate closure when `export.prepare` refuses on a blocking gate report. That manifest includes the calibration diagnostics, six evidence nodes and the battery, which no earlier checkpoint records. No gate changes, and no node key moves. A run now writes three extension checkpoint manifests instead of two. The cell diagnostics collector feeds the terminal battery, so it now executes inside the `nz.gates.terminal` checkpoint, and the third manifest records it from the store. One trade-off follows: if the calibration diagnostics or one of those six evidence nodes raises, the run stops before the collector runs, and the cell diagnostics manifest that the old order kept is not written. From d1022551871ac876b2d871f534c84abe664dff39 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Fri, 20 Nov 2026 17:46:52 +0000 Subject: [PATCH 3/4] Say what the CREATE inventory fixture test can and cannot detect The test checks the fixture's payload digest, the donor's identity and the CREATE kernel ref. Its docstring claimed any CREATE change would fail it. A staging change under the same kernel ref passes, so the docstring now says so and points to the provenance's refresh rule. Co-Authored-By: Claude Fable 5.2 --- .../engine_free/shared/test_nz_transport_declarations.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/microcosm-build/tests/engine_free/shared/test_nz_transport_declarations.py b/packages/microcosm-build/tests/engine_free/shared/test_nz_transport_declarations.py index 62678ee2ca..11419fb43b 100644 --- a/packages/microcosm-build/tests/engine_free/shared/test_nz_transport_declarations.py +++ b/packages/microcosm-build/tests/engine_free/shared/test_nz_transport_declarations.py @@ -835,7 +835,12 @@ def test_every_real_create_column_is_a_canonical_concept_or_unit_output(): def test_the_create_inventory_fixture_is_the_pinned_donors_stored_payload(): - """A donor re-pin or a CREATE change must refresh the fixture.""" + """The fixture's bytes, donor identity and kernel ref match the package. + + A donor re-pin or a new CREATE kernel ref fails here. A staging change + under the same kernel ref does not: this test cannot see what CREATE + returns, so the fixture's provenance says to rerun the probe then. + """ provenance = json.loads( _CREATE_INVENTORY.with_name( _CREATE_INVENTORY.name + ".provenance.json" From a4819b2470e11ea6832218964083f8cc5c732cb2 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Fri, 20 Nov 2026 19:54:55 +0000 Subject: [PATCH 4/4] Pin the one CREATE dtype gap to Int64 in the inventory coverage test The coverage test named the column whose dtype differs from the concept schema but not the dtype, so a fixture refresh that turned household.reference_person_id into float64 would have passed. It now compares the gap as a mapping and pins nullable Int64. Co-Authored-By: Claude Fable 5.2 --- .../engine_free/shared/test_nz_transport_declarations.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/microcosm-build/tests/engine_free/shared/test_nz_transport_declarations.py b/packages/microcosm-build/tests/engine_free/shared/test_nz_transport_declarations.py index 11419fb43b..7ccb0deeac 100644 --- a/packages/microcosm-build/tests/engine_free/shared/test_nz_transport_declarations.py +++ b/packages/microcosm-build/tests/engine_free/shared/test_nz_transport_declarations.py @@ -828,10 +828,13 @@ def test_every_real_create_column_is_a_canonical_concept_or_unit_output(): # The one dtype gap: the concept schema says the reference person is never # null, but CREATE emits nullable Int64. Graph compile checks dtypes on # rewrites, row masks and the mass partition (microcosm.graph.decl), and - # the NZ graph compiles with this gap; a new gap fails here. + # the NZ graph compiles with this gap; a new gap, or another dtype in + # this one, fails here. assert { - key for key in real.keys() & canonical.keys() if real[key] != canonical[key] - } == {("household", "reference_person_id")} + key: real[key] + for key in real.keys() & canonical.keys() + if real[key] != canonical[key] + } == {("household", "reference_person_id"): "Int64"} def test_the_create_inventory_fixture_is_the_pinned_donors_stored_payload():