2026 Retrieval Tombstones for Engineering Docs That Must Forget
A one-person SaaS has a blunt constraint: stale search results cost more engineering time than a slightly slower index. This internal engineering documentation retrieval architecture keeps delete semantics explicit. In a game-listings aggregator, a deleted offer can remain in a runbook, then get copied into a support answer.
Short answer: treat deletion as a versioned state transition, publish tombstones before removing vectors, and make every retrieval result prove that its source is still visible.
The failure is temporal, not lexical
Chunking and embeddings get most of the attention in retrieval-augmented generation. Delete semantics are the quieter failure. A document disappears from the source database at 10:03, but a worker may not see the event until 10:07. The vector store can still return the old chunk at 10:08, and a language model will produce a perfectly fluent answer from it.
The same pattern appears in our gaming dataset. A listing has a seller, region, platform, and expiration time. An internal engineering page explains how those fields are normalized. If the listing is removed for a rights request, the page may be updated too. Two independent indexes now need one deletion decision, and retries must not resurrect either record.
I first thought a hard delete was enough. It was not. A retry from an older ingestion job could reinsert a vector after the row was gone. The fix was to make visibility monotonic: once a source version is marked deleted, a lower version can never become searchable again.
What should retrieval architecture do when internal documentation is deleted?
Start with an event carrying identity and version, not with a storage operation. The event is small enough to audit:
type DocumentDelete = {
documentId: string;
sourceVersion: number;
deletedAt: string;
reason: "retired" | "rights" | "correction";
};
The ingestion service writes this event to a durable log. An index worker consumes it idempotently. It writes a tombstone keyed by documentId, sourceVersion, and tenant, then removes or hides all chunks belonging to that version. A query filter checks the tombstone table before ranking.
That extra read sounds expensive. In practice, it is cheaper than debugging a support transcript that cites a removed price. Keep the tombstone lookup close to the metadata store, and cache only positive visibility decisions for a short time. Never cache “not deleted” for longer than the source can take to publish an event.
Hard deletion still matters for retention and privacy. It is a compaction step, not the correctness mechanism. A tombstone protects the gap between the delete event and physical garbage collection.
That gap is the trap.
A smallest working implementation
The following repository-neutral adapter separates semantic state from a particular vector database. The hide call can set a metadata flag, delete by filter, or move chunks to cold storage; the contract stays the same.
type Chunk = {
id: string;
documentId: string;
sourceVersion: number;
text: string;
};
type Index = {
upsert(chunks: Chunk[]): Promise<void>;
hide(documentId: string, sourceVersion: number): Promise<void>;
};
type Tombstones = {
latest(documentId: string): Promise<number | null>;
put(event: DocumentDelete): Promise<void>;
};
async function applyDelete(
event: DocumentDelete,
tombstones: Tombstones,
index: Index,
): Promise<void> {
const seen = await tombstones.latest(event.documentId);
if (seen !== null && seen >= event.sourceVersion) return;
await tombstones.put(event);
await index.hide(event.documentId, event.sourceVersion);
}
async function isVisible(
documentId: string,
sourceVersion: number,
tombstones: Tombstones,
): Promise<boolean> {
const deleted = await tombstones.latest(documentId);
return deleted === null || sourceVersion > deleted;
}
The ordering is deliberate. Persist the tombstone before hiding chunks. If the process stops after the first write, queries still reject the old version. If it stops after hiding, a replay can safely perform the same operation. The write path must use the same version check; otherwise an old upsert can win a race with a new delete.
For a query, retrieve candidates broadly, join their metadata with visibility state, and only then assemble context. Filtering after the model answers is too late.
Tests that catch resurrection matter more than a happy-path assertion. I run these timeline cases in CI:
- delete version 8, replay delete version 8, and verify one visible state;
- deliver delete version 9 before an upsert for version 8, then verify version 8 is rejected;
- deliver an upsert for version 10 after delete version 9, then verify only version 10 can be retrieved;
- lose the worker after the tombstone write and replay the event;
- run two workers concurrently and verify the higher version wins.
Property-based tests are a good fit: generate shuffled event streams and assert that the visible version is always greater than the latest tombstoned version. Add a metric for “retrieved candidate rejected by tombstone.” A sudden rise means lag or an incorrectly scoped filter, not a mysterious model problem.
What changes at scale, and when this design is wrong
At small scale, a relational table with a unique (tenant, document_id) key and a monotonically increasing version is enough. At larger scale, partition tombstones by tenant and time, replicate them with the same durability target as the index, and compact only after every consumer has acknowledged the delete watermark. Store the source event ID so replay can be audited.
The catch is operational overhead. Tombstones consume storage, every query may need a metadata join, and an eventually consistent source can still expose a deleted page before its event arrives. This design is not suitable when legal erasure requires an immediate, cryptographically verifiable purge across replicas; use a storage system with a documented synchronous deletion guarantee and accept its write cost. Stick with a simple rebuildable index when the corpus is public, disposable, and never used for access decisions.
I am not sure a single global watermark is worth the coordination in a multi-region setup; your mileage may vary. Measure delete-to-invisibility latency, resurrection count, and context rejection rate for two weeks before adding that machinery. The revenue-per-hour test is simple: ship weekly, outsource undifferentiated index plumbing, and spend your scarce time on the ranking behavior users can actually feel.
Top comments (0)