Skip to content

Phase 4: Custom computation modules#88

Merged
anth-volk merged 5 commits intoapp-v2-migrationfrom
feat/sim-report-migration/phase-4
Feb 23, 2026
Merged

Phase 4: Custom computation modules#88
anth-volk merged 5 commits intoapp-v2-migrationfrom
feat/sim-report-migration/phase-4

Conversation

@anth-volk
Copy link
Contributor

Summary

  • Module registry: Frozen dataclass-based registry mapping 10 module names to metadata (label, description, countries, response_fields)
  • GET /analysis/options: Lists available computation modules, filterable by country
  • POST /analysis/economy-custom: Runs only selected modules and returns a filtered response (nullifies unrelated fields)
  • Composable module functions: Extracted ~680 lines of inline computation from monolithic UK/US functions into 14 standalone module functions with dispatch tables and a run_modules() helper
  • 119 unit tests covering registry, options endpoint, economy-custom endpoint, filtered response logic, dispatch tables, function signatures, and run_modules behavior

Test plan

  • All 119 Phase 4 tests pass (pytest tests/test_module_registry.py tests/test_analysis_options.py tests/test_economy_custom.py tests/test_computation_modules.py)
  • Ruff lint/format clean on all Phase 4 files
  • Verify /analysis/options returns correct modules per country in staging
  • Verify /analysis/economy-custom runs only requested modules end-to-end

🤖 Generated with Claude Code

anth-volk and others added 5 commits February 21, 2026 00:44
Define ComputationModule dataclass and MODULE_REGISTRY with 10 modules
(decile, program_statistics, poverty, inequality, budget_summary,
intra_decile, congressional_district, constituency, local_authority,
wealth_decile) plus helper functions for country filtering and validation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Returns available economy analysis modules from the registry, with
optional country query param to filter by UK/US applicability.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Accepts same inputs as /analysis/economic-impact plus a modules list.
Validates module names against the registry for the given country,
triggers computation, and filters the response to only include fields
for the requested modules. Includes GET polling endpoint with optional
modules query param.

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

Move each module's computation logic (decile, poverty, inequality,
budget_summary, program_statistics, intra_decile, constituency,
local_authority, wealth_decile, congressional_district) into standalone
functions in computation_modules.py with UK/US dispatch tables.

The local economy comparison functions now call run_modules() with an
optional modules list, enabling selective computation from the
/analysis/economy-custom endpoint.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add comprehensive test coverage for module registry, analysis options,
economy-custom endpoint, and computation module dispatch system.
Includes lint/format fixes from ruff.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@anth-volk anth-volk merged commit df87ca7 into app-v2-migration Feb 23, 2026
1 check passed
@anth-volk anth-volk deleted the feat/sim-report-migration/phase-4 branch February 23, 2026 11:06
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.

1 participant