Skip to content

Show US version 2 staging runs' reform validation - #326

Merged
anth-volk merged 6 commits into
mainfrom
claude/us-version-2-staging-reform-validation
Nov 27, 2026
Merged

anth-volk merged 6 commits into
mainfrom
claude/us-version-2-staging-reform-validation

Conversation

@anth-volk

@anth-volk anth-volk commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Closes #325. Tracker task 5a · 7 of "1. Collector/Emitter".

Why

US fiscal refresh builds move to the version 2 staging writer in PolicyEngine/microcosm#1135 (tracker task 5a · 8, draft PolicyEngine/microcosm#1771). Version 2 writes a run's result files under runs/<run_id>/artifacts/ and declares each one in the run manifest with its SHA-256. A US version 2 run declares reform_validation (kind validation_summary) at artifacts/reform_validation.json, and build_manifest, release_manifest and calibration_diagnostics under artifacts/ as well. The Candidate tab read reform_validation.json only at the run folder's top level, so a US version 2 run would show no reform validation.

What changes

copiedRunDocuments (frontend/lib/microcosm/stored-staging.ts) picks the reform validation copy by the run's document version:

  • Version 1 run: the copy of its top-level reform_validation.json, as before.
  • Version 2 or 3 run: the index's summary of the run records the version, and the reader reads the copy of artifacts/reform_validation.json. It is shown only when the run manifest declares a reform_validation artifact at that path, and only when the declared SHA-256 equals the copy's. The same rule already applies to a staged bundle's receipt.
  • A version 2 or 3 run never shows a top-level reform_validation.json. That includes a run whose summary records no version or version 1 while its parsed documents are version 2 or 3. Such a run's top-level copy is read and then not shown.

docs/calibration-tree-artifacts.md says the same.

Nothing else changes for a US version 2 run:

  • Its list entry and detail come from its version 3 documents, as for UK version 2 runs.
  • Its calibration views read the diagnostics its run manifest declares. The build and release manifests come from the copies the run's stored tree keeps; 5a · 6 makes the tree build read them from artifacts/.

Not yet in this PR

  • The package pin. @policyengine/calibration-tree 0.1.5 doesn't name artifacts/reform_validation.json among the copied files (StagingRunFileName), so stored-staging.ts widens the type locally (CopiedFileName), and the test store does the same (FakeStagingRunFileName). Once 5a · 6 publishes its new version, this PR raises the pin and drops both.

Decisions

Anthony, 2026-11-27: "The naming conventions for US version 2 runs should be the same as the UK". This settles both questions:

  1. How the copy is named in the collector's index: as UK version 2 runs' copied artifact is named, by its path in the run folder. UK runs use artifacts/staged_dataset.json; this run's copy is artifacts/reform_validation.json. It is shown only when the run manifest declares it with a matching digest, as the UK staged bundle receipt is. This PR implements that.
  2. What a US version 2 run's list entry and detail show of its identity fields: what UK version 2 runs show. The routes return the fields and the page renders nothing new.

Tests

frontend/app/api/microcosm/us-version-2-staging-run.test.ts runs the Staging routes' own handlers against the fake collector store with a US version 2 run built as the version 2 writer builds it (frontend/lib/microcosm/test-support/us-version-2-staging-run.ts: version 3 documents, declared artifacts with their digests). It covers:

  • the run's list entry (identity, version, state);
  • its detail (version 3 documents, delivery, declared artifacts, calibration progress, events);
  • its calibration (declared diagnostics, build and release manifests from the tree's copies, the target tree);
  • its reform validation from artifacts/reform_validation.json;
  • none shown for a copy whose digest differs, an undeclared copy, or a top-level copy in a version 2 run;
  • a US version 1 run's top-level reform validation, still shown.

Red-green:

  • 7f88991 adds the tests. Run by file, the four for the list entry, detail, calibration and version 1 run passed against main's code. The two reform validation tests failed on assertions: no reform validation from artifacts/, and a top-level copy shown for a version 2 run.
  • 1740603 makes them pass. tsc --noEmit passes.
  • f433b9a adds two tests from review round 1, which pass on the change: a version 2 run with progress but no run manifest copy shows no reform validation; the calibration and Build progress readers never read the reform validation copy.
  • f261b36 names the declared path once and notes, in the reader's comment, where it differs from the package's 0.1.5 Hugging Face reader.
  • b511888 adds a failing test from review round 2. A run whose index summary records no version, but whose documents are version 3, showed a top-level reform_validation.json. The collector records a run whose run manifest copy isn't a JSON object that way. Run by name, it failed on its assertion.
  • 2ccc14f makes it pass: the version comes from the run's documents as well as the summary. It also corrects the module and fixture header comments.

The calibration test's stored tree holds copies of the run's build and release manifests, as the collector will make them once 5a · 6 is deployed. 5a · 6's completed state includes building a version 2 run's tree from artifacts/build_manifest.json and artifacts/release_manifest.json. Until then, the collector builds a version 2 run's tree without them.

Review

  • Round 1 (calibration-diagnostics-326-review-round1-2026-11-26.md, at 1740603): 0 high, 1 medium, 0 low.
    • Medium: the calibration test's tree holds manifest copies the collector at main doesn't make for a version 2 run. No change here: 5a · 6's completed state covers building the tree from the artifacts/ manifests, and the test describes the collector after that change, as noted above.
    • It verified the other claims, and the red-green order by running the test file at both commits.
    • Its code-quality points:
      • Applied: the coverage gaps (f433b9a), the doubled path and the reader's comment (f261b36).
      • Not applied, because the outcome is the same as for every other copied file the index lists: a failed store read of an undeclared copy still fails the run detail.
  • Round 2 (calibration-diagnostics-326-review-round2-2026-11-27.md, at f261b36): 0 high, 0 medium, 1 low.
    • Low: a version 3 run whose summary records no version showed an unchecked top-level copy. Fixed test-first in b511888 and 2ccc14f.
    • It found that no cache can serve an old reform validation, and that a later package version naming artifacts/reform_validation.json changes nothing here.
    • Its code-quality points:
      • Applied: the module and fixture header comments.
      • Not applied: an artifact-kind check (a kind change in Microcosm would hide the file), and clearing the calibration cache between tests (there's no function to clear it, and the cached answer is the same store's).
  • Round 3 (calibration-diagnostics-326-review-round3-2026-11-27.md, at 2ccc14f): no bugs (0 high, 0 medium, 0 low).
    • It checked every combination of summary version and parsed documents against the collector's summary writer, and ran the test file at b511888 (8 pass, 1 fail) and 2ccc14f (9 pass).
    • Its wording point on this description is applied above.
    • Left as they are: three further combination tests, one code comment that names only a summary with no version, and two long lines in comments and docs.

Bugs left: none.

What the merge waits for

  • 5a · 6 done: the collector change deployed and its new @policyengine/calibration-tree version on npm, pinned here. The live dashboard keeps reading the collector's index on 0.1.5 only while 5a · 6 keeps the index at schema version 1.
  • Anthony marking this PR ready and merging it. 5a · 8 (microcosm#1771) waits for this PR to be deployed.

🤖 Generated with Claude Code

anth-volk and others added 2 commits November 26, 2026 23:48
… reform validation

A US fiscal refresh build's staging run as the version 2 writer stages it
(PolicyEngine/microcosm#1135): version 3 documents and result files under
artifacts/, each declared in the run manifest with its SHA-256. The list
entry, detail and calibration tests pass already; the two reform validation
tests fail: the dashboard reads reform_validation.json only at the run
folder's top level, so a version 2 run shows none from
artifacts/reform_validation.json and shows a top-level copy it never wrote.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A version 2 or 3 staging run writes its reform validation as
artifacts/reform_validation.json and declares it, with its SHA-256, in its
run manifest (PolicyEngine/microcosm#1135). The Candidate tab now reads that
copy for such a run, and shows it only when the run manifest declares a
reform_validation artifact with the copy's digest. A version 1 run's
reform validation is still its top-level reform_validation.json, which a
version 2 or 3 run never reads.

Co-Authored-By: Claude Opus 5.5 <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 8:26pm UTC

Request Review

anth-volk added a commit to PolicyEngine/microcosm-collector that referenced this pull request Nov 26, 2026
The collector copies the files the dashboard reads by their path in the run
folder, and copies reform_validation.json only from the top level. Microcosm's
version 2 writer puts it at artifacts/reform_validation.json.

The new tests: the reconcile command copies a US version 2 run's
artifacts/reform_validation.json; the package's publish command accepts that
name and loadCopiedStagingRun returns it; a declared copy whose digest differs
from its declaration reads as absent, in the copied-run reader and in the
Hugging Face reader, as the dashboard's reader takes it
(PolicyEngine/calibration-diagnostics#326). Two of them already pass and fix
behaviour that must stay: an index naming files a reader does not know is
still read without them, which lets the dashboard's 0.1.5 read the new index,
and the Hugging Face reader's digest check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk and others added 2 commits November 27, 2026 00:08
From review round 1: a version 2 run whose copies hold progress but no run
manifest shows no reform validation, and the calibration and Build progress
readers, which read shorter document lists, never read the run's reform
validation copy. Both pass on the change; they add coverage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From review round 1: the artifacts/ path of the run's reform validation is
built from its logical name in one place, and the reader's comment says a
version 2 or 3 run's declared copy is what the package's 0.1.5 Hugging Face
reader does not read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk and others added 2 commits November 27, 2026 00:25
From review round 2: the collector records a run whose run manifest copy
isn't a JSON object as a problem with no version in its summary, while its
progress and events are still version 3. The reader takes the version from
the summary, so it shows such a run's top-level reform_validation.json,
which no version 2 or 3 run writes. The test fails on that assertion. The
fake store can now set summary fields apart from the run's documents.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From review round 2: a run whose index summary records no version but whose
documents are version 2 or 3 shows no top-level reform_validation.json,
which no version 2 or 3 run writes. The module header now says where it
differs from the package's 0.1.5 Hugging Face reader, and the US version 2
fixture's header says what it leaves out of what the writer stages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk added a commit to PolicyEngine/microcosm-collector that referenced this pull request Nov 27, 2026
A low-priority bug: a run with no readable run manifest is taken as schema 1
whatever its progress says, so a run whose progress is version 2 or 3 still
takes its top-level build and release manifests and reform validation, in the
tree build and the package's readers, where the dashboard's reader
(PolicyEngine/calibration-diagnostics#326) takes none.

Also from the review: a schema-1 run's parent build manifest reaching the
worker is tested again (the replaced staged-dataset test was the only staging
test of it), and the step that stores missing copies is tested in a dry run on
a version 2 run's undeclared top-level files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anth-volk
anth-volk marked this pull request as ready for review November 27, 2026 15:08
@anth-volk
anth-volk merged commit 351a1e4 into main Nov 27, 2026
5 checks passed
@anth-volk
anth-volk deleted the claude/us-version-2-staging-reform-validation branch November 27, 2026 15:08

This branch was successfully deployed

1 active deployment
Preview — 2ccc14fe 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.

Show US version 2 staging runs' reform validation

1 participant