Skip to content

Standardize all endpoints on country_id with latest-version defaulting#109

Draft
anth-volk wants to merge 4 commits intomainfrom
feat/standardize-country-id
Draft

Standardize all endpoints on country_id with latest-version defaulting#109
anth-volk wants to merge 4 commits intomainfrom
feat/standardize-country-id

Conversation

@anth-volk
Copy link
Contributor

Fixes #108

Summary

  • All API endpoints now accept country_id ("us" or "uk") instead of various tax_benefit_model_name formats
  • Metadata endpoints (parameters, variables, parameter-values) default to the latest model version, preventing duplicate results
  • Optional tax_benefit_model_version_id param added for pinning to a specific version
  • Shared model_resolver service with resolve_model_name(), resolve_country_model(), and resolve_version_id()
  • Household.tax_benefit_model_name column renamed to country_id (Alembic migration included)
  • Deleted unused _get_model_version() function from analysis.py

Test plan

  • Verify /parameters/?country_id=us returns only latest-version parameters (no duplicates)
  • Verify /parameters/?country_id=us&tax_benefit_model_version_id=<uuid> pins to that version
  • Verify /variables/?country_id=uk returns only latest-version variables
  • Verify /parameter-values/?country_id=us&current=true filters by latest version
  • Verify /parameters/children?country_id=us returns tree for latest version
  • Verify /parameters/by-name with country_id in body works correctly
  • Verify /households/ CRUD uses country_id field instead of tax_benefit_model_name
  • Verify Alembic migration runs cleanly (rename column + update existing rows)
  • Verify /datasets/?country_id=us and /regions/?country_id=us still work

🤖 Generated with Claude Code

anth-volk and others added 2 commits March 9, 2026 17:48
…model_name

All API endpoints now accept country_id ('us' or 'uk') instead of various
tax_benefit_model_name formats. Adds shared model_resolver service, converts
Convention B (raw model name) and Convention C (Literal with underscore-to-hyphen
conversion) endpoints, renames Household DB column via Alembic migration, and
removes the old _get_model_version() resolver.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… pinning

All metadata endpoints (parameters, variables, parameter-values) now
resolve country_id to the latest model version by default, preventing
duplicate results when multiple versions exist. Adds optional
tax_benefit_model_version_id param for pinning to a specific version.
Supersedes #99 by combining version resolution with the country_id
standardization.

Closes #98

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
anth-volk and others added 2 commits March 10, 2026 21:43
Replace single policy_id with baseline_policy_id + reform_policy_id on
all analysis endpoints. Add PolicyIdInput sentinel type (UUID, "current_law",
or None) with _resolve_policy_input() converter. Add run=True parameter
to defer computation — when run=False, report status is set to
EXECUTION_DEFERRED instead of triggering simulation.

Includes Alembic migration to add EXECUTION_DEFERRED to reportstatus enum.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…lable

Three enum columns (region_type, report_type, decile_type) were stored as
VARCHAR but needed native PG enum types for proper SQLAlchemy deserialization.
Adds values_callable to store lowercase values and includes Alembic migration
that drops pre-existing uppercase enum types before recreating with lowercase.
Also fixes seed_regions.py to pass RegionType enum members instead of raw strings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Standardize all API endpoints on country_id and default to latest model version

1 participant