Repository navigation
Record each API v2 report run's region, year, report type and .py version on its coordinator log record - #1203
Merged
Merged
Conversation
Tests that fail before the change: API v2's coordinator request carries report_type (single_year unless the simulation service names a budget window's year budget_window_year, which later years copy), and the coordinator's operation names the report's country, region, breakdown, scope, simulation year and report type, with the app's .py version as its service version and the Modal app's name, as API v1's run_simulation records and the v2 workers' records do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
API v2's coordinator request (ReportExecutionInput) carries report_type, as API v1's run_simulation requests do: the simulation service names a budget window's first year budget_window_year, on a new window and on a window re-run, and every later year copies it through year_calculation. The field is left out of the request's JSON when single_year, so a v2 application deployed before it accepts every other report. The coordinator's operation names the report's country, region, breakdown (local_areas for a UK report on the local-area dataset), scope, simulation year and report type, read from its own request under API v1's attribute names, plus modal_app_name; its runtime carries the app's .py version as service.version, as the v2 workers' do. A request that can't be read names none of them and the call goes on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 1 fixes: - report_run_calculation takes report_type as a required keyword, so each caller names single_year or budget_window_year; the two report-type constants are typed Final[ReportType]. - A coordinator test makes the local-area check raise and confirms the call still runs without a breakdown; the test reading a real operation record now covers breakdown too. - The observability guide gets its own section on the coordinator's report fields: which calls lack them, how to select API v2 report runs (database_table = report_runs), the household scope, and how local_areas work differs from API v1's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 2 fixes in the observability guide's coordinator section: - Select API v2 report runs by the operation name and database_table = report_runs, since household report runs name the same table. - Deduplicated calls and preempted calls' retries write records with the same fields, so a run-time summary keeps one per database_row_id. - A household scope appears only on failed calls; API v1's segmented national runs record simulation_year as a string; the run record's report_type differs from the report_type API v2 stores on a report. - Later years' requests are copied from an earlier year's, here and in the contract's field comment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 3 fixes: API v2's reports row stores type as economy or household; the release routes the constituency and local-authority regions to the local-area dataset; nothing marks a deduplicated call's record, so a run-time summary keeps the longest successful record of each report run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk
marked this pull request as ready for review
December 3, 2026 23:17
Since #1193 the reports row also stores budget_window as a report's type, so the guide no longer lists its values; it only says the run record's report_type is a different field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 #1201
What this changes
API v2's report coordinator (
coordinate_report) now records the report it runs on itsstage12_coordinator_executionlog record, under the attribute names and values API v1'srun_simulationrecords use. The run-time summary can then group API v2 report runs the same way as API v1's.Contract library.
ReportExecutionInputgainsreport_type(ReportType:single_yearorbudget_window_year, API v1's two values), which defaults tosingle_year. The request's JSON leaves the field out when it issingle_year(exclude_if, ascliff_result_iddoes). So every single-year request stays byte-for-byte as before, and a v2 app deployed before this change still accepts it.BUDGET_WINDOW_YEAR_REPORT_TYPEandSINGLE_YEAR_REPORT_TYPEare typedFinal[ReportType].Simulation service.
report_run_calculationtakesreport_typeas a required keyword argument:budget_window_year.year_calculation, so they keep the value.single_year.Coordinator.
coordinate_report:modal_app_name;stage12_runtime.report_record_attributesreads from its own request:country,region(the region code, such asstate/ca),scope,simulation_year(an integer),report_type, andbreakdown: local_areasfor a UK-wide or nation report on the local-area dataset.A request that can't be read names none of these, and a failing local-area check leaves
breakdownout. Either way the call goes on: telemetry never fails a request.Docs.
docs/engineering/skills/observability.mdhas a new section, "API v2 coordinator report fields". It covers:database_table = report_runs, not byexecution_mode;local_areaswork differs between the APIs;Changelog fragment:
changelog.d/v2-coordinator-report-fields.added.md.No deployment code changes, and no environment variable is added or read, so there is no environment-variable table.
Tests
The tests are committed before the change (
18116ae9); the change is01d90e8e. Each test was run on its own by pytest node ID:report_typeis refused and that an unreadable request still runs.report_type. The new local-area test fails when theexceptit covers is removed.test_stage12_budget_window_years.py: 3test_budget_window_submissions.py: 1,test_economy_reruns.py: 2,test_economy_submissions.py: 1,test_economy_calculation_inputs.py: 2 changedtest_v2_coordinator_record.py: 8Ruff 0.15.22 format and lint are clean on every changed Python file. Pyright 1.1.414 reports 0 errors on the changed source modules and on the API v1 modules that use the two constants.
Review rounds
Three rounds of adversarial review, each in a fresh clone:
Round 1 (
…-review-round1-2026-12-04.md). Two low-priority bugs:report_typeif it still receives the new service's requests.single_year.Fixes in
831a99a8:report_typeis now required inreport_run_calculation;Final[ReportType];breakdown;Round 2 (
…-review-round2-2026-12-04.md). One medium-priority bug: round 1's bug 1 can also happen when a .py update is released together with this change, or when the v2 default already names an older app. No code change: the one-PR scope was decided. It is handled by the checks before merging below. Guide fixes in7aa81098.Round 3 (
…-review-round3-2026-12-04.md). Two low-priority gaps in those checks:release_is_defaultoutput.Guide wording fixes in
be5fb8e0.After #1193 merged, which stores
budget_windowas a report'stype,91aca5fcstops listing that field's values in the guide.Bugs left (all low priority):
What the merge waits for
Every earlier task in the tracker (substage 1.8 of "Report runtimes") is complete. None of their deployments is needed: this PR changes only API v2's coordinator request and log records, and the summary query (1.8 · 4) reads those records once they exist.
Checks right before merging (read-only; if any fails, the merge waits):
policyengine[models]==6.20.5).Deploy Simulation APIrun onmainis in progress or queued.publish_stage12_v2_defaultjob printedrelease_is_default=truein both beta and prod.For whoever merges the next .py pin change: please wait until this change's release has moved the production v2 default (its
publish_stage12_v2_defaultjob printedrelease_is_default=truein prod). Until then, a v2 app deployed before this change could still receive budget-window years carryingreport_type, and it would refuse them.The merge uses
gh pr merge --admin --merge --match-head-commit <head>, on Anthony's instruction for this PR only. It skips only the required approving review, once every required check has passed. The repository rulesim.process.agents-never-bypassotherwise forbids--admin.🤖 Generated with Claude Code