From 2280ecc1ef99dbe050edb98b41ecc5a154770765 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Wed, 4 Nov 2026 16:54:14 -0500 Subject: [PATCH 1/2] Test anchor hash and label changes and rows from another source A review of microcosm#1513 at 0997c50 found five changes to _follow_later_repin_report that leave every later-report case passing. An anchor check that reads only the group-by label field lets a hash or dimension label change in a B4923C record set through. The one passing case that adds rows declares ed_fsa with the namespace "ed_fsa.", and both passing cases end at the digest "new". So a helper that builds the namespace from the declared source, accepts only ed_fsa as the source or returns a fixed digest passes every case too. So does a label check that allows only the age/85_plus dimension label, since the relabel case changes no other dimension label. For each B4923C record set, one new case changes its record-set hash and one a dimension label, between two record sets outside the anchors, in the second of three changed fields. A new passing case declares bea with the namespace "bea_nipa.", adds a row whose record set shares the anchors' namespace, and ends at a new digest. The relabel case now also changes an AGI label, as #1343's re-pin did. The helper stays the same, and all 34 later-report cases pass with it. Of 73 changes to the helper, the 68 that #1513 counts and these five, 3 leave every case passing here, against 8 at 0997c50 and 41 at ad67d0b, in both pytest modes. #1513 explains the three that remain: <= in the source check, >= in the key-count check, and a label check that matches the two layout fields exactly. Each case that caught a change at an earlier commit still catches it. At 0997c50 the pin test caught the fixed digest and the age-only label check on the committed reports, and nothing caught the other three. Co-Authored-By: Claude Opus 5.5 --- .../engine_free/us/test_us_esi_premiums.py | 68 ++++++++++++++++++- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/packages/microcosm-build/tests/engine_free/us/test_us_esi_premiums.py b/packages/microcosm-build/tests/engine_free/us/test_us_esi_premiums.py index 0e08461e8f..cd5c42bc92 100644 --- a/packages/microcosm-build/tests/engine_free/us/test_us_esi_premiums.py +++ b/packages/microcosm-build/tests/engine_free/us/test_us_esi_premiums.py @@ -1356,8 +1356,8 @@ def test_a_later_report_may_add_rows_from_its_declared_source(self) -> None: ) == ("new", 12) def test_a_later_report_may_relabel_rows_and_add_none(self) -> None: - # As microcosm#1343's re-pin did: label changes, the record-set hash - # that covers them, and no added row. + # As microcosm#1343's re-pin did: label changes in two dimensions, + # the record-set hash that covers them, and no added row. later = self._later_report( added_keys=[], changed_fields={ @@ -1365,6 +1365,10 @@ def test_a_later_report_may_relabel_rows_and_add_none(self) -> None: "rows": 1, "by_record_set": {"x": 1}, }, + "dimension_value_labels/us:statutes/26/62#adjusted_gross_income/all": { + "rows": 1, + "by_record_set": {"y": 1}, + }, "layout/groupby_value_label": {"rows": 1, "by_record_set": {"x": 1}}, "layout/record_set_spec_hash": {"rows": 2, "by_record_set": {"x": 2}}, }, @@ -1376,6 +1380,26 @@ def test_a_later_report_may_relabel_rows_and_add_none(self) -> None: anchor_record_sets=self._ANCHORS, ) == ("new", 10) + def test_a_later_report_may_add_rows_from_a_source_with_its_own_namespace( + self, + ) -> None: + # A source whose namespace is not its name and a dot, a row that + # shares the anchors' namespace outside their record sets, and a new + # feed with its own digest. + later = self._later_report(added_keys=["k1"]) + later["feeds"]["new"]["sha256"] = "newer" + added = self._added([("k1", "bea", "bea_nipa.cy2024.total_wages_salaries")]) + added["new_feed"]["sha256"] = "newer" + assert _follow_later_repin_report( + later, + feed_sha256="old", + feed_rows=10, + anchor_record_sets=self._ANCHORS, + added=added, + declared_source="bea", + declared_namespace="bea_nipa.", + ) == ("newer", 11) + # Each refusing case below names the check that must refuse it, so a check # moved ahead of another fails the case it takes over. A check that reads # only the first entry of a list or a mapping, or only the last, lets @@ -1621,6 +1645,40 @@ def test_a_later_report_refuses_a_listing_it_cannot_follow( ) for anchor in sorted(_ANCHORS) ), + # A hash change, then a dimension label change, in a B4923C record + # set, between two record sets outside the anchors, in the second + # of three changed fields: one case for each anchor and field, + # which the default arguments bind. + *( + ( + lambda r, fields=fields, anchor=anchor: r["rows"][ + "changed_fields" + ].update( + { + fields[0]: {"rows": 1, "by_record_set": {"x": 1}}, + fields[1]: { + "rows": 3, + "by_record_set": {"x": 1, anchor: 1, "z": 1}, + }, + fields[2]: {"rows": 1, "by_record_set": {"z": 1}}, + } + ), + "changes a B4923C record set", + ) + for anchor in sorted(_ANCHORS) + for fields in ( + ( + "layout/groupby_value_label", + "layout/record_set_spec_hash", + "dimension_value_labels/age/85_plus", + ), + ( + "layout/record_set_spec_hash", + "dimension_value_labels/age/85_plus", + "layout/groupby_value_label", + ), + ) + ), ], ids=[ "dropped-row", @@ -1634,6 +1692,12 @@ def test_a_later_report_refuses_a_listing_it_cannot_follow( "anchor-label-cy2023", "anchor-label-cy2024", "anchor-label-cy2025", + "anchor-hash-cy2023", + "anchor-dimension-label-cy2023", + "anchor-hash-cy2024", + "anchor-dimension-label-cy2024", + "anchor-hash-cy2025", + "anchor-dimension-label-cy2025", ], ) def test_a_later_report_still_refuses_dropped_or_changed_rows( From 3fa2563b60a93430026ec1bc3ed9bb073cdbef74 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Wed, 4 Nov 2026 18:20:40 -0500 Subject: [PATCH 2/2] Cover both relabeled record sets with hash and group-by changes The relabel case changes an AGI label in record set y, but its group-by label and record-set hash changes listed only record set x. Its comment says the hash covers the label changes, and in #1343's report each relabeled record set changes its group-by label and record-set hash too. The case now lists y in both, and the comment names both changes. All 34 later-report cases still pass. Against the 73 changes to the helper, every case gives the result it gave before, in both pytest modes. Co-Authored-By: Claude Opus 5.5 --- .../tests/engine_free/us/test_us_esi_premiums.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/microcosm-build/tests/engine_free/us/test_us_esi_premiums.py b/packages/microcosm-build/tests/engine_free/us/test_us_esi_premiums.py index cd5c42bc92..5b60a1cf11 100644 --- a/packages/microcosm-build/tests/engine_free/us/test_us_esi_premiums.py +++ b/packages/microcosm-build/tests/engine_free/us/test_us_esi_premiums.py @@ -1356,8 +1356,9 @@ def test_a_later_report_may_add_rows_from_its_declared_source(self) -> None: ) == ("new", 12) def test_a_later_report_may_relabel_rows_and_add_none(self) -> None: - # As microcosm#1343's re-pin did: label changes in two dimensions, - # the record-set hash that covers them, and no added row. + # As microcosm#1343's re-pin did: label changes in two dimensions, in + # different record sets, with a group-by label and record-set hash + # change in each record set, and no added row. later = self._later_report( added_keys=[], changed_fields={ @@ -1369,8 +1370,14 @@ def test_a_later_report_may_relabel_rows_and_add_none(self) -> None: "rows": 1, "by_record_set": {"y": 1}, }, - "layout/groupby_value_label": {"rows": 1, "by_record_set": {"x": 1}}, - "layout/record_set_spec_hash": {"rows": 2, "by_record_set": {"x": 2}}, + "layout/groupby_value_label": { + "rows": 2, + "by_record_set": {"x": 1, "y": 1}, + }, + "layout/record_set_spec_hash": { + "rows": 3, + "by_record_set": {"x": 2, "y": 1}, + }, }, ) assert _follow_later_repin_report(