Repository navigation
Conversation
…ps certification Tracker task 1.4 · 8. Certification closes the post-export scorer only once every stage has finished, so when the reform-coverage check fails at the certified tier (or with a failure no evidence owner matches), or any stage raises, the pool's workers keep running the units they had started until the process exits. The new tests run _certify_us_build on the fixture plan with the fake engine, and require: - a failed check that stops certification to leave no pool worker running and no batch files when the refusal leaves _certify_us_build, with the check's reform units run first and the reform-validation unit already started killed rather than finished (certified tier, and evidence tier with an unowned failure); - any other error during scoring to close the scorer too, pooled or serial; - an error from closing the scorer to be printed, with the original error raised. Two pins pass already: a failed check that certification goes on past (the allow option, or an evidence failure with an owner) cancels nothing, and every later stage writes its file. The fake engine gains WAIT_FOR_OTHER_REFORMS, which holds every reformed simulation but the listed ones. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… scoring
Tracker task 1.4 · 8 ("Schedule the reform-coverage passes first and cancel
the rest when that check fails"). Pooled scoring already hands out the
reform-coverage smoke's reform units before any other stage's, after the
merged baseline pass. Certification now closes the scorer when any error
stops it between opening the scorer and taking its manifest block, then
raises that error:
- the smoke's refusal at the certified tier, or an evidence-tier smoke
failure that matches no owner;
- any stage's own error, a unit that failed on every attempt, or a SIGTERM
(BuildTerminatedError).
A pooled scorer's workers then stop at once: those still running a unit,
such as reform validation's first units, which start while the smoke's last
are running, are killed rather than left to run until the process exits.
Every scorer removes its batch files. An error from closing is printed and
the first error is the one raised (_close_post_export_scorer_after_error).
A failed smoke that certification goes on past (the allow option, or an
evidence failure with an owner) cancels nothing. The check itself, its
record and the serial scorer's outputs are unchanged.
The diff re-indents the scoring stages inside the new try block; view it
with whitespace ignored.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 1 (two adversarial reviewers) found no fault in the change and these in its tests: - The stop test raced with its worker: the pool hands reform validation's first unit to the worker as the check's last result comes back, and the close could kill the worker before it logged that unit's first engine. The test now waits, after the check runs, until the worker has built it, so the kill always lands on a started unit. - Nothing raised an interrupt. test_any_error_during_scoring_closes_the_scorer gains a pooled case where the stage raises BuildTerminatedError (a KeyboardInterrupt, as certification raises a SIGTERM), so a handler narrowed to Exception would fail it. - "Killed at once" was not separated from a close that waits: the stop test now requires the refusal within 8 seconds of the check's result, below the pool's 10-second wait for a worker told to stop, while the started unit waits two minutes. - Live workers were found only among processes that wrote to the engine log; the tests now require no new multiprocessing child at all. - The opener stub dropped certification's batch parent; the scorers are now built in it, and the tests require the parent the scorer made to be removed too. - The stop test now also checks that the merged baseline pass's engines were all built before any reform's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 1 found the wording loose. The docstring of _close_post_export_scorer_after_error, the release-build doc and the changelog fragment now say that: - only workers running a unit are killed at once; idle workers are told to exit and killed after 10 seconds if they have not; - with one worker, reform validation's first unit is handed out as the smoke's last result comes back, before the smoke's result is decided; - an Exception from closing is printed and the first error raised, but an interrupt while closing (Ctrl-C, or a first SIGTERM) is raised instead; - batch files a failed close left are removed when the process exits. No code changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 2 found nothing serious in the change. From its findings:
- An error from closing whose text cannot be made (its __str__ raises)
replaces the error that stopped certification, because the warning
formats it unguarded. New case
test_an_error_closing_the_scorer_does_not_replace_the_one_that_stopped_it
[unprintable] fails until the warning is guarded.
- These pass already and pin documented behaviour:
- test_an_interrupt_while_closing_the_scorer_is_raised: an interrupt
while closing is raised, with the first error as its context;
- test_a_stage_error_kills_the_units_still_running: reform validation
failing while the worker runs its next unit kills that unit at once.
- test_a_failed_check_that_does_not_stop_certification_cancels_nothing
passed even when the busy worker was killed and its unit run again in a
fresh one (the reviewer showed this). It now also requires one pool, one
worker start and no failed attempts.
- The tests build their exceptions inside the test, not at collection, so
no exception and its traceback outlives its test.
- Wording: WAIT_FOR_OTHER_REFORMS waits before each variable an engine
computes; the module docstring lists the closing tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- _close_post_export_scorer_after_error guards making the warning's text: an error from closing whose __str__ raises is printed by its class name, and the error that stopped certification is still the one raised. - The release-build doc and the changelog fragment say the scorer is closed before the error leaves certification (it has already been raised by then). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review round 3 found nothing serious. From its findings: - When closing the scorer after an error raises, and writing the warning to standard error fails too (a broken pipe), the write's error replaces the one that stopped certification. New test_a_warning_that_cannot_be_written_does_not_replace_the_error fails until the write is guarded. - test_a_stage_error_kills_the_units_still_running also requires the batch parent the scorer made to be removed, as the neighbouring tests do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_close_post_export_scorer_after_error no longer lets a failed write of its warning (standard error's reader gone) replace the error that stopped certification: the print is guarded, and the first error is raised. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tracker task 1.4 · 8 (project 15, "US build memory, CPU and run time"): "Schedule the reform-coverage passes first and cancel the rest when that check fails".
Stacked on #1775 (1.4 · 7, pooled post-export scoring as certification's default): this pull request's base is #1775's branch, so its diff shows only this task. It will be rebased onto
mainonce #1775 merges.What this does
Certification (
_certify_us_buildintools/build_us_fiscal_refresh_release.py) now closes the post-export scorer when any error stops it during scoring, then raises that error. Before, nothing closed the scorer until every stage had finished, so on an error a pooled scorer's workers kept running the units they had started until the process exited and the pool's exit handler killed them.BuildTerminatedError._close_post_export_scorer_after_error):Exceptionfrom closing is printed to stderr, and the first error is the one raised. This holds even when the error's text cannot be made or stderr cannot be written;--allow-reform-coverage-smoke-failures, or an evidence-tier failure with an owner) cancels nothing: every later stage still runs and writes its file.How this meets the task's finished-when text
"The reform-coverage passes run first, and the remaining passes are cancelled when that check fails."
Decisions (Anthony, 27 November 2026, recorded in the tracker task's notes)
reform_coverage_smoke.jsonkeeps every probe's result. The check function, its record and the serial scorer's outputs are unchanged. Cancelling matters only for pooled scoring; the serial path already raises before reform validation starts.tools/probe_us_post_export.py) is unchanged: it runs every stage whatever the check says, and it already closes its scorer in afinallyblock.Tests
Red-green throughout: each round's failing tests were committed before the change that makes them pass.
The new tests are at the end of
packages/microcosm-build/tests/engine_free/us/test_us_post_export_pooled_scoring.py. They run_certify_us_buildwith a stub of the build record on the fixture plan and the fake engine, in certification's batch folder, with three of the shipped probes made to pass or fail.test_a_failed_check_that_stops_certification_stops_the_pools_workers[certified|evidence_unowned]: one worker, and every reform other than the check's waits on a file nobody writes.reform_validation.jsonwas never written.test_any_error_during_scoring_closes_the_scorer[pooled|serial|pooled_sigterm]: an error, or aBuildTerminatedError, from the demographics writer leaves no worker running and no batch files.test_a_stage_error_kills_the_units_still_running: reform validation fails as it builds its second reform, while the worker runs that reform's unit. The unit is killed within 8 seconds.test_an_error_closing_the_scorer_does_not_replace_the_one_that_stopped_it[ordinary|unprintable]andtest_a_warning_that_cannot_be_written_does_not_replace_the_error: the check's refusal is raised.test_an_interrupt_while_closing_the_scorer_is_raised: the interrupt is raised, with the refusal as its context.test_a_failed_check_that_does_not_stop_certification_cancels_nothing[allowed|evidence_owned]: every stage writes its file, from one pool and one worker start, with no failed attempt.The fake engine (
test_support/microcosm_build/us_post_export_pool.py) gainsWAIT_FOR_OTHER_REFORMS, which makes every reformed simulation other than the listed ones wait for a file before each variable.What was run, and what wasn't:
_certify_us_build's source (test_us_post_export_scoring.py,test_us_fiscal_refresh_builder.py,test_us_post_export_pooled_scoring.py,test_release_contract_fixture_generation.py) were read against the change, by me and by two reviewers, but not run. They useast.walk, line order, or substrings outside the re-indented lines.The tool's diff re-indents the scoring stages inside the new
tryblock, so view it with whitespace ignored (?w=1).Review
Three rounds of adversarial review (subagents) followed, each with its fixes:
Not done here, and known effects
No CI runs on this pull request yet. The test workflow runs only on pull requests that target
main, and retargeting starts no run (docs/agent-guide.md). Once Score US post-export requests in the shared worker pool by default #1775 merges, this branch is rebased ontomain, which pushes, retargets and starts CI.Cost figures: those in decision 2 are estimates from tracker task 1.4 · 6's per-pass figures. No run measured them.
Closing now happens before
certify_mainreports the failure to staging (telemetry.fail). The close takes about 0.05–0.2 s when measured, and up to 10 s if an idle worker is slow to exit. A second SIGTERM in that window kills the process before the failure is reported, because the first SIGTERM resets the handler.A pre-existing edge case:
_HouseholdBatchedPostExportScorer.close(from Score US post-export requests in the shared worker pool by default #1775 andmain) has notry/finally. If finishing an open reform raises, its batch files are left until the process exits, when its finalizer removes them. This pull request leaves that code alone.🤖 Generated with Claude Code