Skip to content

Evaluation harness: resolve BE's build from releases.json as well as latest.json - #323

Merged
anth-volk merged 4 commits into
mainfrom
claude/be-releases-record-resolver
Nov 25, 2026
Merged

anth-volk merged 4 commits into
mainfrom
claude/be-releases-record-resolver

Conversation

@anth-volk

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

Copy link
Copy Markdown
Contributor

Closes #322. Tracker: "1. Collector/Emitter", task 4a · 40.

Merge order: after tracker task 4a · 39 is done (a manual deletion of a GitHub variable; this code does not depend on it, only the tracker order does), and before 5b · 5, which deletes BE's latest.json.

Why

evaluation_harness/microcosm_release.py resolves the Belgium build that scripts/run_full_chronicle_evaluation.py --jurisdictions BE evaluates, by reading latest.json from policyengine/populace-be-private with the operator's own Hugging Face token. Tracker substage 5b moves that repo to the layout the US and UK release repos use, releases.json plus releases/<release>/<build>/ folders, and 5b · 5 deletes latest.json. Without this change the BE run stops at its first read.

What changes

The module reads both layouts, following the readers of the US and UK release repos: the telemetry collector's release run (telemetry_collector/calibration_tree_reconciliation.py, releases_record.py) and Microcosm's dataset loader (microcosm.data.loader). Decided with Anthony on 2026-11-25.

  • Which file decides. When the repo has releases.json, it decides, and latest.json is not read. Only an absent releases.json selects latest.json: nothing at that path in a local release directory, or Hugging Face's 404 with X-Error-Code: EntryNotFound. A local releases.json that is a directory, a broken link or a link loop is refused. Every other failure is raised (401, 403, 404 RevisionNotFound or RepoNotFound, 5xx, network errors), so a refused token or a server error never resolves the build an old latest.json names in a repo that has moved. This is Microcosm's loader's rule. The injectable artifact_reader signals an absent file with FileNotFoundError, as the local reader already did; the local reader now raises it only when nothing is at the path.
  • Which build. The current build of the record's default release, which the collector treats as the repo's latest. A record with no default release, or whose default release has no current build, is refused.
  • The record's rules. releases.json is checked with a copy of the collector's parse_releases_record, which refuses exactly what @policyengine/calibration-tree's parser refuses. The harness depends only on numpy, pyarrow and pyyaml, so it cannot import either parser.
  • Identity check. The build folder's release_manifest.json must name the selected release and build: the collector's whole check, and the identity part of Microcosm's loader's (the loader also checks the manifest's schema_version and that its dataset_role matches the release's role, which concern loading a dataset, not this evaluation). build_manifest.json is read but not checked, so a moved build whose build manifest keeps its old build_id is accepted.
  • What the run summary records (microcosm_be_release, whose hash feeds the run ID). In the new layout:
    • release_id is <release>/<build>, the build's folder under releases/ and the collector's build ID;
    • artifact_paths names the three files in that folder;
    • artifact_sha256 hashes those three files only, so the run ID does not change when an unrelated build is published to or withdrawn from the repo.
      The keys are the same as today's, except that there is no latest hash.
  • The latest.json layout is unchanged. It resolves the same build and gives the same release_id, paths and hashes, latest included, so a rerun before BE's move gives the same summary and run ID. What changes on that path, none of it in the outputs: each run first requests releases.json; a file missing on Hugging Face raises FileNotFoundError instead of HTTPError (no caller catches either); a local artifact that exists but is not a regular file raises ValueError instead of FileNotFoundError; and a release manifest whose build is not an object is refused with the existing mismatch error instead of an AttributeError.
  • ResolvedMicrocosmRelease. latest is None when releases.json selected the build, and a new releases_record field holds the record. Nothing in the repository reads either field.

What this does not change

  • The CLI options (--microcosm-release-dir, --microcosm-release-repository, --microcosm-release-revision). A revision from before BE's move has no releases.json, so it is still resolved through that commit's latest.json.
  • The check that every calibration target lists Chronicle record IDs. It is why the module serves BE only: pointed at the US repo, it would resolve the build and then refuse its diagnostics (none of its 5,659 targets lists them).
  • Scores. After BE's move a rerun gets a new run ID, because the paths and the rewritten manifests' hashes change. The calibration-exposure labels stay the same as long as BE's calibration_diagnostics.json is copied unchanged: the switch tool copies a tagged build's declared files byte for byte and checks their SHA-256, and moving BE's untagged builds is tracker task 5b · 2, not yet written.

Tests

CI does not run the root tests/ folder (docs/chronicle-update-workflow.md: the harness tests are run by hand), so these were run locally by node ID.

  • tests/test_microcosm_release.py:

    • new: the releases.json layout from a reader and from a local directory, with latest.json and the old folder still present; the read failures that must not fall back; a record with no default release or no current build; release manifests that name another build or release, or none; 24 records that break the record's rules, each matched to its own rule's message (invalid UTF-8 and deep nesting included); a record with a leading byte order mark; a local releases.json that is a directory, a broken link or a link loop, and one that links to a file elsewhere; the Hugging Face reader's absent-file answer and the failures it must raise unchanged; every output of the latest.json layout, and its refusal of a release manifest build that is not an object.
    • changed: the two tests that inject a reader now use one that raises FileNotFoundError for an absent file, and the request list starts with releases.json.
  • tests/test_be_full_run.py: new, a BE run on the new layout and the summary block it records.

  • First change: red 824ab14 (40 of the 48 selected test cases fail; the 8 that pass check behaviour that must not change), green 2932f45 (all 48 pass).

  • Review round 1 fixes: red 6f9d2a1 (the 3 local releases.json cases fail; the other new and stricter cases pass), green 07f2f27 (all 56 pass).

Review

One round of adversarial review, in a fresh subagent, on 2932f45. It found no high- or medium-priority bugs, so review stopped there.

  • Low, fixed in 07f2f27: a releases.json in a local release directory that is a directory, a broken link or a link loop counted as absent and selected latest.json.
  • Code quality, applied: four malformed-record cases matched only the releases.json prefix and would still pass with their own rule deleted; each case now matches its own message, with new cases for a byte order mark, invalid UTF-8, deep nesting and the latest.json layout's non-object build. The release-manifest check no longer reads names bound in another branch. The copied record rules name the collector commit they match (370c91b). This description no longer overstates the loader's check or the changes on the latest.json path.
  • Code quality, not applied: splitting resolve_microcosm_release into one helper per layout. The function keeps both layouts' steps in order in one place, and the change would touch the latest.json path that must stay as it is.
  • Not verified by the reviewer (they need Hugging Face or the tracker): that none of the US repo's 5,659 targets lists Chronicle record IDs (the author checked it on 2026-11-25), and the merge order (from the tracker). Whether BE's calibration_diagnostics.json is copied unchanged depends on 5b · 2 and is unverified.

Environment variables and secrets

No deployment code changes. The module reads HF_TOKEN or HUGGINGFACE_TOKEN from the operator's environment, as before; it is an operator tool, one of the exceptions agreed in 4a · 21.

🤖 Generated with Claude Code

anth-volk and others added 2 commits November 25, 2026 22:34
The evaluation harness's Microcosm release resolver reads only
latest.json, which BE's release repo deletes when it moves to
releases.json and releases/<release>/<build>/ folders. These tests
describe the resolver reading both layouts, as the telemetry collector
and Microcosm's loader read the US and UK release repos: releases.json
decides when present, only its absence selects latest.json, the current
build of the default release is resolved as <release>/<build>, and its
release manifest must name that release and build.

Refs #322.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The resolver now reads releases.json first, as the telemetry collector
and Microcosm's loader read the US and UK release repos. When the
record exists it decides: the current build of its default release is
resolved from releases/<release>/<build>/, its release_id is
<release>/<build>, and its release manifest must name that release and
build. The record is checked with a copy of the collector's
parse_releases_record rules, since the harness cannot import it.

Only an absent releases.json (no local file, or Hugging Face's 404
EntryNotFound) selects latest.json, which resolves the same build with
the same outputs as before. Every other read failure is raised, so a
refused token or a server error never resolves an old pointer's build
in a repo that has moved.

Refs #322.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 25, 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 25, 2026 6:55pm UTC

Request Review

anth-volk and others added 2 commits November 25, 2026 22:53
A local releases.json that is a directory, a broken link or a link
loop must be refused, not read as an absent file that selects
latest.json. Each malformed-record case now matches the message of its
own rule, and new cases cover a leading byte order mark, invalid UTF-8,
deep nesting, a releases.json linked to a file elsewhere, and the
latest.json layout's refusal of a release manifest build that is not an
object.

Refs #322.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The local release-directory reader reported every path that is not a
regular file as absent, so a releases.json that is a directory, a
broken link (a Hugging Face cache snapshot copied away from its blobs)
or a link loop selected latest.json. It now treats only a path with
nothing at it as absent and refuses the rest. The release manifest
check no longer reads names bound in another branch, and the copied
record rules name the collector commit they match.

Refs #322.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anth-volk
anth-volk marked this pull request as ready for review November 25, 2026 18:59
@anth-volk
anth-volk merged commit b8443df into main Nov 25, 2026
5 checks passed
@anth-volk
anth-volk deleted the claude/be-releases-record-resolver branch November 25, 2026 18:59

This branch was successfully deployed

1 active deployment
Preview — 07f2f27d Deployed Nov 25, 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.

Evaluation harness: resolve BE's build from releases.json as well as latest.json

1 participant