Repository navigation
ci: fail when an expected test count of the contract suite's passes is stale - #181
Merged
Merged
Conversation
…s stale `scripts/contract.sh` and `scripts/stage2-contract.sh` each exit 5 when the number of tests that passed is not the number they expect, but only when they are run. Most of contract.sh's passes run in CI cells; `blast`, `budget` and `engine` run in none (contract-all.sh has nine passes and not those, and only mutants.sh runs the last two, against broken builds); and stage2-contract.sh needs a deployed Worker. Its `main` count was 59 until 2026-11-14 while the suite had listed 61 since #151, and #169's three tests made it 64 the same day. Nothing noticed. `scripts/check-contract-counts.sh` reads every arm of both scripts (13 in stage2, 10 in contract.sh), runs the arm's own filters through libtest (`cargo test -p thrust-contract-tests --test <bin> -- --list --format terse <filters>`, which needs no server and no environment), counts the lines that end in `: test`, and compares. It copies no filter, so a filter cannot drift from its count. It fails closed with exit 2 on an arm it cannot read, a different number of arms read than written, no arm at all, a count that is not a number, an `EXPECT_` variable with no value or two, a listing that fails, and a filter that selects nothing (libtest prints nothing and exits 0 for that). The self-test (a step of `deps`, no compile) runs it on 16 worlds with a fake lister, each read to be refused for the reason it names: a count one too high and one too low, a filter that selects nothing, a failing listing, a script with nothing to read, an arm with no count, a variable with none and with two, the default arm of contract.sh read as `main`, one pass asked for alone. The real run (a step of `hermetic`, after the suite is built) ends with a control on the real stage2-contract.sh with its `main` count made wrong, which must be refused. Shown on the real suite: all 23 arms agree today (stage2 `main` 64, contract `main` 70, `bindings` 3 and 5), and renaming one test out of `sweeper_` makes four arms fail with exit 1 (stage2 `main` 65 for 64 and `sweeper` 2 for 3, contract `main` 71 for 70 and `sweeper` 2 for 3). The file was restored and compared. The self-test passes under dash on this Mac, under the Mac's sh, and in an ubuntu:24.04 container (dash with GNU sed and grep). The prose that had rotted in stage2-contract.sh is fixed with it: its usage line named 6 of its 13 passes, its header said `bindings` runs 5 tests where it runs 3, and `crontrigger`, `blast` and `ratelimit` had no entry. evidence-and-controls.md and contract-suite.md now say what enforces the rule they state, and status.md no longer says the count "has not been kept up". Not run here: the new `hermetic` step on a runner. `cargo test -p thrust-contract-tests` unifies features differently from `--workspace`, so it may rebuild some dependencies there; the job's timeout is 30 minutes. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
aRustyDev
added a commit
that referenced
this pull request
Nov 15, 2026
… into the OpenAPI Projects branch #179 conflicted with main a third time, once the three small PRs it was opened with had merged. One conflict, `docs/src/testing/status.md`, and it is one hunk because G-25 and G-26 are adjacent rows: this branch changed G-25 only (the schema diff), #180 changed G-26 only (`THRUST_RL_CREATE_ID`). Checked by hash against the merge base (G-25 4337a2f968e5 on main and the base, 55eb907971f4 here; G-26 bb75219068af on the base and here, 104945eb6fb9 on main), so the resolution is this branch's G-25 row and main's G-26 row, and each now has exactly those hashes. `.github/workflows/ci.yml` merged without a conflict: `deps` has the count guard's self-test, the release step and the OpenAPI step; `hermetic` has the count check and the OpenAPI tests; `lint` has the OpenAPI clippy. #182's D-19 row and #181's sentence in G-33 are in `status.md`, no conflict marker is left anywhere in the tree, and `cargo metadata --locked` resolves. Refs: #58 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
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.
Part of #58; this PR does not close it.
The expected test counts of the contract suite's passes went stale twice in one day (2026-11-14: stage2's
mainsaid 59 while the suite listed 61, then 64), because a count is checked only when its script runs, andscripts/stage2-contract.shneeds a deployed Worker. This makes CI check them.What it does
scripts/check-contract-counts.shreads every arm ofscripts/stage2-contract.sh(13) andscripts/contract.sh(10 on this branch, 11 onmainsince #176 addedmail), runs the arm's own filters through libtest (cargo test -p thrust-contract-tests --test <bin> -- --list --format terse <filters>; no server, no environment), counts the lines that end in: test, and compares with the arm's count. It copies no filter, so a filter cannot drift from its count.hermeticjob: the real check, right after the suite is built by the nextest step, then a control: the realstage2-contract.shwith itsmaincount made wrong must be refused.depsjob:--self-test, no compile: 16 worlds with a fake lister, each read to be refused for the reason it names.gate's required contexts do not change.It also covers three counts that no CI cell checks today:
blast,budgetandengine(contract-all.shruns nine passes and not those;mutants.shruns the last two against broken builds only).It fails closed
Exit 1 is a count that differs. Exit 2, "cannot vouch", is: an arm it cannot read; a different number of arms read than written (the check that a reformatted script cannot make it read nothing and pass); no arm at all; a count that is not a number; an
EXPECT_variable with no value or two; a listing that fails; and a filter that selects nothing (libtest prints nothing and exits 0 for that, which is not a count of anything).Checked
main64, contractmain70,bindings3 and 5).main, which by then had feat(email): an SMTP adapter, and the native server sends the reset mail when it has a relay #176'smailpass): thehermeticstep read 13 stage2 arms and 11 contract arms and passed in 33 seconds (the first listing took 26 of them, the other 23 together 6), so whatevercargo test -phad to compile again cost under half a minute against the job's 30-minute timeout. The eleventh arm iscontract mail: 3 tests, which did not exist when I wrote the guard and was counted with no change to it (the arms are read from the scripts, and a count of arms read that differs from the count of arms written is exit 2). The control, a stage2 count made wrong, was refused.sweeper_filter makes four arms fail with exit 1, naming the script (stage2main65 for 64,sweeper2 for 3; contractmain71 for 70,sweeper2 for 3). The file was restored and compared byte for byte./bin/dash, under this Mac'ssh, and in anubuntu:24.04container (dash with GNUsedandgrep, as on the runner). The self-test's verbose mode (CHECK_VERBOSE=1) prints what each case said; I read them all.stage2-contract.shis fixed: its usage line named 6 of its 13 passes, its header saidbindingsruns 5 tests (it runs 3), andcrontrigger,blastandratelimithad no entry.evidence-and-controls.md,contract-suite.mdand G-33's mention of the stale 59 now say what enforces the rule.Not run here
Stage2's count of 64 has still never been run against a deployed Worker: this checks it against the suite, not against a Worker.
🤖 Generated with Claude Code