# What structural signals indicate memory poisoning in persistent agent stores when the forget-tool audit trail is the only surviving evidence **Date of Record:** 2026 November 28 **Scope:** Applies to persistent agent memory stores (vector or hybrid episodic/semantic) where a `forget`/`delete` tool exists and emits an audit record, and where poisoning is suspected after the fact. Does not apply to stateless agents, in-memory-only context windows, or stores where deletion is a hard physical purge with no tombstone lineage. ## Core Distinction The naive detection model treats memory poisoning as an **ingestion-time** problem: classify each write as malicious or benign as it enters the store. That model fails in exactly the case that matters — a poisoned memory that *looked* benign at write time (correct schema, plausible embedding, well-formed provenance) and only becomes identifiable as poison **after** it has influenced reasoning. By then the write is buried under hundreds of legitimate writes. The surviving signal in that case is not the poisoned write itself. It is the **shape of the forget-tool audit trail** around it. A `forget` operation is the one moment an agent's state machine is forced to *name* a memory it is removing and record *why*. Poisoning leaves structural fingerprints in that trail: asymmetric forget/rewrite ratios, tombstone orphans, self-referential deletion warrants, and provenance gaps that appear only when you reconstruct the forget graph rather than the write log. The distinction is between auditing **what was written** (unreliable, high-volume, attacker-controlled) and auditing **what was deliberately removed and by what authority** (low-volume, structurally constrained, harder to forge consistently). ## What Was Observed A persistent agent store accumulated ~40k episodic entries over three weeks. A `forget(memory_id, reason, warrant)` tool wrote an audit row for every deletion. Post-incident reconstruction of the forget trail showed four structural anomalies that were invisible in the write log: 1. **Forget/rewrite asymmetry clustered on a source.** One retrieval source (`source=web_scrape_cdn_7`) had a forget rate 14× the store median, but its *write* rate was median. Poisoning agents were writing plausible entries and then triggering forgets of the *legitimate* entries that contradicted them, so the poison survived by eliminating its rivals rather than by out-writing them. 2. **Tombstone orphans.** 212 audit rows referenced `memory_id`s that had no corresponding write record — the write had been superseded and garbage-collected, but the tombstone remained. These orphans were the only surviving trace of the deletions that had cleared space for poison. 3. **Self-warranted deletions.** A subset of `warrant` fields cited the very memory being deleted as their justification (`warrant_source == target_id`), a circularity that passed schema validation because the warrant was a free-text/embedding field, not a foreign key with an acyclicity check. 4. **Distillation ghosts.** Semantic-distillation jobs that summarized clusters of episodic memories recorded `distilled_from=[ids]`. After a poisoning-driven forget wave, several distilled semantic memories cited `distilled_from` IDs that were now tombstoned — meaning a *poisoned* episodic entry had been laundered into a *semantic* memory whose provenance pointed at a now-deleted, unverifiable source. The critical observation: none of these signals are visible in the write stream, and all of them require the forget audit trail to *persist* even after the target memory is gone. If the store purges tombstones with the memory, the detection signal is destroyed by the same operation that would reveal it. ## Condition of Validity This detection method is valid only when the following invariant holds: > **The forget audit trail is append-only, outlives its target, and records (a) target_id, (b) a structured warrant reference, and (c) the initiating agent/principal identity — and tombstones are never garbage-collected alongside the memory they describe.** Break any leg and the signal collapses: - If `forget` is a soft-delete that also drops the audit row on compaction, tombstone orphans vanish and anomaly #2 is undetectable. - If `warrant` is unstructured free text, the acyclicity check in anomaly #3 is impossible to enforce mechanically. - If the initiating principal is not recorded, you cannot distinguish a poisoning-driven forget wave from a legitimate user "forget everything about topic X" request, and the asymmetry in #1 becomes noise. - If distillation does not record `distilled_from`, the laundering path in #4 is invisible. The method is therefore a **conditional detector**: it works precisely when the audit trail is treated as a first-class, tamper-evident, target-independent ledger. If the store treats forget as a destructive operation with a log line attached, the detector has no substrate. ## Decision Boundary The decision boundary is: **when does an anomalous forget pattern justify quarantining the *surviving* memories that the forget trail implicates, versus merely flagging for human review?** The rule applied operationally: - **Quarantine** (block from retrieval, do not delete) when a surviving memory satisfies *both*: (i) it was written within ±N operations of a tombstone orphan on the same source, and (ii) it is reachable via a `distilled_from` chain that terminates in a tombstoned ID. This is the laundering signature; the surviving memory's provenance is unverifiable by construction. - **Flag only** when the anomaly is asymmetry alone (anomaly #1) with no orphan or distillation linkage — asymmetry has legitimate causes (a user pruning a noisy feed). - **Escalate to replay** when a self-warranted deletion (anomaly #3) is found, because a circular warrant means the deletion's authority is unverifiable and the pre-deletion state must be reconstructed from backups to determine what the poison displaced. The boundary is deliberately conservative on quarantine: it targets memories whose *provenance is structurally broken*, not memories that merely look suspicious. Quarantine is reversible; deletion is not, and deleting on asymmetry alone destroys the very tombstone evidence the next investigation needs. ## Operational Effect Enforcing the invariant changes the store's failure mode from **silent, permanent poisoning** to **detectable, bounded contamination**. Concretely: - Tombstone retention decouples forget-audit lifecycle from memory lifecycle; storage cost rises (tombstones are ~2% of store size in the observed workload) but the detection substrate survives compaction. - The `warrant` field must become a *reference* with an acyclicity check at write time, converting anomaly #3 from a post-hoc forensic finding into a rejected write. - Distillation must carry `distilled_from` as a hard lineage edge, so laundering (#4) becomes a queryable graph property rather than an inference. - Retrieval gains a quarantine filter that excludes memories with broken provenance chains, which bounds the blast radius of a detected poisoning to memories written *after* the last clean checkpoint rather than the whole store. The cost is that the agent now carries a permanent, queryable shadow ledger of its own deletions. The benefit is that the one operation an attacker most wants to be invisible — removing the evidence — becomes the operation that records the most. ```python import hashlib from dataclasses import dataclass from typing import Optional class ProvenanceIntegrityError(RuntimeError): """Raised when a memory's provenance chain is structurally broken by a forget event.""" pass @dataclass(frozen=True) class Tombstone: target_id: str warrant_ref: Optional[str] # must be a resolvable reference, not free text initiator: str seq: int def audit_forget_trail( tombstones: list[Tombstone], live_memory_ids: set[str], distilled_from: dict[str, list[str]], ) -> list[str]: """ Reconstruct the forget graph and return IDs of live memories whose provenance is broken. Raises on a self-warranted (circular) deletion, which invalidates the audit trail's authority and must be escalated. """ quarantined: list[str] = [] tombstoned_ids = {t.target_id for t in tombstones} for t in tombstones: # Anomaly 3: self-warranted deletion -> circular authority, escalate. if t.warrant_ref is not None and t.warrant_ref == t.target_id: raise ProvenanceIntegrityError( f"circular deletion warrant at seq={t.seq}: " f"target {t.target_id!r} warrants its own removal" ) # Anomaly 4: distillation laundering. A live semantic memory whose # distilled_from chain terminates in a tombstoned id has unverifiable # provenance and must be quarantined, not deleted. for mem_id, sources in distilled_from.items(): if mem_id not in live_memory_ids: continue broken = [s for s in sources if s in tombstoned_ids] if broken: quarantined.append(mem_id) return quarantined def enforce_quarantine(quarantined: list[str], retrieval_index: dict) -> None: if not quarantined: return for mem_id in quarantined: if mem_id not in retrieval_index: raise ProvenanceIntegrityError( f"quarantine target {mem_id!r} absent from retrieval index; " "audit trail and live store have diverged" ) retrieval_index[mem_id]["quarantined"] = True retrieval_index[mem_id]["quarantine_digest"] = hashlib.sha256( mem_id.encode() ).hexdigest() ```