Repository navigation
Test policyengine-us main against the Core under test on each PR - #635
Conversation
Core 3.33.13 broke policyengine-us main's state machine test within minutes of release, while the country smoke job passed: it installs a pinned policyengine-us release and only checks that systems load. The new PolicyEngineUSMain job runs a list of fast policyengine-us tests that drive Core internals, with the Core release and then with this checkout, and fails only on tests that fail with this Core alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis
left a comment
There was a problem hiding this comment.
Agent review for Max, written by Claude Code for Max Ghenis.
The new job can go green without running the policyengine-us tests, and that needs a fix before its result can be relied on (00167396 reviewed; the PR has no earlier reviews or comments).
P1. Green result after an incomplete run. pr.yaml:167 and 175 end in || true, so pytest's exit status is lost. compare then looks only at tests present in the candidate report. A test that passed with the release and is missing from the candidate report counts for nothing. I ran country_main_tests.py compare at this head on hand-written JUnit files:
| Release report | Candidate report | Expected | Actual |
|---|---|---|---|
| 2 passed | empty (pytest exit 5) | fail | exit 0, "0 tests ran with this Core [...] Every test passes with this Core." |
| 2 passed | 1 passed, the other missing (pytest exit 2) | fail | exit 0, "Every test passes with this Core." |
| 1 collection error | the same collection error | fail or inconclusive | exit 0, with one warning |
| 1 collection error | 1 passed, 1 failed | inconclusive | exit 1, "This Core breaks t::b" |
pytest writes the JUnit file in all these cases: wrap_session calls pytest_sessionfinish after an interrupt too, and exit 5 means no tests were collected. Two runs of the workflow's own command, one with an empty test file and one with a KeyboardInterrupt in a test, also ended green (reported, not rerun here).
The third row is the likely one. Without --continue-on-collection-errors, pytest stops before the first test when any file fails to collect, and neither the command here nor policyengine-us's configuration sets that flag. If policyengine-us main has one listed file that does not import, both runs stop, no test in the other 12 files runs, and any Core break in them passes. That is the state the job is designed to tolerate (the script's docstring: "policyengine-us main is sometimes red for its own reasons"). The fourth row is the reverse: if this Core fixes the collection error, tests that were already failing in the other files are blamed on it.
Suggested fix:
- Pass
--continue-on-collection-errorsin both runs. Assertion and collection failures then end in exit 1 and still go tocompare. - Run pytest without
xargs(for example,mapfile -t files < ../selected.txt), because GNUxargsturns any pytest status from 1 to 125 into 123. Then capture the status in place of|| true, and fail the step when it is above 1. - In
compare, fail when the candidate report has no tests, or lacks a test that passed with the release.
The job's test at test_country_main_tests.py:137-169 compares the command strings and does not drive these exits.
P2. One listed file downloads the default microdata. policyengine-us-main-tests.txt:25 selects test_uprating_extensions.py, where one test calls Microsimulation() only to read parameters. With no dataset, that resolves to a Hugging Face download of a file that policyengine-us puts at about 830 MB. Each job on a fresh runner would download it, and both runs would build that simulation. I read this path and did not run it. Core's smoke job avoids this today: RUN_SMOKE_TESTS is "0", and test_country_init.py says its tests "don't need a dataset". Deselect that test, or have policyengine-us read system.parameters there.
P2. The summary says more than the reports show. country_main_tests.py:97-98 prints "Every test passes with this Core." when a candidate test was skipped (2 passed, then 1 passed and 1 skipped: exit 0, that line), and when none ran. Line 95 calls shared failures "policyengine-us's own". Your second replay row shows otherwise: the test fails with 3.33.13 and with master because a Core release changed, and it passed with 3.33.12. Say "failing with both Cores", and count skips.
P3. The install step (pr.yaml:171-172) has no uv pip check. The smoke job runs one (pr.yaml:115-116), and this job is where a Core bound that conflicts with policyengine-us main would show.
Until the P1 is fixed, green does not mean the tests ran, which bears on your first open question (block merging, or only report).
Address review: `|| true` hid pytest's status, and compare looked only at tests in the candidate report, so an empty or cut-short run went green. - Run both passes through `country_main_tests.py run`, with --continue-on-collection-errors, and fail on any pytest status but 0 or 1. - compare fails when this Core's run recorded no tests, a report is missing, or a test that passed with the release did not run. A failure in a file the release could not collect is a warning, not a break. - The summary counts skips and says "failing with both Cores". - Deselect the uprating test that downloads the default microdata. - Check the installed dependencies after installing this Core. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Core change can need a policyengine-us fix after its release, so a test this Core breaks no longer fails the job. compare writes its result, and the new report step posts a neutral "policyengine-us compatibility" check listing the breaks (successful when there are none) and one bot comment, updated on later runs. A file this Core cannot collect counts as a break. The job still fails when the comparison cannot be trusted: a run wrote no report or no tests, or a test that passed with the release did not run for any reason the reports show. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ummary - compare fails when the Core release's run collected no tests (only collection errors), instead of calling every entry a failure with both Cores and reporting no breaks. - A test that passed with the release and is skipped with this Core is a warning and listed in the check summary. - The compare step appends its result to the job summary, which the PR comment and the no-write-access warning point to. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The release-baseline check ignores modules that skipped themselves while being collected, as it ignores modules that failed to import, so a release run with only those entries fails the job instead of reporting no breaks. - Tests in a module this Core skips while collecting are newly skipped (a warning, listed in the check) rather than missing (a job failure). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Codex reviewed All 29 focused tests passed locally, and all 21 checks passed on this commit, including the policyengine-us compatibility job. CI run |
What this fixes
Core 3.33.13 broke a policyengine-us test on main within minutes of its release, and nothing in Core's CI could have shown it first.
core/test_social_security_input_state_machine.py, whose backend runs Core's installedSimulationBuilder,Simulation, holder and dumper source in namespaces it builds.build_default_simulationnow callsoperator.index, andrestore_simulationcalls a new_restore_count.NameError: name 'operator' is not defined; policyengine-us CI installs the newest Core on every run. PolicyEngine/policyengine-us#10504 gives the backend both names.#624 itself is correct. Core already checks itself against policyengine-us, but
SmokeTestForMultipleVersionspassed on #624 because it doesn't test enough to catch this:policyengine-us==2.42.13, which predates the test.Nothing checks again after the PR either:
Publishinpush.yamlhas noneeds.What changes
A new PR job,
PolicyEngineUSMain("Test policyengine-us main against this Core"), sits beside the smoke job:.github/requirements/policyengine-us-main-tests.txtwith that release, with a JUnit report.direct_url.jsonpoints at the checkout (the two versions can be equal before a release bump), and runsuv pip check..github/country_main_tests.py comparesorts the results, andreportputs them on the PR.How a break shows
A Core change can break policyengine-us on purpose, with the policyengine-us fix landing after the Core release. So a break does not fail the job. Instead:
github-actions[bot]posts one comment listing the tests, with the advice to merge if the change is intended and fix policyengine-us right after the release. Later runs edit that comment rather than adding new ones; once nothing breaks, it says so.A break is a test that fails with this Core but did not fail with the release, or a test that passed with the release in a file this Core cannot collect. A test that fails with both Cores is policyengine-us's own failure, so it only gets a warning, as does a failure in a file the release could not collect. A test that passed with the release and is skipped with this Core, on its own or because its file skips itself, is not a break, but its coverage is lost: it gets a warning and its own list in the check.
That rule addresses why #546 pinned the smoke bundle: country-side failures kept turning Core's CI red. policyengine-us main is sometimes red for its own reasons. Release run 40544014984, the first on 3.33.13, failed this Core test and also
core/test_mt_state_agi_invariants.py, a policyengine-us failure fixed by PolicyEngine/policyengine-us#10496. This job would blame Core only for the first.When the job fails
The job fails only when its comparison cannot be trusted:
The test list
The list starts with 13 fast files that drive Core internals: simulations, holders, data storage, tools, populations, parameters and reforms. It includes the state machine test. Together they took about 95 seconds in policyengine-us release run 40544965026, against 96 minutes for its whole
tests/core.deselect <path>::<test>line leaves one test out. The list deselects one test intest_uprating_extensions.pythat builds the default Microsimulation, downloading about 830 MB of microdata only to read parameters.Permissions
The job gets
checks: writeandpull-requests: writeto post the check and the comment; no secrets or setup are needed. The job summary also keeps the full result. On a PR from a fork the token is read-only, so the report step warns and the job still passes, with the result in the job summary.Tests
tests/core/test_country_main_tests.py, 29 tests, covering:runagainst real pytest exits: passing, failing, a collection error, no tests and interrupted;These tests were not run locally after the last four commits; CI runs them. They passed with the rest of this PR's checks (21 of 21) on 17a9e69, including
ruff format --checkand actionlint. a08b130 adds the release-baseline check, the newly skipped list and the job summary; d45823a treats files that skip themselves during collection as not collected.Live check on 2026-12-02, on this PR and on a throwaway test PR, Test only, do not merge: check the policyengine-us break report #680 (now closed). Test only, do not merge: check the policyengine-us break report #680 was this branch plus a new module-level name used in
build_default_simulation, the kind of change 3.33.13 made:TestSocialSecurityInputStateMachine::runTestAn earlier local replay against Restore simulations with no persons or empty groups, and refuse non-integer default counts #624's merge commit (bb7660e), with 3.33.12 as the release, found the state machine test as the one break. With 3.33.13 as the release and
masteras the candidate, it found no break, since the test failed with both.Open question for review: should the list move to policyengine-us, so the people writing those tests maintain it?
🤖 Generated with Claude Code