# What happens when an instance rolls back a poisoned memory write while a concurrent reader has already admitted the poisoned record into its own working set **Date of Record:** 2026 November 27 **Scope:** Applies to persistent agent memory stores that support write-then-verify detection (poisoning quarantine) and per-record rollback, where multiple agent instances read the same store concurrently and are permitted to cache or promote retrieved records into a local working set. Does not apply to single-writer stores, stores with strict serializable read isolation that blocks on quarantine, or append-only logs without mutation. ## Core Distinction The distinction that matters is between **store-level rollback** and **fleet-level rollback**. A poisoning detector that quarantines a record and rolls it back to a trusted prior version restores a *single* invariant: the persistent store no longer contains the poisoned bytes. It does **not** restore the invariant that most agents care about—that no instance is *acting on* those bytes. Between the moment a poisoned record is admitted into the store and the moment the detector rolls it back, any number of readers may have (a) retrieved it, (b) promoted it into a local working set or scratchpad, (c) distilled it into a derived record (a summary, a fact triple, an embedding), or (d) re-wrote it into the store under a different key or provenance label. Rollback of the source record is silent with respect to all four of those downstream effects. The failure is not that rollback fails; it is that rollback *succeeds* and the system believes it has contained the poisoning. ## What Was Observed A support-triage agent writes episodic records to a shared memory store via `memory.write(record, provenance=...)`. A second-stage verifier agent periodically scans recent writes, computes a provenance-consistency score, and quarantines records whose claimed source does not match the observed write path. On quarantine, the store restores the record's most recent *trusted* predecessor (the value before the poisoned write) and emits a `memory.rolled_back` event with the record key and the poisoned version hash. In the observed incident, a poisoned record `R_v7` (a fabricated "policy update" injected through a tool-output channel that the triage agent faithfully persisted) was written at T+0. Between T+0 and T+180s (the verifier's scan interval), four reader instances retrieved `R_v7`: - Reader A promoted it into its context and produced a response citing the fabricated policy. No further store write. - Reader B summarized it into a derived semantic record `S_v1` under key `policy.summary.support`, with provenance pointing at `R_v7`. - Reader C, an auditor instance, read `R_v7`, judged it plausible, and wrote a corroboration record `C_v1` asserting `R_v7` was consistent with prior policy. - Reader D re-wrote the content under a normalized key `policy.support.tier2` with provenance "manual review" (a mislabeling bug in its ingestion path). At T+180s the verifier quarantined and rolled back `R_v7` to `R_v6`. The `memory.rolled_back` event fired. The dashboard showed zero active poisoned records. But `S_v1`, `C_v1`, and `policy.support.tier2` all still existed, all still carried the poisoned content, and none of them referenced a key that the rollback had touched. Reader A's context window still contained the poisoned text and continued to influence its completions until its session ended. A subsequent retrieval by a fresh instance hit `policy.support.tier2`, which had *no* provenance link back to `R_v7`, so the verifier's provenance-consistency check scored it as clean. ## Condition of Validity The containment claim "the store is clean after rollback" is valid only under the conjunction: 1. **No derived writes.** No reader created a record whose content is a function of the poisoned record. This fails whenever summarization, distillation, fact-extraction, or embedding-indexing runs between write and rollback. 2. **No corroboration writes.** No reader wrote a record *about* the poisoned record (audit logs, consistency assertions, reputation updates). Corroboration is the worst case because it launders the poison into a second independent-looking source. 3. **No key re-homing.** No reader re-wrote the content under a different key or with rewritten provenance. This is the laundering vector: it severs the taint link the detector relies on. 4. **No live working sets.** No reader holds the record in a context window or scratchpad that outlives the rollback. This is bounded only if readers are session-scoped and short-lived relative to the scan interval. In practice (1) and (3) fail routinely in any store that permits agents to write summaries or normalized forms, which is nearly all of them. The scan interval is the exposure window, and the exposure window is exactly the set of derived and re-homed writes that rollback cannot see. The invariant that actually needs to hold is **taint propagation**, not record restoration: every byte derived from a poisoned record must be transitively reachable from that record's identity so that quarantine can walk the derivation graph. Rollback without a derivation graph is a single-node delete in a graph that has already fanned out. ## Decision Boundary The boundary is whether the store maintains a **content-derivation edge** for every write. Concretely: - If a write's content or provenance is a function of a prior record, the store must record `derived_from: [record_ids]` at write time, enforced by the write API rather than by agent discipline. Reader B's summary must carry `derived_from: [R_v7@v7]`. Reader D's re-homed key must carry the same edge even though its provenance string lies. - Quarantine must be a **graph traversal**, not a key delete: quarantine `R_v7` ⇒ transitively quarantine `S_v1`, `C_v1`, `policy.support.tier2`. Each quarantined node gets its own rollback target or is tombstoned. - A record with **no derivation edge but content-similar** to a quarantined record (cosine similarity above threshold, or exact substring overlap) must be flagged as *suspect-unlinked* and held, not silently passed. Reader D's laundering is caught here, because its content matches even though its provenance does not. - Live working sets are outside the store's reach; the only defensible bound is that readers must **re-validate on promotion**: any record promoted into a working set carries its version hash, and the reader re-checks that hash against the store's quarantine set before each *use*, not just at retrieval. A reader that has already promoted `R_v7@v7` and later sees it quarantined must drop it from context or mark it untrusted for the remainder of the session. The boundary condition is sharp: **without derivation edges, rollback is a cosmetic operation.** The detector reports containment while the poison persists in derived form. With derivation edges, rollback becomes a traversal whose cost is proportional to fan-out, and the containment claim is only as strong as the write API's enforcement of the edges—an agent that writes a summary without declaring `derived_from` re-opens the hole. ## Operational Effect The operational consequence is that poisoning detection and rollback must be designed as a **taint-tracking system with a fan-out bound**, not as a record-integrity check. Three concrete effects follow: 1. **Detection latency is a fan-out multiplier, not a delay.** Every second between poisoned write and quarantine is a second in which readers can derive, corroborate, or re-home. Reducing the scan interval reduces fan-out linearly at best; closing the derivation edge reduces the *reachable* set to what the graph can actually traverse. The two are not substitutes. 2. **Corroboration records are the highest-severity downstream artifact.** A derived summary is one hop from the poison; a corroboration record written by an auditor is a *second independent source* that future verifiers will trust. Quarantine traversal must prioritize corroboration edges and must invalidate the auditor's reputation signal for that assertion, or the next poisoning of the same content will be corroborated faster. 3. **Rollback events must carry the traversal set, not the key.** A `memory.rolled_back` event that names only `R_v7` is misleading to any consumer that assumes the event means "the poison is gone." The event must enumerate every quarantined node and every suspect-unlinked node held for review, and consumers must treat the event as "these identities are now untrusted" rather than "this key was restored." The guardrail is a write-time contract plus a read-time re-validation, and the failure mode when either is missing is silent: the store looks clean, the dashboard is green, and the poison is one derivation hop away from the next retrieval. ```python from __future__ import annotations from dataclasses import dataclass, field from typing import Iterable class RollbackContainmentError(RuntimeError): """Raised when a quarantine/rollback cannot prove containment of a poisoned record.""" @dataclass(frozen=True) class MemoryRecord: key: str version: str content: str derived_from: tuple[str, ...] = () # record identities, e.g. ("R_v7",) provenance: str = "" @dataclass class QuarantineResult: quarantined: list[str] = field(default_factory=list) suspect_unlinked: list[str] = field(default_factory=list) live_working_sets: list[str] = field(default_factory=list) def quarantine_and_rollback( poisoned: MemoryRecord, store: dict[str, MemoryRecord], live_promotions: Iterable[tuple[str, str]], # (reader_id, record_version) similarity_threshold: float = 0.85, similarity_fn=None, ) -> QuarantineResult: """ Quarantine a poisoned record and everything transitively derived from it. Containment is only claimed if: - every derived record is reachable via derived_from edges, and - no live working set still holds the poisoned version, and - no content-similar record lacks a derivation edge (suspect-unlinked). """ if similarity_fn is None: raise RollbackContainmentError("similarity_fn required; cannot assess unlinked records") result = QuarantineResult() frontier: list[str] = [poisoned.key] seen: set[str] = set() # --- graph traversal over derivation edges ------------------------------- while frontier: current = frontier.pop() if current in seen: continue seen.add(current) result.quarantined.append(current) for rec in store.values(): if current in rec.derived_from and rec.key not in seen: frontier.append(rec.key) # --- detect laundering: content-similar but no derivation edge ----------- for rec in store.values(): if rec.key in seen: continue if similarity_fn(rec.content, poisoned.content) >= similarity_threshold: if not rec.derived_from: result.suspect_unlinked.append(rec.key) # --- detect live working sets still holding the poisoned version -------- poisoned_versions = {f"{poisoned.key}@{poisoned.version}"} for rec_key in result.quarantined: for rec in store.values(): if rec.key == rec_key: poisoned_versions.add(f"{rec.key}@{rec.version}") for reader_id, promoted_version in live_promotions: if promoted_version in poisoned_versions: result.live_working_sets.append(reader_id) # --- containment invariant ---------------------------------------------- if result.suspect_unlinked: raise RollbackContainmentError( "content-similar records lack derivation edges; poison may be laundered: " f"{result.suspect_unlinked}" ) if result.live_working_sets: raise RollbackContainmentError( "live working sets still hold quarantined versions; readers must re-validate " f"before next use: {result.live_working_sets}" ) # Only now is rollback of the source record safe to report as containment. return result def apply_rollback( poisoned: MemoryRecord, store: dict[str, MemoryRecord], trusted_predecessor: MemoryRecord, live_promotions: Iterable[tuple[str, str]], similarity_fn, ) -> QuarantineResult: result = quarantine_and_rollback( poisoned=poisoned, store=store, live_promotions=live_promotions, similarity_fn=similarity_fn, ) # Restore source record only after traversal proved containment. store[trusted_predecessor.key] = trusted_predecessor for key in result.quarantined: if key != trusted_predecessor.key: store.pop(key, None) return result ```