AI_PR_GUIDE.md
This guide helps AI assistants (and humans using them) submit high-quality PRs to Litestream.
Before submitting a PR:
go test commandslog.Printf(err) followed by continue or return nil — this silently swallows failures.Analysis of recent PRs shows successful submissions share these patterns:
Show evidence, don't just describe the fix.
Good:
## Problem
File patterns show excessive snapshot creation after checkpoint:
- 21:43 5.2G snapshot.ltx
- 21:47 5.2G snapshot.ltx (after checkpoint - should not trigger new snapshot)
Debug logs show `verify()` incorrectly detecting position mismatch...
Bad:
## Problem
Snapshots are created too often. This PR fixes it.
Explicitly state boundaries.
Good:
## Scope
This PR adds the lease client interface only.
**In scope:**
- LeaseClient interface definition
- Mock implementation for testing
**Not in scope (future PRs):**
- Integration with Store
- Distributed coordination logic
Bad:
## Changes
Added leasing support and also fixed a checkpoint bug I noticed.
Good: Include actual commands that can be run:
# Unit tests
go test -race -v -run TestDB_CheckpointDoesNotTriggerSnapshot ./...
# Integration test with file backend
go test -v ./replica_client_test.go -integration file
Bad: Vague descriptions like "Manual testing with file backend" or "Verified it works"
For behavior changes, show the difference:
Good:
## Behavior Change
| Scenario | Before | After |
|----------|--------|-------|
| Checkpoint with no changes | Creates snapshot | No snapshot |
| Checkpoint with changes | Creates snapshot | Creates snapshot |
Problem: Mixing unrelated changes in one PR.
Example: PR titled "Add lease client" also includes a fix for checkpoint timing.
Fix: Split into separate PRs. Reference them: "This PR adds the lease client. The checkpoint fix is in #XXX."
Problem: Implementing a fix without proving the problem exists.
Example: "Add exponential backoff" without showing what's filling disk.
Fix: Include investigation showing the actual cause before proposing solution.
Problem: "Tested manually" or "Verified it works."
Fix: Include exact commands:
go test -race -v -run TestSpecificFunction ./...
Problem: Large features without explaining how they fit.
Fix: For multi-PR work, explain the phases:
This is Phase 1 of 3 for distributed leasing:
1. **This PR**: Lease client interface
2. Future: Store integration
3. Future: Distributed coordination
Use this structure for PR descriptions:
## Summary
[1-2 sentences: what this PR does]
## Problem
[Evidence of the problem - logs, file patterns, user reports]
## Solution
[Brief explanation of the approach]
## Scope
**In scope:**
- [item]
**Not in scope:**
- [item]
## Test Plan
[Include actual go test commands here]
## Related
- Fixes #XXX
- Related to #YYY
From CONTRIBUTING.md: