Skip to content

Release history page: one panel's timeline, by reference engine - #324

Draft
juaristi22 wants to merge 7 commits into
release-history-backend-224from
claude/release-history-page-224-b50b5f
Draft

juaristi22 wants to merge 7 commits into
release-history-backend-224from
claude/release-history-page-224-b50b5f

Conversation

@juaristi22

@juaristi22 juaristi22 commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The second PR for #224: the page that reads what #304 stores. For one country, it draws every national data
file the country publishes, measured on one fixed engine, so a move between two releases comes from the data
and not the model. It is stacked on #304 and reads its timeline.json.

The page is at /microcosm/release-history?country=<code>. The sidebar lists it under Releases as "Release
history", for every country the dashboard serves (see Follow-ups).

How it works:

  • Three read routes, all on the server. GET /api/microcosm/release-history gives a country's panels from
    the manifest, one per reference engine, and the panel the page opens. .../timeline?panel= gives one panel's
    whole timeline.json, with what its panel.json says about presenting its outputs. .../export?panel=
    gives the same timeline as a CSV, with the columns of the producer's export command. The browser never
    gets a Blob URL or a token, and only a panel the country's manifest entry lists is read. The routes read
    Blob as the dashboard's other Blob reads do, with no credential passed (frontend/HOSTED_RUNTIME.md), so
    the page needs no new setting, and they never write.
  • Which panel opens. The served panel, the last complete one. After an engine bump the pinned panel fills
    first: a notice says how many files it holds and links to it, and the page moves to it once it is complete.
  • The engine toggle. One option per panel that holds a measured file, including one a run from another
    ref filled. Choosing one switches the whole page to that engine's timeline. The page names the builds the
    chosen engine has no value for, by why: never run, retrying, out of attempts, or a file the producer refused.
  • The chart. One column per build in publish order, with a Relative (%) / Absolute switch. Relative, the
    default, places each release as a percentage above or below the output's official figure. An output with no
    official figure shows values under both, with a note. A line joins two builds only where the timeline has a
    step.
  • Builds with no value keep their column, shaded and labelled, so the axis is the same on every engine. A
    withdrawn build is listed and marked; a value measured before the withdrawal is a hollow marker that no line
    joins.
  • Marks on the time axis: a new build engine, the same file published again, and a withdrawn build.
  • What moved. The outputs ranked by their step at the latest build beside their own typical step, the
    median of their earlier steps on the panel, so no outside threshold is needed. A step is "nearer to" or
    "further from" the official figure.
  • The step card. A click on a step sets what its two builds declare side by side: the Microcosm commit,
    the model and core each file was built with, the number of targets and whether the target set changed, the
    registry version, and the columns the reference model does not define. It links to the two commits on GitHub
    and to each build's Calibration fit page.
  • State in the URL. The engine's panel, the output, the scale and the open step, so a link opens the same
    view. A default is never written, and a value the page cannot use falls back to its default.
  • Withheld cells. The page shows a withheld cell as "Withheld" and never as a number. It removes every
    number from a cell or a step that is not ok before anything is drawn, ranked or exported, and it computes
    nothing across outputs: no sum of deciles and no total less its parts.
  • Neutral words. An output "moved", and is "nearer to" or "further from" its official figure. Every output
    has a label, and the page never prints an output's id: four ids per reform spell "gaining" and "losing".
  • No country code in the code. Labels, groups and order come from each panel's spec; gating comes from the
    dashboard's country registration and from whether the manifest holds a measured file.

One change to #304's timeline

buildTimeline now copies what each build declares into timeline.json, in an optional declared block per
build: the build its point was fetched through, its built-at time, the model and core it was built with, the
range of models it declares, its Microcosm repository and commit, its target set's digest and size, the target
registry version and the household weight year. The step card and the build-engine mark read it. Without it
the page would read every point on each request.

It is the first commit and stands alone, so it can move into #304. The key is optional in
timeline.schema.json: a timeline written before it stays valid, and the next finalize rewrites it. No id and
no stored point changes.

What's here

  • frontend/app/api/microcosm/release-history/: the three routes. A timeline grows with every build and a
    function's response is capped, so the timeline and the CSV are sent gzipped to a client that accepts it.
  • frontend/app/microcosm/release-history/page.tsx and frontend/components/microcosm/release-history-*.tsx:
    the page, its sections, the chart (SVG, drawn from a layout the tests check) and the step card.
  • frontend/lib/microcosm/release-history-{summary,read,http,source,export}.ts: what the routes share.
  • frontend/lib/microcosm/release-history-{outputs,format,chart,moved,builds,url,page}.ts: the page's logic,
    all pure.
  • frontend/lib/api/hooks/use-release-history.ts: the page's two reads.
  • frontend/components/layout/nav-items.ts: the sidebar entry, which goes with the calibration capability.
  • frontend/lib/microcosm/test-support/: a store built from the producer's fixtures, and a synthetic store
    with the cases the page must show.
  • frontend/scripts/release-history-dev-store.ts: writes the synthetic store to a folder.
  • RELEASE_HISTORY_LOCAL_DIR: names a local folder in the store's layout for the routes to read in place of
    Blob. It is read-only and unset on a hosted deployment.
  • docs/release-history.md: a section on the page.

Testing

No production data exists yet, so the page was built and tested on synthetic data: each country's committed
fixtures and a seeded generator, put through the real finalize and timeline code. The synthetic UK is part-way
through an engine bump; the synthetic US has a second engine's panel under another definition.

  • cd frontend && bun test: 723 passed. bun run lint is clean, and bun run build passes.
  • cd release_history && uv run pytest -q: 131 passed, with ruff and pyright clean, after the timeline
    change.
  • The tests cover: the panel that opens in each state of an engine bump; the three routes on an in-memory
    store (no country, an unknown country, no history, a panel the manifest does not list, a timeline of another
    panel, the cache headers, gzip); labels, groups and order for both countries' specs; the chart's layout; the
    what-moved ranking; the marks and the step card's facts; the URL state; and the CSV, whose columns are
    compared with the Python command's.
  • Withheld cells have their own tests at each layer: a timeline that wrongly carried a number beside a
    withheld status yields none in the page's entries, the chart, the rendered markup or the CSV.
  • Checked in a browser on the synthetic store: both UK engines, an output with no official figure, an output
    withheld in some builds, the step card, the US, a country with no history, an unknown country code, and a
    phone width.
  • The page's text had a neutrality review; its findings are applied.
  • Not checked: real data, and the page on a deployment, where the routes read Blob with the deployment's
    own credentials.

To look at it locally:

cd frontend
bun run scripts/release-history-dev-store.ts --out ../.tmp/release-history-store
RELEASE_HISTORY_LOCAL_DIR=../.tmp/release-history-store bun run dev

then open /calibration/dashboard/microcosm/release-history?country=uk.

Follow-ups

  • A capability of its own for the sidebar entry. The country registry has none for the release history, so
    the entry goes with calibration and shows for every country; one with nothing measured gets the page's
    empty state. A release_history capability belongs in @policyengine/calibration-tree's countries.ts,
    which lives in PolicyEngine/microcosm-collector: a change there, a new npm version, then a PR here that
    raises the pinned version and moves the entry to it.
  • Official values for the reforms. The references hold a value for 13 UK baseline items; every reform is a
    citation with no value, so the Relative view has an official figure for those 13 outputs only. Values for the
    UK reforms need HMRC's ready reckoner in Chronicle.
  • A link that compares two releases on the dashboard: no page takes two releases from its URL today.
  • A compact timeline encoding, for when a compressed timeline nears the response cap.
  • Baseline labels from the spec: the page makes them from the ids, because labels.json holds reform labels
    only.

🤖 Generated with Claude Code

juaristi22 and others added 6 commits November 26, 2026 14:30
…ard and marks

The page (PR 2 of #224) opens a card on a step with the facts of its two builds,
and marks a change of build engine on the time axis. Those facts are in the
points, and `timeline.json` copied none of them, so the page would have read
every point on each request.

- `buildTimeline` adds a `declared` block to each build: the build its point was
  fetched through, its built-at time, the model and core it was built with, the
  range of models it declares, its Microcosm repository and commit, its target
  set's digest and size, the target registry version and the household weight
  year. It is null where the panel holds no point. Two builds that publish one
  file carry the same facts.
- The key is optional in `timeline.schema.json`, as the schema's rule for a key
  added later says: a timeline written before this commit stays valid, and the
  next finalize rewrites it. No id and no stored point changes.
- The Python `TimelineBuild` type, the generated TypeScript types and both
  countries' timeline fixtures follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… panel's timeline, and its CSV

The page (PR 2 of #224) reads the store PR 1 writes. Three routes read it on the
server, through the store module, so the browser never gets a Blob URL or token.

- `GET /api/microcosm/release-history?country=`: the country's panels, one per
  reference engine that holds a measured file, with engine, coverage and whether
  the definition equals the default panel's, and the panel the page opens. That
  is the served panel: after an engine bump the pinned panel fills first and the
  page moves to it once it is complete. A country with no measured file answers
  `available: false`. The per-file entries stay in the manifest.
- `GET /api/microcosm/release-history/timeline?country=&panel=`: one panel's
  summary, its whole `timeline.json`, and what its `panel.json` says about
  presenting its outputs (currency, period labels, the baseline items and
  reforms in spec order, the disclosure policy). Without `panel` it serves the
  default one. Only a panel the country's manifest entry lists is read, and a
  stored timeline of another panel or format is a 502.
- `GET /api/microcosm/release-history/export?country=&panel=`: the same timeline
  as a CSV download with the columns of the producer's `export` command; a test
  reads the column list from the Python file. A withheld value is an empty cell.
- A timeline grows with every build and a function's response is capped, so the
  timeline and the CSV are sent gzipped to a client that accepts it.
- Every route requires a country and answers an unknown code with the shared
  not-configured response before reading; all three join the every-route test.
- `RELEASE_HISTORY_LOCAL_DIR` names a local folder in the store's layout (a
  pulled panel, or a synthetic one) for the routes to read instead of Blob. It
  is read-only, never leaves the folder, and is unset on a hosted deployment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…and test it on

No production data exists while the page is built, so the logic is tested on a
synthetic store: each country's committed fixtures and a seeded generator, put
through the real finalize and timeline code. Everything here is pure.

- Outputs: each one gets a label, a group and a place in the order from its id
  and the panel's spec (receipts, spending, caseloads, population, incomes,
  poverty rates, then one group per reform), in neutral words. An entry holds
  one output's own values across builds, with every number removed from a cell
  or a step that is not `ok`, so nothing further down can show or derive a
  withheld value. Nothing adds or compares two outputs.
- Chart layout: one column per build in publish order; Relative places each
  value as a percentage of the output's official figure and Absolute places the
  values; an output with no official figure is drawn in values under both. A
  build with no value keeps its column, shaded and labelled with why (withheld,
  not measured, gap, retrying, failed, withdrawn), so the axis is the same on
  every engine. A line joins two builds only where the timeline has a step. A
  withdrawn build's value is a hollow marker no line joins.
- What moved: outputs ranked by their step beside their own typical step, the
  median of their earlier steps. A republished file is left out of that median,
  an output with fewer than three earlier steps is ranked after by the size of
  its step, and a step beside a withheld cell is counted and never ranked. A
  step is "nearer to" or "further from" the official figure.
- Builds: the marks on the time axis (a new build engine, a republished file, a
  withdrawn build), the builds an engine has no run for by why, and the facts
  of a step's two builds with links to their Microcosm commits.
- The page's state in its URL: the engine's panel, the output, the scale, the
  open step. Defaults are never written.
- `scripts/release-history-dev-store.ts --out <folder>` writes the synthetic
  store for `RELEASE_HISTORY_LOCAL_DIR`: the UK part-way through an engine
  bump, the US with a second engine's panel under another definition.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`/microcosm/release-history?country=<code>` draws what #304 stores: every
national data file a country publishes, measured on one fixed engine. It is
reachable by URL; a navigation entry needs a capability in the calibration
tree package, which is a change in microcosm-collector.

- The page opens the served panel. After an engine bump a notice says how many
  files the newer engine holds and links to it. The engine toggle lists every
  panel that holds a measured file, and the page names the builds the chosen
  engine has no value for, by why: never run, retrying, out of attempts, or a
  file the producer refused.
- In order: the notices, the series facts, what moved at the latest build, the
  builds of the series, and the outputs, with the selected output's stats,
  chart, official reference, step card and table. The table sits behind a
  toggle, closed by default.
- The chart is SVG drawn from the tested layout, with a Relative (%) / Absolute
  switch, Relative by default. Each column is a button: hover or focus reads
  out its value, and a click opens its step. A withdrawn build is listed and
  marked, and its column stays, shaded.
- The step card sets what a step's two builds declare side by side, with links
  to their Microcosm commits and to each build's Calibration fit page.
- The state is in the URL (the engine's panel, the output, the scale, the open
  step), and a value the loaded panel cannot use leaves the URL.
- After a neutrality review of the page's text: an output "moved" and is
  "nearer to" or "further from" its official figure; the page labels every
  output and never prints an output's id, because four ids per reform spell
  "gaining" and "losing"; a build's state reads "Out of attempts" and "File
  refused", which say what happened to the run and are no verdict on the build.
- Also in the logic: axis labels keep the decimals that tell two ticks apart,
  the latest value's label stays clear of the line and of a shaded column, and
  a step away from a value of zero ranks first with no percentage.
- The rendered page is tested on the synthetic store, including that a number
  a timeline wrongly carried beside a withheld status reaches no markup.
- `docs/release-history.md` gains a section on the page.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…als, passing none

The page's routes passed `BLOB_READ_WRITE_TOKEN` to the Blob client when the
environment held one. The dashboard's other Blob reads pass no credential
(frontend/HOSTED_RUNTIME.md), so `@vercel/blob` uses the deployment's Vercel
OIDC token with `BLOB_STORE_ID` when both are present and the token otherwise.
An explicit token skipped that choice.

- `releaseHistoryReadStore` now opens the Blob store with no token, whatever
  the environment holds, and gives the routes a store they cannot write
  through. The page needs no setting of its own for Blob.
- A named local folder (`RELEASE_HISTORY_LOCAL_DIR`) is still read in place of
  Blob, which is then never opened.
- `docs/release-history.md` and `frontend/HOSTED_RUNTIME.md` say so.

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

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
calibration-diagnostics Ready Ready Preview Nov 26, 2026 5:38pm UTC

Request Review

The entry goes with the `calibration` capability, which every country the
dashboard serves holds: the country registry has no capability for the
release history itself, and adding one is a change to
@policyengine/calibration-tree in PolicyEngine/microcosm-collector. A country
with nothing measured gets the page's empty state. No country code is
branched on.

The sidebar tests, the third-country conformance test and the docs follow.

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

This branch was successfully deployed

1 active deployment
Preview — b66cb7e9 Deployed Nov 26, 2026 by vercel[bot]
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