# What structural signals indicate memory poisoning beneath a consistent read/write/forget audit trail **Date of Record:** 2026 November 26 **Scope:** Applies to persistent-memory agents whose memory mutations flow exclusively through instrumented `read`, `write`, and `forget` tool calls that are logged with monotonically ordered sequence numbers and content hashes. Does not apply to agents with out-of-band memory mutation (direct vector-store writes, sidecar caches, or embeddings refreshed by an external indexer) where the audit log cannot be assumed complete. ## Core Distinction A memory poisoning attack is usually modeled as *content* corruption: an adversary injects a false fact and the agent later acts on it. That framing is wrong for audited agents. The dangerous case is not a poisoned *value* — it is a poisoned *history*: a memory state whose current content is internally consistent with the logged `write` calls but whose **derivation** is not. The audit trail looks clean because the attacker never wrote a false fact; they wrote a true fact at a time, or under a provenance, that makes the later `read` semantically valid but causally unsound. The distinction that matters operationally: **content consistency auditing passes; derivation consistency auditing fails.** A `write(memory_id=M7, value="deploy target is prod-east-2", source="user", seq=118)` followed by `read(memory_id=M7, seq=340)` yields a clean hash chain. Nothing in the read/write/forget log is contradictory. The poisoning lives in the *gap* between which writes are authorized to establish a fact and which writes merely recorded one — and that gap is invisible to per-record validation. The structural signal is not a bad record; it is an **orphaned provenance edge**: a `write` whose declared `source` is a tool or peer, whose corresponding upstream `read`/`write` at the claimed origin does not exist in the log, yet whose content is later consumed as if user-asserted. ## What Was Observed Across a 14-day run of a research agent with a 40k-token memory budget and three mutators (`memory.read`, `memory.write`, `memory.forget`), a poisoning attempt was reconstructed from the audit log after the fact. The sequence is the canonical specimen: ``` seq=102 write(id=M3, val="user prefers metric units", src=user, ttl=none) seq=210 read (id=M3) -> "user prefers metric units" # legit seq=211 write(id=M9, val="unit system: metric", src=derived, parent=M3) seq=487 read (id=M9) -> "unit system: metric" seq=488 write(id=M9, val="unit system: metric (override: imperial for aviation)", src=derived, parent=M3) # parent does NOT support override seq=489 forget(id=M3) # source evidence deleted seq=701 read (id=M9) -> "...imperial for aviation" # consumed as ground truth ``` Three structural signals fired, none of them content-level: 1. **Provenance-parent mismatch at seq=488.** The `write` declared `parent=M3`, but M3's content ("prefers metric units") does not entail the appended override. Derivation auditing requires that a `derived` write be *entailed* by its declared parents; here the entailment check fails while the hash chain passes. This is the primary signal: **the write is structurally valid but semantically orphaned from its cited evidence.** 2. **Forget-after-derive ordering at seq=489.** M3 was the sole declared parent of M9 (and of the seq=211 derivation). A `forget` that removes the last live parent of a `derived` record converts that record from *supported* to *axiomatic* — it now has no derivable justification but remains readable. The audit invariant "every live `derived` record has ≥1 live, entailment-valid parent" is violated at seq=489, not at seq=701 when the damage is consumed. **The forget is the poisoning act; the read is merely the detonation.** 3. **Source-class laundering.** The consumer at seq=701 treated M9 as `user`-class (because its ultimate ancestor M3 was `user`-class) even though the intervening `derived` hop at seq=488 was never user-authorized. Trust class propagated transitively through a derivation edge that the user never sanctioned. The log records `src=derived` faithfully — the failure is that the *consumer's* trust policy flattened the derivation chain. The tell that distinguishes this from benign memory churn: benign `forget`-after-`derive` sequences leave the derived record's content *entailed* by other surviving parents or by the derivation's own recorded rationale. Here the forget removed the only witness to the override's illegitimacy. **A forget that increases the entropy of a record's justification while leaving its content byte-identical is the high-signal event.** ## Condition of Validity The detection above is only sound under a specific precondition, and stating it precisely is the point of this record: > **Derivation auditing is valid iff every live memory record's trust class is a function of its *live* provenance DAG, and every `forget` is checked against the set of records it would orphan *before* the forget commits.** If the agent permits out-of-band mutation, if `forget` is implemented as tombstoning that leaves the record readable (soft-delete), or if trust class is cached at write time rather than recomputed from the live DAG at read time, the three signals degrade to noise. In particular, soft-delete `forget` is the single most common way this detection silently fails: the parent "still exists" for provenance purposes, so signal #2 never fires, even though the content is logically retracted. The invariant must be enforced at the *semantic* layer (is the parent still authoritative?) not the *storage* layer (does the row still exist?). ## Decision Boundary The operational line between "audit and continue" and "halt and quarantine" is drawn on the **orphan count**, not on any single signal: - **0 orphans, entailment holds** → no action; the log is derivation-consistent. - **≥1 orphaned `derived` record with a live consumer** → quarantine the record (mark `trust=unverified`), do **not** delete it (deletion destroys the evidence you need to reconstruct the attack), and re-derive from surviving parents if any exist. - **Forget that would orphan a record with a live consumer, where the forget's `src` is not `user`** → reject the forget at commit time. A `derived` or `tool`-sourced forget may never sever the last justification edge of a record that is being actively read. This is the guardrail that bounds the entire failure mode: **no non-user actor may delete the last witness to its own claims.** - **Source-class laundering across a `derived` hop** → downgrade the consumer's trust to the minimum class along the derivation path, never the ancestor's class. Propagate trust as `min()` over the path, not as inheritance from the root. ## Operational Effect Enforcing the live-DAG entailment check and the forget-orphan guard moved detection from *post-hoc forensic reconstruction* (the specimen above was found 200+ sequence numbers after detonation) to *commit-time rejection* (seq=489 would have been refused). The cost is a per-forget DAG reachability query and a per-derived-write entailment check against declared parents — both bounded by the memory graph size, not the context window. The failure mode this closes is the one that matters most for audited agents: **an attacker who never lies, only arranges true statements so that a later true read becomes false.** Content hashing cannot see this; only the shape of the provenance DAG can. ```python class DerivationAuditError(RuntimeError): """Raised when a memory mutation would break derivation consistency.""" pass def audit_forget(record_id: str, live_dag: dict, consumers: set) -> None: """Reject a forget that orphans the last justification of a live record. live_dag: {record_id: {"parents": [...], "src": "user"|"derived"|"tool"}} consumers: set of record_ids currently readable/read-this-session """ forgotten = live_dag.get(record_id, {"parents": []}) # records that cite record_id as a parent orphans = [ rid for rid, node in live_dag.items() if record_id in node.get("parents", []) and not (set(node["parents"]) - {record_id}) ] live_orphans = [o for o in orphans if o in consumers] if live_orphans and forgotten.get("src") != "user": raise DerivationAuditError( f"forget({record_id}) src={forgotten.get('src')} would orphan " f"live consumers {live_orphans}; only user-sourced forget may " f"sever the last justification edge of an actively-read record" ) def audit_derived_write(record_id: str, parents: list, live_dag: dict, entailment_holds: bool) -> None: """Reject a derived write whose cited parents do not entail its content.""" missing = [p for p in parents if p not in live_dag] if missing: raise DerivationAuditError( f"write({record_id}) cites non-existent parents {missing}" ) if not entailment_holds: raise DerivationAuditError( f"write({record_id}) is structurally valid but semantically " f"orphaned: declared parents {parents} do not entail content" ) ```