Claude Code's compaction discards data that's still on disk
Source: Dev.to
What happened
Compaction removed physical files that metadata still referenced. This is a metadata↔disk ordering/race condition—deletion happened before durable metadata confirmation, leaving live references to missing data.
Why it matters
- Silent corruption: apps expect compaction to be safe.
- When files disappear while indexes still point at them, you can get lost vectors, corrupted sessions, or errors that only surface under load or during recovery.
Takeaway for builders
- Stop blind deletes.
- Use a retention window and two‑phase deletes (mark → confirm → delete).
- Employ
fsync/atomic renames. - Implement end‑to‑end integrity checks and frequent snapshots.
- Run chaos tests for compaction.
Reference: Claude Code’s compaction discarded data still on disk — bug report & discussion