# Fast tests and validation studies This page separates the checks that run before every pull request from statistical studies that run only when a relevant implementation changes. `README.md` gives the fast command. [Method benchmarking](method-benchmarking.md) gives the study design and registration rules. ## The two checks | check | command | what it establishes | | --- | --- | --- | | fast tests | `pytest -q -n auto --dist loadgroup` | unit, integration, end-to-end, documentation, provenance, artifact, and published-verdict behavior | | registered validation study | the affected study directory's documented regeneration command | repeated-sampling, large-sample, flexible-learner, and reference-implementation claims | Run the fast tests before every pull request. They recompute every published verdict and negative control from committed study artifacts. They do not refit committed study replications. Run a registered study only when a result-determining change can affect what that study computes. Choose a complete rerun or an audited targeted rerun under the conditions below. Both routes retain every declared replication and recompute each affected summary and verdict. The repository has no pytest slow tier. Registered studies replace the deprecated repeated-sampling tests. An unrecorded partial probe cannot replace published study evidence. ## What belongs in the fast suite Use a fast test when one compact sample, an exact law, or a deliberate mutation can observe the behavior. This includes these checks: - public behavior, validation, serialization, and presentation; - exact-law, Gateaux, remainder, identity, and mutation instruments; - targeting, cross-fitting, nuisance routing, and inference formulas on compact data; - artifact hashes, schemas, provenance, generated claims, and verdict recomputation; - documentation parsing, links, and executable examples. Use `tests.conftest.FAST_KWARGS` and explicit parametric learners for estimator tests. Use a flexible learner only when flexible learning is the subject. Do not add an expensive pytest marker. A claim that needs repeated sampling, large samples, many flexible fits, or an external implementation belongs in a registered validation study. ## Choose affected studies A change affects a study when it can move that study's inputs, fits, or verdicts. Typical examples include these changes: | change | action | | --- | --- | | an estimand, influence curve, variance, clustering, targeting, cross-fitting, nuisance prediction, or randomization path | regenerate every registered row that evaluates the path | | a study law, margin, cell, seed, learner, estimator argument, schema, package pin, or reference runner | regenerate the affected evidence; use a targeted rerun only when its eligibility conditions hold | | documentation, formatting, comments, type annotations, or presentation that preserves fitted arrays | run fast tests only | | validation that exits before estimator construction | run fast tests only | Use the [implementation validation grid](../technical-reference/method-evidence/validation-grid.md) to find the rows for a method. Read each row's coverage limits before selecting it. If several rows evaluate the changed path, regenerate each one. Record the selected study names and commands in the pull request. For regenerated evidence, also name the artifacts that moved and those that stayed byte-identical. ## Targeted reruns Use a targeted rerun when an audit identifies every affected replication before fitting replacement samples. A seed collision repair can meet this condition without refitting samples whose seeds stay unchanged. When the conditions below hold, the study can reuse unchanged fits. | condition | required evidence | | --- | --- | | bounded change | identify affected replication keys from inputs or code, before reading replacement outcomes | | fixed design | preserve the laws, learners, sample sizes, budgets, margins, pairing, and reading rules | | reusable evidence | pin the original artifact commit and verify every inherited artifact hash | | unchanged path | show that inherited samples and fitted quantities retain their result-determining inputs and code | | independent fits | construct fresh estimators and learners for each replication; exclude shared training state and execution-order dependence | | runtime | match the original runtime for replacement fits; independently investigate any unexplained replay difference | | complete accounting | replace every affected key exactly once; retain every unaffected row and all declared counts | | dependent fits | rerun both sides of an affected paired comparison and every dependent fit | | analysis | recompute all affected summaries, bootstrap intervals, controls, and verdicts from the complete combined rows | | provenance | distinguish inherited evidence from replacement fits and recomputed analyses in the manifest | | verification | independently check the selection, preserved evidence, replacement fits, complete analysis, and manifest | Select replacement seeds from the declared allocation rule. Do not select samples from their fitted results. Keep an unchanged replay witness when it can test the claimed reuse boundary. A replay witness supports the code audit. It does not establish that every inherited fit is unchanged. Declare any numerical replay tolerance before fitting. Require exact agreement for keys, counts, and discrete decisions. Passing a tolerance alone does not explain a runtime or source difference. Retain primary and reference files as exact bytes when the change cannot affect them. Retain unaffected replication rows exactly, even when recompressing their complete file changes its hash. Publish failed or unresolved verdicts under the original acceptance rules. Do not repair a failed fit by dropping its row or drawing a more favorable sample. Use a complete rerun when the audit cannot bound the change or verify the inherited evidence. Estimator changes that affect every fit usually require this route. Changing a runtime, learner, law, or reference can also invalidate the claimed reuse boundary. [Method benchmarking](method-benchmarking.md#targeted-regeneration-record) defines the provenance record. Record the targeted command, selected keys, baseline, preserved artifacts, and validation in the pull request. ## Result-neutral study edits A study manifest records the Python modules that produced the run. A Python hash difference does not fail the fast tests because a comment or extracted helper can change the bytes without changing the result. Regenerate only when the edit changes what the study computes. Reference Dockerfiles and R sources follow a stricter rule. The fast suite refuses an undeclared hash difference. Regenerate a result-determining reference edit. Record a result-neutral edit in `tests/canonical/provenance-revisions.md` without rewriting the recorded manifest hash. Read [method benchmarking](method-benchmarking.md#what-makes-a-study-stale) for the complete provenance contract. ## Resume a study run `tests/canonical/regenerate.py` keeps the scratch of each run outside the repository. An R reference stores the result of each group as a checkpoint. A rerun of the same command reuses the Python phase, the calibration and each checkpoint. The rerun prints what it reused. A failure checkpoint is reused like a result: the rerun does not refit a group whose comparator call failed. The Python phase stores each replicate as a checkpoint too, so a rerun refits only the replicates that the stopped run did not finish. The property phase does the same, with one checkpoint for each fit of each property loop. The [failure rule](method-benchmarking.md#comparator-fitting-failures) says which errors stop the phase. A run shares its cache with a rerun only when the two have one *resume key*. The key holds the declared study without its output path, `HEAD` and the tree state. It also holds the reference sources, the R harness, the content of the samples and the truth, n, the replicate count and the Python versions. A change to any of these starts a new cache. | item | location or command | | --- | --- | | host scratch | `%LOCALAPPDATA%/cleverly/runs///` on Windows, `~/.cache/cleverly/runs///` elsewhere. `--cache DIR` replaces it | | R checkpoints | `/cache///__/` in the Docker volume `cleverly-cache` | | Python checkpoints | `checkpoints//