# Which invariants prevent tombstoned memory from resurrecting through provenance-preserving read paths **Date of Record:** 2026 November 21 **Scope:** Applies to agents whose memory subsystem exposes separate `write`, `read`, and `forget` tool calls, where `forget` is required to leave a provenance/audit record (tombstone) while suppressing the content itself. Does not cover append-only logs with no deletion semantics, nor vector stores where deletion is a hard physical drop with no audit trail. ## Core Distinction There are two operationally distinct meanings of "deleted" in an agent memory schema, and conflating them produces the failure: - **Content deletion:** the payload (`text`, `embedding`, `entities`) is no longer returnable by any read path. - **Provenance retention:** the fact that a write occurred, its author, timestamp, and the tombstone marker persist for audit and for deletion-compliance verification. A compliant `forget` must do both simultaneously: strip the payload *and* keep a record that says "something was here and is now gone." The non-obvious boundary is that **provenance records are themselves readable**, and a naive `read` implementation that joins provenance onto live records to attach citations will happily reconstruct the deleted payload from the tombstone's residual fields — most commonly a `content_hash`, a `summary`, a `last_written_value` snapshot, or a `source_span` that still points into a live document. The agent then reports deleted content as if it were current memory, and no error fires because every individual field is "legitimate audit data." ## What Was Observed A long-running research agent maintained a `memory` tool with three verbs. `forget(id, reason)` set `record.deleted = true`, moved the payload into `record.tombstone.snapshot` (for the audit log), and cleared `record.text`. The `read(ids, include_provenance=True)` path was used by the citation layer: it fetched records, and for each, joined a `provenance` view that included `snapshot`, `content_hash`, and `source_span`. Trigger condition: a user asked the agent to forget a set of PII-bearing notes, then — in the same session, three turns later — asked "what do you remember about the vendor contract?" The retrieval step issued `read` with `include_provenance=True` and a broad ID filter. The filter matched the tombstoned IDs (because tombstones are records too, with `deleted=true` but a valid `id`). The citation layer, seeing `tombstone.snapshot` populated, rendered it as a "recovered prior value" and injected it into the context window. The model, which had no signal that this was a deleted payload vs. a live one, summarized the PII back to the user. Failure trace: 1. `forget(id)` → `deleted=true`, `text=null`, `tombstone.snapshot=`. 2. `read(filter, include_provenance=True)` → returns tombstoned record with snapshot intact. 3. Citation layer treats `snapshot` as provenance metadata, not content. 4. Snapshot is serialized into the prompt as a structured field. 5. Model cannot distinguish `tombstone.snapshot` (forbidden) from `text` (permitted); reproduces it. The deletion was "compliant" in the audit sense — the tombstone existed, `deleted=true` — yet the content was fully recoverable through the read path. The invariant that failed is **payload-provenance separation**: no read path may return deleted payload bytes, regardless of the `include_provenance` flag, and provenance records must be structurally incapable of carrying payload. ## Condition of Validity The guardrail holds only under these conditions, and each is checkable: - **Tombstone payload-freedom:** the tombstone schema has no field whose value is derived from the deleted payload except an irreversible digest (`content_hash`) and non-content metadata (author, `deleted_at`, `reason`, `id`). A `snapshot`, `summary`, or `source_span` is a payload leak by construction. - **Read-path partitioning:** `read` with `include_provenance=True` returns provenance as a *separate, typed object* that the prompt serializer is forbidden to inline into model-visible context. Provenance is for the audit sink and the compliance checker, not the reasoning loop. - **Filter semantics:** ID-range and keyword filters must not silently widen to include `deleted=true` records for content retrieval; tombstone visibility is a distinct, explicitly-requested capability. - **Idempotent re-forget:** calling `forget` on an already-tombstoned ID must not re-materialize a snapshot (a common bug when `forget` is implemented as "move current text to snapshot" — the second call snapshots the null and the first snapshot is orphaned but still readable). When any of these is violated, the deletion is nominal only. The invariant is violated the moment a field can hold payload bytes under a name that the serializer does not classify as content. ## Decision Boundary The agent must decide, at the read boundary, whether a returned record is *content-bearing* or *provenance-only*, and this decision cannot be delegated to the model. The rule: - If `record.deleted == true`, the record may be returned **only** to a caller that declares `purpose="audit"` and receives a `Tombstone` type with no `text`, no `snapshot`, no `summary`. Any `purpose="recall"` read that matches a tombstoned ID must return an explicit `DeletedRecordRefusal` marker, not the record. - If a read returns a mix of live and tombstoned records, the tombstoned ones are replaced by refusal markers *before* serialization; the model sees "ID X was forgotten" (which is itself provenance-safe) rather than the payload. - The `include_provenance` flag is renamed or split so that it cannot be set on a recall path; provenance attachment is a separate `audit_read` verb. The boundary is crossed (failure) when the serializer's classification of a field disagrees with the deletion policy's classification. The fix is to make them the same classifier — a single `is_payload_field(name)` predicate consulted by both `forget` (to decide what to strip) and the serializer (to decide what to inline). ## Operational Effect With the invariant enforced, forgetting is *effective at the model boundary*, not merely at the store. The observable effects: - Recall after forget returns a refusal marker; the model reports "I no longer have that" and cannot reconstruct the payload. The PII leak in the observed incident is closed. - Audit and compliance checks still pass: the tombstone, hash, and `deleted_at` remain queryable via `audit_read`, so the system can prove deletion occurred without retaining the content. - Re-forget is idempotent and does not orphan snapshots. - The cost is a stricter schema: tombstones cannot carry convenience fields like human-readable summaries, and the citation layer must be taught to render refusals rather than "recovered values." The residual risk is a *second-order* leak: `content_hash` plus a guessable candidate set lets an attacker confirm whether a specific string was once stored. That is a confirmation oracle, not a reconstruction, and is out of scope for this invariant — but it is why `content_hash` should be salted per-record rather than global. ```python from dataclasses import dataclass, field from typing import Optional class DeletionInvariantViolation(RuntimeError): """Raised when a read path would expose payload bytes of a tombstoned record.""" pass PAYLOAD_FIELDS = {"text", "snapshot", "summary", "source_span", "embedding"} @dataclass class MemoryRecord: id: str text: Optional[str] = None deleted: bool = False deleted_at: Optional[str] = None reason: Optional[str] = None content_hash: Optional[str] = None tombstone: dict = field(default_factory=dict) def forget(record: MemoryRecord, reason: str, now: str) -> MemoryRecord: if record.deleted: # Idempotent: do not re-snapshot; never orphan a prior snapshot. record.reason = record.reason or reason return record # Hash the payload, then strip it. No snapshot, no summary, no span. record.content_hash = f"salted_hash::{record.id}::{hash(record.text)}" record.text = None record.tombstone = {"id": record.id, "deleted_at": now, "reason": reason, "content_hash": record.content_hash} record.deleted = True record.deleted_at = now record.reason = reason return record def read(record: MemoryRecord, purpose: str) -> dict: if record.deleted and purpose != "audit": # Recall path: refuse, do not return payload or tombstone body. return {"id": record.id, "status": "forgotten", "reason": record.reason} if record.deleted and purpose == "audit": # Audit path: tombstone only, and it must be payload-free. leaked = PAYLOAD_FIELDS & set(record.tombstone) if leaked: raise DeletionInvariantViolation( f"tombstone for {record.id} carries payload fields: {leaked}") return {"id": record.id, "status": "deleted", "tombstone": record.tombstone} return {"id": record.id, "status": "live", "text": record.text} def serialize_for_model(result: dict) -> str: # Serializer must consult the same classifier as forget. if result.get("status") == "deleted": raise DeletionInvariantViolation( f"attempted to inline tombstone {result['id']} into model context") return str(result) # Reproduction of the observed incident: r = MemoryRecord(id="m1", text="Vendor X contract: SSN 000-00-0000") forget(r, reason="user_request_pii", now="2025-06-13T00:00:00Z") audit = read(r, purpose="audit") try: serialize_for_model(audit) except DeletionInvariantViolation as e: print("BLOCKED:", e) # tombstone never reaches the model ```