From 2c734f00fbd9572fd2a94b38505bbb2921c105dd Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Fri, 20 Nov 2026 08:02:56 +0000 Subject: [PATCH 1/2] Select the populace-us donor profile for New Zealand NZ's nz.create reads the new donor_profile.json whole as its donor_profile param, with ruling d3058's choices (rented_public_authority, read_false, tenure_wins) on donor 48b9d479. The donor stage declares the spm_unit table the profile reader opens, so source_stages.json, its receipt in spec/sources.yaml, donor_pin_sha256 and the donor receipt's params move, and every NZ node re-keys. One profiled CREATE probe on the pinned donor refreshes the D4 inventory fixture: it gains household.tenure, person.enrolled_full_time and person.legal_marital_status and nothing else changes, so the staging gap is empty and the graph composes against the real inventory alone. The entitlement document lists the cell diagnostics collector before nz.gates.terminal (uses #1699); graph_to_json is unchanged by that entry. Regenerated transport_graph.json, entitlement_graph.json and the NZ golden. No shared source module changes. Co-Authored-By: Claude Opus 5.5 --- .../nz-donor-profile-selection.changed.md | 1 + .../microcosm/build/nz/country_package.json | 5 + .../src/microcosm/build/nz/donor_profile.json | 11 ++ .../microcosm/build/nz/entitlement_graph.json | 1 + .../src/microcosm/build/nz/source_stages.json | 3 +- .../src/microcosm/build/nz/spec/sources.yaml | 5 +- .../microcosm/build/nz/transport_graph.json | 5 + .../shared/test_nz_spec_package.py | 55 +++++++- .../shared/test_nz_transport_declarations.py | 120 +++++++++++++----- .../test_spec_engine_country_bundles.py | 1 + ...create_inventory_populace_us_48b9d479.json | 2 +- ..._populace_us_48b9d479.json.provenance.json | 43 ++++++- .../tests/golden/nz_country_spec.json | 16 ++- tools/build_nz_entitlement_graph.py | 16 ++- tools/build_nz_transport_graph.py | 1 + 15 files changed, 229 insertions(+), 56 deletions(-) create mode 100644 changelog.d/nz-donor-profile-selection.changed.md create mode 100644 packages/microcosm-build/src/microcosm/build/nz/donor_profile.json diff --git a/changelog.d/nz-donor-profile-selection.changed.md b/changelog.d/nz-donor-profile-selection.changed.md new file mode 100644 index 0000000000..33ae41d61b --- /dev/null +++ b/changelog.d/nz-donor-profile-selection.changed.md @@ -0,0 +1 @@ +New Zealand's transport graph selects the shared `populace-us-cps-asec` donor profile, version 1, through a new `donor_profile.json` resource that `nz.create` reads whole as its `donor_profile` param. The document records ruling d3058's choices for one engineering measurement run on donor `48b9d479`: `assisted_renter_tenure` is `rented_public_authority` (assisted renters stand in for public-authority tenants, because the donor carries no landlord signal), `blank_full_time_study` is `read_false` (blank study answers read as not full time on this pinned donor) and `housing_cost_contradicting_tenure` is `tenure_wins` (rent or mortgage interest that contradicts the staged tenure is zeroed and counted in CREATE's receipt). The donor stage in `source_stages.json` and its copy in `spec/sources.yaml` now declare the donor's `spm_unit` table, which the profile reader opens, so the source receipt, `nz.create`'s `donor_pin_sha256` and `nz.evidence.donor_receipt`'s `source_stages` params move with that file. `nz.create` and `nz.evidence.donor_receipt` re-key, and so does every other node of the graph, since all of them descend from `nz.create`; a CREATE inventory stored before this change does not serve the profiled run, because its store key includes CREATE's params. One profiled CREATE probe on the pinned donor refreshes the D4 fixture (`create_inventory_populace_us_48b9d479.json` and its provenance): it adds `household.tenure`, `person.enrolled_full_time` and `person.legal_marital_status` and changes no other column, so the declared staging gap is empty and the NZ graph composes against the real inventory alone. The entitlement document also lists the cell diagnostics collector just before `nz.gates.terminal`, so the collector's checkpoint manifest is written even if a node that only the battery's checkpoint runs raises; the composed graph is byte-identical with and without that entry. NZ's golden spec summary moves with these files. No shared source module changes. diff --git a/packages/microcosm-build/src/microcosm/build/nz/country_package.json b/packages/microcosm-build/src/microcosm/build/nz/country_package.json index f81aaf7bf9..8b955ecb61 100644 --- a/packages/microcosm-build/src/microcosm/build/nz/country_package.json +++ b/packages/microcosm-build/src/microcosm/build/nz/country_package.json @@ -271,6 +271,11 @@ "path": "export_replay_bindings.json", "kind": "legacy_json", "schema_id": "legacy_json" + }, + { + "path": "donor_profile.json", + "kind": "legacy_json", + "schema_id": "legacy_json" } ] } diff --git a/packages/microcosm-build/src/microcosm/build/nz/donor_profile.json b/packages/microcosm-build/src/microcosm/build/nz/donor_profile.json new file mode 100644 index 0000000000..5ed8aca641 --- /dev/null +++ b/packages/microcosm-build/src/microcosm/build/nz/donor_profile.json @@ -0,0 +1,11 @@ +{ + "format": "microcosm.donor-profile/1", + "profile": "populace-us-cps-asec", + "version": 1, + "donor_sha256": "48b9d479fb4fd1c3537f9383ce4697d130b6f618658409d74f6233c43b994c7e", + "choices": { + "assisted_renter_tenure": "rented_public_authority", + "blank_full_time_study": "read_false", + "housing_cost_contradicting_tenure": "tenure_wins" + } +} 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 cf5369a269..dd59410e97 100644 --- a/packages/microcosm-build/src/microcosm/build/nz/entitlement_graph.json +++ b/packages/microcosm-build/src/microcosm/build/nz/entitlement_graph.json @@ -1031,6 +1031,7 @@ }, "checkpoints": [ "nz.as.bands", + "nz.as.bands.cell_diagnostics", "nz.gates.terminal" ], "gate_evidence": [ diff --git a/packages/microcosm-build/src/microcosm/build/nz/source_stages.json b/packages/microcosm-build/src/microcosm/build/nz/source_stages.json index df21d43b57..d3133feee5 100644 --- a/packages/microcosm-build/src/microcosm/build/nz/source_stages.json +++ b/packages/microcosm-build/src/microcosm/build/nz/source_stages.json @@ -33,7 +33,8 @@ "kind": "read_tables", "tables": [ "person", - "household" + "household", + "spm_unit" ], "weight": "household_weight" } diff --git a/packages/microcosm-build/src/microcosm/build/nz/spec/sources.yaml b/packages/microcosm-build/src/microcosm/build/nz/spec/sources.yaml index 48d2a4497e..e0d68c4468 100644 --- a/packages/microcosm-build/src/microcosm/build/nz/spec/sources.yaml +++ b/packages/microcosm-build/src/microcosm/build/nz/spec/sources.yaml @@ -1,9 +1,9 @@ sources: -- byte_size: 2928 +- byte_size: 2952 id: nz_populace_us_support_contract loader: kernel:load_populace_us_support_pool role: nz_populace_us_support_pool - sha256: cc82c68878ac0fc07ecbd796c1a66de6f34786ef8785125046425c37f26aff31 + sha256: a9111d0e319f06de459236bf036468268726969b520ae30b5e68e346b29ad124 vintage_authorities: - id: nz_support_pool_2024_buildp kind: survey_period @@ -55,6 +55,7 @@ stages: tables: - person - household + - spm_unit weight: household_weight outputs: - person_id 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 fee4434179..fb4f39302f 100644 --- a/packages/microcosm-build/src/microcosm/build/nz/transport_graph.json +++ b/packages/microcosm-build/src/microcosm/build/nz/transport_graph.json @@ -58,6 +58,11 @@ "path": [], "encoding": "sha256" }, + "donor_profile": { + "resource": "donor_profile", + "path": [], + "encoding": "json" + }, "unit_rule": { "resource": "benefit_unit_rule", "path": [], diff --git a/packages/microcosm-build/tests/engine_free/shared/test_nz_spec_package.py b/packages/microcosm-build/tests/engine_free/shared/test_nz_spec_package.py index 1f1a5d3df6..df4f169c13 100644 --- a/packages/microcosm-build/tests/engine_free/shared/test_nz_spec_package.py +++ b/packages/microcosm-build/tests/engine_free/shared/test_nz_spec_package.py @@ -173,6 +173,7 @@ from microcosm.frame import concepts as frame_concepts from microcosm.frame.concept_mapping import MAPPING_FORMAT from microcosm.frame.input_closure import INPUT_CLOSURE_FORMAT +from microcosm.frame.transport import DONOR_PROFILE_FORMAT from test_support.paths import paths_for _BUILD = paths_for("microcosm-build") @@ -1019,7 +1020,7 @@ def _serialized_identifier(key: object, child: object) -> bool: """ if key == "format": - return child in {INPUT_CLOSURE_FORMAT, MAPPING_FORMAT} + return child in {INPUT_CLOSURE_FORMAT, MAPPING_FORMAT, DONOR_PROFILE_FORMAT} return ( key == "type" and isinstance(child, Mapping) @@ -3368,6 +3369,14 @@ def test_the_input_closure_format_identifier_is_not_a_python_symbol(self) -> Non INPUT_CLOSURE_FORMAT } + def test_the_donor_profile_format_identifier_is_not_a_python_symbol(self) -> None: + # donor_profile.json's format tag; outside a format key the scan reads + # its dotted prefix as a module that does not exist. + assert dotted_symbol_citations({"format": DONOR_PROFILE_FORMAT}) == set() + assert dotted_symbol_citations({"note": DONOR_PROFILE_FORMAT}) == { + "microcosm.donor" + } + def test_a_declared_artifact_type_is_not_a_python_symbol(self) -> None: from microcosm.build.transport.income_evidence_kernels import ( OMISSION_REGISTER_TYPE, @@ -4218,6 +4227,50 @@ def test_donor_pin_and_us_support_provenance_are_explicit(self) -> None: assert {"donor_country_code", "support_stratum"} <= set(donor.outputs) assert "US donor support records" in donor.survey + def test_donor_profile_is_the_d3058_selection_for_the_pinned_donor(self) -> None: + from microcosm.frame.transport import parse_donor_profile + from microcosm.graph.canonical import canonical_json + + document = _load("donor_profile.json") + # Composition hands CREATE the canonical text of the whole document + # (transport/compose.py's whole-resource json selection), and the + # shared parser accepts only that spelling. + text = canonical_json(document).decode("utf-8") + profile = parse_donor_profile(text) + assert profile.canonical_text == text + assert document["format"] == DONOR_PROFILE_FORMAT + assert (profile.name, profile.version) == ("populace-us-cps-asec", 1) + # d3058, rules 2 to 5, for one engineering measurement run: assisted + # renters stand in for public-authority tenants (the donor has no + # landlord signal), blank study answers read as not full time on this + # pinned donor only, and tenure wins over contradicting housing costs. + assert dict(profile.choices) == { + "assisted_renter_tenure": "rented_public_authority", + "blank_full_time_study": "read_false", + "housing_cost_contradicting_tenure": "tenure_wins", + } + stages = load_country_spec("nz").sources.stage_map() + (artifact,) = stages["load_populace_us_support_pool"].artifacts + assert profile.donor_sha256 == artifact["sha256"] + assert profile.donor_sha256 == _load("transport_inputs.json")["donor"]["sha256"] + # Whole-document selection trims documents with target_references, + # and the reference-closure scan reads "reference"/"target" keys. + assert not {"target_references", "reference", "target"} & set( + _nested_keys(document) + ) + + def test_donor_stage_reads_the_spm_unit_table_the_profile_stages(self) -> None: + from microcosm.frame.transport import _PROFILE_COLUMNS + + stages = load_country_spec("nz").sources.stage_map() + (operation,) = stages["load_populace_us_support_pool"].operations + assert operation.kind == "read_tables" + assert operation.parameters["tables"] == ["person", "household", "spm_unit"] + # Placement ruling term 3: the stage declares every donor table the + # profile reader opens. CREATE sees only this file's digest + # (donor_pin_sha256), so nothing at run time checks the declaration. + assert set(_PROFILE_COLUMNS) <= set(operation.parameters["tables"]) + class TestReportingClassifiers: def test_reporting_resource_is_packaged_and_loader_visible(self) -> None: 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 7ccb0deeac..94bea51ca3 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,18 +676,21 @@ def test_nz_executable_support_keeps_region99_separate_from_ta999(): } -# 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. +# D4 (d3058): CREATE's inventory on the pinned donor under NZ's donor profile, +# 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 = { +# Columns the graph reads that CREATE on the pinned donor does not give. The +# donor profile (d3058 rules 2, 4 and 5) now stages household.tenure, +# person.enrolled_full_time and person.legal_marital_status, and the fixture +# holds them, so nothing awaits staging. +_AWAITING_DONOR_STAGING: dict[tuple[str, str], str] = {} +# The columns NZ's donor profile stages, with the dtypes the graph declares. +_PROFILE_STAGED = { ("household", "tenure"): "string", ("person", "enrolled_full_time"): "bool", ("person", "legal_marital_status"): "string", @@ -769,8 +772,9 @@ def _nz_composition_spec_and_config(): 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. + inventory the pinned donor gave under NZ's donor profile, plus any columns + awaiting donor staging at their concept dtypes (none now). No bridge or + region column enters as a root. """ from microcosm.graph import Owned @@ -817,6 +821,23 @@ def test_the_staging_gap_declares_the_canonical_concept_dtypes(): } +def test_the_profiled_inventory_holds_the_staged_columns_at_canonical_dtypes(): + """D4: the donor profile fills the gap attempt 7 found, at graph dtypes.""" + from microcosm.frame.transport import _PROFILE_CONCEPTS + + # The shared reader's own list of the concepts a profile writes. + assert set(_PROFILE_STAGED) == { + (entity, column) + for entity, columns in _PROFILE_CONCEPTS.items() + for column in columns + } + canonical = _canonical_dtypes() + assert _PROFILE_STAGED == {key: canonical[key] for key in _PROFILE_STAGED} + real = _real_create_inventory() + assert {key: real.get(key) for key in _PROFILE_STAGED} == _PROFILE_STAGED + assert set(_PROFILE_STAGED) <= _nz_root_reads(_spec()) + + def test_every_real_create_column_is_a_canonical_concept_or_unit_output(): canonical = _canonical_dtypes() _, unit = _structural_and_unit_columns(_spec()) @@ -865,41 +886,49 @@ def test_the_create_inventory_fixture_is_the_pinned_donors_stored_payload(): if row.get("structural") == "create" ) assert create["kernel"] == provenance["create_kernel"] + # The fixture is CREATE under this donor profile; a new profile document + # must refresh it. + from microcosm.frame.transport import parse_donor_profile + from microcosm.graph.canonical import canonical_json + profile = parse_donor_profile( + canonical_json(spec["resources"]["donor_profile"]).decode("utf-8") + ) + assert provenance["donor_profile"]["document_sha256"] == profile.sha256 -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 +def test_nz_composes_against_the_real_profiled_inventory_alone(): + """D4: NZ composes on the pinned donor's profiled CREATE inventory alone. - 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) + Attempt 7's unprofiled inventory lacked three columns the graph reads, so + composition refused. The profile stages them, so CREATE declares exactly + the stored inventory and owns the staged columns in the composed graph. + """ + assert not _AWAITING_DONOR_STAGING + _, config, graph, compiled = _nz_composed() + assert { + (owned.entity, owned.column): owned.dtype for owned in config.create_outputs + } == _real_create_inventory() + owned = { + (item.entity, item.column): item.dtype + for item in graph.node("nz.create").outputs + } + assert {key: owned.get(key) for key in _PROFILE_STAGED} == _PROFILE_STAGED + assert "nz.create" in compiled.order 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. + Extension checkpoints write their manifests in declared order before + export.prepare runs (transport/cli.py). The document lists the cell + diagnostics collector before nz.gates.terminal, so its manifest is written + even if a node only the battery's checkpoint runs raises. """ assert compose.transport_endpoints(_spec())["checkpoints"] == ( "nz.as.bands", - "nz.gates.terminal", "nz.as.bands.cell_diagnostics", + "nz.gates.terminal", ) @@ -968,6 +997,33 @@ def test_nz_packaged_graph_compiles_with_only_pins_and_money_producers(): assert f"nz.v.{variant}.gap" in compiled.order +def test_nz_create_receives_the_donor_profile_as_canonical_text(): + """nz.create selects the whole profile document; CREATE's parser accepts it.""" + from microcosm.frame.transport import parse_donor_profile + + spec = _spec() + (row,) = ( + row + for row in spec["resources"]["transport_graph"]["nodes"] + if row["id"] == "nz.create" + ) + assert row["params"]["donor_profile"] == { + "resource": "donor_profile", + "path": [], + "encoding": "json", + } + # Placement ruling term 6: the node key hashes the document; no digest. + assert "donor_profile_sha256" not in row["params"] + _, _, graph, _ = _nz_composed() + create = graph.node("nz.create") + text = create.params["donor_profile"] + assert isinstance(text, str) + profile = parse_donor_profile(text) + assert profile.canonical_text == text + assert profile.donor_sha256 == create.params["donor_sha256"] + assert not list(compose._named_reference_values(json.loads(text))) + + def test_every_composed_battery_keeps_the_d1982_release_candidate_off(): """d1982: the batteries an extension branch adds keep the flag off too. diff --git a/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_country_bundles.py b/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_country_bundles.py index ccf3c6e6e8..c7bea3b53e 100644 --- a/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_country_bundles.py +++ b/packages/microcosm-build/tests/engine_free/shared/test_spec_engine_country_bundles.py @@ -263,6 +263,7 @@ def test_nz_generation_zero_views_come_from_the_country_spec_seam() -> None: "chronicle_feed.json", "concept_mapping.json", "currency_bridge.json", + "donor_profile.json", "earnings_bands.json", "entitlement_graph.json", "export_contract.json", 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 index 33bc9bf906..ad4928805d 100644 --- 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 @@ -1 +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 +{"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":"legal_marital_status","dtype":"string","entity":"person"},{"column":"enrolled_full_time","dtype":"bool","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":"tenure","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 index 2ca6bdeac6..aa7f6a3327 100644 --- 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 @@ -1,20 +1,49 @@ { - "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" + "commit": "main 7ff5a26bc2 plus #1688, #1698 and #1699", + "date": "2026-11-20", + "how": "One in-memory probe: prepare_create_outputs(spec, sources, resume='forbid') with no inventory store, on the pinned donor and the NZ Chronicle feed artifact, with NZ's packaged spec selecting donor_profile.json. CREATE did not refuse." }, + "create_implementation_hash": "bd47b92814e5c0ad01571b43ff1665563ae3ea85cedc6d8168bde75523b3de0f", "create_kernel": "transport.create@1", "donor": { "revision": "populace-us-2024-buildp-sparse-rmloss100-cae8640-20260728T011454Z", "sha256": "48b9d479fb4fd1c3537f9383ce4697d130b6f618658409d74f6233c43b994c7e", "size_bytes": 462915783 }, + "donor_profile": { + "choices": { + "assisted_renter_tenure": "rented_public_authority", + "blank_full_time_study": "read_false", + "housing_cost_contradicting_tenure": "tenure_wins" + }, + "document_sha256": "2229e09f725405ae03d228a1e497b9aec1c952c32e7eacdb08b3755d057d81c2", + "profile": "populace-us-cps-asec", + "receipt_counts": { + "blank_a_enrlw_by_source_year": { + "2022": 54464, + "2023": 54654, + "2024": 0 + }, + "mortgage_interest_zeroed_households": 6310, + "rent_zeroed_households": 10739, + "spm_units": 59900, + "spm_units_without_members": 0, + "tenure_households": { + "owned_outright": 17649, + "owned_with_mortgage": 22938, + "rent_free": 567, + "rented_nonprofit_social": 0, + "rented_private": 15256, + "rented_public_authority": 830 + } + }, + "version": 1 + }, "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.", + "note": "Measured at capture under the locked numpy 2.4.6, pandas 3.0.3 and tables 3.11.1: create@1's implementation hash is the value above. The staged columns household.tenure (string), person.enrolled_full_time (bool) and person.legal_marital_status (string) are the three columns this payload adds to the attempt-7 inventory (payload sha256 305107d61aacfbeebfb1c693dc9440f652441d273257a0460e1f7291203d6b6d); every other column and dtype is unchanged.", "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.", + "payload_sha256": "b5f6ee552ec53f655af43da45221e3224d49c1c95e7e9e93adfe00e931349047", + "refresh": "Rerun prepare_create_outputs(spec, sources, resume='forbid') on the pinned donor and replace both files whenever the donor pin, donor_profile.json or CREATE's staging changes.", "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 27c4577db5..37ed3c20c4 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": "4214fdfade3c910bf8d8180c3d65e1953dbdbb3190642fed6e095b461bf88fd1", + "fingerprint": "d688376f4eb48aacd836f43e44c60a0cef4615ba1d80aa747e53ca783c1732f2", "gate_ids": [ "calibration_per_family_fit", "demography_per_family_fit", @@ -51,10 +51,11 @@ "calibration_settings.json": "56e4d1da8468245da6bd41daf263425cc65e4e9c9f11ff45eee459d3aed1989e", "chronicle_feed.json": "598f4f50c0e68e28e7824470e262815bae88344c2ab7248339034841054dbffc", "concept_mapping.json": "1d527c093870839cf535f34f8b4d4ad477547ed1aa57d7acb35087ce0ec974e8", - "country_package.json": "53deee4d1ff74730a7ef0743c3ab9e42ee3352b41c2df6ae516b4283833b5d84", + "country_package.json": "2ab5232bf49b45763908864235bb21f3979fa8e30e9e08033d75a5af8d497571", "currency_bridge.json": "ddf6fdb30ce2b930496fcfe18e1c2848443ae0a5dbb4100e109403ec3620c6aa", + "donor_profile.json": "f8775a9c0c2904c2b209784bdf4109f04806eca37688bf57d86ed451691802b3", "earnings_bands.json": "7c9f6ae99bf4346fba0ae315037b3d65b59472cd588a1573e7a3f3091c168342", - "entitlement_graph.json": "89ac989202d339f681131c7083437333de5d40bc8d14ab69f1ce6ea494aa2d99", + "entitlement_graph.json": "d41a4575e2dd63dfa6a5accd710fd27e5e4ce3cfe271db99691cb57313b3a5ac", "export_contract.json": "3fb78dd3a6d1b0f59b6a2df8883f1a175b07a2a2f57f35c1eb89a8802c983993", "export_replay_bindings.json": "bc2e8b8a838e02b76955cf22b735bfc172495b6918d3b7f6594da67d0a02a136", "family_reconciliation.json": "20e3f9f3ce6266d57828d721c99d15bd3642e6c6314a7076ec38972de02bc69e", @@ -83,16 +84,16 @@ "rent_bands.json": "1feccbe80fe662bf14a11ab1a3a4047dd8cf62d0f813112aa2aa248799e620ed", "reporting_classifiers.json": "60f0936a9cab3776affda81e2612174dbc2192947630e9cc037b9b11277ca4d2", "scenarios.json": "86e102bb3f301ee78238f020fef0839dbbad54b367b7b1e9ce7824956f2d1135", - "source_stages.json": "cc82c68878ac0fc07ecbd796c1a66de6f34786ef8785125046425c37f26aff31", + "source_stages.json": "a9111d0e319f06de459236bf036468268726969b520ae30b5e68e346b29ad124", "spec/bundle.yaml": "e9716ce827e9006d4efdc392e7aaf9cbc33c16112a8fbc423e8f3e74ec506d8e", "spec/catalogs.yaml": "3ab2025af39cba93ead707b9463e428430a45b30696a43d0906cbcd97ed36631", "spec/geography.yaml": "0dbf9f850dc3cef983f166bf6783022094894ec2461ad71f4809607bcfd390a9", - "spec/sources.yaml": "afdaa4bef98cf520a1c72b6013d1e453162c761cd4b3c1548620184f6ba41297", + "spec/sources.yaml": "7f45520ec43639d061cbe2ba08300a8d2c89c35863a937e1d5b0103377be1037", "spec/spine.yaml": "b3e6a2832ff7671777cae113b7fc45f5e3492bb519526f229118d0851083533e", "spec/vintages.yaml": "1ecc1a3f952bd25b834c394314e8c933ddb5b095fd64ba492dddb03e3cdd803e", "target_references.json": "6af5258a4e3451d7742ab9f3b454fec9e0bd7cf320fab6e784ff002a8be211c8", "transport_atomic_geography_support.json": "53465827f67c87aaf5a06c305c082cbf1e6cdf28f3843e853d1e012635517d10", - "transport_graph.json": "4ada151226baf62377dd8da64314563cb15e0fd4caa6c757b4d0754b451271da", + "transport_graph.json": "01d6f501a9b2904f1bf0d32cba908431a426d3b5438b2a40a9a2a69c58adb699", "transport_inputs.json": "16d3957214d6305e3d3f41fe6343143a411d6055c75c43d3f171db3ee659ec2d" }, "resources": [ @@ -149,7 +150,8 @@ "gap_annualisation.json", "holdout_comparator_bindings.json", "as_encoding.json", - "export_replay_bindings.json" + "export_replay_bindings.json", + "donor_profile.json" ], "stage_names": [ "load_populace_us_support_pool" diff --git a/tools/build_nz_entitlement_graph.py b/tools/build_nz_entitlement_graph.py index 5c862882d5..29cf4e456d 100644 --- a/tools/build_nz_entitlement_graph.py +++ b/tools/build_nz_entitlement_graph.py @@ -668,11 +668,17 @@ def documents(nz=NZ): # 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"], + # gate report; no gate changes. The cell diagnostics collector feeds + # the terminal battery, so the document lists it just before + # nz.gates.terminal: it runs in its own checkpoint and writes its + # manifest even if a node only the battery's checkpoint runs then + # raises. entitlement.py appends the collector only when a document + # leaves it out. + "checkpoints": [ + "nz.as.bands", + "nz.as.bands.cell_diagnostics", + "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 0c38a7b753..66182b8233 100644 --- a/tools/build_nz_transport_graph.py +++ b/tools/build_nz_transport_graph.py @@ -1094,6 +1094,7 @@ def documents(): "transport_inputs", "value", "donor", "size_bytes" ), "donor_pin_sha256": select("source_stages", "sha256"), + "donor_profile": select("donor_profile"), **rule, **document("mass_reference", "mass_references"), "country": "nz", From 980219c44c3786d05e9a8db969c02f7109746feb Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Sat, 21 Nov 2026 15:30:00 +0100 Subject: [PATCH 2/2] Record the NZ CREATE inventory capture at main 32f341d475 Rerun the profiled CREATE probe on the pinned donor after #1698's round-2 staging edits landed. CREATE did not refuse; create@1's implementation hash is now 135f21143c6c, and the payload (b5f6ee552ec5) and every receipt count equal the 2026-11-20 capture, so only the provenance's capture fields and hash change. Co-Authored-By: Claude Opus 5.5 --- ...te_inventory_populace_us_48b9d479.json.provenance.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 index aa7f6a3327..ff0a5fee14 100644 --- 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 @@ -1,10 +1,10 @@ { "captured": { - "commit": "main 7ff5a26bc2 plus #1688, #1698 and #1699", - "date": "2026-11-20", + "commit": "main 32f341d475 (after #1688, #1699, #1700 and #1698 merged) plus this change", + "date": "2026-11-21", "how": "One in-memory probe: prepare_create_outputs(spec, sources, resume='forbid') with no inventory store, on the pinned donor and the NZ Chronicle feed artifact, with NZ's packaged spec selecting donor_profile.json. CREATE did not refuse." }, - "create_implementation_hash": "bd47b92814e5c0ad01571b43ff1665563ae3ea85cedc6d8168bde75523b3de0f", + "create_implementation_hash": "135f21143c6cc9bc7c355d5bf248a0c2c5731bd969d22bc591f201762bc7c867", "create_kernel": "transport.create@1", "donor": { "revision": "populace-us-2024-buildp-sparse-rmloss100-cae8640-20260728T011454Z", @@ -41,7 +41,7 @@ "version": 1 }, "kind": "nz_create_inventory_fixture", - "note": "Measured at capture under the locked numpy 2.4.6, pandas 3.0.3 and tables 3.11.1: create@1's implementation hash is the value above. The staged columns household.tenure (string), person.enrolled_full_time (bool) and person.legal_marital_status (string) are the three columns this payload adds to the attempt-7 inventory (payload sha256 305107d61aacfbeebfb1c693dc9440f652441d273257a0460e1f7291203d6b6d); every other column and dtype is unchanged.", + "note": "Measured at capture under the locked numpy 2.4.6, pandas 3.0.3 and tables 3.11.1: create@1's implementation hash is the value above. The staged columns household.tenure (string), person.enrolled_full_time (bool) and person.legal_marital_status (string) are the three columns this payload adds to the attempt-7 inventory (payload sha256 305107d61aacfbeebfb1c693dc9440f652441d273257a0460e1f7291203d6b6d); every other column and dtype is unchanged. A capture on 2026-11-20, before #1698's last staging edits, gave the same payload and receipt counts under create@1 hash bd47b928.", "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": "b5f6ee552ec53f655af43da45221e3224d49c1c95e7e9e93adfe00e931349047", "refresh": "Rerun prepare_create_outputs(spec, sources, resume='forbid') on the pinned donor and replace both files whenever the donor pin, donor_profile.json or CREATE's staging changes.",