Skip to content

Dashboard data contract: schema-validated exports + published release artifacts#65

Open
MaxGhenis wants to merge 1 commit into
site-perf-seofrom
data-plane-contract
Open

Dashboard data contract: schema-validated exports + published release artifacts#65
MaxGhenis wants to merge 1 commit into
site-perf-seofrom
data-plane-contract

Conversation

@MaxGhenis

Copy link
Copy Markdown
Contributor

Stacked on #61 (base branch site-perf-seo, which owns prepare-data.ts). Retarget to main after #61 merges.

Why

app/src/data.json is a 57MB generated artifact committed as source. That's why .git is ~290MB locally, why refresh PRs are conflict magnets — and because nothing validated the export contract, the analyze CLI could (and did) write an unloadable payload to the app path: export_dashboard_data wrote the bare per-country bench object instead of the {"countries": {...}} shape the app requires. A working tree with exactly this corruption exists right now.

What

Contract (validation at every write):

  • policybench/dashboard_schema.py validates payload shape, per-country required keys, scenario cross-references, and finite numbers. The per-country-copied-to-app-path mistake produces a specific, named error.
  • All three write sites (export_full_run, export_country, export_dashboard_data) validate before writing and serialize with allow_nan=False (Python emits NaN literals that JSON.parse rejects — a second silent-corruption class, now a loud export failure).
  • export_dashboard_data bug fixed: it now wraps the bench under {"countries": {...}}.
  • policybench validate-dashboard [path] checks any file from the CLI; the app applies the same shape guard at build time with a readable error.

Published artifacts (blob out of git):

  • policybench publish-dashboard --tag dashboard-data-<date> validates, uploads data.json as a GitHub release asset, and writes the committed 9-line pointer app/src/data.artifact.json (tag, url, sha256, bytes).
  • prepare-data.ts resolves src/data.json first (local flows unchanged), else downloads the pointer's asset with sha256 verification and caches under gitignored app/.cache/.
  • The current payload is published for real as release dashboard-data-20260520; the download path is verified end-to-end (fetch → hash check → split → build, then cache hit on rerun).
  • docs/artifacts.md records the contract and the cutover plan: once the in-flight refresh (Pin US PolicyBench runs to policyengine.py 4.14.2 #59) lands, refreshes publish + commit the pointer, and the committed blob gets deleted. History rewrite is explicitly out of scope.

Verification

  • Python: 297 tests pass (18 new), ruff clean.
  • App: 24 bun tests pass (7 new), lint clean, production build green both from the committed file and from the downloaded artifact.

🤖 Generated with Claude Code

Every dashboard payload write now validates against the app contract
(policybench/dashboard_schema.py) and serializes with allow_nan=False.
This catches the two observed failure classes at write time: a
per-country export copied to app/src/data.json (the analyze CLI did
exactly this by default — export_dashboard_data wrote the bare bench
object, which the app cannot load; it now wraps under {"countries"})
and NaN literals that JSON.parse rejects.

policybench publish-dashboard validates, uploads data.json as a GitHub
release asset, and writes a committed pointer
(app/src/data.artifact.json: tag, url, sha256, bytes). The app's
prepare-data resolves src/data.json first, else downloads the pointer's
asset with sha256 verification and caches it under app/.cache/. The
current payload is published as release dashboard-data-20260520 and the
download path is verified end-to-end.

policybench validate-dashboard checks any payload file from the CLI.
docs/artifacts.md records the contract and the cutover plan that stops
committing the 57MB blob once the in-flight refresh lands.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
policybench-site Ready Ready Preview, Comment Jun 10, 2026 11:27am

Request Review

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.

1 participant