tools/cargo-mutants.sh: one owner of cargo-mutants on Yggdrasil

One verify job per range: a plan container lists the mutants (diff taken at the
workspace root), stage 1 runs each file's mutants against that file's tests only
and decides only caught and unviable, stage 2 confirms every survivor, timeout,
unfiltered or zero-test file on the full suite, sharded over free slot leases,
and the merge prints one MUTANTS line and the final MISSED/TIMEOUT names.
NAMES reruns chosen survivors; TEST_ARGS skips flaky tests.

Deletes ygg-verify.sh's MISSED/TIMEOUT summary grep and its inline cargo mutants
usage example; the host-mode export gains YGG_SLOTS and YGG_ROOT. Briefs and
SKILL.md name the script; the mock docker grows /cm and /out, with a fake cargo
and a fake flock for the new test-tools.sh cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Eureka 2026-11-01 19:15:38 +01:00
commit d4fba11da6
15 changed files with 703 additions and 25 deletions

View file

@ -83,10 +83,12 @@
# YGG_WORK (the clone), YGG_IMAGE, YGG_CPUS, YGG_MEM, YGG_CNAME (job name),
# YGG_LABEL (every container it starts must carry `--label $YGG_LABEL`: the
# watchdog kills containers by that label), YGG_KILLED (a path that exists once
# the watchdog has killed the job: stop starting work) and DOCKER_ARGS. The
# command owns the container topology and must remove what it creates.
# tools/mutation-table.sh is the one user: it snapshots a baselined container
# and runs each mutant in a fresh container from the snapshot.
# the watchdog has killed the job: stop starting work), YGG_SLOTS and YGG_ROOT
# (the slot pool: $YGG_ROOT/slot-<i>.lock for i in 1..$YGG_SLOTS, flock -n) and
# DOCKER_ARGS. The command owns the container topology and must remove what it
# creates. Two users: tools/mutation-table.sh snapshots a baselined container
# and runs each mutant in a fresh container from the snapshot;
# tools/cargo-mutants.sh also leases free slot locks for extra containers.
# DOCKER_ARGS='<extra docker run flags>' passes through to the container's
# own `docker run`, appended after the fixed flags and before the image name
# (e.g. DOCKER_ARGS='--sysctl net.ipv6.conf.all.disable_ipv6=0' or
@ -133,8 +135,8 @@
# dotnet tool install -g dotnet-stryker)
# any other value is used as an image name as-is.
# Example:
# ygg-verify.sh /f/Projects/Huginn HEAD rust \
# 'cargo test --workspace && git diff BASE HEAD > /tmp/d && cargo mutants --in-diff /tmp/d'
# ygg-verify.sh /f/Projects/Huginn HEAD rust 'cargo test --workspace'
# Rust mutation runs use tools/cargo-mutants.sh, never an inline cargo mutants command.
set -euo pipefail
here=$(cd "$(dirname "$0")" && pwd)
@ -186,7 +188,6 @@ ygg_summarize() {
if [ "$untrusted" -gt 0 ]; then
echo "$untrusted YGG-SUMMARY lines without this run's nonce were ignored (a test printed them, or the table printer predates the nonce); see the log"
fi
{ grep -E '^(MISSED|TIMEOUT) |mutants tested' "$log" || true; } | awk 'NR<=20'
if [ "$status" != 0 ]; then
if [ "$nf" -eq 0 ] && [ "$f" -eq 0 ] && [ "$own" -eq 0 ] && [ -z "$loads" ]; then
echo "exit non-zero with no failing test parsed: build error, crash, timeout or a non-test command"
@ -389,7 +390,7 @@ if [ "$host_mode" = 1 ]; then
# Own process group (set -m), started in the job's work directory, so the watchdog can signal all of it.
set -m
( cd "$work" && export YGG_WORK=$work YGG_IMAGE=$image YGG_CPUS=$cpus YGG_MEM=$mem YGG_CNAME=$cname YGG_LABEL=$label \
YGG_KILLED=$killed DOCKER_ARGS=$docker_args
YGG_KILLED=$killed YGG_SLOTS=$slots YGG_ROOT=$root DOCKER_ARGS=$docker_args
[ -z "$nonce" ] || export YGG_NONCE=$nonce
exec bash -o pipefail -c "$cmd" ) </dev/null &
hostpid=$!