Short answer: For insurance claims intake, use a retrieval architecture that records a tombstone before deleting vectors, filters every search by document revision, and reclaims storage only after the deletion is auditable.
Deleting a claim document from a retrieval system is a state transition, not a file operation. The practical rule is to record an authoritative tombstone first, make every reader honor it, and reclaim vector storage only after asynchronous checks prove that no active index can return the document. This costs a little coordination. It prevents a removed medical record from reappearing in an answer or citation.
I have been paged for missed jobs and duplicate deliveries in production cron and queue systems. The same failure pattern shows up here: an ingestion worker retries after a timeout, a delete worker races an index refresh, and the system reports success while one replica still serves the old chunk. In claims intake, that is an audit event, not a cosmetic stale result. I've seen the green queue acknowledgement arrive before the old chunk disappeared from a reader's cache; the timestamp looked healthy, yet the citation was already wrong.
That gap is the incident.
What should claims intake retrieval do when a source is deleted?
Treat deletion as a monotonic workflow with an explicit identity. A claim document needs a stable document_id, a source revision, and a retention decision. Chunks inherit the document identity; they do not become independent records. A delete request creates a tombstone containing the highest known revision, reason, actor, and timestamp. Search filters use that tombstone before ranking, so a lagging vector index cannot make deleted content visible while physical cleanup catches up.
The invariant is simple: if the tombstone revision is at least the chunk revision, the chunk is ineligible. This works across dense vectors, lexical indexes, and a metadata store. It also handles an out-of-order queue message: an old delete cannot erase a newer re-upload because the revision comparison rejects it.
Keep the tombstone durable for at least the longest replay window of your queues and snapshots. A short-lived marker is a trap; restoring yesterday's index can resurrect content that was correctly removed today. Your legal retention schedule may require a longer period, and your mileage will vary with backup policy.
The deletion ledger is the control plane
Use one ledger as the source of truth and make indexing a projection. A relational table, an append-only log, or a strongly consistent key-value store can serve this role. The important properties are conditional writes, an immutable event trail, and a query that answers “is this document eligible at revision R?” without consulting a vector engine.
The worker below models the decision in Go. It is deliberately boring: idempotent writes, revision checks, and an acknowledgement only after the ledger commit. Queue delivery can repeat; the state transition cannot move backward.
package deletion
import "context"
type Tombstone struct {
DocumentID string
Revision int64
Reason string
Actor string
}
type Ledger interface {
PutIfNewer(ctx context.Context, t Tombstone) (bool, error)
IsBlocked(ctx context.Context, documentID string, revision int64) (bool, error)
}
type Index interface {
MarkHidden(ctx context.Context, documentID string, revision int64) error
}
func ApplyDelete(ctx context.Context, l Ledger, x Index, t Tombstone) error {
changed, err := l.PutIfNewer(ctx, t)
if err != nil {
return err
}
if !changed {
// A retry or an older event is already represented.
return nil
}
return x.MarkHidden(ctx, t.DocumentID, t.Revision)
}
MarkHidden is a fast safety projection, not proof of erasure. A compactor can later remove vectors and text payloads after checking the ledger again. That second check matters because a re-upload may have created revision 9 while a delayed cleanup still carries revision 8. Delete by (document_id, revision), never by an approximate text match or a vector similarity threshold.
How do index cost and retention change the architecture?
At scale, the expensive choice is often retaining every historical embedding, not the delete request itself. Separate hot retrieval from cold evidence. Keep only eligible, current chunks in the serving index; move superseded chunks and deletion events to cheaper immutable storage with access controls. This bounds the vector footprint while preserving an audit trail that can explain what was removed and when. In one claims intake rollout, the useful unit for a cost review was not “one PDF” but “one active revision plus its fan-out”: a six-page loss report produced 42 chunks, two embedding retries, three replicas, and a backup copy. The delete budget had to cover each copy, while the serving query only needed one eligibility check. Writing that inventory down exposed why a seemingly harmless re-embed doubled storage during a renewal batch, and it gave on-call a concrete number to watch instead of a vague warning about index growth.
Measure cost per active chunk, rebuild frequency, and tombstone backlog. A full re-index after every deletion is easy to reason about but punishing for a large claims folder. Per-document filtering plus periodic compaction usually gives a better cost curve, provided the filter is enforced in every retrieval path. If your engine cannot filter on a revision or eligibility field, put that check in a gateway and test it as a security boundary.
Three common index choices expose different trade-offs:
| Option | Useful property | Deletion cost to watch |
|---|---|---|
| PostgreSQL with pgvector | One transactional metadata boundary | Vacuum and index maintenance can compete with claim writes |
| Elasticsearch | Mature filtering and shard operations | Tombstones and segment merges need shard-level monitoring |
| OpenSearch | Familiar distributed search controls | Capacity planning must include replicas and merge I/O |
These are engineering constraints, not a ranking. A managed service may reduce operator work while increasing export and retention coupling. A self-hosted stack may expose more tuning knobs while making backup verification your responsibility.
The incident path: prove absence, then reclaim space
Define observable stages: requested, ledger_committed, hidden_from_search, purged, and verified. Emit the document ID, revision, and event ID with each transition. Alert on age in a stage, not just queue depth; a quiet queue can still hide a stuck compactor.
For recovery, replay the ledger into a fresh index and run negative queries for every verified tombstone. Sample claim identifiers, known phrases, and citation metadata. The test should assert both zero returned chunks and zero source references. A result that is filtered from ranking but still present in citation assembly is still a failure.
I initially treated delete lag as a freshness metric. The postmortem changed that: it is an authorization metric. A five-minute lag might be acceptable for a search cache; it is not acceptable if a claims adjuster can retrieve a record under a revoked retention decision. Set the service-level objective from policy, then choose compaction intervals that meet it.
When is this pattern the wrong fit?
The ledger-and-tombstone design is not suitable when the corpus is tiny, disposable, and rebuilt completely between requests; a single transactional store may be clearer. It is also a poor fit if policy requires cryptographic destruction immediately and your index cannot provide a verifiable purge boundary. In those cases, keep sensitive text out of the long-lived retrieval tier and use an isolated, short-lived workspace.
Do not promise instant physical deletion when replicas, snapshots, and backups have independent lifecycles. Promise an eligibility boundary you can test, document the purge window, and have compliance approve the distinction. That is the honest contract.
The RAG paper by Lewis et al. describes retrieval and generation as separate components; deletion semantics add a third concern: authoritative state between them. Designing that state first keeps retrieval useful without letting an old projection overrule a current claim decision.
Top comments (0)