fix: gate IG-counterpart matching to the direct-expenditure flow family

Review found the suffix-set match alone is unsafe: revenue-side recipes
(ig_federal_b47_wide, ig_state_c47_wide, ig_local_d47_wide, and their *_89
siblings) coincidentally share exact suffix sets with M/L expenditure
recipes despite representing a different flow direction. Reachable today via
a mis-scoped cog_spending(category = "IG Federal") call, not just
cog_revenue(). Thread flow_prefixes (same parameter .build_harmonization_block
already uses) through .build_suggestions()/.attach_ig_counterparts() and
require a firing recipe's own prefixes to be both in the calling verb's flow
family and within {E,F,G} before searching the M/L catalog.
This commit is contained in:
2026-07-27 11:08:57 -04:00
parent c28712f62f
commit 24b2ff7d8c
3 changed files with 124 additions and 16 deletions
+2 -1
View File
@@ -217,7 +217,8 @@ cog_spending <- function(govid, years, category = NULL,
harmonization <- .build_harmonization_block(
con, govid, years, resolved, flow_prefixes
)
suggestions <- .build_suggestions(con, govid, years, category, result, resolved$basis)
suggestions <- .build_suggestions(con, govid, years, category, result,
resolved$basis, flow_prefixes)
}
# Determine expenditure_concept_note: only non-empty for "total", explains