Repository navigation
Conversation
Saved reports keep, in `provisions`, the growth settings of each indexed
change in their reform (path plus the growth keys, without values), as app v3
sent them before D1 · 5. Saves and updates store them, every user-report
read and /v2/shared-reports/{id} return them, and rows saved before D1 · 5
are read down to their settings. The column-only test class goes, since the
model maps the column again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
App v3 lets a reform's change grow from one year on with an index or with
current law, and a policy keeps only the yearly values that gives, so the
saved report is the only place the settings live. D1 · 5a stopped storing
them, which left app v3 unable to reopen an indexed change as indexed.
API v2 maps `user_report_associations.provisions` again. Saves and updates
keep the `path` and growth keys of each indexed change (growth set and not
`fixed`) and discard other changes, values, labels and dated schedules; a
change's `breadcrumb`, `baseline_value` and `value` become optional. The
owner's reads, `/v2/shared-reports/{id}`, the account export and the admin
saved-items read return the settings, and rows saved before D1 · 5 are read
down to them. Published reports still return none. No revision is needed:
the column never left the table. Project 17 moves the settings into policies
and drops the column.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 1 found that a stored growth key of the wrong type, or a column holding something other than a list, reaches the response item, which raises, so one such row fails the owner's list, the account export and the admin saved-items read. The tests read such rows through the response item. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A read keeps a stored item only when each growth key it sets holds its JSON type (no booleans for numbers), and a column that holds no list gives no settings, so one row can never fail a list or an export. Restore the simulation-role privilege test's wording, which was right: since revision 4e30076d4b9f no model of the simulation tables leaves a column out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 2 found that a stored integer `growth_round_to` too large for a float passes the read, and the response item refuses it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A number stored for `growth_round_to` must convert to a finite float, as the response item requires, or the read skips the item. The saved report's response item also says the settings are temporary. 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 ❌ Your patch check has failed because the patch coverage (67.27%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #4414 +/- ##
==========================================
- Coverage 93.99% 93.94% -0.06%
==========================================
Files 459 459
Lines 26259 26308 +49
Branches 4088 4104 +16
==========================================
+ Hits 24682 24714 +32
- Misses 901 908 +7
- Partials 676 686 +10
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:
|
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 #4413
Summary
Saved reports keep the growth settings of their reform's indexed changes again, for now. App v3 lets a reform set a parameter from one year on and then grow it with an index (such as CPI-U) or as current law grows it, with rounding; a policy keeps only the yearly values that gives, so the saved report is the only place the settings live. #4402 stopped storing them, so app v3 could no longer reopen an indexed change as indexed. This partly reverses #4402, under the old names, as a temporary home: a later project moves the settings into policies and drops the column.
user_report_associations.provisionsagain (noexclude_properties). No Alembic revision and no data change: the column never left the table. Thecolumns_left_out_of_the_mappercategory of direct SQLAlchemy use goes, since no model uses it now.POST /v2/user-reportsandPATCH /v2/user-reports/{id}takeprovisionswithout the deprecated mark. Only indexed items are kept:growthset and notfixed(an empty string counts as not indexed). Each stored item ispathplus the growth keys it sets (growth,growth_start,growth_base,growth_round_to,growth_round). Values, labels and dated schedules are checked as before (64 KiB cap, no NaN or Infinity, no unknown keys) and discarded.breadcrumb,baseline_valueandvaluebecome optional, so app v3 can send only the path and settings; older builds' full items are accepted again and their settings kept. OnPATCH, a list replaces the settings,nullclears them, and leaving the field out keeps them.GET /v2/shared-reports/{id},GET /v2/me/exportand the admin saved-items read returnprovisionsas a list ofReportGrowthSettingsItem(keys not set are absent, not null), ornull. Rows saved before Saved reports stop storing and returning a copy of the reform's changes #4402 hold full copies of the reform's changes; reads return them read down to the same settings without changing the row. A stored item whose growth keys don't hold their JSON types is skipped, and a column holding no list gives no settings, so one row never fails a list or an export.provisions.provisionsagain for the user-report and shared-report routes. Changelog fragmentsaved-reports-growth-settings.added.md.Migration scope: the
reportroute group (/v2/user-reports,/v2/shared-reports/{id}) and the account export and admin saved-items reads that return saved reports. Nothing changes on the Flask/API v1 path, and nothing new is prepared for other services. User-visible API contract changes, intended:provisionsis returned again on those reads, and the request field is no longer deprecated, withbreadcrumb,baseline_valueandvalueoptional. No inline ruff suppressions added.It fixes a test that fails on
master:tests/unit/v2/test_me_routes.py::test_export_answers_the_current_run_of_each_saved_reportpassesprovisions=NonetoUserReportRead(from #4386), which #4402 removed, so it fails with aTypeErrorthere.Testing
Failing tests first (
b1c9f689b), then the change (ae2c64e8a). Newtests/unit/v2/test_saved_report_growth_settings.pyreplacestest_saved_report_reform_copy.py, and the column-only test classsaved_report_reform_copies.pygoes (its users store through the model). Changed: the report and shared-report route tests (round trip, settings-only save, keys echoed only when stored, OpenAPI types), the account-service, export and admin tests, the model and persistence-category tests, the published-page test and its fixture, the contract registry, andtests/integration/test_v2_user_identity_persistence.py::test_non_finite_numbers_never_reach_jsonb.Each test run by its own node ID (21 nodes, 42 cases with parameters, including the integration test against a disposable PostgreSQL 17 database):
b1c9f689b: 26 failed, 16 passed (unchanged parameter cases and the published-page assertion). The failures were assertions, orTypeError/AttributeErrorwhere tests pass or readprovisionson read records that had no such field yet, or a validation error where a save sends only path and settings;ae2c64e8a: 42 passed.Review fixes, each test first:
6c595b10bthenb519104d7(4 cases: 4 failed, then 4 passed), and5e0b18699then2299e0a08(1 test: failed, then passed).Checks:
make quality-check(ruff, ruff format,lint-imports, mypy on its configured files, the quality guards including the migration-contract and rules guards) passed;alembic -c alembic-v2.ini checkagainst the disposable database found no new operations;python -m scripts.rules validatepassed.Review
Three rounds of adversarial review before this PR:
policyengine-api-v2plan-d1-10-saved-reports-growth-settings-review-round1-2026-12-04.md): no high or medium bugs; one low: the read copied growth values without type checks and assumed a list, so a malformed row (only possible by a manual edit) would make the response item raise. Fixed inb519104d7. It also found a test docstring this branch had made wrong; restored....-review-round2-2026-12-05.md): no high or medium bugs; one low: a stored integergrowth_round_totoo large for a float passed the read and the response item refused it. Fixed in2299e0a08, and the response item's description now says the settings are temporary....-review-round3-2026-12-05.md): no bugs. Its note that the request item's OpenAPI description named an internal function is fixed inf6c37fe9e.Bugs left: none. Points left as they are: the growth keys are declared in the request model, the read function and the response item (the old shape, kept for a temporary column); the request model still converts input as it did before #4402 (for example
growth_start: truebecomes 1); OpenAPI shows the optional growth keys as nullable, as before #4402; reading old rows is tested on SQLite only.Merge order
This is task D1 · 10 of the detailed-save API project. Every earlier task is complete: D1 · 0 to D1 · 7a are deployed, and D1 · 8 (#4400) and D1 · 9 are merged; none of their deployments is needed, since this change uses only a column that has always existed and #4402's code. The merge waits only for this PR's checks. It builds on
master, not on another task's branch. No deployment code changes, so there is no environment table.The app side (saving the settings again and reopening indexed changes as indexed in Build) is a separate app v3 task, which needs this deployed.
🤖 Generated with Claude Code