Skip to content

Drop the report columns API v1 removes from sim's table models - #1111

Merged
anth-volk merged 10 commits into
mainfrom
v2plan/c1-42-drop-report-columns
Nov 25, 2026
Merged

anth-volk merged 10 commits into
mainfrom
v2plan/c1-42-drop-report-columns

Conversation

@anth-volk

@anth-volk anth-volk commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1110

Sim's mapped classes of reports, report_runs and budget_window_runs no longer declare the nine columns that API v1's revision 4e30076d4b9f drops (PolicyEngine/policyengine-api#4335, C1 · 41), or the foreign key, index and check constraint it drops with them. public-api-commit moves to 825a9b3c9, API v1's merge of #4335.

Follows #1096 (C1 · 38), merged as 770091fc, which stops the v2 runtime writing report_runs' four cliff columns.

What changed

  • Report no longer declares label, description, user_id, fk_reports_user_id_users or ix_reports_user_id.
  • ReportRun no longer declares trigger, baseline_cliff_gap, baseline_cliff_share, reform_cliff_gap, reform_cliff_share or ck_report_runs_cliff_impact_complete.
  • BudgetWindowRun no longer declares trigger. recalculate stays.
  • ReportRunTrigger, the enum of the two trigger columns, and ReferencedUser, the model of users that only reports.user_id referenced, had no other use, so they are removed with their exports. Sim's foreign keys to API v1's tables go from 20 to 19, and its enum columns from 8 to 6.
  • New guard tests, test_a_model_maps_none_of_the_columns_api_v1_drops and test_a_model_declares_no_constraint_or_index_api_v1_drops, fail if any of them returns.
  • Tests and fixtures no longer name the columns, and the documentation and docstrings that described them are updated. Changelog fragment: c1-42-drop-report-columns.removed.md.
  • libs/policyengine-simulation-persistence/public-api-commit moves from d2b5dc310 to 825a9b3c9, API v1's merge of Drop the per-user and cliff columns from v2 report rows policyengine-api#4335. That commit also contains #4329 and #4333, which change no table or grant.

With #1096, no statement names these columns, and none selects or inserts whole rows of these three classes, so the change removes declarations only.

Deploy order

This release and C1 · 41's revision can be applied in either order, as long as a sim release with #1096 is in production first. C1 · 41 already requires that.

No deployed code compares these tables with the models: the live schema check in validation.py covers only the stage12_evaluation_* tables.

The pinned API v1 commit

At 825a9b3c9, tests/test_public_api_schema.py::test_the_models_match_the_public_api_tables finds no differences, so no test is expected to fail. At the previous pin, d2b5dc310, it found 12: the nine columns, the foreign key, the index and the check.

Tests

Test-first: 65bcb8d0 adds the failing guard tests before the change. Only selected tests ran, each by node ID. They ran against two disposable PostgreSQL 17 databases, each built with API v1's migration chain and privilege manifest:

  • without: API v1 at 825a9b3c9, the new pinned commit, revision 4e30076d4b9f, which drops the columns.
  • with: API v1 at d2b5dc310, the previous pinned commit, revision bc334f9877b7, which still has them.
Database Service (116 cases) Runtime (101 cases) Schema comparison (6 cases)
without pass pass pass
with pass pass 5 pass; test_the_models_match_the_public_api_tables fails with the 12 differences above

The service cases cover creates, re-runs, budget windows, and writes by both database roles. The runtime cases cover report run completion, the budget window store, household runs, the stuck-run sweep and cliff results.

Sim's checks pass: the pinned Ruff format and lint, the rules registry, the quality guards including file length, the lock checks, and Pyright for the two persistence libraries and the entry project.

Review

Four review rounds.

  • Round 1 found two tests still expecting 20 foreign keys and 8 enum columns. Fixed in 59f4eea0.
  • Round 2 found no bugs. Its one test-quality finding is fixed in 8d220f96: the two completion tests seed a pending cliff result for each side and require it unchanged. They fail when completion is changed to update those rows.
  • Round 3, on the merge of main and the move of public-api-commit, found one bug: test_a_request_losing_the_report_run_adds_the_winners_runs_calculations, which Start each side's cliff calculation when a report asks for cliffs #1099 added, still inserted report_runs.trigger, and the Public API schema job failed on it. Fixed in 1a00cbf8.
  • Round 4 found no bugs.

Merge with #1099

#1099 (C1 · 39) merged first. 653e47d1 merges main and resolves three conflicts, in docs/migration/stage-12-modal-worker-foundation.md, keyed_economy_records.py and the entry project's README.md: each keeps #1099's include_cliffs text and drops the sentences about the columns API v1 removes. 1a00cbf8 stops one test #1099 added inserting report_runs.trigger.

🤖 Generated with Claude Code

anth-volk and others added 6 commits November 25, 2026 00:19
API v1's revision 4e30076d4b9f drops reports.label, description and
user_id, report_runs.trigger and its four cliff columns, and
budget_window_runs.trigger, with the foreign key, index and check on
them. The models still map all of them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Report loses label, description and user_id, with its key to users and
that column's index. ReportRun loses trigger and its four cliff columns,
with their check. BudgetWindowRun loses trigger. ReportRunTrigger and
ReferencedUser have no other use, so they go too.

No statement named these columns already, apart from the models
themselves, so the models work on a database that still has them, where
new rows leave them null, and on one without them. The test fixtures stop
writing them so they run against both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fixture selected every column the model maps, so it would fail on a
database without one of them, whichever release it tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test_tables counted eight enum columns, two of them the trigger columns.
test_mapped_classes repeated the foreign key total test_tables already
checks along with the keys themselves, so it no longer states one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The two completion tests lost what they checked when the report run's
cliff columns went, so they now check that no cliff_impacts row appears.
Also drop two names that came from the removed trigger values and the
remaining notes that shared rows hold no label, user or trigger, which
no longer describe any column.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With no cliff_impacts row seeded, the two completion tests could not see
an update of one, and the Modal worker role can't insert one. They now
seed a pending result for each side and check it stays unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anth-volk
anth-volk force-pushed the v2plan/c1-42-drop-report-columns branch from decbea8 to 8d220f9 Compare November 24, 2026 20:30
Base automatically changed from v2plan/c1-38-run-cliff-results to main November 24, 2026 21:21
anth-volk and others added 4 commits November 25, 2026 19:42
#1099 rewrote three passages beside C1 · 42's removals: the Stage 12
worker document's cliff paragraph, KeyedEconomyReport's docstring and the
entry project's re-run section. Each keeps #1099's include_cliffs text and
drops the sentences about the per-user and cliff columns API v1 removes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
public-api-commit moves from d2b5dc31 to 825a9b3c9, API v1's merge of
PolicyEngine/policyengine-api#4335 (C1 · 41). Its revision 4e30076d4b9f
drops reports.label, description and user_id, report_runs.trigger and its
four cliff columns, and budget_window_runs.trigger, with their foreign key,
index and check, none of which sim's models declare any more. Its privilege
manifest no longer grants updates of the four cliff columns. The
`Public API schema` job's comparison now builds those tables without them,
so test_the_models_match_the_public_api_tables can pass.

The commit also contains PolicyEngine/policyengine-api#4329 and #4333,
which change no table or grant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#1099 added test_a_request_losing_the_report_run_adds_the_winners_runs_calculations
on main, and it inserts a competing report run with trigger="initial". The
merge of main into this branch kept it, but ReportRun no longer maps
trigger, which API v1 drops, so the insert failed to compile ("Unconsumed
column names: trigger") and failed the Public API schema job. The insert
now leaves the column out, as every other report run insert does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GitHub took the push of a73bdcc and 1a00cbf onto the branch but kept
#1111's head at 653e47d and ran no checks on them. This commit changes
no file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anth-volk
anth-volk marked this pull request as ready for review November 25, 2026 18:27
@anth-volk
anth-volk merged commit 5b80c17 into main Nov 25, 2026
28 checks passed
@anth-volk
anth-volk deleted the v2plan/c1-42-drop-report-columns branch November 25, 2026 18:27
anth-volk added a commit that referenced this pull request Nov 25, 2026
main now pins API v1's merge of the report column drops (825a9b3c), and
its table models drop the columns C1 · 41 drops. Nothing conflicted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk added a commit that referenced this pull request Nov 25, 2026
#1096 and #1111 moved public-api-commit on main, so this PR no longer
compares the models at API v1's 003ee4996.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Sim's table models still map the report columns API v1 drops

1 participant