Skip to content

Stop mapping the report columns the next v2 revision drops - #4333

Merged
anth-volk merged 13 commits into
masterfrom
v2plan/c1-40a-stop-mapping-report-columns
Nov 25, 2026
Merged

anth-volk merged 13 commits into
masterfrom
v2plan/c1-40a-stop-mapping-report-columns

Conversation

@anth-volk

Copy link
Copy Markdown
Collaborator

Fixes #4332

Summary

  • Report no longer maps label, description or user_id, and ReportRun and BudgetWindowRun no longer map trigger. The columns stay in __table_args__, so the tables don't change and there is no revision.
  • Report.user and User.reports go, and create_report_run takes no trigger.
  • /v2/reports run items and budget-window run items no longer have trigger. Run lists, report reads, and create and re-run answers all change. A user's trigger stays on user_report_run_associations.

Why it ships separately

The deploy upgrades the v2 schema before new code takes traffic. The next revision, in the PR that follows this one, drops these columns and report_runs' four cliff columns, so the release serving at that moment must name none of them. With #4329, which stops mapping the four cliff columns, this release is that one.

Deploy order

  1. Store one cliff result per simulation run, and run every database statement through the ORM #4327 and Read report cliffs from simulation runs' cliff results, and take include_cliffs on re-runs #4329
  2. This PR
  3. The PR that drops the columns

Migration notes

  • Route group covered: /v2/reports, on FastAPI. Nothing moves between Flask and FastAPI.
  • API contract change: the trigger field is removed from run items. v3 has it only in its generated types and calls no /v2/reports route.
  • The migration contract documents regenerate unchanged.

Testing

  • The tests this PR adds or changes pass by node ID against disposable PostgreSQL 17.
  • With this code on a database where the nine columns were dropped by hand, and privileges.py no longer naming the cliff columns, 30 report read, create and re-run cases pass.
  • alembic -c alembic-v2.ini check finds nothing to generate, and reconcile_v2_privileges.py apply and verify pass.
  • ruff, ruff format, lint-imports, python -m scripts.rules validate, run_quality_guards.py and make typecheck-v2 pass. Explicit mypy on the changed policyengine_api/data/v2/ files reports 20 errors, the same count as the base branch.
  • The full suites were not run locally.

🤖 Generated with Claude Code

anth-volk and others added 5 commits November 19, 2026 02:58
Whole-row reads of reports, report runs and budget-window runs name none
of the per-user columns a later revision drops, the tables keep them, run
reads no longer answer a trigger, and create_report_run takes none. The
report fixtures stop storing those columns, so the reads are tested on
rows that hold none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Report leaves out label, description and user_id, and ReportRun and
BudgetWindowRun leave out trigger, so API v1 neither selects nor writes
them. The tables keep the columns, so there is no revision, and a release
of this code keeps serving /v2/reports while a later revision drops them.
Run items and budget-window run items no longer have a trigger field, and
create_report_run takes none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	policyengine_api/data/v2/models/reports.py
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A catalog publication test stops passing a label the model discards, and a
report-run test is named for what it now covers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.77%. Comparing base (16eb1ce) to head (e7585ca).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4333      +/-   ##
==========================================
- Coverage   93.78%   93.77%   -0.01%     
==========================================
  Files         413      413              
  Lines       23537    23528       -9     
  Branches     3662     3661       -1     
==========================================
- Hits        22073    22064       -9     
  Misses        848      848              
  Partials      616      616              
Flag Coverage Δ
integration 58.77% <100.00%> (-0.01%) ⬇️
unit 90.90% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

anth-volk and others added 4 commits November 25, 2026 00:10
C1 · 40's branch brings #4327's rule api.data.orm-only, which refuses
sa.Column(...) anywhere. As C1 · 40 does for the four cliff columns, the
five per-user columns (reports.label, description and user_id, and both
run tables' trigger) are SQLModel fields again, still left out of the
mappers by exclude_properties. Tests stop writing them through the
models, which can't set an excluded column; the privilege tests set
trigger through BudgetWindowRunColumns and ReportRunColumns, and the
column-mapping tests read the stored schema instead of Core tables.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ests

The model and shared-row tests read trigger and label from the mappers,
which leave them out since the base's ORM-only rule made them SQLModel
fields under exclude_properties; they now read the stored schema or
leave the columns out. The malformed-key test no longer inserts label.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The shared-rows test reads label and both triggers through the column
classes, as the rule requires (ReportColumns gains label), instead of the
models' class attributes, which are the tables' Core columns. The
column-mapping tests check again that the five columns have no server
default, and that both triggers keep the shared enum type. The guide and
docstrings name every column the mappers leave out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The column-only classes take trigger's type from the user records'
mapper, which holds the same enum, and the trigger type test compares
the runs' type with the user records' instead of checking a name alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Base automatically changed from v2plan/c1-40-report-cliffs to master November 25, 2026 14:15
@anth-volk
anth-volk marked this pull request as ready for review November 25, 2026 14:57
@anth-volk
anth-volk merged commit bbb34f7 into master Nov 25, 2026
23 checks passed
@anth-volk
anth-volk deleted the v2plan/c1-40a-stop-mapping-report-columns branch November 25, 2026 14:57
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 branch was previously deployed

1 inactive deployment
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.

Stop mapping the report columns the next v2 revision drops

1 participant