API v2: report validations as an append-only, provenance-keyed resource on reports
@anth-volk がすでに取り組んでいます。
2026年9月8日 から。
評価
この issue はまだ評価されていません。
説明
@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.
- 主要言語
- Python
- スター
- 18
- フォーク
- 33
- 平均マージ
- 1日 4時間
- マージ済み PR(30日)
- 21
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
PolicyEngine/policyengine-api のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
PolicyEngine/policyengine-api#3853 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
PolicyEngine/policyengine-api#3851 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
PolicyEngine/policyengine-api#3847 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 38/100
PolicyEngine/policyengine-api#3823 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
PolicyEngine/policyengine-api#3816 ·
PolicyEngine/policyengine-api の issue をすべて見る
似ている issue
-
bug confirmed issue
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
open-webui/open-webui#30750 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 90/100