Repository navigation
Drop the per-user and cliff columns from v2 report rows - #4335
Merged
Merged
Conversation
The per-user columns of reports, report runs and budget-window runs, and the report runs' cliff columns, go in a new revision. Report reads stop answering a run's trigger, the privilege manifest stops naming the cliff columns, and account deletion needs no reports.user_id. Rows the tests store at the head revision stop naming the columns. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 that depend on them. The downgrade adds them back empty. /v2/reports run items no longer have a trigger, the Modal worker's grants no longer name the cliff columns, and account deletion no longer touches reports. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…c1-41-drop-report-columns # Conflicts: # policyengine_api/data/v2/models/reports.py # policyengine_api/data/v2/models/users.py # tests/integration/test_v2_report_cliff_reads.py
The revision's tests compare it and its downgrade with the parent schema built from the base, and CI's migration lifecycle job runs them. A test assertion that could not fail goes, and the privilege docstring and the migration guide say what must happen before merging and after a downgrade. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…c1-41-drop-report-columns
The revision gets its generation command and a description, the privilege test starts from the Modal worker's old cliff grants, the workflow test pins the new lifecycle module, and the downgrade guides say that going below the shared reports revision needs no reports or runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4335 +/- ##
==========================================
- Coverage 93.80% 93.77% -0.03%
==========================================
Files 413 413
Lines 23537 23516 -21
Branches 3662 3661 -1
==========================================
- Hits 22078 22052 -26
- Misses 842 848 +6
+ Partials 617 616 -1
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:
|
The reports cases of test_a_malformed_or_incomplete_key_is_refused still named label, which revision 4e30076d4b9f drops, so they failed on the missing column instead of the key check. Each case now also names the check constraint it expects, so a refusal by a different check fails it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…c1-41-drop-report-columns # Conflicts: # docs/engineering/skills/alembic-migrations.md
…c1-41-drop-report-columns # Conflicts: # docs/migration/stage-12a-user-login.md # docs/migration/stage-9-v2-metadata.md # tests/unit/v2/test_alembic_v2_revisions.py
Merging the dynamics revision through C1 · 40a brought back the cliff impacts test's head assertion, which this branch had removed: revision 4e30076d4b9f is the head, and the chain test already asserts that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…c1-41-drop-report-columns # Conflicts: # .github/scripts/test_alembic_v2_lifecycle.sh # tests/unit/test_alembic_workflows.py
…c1-41-drop-report-columns # Conflicts: # policyengine_api/data/v2/models/base.py # policyengine_api/data/v2/models/reports.py # tests/integration/test_alembic_v2_lifecycle.py # tests/integration/test_alembic_v2_simulation_runs.py # tests/integration/test_v2_report_cliff_reads.py # tests/integration/test_v2_shared_report_rows.py # tests/integration/test_v2_simulation_role_privileges.py # tests/integration/test_v2_user_identity_persistence.py # tests/unit/v2/test_model_persistence.py # tests/unit/v2/test_report_column_mapping.py # tests/unit/v2/test_shared_report_models.py # tests/unit/v2/test_simulation_run_models.py
…c1-41-drop-report-columns # Conflicts: # tests/unit/v2/test_shared_report_models.py
Rule api.data.orm-only, from the base, refuses the test's handwritten SQL and engine. It now takes the owner's Session factories, reads the schema and enum types through the Inspector, writes and reads the parent revision's columns through small mapped classes of that revision, and grants the Modal worker's old cliff columns with the test grant helper. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…c1-41-drop-report-columns # Conflicts: # tests/integration/privilege_statements.py # tests/integration/test_v2_shared_report_rows.py # tests/integration/test_v2_simulation_role_privileges.py # tests/unit/v2/test_report_column_mapping.py # tests/unit/v2/test_shared_report_models.py
…c1-41-drop-report-columns # Conflicts: # tests/integration/privilege_statements.py # tests/unit/v2/test_report_column_mapping.py
The merge brought the base's two report run cliff tests, which expect the cliff fields this branch drops; the branch's own test, that the model neither loads, writes nor declares them, is back. Docstrings and the alembic-migrations guide no longer describe the dropped columns as still in the tables, and the column drops test types its role fixture. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The column drops test stores a user on the parent revision's report, so the check that a downgrade restores no values covers user_id too, and the cliff reads test says the columns it scans for are the dropped ones. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…c1-41-drop-report-columns
Base automatically changed from
v2plan/c1-40a-stop-mapping-report-columns
to
master
November 25, 2026 14:57
anth-volk
marked this pull request as ready for review
November 25, 2026 15:38
anth-volk
added a commit
that referenced
this pull request
Nov 25, 2026
Revision d417fe8b1b17 now sits on 4e30076d4b9f, master's head, instead of 9d1d12a7ac58. Autogenerating it again from 4e30076d4b9f gives the same operations, which its docstring and the migrations skill now say. - The head constant, the revision chain test, this revision's own test, the lifecycle script and its workflow test, and the skill's downgrade-chain paragraph name the new order: d417fe8b1b17, 4e30076d4b9f, bc334f9877b7, 9d1d12a7ac58. - Master now runs every database statement through the ORM (rule api.data.orm-only). test_alembic_v2_user_dynamics.py and the saved-dynamic fixture in test_v2_user_identity_persistence.py move from Core connections and SQL text to the owner's Sessions, mapped classes and add_row; the rule's test listed their 20 findings before the change and none after. - Both sides raised the import test's table count from 50 to 51; it is 52 with cliff_impacts and user_dynamics. - The report column drops test of the deploy's privilege steps upgraded only to 4e30076d4b9f, so apply refused while user_dynamics was declared but absent. It now upgrades to the head before applying, as the deploy does. Each of those tests was seen failing by node ID before the change and passes after it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 25, 2026
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 #4334
Summary
Adds v2 revision
4e30076d4b9f, onbc334f9877b7. It drops:reportslabel,description,user_idfk_reports_user_id_users,ix_reports_user_idreport_runstrigger,baseline_cliff_gap,baseline_cliff_share,reform_cliff_gap,reform_cliff_shareck_report_runs_cliff_impact_completebudget_window_runstriggerUPDATEon the four cliff columns goes.reports.v2_report_run_triggerstays, foruser_report_run_associations.budget_window_runs.recalculatestays.The drops can't be undone by a downgrade
The downgrade adds the columns, key, index and check back with every value null. Nothing copies the values first, because these rows name no user to copy them to.
Before merging, an operator exports the stored values from staging and from production, and keeps the result outside this repository, because labels and descriptions are users' text. These queries only read:
What must be in production before this merges
The release workflow upgrades the v2 schema before the new Cloud Run revision takes traffic, so the release already serving runs on the dropped schema.
/v2/reportsread fails during the deploy.mainstill writes the four cliff columns, so without it every economy report run's completion fails.C1 · 42 follows: the simulation service's table models lose these columns and its pinned API v1 commit moves to this merge. Until then its schema comparison fails against this schema; requests are not affected.
Migration notes
/v2/reports. This PR changes no HTTP response; Stop mapping the report columns the next v2 revision drops #4333 removedtrigger..github/scripts/test_alembic_v2_lifecycle.shgains the new test module. It reads no new environment variable:V2_MIGRATION_DATABASE_URL,V2_ALEMBIC_DISPOSABLE_TESTandUV_PYTHONare literal values inalembic-v2-check.yml's jobenv.Testing
alembic -c alembic-v2.ini checkfinds nothing to generate, andreconcile_v2_privileges.py applyandverifypass./readyprivilege check finds nothing missing.lint-imports,python -m scripts.rules validate,run_quality_guards.pyandmake typecheck-v2pass. Explicit mypy on the changedpolicyengine_api/data/v2/files adds no error to the base branch's.🤖 Generated with Claude Code