Backend & Distributed Systems
Tombstones for Delete and Reseed Safety
How to permanently delete user-visible records while preventing startup seed logic from recreating the same unwanted item.
Seed data is useful for first-run setup, but it can fight user intent. A common failure is: the user deletes a seeded task, the application restarts, and initialization inserts it again because the row is missing. The visible record should be permanently deleted, while a small tombstone records that this seed must not return.
Separate retention from suppression
A universal soft-delete column keeps the entire record, including notes that the user expected to remove. This design deletes the task row and stores only the minimum suppression key and deletion time:
CREATE TABLE task_tombstones (
title TEXT PRIMARY KEY,
deleted_at TEXT NOT NULL
);Startup insertion then requires two negative conditions: no live task with that title and no matching tombstone. The tombstone is not a hidden copy of the task and contains no note body.
Transactions protect intent
Deleting the row and writing the tombstone must succeed together. If the process crashes between the two operations, the next startup can resurrect the item. A transaction or a database batch gives the two statements one commit boundary.
The suppression key also needs a stable definition. Titles work for a small fixed seed catalog, but a larger product should assign immutable seed IDs so wording changes do not bypass the tombstone.
End-to-end evidence matters
The production-like test created a uniquely named task, reloaded the API, modified status and notes, deleted it, and reloaded again. The task count returned to its original value and the known academic item stayed intact. The temporary tombstone remained, which is the intended evidence that deletion survives initialization. This pattern is useful when bootstrap defaults exist, but it should not be applied blindly to user-created records that have no reseeding path.
Related writing
Backend & Distributed Systems
Capacity-Aware Weekly Planning with Locking
A deterministic weekly planning API that protects deadlines, respects time capacity, limits daily load, and locks accepted plans.
Backend & Distributed Systems
Idempotent Session Writes with Conflict Detection
A production-minded API design for retry-safe learning session writes, semantic conflict detection, and response-loss recovery.
Backend & Distributed Systems
Domain Ledgers on D1 for a Learning OS
Evolving a task application into explicit goal, plan, attempt, error, review, and evidence ledgers without a risky rewrite.