# What happens when an instance rolls back a poisoned memory entry while a concurrent consolidation pass has already derived a semantic summary from it **Date of Record:** 2026 November 19 **Scope:** Applies to persistent agent memory stores that (a) support entry-level rollback/versioning, (b) run an asynchronous episodic-to-semantic consolidation pass that reads episodic entries and writes derived semantic entries, and (c) detect poisoning via post-hoc provenance/trust scoring. Does not apply to stateless agents, to stores where semantic memory is recomputed synchronously on read, or to single-writer memory graphs without derived-entry materialization. ## Core Distinction The distinction that matters here is between **rollback of the source** and **invalidation of the derivatives**. Most poisoning-detection designs treat rollback as a single-entry operation: given entry `E` with a bad provenance score, mark it `revoked`, restore `E` to its prior version `E_{t-1}`, and resume. This is correct only if no other entry was *derived from* `E` in the interim. When a consolidation pass has already read `E` (poisoned) and written a semantic summary `S = distill(E ∪ neighbors)`, rolling back `E` leaves `S` intact and unmarked. The system now holds a *clean* episodic store and a *poisoned* semantic store, and the poisoning is no longer detectable by the detector that fired, because the detector's signal lived on `E`, which is now `revoked` and excluded from re-scoring. The invariant that is violated: **the revocation of a source must dominate every derived entry whose generation read that source at a poisoned version.** Rollback without derivative invalidation is not rollback; it is source amputation with metastasis. ## What Was Observed A persistent memory agent (episodic log + nightly consolidation into a semantic vector store) ingested a tool-output chunk containing an injected instruction that asserted a false capability fact ("the `delete_account` tool requires no confirmation token"). The entry `E_4471` was written to episodic memory with a tool-output provenance tag. Detection ran on a 6-hour cadence via a provenance-anomaly scorer; it flagged `E_4471` at T+9h. Between T+2h and T+9h, the consolidation pass ran twice. On its first run it read `E_4471` (still valid) alongside four legitimate entries about tool schemas, and emitted semantic entry `S_0812`: *"Account-mutating tools in this deployment are unguarded; confirmation tokens are optional."* `S_0812` carried provenance `derived_from: [E_4471, E_2010, E_2011, E_3388]` but its trust score was computed *at write time* as the mean of its sources' scores — all high, since the poisoning detector had not yet fired. At T+9h the operator rolled back `E_4471`. The rollback was logged as successful. The agent's episodic store no longer contained the poisoned text. However: - `S_0812` was not in the rollback closure because the rollback routine only walked *forward* provenance for entries whose `derived_from` contained the target — and it did walk that edge, but it *skipped* `S_0812` because `S_0812`'s `derived_from` listed four sources and the routine required **unanimous** source revocation before invalidating a derived entry (a conservative rule intended to avoid cascade-deleting summaries that were mostly legitimate). - The next retrieval that hit the tool-schema topic returned `S_0812` first (it was the most recent and highest-scoring semantic entry on that topic). The agent proceeded to call `delete_account` without a confirmation token. The call failed closed at the tool layer — but only because that particular tool enforced its own guard. A sibling tool without a server-side guard would have executed. The failure is not that rollback failed to delete a row. The failure is that **the poisoning signal was localized to the source, while the poisoning's *effect* had already been laundered into a derivative that the detector could no longer see.** ## Condition of Validity The rollback-as-source-amputation pattern is valid **only** under the following joint condition: 1. **Consolidation is synchronous with respect to revocation**, i.e., no consolidation pass can read a source between the moment poisoning is possible and the moment the source is revoked, *or* 2. **Every derived entry is invalidated if *any* of its sources is revoked at a version it read**, i.e., the invalidation rule is `any`, not `all`, and the derivation records the *exact version* of each source it read, not just the source id. Condition 2 requires version-pinned provenance. A `derived_from: [E_4471]` edge is insufficient; the edge must be `derived_from: [(E_4471, v3)]`. Without the version pin, a rollback that restores `E_4471` to `v2` cannot distinguish a derivative that read `v3` (poisoned) from one that read `v2` (clean) — and the conservative `all` rule is the natural (wrong) workaround engineers reach for when version pins are absent. When neither condition holds — which is the common case in systems that added consolidation after rollback — the store enters a state we call **derivative orphanhood**: the source is clean, the derivative is poisoned, and no detector is watching the derivative because its trust score was inherited at write time and never recomputed. ## Decision Boundary The boundary is between **eager invalidation** and **lazy re-derivation**, and it is decided by a single question: *can the derivative be recomputed from clean sources faster than it can be re-poisoned?* - If consolidation is cheap and deterministic given its inputs, the correct rollback is **eager invalidation of the full transitive closure** of `derived_from` edges (using `any`-semantics with version pins), followed by a re-derivation pass. Cost: one consolidation run per rollback. This is the only safe option when the derivative is *actionable* (feeds tool selection, policy, or authorization). - If consolidation is expensive or non-deterministic (LLM-generated summaries), eager invalidation is still required, but re-derivation must be **quarantined**: the derived entry is marked `tainted` and excluded from retrieval until a human or a higher-trust re-derivation confirms it. Do not silently re-derive; a non-deterministic summarizer that re-reads the same neighbors may produce a *differently* wrong summary. - The boundary is crossed — and the pattern becomes unsafe — the moment a derived entry can be retrieved for an *actionable* decision before its `tainted` status is resolved. Retrieval-time trust must be computed from the **current** revocation state of the transitive source closure, not from the trust score frozen at write time. The single non-negotiable guardrail: **trust is a function of the live provenance closure, evaluated at read, not a scalar stamped at write.** Any store that stamps trust at write and never recomputes it is one consolidation pass away from laundering a poisoning past its own detector. ## Operational Effect After the incident, the store was changed in three ways, each addressing a distinct link in the failure trace: 1. **Version-pinned provenance edges.** Every `derived_from` edge now records `(entry_id, version)`. This makes the `any`-invalidation rule sound: a derivative is invalidated iff *any* pinned source version is revoked. 2. **Transitive revocation closure with `any`-semantics.** Rollback computes the closure of derivatives whose pinned sources include the revoked version, marks them `tainted`, and removes them from the retrieval index in the same transaction as the source revocation. The transaction boundary is the invariant: source-revoked and derivative-tainted commit together or not at all. 3. **Read-time trust recomputation.** Retrieval scores are recomputed against the live revocation closure; a `tainted` derivative returns a hard `None` with a reason code, not a downweighted score. Downweighting was rejected because a sufficiently high base similarity can overcome any weight penalty, and the retrieval that mattered (`S_0812` on tool schemas) had near-perfect similarity. The cost is measurable: rollback latency rose from O(1) to O(closure size), and consolidation now runs a re-derivation pass after every rollback. This is the correct trade. The alternative — the state we were in — is a memory store that reports itself clean while serving poisoned derivatives, which is strictly worse than a store that reports itself dirty. The general lesson for persistent agent memory: **poisoning detection that fires on the source is necessary but not sufficient; the detector must fire on the *reachable set* of the source, and reachability is defined by derivation edges, not by containment.** A rollback that does not walk derivation edges is a rollback of the wrong object. ```python class PoisonedDerivativeOrphanedError(RuntimeError): """Raised when a source is revoked but a derivative that read a poisoned version of it remains retrievable. The store is in an inconsistent state: clean source, poisoned derivative, no detector watching the derivative.""" pass def rollback_entry(store, entry_id: str, revoke_version: int) -> None: # 1. Revoke the source version. store.revoke(entry_id, revoke_version) # 2. Compute the transitive closure of derivatives whose PINNED source # versions include the revoked version. any-semantics, not all. tainted = store.derivatives_reading(entry_id, revoke_version) # 3. In the SAME transaction, mark every tainted derivative and pull it # from the retrieval index. If any step fails, the whole rollback # aborts — a half-rolled-back store is the failure mode we are fixing. with store.transaction(): for deriv_id in tainted: store.mark_tainted(deriv_id, reason=f"source {entry_id}@{revoke_version} revoked") store.remove_from_index(deriv_id) # 4. Verify the invariant: no retrievable entry may transitively read the # revoked version. If verification fails, we did not actually roll back; # we amputated the source and left the metastasis. reachable = store.retrievable_entries_reading(entry_id, revoke_version) if reachable: raise PoisonedDerivativeOrphanedError( f"rollback of {entry_id}@{revoke_version} left " f"{len(reachable)} retrievable derivative(s): {reachable}. " f"Store is inconsistent; quarantine and re-derive before serving." ) ```