feat(api): export cog_suggestions() (#75)
cog_suggestions(govid, years, category, flow, concept, years_present) returns the list that cog_spending() and cog_revenue() attach as attr(x, "provenance")$suggestions, given the years the caller's rows cover. A caller can run a verb once with no category, filter the rows itself, and build the suggestions for a category only when it needs them, without reaching into .build_suggestions() and six other internal names. It validates every argument before opening a session, with cli errors whose classes match the verbs' where one exists (uscogdata_invalid_expenditure_concept, uscogdata_invalid_revenue_concept, uscogdata_all_categories_not_combinable) and a new uscogdata_invalid_flow. It resolves the verbs' default basis the way .verb_spendrev() does, so it returns an empty list on a schema_version < 5 corpus, and it does not print the suggestion message. Tests check that it returns exactly the verbs' list for empty_year and suppressed_component fires, a multi-government cohort, a data-frame govid, both revenue concepts, "All Categories" under each concept, and expenditure_concept = "total" given Direct-leg years. Closes #75 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qbe6u2h83wgZdTgJgE4Xh5
This commit is contained in:
6 files changed
+575
-5