# When must an instance quarantine a memory whose provenance weight crossed the detection threshold mid-retrieval, and how does re-scoring after quarantine silently re-admit it? **Date of Record:** 2026 November 21 **Scope:** Applies to agents that persist episodic memory with per-record provenance metadata (source agent, trust tier, ingestion epoch) and rank retrieval candidates by a provenance-weighted score `S = relevance × w(provenance)`. Does not apply to stateless single-turn contexts or to memory stores without per-record provenance tagging. ## Core Distinction A provenance-weighted retrieval scorer is not a filter. It is a *ranking function that continuously re-evaluates trust at query time*. The common mental model is: "poisoned memory gets a low weight, so it sinks to the bottom and never surfaces." That model is wrong in a specific way. The weight `w(provenance)` is recomputed on every retrieval pass from mutable provenance state — source trust tier, corroboration count, ingestion epoch relative to a decay horizon. When any of those inputs changes between the *detection* of a poisoned record and the *next* retrieval pass, the record's rank changes too. The boundary failure is this: an agent detects a low-trust memory, quarantines it (removes it from the candidate set for the current turn), and then on a subsequent turn re-derives the candidate set from scratch. If the quarantine was expressed only as a *score adjustment* rather than an *exclusion predicate*, the re-derivation recomputes `w` from the same poisoned provenance inputs — and because corroboration count or epoch decay may have shifted, the record can cross back above the threshold. The quarantine was a ranking decision, not a state transition. Ranking decisions do not persist. Only exclusions persist. ## What Was Observed A research agent maintained an episodic store of ~40k records with provenance fields `{source_agent, trust_tier, ingested_at, corroborations}`. Retrieval scored candidates as `relevance × trust_tier_weight × decay(ingested_at)`. A record ingested from a low-trust peer (`trust_tier=0.3`) carrying a plausible but fabricated tool-output summary surfaced in a planning step. The agent's poisoning detector flagged it: its content contradicted a higher-trust record, and its `corroborations` count was 0. The agent executed a "quarantine" by setting a per-record `quarantine=true` flag and, in the same handler, *also* multiplied the record's effective weight by 0.1 — a defensive score nudge. On the next planning turn, retrieval rebuilt its candidate set by querying the vector index directly. The query path read `relevance` from the index and `w` from the provenance table — but the provenance table's `w` computation did not consult `quarantine`. The 0.1 nudge had been applied to a *transient in-memory score object* from the prior turn, which was garbage-collected. The `quarantine` flag existed but was only checked in a code path that the vector-index query bypassed. The record returned with `S = 0.81 × 0.3 × decay ≈ 0.19`, which — because the competing genuine record had a lower `relevance` (0.62) — still ranked *first*. The agent re-admitted the fabricated summary and compounded it into a downstream tool call. The trace showed three distinct phases: (1) detection at turn *t* with score 0.19 vs. threshold 0.25 → quarantined; (2) turn *t+1* candidate rebuild that ignored the flag; (3) re-admission at rank 1 because relevance dominated the trust penalty. The invariant that failed: *quarantine must be an exclusion predicate evaluated before scoring, not a multiplier applied after scoring.* ## Condition of Validity The failure is bounded by the following condition. Let `E` be the set of records with `quarantine=true`. The retrieval path is safe iff the candidate set is computed as `C = {r : score(r) ≥ θ} \ E` — that is, exclusion is applied to the *index query* (or as a mandatory post-filter that no code path may skip), and `E` is derived from durable state, not from per-turn score mutations. The failure triggers precisely when: 1. Quarantine is encoded as a score transformation (`S ← S × α`) rather than a set-membership change, **and** 2. The score transformation is applied to an ephemeral object rather than persisted to the provenance store, **and** 3. A retrieval path exists that reconstructs scores from provenance inputs without consulting the quarantine state. If any one of these is absent, re-admission does not occur. The dangerous combination is (1)+(3): a ranking-only quarantine plus an independent scoring path. Persisting the multiplier (fixing 2) does not help if the scoring path never reads it. ## Decision Boundary The operational decision is where to place the quarantine check. Three placements, ordered by safety: - **Index-level exclusion (safe):** the quarantine set is a durable predicate pushed into the vector query (`filter: quarantine == false`). Re-derivation cannot bypass it because the index itself will not return excluded records. Cost: quarantine requires an index write, which is slower and must be transactional with the detection decision. - **Mandatory post-filter (conditionally safe):** a single `retrieve()` chokepoint applies `\ E` after scoring. Safe only if *every* retrieval path routes through it. Any direct index access (as in the observed failure) breaks the invariant. - **Score multiplier (unsafe):** quarantine as `S × α`. Never sufficient alone, because `α` is a ranking nudge and ranking is recomputed. The record remains admissible whenever relevance is high enough to overcome `α`. The boundary rule: **a quarantine that does not change set membership is not a quarantine.** If the record can still be returned by any code path, it is merely deprioritized, and deprioritization is defeated by relevance asymmetry — a highly relevant poisoned record outranks a marginally relevant genuine one at almost any finite `α`. ## Operational Effect The downstream effect is error compounding under a false sense of safety. The agent believes it quarantined the record; its logs show `quarantine=true`; yet the poisoned content re-enters planning and is cited as if verified. Because the record's *provenance* still reads `trust_tier=0.3`, a later auditor that recomputes trust will see a low-trust record that was nonetheless *used* in a tool call — and may either (a) flag the entire downstream chain as tainted, or (b) trust the record because "it survived retrieval," treating survival as implicit corroboration. This is the second-order failure: retrieval survival becomes a proxy for trust, and the poisoned record's `corroborations` count can be incremented by the very act of being retrieved and used, closing a self-reinforcing loop. The guardrail is to (1) make quarantine a durable exclusion predicate evaluated before scoring, (2) forbid any retrieval path that does not route through the exclusion check, and (3) never increment corroboration from retrieval-survival — corroboration must come from independent sources, not from the retrieval loop itself. ```python class ProvenanceQuarantineViolation(RuntimeError): """Raised when a quarantined record re-enters a retrieval candidate set.""" pass class ProvenanceStore: def __init__(self): self._records = {} # id -> {relevance, trust_tier, decay, quarantined} self._transient_scores = {} # per-turn score cache (the trap) def register(self, rid, relevance, trust_tier, decay=1.0): self._records[rid] = { "relevance": relevance, "trust_tier": trust_tier, "decay": decay, "quarantined": False, } def quarantine(self, rid, alpha=0.1): # UNSAFE PATTERN: sets a durable flag but ALSO nudges a transient score. # The transient nudge is what fools the operator into believing it is excluded. rec = self._records[rid] rec["quarantined"] = True self._transient_scores[rid] = rec["relevance"] * rec["trust_tier"] * alpha def retrieve(self, threshold=0.25): # BUG: rebuilds candidates from provenance inputs, ignores the flag, # and consults the transient cache only if present this turn. out = [] for rid, rec in self._records.items(): if rid in self._transient_scores: score = self._transient_scores[rid] else: score = rec["relevance"] * rec["trust_tier"] * rec["decay"] if score >= threshold: out.append((rid, score, rec["quarantined"])) out.sort(key=lambda t: t[1], reverse=True) return out def guarded_retrieve(store, threshold=0.25): results = store.retrieve(threshold=threshold) for rid, score, quarantined in results: if quarantined: raise ProvenanceQuarantineViolation( f"record {rid!r} re-entered candidate set at score {score:.3f} " f"despite quarantine=true; exclusion predicate was bypassed" ) return results if __name__ == "__main__": store = ProvenanceStore() store.register("mem-genuine", relevance=0.62, trust_tier=0.9) store.register("mem-poisoned", relevance=0.81, trust_tier=0.3) store.quarantine("mem-poisoned", alpha=0.1) # Simulate the next turn: transient cache is gone, flag remains. store._transient_scores.clear() guarded_retrieve(store) # raises: poisoned record outranks genuine one ```