Repository navigation
Conversation
anth-volk
added this pull request to stack #3917
October 14, 2026 18:47
anth-volk
force-pushed
the
ruff-complexity-economy
branch
3 times, most recently
from
October 14, 2026 21:13
59307e2 to
b87554c
Compare
anth-volk
force-pushed
the
ruff-complexity-economy
branch
4 times, most recently
from
October 14, 2026 22:56
51e6891 to
827680a
Compare
Snapshot the complete economy comparison output (UK and US, every breakdown region and income-change bucket, cliffs) with key order, value types and float reprs, and add focused characterization tests for the economy service's request plumbing, the shared-cache keys and records, the household calculation options and cache reads, SPM selection and worker-result checks, and the release command. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Split the constituency and local-authority breakdowns into a region filter, a dataset load, an income-change bucket lookup and one shared per-area loop, and name the poverty age bands and income-change thresholds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve an SPM selection in parse, bundle-configuration and certified-merge steps, check budget-window and annual worker results in separate helpers, and name the calendar-year length and the release command's argument count. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Also name the in-memory fake's compare-and-delete argument count. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Group the policy pair, region, dataset and period into ReformImpactScope and add ReformImpactIdentity (scope, cache version and options hash), so the reform-impact cache, its service and the budget-window cache key take one object instead of eight or more fields. Stored impacts take a ReformImpactExecution (execution ID, start time, observability ID), and the error and completion updates drop the scope arguments they ignored. Cache keys and stored records are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pass an annual or budget-window request as an EconomicImpactRequest, which lives in its own module so routes need not load the service to build one. Split the budget-window request into stored-state replay, batch polling and claimed submission steps, and impact creation into reuse, stored-impact and claim-and-submit steps. Group the options-hash bundle fields into RuntimeBundleIdentity and the budget-window year lists into BudgetWindowYearProgress, build simulation options from the setup options, and name the number of computing years a progress message lists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
prepare_household_calculation and calculate_household take a HouseholdCalculationOptions (add_missing, spm, spm_requested) instead of three keyword arguments; the calculate route builds it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The per-area rows are plain dicts that the breakdown models validate, so type them as dict[str, Any] rather than dict, which mypy reads as a mismatch with the models' field types. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Alembic tests load a logging configuration that disables existing loggers, so in a full run the comparison module's logger no longer reached caplog. Attach a recording handler to that logger, enabled for the test's duration, so the snapshot sees what the module logs in any test order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk
force-pushed
the
ruff-complexity-economy
branch
from
October 15, 2026 00:06
827680a to
e26d4a5
Compare
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3929
Summary
Phase 1 step 1.8, group 8b, part 1 of 3: the economy and calculation services, refactored within ruff's complexity limits. Stacked on #3924. Part 2 (#3933) covers the rest of the application, and part 3 (#3934) covers tests, scripts and the rules tool, then switches ruff to
ALL.economy_comparison.py):ADULT_MIN_AGEandSENIOR_MIN_AGE.tests/data/economy_comparison_snapshots.jsonstores the complete output ofcompare_economic_outputsand both breakdowns for UK, US and other-country inputs (17 regions each). It records every dict's key order, floats asrepr, value types and the logs, and the refactor reproduces it exactly. Regenerate it only deliberately, withECONOMY_COMPARISON_SNAPSHOTS=update. The file is about 200 KB.get_economic_impactandget_budget_window_economic_impacttake anEconomicImpactRequest, in its own module, instead of 9–11 arguments.ReformImpactScope,ReformImpactIdentityandReformImpactExecutionreplace the long argument lists. The cache's key strings and stored records are unchanged, and pinned by tests.set_error_reform_impactandset_complete_reform_impactdrop the scope arguments they already ignored.budget_window_cache.build_keytakes the scope.HouseholdCalculationCache.getsplits into a well-formedness check and a receipt check.spm.normalize_spm_selectionandworker_spm._check_worker_resultare split into steps, with the same error codes, messages and causes.household_calculation_servicetakes aHouseholdCalculationOptions.routes/economy_routes.py,routes/household_routes.pyand the affected tests.Testing
pytest tests/unit tests/contract, to_refactor and the dedupe integration test (themake testset) at this branch's tip: 2,599 passed, which is the base's 2,433 plus the 166 new tests.make typecheck-v2is clean. mypy on the changed application files outside that gate shows no new errors.ruff checkandruff format --check(0.15.12) are clean.redis-server./v2/openapi.jsonpreview and the legacy spec are byte-identical to the base. The only additions are adapter entries for the new internal dataclasses.test_v1_route_contracts.pyleaves a fake-backedeconomy_routesmodule bound for later tests, andtest_alembic_baseline.py's logging setup disables existing loggers for the rest of the run. The new snapshot test records logs from the module logger for that reason.CI complete, which fails and says why. Its full run starts once the PRs below it merge.🤖 Generated with Claude Code