Repository navigation
Conversation
A sample mode for the Route A driver: it draws a household sample of a named base H5 with tools/sample_us_base_households.py, dry-runs the release's checks on it, builds the release on it with --sample-receipt, without staging and under a 28 GiB memory limit, and stops at the build record with ROUTE_A_SAMPLED.json. These tests fail before the change. The existing driver tests now read the release stage's memory limit from a setting, the rerun guard in build and sample mode, and release_ran through a stage_ran that any stage's command can be compared with. run_driver_settings passes the driver's own arguments. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
--sample builds no base. It hashes the base H5 SAMPLE_BASE_H5 names against SAMPLE_BASE_SHA and the release's own inputs, not the base stage's raw inputs; draws whole source households (SAMPLE_FRACTION, default 0.05, with SAMPLE_SEED) with tools/sample_us_base_households.py into <run>/sample/; dry-runs the release's gates on the sample; and builds the release on it with --sample-receipt. It sets ROUTE_A_STAGING=0, refuses ROUTE_A_CERTIFY=1, runs no base preflight, stops any stage above 28 GiB of resident memory and waits for SAMPLE_RAM_GIB (default 8, at most 28) of free memory in place of RELEASE_RAM_GIB. Its stages live in sample-<commit> beside run-<commit>, and it stops at the build record with ROUTE_A_SAMPLED.json, exit 0, or 3 when the build failed its release gates. The commit check needs the sampler with the flags the driver passes and a release parser declaring --sample-receipt; RELEASE_EXTRA_ARGS may not carry --sample-receipt. A rerun keeps an accepted sample only for its sampler command and base sha256 (stage_ran, which release_ran now uses), and an accepted sample build only for its release command and inputs, saying to move the sample run aside rather than --rebuild. The test of the sample stage now reads only its own printed lines, not the driver's log. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When a driver is stopped during the sample stage, its supervisor can finish and record an accepted result that no driver marked accepted. The driver's run_stage accepts such a result, so the sample must be compared with the current sampler command and base sha256 before that, and the record of the base it was drawn from must keep the earlier digest. A fresh draw after a failed attempt moves that attempt's sample directory aside. Both tests fail before the change (review round 1, bug 1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A driver stopped during the sample stage can leave a supervisor that finishes and records an accepted result, which run_stage accepts. The sample stage now compares such a sample with the current sampler command and SAMPLE_BASE_SHA before run_stage, as it does an accepted one, and writes the record of the base digest only when the sampler is launched, so a changed fraction, seed or base is refused instead of building the release on the old sample (review round 1, bug 1). A fresh draw moves an earlier attempt's sample directory aside first. The driver's start-of-run log, the example settings, the runbook and the changelog now say that the sampler, the dry run and the release wait for SAMPLE_RAM_GIB, and the prefetch for at most that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A release-gate dry run that the supervisor of an earlier, stopped driver finished must be kept only for the release settings it checked, so its settings key is recorded as it starts and compared before run_stage can accept its result (review round 2, bug 1). With ROUTE_A_DRY_RUN=0 the sample hand-over record must say no dry run checked the build, not repeat an earlier dry run's result (review round 2, bug 2). These tests fail before the change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The release-gate dry run's settings key is now recorded as the dry run starts, and compared before run_stage can accept a result, whether a driver accepted the dry run or the supervisor of an earlier, stopped driver finished it. A release started after a change of settings is therefore always dry-run on those settings (review round 2, bug 1). This applies to full builds too, which had the same gap before this branch. With ROUTE_A_DRY_RUN=0, ROUTE_A_SAMPLED.json's release_dry_run says no dry run checked the build instead of repeating an earlier dry run's result (review round 2, bug 2). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The record's release_dry_run must describe the build, not the rerun that writes the record: the driver records, as the release starts, whether a dry run checked its settings and what it found, and the sample hand-over reports that record, or "not recorded" for a build released before the driver recorded it (review round 3). These tests fail before the change, apart from the cases that check a release an earlier driver's supervisor finished keeps its record. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The driver now writes <run>/release-dry-run.result as the release
starts: the dry run's acceptance marker, or that none ran with
ROUTE_A_DRY_RUN=0. A release that the supervisor of an earlier, stopped
driver finished keeps that driver's record. ROUTE_A_SAMPLED.json reports
this record ("not recorded" for a build released before it existed), so
a rerun with other dry-run settings no longer changes what the hand-over
says checked the build (review round 3). The changelog now says the
dry-run key change applies to full builds too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes #1861
Do not merge: check the sample mode against 1.9 · 2's
--sample-receiptand any build-ID rule for sample builds once its PR exists (this PR's own step)What this changes
tools/route_a/route_a.sh --samplebuilds the US national release on a household sample of an existing base H5 and stops at the build record. It is tracker task 1.9 · 3 of "15. US build memory, CPU and run time". 1.9 · 4's before-and-after tool runs it on two commits.route_a.env, checked before the run root is made):SAMPLE_BASE_H5andSAMPLE_BASE_SHAare both required: the base H5 to sample and its SHA-256.SAMPLE_FRACTION(default 0.05) andSAMPLE_SEED(default 0) set the draw.SAMPLE_RAM_GIB(default 8, from 1 to 28) is the free memory to wait for. It is a separate setting fromRELEASE_RAM_GIB, because the example settings file sets that to 50 for full builds.ROUTE_A_CERTIFY=1is refused, and--samplewith any other mode is refused.tools/sample_us_base_households.pydeclaring--base,--fraction,--seedand--out, and a release parser that declares--sample-receipt.samplestage in place of the base stage and the base's release-check preflight. It runs the base household sampler without the Hugging Face credential variables, into<run>/sample/;ROUTE_A_DRY_RUN, default 1);--base-h5naming the sample and--sample-receiptnaming its receipt.SAMPLE_RAM_GIBof free memory before starting; the prefetch waits for the smaller of 12 GiB and that.ROUTE_A_STAGINGis set to 0 whatever the settings file says.sample-<commit>beside a full build'srun-<commit>, so the two never share an accepted stage.ROUTE_A_SAMPLED.jsonwhen it starts, and stops after the release with a new one. The record names the sampled base and its SHA-256, the fraction and seed, the sample and its receipt with their SHA-256 values, the build directory and record, whether the build failed its release validation checks, the dry run that checked the build, and the memory settings.SAMPLE_BASE_SHAit was drawn with. This covers a sample a driver accepted and one the supervisor of an earlier, stopped driver finished.--rebuildis a mode of its own.Two changes also apply to full builds:
run_stagecan accept an earlier result. Before this, a dry run that the supervisor of an earlier, stopped driver finished was accepted after the release settings had changed, and was then recorded with the new key.<run>/release-dry-run.resultas the release starts, saying which dry run checked it.release_rannow calls a generalstage_ran.--sample-receiptis refused inRELEASE_EXTRA_ARGS.Docs: a "Sample mode" section, stage rows and limit rows in the Route A runbook; the sample settings in
route_a.env.example; one paragraph indocs/agent-guide.md;changelog.d/1861-route-a-sample-mode.added.md.No build's output changes: this changes the driver that starts builds. No recorded hash or pin moves. No code shared with the UK build changes.
Built on
main(879cef1), not on an earlier task's branch. The driver's tests readroute_a.shonly and need none of 1.9 · 1's or 1.9 · 2's code. The interfaces it assumes were checked as follows:--base,--out,--fractionand--seed; the sample is written as<out>/<name of the --base file>; the receipt is<out>/sample_receipt.json; and--outmay already exist.--sample-receipt <path>has no PR yet. If it requires a-sample-segment in a sample build's ID, this PR will add it to the release ID the driver passes. That check is the "Do not merge" step above.Tests
All added or changed tests are engine-free and in
packages/microcosm-build/tests/engine_free/us/. Each was run selected individually, once on the commit that adds it and once after the change.test_route_a_sample_mode.pycovers:--sample-receipt;test_route_a_driver.py:--sample;release_ranthroughstage_ran;test_a_sample_rerun_with_other_settings_is_refusedandtest_a_dry_run_an_earlier_supervisor_finished_counts_only_for_its_settings.test_support/microcosm_build/route_a_driver.py'srun_driver_settingspasses the driver's arguments.Results on each pair of commits (tests that fail before the change, then the change):
Round 3's reviewer ran all 44 cases at a87e40d under macOS bash 3.2.57: all passed. shellcheck reports nothing on
route_a.shandroute_a.env.example, and ruff check and ruff format report nothing on the changed Python files. No CI has run yet; this PR starts it.Review rounds
Three adversarial review rounds ran, each in a fresh subagent. The review files are in the project's notes folder.
run_stagewithout comparing its command or base digest, and the digest record was overwritten.run_stage, the digest is recorded only when the sampler starts, and a failed attempt's sample directory is moved aside.ROUTE_A_DRY_RUN=0, the record'srelease_dry_runrepeated an earlier dry run's result.release_dry_rundescribed the rerun's settings.Bugs left: none. Code-quality points left, none of which changes a build:
RUN_ROOToverwritesinputs.resolved.json, andROUTE_A_SAMPLED.jsonis one file perRUN_ROOT. 1.9 · 4 runs each commit under its ownRUN_ROOT.ROUTE_A_BUILT.jsonstill reports the dry run from the acceptance marker, as before this branch.run_stage, and three test helpers copied from the driver tests.--resolvedoesn't check the sample settings.What the merge waits for
mergedis enough. The sample mode runs its tool at the build commit, and a microcosm merge deploys and publishes nothing.--sample-receipt, no PR yet):mergedis enough, for the same reason. Its certification refusal of sample builds is what the runbook and record rely on, and it must merge before this PR.Environment variables and secrets
The changed driver reads settings from the operator's local, untracked settings file (
route_a.env, or the fileROUTE_A_ENVnames), sourced by the driver. None comes from a secret store or CI.SAMPLE_BASE_H5,SAMPLE_BASE_SHA,SAMPLE_FRACTION,SAMPLE_SEED,SAMPLE_RAM_GIB(new)route_a.sh; passed to the sampler as arguments and to the supervisor configuration as limitsROUTE_A_STAGING,ROUTE_A_CERTIFY,ROUTE_A_DRY_RUN,RELEASE_RAM_GIB(existing)ROUTE_A_STAGING=0, refusesROUTE_A_CERTIFY=1, honoursROUTE_A_DRY_RUN, and replacesRELEASE_RAM_GIBwithSAMPLE_RAM_GIBHF_TOKEN,HUGGING_FACE_HUB_TOKEN,HUGGINGFACE_HUB_TOKEN,HUGGING_FACE_TOKEN_MAX,SLACK_WEBHOOK_POPULACE_US,SLACK_WEBHOOK_POPULACE_UK/usr/bin/env -ubefore the sampler starts, as for the probe; the release in sample mode runs without the four Hugging Face variables, as withROUTE_A_STAGING=0🤖 Generated with Claude Code