Skip to content

A US build has no tier: certification chooses it, at the build's commit or a later one (#1585 item 11) - #1681

Merged
juaristi22 merged 7 commits into
mainfrom
us-certify-chooses-tier
Nov 18, 2026
Merged

juaristi22 merged 7 commits into
mainfrom
us-certify-chooses-tier

Conversation

@juaristi22

@juaristi22 juaristi22 commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #1585 (item 11). This follows #1672 and carries out two of María's rulings on its "For review" questions (#1672 comment):

  1. Which commit certification may run at: "allow the same behavior as the uk".
  2. Where the tier is chosen: "a build should just be a build (no tier) and certification should be a choice after it!!"

Rulings 2, 4 and 5 keep #1672 as it is: the skip flags are accepted and recorded, the gate summary is computed once, and a failed build's H5 is kept. It also takes up Max's post-merge review of #1672 (#1672 comment).

Why

The last two Route A national builds took 33.0 and 56.5 hours (their build manifests' timing.total_build_seconds), and #1676 prepares the next one. Under #1672 the tier is chosen when the build starts, so a build launched at the certified tier that fails a gate can only be rebuilt. With the tier chosen at certification, the same build can be certified as evidence once each failure has an owner, from a per-run file or from a new owner committed after the build.

Commits

  • 4af679d: rulings 1 and 3.
  • 10792c1: main merged in after Build a US national release and stop; certify it as a separate step (#1585 item 11, PR 4a) #1672 landed (no change to the tree).
  • a50c72b: Max's point 1, the publisher's staging check. It changes what main's publisher refuses today, so it is a commit of its own. It follows the rulings commit, since putting it first would have needed a rebase.
  • 53afc22: Max's other points.
  • bc4cd7f: keeps the written-file check right after the H5 write and one batched raise in _main, as the stored-input register's source-shape pin requires.
  • c733ceb: keeps the owners register out of the US country package (below), since the US engine contract test pins the US spec's configuration fields.
  • 1ec1338: Vahid's review of this PR (below).

What changes

A build has no tier (tools/build_us_fiscal_refresh_release.py):

The build record is schema 3. It has no release, no evidence_release setting and no owner patterns, the build's own directory is layout.build_dir, and it lists the failures of the written H5's own checks apart (artifact_integrity_failures, below). A record of another schema is still refused with the commit whose code can certify it.

Certification chooses the tier (tools/certify_us_national_build.py <out>):

Certification may run at a later commit, as a UK cut is certified at its sign-off's head (microcosm#1301):

  • It runs at the build's commit, or at a descendant of it whose diff touches only:
    • tests (packages/*/tests/, test_support/, the root conftest.py);
    • docs (docs/, LICENSE, and Markdown outside the packages' sources);
    • changelog fragments (changelog.d/);
    • the standing evidence owners register.
  • Anything else is refused, naming the paths. The packages must still be the ones the build ran on, loaded from the tool's own checkout, where every git check runs.
  • The standing owners moved out of the tool's source into the packaged register packages/microcosm-build/src/microcosm/build/us_runtime/data/evidence_failure_owners.json, with the same two owners (PUF donor uprating overstates mean-reverting distribution series: non_sch_d at 2.39x the SOI concept #487, and QRF amount forests lose donor design weights after the n-of-n bootstrap: extreme-tail draws are a seed lottery #481 with PUF donor uprating overstates mean-reverting distribution series: non_sch_d at 2.39x the SOI concept #487). It is the US sign-off: a commit that only adds an owner there can certify a failed build as evidence without a rebuild. It is runtime data, not a country resource, so a sign-off moves no US spec digest or field count.
  • Both manifests record the certification in an additive certification block beside the build's code, which keeps the build's commit as the release contract reads it. The block holds the tier, the certifying commit (certification.code.git_commit), the paths changed since the build's commit, and the build record's ID and digest. At the evidence tier it also holds the digests of the owner registers, taken from the bytes that decided ownership. The contract does not read the block.

Max's review of #1672:

  1. The publisher checks the build's own staging again (a50c72b). Since Build a US national release and stop; certify it as a separate step (#1585 item 11, PR 4a) #1672 the build manifest's staging block is the certification's, with the build's own under staging.build, and the publisher's check read only the top level. A build whose own uploads never arrived passed once its certification staged or opted out; before Build a US national release and stop; certify it as a separate step (#1585 item 11, PR 4a) #1672 the publisher refused it. _staging_undelivered (microcosm.data.publish_cli) now checks both blocks, and --allow-missing-staging still lifts the check.
  2. Every reference a gate reads refuses a failed build. --incumbent-diagnostics joins the two input-mass references, and the release-gate preflight refuses a failed build's H5 as its --export-input-mass-reference-h5, which Route A passes to both preflights. The rule, the fragments and the docstrings now name what is covered.
  3. What the written H5 fails is recorded on a green build too. A failed stored-input premise or export audit after the write joins the record's failures and is listed apart, so the H5 never stands without a record marking it failed, and no reference takes it. No tier certifies such a build (above), and it exits 1, not 3, so Route A does not keep it for certification.
  • Smaller points:
    • A record that does not read now counts as a failed build's for both the reference refusal and the --out refusal, so its --out can be built into again instead of awaiting a certification that cannot read it.
    • Route A removes ROUTE_A_BUILT.json once a --certify run's certification is accepted, so it never stands beside a certified release.
    • For PR 3: a failed build now reaches us_national_stored_inputs_written before it raises, so the gate battery's shadow records its terminal phase as complete. Before Build a US national release and stop; certify it as a separate step (#1585 item 11, PR 4a) #1672 it recorded that phase as blocked, with one entry unreached.
    • Not done: naming a failed build beside a starting input's digest (--base-h5, --selection-source-h5, --warm-start-calibration-npz) in the manifest, which the review offered as optional.

Vahid's review of this PR (review), in 1ec1338:

  1. The tool's own checkout. Every git check runs with -C at the tool's checkout, whatever the current directory. The build and certification refuse workspace packages that load from another tree, since they all report one version wherever they are installed from.
  2. Owner digests are of the bytes that decided ownership: the standing register's at import, and the per-run file's from the single read that also gives its patterns.
  3. A half-written certification certifies nothing. A build counts as certified once both manifests name it, and the rewrite writes the build manifest last. This holds for certifying once, for the --out refusal and for the evidence exemption, which also needs tier: evidence and a known failure.
  4. A failed build's --out is no reference either, and the probe's --reference-smoke, --reference-validation and --reference-build-manifest refuse a failed build's files too. Its --calibration-diagnostics stays open, since it is the scored build's own fit.
  5. Route A's failed-build branch is run, not matched. A test runs the driver's code from the release stage's acceptance to the certify stage, against a release stage that exited 3 or 0.
  • Smaller points: a standing owner pattern must be one gate's failure prefix (at least two words, then failed:). The build checks for a certified build again just before the H5 write. Route A removes ROUTE_A_BUILT.json once certification is accepted.

Callers:

  • Route A.
    • ROUTE_A_CERTIFY_TIER=certified|evidence chooses the tier for --certify. With evidence, ROUTE_A_EVIDENCE_FAILURE_OWNERS (an absolute path) passes the owners file.
    • With ROUTE_A_CERTIFY=1, the commit check requires the build commit's certification parser to declare the flags the tier passes. check_flags.py --in-function _certify_parser checks that parser alone, since the build parser still declares the dry run's flags of the same names.
    • The release stage accepts exit 3, so a build that failed its gates is kept. A build-only run then ends with ROUTE_A_BUILT.json (release_gates_failed: true) and exit 3. A --certify run at the certified tier refuses such a build before the certify stage starts.
    • The preflights and the hand-off use the release directory of the chosen tier, and the hand-off records the tier, the release and the published build ID.
    • Certifying at a later commit is done by hand from a checkout of that commit; the driver certifies in the build's own worktree.
  • The post-export probe accepts an uncertified build's build/ directory as its reference.
  • The exact-k ladder launcher's receipt adds the build's own directory beside the national release directory certification will place it in.

Docs: the release build rule's "Build, then certify" section (the tier, a later commit, the record, the refusals, a failed release gate, what the written file fails, staging, the drivers), the README's build, dry-run, exact-k and evidence paragraphs, the release contract's note on the evidence release, the Route A runbook and env example, the agent guide, two changelog fragments, and a correction to #1672's.

Compatibility

Tested

  • Engine-free, with no country engine installed (as CI):
    • At 10792c1 (the rulings and the merge of main): the builder's test file, 453 tests, none failing.
    • At bc4cd7f: the 11 files these commits touch most (the builder's, the Route A driver, the probe, the launcher, the shadow, the dry run, the preflight, the publisher's guard, the stored-input register, post-export scoring and release publication), 920 tests, none failing. At 53afc22 the same files failed one source-shape pin in the stored-input register tests, fixed in bc4cd7f.
    • CI's first run failed one US engine contract test, test_us_coverage_is_exact_complete_and_honest, on the US spec's configuration field count (expected 42404, got 42407: the register's resource row), fixed in c733ceb. CI runs the whole engine-free suite on this PR.
    • At 1ec1338 (Vahid's review): the 36 test files that load the release tool, the probe or the Route A driver, 2,655 tests. One, a new test with a wrong telemetry stub, failed; it was fixed in that commit and then passed. The probe's two files ran again after its last change (51 tests), and so did the Route A driver's (113 tests, one skipped because shellcheck is not installed). None fail.
    • Every edited Python file passes ruff check and ruff format; ruff check ., tools/ci_test_plan.py verify and verify-workflow, and the graph acceptance burndown pass.
  • New tests:
    • Build and record. A build ID carries no tier and certification mints the evidence ID; a build refuses the tier flags outside a dry run; the record carries no tier; the standing owners load from the packaged register, whose repository path is the one the rule allows; a failed build exits 3 when run as a command, and prints both certify commands.
    • Certification. It chooses the tier of a failed build: refused at the certified tier, refused at the evidence tier without an owner, and certified there with one, into the evidence release under the evidence ID, the weight evidence left behind. It refuses a register mismatch, owned or not, an exact-k build at the evidence tier, a written H5 that failed its own checks at either tier, and a build already certified at either tier. Placement copies exactly the pinned files, checks each copy, clears an earlier attempt's files and leaves the record as it was.
    • A later commit, on real commits in a repository of its own: the build's commit; a descendant changing only docs, tests, a fragment and the register, whose paths are recorded; a descendant changing code, refused with its paths; a commit that does not descend; and a commit the checkout lacks. The path rule has a case for each class, and Markdown inside a package's source counts as code.
    • End to end, in the builder's harness: a build with one standing-owned failure records it, keeps its H5 and exits with its refusal. Certification refuses it at the certified tier and certifies it at the evidence tier, with the evidence ID, the owned known_failures and the certification block, and the evidence contract's checks pass on what it wrote. The certified green run's manifests carry the certified block. A green run whose written file fails its premise now leaves a record that marks its H5 failed, and no tier certifies it.
    • Max's review: the publisher's staging check over every combination of the certification's and the build's blocks, and a refused publication lifted by --allow-missing-staging; the incumbent diagnostics and the preflight's export reference refuse a failed build; an unreadable record counts as a failed build's for both checks.
    • Route A: the tier settings and their refusals, the certify stage's argv for each tier, the release stage's acceptance of exit 3 and what a build-only or certify run does with a failed build, the narrowed flag check, and the removal of ROUTE_A_BUILT.json after certification.
    • The probe reads an uncertified build's build/ directory, and accepts a failed build's evidence release once it is certified.
    • Vahid's review: the git checks run in the tool's checkout from an unrelated repository's directory; both commands refuse another tree's packages before any work; the owner digests are of the bytes read; a manifest pair a crash left part-written, at each step of the rewrite, certifies nothing; the probe refuses the failed --out itself and each explicit reference flag, and takes the failed build's own calibration diagnostics; a standing pattern without a gate's prefix is refused; and the Route A branch for a failed build is run for each tier and mode.
  • Source-shape pins now hold the tier at certification: no branch of _main tests --evidence-release, no owner is resolved there, the record has no tier, and every release-gate raise in certification sits under the certified tier. The CG tail transfer: field-local donor quarantine + mass-conserving own-tail stratum + E01000 receipt (#567) #568 weight-evidence pin follows the build's refusal, the register-mismatch pin follows certification's check, and US gates in us/gates.json, run in shadow beside today's gates (#1585 item 11, PR 2 of 4) #1635's pin on the shadow's release follows the new reuse refusal.
  • Not run here: the whole engine-free suite, which CI runs on this PR, any build, and the engine test jobs.

For review

Order

🤖 Generated with Claude Code

juaristi22 and others added 4 commits November 18, 2026 18:14
… one (#1585)

María's rulings 1 and 3 on #1672's review questions (microcosm#1585 item 11).

Ruling 3, a build has no tier:
- The release tool records every release-gate failure and writes its H5 and
  record, as a certified-tier build did. Its own files go to <out>/build/,
  and a build whose gates failed exits 3 once its record is written.
  --evidence-release and --evidence-failure-owners only preview a dry run.
- Its ID never carries -evidence-. The record is schema 3, with no release,
  no evidence_release setting and no owner patterns.
- tools/certify_us_national_build.py chooses the tier. Certified, the
  default, places the build in the national release and refuses any failure
  and the #568 weight evidence. --evidence-release places it in the evidence
  release under its ID with an -evidence- segment, once every failure has an
  owner; it refuses a QRF register mismatch and an exact-k build.
- Certification copies the record's pinned files into that release's
  directory, checking each copy, and never edits the record. A build is
  certified once, at either tier.

Ruling 1, certify at a later commit, as the UK allows:
- Certification may run at a descendant of the build's commit whose diff
  touches only tests, docs, changelog fragments and the standing owners
  register. Anything else is refused, naming the paths.
- The standing owners moved from the tool into the packaged
  us/evidence_failure_owners.json, the US sign-off.
- Both manifests record the certifying commit in an additive certification
  block beside the build's code.

Route A gains ROUTE_A_CERTIFY_TIER and ROUTE_A_EVIDENCE_FAILURE_OWNERS, and
its release stage keeps a build that failed its gates (exit 3);
check_flags.py --in-function checks the certification parser. The probe and
the exact-k launcher follow the build's directory. Docs and a changelog
fragment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main is #1672's merge, tree-identical to this branch's base (95279a4).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Max's first point on #1672 (issuecomment-6986570734). Since build and
certification are two steps, a US national build manifest's staging block
is certification's, with the build's own under staging.build. The
publisher's staging check read only the top-level block, so a build whose
own uploads never arrived passed once its certification staged or opted
out; before #1672 the publisher refused it. The check now reads both
blocks. --allow-missing-staging still lifts it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fails (#1585)

Max's other points on #1672 (issuecomment-6986570734):

- A failed build's files are no --incumbent-diagnostics, and the
  release-gate preflight refuses them as its export input-mass reference, so
  "no gate judges against it" holds for every reference a gate reads.
- What the written H5 fails in its own checks (the stored-input premise, the
  export audit) is recorded on a green build too, so its H5 never stands
  without a record marking it failed. The record lists these apart as
  artifact_integrity_failures, and no tier certifies them: the evidence tier
  relaxes gate verdicts, never the written artifact's. Such a build exits 1,
  so Route A does not keep it for certification.
- A record that does not read counts as a failed build's for both the
  reference refusal and the --out refusal, instead of leaving that --out
  stuck awaiting a certification that cannot read it.
- Route A removes ROUTE_A_BUILT.json once --certify writes its hand-off.
- #1672's changelog fragment no longer says a failed build cannot be
  certified at all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
juaristi22 and others added 2 commits November 18, 2026 18:38
The stored-input pin (test_us_stored_input_register) holds the written
file's check right after the H5 write and one batched raise in _main. The
integrity list now starts before the write, the refusal after the record
tests the build's refusal and that list instead of terminal_gate_failures,
and the pin expects the premise failure recorded, not raised, on a green
build too (review of #1672).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
As a declared US country resource, evidence_failure_owners.json added its
resource row's three fields to the US spec's configuration field ledger,
which test_us_coverage_is_exact_complete_and_honest pins (expected 42404,
got 42407), and it moved the spec's digest. No part of the spec reads the
register, and a sign-off should move neither, so it is a packaged US runtime
data file instead, beside the other runtime data in us_runtime/data/, and
country_package.json is main's again. A test holds it out of the country
package.

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

@vahid-ahmadi vahid-ahmadi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, María. This reads well. The tier now sits at certification, the later-commit rule is narrow, and the order of the refusals matches the body. Nothing here blocks. Most of these points are low. Two of them are gaps #1672 already had, which the later-commit rule now leans on.

1. Certification checks the repository it is run from, not the one its code came from (low–medium, already in #1672).

  • Where: _certifying_commit (tools/build_us_fiscal_refresh_release.py:14312), _git_dirty_paths (:3574) and the helper at :3567 run git in the current directory.
  • Why versions don't catch it: the package version check can't tell checkouts apart, because the workspace packages all report the same version.
  • The gap: running a later checkout's tool from the build's own worktree, or from a venv installed from another tree, certifies with code the rule never classified. certification.code.git_commit then records the build's commit rather than the code that ran. A reproduction imported the tool from an unrelated clean repository, and the commit and dirty checks passed against that repository.
  • Suggestion: run git with -C set to the tool's own repository root, and assert that microcosm.*.__file__ resolve under it. "The packages must still be the ones the build ran on" then holds without relying on the cwd. The later-commit test uses monkeypatch.chdir, so it assumes the same thing.

2. The owner files' digests are taken when the manifest is written, not when the owners are read (low).

  • Where: manifest_block hashes the standing register (:14441) and the per-run --evidence-failure-owners file (:14443-14444) at the end of certification. The ownership decision used the bytes read before scoring, and for the standing patterns that is at import.
  • The gap: git doesn't track the per-run file, and the dirty check runs only once, before scoring. An edit during a long certification therefore records a digest for a file that didn't decide ownership. A reproduction recorded one digest while ownership was decided by a file with another.
  • Suggestion: hash the bytes when they are loaded.

3. A half-written certification counts as certified (low, already in #1672, wider here).

  • Where: release_manifest.json and the rewrite of both manifests use plain write_text, with telemetry.complete() after them.
  • The gap: a crash in that window leaves a manifest that blocks certifying again and blocks building into that --out.
  • New in this PR: in the evidence release, the same partial manifest also makes _build_certified_as_evidence exempt the failed build from the reference refusals. An empty evidence release_manifest.json was enough in the test fixture.
  • Suggestion: write to a temporary file and rename it, or count a build as certified only once the contract has passed on what was written.

4. --reference-release-dir <failed --out> is not refused (low).

  • Where: _failed_build_holding (:2780) walks target.parents, which leaves out the path itself.
  • What is refused: the H5 in artifacts/, build/, releases/<release> and symlinked paths.
  • Impact: small. The probe then finds no reference files and runs without a reference.
  • Fix: walk (target, *target.parents). Relatedly, the probe's explicit --reference-smoke, --reference-validation and --reference-build-manifest flags aren't checked. A failed uncertified build has none of those files, so that part is mostly theoretical.

5. Route A's failed-build branch is pinned only by matching strings in the script (low).

  • The gap: setting BUILD_FAILED_GATES never (tools/route_a/route_a.sh:836) still passes all 112 driver tests.
  • What breaks: a build-only run of a failed build would then write release_gates_failed: false and exit 0. A certified-tier --certify run would skip the early refusal at :897.
  • Suggestion: a test that runs the script against a stub release stage that exits 3.

Smaller points:

  • The register loader refuses only empty patterns and owners without an issue reference. A register-only commit can now certify, and a one-character pattern there would own every ownable failure. Is a minimum pattern shape, or a check that each pattern matches a known gate, worth adding?
  • A rebuild into a failed --out: whether the --out holds a certified build is checked when a build starts (:15229, :15557), not again before the H5 write. A rebuild started before the old build was evidence-certified could later overwrite the H5 and the record that the certified manifest pins. This is a cost of keeping a failed build's --out buildable (For review, item 1). The publisher's digest checks should catch it, but refusing again before the write would close it. I didn't reproduce this one.
  • A stale ROUTE_A_BUILT.json: if certification succeeds but a later preflight fails, the run stops before route_a.sh:948 and leaves ROUTE_A_BUILT.json (certified: false) beside a certified release. The README's "replaces" holds only for a run that succeeds.

On the For-review questions:

  • I'd lean towards refusing a rerun into a failed build's --out once it can be evidence-certified (item 1); the smaller point on rebuilds above is the reason.
  • Keeping the dry run's --evidence-release preview seems fine.

Also checked, with no issues found:

  • The later-commit classifier. It handled tests' conftest.py, test_support/, Markdown inside and outside package sources, .MD, docs/*.py, pyproject/uv.lock correctly. On real commits it refuses a rename from src to docs (named by its source path), a mode-only change and a symlink swap.
  • The order of checks: schema, then digest, then pinned files; written-H5 failures at both tiers; then exact-k, the register mismatch (no owner can claim it), unowned failures; then the dirty, commit and version checks; then certify-once.
  • The certified tier still refuses everything #1672 refused.
  • Placement: fixed names, no traversal, each copy checked against its digest, the weight evidence never copied, the record untouched.
  • Exit 3 comes only from a release-gate failure after the record is written, and the written-H5 failure exits 1. Route A accepts 3 from the release stage only.
  • The publisher's staging check is right over every combination of the certification's and the build's blocks, and --allow-missing-staging still lifts it.
  • One failed-build helper serves all three reference callers. An unreadable record counts as failed, and an evidence-certified build passes.
  • Route A's tier settings refuse bad values and relative paths with exit 64.
  • Tests at bc4cd7f: the builder, register and shadow tests (497, none failing) and the Route A, probe, preflight, launcher and publisher tests (284 passed, 2 skipped).

CI: at bc4cd7f both engine-us jobs failed on the spec-engine field count (42404 against 42407) because of the register's new row in country_package.json. c733ceb moves the register to us_runtime/data/, and CI on it was still running at the time of writing.

Review drafted with AI assistance and checked against the code at c733ceb.

- Every git check (commit, merge-base, the diff since the build, dirty
  paths) runs with -C at the tool's own checkout, whatever the current
  directory; the build and certification refuse workspace packages that
  load from another tree, since they all report one version.
- The owner digests are of the bytes that decided ownership: the standing
  register's at import, the per-run file's from its one read.
- A certification counts only once both manifests name the build (the
  build-folder rewrite writes the build manifest last), for certifying
  once, the --out refusal and the evidence exemption, which also needs
  tier "evidence" and a known failure.
- _failed_build_holding walks the path itself too, and the probe refuses a
  failed build's file as --reference-smoke, --reference-validation and
  --reference-build-manifest; --calibration-diagnostics, the scored build's
  own fit, stays open.
- A standing owner pattern must be one gate's failure prefix (two or more
  words, then " failed:"); the build checks for a certified build again
  just before the H5 write; Route A removes ROUTE_A_BUILT.json once
  certification is accepted.
- Route A's failed-build branch is run by a test against a release stage
  that exited 3 or 0, with the driver's own log, fail and sha_of.

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

Copy link
Copy Markdown
Collaborator Author

Thanks, Vahid. All of these are fixed in 1ec1338:

  1. Checkout. Every git check now runs with -C set to the tool's own checkout (_repository_root()), whatever the current directory. The build and certification both refuse a workspace package (microcosm.build, .calibrate, .data, .diagnostics, .fit, .frame, .graph) that loads from outside that checkout. The real-git tests now set _repository_root instead of relying on chdir, and a new test runs the checks from an unrelated repository.
  2. Owner digests. Each digest is now of the bytes that decided ownership. The standing register is hashed at import, and the per-run file is read once for both its patterns and its digest.
  3. Half-written certification. A build now counts as certified only once both manifests name it. The build-folder rewrite writes the release manifest first and the build manifest last. A certification that stopped before that point, torn writes included, therefore certifies nothing: it can be certified again or built into, and the rerun clears both manifests. The evidence exemption also needs tier: evidence and at least one known failure. I left the writes as they are, since the rewrite is shared with the UK in microcosm-data. One window remains: a crash after the rewrite, during the staging telemetry's last steps, leaves a certified directory with every file written. Only the staging run's completion is lost.
  4. References. _failed_build_holding now walks (target, *target.parents). The probe also checks --reference-smoke, --reference-validation and --reference-build-manifest. The test covers the --out itself and each of those flags. --calibration-diagnostics stays open: it's the scored build's own fit, which a failed build's export needs.
  5. Route A. A new test runs the driver's own code, from the release stage's acceptance to the certify stage, against a release stage that exited 3 or 0. It covers four cases: a build-only run of a failed build (exit 3, release_gates_failed: true); a green one (exit 0, or 4 when the base preflight blocked); the refusal at the certified tier before the certify stage; and the evidence tier going on to it. Never setting BUILD_FAILED_GATES now fails it.

Smaller points:

  • Register patterns. Each standing pattern must now be one gate's failure prefix: at least two words, then failed:. Both current entries pass. I didn't add a check against known gates. Per-run files keep the earlier rule, since they're given at certification and recorded by digest.
  • Rebuild into a failed --out. The build now checks again for a certified build just before it writes the H5.
  • Stale ROUTE_A_BUILT.json. The driver now removes it as soon as certification is accepted, before the release preflights, and the README says so.

docs/us-release-build-rule.md and the changelog fragment cover the new rules.

@vahid-ahmadi vahid-ahmadi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, María. Everything I raised is addressed at 1ec1338. I checked each fix against the code:

  1. Checkout.
    • _git_output, _git_commit_exists and every call in _certifying_commit now pass -C with _repository_root() (the tool's own tree).
    • _refuse_packages_from_another_checkout refuses any of the seven workspace packages whose find_spec origin is not under that root. Both certification and a real build run it; a dry run doesn't.
  2. Owner digests. The standing register is read once as bytes at import, and its digest comes from those bytes (US_EVIDENCE_FAILURE_OWNERS_SHA256). The per-run file is likewise read once for its patterns and its digest (_read_evidence_failure_owners_file). manifest_block no longer reads either file again.
  3. Half-written certification.
    • _finished_release_manifest counts a directory as certified only when both manifests carry the build-folder shape: a string release equal to the directory name, and the same string build in both.
    • Before the rewrite, build is still the tagged object and there is no release, so the check does tell finished from unfinished.
    • Placement now clears a partial release_manifest.json. The evidence exemption also needs tier: evidence and at least one known failure.
    • One small window is left: rewrite_release_dir refreshes the checksum ledger after both manifests. A crash between those writes would leave a "finished" directory with a stale ledger, but the publisher's checksum check should refuse it. That seems fine to leave.
  4. References. _failed_build_holding walks (target, *target.parents). The probe checks all four reference flags, and keeping --calibration-diagnostics open is the right call.
  5. Route A.
    • ROUTE_A_BUILT.json is removed as soon as certification is accepted, before the preflights.
    • The register now requires a " failed:" prefix.
    • The certified-build check runs again just before the H5 write.

The builder, Route A driver, probe, preflight and publisher-guard tests pass locally at this head, with none failing. engine-us and engine-free were still running at the time of writing.

Nothing further from me.

Review drafted with AI assistance and checked against the code at 1ec1338.

@juaristi22
juaristi22 marked this pull request as ready for review November 18, 2026 22:04
@juaristi22
juaristi22 merged commit cfd5a2a into main Nov 18, 2026
12 checks passed
juaristi22 added a commit that referenced this pull request Nov 19, 2026
…o the engine refresh

main brings #1681 (rulings 1 and 3 on #1672: a build has no tier and
certification chooses it; certification may run at a descendant of the
build's commit that changes only tests, docs, changelog fragments and the
standing evidence owners register) and #1677 (the Modal base hand-off copies
the gate shadow directory). No textual conflicts.

Checked where the two sides meet in tools/build_us_fiscal_refresh_release.py:
the release still writes the base's household-location attributes after the
written-H5 stored-input check and before the build record binds the H5's
sha256, and certification still reads them back from the written H5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
juaristi22 added a commit that referenced this pull request Nov 19, 2026
… the runbook

Certification takes about two days, so the runbook now runs the build, then
probes it on a 5% household sample with tools/sample_us_export_households.py
and tools/probe_us_post_export.py (about 10 hours on the published export),
then waits for María's assessment. The operator certifies only when she
asks, at the tier she names.

- Step 5 runs certification's post-export checks on the sample. It leaves out
  the probe's QRF tail stage, which grades at final weights while the build
  decides that gate at base weights; certification does not run it.
- Step 6 lists what she reads (the build's verdicts, its fit, the gate
  shadow, the probe's failures) and the three answers: certify, build again,
  or certify as evidence.
- Section 7 describes #1681 as merged: the build refuses --evidence-release,
  and a later commit certifies only when it changes tests, docs, changelog
  fragments or the standing owners register, so a code fix needs a new build.
- S6 stops on a probe failure; S3 names the gate shadow's directory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
juaristi22 added a commit that referenced this pull request Nov 19, 2026
After the merge of main, the release stage accepts exit 3 too (a build that
failed its release gates, kept for an evidence certification), so its
run_stage line names "0 $BUILT_FAILED_GATES_RC". The pin follows it; the
order it checks (the release config, then the stop, then the run) is the
same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MaxGhenis added a commit that referenced this pull request Nov 19, 2026
Brings #1672, #1677 and #1681. None of them touches a file this branch changes.

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

Copy link
Copy Markdown
Contributor

Lines refer to cfd5a2a5e. The fixes from the #1672 review hold: the publisher again refuses a build whose own staging never arrived, the named references refuse a failed build, and the record keeps what the written file fails. No us_national shadow site moved. A later commit can change a certification only through the owners register, at the evidence tier. We read the code and ran nothing.

Four points:

  1. The rule says the certified tier refuses a source-coverage failure it finds (docs/us-release-build-rule.md:86-88). Certification records that gate's failures only at the evidence tier (tools/build_us_fiscal_refresh_release.py:19592-19607). At the certified tier it writes both manifests, and the publisher's contract refuses the build later. _refuse_reusing_a_certified_build then refuses an evidence certification of the same build (:14741). A build that fails source coverage alone ends finished, unpublishable and unable to change tier. Could the certified tier refuse a failed source-coverage gate before it writes the manifests, as it refuses a failed smoke (:19454-19455)?

  2. "No gate judges against it" (:2802-2803, docs/us-release-build-rule.md:185-186) still claims more than the code does. With no export reference, the export input-mass gate judges against the base frame (:8666, :18930-18934), and a failed build's H5 may serve as --base-h5 (:2787-2789). Route A refuses --base-h5 in RELEASE_EXTRA_ARGS (tools/route_a/route_a.sh:401), so only a hand-run build reaches it.

  3. A build that passed its release gates and then failed certification counts as a good build to the reference checks. _failed_build_holding reads the build's recorded failures and the CG tail transfer: field-local donor quarantine + mass-conserving own-tail stratum + E01000 receipt (#567) #568 evidence (:2832-2856), so a build whose certified-tier smoke failed still serves as an input-mass reference and as the probe's reference directory.

  4. A raise between the H5 write and the record write still leaves an H5 with no record, and every reference check accepts that file. A full disk at the NPZ write or the base copy would do it (:19183-19189).

Smaller points:

  • The standing register's pattern rule asks for two words and failed: (:12263-12277). input signal failed: passes it and matches every gate whose prefix ends in those words.
  • check_commit checks the certification parser only when the driver passes certify flags (route_a.sh:332-339), and it passes none at the certified tier with staging on (:158-162).
  • The release stage accepts a build that finished with failed gates (route_a.sh:816), so a rerun at the same commit keeps that build.
  • The summaries of the allowed paths (docs/agent-guide.md:478-479, tools/certify_us_national_build.py:28-29) leave out LICENSE, the root conftest.py and Markdown outside package sources (:14420-14427).
  • No test covers a version-2 staging block in the publisher's new check.

juaristi22 added a commit that referenced this pull request Nov 19, 2026
Max's review of #1681 at cfd5a2a, its four points and two of its smaller
ones (the Route A points follow with the driver):

1. The certified tier refuses a failed source-coverage gate before it writes
   either manifest, as it refuses a failed smoke, so the build can still be
   certified as evidence.
2. A failed build's H5 is a --base-h5 only beside an
   --export-input-mass-reference-h5: without one, the export input-mass gate
   judges the export against its base.
3. Certification adds every gate failure it finds to
   certification_failures.json beside the build record, at either tier, and
   a build that passed its own gates and then failed certification's is no
   reference until a certification ships it.
4. The build writes build_incomplete.json before its H5 and removes it once
   its record is written, so an H5 that no record pins is no reference.

A standing evidence owner pattern owns a failure line only from its start,
so "input signal failed:" no longer owns every gate ending in those words.
The allowed-path summaries now name the root conftest.py, LICENSE and
Markdown outside package sources, and a publisher test covers version 2
staging blocks in a separately certified build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
juaristi22 added a commit that referenced this pull request Nov 19, 2026
The build is one command: route_a.sh dry-runs the release's gates on the
fresh base as a stage of its own before the release starts
(ROUTE_A_DRY_RUN=1, the default). Exit 0 or 2 lets the release start; 1, a
certain failure, stops the run in minutes. A dry run holds for the release
settings it checked, by a digest of the release command without its build
ID, so a restart with other settings dry-runs them again.

--probe probes an accepted build on a 5% household sample with
certification's own post-export checks, as two supervised stages under the
run directory, and stops; a failed build gets its fit and target surface
from its record, since it is no reference. --certify stays a step of its own.

From Max's review of #1681:

- check_commit checks the certification tool and parser on every run,
  whatever the tier, and check_flags.py refuses a source without the named
  parser even when no flag is passed.
- A rerun to build refuses release settings other than the accepted build's,
  which it would otherwise keep without a word, and --rebuild sets the
  accepted build and its probe aside, keeping them on disk, to build the
  release again on the same base. It refuses a certified build.

The runbook has one command per step (resolve, build, probe, certify) and
one command that collects a run's logs and records, without its data files,
to send for diagnosis; the README and the settings example follow.

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.

3 participants