Repository navigation
Declare uq_report_runs_id_report on sim's model of report_runs, with the API v1 pin on D1 · 0a's merge - #1179
Merged
Merged
Conversation
…rison fails) PolicyEngine/policyengine-api#4386's revision 7dcd2cd14330 adds the unique constraint uq_report_runs_id_report on report_runs (id, report_id), the target of the saved reports' key to their current run. ReportRun doesn't declare it yet, so the comparison with API v1's tables at this commit fails on the missing constraint. The pin names #4386's head until it merges, as the library's README says; it moves to the merge commit before this merges. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
API v1's revision 7dcd2cd14330 (PolicyEngine/policyengine-api#4386) adds the unique constraint on report_runs (id, report_id) that a saved report's key to its current run refers to. ReportRun declares it, so the models match API v1's tables again. id is already the primary key, so the constraint refuses no row the service writes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#4386 merged as 41fc0151 with a merge commit, whose tree is the same as its head e36efee7, which the comparison ran against; the pin now names a commit on API v1's master. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s users Review round 1's code-quality note: API v1's revision 7dcd2cd14330 also makes the constraint the target of a saved report's key to its current budget window run. Comment only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk
marked this pull request as ready for review
December 2, 2026 17:29
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 #1178
Sim's mapped class of
report_runsdeclares the unique constraintuq_report_runs_id_reporton(id, report_id), which API v1's revision7dcd2cd14330adds (PolicyEngine/policyengine-api#4386, D1 · 0a), andpublic-api-commitmoves to41fc0151, API v1's merge of #4386.Same-Repository Draft PR Check
PolicyEngine/policyengine-sim-api, not a personal fork.Changelog
changelog.d/<name>.<type>.md, whose type is breaking, added, changed, fixed or removed.Summary
user_report_associations (current_report_run_id, report_id)toreport_runs (id, report_id), so a saved report's current run is one of its own report's runs. PostgreSQL requires a unique constraint on the referenced columns, so the revision addsuq_report_runs_id_report.test_the_models_match_the_public_api_tablescompares sim's models with API v1's tables constraint by constraint (rulesim.persistence.models-match-public-api), so from #4386's merge on it fails against API v1'smaster, and the weekly drift run (public-api-schema-drift.yml) would fail.ReportRun.__table_args__declaresUniqueConstraint("id", "report_id", name="uq_report_runs_id_report"), with the same name, columns and column order as API v1's revision and API v1's ownReportRunmodel.libs/policyengine-simulation-persistence/public-api-commitmoves frome0c9d2f7to41fc0151, API v1's merge commit of #4386, which is on API v1'smaster. Between the two, API v1 adds one other revision,50430a2da57f(published_report_images), a table sim doesn't model, granted only to API v1's own runtime role.uq_budget_window_runs_id_reportnow also names API v1's key from a saved report to its current budget window run, which #4386 adds.changelog.d/d1-0b-report-runs-id-report.changed.md.idis already the primary key, so the constraint refuses no row the service writes. NoON CONFLICTtarget, find-or-create path or constraint-name mapping in sim uses the set of unique constraints onreport_runs.user_report_associationsisn't in sim's metadata. A merge tomainreleases and deploys the service and publishespolicyengine-api-simulation-client, as every sim merge does.Testing
Test first, with the existing comparison as the test:
45ce43a8moves the pin alone, and the comparison fails;5547a80badds the constraint, and it passes. Onlylibs/policyengine-simulation-persistence/tests/test_public_api_schema.py::test_the_models_match_the_public_api_tablesran, selected by node ID, against a disposable PostgreSQL 17 database built with.github/scripts/public-api-schema-reference.shat #4386's heade36efee7(revision7dcd2cd14330applied):45ce43a8(pin moved, no constraint)report_runs: the model has no constraint uq_report_runs_id_report (UNIQUE (id, report_id))5547a80b(constraint added)#4386 then merged as
41fc0151, a merge commit whose tree is identical toe36efee7's, soa0981568pins41fc0151without another run.Sim's checks pass: the pinned Ruff format and lint, the rules registry render, the quality guards including file length, the lock checks, and Pyright for
libs/policyengine-simulation-persistence.Review
One round, which found no bugs: it confirmed the constraint matches API v1's, the pin is on API v1's
masterwith the tested tree, nothing else API v1 changed between the two pins is compared, and no runtime path changes. Its code-quality note, that the comment onuq_budget_window_runs_id_reportnames only one of its two users, is fixed in5ac9f2cc(comment only). No bugs are left.What the merge waits for
done. Earlier in the same tracker substage; this PR uses none of its code.41fc0151, which is enough. The pin names that merge commit and the comparison builds API v1's tables at it; this PR doesn't need #4386 deployed.It builds on
main, not on another task's branch.🤖 Generated with Claude Code