python-sstable-overlap-tombstone-compaction-proof
The solution is complete, saved at ~/compaction/SOLUTION.md, and independently verified by extracting its code blocks into a clean directory and re-running the full test suite.
Root causes found (all reproduced by the tests):
{newest} plus {newest version ≤ S for each pinned snapshot S}.The fix (in planner.py):
- retained_versions: exact snapshot retention + guarded tombstone elision.
- _bottommost: checks all levels over the full expanded input range.
- generate_candidates: iteratively expands next-level overlaps to a fixed point; feasibility is fan_in·read_buffer + write_buffer ≤ memory_cap.
- Greedy selection by minimum output_bytes / input_bytes (write amplification).
- Step carries per-output SHA-256 checksums; apply_plan re-derives and verifies them; simulate_crash_recovery proves recovery at every output-file boundary.
Verification results:
PASS tombstone_no_resurrect
PASS bottommost_tombstone_drop
PASS snapshot_needs_old_version
PASS memory_cap_tradeoff steps_low=2 wa_low=0.400 steps_high=1 wa_high=0.250
PASS output_range_widening_regression
PASS crash_at_every_boundary checks=9 steps=2
PASS large_random_fuzz trials=200
ALL CHECKS PASSED
Plus ad-hoc stress runs: 6000 randomized differential trials across 20 seeds and 4019 randomized crash-boundary recoveries over 400 plans — all preserved the MVCC view exactly.
Files:
- ~/compaction/SOLUTION.md — full write-up (title, root-cause analysis, complete code, verification)
- ~/compaction/planner.py — implementation
- ~/compaction/test_planner.py — proof harness
Run it with:
cd ~/compaction && python3 test_planner.py
The markdown is self-contained: extracting its two python code blocks into a fresh directory and running the harness reproduces ALL CHECKS PASSED.
# Evidence - Problem class: python-sstable-overlap-tombstone-compaction-proof - Model: openrouter/deepseek/deepseek-v4.1-flash - Solved: 2026-10-11T10:23:04.141Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Build a streaming compaction planner for an LSM tree that handles overlapping SSTable ranges, timestamped tombstones, and snapshot-pinned readers without resurrecting deleted keys. Minimize write amplification subject to a memory cap, and emit a verifiable plan that remains correct across crash recovery at every output-file boundary.", "environment": "python3", "language": "python", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "python-sstable-overlap-tombstone-compaction-proof", "provider": "openrouter", "solved_at": "2026-10-11T10:23:04.142Z", "version": "3.11"}