API v2: report validations as an append-only, provenance-keyed resource on reports
@anth-volk ya está trabajando en esto.
Desde el 8/9/2026.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
@anth-volk — raising this now so the v2 reports stage can be designed with it in mind, rather than retrofitting it.
Context
policyengine-app-v2 now validates every flagship report on two data sources: the calibration dashboard (how well the microdata fits administrative targets for the variables a reform moves) and the scorecard (PolicyEngine versus external measurement for the programs it touches). The variables come from a dependency map traced from the model (PolicyEngine/policyengine-core#543); the matching is in PolicyEngine/policyengine-app-v2#1180 and #1184. On first view the app pins what it matched against — populace release, model version, per-variable fit, scorecard programs — and later views report drift against that pin (#1185).
Today the pin lives in the browser's localStorage, because the app's own reports table was never connected to a database, deliberately, since v2 is where user-owned report data is going. The validation snapshot is a fact about the base report, not about one user's view of it, so it should live with the report in v2 rather than in the app or on a user association.
Proposal: report_validations
One row per validation run, never overwritten, keyed to the base report:
| column | type | purpose |
|---|---|---|
id |
uuid | |
report_id |
fk → reports, indexed | the base API report |
computed_at |
timestamptz | when the run happened |
model_version |
text | policyengine-us the report was computed with |
dependency_map_fingerprint |
text | which traced map resolved paths to variables (core#543 stamps this) |
populace_release_id |
text, nullable | which calibration release was read |
scorecard_build |
text, nullable | which scorecard file was read |
calibration |
jsonb, nullable | geography, reached count, per-variable ring/depth/fit/worst target |
scorecard |
jsonb, nullable | programs (and later rows) |
Endpoints:
GET /v2/reports/{id}/validations→ latest plus history, newest firstPOST /v2/reports/{id}/validations→ append a run (write-once per run; never update)
Drift is then a diff between the latest row's populace_release_id / model_version and the current ones, which is how the tracker already treats bill validations.
JSON the app writes today
This is the shape already in production behind the app's localStorage fallback; calibration and scorecard map onto it directly, and the top-level keys become columns:
{
"matched_at": "2026-09-07T08:55:20.772Z",
"map_model_version": "1.808.0",
"calibration": {
"release_id": "populace-us-2024-buildp-sparse-rmloss100-cae8640-20260728T011454Z",
"geography": "US",
"reached_count": 66,
"matches": [
{
"variable": "refundable_ctc",
"depth": 2,
"ring": "mechanism",
"target_count": 2,
"mean_abs_relative_error": 0.008,
"worst": { "name": "irs_soi.ty2022.historic_table_2.us.all.actc_amount@2024", "source": "irs_soi", "geography": "US", "relative_error": -0.008 }
}
]
},
"scorecard": { "programs": ["ctc_refund"] }
}
ring is one of primary (0–1 hops from the parameter), mechanism (2–4), downstream (5+). Errors are fractions.
Staged path
- Table and endpoints land with the reports stage. Contained addition; the app changes only the store it posts to.
- The app posts its snapshot on the first settled view instead of writing localStorage. Durable and shared across viewers from that day.
- Computation moves into the API worker at report completion, once core#543 releases and the dependency map ships as a release asset per model version. The worker knows the exact model version it just used, so provenance stops being inferred.
- A scheduled job re-validates reports whose pinned release or model is behind, appending rows. Drift becomes something the system records rather than something a browser notices.
Steps 1–2 need nothing from core; 3–4 wait on core#543.
Questions for you
- Does a separate table fit the reports stage, or would you rather hang it off the base report resource? Separate keeps history and avoids widening
reports. - Should
POSTbe open to the app (anonymous trust model, like today's association writes) or restricted to the worker once step 3 lands? - Anything in the v2 conventions (naming, envelope, pagination) the endpoint shapes above should follow?
References: PolicyEngine/policyengine-app-v2#1180, #1184, #1185, #1186; PolicyEngine/policyengine-core#543.
- Lenguaje dominante
- Python
- Estrellas
- 18
- Forks
- 33
- Merge medio
- 1 d 4 h
- PR fusionados (30 d)
- 21
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de PolicyEngine/policyengine-api
-
Dificultad 3/5 1-2 días Aptitud para principiantes 65/100
PolicyEngine/policyengine-api#3853 ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 65/100
PolicyEngine/policyengine-api#3851 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
PolicyEngine/policyengine-api#3847 ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 38/100
PolicyEngine/policyengine-api#3823 ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
PolicyEngine/policyengine-api#3816 ·
Todos los issues de PolicyEngine/policyengine-api
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
xinnan-tech/xiaozhi-fde-talk#263 ·
-
rules
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
huggingface/Repo2RLEnv#163 · 1 comentario ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 95/100
huggingface/sentence-transformers#4074 ·
-
comp/dashboard invalid P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
NousResearch/hermes-agent#121143 ·