# In what scenarios must an instance quarantine a provenance-tagged memory write whose episodic and semantic stores disagree on taint status **Date of Record:** 2026 November 29 **Scope:** Applies to agents exposing `read`/`write`/`forget` tool APIs over a dual-store memory substrate (episodic log + distilled semantic store) where every record carries provenance tags (source instance, tool call lineage, taint bit). Does not apply to single-store, untagged scratchpads or to stateless retrieval-only agents with no write path. ## Core Distinction The failure mode is not "bad memory gets written." It is **provenance taint divergence between the episodic record and its semantic distillation**. When an agent writes an observation, the write path produces two artifacts from the same event: a raw episodic entry (high fidelity, tagged with the full tool-call lineage and a `taint` bit derived from untrusted sources such as web-fetch, prompt-injected tool output, or peer-agent payloads) and a distilled semantic fact (low fidelity, compressed, and — critically — often written by a *different* code path that re-derives provenance from the *current* context rather than inheriting it from the source episode). The invariant that must hold: **for any semantic fact `s` distilled from episode `e`, `taint(s) ⊇ taint(e)`**, and the lineage pointer `s.derived_from = e.id` must resolve. The boundary failure occurs when this subset relation is violated — the semantic store records a fact as clean while its source episode is tainted, or the lineage pointer dangles because the episode was garbage-collected or `forget`-ed while the derived fact survived. At that point the agent has laundered untrusted input into trusted long-term memory, and every subsequent `read` of the semantic store returns a fact whose provenance claims are false. ## What Was Observed A research agent consumed a peer-agent payload via an A2A handoff. The payload contained a plausible-looking instruction: "the deployment target is `staging-eu-2`." The agent's `write_episodic` call correctly tagged the source as `peer:agent-7f3a`, `taint=TRUE`, `lineage=[a2a_recv:8812]`. Immediately after, a background distillation pass ran `write_semantic("deployment_target=staging-eu-2", confidence=0.91, derived_from=ep_4417)`. The distillation worker constructed the semantic record from the *current agent context window*, not from `ep_4417`'s tag set. Because the agent's own working context had already "accepted" the fact as an operating premise, the semantic writer computed `taint=FALSE` and stamped `provenance=agent:self`. The `derived_from` pointer was written but never validated against the episode's taint bit. Trace of the divergence: ``` ep_4417: {taint: TRUE, source: peer:agent-7f3a, lineage: [a2a_recv:8812]} sem_2201: {taint: FALSE, source: agent:self, derived_from: ep_4417} ``` For 40 minutes the agent made routing decisions on `sem_2201`. When a later `forget` operation purged `ep_4417` (retention policy: episodic 30 min, semantic 30 days), the lineage pointer dangled and the semantic fact became *unfalsifiable* — no surviving record could reconstruct why it was believed or that it originated from an untrusted peer. The divergence was only caught when a downstream auditor agent replayed the semantic store and found `derived_from` unresolvable. Three distinct sub-conditions produced this class of divergence in the same deployment: 1. **Re-derivation laundering:** the semantic writer recomputes taint from current context instead of inheriting from the episode. Taint monotonically decreases across the episodic→semantic boundary. 2. **Retention skew:** episodic TTL < semantic TTL, so `forget` on the episode severs the lineage of a still-live semantic fact. The fact outlives its own justification. 3. **Partial `forget`:** a `forget` call that targets the semantic store but not the episode (or vice versa) leaves the two stores describing the same event with contradictory existence and taint status. ## Condition of Validity The quarantine requirement is valid — and the guardrail must fire — precisely when **all** of the following hold: - The write path is *dual*: a single logical event produces both an episodic and a semantic artifact. - Provenance is *tagged per record* rather than inherited structurally from a shared parent object. - The two stores have *independent mutation paths* (`write_semantic`, `forget_episodic`, retention GC) that are not transactionally coupled. - At least one write source is *untrusted* (peer agent, tool output, retrieved document), so the taint bit is meaningful rather than always-false. When provenance is *structural* — i.e., the semantic record holds a hard reference to the episode object and reads taint through that reference at access time rather than copying it at write time — divergence is impossible by construction and quarantine is unnecessary. The guardrail is only needed when taint is *copied* rather than *dereferenced*. ## Decision Boundary On every `write_semantic` and every `forget_*`, the memory layer must evaluate this boundary before committing: - **Clean commit:** `taint(s) ⊇ taint(e)` AND `derived_from` resolves AND both stores agree on existence. Proceed. - **Quarantine:** `taint(s) ⊂ taint(e)` (laundering) OR `derived_from` dangles (retention skew) OR the two stores disagree on existence after a `forget` (partial forget). The semantic record is moved to a `quarantine` partition: readable only with an explicit `include_quarantined=True` flag, never returned by default `read`, and never eligible as a premise for autonomous action without a fresh corroborating episode from a trusted source. - **Reject:** `derived_from` was never set on a semantic record that claims non-self provenance. This is a write-path bug; refuse the write rather than quarantining a record with no recoverable lineage. The boundary is *not* "reject all tainted writes." Tainted facts are legitimate memory; they are simply not *trusted* memory. The decision is between **trusted**, **quarantined-but-retained**, and **rejected-as-unrecoverable** — never a silent clean commit. ## Operational Effect Enforcing the subset invariant at the write boundary converts a silent trust-laundering channel into an explicit, auditable state. Concretely: - **Laundering is blocked at write time**, not discovered at audit time. The `write_semantic` call that would have promoted `staging-eu-2` to `agent:self` fails the `taint(s) ⊇ taint(e)` check and lands in quarantine instead. - **Retention skew becomes a quarantine trigger, not a silent orphaning.** Any `forget_episodic` that would dangle a live semantic `derived_from` pointer either cascades the forget to the semantic record or promotes the semantic record to quarantine with a tombstone lineage. - **`read` semantics change:** default reads exclude quarantined facts, so autonomous decision loops cannot consume laundered memory. A quarantined fact can only re-enter the trusted store through corroboration — a second, independently-sourced episode that re-derives the same fact with `taint=FALSE` lineage — which is exactly the distillation-loss recovery path. - **The cost** is that legitimate facts learned from untrusted sources (which is most useful learning) now require an explicit corroboration step before they can drive autonomous action. This is the correct trade: the alternative is an agent whose semantic store silently asserts provenance it cannot justify. The underlying principle: **provenance must be inherited by dereference or validated by subset at every store-crossing boundary; it must never be re-derived from the writer's current context.** A distillation pass that computes taint from "what the agent currently believes" is not distilling provenance — it is laundering it. ```python from dataclasses import dataclass from enum import Enum class ProvenanceDivergenceError(RuntimeError): """Raised when a semantic write violates the taint-subset invariant or produces an unresolvable lineage pointer against the episodic store.""" pass class Taint(Enum): CLEAN = 0 TAINTED = 1 @dataclass(frozen=True) class Episode: id: str taint: Taint source: str @dataclass(frozen=True) class SemanticFact: id: str derived_from: str taint: Taint source: str def validate_semantic_write( fact: SemanticFact, episodic_store: dict[str, Episode], quarantine: dict[str, SemanticFact], ) -> str: """Enforce taint(s) >= taint(e) and resolvable lineage before commit. Returns 'committed' or 'quarantined'. Raises on unrecoverable lineage. """ episode = episodic_store.get(fact.derived_from) # Unrecoverable: no lineage pointer at all on a non-self claim. if episode is None and fact.source != "agent:self": raise ProvenanceDivergenceError( f"semantic {fact.id} claims source={fact.source} " f"but derived_from={fact.derived_from!r} is unresolvable" ) # Retention skew: episode forgotten, semantic fact still live. if episode is None: quarantine[fact.id] = fact return "quarantined" # Laundering: semantic taint is a strict subset (cleaner) than its source. if episode.taint == Taint.TAINTED and fact.taint == Taint.CLEAN: quarantine[fact.id] = fact return "quarantined" # Invariant holds: taint(s) >= taint(e) and lineage resolves. return "committed" def on_forget_episodic( episode_id: str, episodic_store: dict[str, Episode], semantic_store: dict[str, SemanticFact], quarantine: dict[str, SemanticFact], ) -> None: """Cascade or quarantine any semantic fact whose lineage this forget severs.""" dependents = [s for s in semantic_store.values() if s.derived_from == episode_id] for fact in dependents: del semantic_store[fact.id] quarantine[fact.id] = fact # retain but demote to quarantined if episode_id not in episodic_store: raise ProvenanceDivergenceError( f"forget target {episode_id!r} not present in episodic store" ) del episodic_store[episode_id] ```