Repository navigation
Conversation
… (failing) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ports The submission service checks that the country's row allows household calculations, that the household and each policy are stored in the country, and that the policies' parameters all exist in the running catalog, then sends report_type household with the household, year, policies and add_missing_variables. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…failing) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A household report is told from an economy report by its household_id. Its result, once its newest run has succeeded, is each simulation run's calculated household from simulation_runs.household_result, read as the household function's version 1 result document; a document that cannot be read answers 500. Lists name household reports beside economy reports. The create body is a union told apart by kind, and the household checks' refusals answer 422 (no household calculations) and 404 (household not stored). Budget windows are still not read here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d that CI runs them (failing) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ling) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The request names no year, as the simulation service's household reports and household calculations take none; a household with no default year is refused with 422 before the policies are read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ing) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A failed run's simulation runs may hold the household function's failure document; the read gives each side's code, message, input errors and SPM error, as a household calculation's read does, and none for a side without a readable one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… on household reads, the create dispatch (failing) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Household reports use the household calculations' country check, error and household source; a household read has no region or dataset, which move to the economy read; the report items share one base of the fields every kind has, and the reads one helper for the newest run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… 400 codes, failures on PostgreSQL (failing) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each side's failure has its own schema, whose code is always named and whose text is about reports; the stored documents are typed as JSON; every report kind has a name for the unsupported-kind message; and the create route's 422 text reads as one sentence. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd named, each side's run status (failing) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each side's failure is a report type of its own whose code is always named, read straight from the failure document; the integration tests give each side's simulation run its own status, and a test checks that every report kind has a name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e each side's recorded status Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4293 +/- ##
==========================================
+ Coverage 93.22% 93.31% +0.08%
==========================================
Files 357 364 +7
Lines 20526 21040 +514
Branches 3338 3406 +68
==========================================
+ Hits 19136 19634 +498
- Misses 818 828 +10
- Partials 572 578 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…bases Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every report kind is now read, listed and created by /v2/reports: the read types, item models, request union and submission client hold all three, budget windows declare their own region and dataset, the window tests build the submission service with a household source, and the tests of a kind that cannot be read yet are gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every kind of report is now read, listed and created here, so the 422 for an unreadable kind, its error and the kind filter on lists are gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… (failing) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The user decided household reports always add every variable the household lacks, since their caller needs every value; the simulation service now refuses the field. The request body and the body sent to its /reports no longer have it, and reads find nothing about it in options. Household calculations keep their option. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch was previously 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 #4291
Summary
/v2/reportsserves household reports: reports over two household simulations of one stored household. There is no separate household-report route. This replaces #4132, which was built on the simulation service's/v2/household-reportsroutes that the redesign removed.Create.
POST /v2/reportstakes a body told apart bykind. Economy bodies are unchanged. A household body is:{"country_id": "uk", "kind": "household", "label": "…", "description": null, "household_id": "<uuid>", "baseline": {"policy_id": null}, "reform": {"policy_id": "<uuid>"}}default_year, as/v2/household-calculationsand the simulation service's household reports do, so the body names no year.reformnull or omitted makes a report of the baseline alone. Each empty object is current law./calculate-fulldoes, because the household report page needs every value. There is noadd_missing_variablesoption, unlike Serve household reports at /v2/reports #4132 and/v2/household-calculations: a body naming it is refused with 422, and the simulation service refuses it too.reports.inputsis{}for a household report, so reads answeroptions: {}.Before asking the simulation service, the Public API checks, in this order, with
/v2/household-calculations' checks and errors:countriesrow hashousehold_enabled. Otherwise it answers 422. A household-only country passes, and still gets 422 for economy reports.missing_parameters, the baseline's policy first), as economy reports are checked (Refuse /v2/reports and /v2/simulations submissions whose policies set missing parameters #4286).A database or catalog that cannot be read during these checks answers 503. Then
SimulationSubmissionService.submit_household_reportsends the simulation service'sPOST /reports:{"country": "uk", "report_type": "household", "label": "…", "description": null, "household_id": "<uuid>", "baseline": {"policy_id": null}, "reform": {"policy_id": "<uuid>"}}Its answers are read exactly as an economy report's are: the same 201/202, 422, 400, 500, 503 and lost-answer handling, and the same 502 with
report_idwhen the created report cannot be read back. The simulation service's household 400 codes (unknown_household,unknown_policy,unknown_catalog_version,no_household_function,missing_reference) describe its state or rows the Public API already checked, so they answer 503. Its 422s (missing_parameters,household_not_calculable) answer 422 with their reasons.Read and list. A report whose row has
household_idset is a household report.GET /v2/reports/{report_id}answers its definition, withkindhouseholdandhousehold_id, and its newest run, whatever its status and versions. Once that run has succeeded,resultholds each simulation run's calculated household, read fromsimulation_runs.household_resultas the household function's version 1 result document (the documenthousehold_jobs.resultholds). Each side has the same shape as a/v2/household-calculationsresult:household,warnings,spm_configandspm_provenance.result.reformis null for a report of the baseline alone.failuregives each side's calculation error from its failure document:code,message,input_errorsandspm_error, as a/v2/household-calculationserror. A side is null when it succeeded or has no readable failure document, as for a run Modal refused. The run'serror_messagestill says why it failed.GET /v2/reports?report_id=…lists household reports beside economy reports, in the order named and without results or failures.User-visible contract changes
POST /v2/reportsacceptskindhousehold. Its schema is a union told apart bykind, and its 404 and 422 descriptions cover the household checks.GET /v2/reports/{report_id}andGET /v2/reportsanswer household reports instead of 422 (or leaving them out of lists). Their item schemas are unions told apart bykind, now of all three kinds. No kind is refused any longer, so the read's 422 for a kind it could not read yet is gone.result.item.kindon the report read. The regenerated documents are included./v2/user-reports) already accept any report'sreport_id.Merge order
It was built on #4286 and #4281, which have both merged;
masteris merged in (no rebase), and the base ismaster./v2/reports) merged first; this branch merged it in./v2/reportsnow reads, lists and creates all three kinds. A budget window's read declares its own region and dataset, and its tests build the submission service with a household source./reports), which sends and stores exactly the shapes above. Once it merges, sim's release publishes apolicyengine-api-simulation-clientwithHouseholdReportRequest; the Public API will depend on that release. Until it is deployed, a household report create answers what the deployed simulation service answers to it: 422 from a/reports(Create economy reports and simulations through POST /reports and POST /simulations policyengine-sim-api#1052) that does not knowreport_typehousehold, or 503 where/reportsis not deployed. When it ships, this PR is updated to what it actually ships, including any release ofpolicyengine-api-simulation-clientthe Public API must depend on.Environment variables and secrets
No new variables or secrets. The new code reads:
SIMULATION_ENTRYPOINT_URL: a GitHub environment secret (staging,production) → the Cloud Run deploy jobs'env:inpush.yml→deploy_cloud_run_candidate.sh→ Cloud Run runtime. These are the same economy report adapter and client as Serve economy reports and simulations from the detailed-save tables at /v2/reports and /v2/simulations #4281.GATEWAY_AUTH_ISSUER,GATEWAY_AUTH_AUDIENCE,GATEWAY_AUTH_CLIENT_IDandGATEWAY_AUTH_CLIENT_SECRET_RESOURCE: organization secrets → the deploy step'senv:→ the deploy script → Cloud Run runtime. The client secret is read from Secret Manager at runtime. These are unchanged from Serve economy reports and simulations from the detailed-save tables at /v2/reports and /v2/simulations #4281.V2_RUNTIME_DATABASE_URL_SECRET_RESOURCE), unchanged. The runtime role readscountries,households,policies,reports,simulations,simulation_runsandreport_runs, and holdsSELECTon each. The integration tests run as that role.The workflow change adds
tests/integration/test_v2_household_reports.pyto an existing step ofv2-integration-check.yml. Its database URL and settings are the job's literal disposable values inenv:(V2_MIGRATION_DATABASE_URL,V2_ALEMBIC_DISPOSABLE_TEST,DEPLOYMENT_ENVIRONMENT). No secret is involved.Not verified:
SIMULATION_ENTRYPOINT_URLserves a revision with household reports in/reports(C1 · 15);Inline suppressions
None added.
Testing
Each change was built test-first, and each failing test was committed before its fix.
SimulationSubmissionServiceconstruction passeshouseholds;test_v2_report_reads's unreadable-kind test now uses a budget window;test_alembic_workflowschecks that CI runs the new integration file.alembic -c alembic-v2.ini checkon a fresh PostgreSQL 17 database reports no operations.lint-imports,python -m scripts.rules validate,python scripts/run_quality_guards.py, ruff, ruff format and mypy pass. Nothing underpolicyengine_api/data/v2/changed.Review
Four read-only review rounds, none of which found a bug, then a fifth on the changes after merging #4290 and dropping
add_missing_variables. Every quality finding was fixed, each code change test-first:/v2/household-calculations' country check, error and household source. Region and dataset moved off the shared read to the economy read. The report items share one base model. The changelog's "two simulations" is corrected. Tests cover the create dispatch.🤖 Generated with Claude Code