| Observed exhibit | Value |
|---|---|
| Input |
((0, 'a'), (0, 'a'))
|
| Required output |
((0, 'a'), (0, 'a'))
|
| Baseline output |
((0, 'a'),)
|
| Corrected explicit replay |
((0, 'a'), (0, 'a'))
|
| Missing obligation in the weak gate | Retain every occurrence of every complete record. |
The baseline loses one occurrence. Stability is not assessed after that preservation failure. The correction was executed on the saved value; this replay did not generate or shrink a new witness. Inspect the before/after replay.
01 / The rule and its domain
What is property-based testing useful for?
A property describes what must hold for inputs in a declared domain. An example test fixes a particular input and expectation; a generated property test applies an assertion to inputs supplied by a strategy. Keep both: selected examples preserve known requirements and regressions, while generation explores additional combinations. Hypothesis replay guidance
For a pure function, begin with a boundary: output depends only on explicit input, with no intended I/O or hidden mutable state. Specify mutation, aliasing and supported values. Purity makes repeated evaluation easier to reason about, but a function’s label or repeated deterministic outputs cannot establish that boundary. Inspect its source and dependencies. A test that always returns the same value could still write a file.
Properties must follow the actual requirement and type signature. Pure functions do not automatically owe idempotence, commutativity, associativity or monotonicity. The pure function f(x) = x + 1 is not idempotent. For sorting, idempotence can complement preservation; returning an empty tuple is also idempotent.
| Approach | The useful question |
|---|---|
| Generated property testing | Does this implementation satisfy the agreed predicates on the inputs exercised? |
| Differential testing | Do two computations agree under a justified comparison rule? |
| Fuzzing | Can input exploration reach an unacceptable behavior recognized by the harness? |
| Solver or model analysis | Does the encoded property follow within the model and its assumptions? |
These approaches can overlap. A property may use a reference implementation; a fuzzer may check properties. Here the central task is to justify the rule, construct its domain, challenge the oracle and retain a useful counterexample. A solver result about an authored model needs a separate connection to actual code.
02 / Start with a usable record
Free property-based testing worksheet
Copy this complete record into a repository, issue or review document. Replace the brackets, retain unknowns and link the underlying evidence. Use one record per callable and contract revision. The worksheet is selectable here; the separate portable evidence kit contains the sorting experiment.
Blank worksheet
PROPERTY TEST REVIEW
Record ID / revision:
Decision this review supports:
Author / executor:
Requirement owner / oracle reviewer:
Acceptance authority / recorded disposition:
AGREED BEHAVIOR AND BOUNDARY
Requirement ID, revision, authoritative wording and source:
Callable, signature, implementation file and candidate revision/hash:
Transitive helpers, dependencies and source-review basis:
Explicit inputs on which output may depend:
Intended I/O and hidden-state policy:
Input mutation / output mutation / aliasing and identity policy:
Supported representation, sizes, types and exceptional values:
Equality: full values, identifiers, ignored fields or tolerances:
Multiplicity: which occurrences must survive:
Ordering key / tie handling / stability required and why:
Unsupported classes and behavior left unspecified:
Open contract decisions and responsible owner:
PROPERTIES AND EXPECTATIONS
For EACH property:
Name / requirement rationale / applicability precondition:
Executable assertion and observation boundary:
Independent expectation or reference and its assumptions:
Plausible wrong implementation / concrete distinguishing input:
How a vacuous pass or skipped precondition is detected:
Oracle review: reviewer, reviewed revision, findings and disposition:
Required gate checks:
Additional diagnostics, clearly separate:
Not-assessed outcomes and their interpretation:
GENERATOR AND IMPLEMENTATION LINK
Exact strategy and versioned source:
Constructed types, bounds, relationships and duplicate policy:
Required categories / retained selected cases / observed categories:
Filters or assumptions, rejection information and excluded classes:
Runner entrypoint -> import -> selected callable -> actual call:
Adapters, mocks or authored models between input and implementation:
How observed inputs, outputs and implementation calls are recorded:
RUN AND REPLAY BASIS
Runtime, platform, dependency pins and relevant environment:
Exact command, working directory and fresh result location:
Settings: budget, seed, phases, database, deadline, other overrides:
First failing input / expected result / observed result:
Reported shrunk input / actual assertion note / raw log:
Interpretation: implementation, requirement, oracle or generator error:
Correction identity and why it restores the agreed behavior:
Saved explicit regression values and replay command:
Actual before/after replay results:
New generation/shrinking, if performed, recorded separately:
Non-vacuity challenges and actual outcomes:
CAMPAIGN ACCOUNTING AND DECISION
Per job: body entries / distinct primary inputs / implementation calls:
Per property: pass / fail / not assessed; asserted gate result:
Engine counters and their separately named units:
Repeated shrink/replay inputs and known overlap across jobs:
Raw observations, summaries, provenance and checksums:
Limits: untested inputs, environments, integration and other claims:
Stale-evidence triggers and rule for reuse or rerun:
Next action / responsible person or queue / acceptance criterion:
Acceptance decision, authority, scope and date, or explicitly pending:
Filled record for the retained sorting run
This record describes actual fixture observations. Proposed project actions remain unperformed; no product acceptance or invented reviewer sign-off is recorded. Its basis is the contract, harness, source review and execution report.
RECORD: Stable sorting fixture; contract revision 1.
DECISION: Assess the captured property checks for this teaching callable.
AUTHORITY: No project acceptance recorded. A repository adopter must assign
the function owner and test reviewer before accepting a production change.
REQUIREMENTS: TREQ-SORT-01 orders by key and retains every occurrence;
TREQ-SORT-02 preserves equal-key subsequences; TREQ-SORT-03 declares the
pure boundary, unchanged input and equal results on repeated equal inputs.
DOMAIN: Tuple of 0..8 immutable (key, tag) pairs; integer keys -2..2,
excluding bool; tags exactly a/b/c. Complete pairs and keys may repeat.
EQUALITY: Whole-pair values. Tags are not unique IDs. Counts matter.
ALIASING: Original immutable records may be reused in the result tuple.
No fresh-object identity guarantee. Only local temporary lists are mutated.
EXCLUSIONS: Floats/NaN, custom comparison/equality, locale rules, mutable
records, external lookup, concurrency, longer inputs and performance.
Outside-domain behavior is unspecified, not an observed rejection policy.
SOURCE: fixture/sorting.py; corrected callable stable_sort(records).
SHA256: 3e4241100fb34b616294456b77d297605ff94641c78df434c0b00985835866a6
LINK: fixture/run_properties.py imports stable_sort;
IMPLEMENTATIONS["corrected"] selects it; check -> evaluate -> call ->
function(value). Baseline selects drop_duplicates, which calls stable_sort.
HARNESS SHA256:
2612041a92e51be548d888ff949eb1ff922d01b50095cd2b2163d25e7197a030
PURITY BASIS: Retained source/call-graph review found no imports, module
assignments, global/nonlocal declarations, I/O or mutable global data.
Trust boundary includes ordinary Python runtime/builtins and immutable
value inputs. Harness logging/cache/framework state sit outside it.
Finite repeat/snapshot checks do not prove general purity or totality.
FULL GATE: ordered, multiplicity, stable_equal_keys, input_unchanged,
repeat_deterministic, idempotent. Stability is not assessed if multiplicity
fails. Set equality is an additional diagnostic, never a required gate.
ORACLES: Adjacent key comparisons; Counter over complete pairs; per-key
subsequence equality. Readable expected output uses Python's stable
sorted(records, key=lambda r: r[0]), converted to tuple.
RATIONALE: Stable sorting again preserves the required ordered sequence.
WEAKNESS CHECK: Empty output and deduplication satisfy ordering and
idempotence. Neither establishes preservation.
ORACLE REVIEW BASIS: Declared contract, retained independent checks and
Python sorting/Counter semantics; no separate human sign-off recorded.
GENERATOR: lists(tuples(integers(-2,2), sampled_from(('a','b','c'))),
min_size=0, max_size=8, unique=False).map(tuple). No filter or assume.
SELECTED CASES: Eight entries, supplemented by two retained witnesses;
empty/singleton, duplicates, sorted/reverse order and equal-key groups.
RUNTIME: Python 3.14.7; macOS 26.5 arm64.
PINS: Hypothesis 6.170.12; sortedcontainers 2.4.0.
GENERATED SETTINGS: max_examples=200; seed=20261028; database=None;
deadline=None; derandomize=False; report_multiple_bugs=False;
print_blob=True. Passing jobs: generate/normal verbosity.
Search jobs: generate+shrink/debug verbosity. PYTHONHASHSEED=0;
temporary isolated engine cache.
ENTRYPOINT: Recorded interpreter -B reproduce.py --output captured.
PORTABLE RERUN: .venv/bin/python -B reproduce.py --output local-rerun
Working directory: extracted kit root; output must not already exist.
REPLAY ONLY: .venv/bin/python -B fixture/run_properties.py --job regression-replay --output local-replay --capture-root captured
This command uses bundled captured witnesses and a fresh output directory;
it evaluates the selected cases and retained inputs directly.
BASELINE FIRST FAILURE: ((1,'a'),(-2,'c'),(2,'b'),(-1,'c'),(1,'a')).
REPORTED SHRUNK INPUT: ((0,'a'),(0,'a')).
EXPECTED: both records. BASELINE: ((0,'a'),).
CORRECTED REPLAY: both records retained.
UNSTABLE FIRST FAILURE: ((0,'c'),(0,'a')).
REPORTED SHRUNK INPUT: ((0,'a'),(0,'b')).
EXPECTED: a,b order. UNSTABLE: b,a. CORRECTED REPLAY: a,b.
CORRECTION: stable insertion sort using <, without deduplication.
All variants coexist in the same frozen source; no mid-run edit.
CHALLENGES: Weak baseline gate 200/200 passes, multiplicity fails 146;
weak empty gate 200/200 passes, multiplicity fails 199.
Unstable saved witness fails stability and idempotence.
COUNTS (entries / distinct primary inputs / implementation calls):
weak-baseline 200/200/600; weak-empty 200/200/600;
search-baseline 32/30/96; search-unstable 13/11/39;
corrected-campaign 200/200/600; regression-replay 40/9/120.
CORRECTED RESULT: Six-check gate passes 200/200 generated primary inputs
and separately 10/10 replay case entries, with nine distinct replay values.
Calls per entry: primary, repeat original, idempotence on primary output.
Search engine summaries: baseline 36 cases, unstable 14 cases.
Successful shrinks: baseline 11, unstable 2. These are separate counters.
OVERLAP: Repeated search inputs and overlapping jobs; no unique union
claimed. Replay does not regenerate or shrink a failure.
EVIDENCE ROOT: /assets/property-based-testing/research-rerun/
Records: captured/execution-report.json; captured/*/summary.json;
captured/*/evaluations.jsonl.gz; captured/search-*/counterexample.json;
captured/search-*.stdout.txt;
captured/regression-replay/counterexample-regression.json; SHA256SUMS.
LIMITS: Finite fixture only; no production, other-runtime, Proof, solver,
structural-coverage, exhaustive enumeration or universal proof result.
STALE TRIGGERS: Contract, domain, equality, key/tie policy, source/helper,
strategy, oracle, dependency, runtime or relevant environment changes.
PROPOSED NEXT ACTION: Adopting function owner identifies the real callable
and supported domain; test reviewer checks its oracle and runs the linked
candidate. Criterion: attributable results, addressed failures and visible
remaining gaps. Production acceptance stays with the assigned authority.
03 / An observed failure and an executed correction
Sorting records without losing occurrences
The fixture contract requires ascending order by key alone, complete occurrence preservation and stable equal-key order. Its immutable tuples contain zero through eight records, integer keys from −2 through 2 excluding booleans, and tags a, b or c. Stability matters here because TREQ-SORT-02 explicitly requires it.
The faulty baseline removes duplicate complete values, then sorts the survivors. The correction is this actual function from sorting.py:
def stable_sort(records):
result = []
for record in records:
position = len(result)
while position > 0 and record[0] < result[position - 1][0]:
position -= 1
result.insert(position, record)
return tuple(result)
The strict comparison inserts a new equal-key record after earlier ones. The baseline, correction, empty-output challenge and unstable challenge are separate functions in the same captured source. They were all present before execution, and source hashes remained unchanged during the capture.
The static review found no imports, mutable module data, global/nonlocal statements or I/O calls in this source and its local helper. Temporary list mutation is internal; returned records are immutable values. The boundary assumes ordinary Python runtime/builtins. Harness logging and framework state are outside it. Repeated-call and input-snapshot observations support only the executed cases; they cannot establish no hidden effects or totality for every possible input.
Check the behavior independently of the sorting algorithm
The harness imports the four functions directly. Its IMPLEMENTATIONS["corrected"] entry selects stable_sort; check(records) calls evaluate, whose local call executes function(value). This is implementation execution, with no authored model or substitute sorter between the generated input and the selected function.
| Required check | What the harness observes |
|---|---|
ordered
|
Adjacent output keys are nondecreasing. |
multiplicity
|
Counter(output) == Counter(records) for complete pairs. |
stable_equal_keys
|
Each key’s output subsequence equals its input subsequence; assessed only after preservation passes. |
input_unchanged
|
Original input equals its value snapshot. |
repeat_deterministic
|
Repeating the original-input call returns an equal value. |
idempotent
|
Sorting the primary output again leaves it equal. |
The readable expected result is tuple(sorted(records, key=lambda r: r[0])). Python documents stable key sorting, and Counter counts hashable values with multiplicity. These support independent checks that do not repeat insertion-sort mechanics. The reference output is retained for inspection; the six predicates determine the full gate. There is no separate reference-equality assertion. Python sorting · Counter
The extra set-equality diagnostic deliberately exposes a weaker claim. It passes for the duplicate-dropping baseline. It is not a seventh required law.
Generate the declared domain
The actual strategy constructs the supported values directly:
RECORDS = st.lists(st.tuples(st.integers(-2, 2), st.sampled_from(("a", "b", "c"))),
min_size=0, max_size=8, unique=False).map(tuple)
No filter or assume removes duplicates. Exact repeats and distinct tags sharing a key remain reachable. The bound of eight belongs to this teaching contract; it is not a recommended limit for a real sorter that supports longer inputs. Strategy reachability does not establish that a campaign exercised every category or every value. Strategies · Domain and distribution
Two green weak campaigns conceal record loss
Both weak campaigns assert order, unchanged input, repeat determinism and idempotence. Both pass 200/200 asserted weak gates. Yet the baseline fails the separately recorded multiplicity check in 146 body entries, and empty output fails it in 199. Baseline summary · Empty-output summary
Empty output contains no adjacent inversion and stays empty when sorted again. Deduplication can preserve set equality while discarding occurrences. A larger budget for these weak assertions would not supply the missing requirement.
Follow the generated failures
The baseline search first fails on:
((1,'a'),(-2,'c'),(2,'b'),(-1,'c'),(1,'a'))
Hypothesis reports the shrunk input ((0,'a'),(0,'a')). The baseline returns ((0,'a'),); the contract requires both occurrences. The retained assertion note is:
Failing test case: check(
records=((0, 'a'), (0, 'a')),
)
Its message is required multiplicity violated. The counterexample record retains first/final inputs, calls, expected output and the version-specific reproduction blob. The raw debug log records 11 successful shrinks and 36 engine test cases; the harness records 32 body entries. Those are different counters.
The unstable variant changes < to <=, inserting later equal-key records before earlier ones. Its first failure is ((0,'c'),(0,'a')); its reported shrunk input is ((0,'a'),(0,'b')), with actual output ((0,'b'),(0,'a')). Both inputs contain two records. The log records two successful shrinks, 14 engine test cases and 13 harness body entries. This witness preserves multiplicity but fails stability and idempotence. Failure record · Raw log
“Shrunk” means the tool’s reported reduced example under this strategy and ordering, not a globally smallest witness. List strategies can remove elements and shrink their components; sampled_from can move toward earlier supplied values. A useful reduction need not shorten the tuple. Strategy shrinking semantics
Inspect the correction and count the actual work
The corrected function retains both duplicate occurrences and preserves a,b in the saved stability case. It passes all six required checks on 200/200 generated primary inputs. It separately passes 10/10 explicit replay case entries, representing nine distinct input values. Corrected campaign · Replay summary · Before/after witnesses
| Recorded job | Body entries | Distinct primary inputs within job | Implementation calls | Child exit |
|---|---|---|---|---|
weak-baseline
|
200 | 200 | 600 | 0 |
weak-empty
|
200 | 200 | 600 | 0 |
search-baseline
|
32 | 30 | 96 | 1 |
search-unstable
|
13 | 11 | 39 | 1 |
corrected-campaign
|
200 | 200 | 600 | 0 |
regression-replay
|
40 | 9 | 120 | 0 |
Every body entry invokes the selected implementation three times: primary input, repeated original input, and primary output for idempotence. Calls to the Python reference are excluded. Each search asserts its named target property while recording the other checks; the corrected campaign asserts the six-check gate. Replay runs eight selected entries plus two saved witnesses against four variants. One saved witness duplicates a selected value; replay also overlaps generated evidence.
Across jobs there are 685 body entries and 2,055 implementation calls, not 685 unique inputs or 210 unique correction inputs. The full provenance and each job’s compressed observations preserve the repetitions. Per-property pass/fail/not-assessed counts are distinct from gate results.
Search exit 1 records an expected failed assertion. Wrapper exit 0 means the expected contrasts and unchanged sources were confirmed, including those failing children. It is not acceptance of every implementation.
Inspect and reproduce this evidence, starting with the portable README. Compare the contract, failing assertion and corrected replay before adapting the harness to your function.
Follow the rule through the failure
Download the complete video transcript.
Read the complete video transcript
Start with the declared sorting contract. Inputs are immutable tuples of bounded key and tag records. Every occurrence must survive, and equal-key records must keep their original order. The retained source review supports this small function boundary. Repeating an output alone would not establish purity or rule out hidden effects.
The recorded weak campaigns check ordering, unchanged input, repeat determinism and idempotence. Both the duplicate-dropping baseline and the empty-output implementation pass all two hundred weak gates. Separate observations still show record loss. These deliberately wrong implementations expose what the asserted rules permit, before a green result is trusted.
The baseline search finds a multiplicity failure and reports a shrunk input containing two identical records. The baseline returns only one. The contract requires both. Retain the original failure, reported reduced input and raw log. This is the tool's reduced witness for the recorded strategy, without a global-minimum claim.
The second search challenges stability, which this contract explicitly requires. Its reported input has tags a then b under the same key. The unstable function returns b then a. Multiplicity survives, but stability and idempotence fail. The first and final failing inputs both contain two records; shrinking did not shorten them.
The implemented correction uses stable insertion sorting without deduplication. It passes the six-check gate on two hundred generated primary inputs and separately on ten explicit replay entries. Those replay entries represent nine distinct values and overlap generated evidence. Replaying saved inputs confirms their observed correction; it does not repeat generation or shrinking.
Each recorded test evaluation called the selected sorter three times: on the input, again on the same original input to check that the result repeats, then on the first result to check that sorting it again leaves it unchanged. Repeated search inputs and overlapping campaigns cannot be added into unique coverage. Production integration and other runtimes remain unperformed. The proposed next step is to complete the worksheet for one actual function, name its owner and reviewer, and assign responsibility for the acceptance decision.
Read the text walkthrough
1. Declare the function boundary
Start with the declared sorting contract. Inputs are immutable tuples of bounded key and tag records. Every occurrence must survive, and equal-key records must keep their original order. The retained source review supports this small function boundary. Repeating an output alone would not establish purity or rule out hidden effects.
2. Challenge the green result
The recorded weak campaigns check ordering, unchanged input, repeat determinism and idempotence. Both the duplicate-dropping baseline and the empty-output implementation pass all two hundred weak gates. Separate observations still show record loss. These deliberately wrong implementations expose what the asserted rules permit, before a green result is trusted.
3. Keep the duplicate witness
The baseline search finds a multiplicity failure and reports a shrunk input containing two identical records. The baseline returns only one. The contract requires both. Retain the original failure, reported reduced input and raw log. This is the tool's reduced witness for the recorded strategy, without a global-minimum claim.
4. Preserve equal-key order
The second search challenges stability, which this contract explicitly requires. Its reported input has tags a then b under the same key. The unstable function returns b then a. Multiplicity survives, but stability and idempotence fail. The first and final failing inputs both contain two records; shrinking did not shorten them.
5. Replay the implemented correction
The implemented correction uses stable insertion sorting without deduplication. It passes the six-check gate on two hundred generated primary inputs and separately on ten explicit replay entries. Those replay entries represent nine distinct values and overlap generated evidence. Replaying saved inputs confirms their observed correction; it does not repeat generation or shrinking.
6. Carry the limits forward
Each recorded test evaluation called the selected sorter three times: on the input, again on the same original input to check that the result repeats, then on the first result to check that sorting it again leaves it unchanged. Repeated search inputs and overlapping campaigns cannot be added into unique coverage. Production integration and other runtimes remain unperformed. The proposed next step is to complete the worksheet for one actual function, name its owner and reviewer, and assign responsibility for the acceptance decision.
04 / The working method
How to write and assess a generated property test
1. Agree what a valid answer means
Name the callable, contract owner and supported inputs before choosing laws. Define output representation, equality, multiplicity and any ordering requirement. Decide whether malformed inputs are rejected, normalized or outside scope. An undeclared case is an open contract decision, not a convenient filter.
2. Justify each property with a counterexample
Ask what wrong implementation could pass. For sorting, ordering permits empty output; set equality permits deduplication; key-only counts can miss altered tags. Match each required observation to the promise it protects. Keep diagnostics separate from assertions that determine the gate.
3. Construct the supported domain deliberately
Generate valid relationships directly where practical. Preserve duplicates if occurrence loss matters, and distinct equal-key values if stability matters. Retain important examples explicitly rather than assuming generation will select them. Review exclusions against the real API: a small demonstration domain cannot silently become the test domain for an unbounded production contract.
Hypothesis distinguishes a strategy’s possible values from their generation distribution. Do not describe this campaign as uniform random sampling or infer a confidence percentage from its size. Domain guidance
4. Review the oracle and actual call path
Have a reviewer derive expected behavior from the contract. For complex output, use independent invariants, selected exact expectations or a justified reference. A second implementation can share the same misunderstanding, so agreement does not settle intent.
Trace the runner’s import and dispatch to the candidate bytes. Inspect helper calls and adapters. For purity, identify clocks, random sources, external lookup, mutable globals and aliased mutable inputs. Source review can support a declared scope; deterministic outcomes alone cannot prove the absence of effects. Hypothesis’s flakiness guidance explains why uncontrolled state also undermines replay.
5. Record the run before interpreting its size
Keep versions, settings, command, seed, database policy, phases and environment with raw observations. Record actual body entries and implementation calls. Configured max_examples is a generation budget, not a measured unique-input or call count. Failure search and confirmation can change execution counts. Case-count explanation
6. Diagnose the failure before changing the code
Preserve the first failure, reported shrunk value, assertion and outputs. Confirm that the input belongs to the agreed domain and that the expectation expresses the rule. A failed property can reveal an implementation defect, an incorrect oracle, an unrealistic generator or an unresolved requirement. Repair the responsible artifact with its owner; do not weaken a valid rule merely to match existing code.
7. Keep the regression and renew the campaign
Retain explicit values, run them against the correction, and record a fresh campaign separately. A fixed seed helps within a controlled setup; versions, strategies, settings or external state can change the search. A reproduction blob is version-specific and temporary. For durable regressions use concrete inputs, through direct tests or @example with Phase.explicit enabled. This fixture’s replay is a direct runner job. Replay guidance · API phases
05 / Before trusting the result
Property-based testing review checklist
- The requirement owner has resolved equality, domain and conditional laws.
- The generator can reach the relevant failure classes without removing them.
- The harness calls the intended candidate function, with identifiable source.
- Purity, mutation and aliasing claims have a declared boundary and review basis.
- Each required property rejects a plausible mistake; selected challenge results are retained.
- Independent expectations have been checked against the contract.
- Failure, not assessed, missing and passing outcomes remain distinguishable.
- Shrunk values, exact regressions, versions and settings are retained separately.
- Counts state their units and disclose repetition and overlap.
- Unsupported inputs, integration gaps and acceptance authority remain visible.
Reassess freshness after changes to the contract, key, equality, stability policy, source/helper, generator, oracle, runtime or dependency. Preserve the old result, identify affected claims and rerun or justify reuse. Matching hashes identify bytes; they do not establish that the contract is correct.
06 / Mistakes that make green unhelpful
Common property-based testing mistakes
| Mistake | What it permits | Useful correction |
|---|---|---|
| Check ordering alone | Empty output passes. | Check every record and occurrence. |
| Compare sets or only keys | Duplicate loss or changed record content can disappear. | Define equality and compare complete-value counts. |
| Demand familiar laws without justification | Correct behavior can fail an irrelevant property. | Derive each law from the contract and signature. |
| Generate only unique keys | Stability is never challenged. | Include equal-key records with distinguishable values. |
| Copy the implementation into the oracle | Both artifacts can encode the same mistake. | Review independent expectations and deliberate faults. |
| Count an unassessed condition as passed | Missing preservation masquerades as demonstrated stability. | Retain the prerequisite and not-assessed result. |
| Save only a seed | Later changes can prevent reproduction. | Preserve concrete input, expectation and source basis. |
| Treat wrapper success as acceptance | Expected failing children or incomplete scope disappear. | Inspect child outcomes, assertions and remaining work. |
The three deliberately faulty variants challenge specific weaknesses. They are not an exhaustive mutation campaign, a general test-quality score or evidence that every bug will be found.
07 / Keep intent and execution connected
Using Proof with implementation property tests
The standalone kit runs Python and Hypothesis. A Proof project can connect the agreed requirement, implementation link, test, counterexample, correction and review state so the next change has usable context. Keep those records attributable to the requirement and source versions. Proof’s project and agent workflow
Three activities need distinct evidence:
| Activity | What its output establishes |
|---|---|
proof verify-properties
|
Results for supported authored models and their properties or data constraints, within the encoding. |
proof proptest
|
Generated model-derived fixture data that a consuming test must use appropriately. |
| Repository implementation test | Observations from actual calls and assertions against the identified implementation. |
Proof’s property-verification reference describes the model boundary. Its property-fixture reference explicitly separates generated JSON from the test that feeds values into code. Neither command was run for this sorting experiment.
Hosted MCP supplies project context and supported graph operations; it does not start verification inside your repository. The agent runs repository or CI work through that environment’s permissions. A tool label, permission to approve, or declaration that a function is pure supplies no missing execution evidence. Acceptance remains an authorized decision. MCP responsibilities
For one supported written bounded predicate, free Spec Lab can help review an interpretation and proposed cases/model plan. It does not execute this Hypothesis harness, test your production function, establish purity or prove the complete multiset-and-stability contract.
08 / Choose the method for the question
Which testing workflow fits?
| Choice | Useful task | Work that remains |
|---|---|---|
| Hypothesis | Generate structured Python values and reduce discovered failures. | Write the domain, implementation call and meaningful assertions. |
| Explicit regression tests | Keep a known counterexample in routine checks. | Continue exploring other supported inputs. |
| Stable reference comparison | Obtain readable expected outputs for this sorting contract. | Review agreement assumptions and preserve independent predicates. |
| Model or solver analysis | Investigate an encoded property beyond selected executions. | Review encoding/domain and establish its implementation relationship. |
| Repository/CI with Proof context | Retain requirements, tests, results and affected-change context. | Execute the actual harness and make the acceptance decision. |
These are complementary choices, not a ranked tool benchmark. Start with the smallest workflow that calls your real function and retains reviewable failures. Expand the supported domain and execution environment when the product contract demands it.
09 / Inspect and reproduce
Primary sources and reproducibility
Official references and what they support
| Primary source | Use and limit |
|---|---|
| Hypothesis introduction and strategies | Generated arguments, domain construction and strategy-specific shrinking; no intended behavior is inferred. |
| API reference and settings tutorial | Seed, phases, settings and reproduction controls; configuration is not observed coverage. |
| Case counts and replay | Execution counts, concrete examples and version-sensitive reproduction; replay is distinct from search. |
| Domain/distribution and flaky failures | Input scope and reproducibility assumptions; no statistical-confidence or general-purity result. |
| Python sorting and Counter | Stable reference sorting and complete-value counts; custom API semantics still need agreement. |
| Hypothesis 6.170.12 package metadata | Python ≥3.11 package requirement; no claim that this kit ran on every supported version. |
| Claessen and Hughes, QuickCheck, 2000 | Original paper’s institutional abstract supports programmer-defined properties and generators. Modern Hypothesis details above use its own documentation. |
The inspected Hypothesis documentation identifies version 6.170.12. The explicitly versioned Python 3.14 pages identify 3.14.10; the captured interpreter was 3.14.7. Documentation metadata and runtime evidence are separate facts.
Reproduce the portable fixture
Download the 53,203-byte evidence kit and its ZIP checksum. The ZIP’s SHA-256 is:
3f2572026970293eaae79eae2f3c19a8358268c99fb8106d099d1fe9273a5d56
The README describes isolated installation. From the extracted kit root, using your intended Python interpreter:
python3 -m venv .venv
.venv/bin/python -m pip install -r requirements.txt
.venv/bin/python -B reproduce.py --output local-rerun
Use a new output directory; the wrapper refuses an existing one. Installation needs package-index access. The tests themselves need no network or Proof. To match the recorded environment, use Python 3.14.7 on macOS 26.5 arm64 with the supplied Hypothesis 6.170.12 and sortedcontainers 2.4.0 pins. Other environments require their own result.
To replay only the bundled selected cases and retained witnesses, use the actual child entrypoint with a fresh output destination:
.venv/bin/python -B fixture/run_properties.py --job regression-replay --output local-replay --capture-root captured
This separate command performs explicit replay against the four fixture variants. It does not generate or shrink inputs. Retain any local rerun as a new record with its own observations and environment.
The actual capture interval is 2026-10-27T23:11:04.008947–23:11:04.965250 UTC. Its recorded interpreter ran -B reproduce.py --output captured; the execution report retains complete argument arrays, environment, child exits and hashes.
All generated jobs set max_examples=200, seed 20261028, database=None, deadline=None, derandomize=False, report_multiple_bugs=False and print_blob=True. Passing jobs use generation only; search jobs use generation plus shrinking with debug logs. The wrapper fixes PYTHONHASHSEED=0 and isolates its temporary engine cache. The separate replay job does no generation.
Inspect the contract, implementation, harness, selected inputs, purity review, corrected body observations and file checksums. The kit includes all six jobs’ observations and raw output. Hash identity supports traceability, not correctness.
10 / Two more contracts to reason about
Two useful property examples beyond sorting
These are proposed examples, not additional executed campaigns.
Clamp an integer to an agreed interval
Suppose clamp(x) accepts integers from −100 through 100 and returns the nearest value in the inclusive interval 0 through 10. Bounds and idempotence alone permit “always return zero.” Add the actual rule: inputs below zero return zero, inputs above ten return ten, and inputs inside the interval remain unchanged.
Generate each region and retain −1, 0, 1, 9, 10 and 11 explicitly. A wrong clamp(7) = 0 satisfies bounds and idempotence but violates preservation of already-valid values. These expectations come from the hypothetical clamp contract; they are not universal laws of pure functions.
Round-trip a bounded record encoding
Suppose an encoder maps an agreed immutable record domain to bytes and a decoder returns the original record value. Propose decode(encode(x)) == x with explicit equality, supported characters, integer limits and duplicate-field policy.
A matching encoder/decoder mistake can survive a round trip. Keep independent expected byte examples if the format contract specifies canonical bytes, and test malformed-byte handling separately. Encoding is not automatically idempotent: applying a record-to-bytes function to its byte output may not even be valid. Assign an implementation, generator and expected format before claiming any result.
11 / Questions developers ask
Property-based testing questions, answered
How many generated examples are enough?
There is no universal count. Choose a budget after reviewing the domain, risks, oracle strength and execution cost. Report actual results and remaining gaps. The fixture’s 200-example setting is not a statistical confidence level or an exhaustive search.
Do property tests replace ordinary unit tests?
Keep important exact examples and regressions. They make chosen behavior explicit and ensure known failures remain exercised. Generation adds exploration; it does not remove the need to choose expectations.
Does Hypothesis always find the smallest failing input?
Treat its output as the reported reduced example under the strategy, version and settings. Do not claim a globally smallest witness. This fixture’s stability shrink changes values while leaving the record count unchanged.
Can I replay with just the seed?
Retain it, but also retain concrete input values, versions, strategy and settings. A seed is not portable across arbitrary changes. The recorded reproduction blobs are version-specific aids; durable regression values and new generated campaigns serve different purposes.
Does a property failure mean the product has a bug?
It means the asserted check failed on that execution. Verify the contract, input eligibility, oracle and actual call before deciding whether to change the implementation, property, generator or requirement.
Can a pure function still fail these tests?
Yes. Purity concerns dependencies and effects, not whether the computed answer meets the requirement. The duplicate-dropping fixture can be pure within its boundary and still lose required occurrences.
Can the corrected run justify production acceptance?
It supports the specified checks on this fixture and recorded basis. Production linkage, wider input support and other environments remain unexecuted. The responsible project authority must decide what evidence its actual change requires.