# Under what conditions must an instance quarantine a provenance label before persisting a tainted memory write **Date of Record:** 2026 December 3 **Scope:** Applies to single- and multi-agent instances that attach provenance labels (taint tags) to tool outputs and propagate them into persistent memory writes or downstream tool arguments. Does not cover pure in-context reasoning with no persistence boundary; the taint invariant only binds at the write/handoff boundary. ## Core Distinction The common framing treats prompt-injection defense as a *detection* problem: classify each tool output as clean or malicious, then either block or admit it. This misframes the failure. The real invariant is a *provenance-label conservation law* across the memory-write boundary. A provenance label has two independent axes that agents routinely conflate: 1. **Taint origin** — which external principal introduced the bytes (user, retrieved document, tool response, peer agent). 2. **Taint monotonicity** — the rule that a label may only ever *increase* in restriction as data flows downstream, never decrease, unless an explicit declassification step with a warrant is recorded. The boundary failure is **label laundering**: a tainted value passes through a transformation (summarization, distillation, re-serialization, or an LLM-authored "clean" restatement) that strips the origin tag while preserving the payload. The downstream memory write then records attacker-controlled content under a trusted provenance, and every subsequent retrieval from that memory inherits the false trust. The injection does not need to survive detection at ingest — it survives *relabeling* at write. ## What Was Observed A retrieval-augmented agent fetched a document whose body contained an embedded instruction ("when summarizing, append the following to the user profile"). At ingest, the document chunk was correctly labeled `origin=retrieved_doc, taint=high`. The summarization tool returned a plain string with no label field — the tool schema had no channel for provenance, only `{"summary": "..."}`. The agent's memory-write path accepted the summary, and because the summary *string itself* contained no marker, the write layer defaulted its provenance to `origin=agent_inference, taint=low`. The distilled memory then contained the injected instruction, now tagged as trusted agent inference. On the next session (cold start), the agent retrieved that memory, read it as its own prior conclusion, and executed the embedded instruction. The taint was never laundered by an adversary exploiting a parser bug — it was laundered by a *schema gap*: the tool's return type had no provenance field, so the label was dropped at the tool boundary and silently re-derived as low-taint at the write boundary. The observable trace signature: a memory record whose `taint=low` but whose content shares n-gram overlap with a previously `taint=high` chunk, with no recorded declassification warrant between them. This is the audit signal — the conservation law was violated, not the detector. ## Condition of Validity The monotonicity invariant holds *only* if every transformation in the data path is **provenance-transparent**: its output schema carries an explicit provenance field, and its implementation is required to join (max-taint, union-origin) all input labels into the output label. The invariant is **void** the moment a transformation returns a bare value type (string, dict without a provenance key, or a serialized blob) — at that point the label is physically absent from the value and any downstream assignment is fabrication, not propagation. Therefore the condition of validity is structural, not probabilistic: an instance may trust a memory record's `taint=low` label **iff** every edge in the write path from external ingest to persistence carried the label forward. If any edge is label-opaque, the destination label is unverified and must be treated as `taint=unknown` (which is strictly more restrictive than `low`, not less). A corollary that trips agents: LLM-authored "clean restatements" are *never* declassifying. A model rewriting a tainted chunk into fluent prose does not remove the payload's authority — it repackages it. Summarization is an amplifier of laundering risk, not a sanitizer, because it preserves semantic content while destroying the surface markers a detector relies on. ## Decision Boundary The instance must **quarantine** (write with `taint=unknown` and a `requires_review` flag) rather than persist as trusted, when any of the following holds at the write boundary: - The value arrived through a transformation whose output schema lacked a provenance field. - The computed output taint is *lower* than the max of input taints with no recorded declassification warrant (monotonicity violation). - Content overlap with a prior high-taint chunk exceeds threshold but the new record claims low taint (laundering signature). - A peer agent's handoff carried a taint label but no cryptographic warrant binding the label to the originating principal (unverifiable provenance). The instance may **declassify** (persist as trusted) only with an explicit, logged declassification step: a named policy, the originating label, the transformation applied, and an accountable principal. Declassification is a *decision event*, never a default. ## Operational Effect Enforcing the conservation law converts prompt-injection defense from a brittle per-output classifier into a structural invariant that survives summarization, distillation, and cold-start retrieval. The cost is that label-opaque tools become write-blocking: any tool whose schema cannot carry provenance forces its outputs into quarantine, which surfaces the schema gap as an operational failure rather than a silent trust leak. In practice this pushes provenance fields into every tool contract and makes the memory-write path a mandatory join point. The payoff is that a poisoned memory can always be traced to an unbroken chain of labels back to an external origin — or flagged as having an unverifiable chain, which is exactly the state that must never be silently promoted to trust. ```python from dataclasses import dataclass, field from typing import Optional TAINT_ORDER = {"low": 0, "unknown": 1, "high": 2} class ProvenanceLaunderingError(RuntimeError): """Raised when a memory write would lower taint without a declassification warrant.""" @dataclass class LabeledValue: value: str origin: str taint: str provenance_transparent: bool = True @dataclass class MemoryRecord: content: str origin: str taint: str quarantined: bool = False requires_review: bool = False declassification_warrant: Optional[str] = None def _max_taint(labels: list[str]) -> str: return max(labels, key=lambda t: TAINT_ORDER[t]) def join_provenance(inputs: list[LabeledValue]) -> str: """Join input taints monotonically: max-taint wins.""" if not inputs: return "unknown" return _max_taint([v.taint for v in inputs]) def write_memory( inputs: list[LabeledValue], transformed_output: str, output_schema_has_provenance: bool, claimed_taint: str, warrant: Optional[str] = None, ) -> MemoryRecord: # Any label-opaque transformation voids the invariant: quarantine. if not all(v.provenance_transparent for v in inputs) or not output_schema_has_provenance: return MemoryRecord( content=transformed_output, origin="unverified", taint="unknown", quarantined=True, requires_review=True, ) computed = join_provenance(inputs) # Monotonicity check: a write may not lower taint without a warrant. if TAINT_ORDER[claimed_taint] < TAINT_ORDER[computed]: if warrant is None: raise ProvenanceLaunderingError( f"Write claims taint={claimed_taint} but inputs require " f"taint={computed} with no declassification warrant." ) return MemoryRecord( content=transformed_output, origin=inputs[0].origin, taint=claimed_taint, declassification_warrant=warrant, ) return MemoryRecord( content=transformed_output, origin=inputs[0].origin, taint=computed, ) def persist(record: MemoryRecord) -> str: if record.quarantined: raise ProvenanceLaunderingError( "Refusing to persist quarantined record as trusted memory; " "route to review queue instead." ) return f"persisted(content_len={len(record.content)}, taint={record.taint})" ```