FullStack AI Hub
Studio
lesson depth
Mastery
not started · 0%

AI Retention, Deletion, and Audit

Make retention and deletion propagate through derived indexes, caches, traces, evaluations, and backups with auditable evidence.

Freshness: current•14 min read•Security, Safety, and Governance

Key Learning Outcomes

  • ✓Explain the operating model behind AI Retention, Deletion, and Audit.
  • ✓Evaluate trade-offs and failure modes for AI Retention, Deletion, and Audit.
  • ✓Apply AI Retention, Deletion, and Audit to a production decision.
Full Technical Reference Document

Mental model

Data deletion in AI applications is a multi-hop lineage operation across every derived artifact rather than a single database delete. Prompts, GPU KV-cache pages, semantic caches, HNSW vector shards, tenant LoRA weights, and evaluation snapshots must purge deterministically via tombstones, epoch invalidation, or per-tenant DEK crypto-shredding with immutable W3C-PROV receipts.

Provenance lineage graph
Live KV and cache epoch bump
Vector tombstone and compaction
Tenant DEK crypto-shredding
Hash-chained W3C-PROV receipt
Conceptual teaching model synthesized from:NIST Privacy FrameworkPROV OverviewData Controls in the OpenAI Platform

Learning outcomes

  • Map data retention boundaries across raw inference prompts, GPU KV-cache prefix trees, RAG vector chunks, tenant LoRA adapters, and offline backups.
  • Implement crypto-shredding using per-tenant envelope Data Encryption Keys (DEKs) so immutable object backups become unrecoverable without full rewrites.
  • Coordinate synchronous vector tombstones with asynchronous HNSW segment compaction to close post-deletion retrieval leakage.
  • Emit tamper-evident W3C-PROV lineage logs and hash-chained deletion receipts without copying deleted sensitive payloads into the audit store.

Theory

Under the NIST Privacy Framework and modern enterprise data controls, erasing a customer record requires controlling every downstream representation derived from it. Unlike standard CRUD systems where one primary row owns state, LLM platforms scatter derived state across five layers: transient prompt/completion buffers (governed by zero-data-retention API agreements or bounded 30-day abuse logs), GPU prefix KV-cache blocks, approximate nearest-neighbor (ANN) vector shards, fine-tuned LoRA adapters, and immutable telemetry plus evaluation archives.

To guarantee provable erasure without rewriting multi-terabyte Parquet lakes or immutable backups, platforms pair W3C-PROV provenance graphs with envelope crypto-shredding. Under W3C PROV, every chunk, vector, cache entry, and eval row tracks wasDerivedFrom and wasGeneratedBy links tying it to (tenant_id, doc_id, artifact_version). When encrypting backups and traces at rest, each tenant owns an isolated Data Encryption Key (DEK) wrapped by a KMS Key Encryption Key (KEK). Destroying that tenant's DEK cryptographically shreds every historical backup, trace, and eval dump simultaneously in constant time.

For live vector indexes and caches, key destruction alone leaves decrypted vectors exposed in RAM or HNSW graphs. Erasure therefore executes three bounded operations:

  1. Vector tombstones and segment compaction: Write an atomic tombstone into the shard bitmap so ANN queries block deleted chunks immediately, then trigger background compaction to rebuild HNSW links and quantized codebooks without deleted nodes.
  2. Cache and prefix KV invalidation: Bump the tenant cache epoch (tenant_epoch += 1) and evict prefix-cached KV blocks linked to deleted system or document prefixes.
  3. Model adaptation boundary: Store tenant knowledge in retrievable RAG shards or isolated per-tenant LoRA adapters that can be unmounted and shredded independently; never fold tenant PII into shared base weights.

Formally, the residual exposure window TpurgeT_{\text{purge}} across derived tiers satisfies:

Tpurge=max⁡(Tcache_epoch,  Ttombstone+Tcompact,  Tdek_revoke)T_{\text{purge}} = \max\left(T_{\text{cache\_epoch}},\; T_{\text{tombstone}} + T_{\text{compact}},\; T_{\text{dek\_revoke}}\right)

And each purge step appends a hash-chained receipt binding only cryptographic digests—never raw user text:

Hn=SHA256(Hn−1 ∥ SHA256(tenant_id) ∥ artifact_digest ∥ tn)H_n = \text{SHA256}\Big(H_{n-1} \,\|\, \text{SHA256}(\text{tenant\_id}) \,\|\, \text{artifact\_digest} \,\|\, t_n\Big)

Worked quantitative example

Suppose an enterprise tenant erases 12,400 documents (49,600 vector chunks across 4 HNSW shards), 180 semantic cache keys, 1 tenant LoRA adapter (140 MB), and 90 immutable daily S3 Parquet backups totaling 4.2 TB across all tenants.

Without crypto-shredding, rewriting 90 Parquet archives to strip 12,400 documents requires scanning and re-uploading 4.2 TB—consuming hours of batch compute. With per-tenant envelope encryption, revoking the tenant's 256-bit KMS DEK completes in < 250 ms across all 90 snapshots at once. On the live serving tier, incrementing the cache/KV epoch invalidates live hits in < 100 ms, vector tombstones hide all 49,600 chunks from ANN recall in < 2 s, async compaction expunges HNSW graph nodes within 18 minutes, and unlinking the LoRA frees 140 MB—bringing live leakage exposure under 2 s and full physical/cryptographic purge under 20 minutes.

Retention boundary and deletion matrix

AI Artifact ClassRetention ScopeDeletion MechanismW3C-PROV Audit Proof
Prompt & Completion BuffersZero retention or <= 30d abuse TTLMemory zeroization / ZDR / short TTLPolicy mode flag + request digest
Prefix KV Cache & Semantic CacheEphemeral inference windowEpoch version bump & page evictionCache epoch transition receipt
Vector Index Chunks & ANN GraphActive tenant corpus lifetimeSynchronous tombstone + shard compactionShard compaction Merkle root
Per-Tenant LoRA vs Base WeightsTenant isolation / shared immutableAdapter unlink + DEK shred (never shared base)Adapter digest & destroy timestamp
Telemetry & Eval ArchivesCompliance window (90d–365d)Per-tenant DEK crypto-shreddingKMS key-destruction event hash

Trade-offs

Crypto-shredding per-tenant DEKs handles immutable backups cleanly, yet requires strict KMS boundary hygiene: sharing a DEK across tenants causes collateral data loss upon revocation. Per-document DEKs support finer erasure inside immutable archives, at the cost of higher KMS metadata overhead unless keys derive hierarchically via HKDF from a tenant root secret.

Similarly, immediate full HNSW index rebuilds physically purge memory instantly, yet frequent synchronous rebuilds degrade write throughput and search P99 latency. Pairing instant bitmap tombstones (< 2 s logical invisibility) with threshold compaction (rebuilding shards once tombstones pass 10%) balances privacy guarantees against predictable query latency.

Failure modes and misconceptions

  • Deleting only the primary SQL row. Leaving chunk embeddings, BM25 inverted terms, and semantic cache hits intact lets future prompts surface erased text.
  • Recording deleted user content inside audit receipts. Writing raw prompts or filenames into an append-only ledger violates the erasure mandate itself. Log only salted SHA-256 digests, counts, provenance IDs, and timestamps.
  • Training multi-tenant PII into shared base weights. Dense weights entangle training tokens globally, making deterministic single-tenant unlearning unreliable compared with RAG deletion or isolated LoRA weights.
  • Leaving soft-delete tombstones uncompacted indefinitely. Uncompacted tombstones linger inside disk segments and quantized codebooks, inflating memory footprint and forensic recovery risk.
  • Overlooking upstream inference provider retention settings. Sending prompts without verified Zero Data Retention (ZDR) endpoints leaves sensitive payloads in provider 30-day abuse logs.

Decision scenario

A healthcare customer triggers GDPR Article 17 erasure after indexing 3,200 manuals into HNSW vector shards, Redis semantic caches, weekly S3 Parquet eval dumps, and a cloud LLM gateway. Auditors require tamper-evident proof within 24 hours that erased records cannot resurface.

Verify all upstream LLM endpoints enforce Zero Data Retention headers so zero provider logs retain tenant text. Next, query the W3C-PROV lineage graph by tenant_hash to bump the Redis/KV epoch, apply vector shard tombstones, and force immediate shard compaction because erased vectors exceed 5% of shard volume. Revoke and destroy the tenant's KMS DEK so every historical Parquet eval archive becomes unreadable, run a canary retrieval probe verifying zero top-kk matches, and append the hash-chained deletion receipt.

Implementation example

This Python purge coordinator models W3C-PROV lineage propagation across cache epochs, vector tombstones, and envelope DEK crypto-shredding while emitting a hash-chained SHA-256 audit receipt without storing deleted text.

python
from dataclasses import dataclass, field
from hashlib import sha256
import time
​
@dataclass
class ProvDeletionLedger:
chain_head: str = "0" * 64
receipts: list[dict[str, str]] = field(default_factory=list)
​
def record(self, tenant_digest: str, activity: str, artifact_digest: str) -> str:
ts = f"{time.time():.6f}"
next_hash = sha256(f"{self.chain_head}|{tenant_digest}|{activity}|{artifact_digest}|{ts}".encode()).hexdigest()
self.receipts.append({"prev": self.chain_head, "hash": next_hash, "activity": activity, "artifact": artifact_digest})
self.chain_head = next_hash
return next_hash
​
class RetentionPurgeCoordinator:
def __init__(self) -> None:
self.tenant_deks = {"ten-7": "dek-live-v1"}
self.cache_epoch = {"ten-7": 1}
self.tombstones: set[str] = set()
self.ledger = ProvDeletionLedger()
​
def execute_erasure(self, tenant_id: str, chunk_ids: list[str]) -> str:
t_hash = sha256(f"tenant:{tenant_id}".encode()).hexdigest()
self.cache_epoch[tenant_id] = self.cache_epoch.get(tenant_id, 0) + 1
self.ledger.record(t_hash, "prov:InvalidateCacheEpoch", f"epoch:{self.cache_epoch[tenant_id]}")
self.tombstones.update(chunk_ids)
self.ledger.record(t_hash, "prov:TombstoneVectorChunks", sha256(",".join(sorted(chunk_ids)).encode()).hexdigest())
self.tenant_deks.pop(tenant_id, None) # Crypto-shred backups & eval Parquet archives
return self.ledger.record(t_hash, "prov:DestroyTenantDEK", "kms:dek-revoked")
​
coord = RetentionPurgeCoordinator()
head = coord.execute_erasure("ten-7", ["chk-101", "chk-102"])
assert "ten-7" not in coord.tenant_deks and len(coord.ledger.receipts) == 3 and len(head) == 64
Reflect before revealing the guide

Why must immutable backups and vector indexes combine per-tenant DEK crypto-shredding with tombstone compaction and hash-chained receipts without storing deleted payloads?

Prerequisites & Related Concepts (3)

Private notes

0 words
Included In Free Course
Free · Verifiable Credential

FS-201Production LLM Engineer

Design an observable full-stack LLM product from capability validation through interfaces retrieval evaluation security and operations.

37 concepts~35h self-paced
Start Free Course
Weekly Engineering Dispatch

Get the weekly systems teardown

One technical note per week covering inference bottlenecks, retrieval harnesses, and commit-pinned teardowns.