Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5ea3885
Allow explicit local US data without unused bundle certification (#76…
MaxGhenis Nov 17, 2026
8ab66b5
Bind explicit native input periods before US construction (#760) [ski…
MaxGhenis Nov 17, 2026
681f81e
Validate US certification before provenance exports [skip ci]
MaxGhenis Nov 17, 2026
69b2607
fix: reject invalid native dataset files [skip ci]
MaxGhenis Nov 17, 2026
5f51b00
docs: clarify native input file and clock requirements [skip ci]
MaxGhenis Nov 17, 2026
21bf0a3
docs: clarify deferred US certification and native file refusals [ski…
MaxGhenis Nov 17, 2026
439126c
Defer country imports and guard managed US reuse
MaxGhenis Nov 30, 2026
de6b233
Require PR code checks and verify wheels before publishing
MaxGhenis Nov 30, 2026
7060037
Isolate explicit US download tests from certification
MaxGhenis Nov 30, 2026
7aec0df
Keep UK qualification preparation tests offline
MaxGhenis Nov 30, 2026
da6a4cb
Record the local US source and preserve native period inputs
codex Dec 1, 2026
8ec9367
Check PR fragments against their target and require all code jobs
codex Dec 1, 2026
0c061e6
Bind US caches and provenance to the runtime and inputs
codex Dec 1, 2026
6c15ab8
Preserve native option errors and allow in-file virtual storage
codex Dec 1, 2026
968af61
Exercise preloaded SPM drift with country imports enabled
codex Dec 1, 2026
cbf8d59
Bind US output reuse to resolved requests and verify local data prove…
Dec 1, 2026
2cb1d96
Exclude unused population ID aliases from US output cache identity
Dec 1, 2026
6e87cad
Accept the shipped TRO, pin the model wheel and hash only linked lega…
MaxGhenis Dec 2, 2026
6f22b8b
Check a supplied TRO's composition fingerprint against its artifacts
MaxGhenis Dec 2, 2026
760b186
Refuse a supplied TRO whose artifact digests aren't SHA-256 hex
MaxGhenis Dec 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 11 additions & 16 deletions .github/workflows/certify-uk-release.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
# Qualify each new policyengine-uk wheel or uk-data release before promotion.
# UK candidate qualification starts via workflow_dispatch and resolves legacy
# uk-data pairs. Scheduled recovery and requalification are disabled.
#
# A candidate pair (newest model wheel, the core it needs, newest data
# release) is resolved and deduplicated against the ledger, certified into a
# candidate commit on candidate/uk/<model>-<data> (manifest, pins, uv.lock,
# TRO, test constants and snapshots regenerated together), qualified by the
# mandatory gates on that exact commit, replayed by policyengine-scorecard,
# and recorded in the uk-qualification-ledger branch. Promotion is
# serialized: it readies the newest promotable candidate PR that advances
# and recorded in the uk-qualification-ledger branch. Promotion runs
# serially. It readies the newest promotable candidate PR that advances
# main, closes superseded ones and those of pairs from another data line
# (which are never promoted), and (cos d1344) fast-forwards main to its
# qualified commit once every check on it has passed, which succeeds only
# while main is still the commit it was built on; otherwise the catch-up
# requalifies it on current main.
# while main is still the commit it was built on.
#
# Triggers: a policyengine-uk publish or uk-data release (repository
# dispatch), a two-hourly catch-up, or a manual run. A manual run with
# accept_pair_id records a reviewer's acceptance of a needs-review receipt.
# A manual run with accept_pair_id records a reviewer's acceptance of a
# needs-review receipt.

name: Certify UK release candidates

on:
repository_dispatch:
types: [policyengine-uk-release, policyengine-uk-data-release]
schedule:
- cron: "23 */2 * * *"
workflow_dispatch:
inputs:
model_version:
Expand Down Expand Up @@ -298,10 +293,8 @@ jobs:
# The local gates took 80-89 minutes while every wrapper.household
# contract row errored at once. Since #651 those rows run the household
# calculator, which takes the gates past two hours, so a 120-minute limit
# cancelled every attempt and re-staged it. 330 stays under the 360-minute
# ceiling for GitHub-hosted jobs. Note that stage_attempt's four-hour lease
# still lets a catch-up re-stage a live attempt whose gates pass about four
# hours (#662), so in practice runs should stay under that.
# cancelled every attempt. 330 stays under the 360-minute ceiling for
# GitHub-hosted jobs.
timeout-minutes: 330
concurrency:
group: uk-candidate-${{ needs.resolve.outputs.pair_id }}
Expand Down Expand Up @@ -418,6 +411,8 @@ jobs:
fi
gh pr edit "$number" --body-file "$RUNNER_TEMP/pr-body.md"

# Intentionally dormant while workflow_dispatch is the only trigger.
# Its two self-dispatches cannot run without a schedule.
catch-up:
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/pr_agent_notes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
# on 23 October 2026. .github/check-agent-notes.sh lists the paths it
# rejects.
#
# pr_code_changes.yaml has a path filter, so a pull request that adds only
# such files runs none of its jobs. This workflow has no path or branch
# filter. It checks the pull request's head commit, fetched as data, not the
# merge with the base, so the base cannot change the result. Main has none
# of these paths, so a pull request based on main fails exactly when it adds
# one. "edited" covers a retarget: a stacked pull request whose old base had
# On each subscribed pull-request event, the guard checks the fetched PR head
# tree using the default branch's guard when available. Main has none of these
# paths, so a pull request based on main fails exactly when it adds one.
# "edited" covers a retarget: a stacked pull request whose old base had
# no guard first gets one when it is retargeted to main. Every edit runs the
# full check, so a title edit cannot replace a failure with a skipped run.
#
Expand Down
96 changes: 84 additions & 12 deletions .github/workflows/pr_code_changes.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Workflow that runs on code changes to a pull request.
# Report PR code checks on opened, synchronised, reopened and edited pull
# requests and on manual dispatch. Skip code jobs when a pull request's
# changed paths match the documentation exclusions.
#
# Runners. These jobs, the docs build, and Lint and Test on pushes to main
# run on ubuntu-latest unless a repository variable names another runner
Expand All @@ -23,37 +25,71 @@
name: Code changes
on:
pull_request:
paths:
- src/**
- tests/**
- scripts/**
- .github/**
- changelog.d/**
- pyproject.toml
- uv.lock
- src/policyengine/data/bundle/manifest.json
types: [opened, synchronize, reopened, edited]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
Changes:
name: Detect code changes
runs-on: ubuntu-latest
permissions:
contents: read
timeout-minutes: 10
outputs:
code: ${{ steps.paths.outputs.code }}
steps:
- uses: actions/checkout@v6
if: github.event_name == 'pull_request'
with:
fetch-depth: 0
persist-credentials: false
- name: Check changed paths
id: paths
env:
EVENT: ${{ github.event_name }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
status=1
if [[ "$EVENT" == pull_request ]]; then
status=0
git diff --quiet "$BASE_SHA...$HEAD_SHA" -- . ':(exclude)docs/**' \
':(exclude)README.md' ':(exclude)CONTRIBUTING.md' \
':(exclude)CHANGELOG.md' ':(exclude)CODE_OF_CONDUCT.md' || status=$?
fi
case "$status" in
0) echo "code=false" >> "$GITHUB_OUTPUT" ;;
1) echo "code=true" >> "$GITHUB_OUTPUT" ;;
*) exit "$status" ;;
esac

check-changelog:
name: Check changelog fragment
needs: Changes
if: needs.Changes.outputs.code == 'true'
runs-on: ${{ vars.CI_RUNNER_X64 != '' && (vars.CI_RUNNER_EVENTS == '' || contains(format(',{0},', vars.CI_RUNNER_EVENTS), format(',{0},', github.event_name))) && vars.CI_RUNNER_X64 || 'ubuntu-latest' }}
permissions:
contents: read
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
fetch-depth: 0
persist-credentials: false
- name: Install towncrier
run: pip install towncrier
- name: Check for changelog fragment
run: .github/check-changelog.sh
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: .github/check-changelog.sh "${BASE_SHA:-origin/main}"
Lint:
needs: Changes
if: needs.Changes.outputs.code == 'true'
runs-on: ${{ vars.CI_RUNNER_X64 != '' && (vars.CI_RUNNER_EVENTS == '' || contains(format(',{0},', vars.CI_RUNNER_EVENTS), format(',{0},', github.event_name))) && vars.CI_RUNNER_X64 || 'ubuntu-latest' }}
permissions:
contents: read
Expand All @@ -69,6 +105,8 @@ jobs:
- name: Run ruff check
run: ruff check .
Mypy:
needs: Changes
if: needs.Changes.outputs.code == 'true'
runs-on: ${{ vars.CI_RUNNER_X64 != '' && (vars.CI_RUNNER_EVENTS == '' || contains(format(',{0},', vars.CI_RUNNER_EVENTS), format(',{0},', github.event_name))) && vars.CI_RUNNER_X64 || 'ubuntu-latest' }}
permissions:
contents: read
Expand All @@ -89,6 +127,8 @@ jobs:
run: mypy src/policyengine || echo "mypy found errors (non-blocking until codebase is clean)"
Python-Compat:
name: Install + smoke-import (py${{ matrix.python-version }})
needs: Changes
if: needs.Changes.outputs.code == 'true'
runs-on: ${{ vars.CI_RUNNER_X64 != '' && (vars.CI_RUNNER_EVENTS == '' || contains(format(',{0},', vars.CI_RUNNER_EVENTS), format(',{0},', github.event_name))) && vars.CI_RUNNER_X64 || 'ubuntu-latest' }}
permissions:
contents: read
Expand All @@ -114,8 +154,9 @@ jobs:
run: python -c "import policyengine; from policyengine.core import Dataset, Policy, Simulation; from policyengine.outputs import aggregate, poverty, inequality; print('import OK')"
BundleVerification:
name: Verify release inputs and bundle packages
needs: Changes
# Private manifest credentials are available only to trusted repository PRs.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
if: needs.Changes.outputs.code == 'true' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
runs-on: ${{ vars.CI_RUNNER_X64 != '' && (vars.CI_RUNNER_EVENTS == '' || contains(format(',{0},', vars.CI_RUNNER_EVENTS), format(',{0},', github.event_name))) && vars.CI_RUNNER_X64 || 'ubuntu-latest' }}
permissions:
contents: read
Expand Down Expand Up @@ -170,6 +211,8 @@ jobs:
- name: Verify bundle packages
run: policyengine bundle verify --country us --country uk --packages-only --json
Test:
needs: Changes
if: needs.Changes.outputs.code == 'true'
runs-on: ${{ vars.CI_RUNNER_X64 != '' && (vars.CI_RUNNER_EVENTS == '' || contains(format(',{0},', vars.CI_RUNNER_EVENTS), format(',{0},', github.event_name))) && vars.CI_RUNNER_X64 || 'ubuntu-latest' }}
permissions:
contents: read
Expand Down Expand Up @@ -209,3 +252,32 @@ jobs:
run: make test
env:
HUGGING_FACE_TOKEN: ${{ secrets.HUGGING_FACE_TOKEN }}

PR-Checks:
name: PR code checks
if: always()
needs: [Changes, check-changelog, Lint, Mypy, Python-Compat, BundleVerification, Test]
runs-on: ubuntu-latest
permissions: {}
timeout-minutes: 5
steps:
- name: Fail when a dependency failed or was cancelled
if: failure() || cancelled()
run: exit 1
- name: Check code job results
env:
RESULTS: ${{ toJSON(needs) }}
VERIFY_BUNDLE: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
run: |
jq -e --arg verify_bundle "$VERIFY_BUNDLE" '
(keys == ["BundleVerification", "Changes", "Lint", "Mypy",
"Python-Compat", "Test", "check-changelog"]) and
(.Changes as $changes |
$changes.result == "success" and
($changes.outputs.code == "true" or $changes.outputs.code == "false") and
all(del(.Changes) | to_entries[];
.value.result ==
(if $changes.outputs.code == "false" or
(.key == "BundleVerification" and $verify_bundle == "false")
then "skipped" else "success" end)))
' <<< "$RESULTS"
16 changes: 12 additions & 4 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
steps:
- uses: actions/checkout@v6
- name: Setup Pages
uses: actions/configure-pages@v3
uses: actions/configure-pages@v5
- uses: actions/setup-node@v4
with:
node-version: 18.x
Expand Down Expand Up @@ -176,9 +176,8 @@ jobs:
Publish:
runs-on: ubuntu-latest
if: github.event.head_commit.message == 'Update package version'
# PyPI trusted publishing: PyPI accepts uploads only from this workflow in
# the pypi environment, which is limited to main. id-token: write comes
# from the workflow-level permissions. No stored PyPI token.
# PyPI accepts uploads from this workflow through trusted publishing.
# The pypi GitHub environment controls deployment authorisation for trusted publishing.
environment: pypi
env:
GH_TOKEN: ${{ github.token }}
Expand Down Expand Up @@ -217,6 +216,15 @@ jobs:
run: ".github/publish-git-tag.sh"
- name: Build package
run: python -m build
- name: Smoke-test the built wheel
run: |
smoke_dir=$(mktemp -d "$RUNNER_TEMP/policyengine-wheel.XXXXXX")
python -m venv "$smoke_dir/venv"
"$smoke_dir/venv/bin/python" -m pip install dist/*.whl
cd "$smoke_dir"
unset PYTHONPATH
"$smoke_dir/venv/bin/python" -c "import policyengine; print(policyengine.__version__)"
"$smoke_dir/venv/bin/policyengine" bundle manifest > /dev/null
- name: Export bundle release assets
run: python scripts/export_bundle_release_assets.py --dist-dir release-assets
- name: Verify bundle package metadata
Expand Down
1 change: 1 addition & 0 deletions changelog.d/760.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add `native_input_period` for explicit local TIME_PERIOD_ARRAYS files. A four-digit year string sets the input and calculation defaults before the country constructor while preserving each stored period. The option requires a nonempty `.h5` file.
3 changes: 3 additions & 0 deletions changelog.d/760.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Allow explicit local US datasets with `allow_unmanaged=True` to record the local file’s SHA-256 and checked package-version metadata with unverified provenance. Keep the explicit local year-file helpers and standalone long-term loader independent of the unused bundled data.

Check current US runtime certification for managed materialisation, simulation runs and output reuse, model bundle receipts, model TRACE exports and run records with an attached US model. Validate a supplied bundle TRO against the attached model before writing a run record. Bind year files to their source and runtime. Bind cached US outputs to the calculation inputs, resolved legacy SPM profile, reforms, effective scope, requested columns and runtime. Require self-contained HDF5 for explicit local inputs, including standalone long-term loads, and retain in-file virtual storage. Report a missing absolute US dataset path before checking bundled-data certification.
3 changes: 3 additions & 0 deletions changelog.d/761.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Report PR code checks on opened, synchronised, reopened and edited pull requests and on manual dispatch. Skip code jobs when a pull request’s changed paths match the documentation exclusions. Check changelog fragments against the pull request’s target.

Run UK candidate qualification on manual dispatch only. Install and smoke-test the built wheel before uploading distributions to PyPI.
Loading