Item 8: recipes and a repeat-under-parallel-load verifier entry. done 8 / next none

This commit is contained in:
swaits committed 2026-11-23 12:31:57 -07:00
1 parent d63b0f9c49
commit 89f606001a
4 files changed
+85

No files matched your search

+3
View File
@@ -11,6 +11,8 @@ applies_to: A new capability in a product that already exists and already has us
- Each requirement has an acceptance check, and the checks for the core logic are strong (property, differential or fuzz checks where the input space is broad).
- Empty, large, invalid and repeated use of the new capability behave sensibly, and existing data, settings and workflows still work with it.
- The capability is discoverable and usable in the product's own terms (labels, help, errors), with loading, empty and error states where it has a surface.
- The first usable increment is named, the work is ordered to reach it early, and every status update gives its estimated time, labelled as an estimate.
- Where the design depends on a heuristic, classifier or matcher being right most of the time, a throwaway version was first scored on labels a different worker wrote, and the measured ceiling and what stands behind the heuristic are in the design.
## Checks
- Requirements: `requirement-to-check-map` (completeness), `acceptance-examples` (intent), rung 3; every requirement maps to a check or a recorded deferral.
@@ -18,6 +20,7 @@ applies_to: A new capability in a product that already exists and already has us
- Nothing else broke: `baseline-before-change`, `characterization-tests` (regression), rung 3; invariants from before the first edit.
- Real surface: `e2e-playwright` (real-world) for a web capability, `cli-transcript-tests` for a command, rung 3.
- Hostile and odd input: `hostile-input-from-schema` (many-inputs), rung 2, for any new parser, import or boundary.
- Tests are stable: `repeat-under-parallel-load` (test-quality), rung 3, for each new test module.
- Finished cleanly: `no-stubs-scan`, `single-gate-command` (completeness), rung 3.
## Common false finishes
+3
View File
@@ -12,11 +12,14 @@ applies_to: Turning a one-line or short description (an app, a service, a tool)
- It is safe: dependencies audited, secrets handled, trust boundaries modelled, data stored survives crashes and upgrades.
- One command defines done; documentation says how to run and verify it; a release path exists.
- The owner walked it and accepted it, and what was assumed is reported.
- The first usable increment is named, the work is ordered to reach it early, and every status update gives its estimated time, labelled as an estimate.
- Where the design depends on a heuristic, classifier or matcher being right most of the time, a throwaway version was first scored on labels a different worker wrote, and the measured ceiling and what stands behind the heuristic are in the design.
## Checks
- What to build: `acceptance-examples`, `requirement-to-check-map` (completeness), `spec-traceability`; design: `tlaplus` or `quint` for state machines (design).
- Logic: `lean4-proofs`, `kani` or `proptest` (prove, many-inputs), rung 1 to 2; `stateful-model-test`, `differential-reference`, `round-trip`.
- Tests are real: `cargo-mutants` or the language's mutation tool, `vacuity-check`, `assertion-strength-review` (test-quality).
- Tests are stable: `repeat-under-parallel-load` (test-quality), rung 3.
- Real world: `e2e-playwright` or `cli-transcript-tests`, `clean-clone-build`, `packaging-install-upgrade`, `cross-platform-matrix`.
- Safety: `rust-lints-strict`, `dependency-audit-rust`, `secret-scanning`, `threat-model-checklist`, `licence-notices`.
- Done: `single-gate-command`, `no-stubs-scan`, `check-tiering`, `release-gate`; the human: `owner-acceptance-runbook` (intent), rung 6.
+33
View File
@@ -301,6 +301,39 @@ class LintCrossCheckTests(LibCase):
self.assertIn("warning(s)", r.stdout)
class RepeatUnderLoadTests(SisiCase):
"""R-5.6-1: the library has an entry for repeating a test under parallel load, its command works with the
standard library alone, and the two recipes say what this rebuild learned."""
def test_the_entry_is_in_the_library_and_its_command_separates_stable_from_order_dependent_tests(self):
import subprocess
r = self.sisi("verifiers", "show", "repeat-under-parallel-load")
self.assertEqual(r.returncode, 0, r.stdout + r.stderr)
self.assertIn("xargs -P 8", r.stdout)
d = os.path.join(self.tmp, "rp")
os.makedirs(d)
with open(os.path.join(d, "test_mod.py"), "w") as f:
f.write("import os, time, unittest\n"
"class Stable(unittest.TestCase):\n def test_ok(self):\n self.assertEqual(1 + 1, 2)\n"
"class Shared(unittest.TestCase):\n def test_shared_path(self):\n"
" p = os.path.join(os.path.dirname(__file__), 'shared.txt')\n"
" open(p, 'w').write(str(os.getpid())); time.sleep(0.05)\n"
" self.assertEqual(open(p).read(), str(os.getpid()))\n")
cmd = "seq 30 | xargs -P 8 -I{} python3 -m unittest -q test_mod.%s"
run = lambda name: subprocess.run(cmd % name, shell=True, cwd=d, capture_output=True).returncode
self.assertEqual(run("Stable"), 0)
self.assertNotEqual(run("Shared"), 0)
def test_the_recipes_name_the_first_increment_and_the_scored_heuristic(self):
root = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
for name in ("feature", "new-product"):
text = open(os.path.join(root, "done", name + ".md"), encoding="utf-8").read()
self.assertIn("first usable increment", text, name)
self.assertIn("labelled as an estimate", text, name)
self.assertIn("labels a different worker wrote", text, name)
self.assertIn("repeat-under-parallel-load", text, name)
class CoreMdTests(SisiCase):
def test_help_lists_new_commands(self):
out = self.sisi("help").stdout + self.sisi("help", "verifiers").stdout + self.sisi("help", "done").stdout
@@ -0,0 +1,46 @@
---
id: repeat-under-parallel-load
title: Repeat a test about 30 times with copies running in parallel
answers: Does this test still pass when copies of it run at the same time and the machine is busy?
rung: 3
section: test-quality
languages: any
kinds: general, concurrency
cost: low
detect: xargs --version
ran_here: yes
verified: ran
---
## Use when
- You wrote a new test module and are about to report it as passing.
- A test passes alone and fails in the full suite, or fails once and passes on rerun.
- The test uses time, a fixed path or port, a shared directory, the current directory, or random data.
## Do not use when
- The failure is deterministic. Fix it; do not repeat it.
- You need to find a race in the code itself. Repetition only samples; use a model checker or a stress tool built for that.
## Set up
- Nothing beyond `xargs` (GNU or BSD) and `seq`, and the standard test runner of the language. The tests must be hermetic: each copy gets its own temporary directory, state and ports.
## Minimal example
Python's standard library, a module `test_mod.py`:
python3 -m unittest -q test_mod
## Run
Thirty runs, eight at a time. `xargs` exits 123 if any run exits non-zero:
seq 30 | xargs -P 8 -I{} python3 -m unittest -q test_mod
Passing looks like: exit status 0 and no output from unittest. Failure shows as exit 123 with the failing copy's output above it. Reproduce one failure alone, then under load again. Use `-P` near the number of processors, or higher, to make timing worse; run the whole suite as one of the parallel copies when order matters.
## As a contract check
{"id": "repeat-parallel", "claim": "The new test module passes 30 runs, 8 at a time", "kind": "general", "rung": 3, "cmd": "seq 30 | xargs -P 8 -I{} python3 -m unittest -q test_mod", "expect": {"exit": 0}, "tier": "deep", "timeout_s": 900}
## What a pass does not prove
- Thirty passes bound a flake rate only roughly: a 1-in-20 flake can still pass thirty runs. Raise the count for anything that matters.
- Copies that already isolate their state cannot show a shared-state bug between them; check that the test really shares something (a path, a port) when you suspect it.
- Check that the module name matched tests (Python 3.12 and later exit 5 when a module has no tests; older versions exit 0, so check with `-v` once).
- A pass says nothing about the code under test being correct, only that the test is stable.