Files
sisi/verifiers/concurrency/stress-repeat.md
T
swaitsandClaude Fable 5.2 2fc1fe9c2d
ci / tests (macos-latest, python 3.11) (push) Canceled after 0s
ci / tests (macos-latest, python 3.13) (push) Canceled after 0s
ci / tests (macos-latest, python 3.9) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.11) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.13) (push) Canceled after 0s
ci / tests (ubuntu-latest, python 3.9) (push) Canceled after 0s
sisi 0.1.0: a shared rulebook and verification tool for AI coding agents
Contracts with a ladder of checks, an end-of-turn gate, retrospectives and
shared lessons, time-to-delivery measurement, a library of 140 verification
techniques and 20 recipes, personal data kept outside the clone, and
releases with rollback. Standard library only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 22:29:02 -07:00

2.5 KiB

id, title, answers, rung, section, languages, kinds, cost, detect, ran_here, verified
id title answers rung section languages kinds cost detect ran_here verified
stress-repeat Repeated and randomised-timing runs of concurrent tests Does this concurrent test keep passing when I run it many times under different timing? 3 concurrency any concurrency low no docs

Use when

  • It is the only affordable check, and the code is too big for loom, shuttle or simulation.
  • You are hunting a flaky failure and need to make it reproduce often enough to diagnose.
  • As an extra layer beside a stronger check: run the same test with a race detector, sanitizer or Miri in a loop.

Do not use when

  • You can write an exhaustive or schedule-controlled test. Those find bugs repetition misses.
  • You want to conclude the code is correct. Passing 1,000 runs only shows it did not fail in 1,000 runs.

Set up

No special tooling. Tools that help:

  • Rust: a shell loop around cargo test, and cargo test -- --test-threads=1 versus the default to change contention.
  • Go: go test -count=N -race -cpu=1,2,4,8 -shuffle=on.
  • Any: a shell loop, taskset -c 0 to confine to one CPU, a parallel CPU burner (stress-ng --cpu 8) to perturb timing, and random sleep or yield jitter injected in test hooks.

Minimal example

for i in $(seq 1 200); do
    cargo test --release my_concurrent_test || { echo "FAILED on run $i"; exit 1; }
done

Go: go test -race -count=200 -cpu=1,4 -run TestQueue ./queue.

Run

Use the loop above, with stderr kept so a failing run's output is not lost.

Passing looks like: every run exits 0 and the loop ends silently. Failure is the first non-zero exit with the run number; keep its output.

As a contract check

{"id": "stress-queue", "claim": "queue test passes 200 repeated runs under CPU contention", "kind": "concurrency", "rung": 3, "cmd": "for i in $(seq 1 200); do cargo test --release queue_concurrent || exit 1; done", "expect": {"exit": 0}, "tier": "deep", "timeout_s": 1800}

What a pass does not prove

  • This is a weak check, rung 3. A rare schedule needs luck to occur, and a clean loop says little about it.
  • Timing changes between machines. A bug that needs a particular core count or load may never appear on the test machine.
  • A filtered name that matches no tests passes every iteration with 0 tests run; assert that at least one test executed.
  • Still worth having when: it can reproduce a known flaky failure, it runs alongside a race detector, or you have no better option and say so in the result. Check the check: it should fail when you add a known race and a short sleep.