> Agent-ready spec from Diff of the Day (2026-11-30, idea 1). Give this file to your coding agent (Claude Code, Codex, Cursor) and ask it to build the P0 requirements first.

# Spec: Property tests from fixed bugs

## Problem Statement
A fixed bug gets one example test at best, and the same class of mistake comes back with a different input. The history of bug fixes in a repository already describes the rules the code must keep, but nobody turns them into general tests because writing properties by hand is slow. A coding agent can read a fix, state the broken rule and write a property test for it in minutes.

## Goals
- Produce one property test for each of the last 20 bug-fix commits where a rule can be stated.
- Prove each kept test: it fails on the commit before the fix and passes on the fix.
- Finish with a report that lists each bug, its rule, and whether a property was kept or dropped, with the reason.

## Non-Goals
- Rewriting existing example tests: they stay as they are.
- Covering code that never had a bug: this spike follows the history only.
- Formal proof of the rules: property tests with random inputs are enough for one evening.

## User Stories
- As a maintainer, I want each past bug to become a general rule in the test suite so that the same mistake cannot return with another input.
- As a reviewer, I want evidence that a new test would have caught the old bug so that I trust it.
- As a maintainer, I want bugs with no clear rule listed and skipped so that the suite gets no weak tests.
- Edge case: as a maintainer, I want a test that is flaky across 20 seeds dropped, not kept.

## Requirements
### P0 (must have)
- **Find the bug-fix commits**
  - [ ] Reads the git log and selects the last 20 commits whose message or linked issue marks a fix
  - [ ] Writes the list to bugs.md with the commit id, the message and the changed files
- **State the rule and write the property**
  - [ ] For each commit, bugs.md holds one sentence that states the rule in plain language
  - [ ] Each property test uses the project's property-testing library with generated inputs, not fixed examples
- **Prove each test**
  - [ ] Runs each test on the parent commit and records a failure
  - [ ] Runs each test on the fix commit and records a pass
  - [ ] Keeps only tests with both results; the others are listed as dropped with a reason
### P1 (nice to have)
- **Shrunk counterexample in the report**
  - [ ] For each kept test, the report shows the smallest failing input found on the parent commit
- **Seed stability**
  - [ ] Each kept test passes on the current main branch with 20 different seeds
### P2 (later)
- A CI job that asks for a property whenever a commit message says "fix".
- The same method for incident reports that never became commits.

## Success Metrics
- Leading: at least 10 of 20 bugs produce a kept property test.
- Leading: zero kept tests fail on the current main branch.
- Lagging: within three months, one new bug is caught by a property from this set before release.

## Open Questions
- Which property-testing library does the project already use, if any? (you)
- Are there fixes that touch external services and need a fake? (you, non-blocking)

## Timeline
One evening for P0 on a repository with a clean history.

## Agent Instructions
- **Suggested stack**: The project's own language, with Hypothesis for Python, fast-check for TypeScript or the closest equivalent.
- **Build order**: commit list in bugs.md, then the rule per bug, then one property at a time with the before and after runs, then the report.
- **Safety**: work on a new branch in a separate worktree; check out old commits only inside that worktree; do not push and do not change production code.
- **Done when**: bugs.md shows the rule and the before and after result for all 20 commits, and the kept tests pass on main.

## Sources
- Your prompts should feel a little delusional (post on X): https://x.com/poteto/status/2126754224843473374
