Skip to content

Stop the merged baseline pass at a refused post-export batch file - #1772

Merged
MaxGhenis merged 3 commits into
mainfrom
batch-file-error-skips-fallback
Nov 27, 2026
Merged

MaxGhenis merged 3 commits into
mainfrom
batch-file-error-skips-fallback

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

The merged baseline pass from #1725 catches every error with except Exception. A PostExportBatchFileError raised while it reads a batch file therefore takes the fallback path: the scorer logs "each consumer scores its own baseline plan instead" and scores each consumer's plan again. The description of #1751 asks whichever of the two merged second to re-raise the refusal there, as the two held-out writers do. Neither did, and main at c5859652 still catches it.

What changes

  • _baseline_for re-raises PostExportBatchFileError before its broad handler, and both its docstring and the comment that describes the scoring plan now note the exception.
  • docs/us-release-build-rule.md says a refused batch file stops the shared pass and costs a rerun.
  • Two new tests in test_us_post_export_batch_files.py:
    • a batch file whose bytes changed: the merged pass raises, logs no fallback, scores no consumer's own plan and leaves _merged_baseline_failed unset;
    • a batch file that fails one read and passes the next: the merged pass raises. On main it returned values through the fallback.

Effect

  • A changed or missing batch file already stopped certification on main, one pass later. It now stops at the merged pass.
  • A file that failed one read and passed the next let certification finish without the merged pass. It now stops certification, as a refused file does in every other post-export stage. This one changes behaviour.
  • The guard sweep's baseline worker in tools/sweep_us_post_export_scoring.py registers its plans the same way. A refused batch file now stops that worker at the merged pass too.
  • Scored values do not change.
  • No packages/*/src file changes, so neither builder_code_identity nor the worker identity moves. The release tool changes, so a build from before this commit certifies at its own commit, as after Keep the US post-export scorer's household batches in files, not memory #1751.

When certification stops

  • The error names the batch file and says which check failed: the read, with its OSError, or the SHA-256 the scorer recorded. With the fix, the first refusal surfaces. On main, a lasting refusal surfaced only from the fallback's second read.
  • Nothing in certification resumes. The rerun takes the same command on the same --out, with no extra flag, and redoes all of certification, though not the build. Placing the build for certification removes the earlier attempt's outputs and the batch directories its scorer left in post_export_batches/.
  • Under Route A the certify stage fails with exit status 1 and does not retry. Running ./route_a.sh --certify on the same run root and commit reruns it and skips the build stages already accepted.
  • In a build that skips no stage, the shared pass runs before any stage writes its output. A stop therefore loses setup and part of one pass, and the rerun costs one full certification.
  • A refused file stops certification before the scorer closes. Its batch files stay on disk until the command exits, when the scorer's finalizer removes them.
  • Every handler between the batch read and the certify command, apart from the one in _baseline_for, raises the refusal again. _certify_main_with_close_out records the failure first.

Testing

  • Without the fix, both new tests fail on c5859652: the first finds the fallback log line, and the second raises nothing.
  • With the fix, test_us_post_export_batch_files.py and test_us_post_export_scoring.py pass (85 tests).
  • ruff check and ruff format --check pass on the two changed Python files.

axiom: n/a: error handling in the US release tool's post-export scorer; no rule, parameter or RuleSpec change

🤖 Generated with Claude Code

MaxGhenis and others added 3 commits November 26, 2026 20:53
_baseline_for caught every error from the merged baseline pass with
`except Exception`, PostExportBatchFileError included, then logged a
fallback and let each consumer score its own plan. The batch-file PR
said whichever of it and the merged-pass PR landed second should
re-raise the refusal there, as the two held-out writers do; neither
did. A changed file still stopped certification one pass later, and a
file that failed one read and passed the next let certification finish
without the merged pass.

Re-raise PostExportBatchFileError before the broad handler, say so in
the docstring, and test both cases: a changed file (no fallback log,
no fallback pass) and a file that fails one read only (now raises;
main returned values through the fallback).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The rule still said every stage runs its own pass when the shared pass
raises. A refused batch file is now the exception: it stops
certification there, and the cost is a rerun.

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

The scoring-plan comment still said every consumer scores its own plan once
the merged pass fails; a refused batch file is raised at once instead. The
_baseline_for docstring now names the guard sweep's baseline worker, which
registers its plans too. The changed-file test asserts that no consumer
scored its own plan.

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

Copy link
Copy Markdown
Contributor Author

The review of this change returned REQUEST_CHANGES, and I'm going by its finding levels, which leave nothing that blocks the merge. Its one P2 asks certification to close the post-export scorer in a try/finally when a stage fails. That code in _certify_us_build sits outside this change, and every other failure in those stages takes the same path today, so I'm tracking it as a follow-up. Its three P3s concerned the description, which now carries the fixes.

@MaxGhenis
MaxGhenis marked this pull request as ready for review November 27, 2026 00:30
@MaxGhenis
MaxGhenis merged commit 43db96e into main Nov 27, 2026
11 checks passed
juaristi22 added a commit that referenced this pull request Nov 27, 2026
…the e4d46c93 feed and the new CI caps (#931)

Main took six pull requests since 4b78a9b: #1736 (LCFS spending drawn as
a budget and a donor's mix, with a decile receipt beside ONS Family
Spending, the UK feed re-pinned to Chronicle e4d46c93, and register
renewals), #1779 (the CI caps from the slowest legs of 19 to 26 Nov), #1772
(a batch file's error skips the fallback), #1767 (New Zealand declares its
receipt's take-up cap), #1751 (the US post-export H5 path) and #1723 (US QRF
identity tests). The engine lock does not move.

Eight files conflicted.
- uk_runtime/lcfs_consumption.py: main's receipt imports and the clip's
  docstring, which now names the mix donor and keeps this branch's count of
  distinct source households over every clone. Main's new decile and
  range-step receipts count the frame's support in distinct source
  households (source_household_id), so on the clone-first spine a source
  household's clones count once.
- uk_runtime/graph_kernels.py: the LCFS stage keeps this branch's full list
  under the derived binding rule and adds microcosm.fit.donors, which main's
  draw computes through.
- uk_runtime/calibration_run.py: main added the LCFS decile gate to the spine
  gate scope, which this branch keeps in gate_scopes.py; the gate goes there.
- .github/workflows/test.yml: main's caps and their basis, and this branch's
  note on the after-merge job's cap.
- The gate contract pins, the coverage manifest and the H2 fixture are
  recomputed on the merged tree.

The feed. Main moved the UK feed from Chronicle 15040ea5 to e4d46c93 and
recorded that every 15040ea5 row is byte-identical there, the 487 new rows
being ONS Family Spending. This branch's own Scottish Band D facts take the
new pin stamps with their 32 rows unchanged, as main's re-pin did for its
vendored resources; the local membership takes main's feed label and DESNZ
keys beside this branch's two UC seat deferrals. The vendor tool's check
against the e4d46c93 artifact did not run here, which lacks that artifact.

Checks: with policyengine-uk hidden, as in CI's engine-free job, the
tests main's six pull requests change, the LCFS, consumption, Band D,
vendoring and feed tests, the UK graph's binding rules, the nesting,
stage health, battery, contract, gate and coverage tests (2,245 pass;
the vendoring test that rebuilds the vendored resources from a local copy
of the pinned feed refuses this machine's 15040ea5 copy, as it should, and
skips in CI, which has none); the US coverage report and pins (--check);
CI's test plan verify; and on the engine, H2 parity, the UK graph, the
consumption resources and the release input coverage (56 pass).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk added a commit that referenced this pull request Nov 27, 2026
main already holds the same fix (#1772, 0678d1d): _baseline_for
re-raises PostExportBatchFileError before its broad handler, with its own
docstring, release-rule sentence and changelog fragment. The conflicts in
tools/build_us_fiscal_refresh_release.py and docs/us-release-build-rule.md
were wording only, and take main's text. This branch's changelog fragment
repeated main's and is removed. What remains of this branch is
test_the_merged_baseline_pass_raises_a_refused_batch_file_at_once, whose
missing-file case main's tests do not cover.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant