From 40fc91360085cb3f2ff59fc5a932be60561a6ad3 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Sun, 15 Nov 2026 14:23:49 -0500 Subject: [PATCH 1/2] Make Belgium's gate rows pass the transport gate registry Five of Belgium's ten gate rows failed TRANSPORT_GATE_REGISTRY's validators. Nothing ran them, because Belgium has no transport graph yet, and only NZ's manifest is checked in a test. PR 4b's battery node would refuse the manifest on configuration before any gate ran. - calibration_per_family_fit lacked hard_within, min_hard_family_share and min_family_size. It is now not applicable, awaiting d1902, as NZ's fit rows were before their ruling: the method card's fit tolerances are proposed, not ruled. Its notes give the proposal as parameters. - commune_fiscal_income_fit declared report_worst_fit, which no binding routes, and lacked default_rtol. Belgium has no commune-grain reference or commune tolerance, so it is not applicable, and the worst-25 intent moves into its notes. - demographics_vs_statbel declared surface, which no binding routes. It now selects families [demography]; its 2% tolerance is unchanged. - nonnegative_columns now lists the source manifest's non-negative outputs, household_weight and age. - formula_owned_export now lists the 16 variables Belgium's Axiom bindings request, until an export contract lists the exclusions. test_be_gate_manifest.py runs both validators on Belgium's manifest and pins the column lists and the two not-applicable rows to their sources. TestBelgianCompatibility now accepts a declared not-applicable row. The country-spec golden moves only by the gates.json hash and fingerprint. Co-Authored-By: Claude Opus 5.5 --- changelog.d/be-gate-parameters.changed.md | 1 + .../src/microcosm/build/be/gates.json | 54 +++++++---- .../shared/test_be_gate_manifest.py | 95 +++++++++++++++++++ .../engine_free/shared/test_gate_battery.py | 12 ++- .../tests/golden/be_country_spec.json | 4 +- 5 files changed, 144 insertions(+), 22 deletions(-) create mode 100644 changelog.d/be-gate-parameters.changed.md create mode 100644 packages/microcosm-build/tests/engine_free/shared/test_be_gate_manifest.py diff --git a/changelog.d/be-gate-parameters.changed.md b/changelog.d/be-gate-parameters.changed.md new file mode 100644 index 0000000000..e6e44d01c5 --- /dev/null +++ b/changelog.d/be-gate-parameters.changed.md @@ -0,0 +1 @@ +Belgium's `gates.json` rows now pass the transport gate registry's validators, ahead of Belgium's transport graph (PR 4b). `calibration_per_family_fit` is not applicable until d1902 rules on the method card's fit tolerances, as NZ's was before its ruling. Its notes carry the proposed parameters. `demographics_vs_statbel` selects the demography family in place of an unroutable `surface` key. `nonnegative_columns` and `formula_owned_export` declare their column lists: the source manifest's non-negative outputs, and the variables Belgium's Axiom bindings request. `commune_fiscal_income_fit` is not applicable until Belgium has commune-grain references and a commune tolerance, and its unroutable `report_worst_fit` key moves into its notes. A new test, `test_be_gate_manifest.py`, runs the battery's validators on Belgium's manifest. Belgium stays inactive. diff --git a/packages/microcosm-build/src/microcosm/build/be/gates.json b/packages/microcosm-build/src/microcosm/build/be/gates.json index c2c89df650..ef98bb9a45 100644 --- a/packages/microcosm-build/src/microcosm/build/be/gates.json +++ b/packages/microcosm-build/src/microcosm/build/be/gates.json @@ -11,11 +11,8 @@ "gate": "per_family_fit", "phase": "terminal", "criticality": "release_blocking", - "parameters": { - "within": 0.1, - "min_family_share": 0.8 - }, - "notes": "Calibration fit per source family (demography, fiscal income, income tax, social security, caseloads) so no family hides in the average." + "not_applicable": "awaiting d1902: Belgium's per-family fit tolerances (method card BE-MC6) are proposed, not ruled. Shared runner defaults and other countries' numbers may not silently govern Belgium.", + "notes": "Calibration fit per source family so no family hides in the average. Activate when d1902 rules, before any calibrated Belgian candidate. BE-MC6 proposes every calibration target within 5% and demography within 2%; written as NZ wrote its ruled d1376, that is within = hard_within = 0.05, min_family_share = min_hard_family_share = 1 and min_family_size = 1, so a one-target family gates too. Only hard_within, min_hard_family_share and min_family_size decide pass or fail; within and min_family_share are reported." }, { "id": "national_and_nuts1_admin_aggregates", @@ -36,13 +33,8 @@ "gate": "aggregate_admin", "phase": "terminal", "criticality": "diagnostic", - "parameters": { - "geography_levels": [ - "commune" - ], - "report_worst_fit": 25 - }, - "notes": "Commune-grain diagnostics render per-target fit with the worst-fit communes named; promotion to release_blocking is a spine-quality decision (populace#263), not a default." + "not_applicable": "Belgium has no commune-grain calibration reference: target_references.json covers the country and NUTS1 levels only, and commune fiscal income waits for a later commune spine gate. No ruling sets a commune tolerance, so aggregate_admin has no anchor to select and no default_rtol to apply.", + "notes": "Commune-grain diagnostics should render per-target fit with the 25 worst-fit communes named; promotion to release_blocking is a spine-quality decision (populace#263), not a default. Activate with commune fiscal-income calibration references, families [fiscal_income], geography_levels [commune] and a ruled default_rtol. aggregate_admin names every anchor that misses default_rtol, with its miss; a ranked worst-25 list that also shows passing communes needs a shared binding parameter first." }, { "id": "target_profile_coverage", @@ -77,10 +69,12 @@ "phase": "terminal", "criticality": "release_blocking", "parameters": { - "surface": "demography", + "families": [ + "demography" + ], "default_rtol": 0.02 }, - "notes": "The US demographics.json / base_population_scale posture against Statbel population structure: age-band x sex x region totals within tight tolerance." + "notes": "The US demographics.json / base_population_scale posture against Statbel population structure: age-band x sex x region totals within tight tolerance. families [demography] selects the compiled demography anchors (all NUTS1 today). default_rtol 0.02 is BE-MC6's demography tolerance, proposed and pending d1902, as each demography reference's fit_tolerance also is." }, { "id": "exported_nonzero", @@ -95,16 +89,40 @@ "gate": "formula_owned_export", "phase": "terminal", "criticality": "release_blocking", - "parameters": {}, - "notes": "No Axiom derived-rule output may persist as a dataset input (a stored engine output masks reforms) \u2014 enforced from day one; the adapter's writer refuses such columns and this gate re-checks the artifact." + "parameters": { + "formula_owned_columns": [ + "belgium_family_benefits_eligibility_gated_monthly_amount", + "belgium_lgaf_selected_monthly_indexed_amount", + "brussels_family_benefits_article_7_base_monthly_amount", + "brussels_family_benefits_article_9_social_supplement_monthly_amount", + "brussels_family_benefits_child_entitlement", + "brussels_family_benefits_eligible_monthly_amount", + "brussels_family_benefits_selected_monthly_amount", + "flanders_family_benefits_child_entitlement", + "flanders_family_benefits_eligible_monthly_amount", + "flanders_family_benefits_selected_monthly_amount", + "german_speaking_community_family_benefits_eligible_monthly_amount", + "german_speaking_community_family_benefits_selected_monthly_amount", + "german_speaking_community_family_benefits_statutory_base_entitlement", + "wallonia_family_benefits_child_entitlement", + "wallonia_family_benefits_eligible_monthly_amount", + "wallonia_family_benefits_selected_monthly_amount" + ] + }, + "notes": "No Axiom derived-rule output may persist as a dataset input (a stored engine output masks reforms) \u2014 enforced from day one; the adapter's writer refuses such columns and this gate re-checks the artifact. Until Belgium's export contract lists its formula-owned exclusions, formula_owned_columns is every variable a binding in axiom_rules_bindings.json requests, so the gate checks those outputs only." }, { "id": "nonnegative_columns", "gate": "nonnegative_columns", "phase": "terminal", "criticality": "release_blocking", - "parameters": {}, - "notes": "Physically non-negative columns (incomes, contributions) carry no negatives; the column list follows the source manifest's nonnegative_outputs." + "parameters": { + "columns": [ + "household_weight", + "age" + ] + }, + "notes": "Physically non-negative columns carry no negatives. columns is the source manifest's nonnegative_outputs (household_weight and age today); incomes and contributions join the list when the source manifest declares them." }, { "id": "macro_realism_nbb", diff --git a/packages/microcosm-build/tests/engine_free/shared/test_be_gate_manifest.py b/packages/microcosm-build/tests/engine_free/shared/test_be_gate_manifest.py new file mode 100644 index 0000000000..c43d164478 --- /dev/null +++ b/packages/microcosm-build/tests/engine_free/shared/test_be_gate_manifest.py @@ -0,0 +1,95 @@ +"""Belgium's gates.json against the transport gate registry. + +Belgium has no transport graph yet, so no ``gates.battery@1`` node parses +this manifest. These tests run the battery's own validators on it now, so a +row the registry cannot route or complete fails here, not in the first +Belgian battery node. NZ's twin is ``TestNewZealandManifest`` in +test_transport_gate_bindings.py. +""" + +from __future__ import annotations + +import json + +import pytest + +from microcosm.build.country_spec import load_country_spec +from microcosm.build.gate_battery import validate_gate_parameters +from microcosm.build.transport.gate_bindings import ( + TRANSPORT_GATE_REGISTRY, + validate_required_gate_parameters, +) +from test_support.paths import paths_for + +BE_ROOT = paths_for("microcosm-build").package / "src/microcosm/build/be" + + +@pytest.fixture(scope="module") +def spec(): + return load_country_spec("be") + + +def _entry(spec, entry_id: str): + (entry,) = (e for e in spec.gates.gates if e.id == entry_id) + return entry + + +def test_parameters_are_routed_and_complete(spec) -> None: + validate_gate_parameters(spec.gates, TRANSPORT_GATE_REGISTRY) + validate_required_gate_parameters(spec.gates, TRANSPORT_GATE_REGISTRY) + + +def test_nonnegative_columns_are_the_source_manifest_list(spec) -> None: + declared = list( + dict.fromkeys( + column + for stage in spec.sources.stages + for column in stage.nonnegative_outputs + ) + ) + assert list(_entry(spec, "nonnegative_columns").parameters["columns"]) == declared + + +def test_formula_owned_columns_are_the_bound_rule_outputs(spec) -> None: + # Until Belgium has an export contract; then pin formula_owned_excluded, + # as NZ does. + bindings = json.loads( + (BE_ROOT / "axiom_rules_bindings.json").read_text(encoding="utf-8") + )["bindings"] + bound = sorted({column for row in bindings for column in row["variables"]}) + entry = _entry(spec, "formula_owned_export") + assert list(entry.parameters["formula_owned_columns"]) == bound + + +def test_fit_tolerances_wait_for_d1902_in_both_places(spec) -> None: + # BE-MC6's fit tolerances are a proposal (d1902). They live in each + # reference's fit_tolerance and in these rows, so a ruling moves both: + # the per-family row takes parameters (its notes give them) when the + # references stop being pending. + statuses = { + reference.metadata["method_card_status"] for reference in spec.target_references + } + fit = _entry(spec, "calibration_per_family_fit") + assert (fit.not_applicable is not None) is (statuses == {"proposed_pending_d1902"}) + if fit.not_applicable is not None: + assert fit.not_applicable.startswith("awaiting d1902:") + demography_tolerances = { + float(reference.metadata["fit_tolerance"]) + for reference in spec.target_references + if reference.family == "demography" + } + demography = _entry(spec, "demographics_vs_statbel").parameters + assert demography_tolerances == {demography["default_rtol"]} + assert list(demography["families"]) == ["demography"] + + +def test_commune_row_waits_for_commune_references(spec) -> None: + entry = _entry(spec, "commune_fiscal_income_fit") + assert entry.criticality == "diagnostic" + levels = { + reference.ledger_selector.get("geography_level") + for reference in spec.target_references + } + # Activate the row (families, geography_levels, a ruled default_rtol) + # once a commune reference exists. + assert (entry.not_applicable is not None) is ("commune" not in levels) diff --git a/packages/microcosm-build/tests/engine_free/shared/test_gate_battery.py b/packages/microcosm-build/tests/engine_free/shared/test_gate_battery.py index 468d5e95c2..9103b5d99d 100644 --- a/packages/microcosm-build/tests/engine_free/shared/test_gate_battery.py +++ b/packages/microcosm-build/tests/engine_free/shared/test_gate_battery.py @@ -672,9 +672,17 @@ def test_the_be_spec_runs_as_declared_with_named_gaps(self, tmp_path, monkeypatc run.run_phase("terminal", EvidenceContext()) report = json.loads((tmp_path / "terminal_gates.json").read_text()) assert set(report["gates"]) == {gate.id for gate in spec.gates.gates} + declared = {gate.id: gate.not_applicable for gate in spec.gates.gates} assert all( - gate["status"] == "evidence_absent" for gate in report["gates"].values() - ), "unimplemented BE gates are named gaps, never crashes or passes" + gate["status"] == "evidence_absent" + or ( + gate["status"] == "not_applicable" + and gate["reason"] == declared[gate_id] + ) + for gate_id, gate in report["gates"].items() + ), ( + "unbound BE gates are named gaps or declared exclusions, never crashes or passes" + ) assert report["shippable"] is False assert len(report["gates_manifest_sha256"]) == 64 assert ( diff --git a/packages/microcosm-build/tests/golden/be_country_spec.json b/packages/microcosm-build/tests/golden/be_country_spec.json index 4c3de3b4a4..98bff863ed 100644 --- a/packages/microcosm-build/tests/golden/be_country_spec.json +++ b/packages/microcosm-build/tests/golden/be_country_spec.json @@ -1,6 +1,6 @@ { "country": "be", - "fingerprint": "d35397e4071d5eb7b5e293ee17a0847eb18f79ef15cad708365d80416ea8d67b", + "fingerprint": "d63045f3a96ec61f205b208463a6bf45b68038c503e93d70be4a0df5ba20a708", "gate_ids": [ "calibration_per_family_fit", "national_and_nuts1_admin_aggregates", @@ -33,7 +33,7 @@ "axiom_rules_bindings.json": "0d8c9670cc22761f90fba5df99c27bfea420708dad94926248da7dc1cea3a589", "chronicle_feed.json": "71f3967cefa12d8ad6c4b955547bfc37e33183ee839b3edf3a43e0cb72559030", "country_package.json": "204c8c06934160c856d86a9d6c5305d40e9b3a85713c11c3ab031bebb27fbe89", - "gates.json": "df207d9fbb7142a24b09f1987d87d6285031bacdd547c443eb6832cbe30c8424", + "gates.json": "8e0ff2db51ca2ef19f62342098ef07ea4e5d93b2eb844d517e9808260c098fec", "geography_spine.json": "090b83a4fa511e691b8f1486bc4188e4170cf9d4a1239e7418d33d5020ceca50", "holdout_references.json": "c9d32204b4c6364a95fcab066cbbc8b1b99dd49ef608e72c99009f01c7d1c942", "precal_references.json": "321bd4bd675b80c2e3241e19346fb191b72c8a0c101080dca27bae061c3edd89", From f575cd962084991765e37dbce822ffe4197b19ca Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Sun, 15 Nov 2026 16:44:54 -0500 Subject: [PATCH 2/2] Take up round 1 of the gate-rows review The Subfleet hard-tier review (20261115-142458-be-gate-rows-r1) approved 9fecb6e18 with two P2s and seven P3s. P2-1: only the per-family row waits for d1902, but the two aggregate_admin rows carry BE-MC6's unruled 5% and 2%. They stay applicable on purpose: demographics_vs_statbel is Belgium's live fit grading while the per-family row waits, and the national row binds once a country-level reference activates (until then it fails on its country level). Both rows' notes now say so and that a d1902 ruling moves all three rows. The test keeps both rows applicable and pins the national row's default_rtol to the non-demography references' fit_tolerance, as it already pins demography's. P2-2: the d1902 tripwire read every reference's method_card_status, which all card rows share, while the card lets d1902 rule row by row. It now reads the BE-MC6 references' status and says the generator writes one status for every row today. P3s: the fit row's notes describe NZ's two d1376 rows and evidence_absent_blocks correctly; the commune row's reason and test key on commune fiscal income, not any commune reference; a Belgian twin of NZ's bound-or-declared test catches a dropped binding, with macro_realism_nbb named as the one unbound applicable row. The fit row's notes also say NZ's rows list their families. The other P3s are PR-body wording. An independent check of this commit (executed mutants and a round-diff read) found no P0 to P2; its P3s are folded in here: the tripwire refuses an empty BE-MC6 set, the commune test's name says fiscal income, and the national row's case is stated as above rather than as grading it does not yet do. Co-Authored-By: Claude Opus 5.5 --- .../src/microcosm/build/be/gates.json | 8 +-- .../shared/test_be_gate_manifest.py | 55 ++++++++++++++++--- .../tests/golden/be_country_spec.json | 4 +- 3 files changed, 53 insertions(+), 14 deletions(-) diff --git a/packages/microcosm-build/src/microcosm/build/be/gates.json b/packages/microcosm-build/src/microcosm/build/be/gates.json index ef98bb9a45..e6b85d1e7f 100644 --- a/packages/microcosm-build/src/microcosm/build/be/gates.json +++ b/packages/microcosm-build/src/microcosm/build/be/gates.json @@ -12,7 +12,7 @@ "phase": "terminal", "criticality": "release_blocking", "not_applicable": "awaiting d1902: Belgium's per-family fit tolerances (method card BE-MC6) are proposed, not ruled. Shared runner defaults and other countries' numbers may not silently govern Belgium.", - "notes": "Calibration fit per source family so no family hides in the average. Activate when d1902 rules, before any calibrated Belgian candidate. BE-MC6 proposes every calibration target within 5% and demography within 2%; written as NZ wrote its ruled d1376, that is within = hard_within = 0.05, min_family_share = min_hard_family_share = 1 and min_family_size = 1, so a one-target family gates too. Only hard_within, min_hard_family_share and min_family_size decide pass or fail; within and min_family_share are reported." + "notes": "Calibration fit per source family so no family hides in the average. Activate when d1902 rules BE-MC6's fit tolerances, before any calibrated Belgian candidate. BE-MC6 proposes every calibration target within 5% and demography within 2%. NZ's ruled d1376 wrote its two tolerances as two per_family_fit rows, each with evidence_absent_blocks true: one at 5% over its calibration families and demography_per_family_fit at 2%, each with within = hard_within, min_family_share = min_hard_family_share = 1 and min_family_size = 1, so a one-target family gates too. Belgium's 2% lives in demographics_vs_statbel (aggregate_admin), so on activation this row takes within = hard_within = 0.05, both family shares 1, min_family_size 1 and evidence_absent_blocks true as NZ's rows carry; a demography per_family_fit row at 0.02, as NZ has, is the other option. NZ's rows also list their families, so a missing calibration family fails the row; without families, target_profile_coverage is what catches a missing family. Only hard_within, min_hard_family_share and min_family_size decide pass or fail; within and min_family_share are reported." }, { "id": "national_and_nuts1_admin_aggregates", @@ -26,14 +26,14 @@ ], "default_rtol": 0.05 }, - "notes": "Intended weighted aggregates against admin anchors on the future hard surface. The tier metadata in target_references.json is declaration-only in this change; a later runner integration must explicitly bridge it into gate tolerances." + "notes": "Intended weighted aggregates against admin anchors on the future hard surface. The tier metadata in target_references.json is declaration-only in this change; a later runner integration must explicitly bridge it into gate tolerances. default_rtol 0.05 is BE-MC6's administrative-aggregate tolerance, proposed and pending d1902; it equals the 5% each non-demography reference's fit_tolerance carries today. The row stays applicable on purpose, so it binds as soon as a country-level reference activates. Until then it fails on a calibrated surface, because its country level selects no active reference. demographics_vs_statbel is Belgium's live fit grading while calibration_per_family_fit waits on d1902, and a d1902 ruling moves all three rows. Every anchor the row selects, the NUTS1 demography anchors included, is graded at default_rtol; demographics_vs_statbel holds the demography anchors to 2%." }, { "id": "commune_fiscal_income_fit", "gate": "aggregate_admin", "phase": "terminal", "criticality": "diagnostic", - "not_applicable": "Belgium has no commune-grain calibration reference: target_references.json covers the country and NUTS1 levels only, and commune fiscal income waits for a later commune spine gate. No ruling sets a commune tolerance, so aggregate_admin has no anchor to select and no default_rtol to apply.", + "not_applicable": "Belgium has no commune-grain fiscal income calibration reference: commune fiscal income waits for a later commune spine gate, and no ruling sets a commune tolerance, so aggregate_admin has no anchor to select and no default_rtol to apply.", "notes": "Commune-grain diagnostics should render per-target fit with the 25 worst-fit communes named; promotion to release_blocking is a spine-quality decision (populace#263), not a default. Activate with commune fiscal-income calibration references, families [fiscal_income], geography_levels [commune] and a ruled default_rtol. aggregate_admin names every anchor that misses default_rtol, with its miss; a ranked worst-25 list that also shows passing communes needs a shared binding parameter first." }, { @@ -74,7 +74,7 @@ ], "default_rtol": 0.02 }, - "notes": "The US demographics.json / base_population_scale posture against Statbel population structure: age-band x sex x region totals within tight tolerance. families [demography] selects the compiled demography anchors (all NUTS1 today). default_rtol 0.02 is BE-MC6's demography tolerance, proposed and pending d1902, as each demography reference's fit_tolerance also is." + "notes": "The US demographics.json / base_population_scale posture against Statbel population structure: age-band x sex x region totals within tight tolerance. families [demography] selects the compiled demography anchors (all NUTS1 today). default_rtol 0.02 is BE-MC6's demography tolerance, proposed and pending d1902, as each demography reference's fit_tolerance also is. The row stays applicable on purpose: it is Belgium's live fit grading while calibration_per_family_fit waits on d1902, and a d1902 ruling moves it, national_and_nuts1_admin_aggregates and calibration_per_family_fit together." }, { "id": "exported_nonzero", diff --git a/packages/microcosm-build/tests/engine_free/shared/test_be_gate_manifest.py b/packages/microcosm-build/tests/engine_free/shared/test_be_gate_manifest.py index c43d164478..ea59acf71b 100644 --- a/packages/microcosm-build/tests/engine_free/shared/test_be_gate_manifest.py +++ b/packages/microcosm-build/tests/engine_free/shared/test_be_gate_manifest.py @@ -34,11 +34,27 @@ def _entry(spec, entry_id: str): return entry +#: Applicable rows whose gate has no transport binding yet. Both validators +#: skip them, so they report a gap rather than a pass or a refusal. +UNBOUND_APPLICABLE = {"macro_realism_nbb"} + + def test_parameters_are_routed_and_complete(spec) -> None: validate_gate_parameters(spec.gates, TRANSPORT_GATE_REGISTRY) validate_required_gate_parameters(spec.gates, TRANSPORT_GATE_REGISTRY) +def test_every_gate_is_bound_or_declared_not_applicable(spec) -> None: + # The validators skip a row whose gate has no binding, so a shared change + # that dropped a binding Belgium uses would leave the test above passing. + unbound = { + entry.id + for entry in spec.gates.gates + if entry.not_applicable is None and entry.gate not in TRANSPORT_GATE_REGISTRY + } + assert unbound == UNBOUND_APPLICABLE + + def test_nonnegative_columns_are_the_source_manifest_list(spec) -> None: declared = list( dict.fromkeys( @@ -64,15 +80,30 @@ def test_formula_owned_columns_are_the_bound_rule_outputs(spec) -> None: def test_fit_tolerances_wait_for_d1902_in_both_places(spec) -> None: # BE-MC6's fit tolerances are a proposal (d1902). They live in each # reference's fit_tolerance and in these rows, so a ruling moves both: - # the per-family row takes parameters (its notes give them) when the - # references stop being pending. + # the per-family row takes parameters (its notes give them) when BE-MC6 + # stops being pending. The card lets d1902 rule its rows one by one, so + # this reads the BE-MC6 references' status only. The generator writes one + # status for every card row today (METHOD_CARD_STATUS in + # tools/generate_be_target_references.py); ruling BE-MC6 alone needs + # per-row statuses there first. statuses = { - reference.metadata["method_card_status"] for reference in spec.target_references + reference.metadata["method_card_status"] + for reference in spec.target_references + if reference.metadata["method_card_row"] == "BE-MC6" } + assert statuses, "no reference names method card row BE-MC6" fit = _entry(spec, "calibration_per_family_fit") assert (fit.not_applicable is not None) is (statuses == {"proposed_pending_d1902"}) if fit.not_applicable is not None: assert fit.not_applicable.startswith("awaiting d1902:") + # The two aggregate_admin rows stay applicable with BE-MC6's unruled 2% + # and 5%: demography's is the live fit grading while the per-family row + # waits, and the national row binds once a country-level reference + # activates. The national pin ties BE-MC6's administrative-aggregate 5% + # to the per-target 5% in the references' fit_tolerance; they coincide + # today, and a ruling that splits them changes this pin. + for entry_id in ("demographics_vs_statbel", "national_and_nuts1_admin_aggregates"): + assert _entry(spec, entry_id).not_applicable is None, entry_id demography_tolerances = { float(reference.metadata["fit_tolerance"]) for reference in spec.target_references @@ -81,15 +112,23 @@ def test_fit_tolerances_wait_for_d1902_in_both_places(spec) -> None: demography = _entry(spec, "demographics_vs_statbel").parameters assert demography_tolerances == {demography["default_rtol"]} assert list(demography["families"]) == ["demography"] + other_tolerances = { + float(reference.metadata["fit_tolerance"]) + for reference in spec.target_references + if reference.family != "demography" + } + national = _entry(spec, "national_and_nuts1_admin_aggregates").parameters + assert other_tolerances == {national["default_rtol"]} -def test_commune_row_waits_for_commune_references(spec) -> None: +def test_commune_row_waits_for_commune_fiscal_income_references(spec) -> None: entry = _entry(spec, "commune_fiscal_income_fit") assert entry.criticality == "diagnostic" - levels = { - reference.ledger_selector.get("geography_level") + selected = { + (reference.family, reference.ledger_selector.get("geography_level")) for reference in spec.target_references } # Activate the row (families, geography_levels, a ruled default_rtol) - # once a commune reference exists. - assert (entry.not_applicable is not None) is ("commune" not in levels) + # once a commune fiscal income reference exists. + has_reference = ("fiscal_income", "commune") in selected + assert (entry.not_applicable is not None) is not has_reference diff --git a/packages/microcosm-build/tests/golden/be_country_spec.json b/packages/microcosm-build/tests/golden/be_country_spec.json index 98bff863ed..dc2a7cfb6b 100644 --- a/packages/microcosm-build/tests/golden/be_country_spec.json +++ b/packages/microcosm-build/tests/golden/be_country_spec.json @@ -1,6 +1,6 @@ { "country": "be", - "fingerprint": "d63045f3a96ec61f205b208463a6bf45b68038c503e93d70be4a0df5ba20a708", + "fingerprint": "d482b2f983feecc744541ac16f3a01e61d45f06614bbbcd09530c2037983ddde", "gate_ids": [ "calibration_per_family_fit", "national_and_nuts1_admin_aggregates", @@ -33,7 +33,7 @@ "axiom_rules_bindings.json": "0d8c9670cc22761f90fba5df99c27bfea420708dad94926248da7dc1cea3a589", "chronicle_feed.json": "71f3967cefa12d8ad6c4b955547bfc37e33183ee839b3edf3a43e0cb72559030", "country_package.json": "204c8c06934160c856d86a9d6c5305d40e9b3a85713c11c3ab031bebb27fbe89", - "gates.json": "8e0ff2db51ca2ef19f62342098ef07ea4e5d93b2eb844d517e9808260c098fec", + "gates.json": "9704a0c86b324d4243365a320438b47a9d7d5a6af7ec2adfa1821ecb8d611f68", "geography_spine.json": "090b83a4fa511e691b8f1486bc4188e4170cf9d4a1239e7418d33d5020ceca50", "holdout_references.json": "c9d32204b4c6364a95fcab066cbbc8b1b99dd49ef608e72c99009f01c7d1c942", "precal_references.json": "321bd4bd675b80c2e3241e19346fb191b72c8a0c101080dca27bae061c3edd89",