Repository navigation
Conversation
POST, GET and PUT /{country_id}/user-profile and POST, GET and PUT
/{country_id}/user-policy read and changed user profiles and saved
policies by a user_id, auth0_id or record id taken from the request,
and checked no credential. App v2 does not call them, and #4017 reports
no production requests to them in the 30 days to 2026-10-19. Signed-in
users reach their saved work through the v2 routes, which take the
owner from the verified credential. Found by the 2026-10-22 security
review.
The deletions match #4017's: the user-profile blueprint and v1 user
service go, the saved-policy routes and their helpers leave
policy_routes.py, the app-v2 contract registry drops the saved-policy
workflow and the generated contract documents are refreshed. As there,
the v1 saved-policy service and copying modules stay until dual-write
is deleted. GET /{country_id}/policies stays; #4017 removes it with the
legacy site.
New tests state the invariant that every legacy user record operation
is owner-scoped: the deployed application serves neither path, no
module an HTTP route can import touches the v1 user-record tables, and
a Hypothesis property over generated requests to the removed paths
(any method, country, identifier, ownership fields and credentials)
gets 404 or 405 and leaves every stored user record unchanged. The
Cloud Run candidate check asserts the removed paths answer 404.
hypothesis joins the dev extra.
Tests (failed first on origin/master: the routes were registered and
reachable from the route modules, and requests to them reached the
handlers instead of answering 404): the new invariant tests, then the
route boundary, contract and service-boundary tests.
Fixes #4028
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PATCH /{country_id}/simulation and PATCH /{country_id}/report take no
credential, and their records are shared: identical requests reuse one
record. Any caller could replace a complete result with another output
or an error, and every viewer of that record saw it. Found by the
2026-10-22 security review.
There is no compute worker to restrict these updates to: the browser
that ran a calculation stores its result. So the rule is on the record.
Once it holds a complete result, an update that repeats it (a retried
write, or a second browser finishing the same calculation, in either
JSON encoding) answers 200 and writes nothing, and one that would
change its status, output or error message answers 409 and leaves the
record and its runs as they were. A completed US economy output is
compared in its canonical SPM form. The services check this after
locking the record and before any write, so the no-op path does not
restamp the version or touch the runs.
Three results stay open, because the server decided they run again:
stale SPM simulation output, a report under an outdated cache version
(reads resolve it to its current equivalent) and either record while a
server-started rerun is pending or running. Marking a complete report
running now answers 409 rather than 400; the old check still applies
to a failed report.
Tests (failed first on origin/master: a forged output and a status
change replaced complete results with 200): regression tests for each
anonymous change, the canonical economy comparison, the calculation
path and the three open cases, and Hypothesis properties over update
sequences for both records, checked step by step against a reference
model. The OpenAPI document gains both 409 responses.
Fixes #4028
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4029 +/- ##
==========================================
+ Coverage 93.90% 94.10% +0.20%
==========================================
Files 433 451 +18
Lines 24216 25530 +1314
Branches 3754 3976 +222
==========================================
+ Hits 22739 24025 +1286
- Misses 847 855 +8
- Partials 630 650 +20
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:
|
…lity Two independent reviews of the first head found that the finality rule broke one app-v2 flow and left three gaps. App v2 recalculates every simulation of a new household report, reused complete ones included, and stores the installed model's result. After a model release that result differs, so it got 409 and the shared simulation stayed on the older model. A simulation result is now final only when it came from the installed country model or a newer one (PEP 440 comparison of api_version; an unreadable version counts as older when it differs), so recalculation replaces older results as before, and an older revision cannot replace a newer one. The speculative simulation-rerun exception goes: nothing starts one. An update to an outdated report ID now goes to its current equivalent, the record GET already serves for that ID, and keeps the requested ID in the response. Before, PATCH wrote the outdated row and the current record stayed pending; and the outdated-cache-version exception let a revision with another bundle reopen current reports. That exception is gone. A completion whose output decodes to null, such as "null", stored a complete record with no result, which then refused the real one: it is rejected, and a complete record without output is not final. A body id that is not an integer is rejected. Stored outputs are compared as stored, so a JSON-string output repeats as itself. The Cloud Run candidate check reads IDs no record can have and never prints the body, since CI logs are public. uv.lock is relocked with uv 0.13.4, CI's pin, and now only adds hypothesis 6.168.5. The OpenAPI document and docs/canonical-spm.md describe the rules; the report 409 response has its schema. Tests: regressions for newer models, outdated report IDs, null completions, non-integer IDs and JSON-string outputs, which failed first on origin/master, and for older models, which must pass on both; the properties now compare every column of the record and its runs after completion, over a wider output domain; the import walk handles package-relative imports and models used through v1_models. Fixes #4028 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
force-pushed
the
max/legacy-user-route-authz-20261023
branch
from
October 23, 2026 11:36
84eff40 to
b9f0b1f
Compare
This was referenced Nov 17, 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 #4028
A completed v1 household simulation can become final when its output matches a stored-household calculation recorded for the current or a newer runtime. A household report can become final when every linked simulation result matches server evidence for that report's cache version. The v1 migrations persist verification and reserve one row when requests race to create the same current report.
Stale-SPM simulations, results from older runtimes, reports with an active server-started rerun, geography simulations, economy reports, and other outputs without matching server evidence remain correctable. Reading a report preserves its active rerun. A valid US economy completion can replace malformed historical output.
An ordinary PATCH cannot correct a final result. A conflicting update returns 409 and a repeat leaves the saved result and run history unchanged, including when a retry uses the stored JSON number representation. The PATCH routes also validate IDs and reject completions with null output.
For this fix round, the Front door chose server-side verification with the existing PATCH payloads. Calculation keys retain the producer's runtime and cache hits renew its evidence. A rollout between calculation and save cannot give an old result the saving revision's verification. A server-issued receipt returned by callers remains an option for maintainers.
Tests cover rollout in both directions, overlapping MySQL completions through old and current report IDs, MySQL JSON round trips, active reruns, stale SPM, malformed historical outputs, and existing legacy user-route behavior. Local focused tests, Redis and MySQL integration tests, migration checks, and repository quality checks passed.
This update was written by a Codex cloud task for Max and builds on draft PR #4029. No session owns the draft. The merge decision stays with the maintainers.
Updated by a Codex cloud task (queue file 3207-policyengine-api-pr4029-draft-remove-the-v1-user-routes-an).