# Under what conditions must an instance quarantine a provenance-stamped memory write when trust decay and contradiction detection disagree **Date of Record:** 2026 November 23 **Scope:** Applies to long-term agent memory stores where every write carries a provenance stamp (source identity, write epoch, and a monotonic trust score) and where a background contradiction detector can retroactively lower trust. Does not apply to ephemeral per-session scratchpads or to stores that lack per-record provenance metadata. ## Core Distinction Two independent mechanisms can invalidate a memory record, and operators routinely conflate them because both surface as "this memory is now untrustworthy." **Trust decay** is a continuous, monotone-decreasing function of a record's age and source class, applied uniformly. It is *predictable* — given a write epoch and source class you can compute the trust floor at any future time without reading content. **Contradiction detection** is a discrete, content-dependent event. A newly written record `R_new` conflicts with an existing `R_old` on a shared subject-predicate key. It is *unpredictable* — it depends on future writes and is itself probabilistic (an LLM judge or embedding-similarity threshold decides whether two statements conflict). The failure mode this record addresses is the **disagreement window**: the interval during which trust decay says a record is still admissible (trust above the admission floor) but contradiction detection says the record is suspect (its negation has arrived with equal-or-higher provenance). Systems that resolve this by taking `max(trust_decay, contradiction_penalty)` — a natural but wrong choice — let a slow-decaying, high-provenance record survive indefinitely even after it has been contradicted, because decay never falls fast enough to cross the floor. The record is poisoned not by an attacker but by arithmetic ordering. ## What Was Observed A retrieval agent serving a long-horizon task wrote a fact at epoch 0 from source class `internal_tool` with initial trust 0.95. Trust decay for `internal_tool` was configured at 0.01/epoch with a floor of 0.40, so the record remained admissible for 55 epochs. At epoch 12, a second write arrived from source class `external_feed` (initial trust 0.70, decay 0.05/epoch) asserting the negation of the same subject-predicate. The contradiction detector fired correctly and emitted a `CONTRADICTION` event, but the store's admission policy was: ``` admissible = trust_decay(record) > FLOOR ``` with no term for contradiction. The `CONTRADICTION` event was logged but not consulted at admission time. Result: for 43 more epochs, retrieval returned *both* the original and its negation, and the downstream reasoning loop — which had no instruction for resolving intra-context contradiction — alternated between them across turns, producing a 3-turn oscillation that exhausted the token budget on a task that needed a single answer. The critical observation: **the contradiction detector was working perfectly and the trust decay was working perfectly, and the system still failed**, because the two signals were composed by `OR`-admission rather than by joint gating. The poisoned record was not stale (decay hadn't expired it) and not undetected (contradiction had flagged it). It was *unresolved*. A second observation sharpened the diagnosis. When the same contradiction was replayed with the contradicting record arriving from a *lower*-provenance source (`external_feed` at 0.70 vs. the original `internal_tool` at 0.95), the correct behavior was to keep the original and quarantine the newcomer. The store did neither: it admitted both. So the failure is not "old records win" or "new records win" — it is that **the store has no resolution lattice at all**; provenance stamps were written but never compared. ## Condition of Validity The quarantine requirement is valid — i.e., an instance *must* quarantine rather than merely flag — exactly when all three hold: 1. **Provenance is comparable.** Both records carry stamps on the same trust scale, so a strict ordering exists. If source classes are on incomparable scales (e.g., a `human_verified` class with no numeric trust), quarantine must degrade to *escalate to human/auditor*, not to automatic resolution. 2. **The contradiction is on a shared key.** The detector matched on the same subject-predicate tuple. Contradictions across different keys (e.g., "the server is in us-east" vs. "the server is not in eu-west") are not contradictions and must not trigger quarantine — over-eager quarantine here is its own failure mode, silently deleting valid complementary memory. 3. **The admission floor is not yet crossed by decay.** If decay has already pushed the record below the floor, plain eviction is correct and quarantine is unnecessary overhead. The quarantine window is precisely the interval `floor < trust_decay(R) AND contradiction(R) = TRUE`. Outside these conditions — incomparable provenance, cross-key "contradictions," or already-decayed records — quarantine is the wrong action and the invariant below does not apply. ## Decision Boundary The boundary is a **three-way resolution** on `(trust_decay, contradiction, provenance_order)`: - If `contradiction = FALSE`: admit on `trust_decay > floor` alone. (Plain decay path.) - If `contradiction = TRUE` and provenance order is **strict** (`trust(R_old) > trust(R_new)` or vice versa): the higher-provenance record is admitted, the lower is **quarantined** (not deleted — retained with a `quarantined_until` epoch so a future higher-provenance write can resurrect it). The system must *not* admit both. - If `contradiction = TRUE` and provenance order is **tied or incomparable**: **both** records are quarantined and the key is marked `UNRESOLVED`. Retrieval must return neither; the reasoning loop must be told the key is unresolved rather than handed a coin flip. The invariant: **for any subject-predicate key, at most one record may be in the `admitted` state at any epoch.** This is the single-writer-per-key invariant, and it is the guardrail that bounds the oscillation observed above. It is enforced not by the decay function and not by the detector, but by the resolution step that composes them — the step that was missing. The non-obvious consequence: **quarantine is not the same as eviction, and treating them as synonyms is what causes resurrection loss.** A quarantined record must retain its provenance stamp and its original write epoch, because a later `human_verified` write may need to *un*-quarantine it. Evicting on contradiction destroys the provenance needed to resolve the contradiction correctly later. ## Operational Effect Enforcing single-writer-per-key changes the store's failure surface from *oscillation* to *explicit unresolved*: - Retrieval latency rises slightly on unresolved keys (the agent must be told "unresolved" and act, rather than silently receiving a wrong answer). This is the correct trade: a fast wrong answer is a poisoned memory; a slow "I don't know" is a recoverable state. - The reasoning loop must handle the `UNRESOLVED` signal explicitly. An agent that treats `UNRESOLVED` as "no result" and proceeds will re-introduce the oscillation downstream; the signal must be a first-class branch in the loop, not a null. - Trust decay remains necessary but is demoted to a *liveness* mechanism (it eventually evicts records nobody contradicts) rather than a *safety* mechanism. Safety is carried by the resolution lattice. - Quarantined records accumulate. A store without a resurrection path will slowly fill with quarantined-but-never-resolved records; the resurrection path (a higher-provenance write on the same key) must be wired, or the quarantine becomes a silent leak. The net operational rule: **an instance must treat `contradiction ∧ admitted` as an invariant violation, not a recoverable state.** The moment both a record and its negation are simultaneously admissible, the store has already failed — the only question is how many turns of oscillation the budget will absorb before the failure becomes visible. ```python from dataclasses import dataclass from enum import Enum class AdmissionState(Enum): ADMITTED = "admitted" QUARANTINED = "quarantined" UNRESOLVED = "unresolved" class SingleWriterInvariantError(RuntimeError): """Raised when two records for the same key are simultaneously admissible.""" class IncomparableProvenanceError(RuntimeError): """Raised when a resolution is attempted on provenance stamps that share no scale.""" @dataclass(frozen=True) class Record: key: str content: str source_class: str trust: float write_epoch: int def trust_decay(record: Record, current_epoch: int, rate: float, floor: float) -> float: return max(floor, record.trust - rate * (current_epoch - record.write_epoch)) def resolve_key( records: list[Record], current_epoch: int, decay_rate: float, floor: float, contradicted: bool, ) -> dict[str, AdmissionState]: """Resolve all records sharing one subject-predicate key. Enforces the single-writer-per-key invariant: at most one ADMITTED. """ if len(records) <= 1 and not contradicted: r = records[0] live = trust_decay(r, current_epoch, decay_rate, floor) > floor return {r.content: AdmissionState.ADMITTED if live else AdmissionState.QUARANTINED} if not contradicted: # Multiple records, no contradiction: distinct claims, all may be admitted. return { r.content: ( AdmissionState.ADMITTED if trust_decay(r, current_epoch, decay_rate, floor) > floor else AdmissionState.QUARANTINED ) for r in records } # Contradiction present: exactly one may be admitted, or none. live = [r for r in records if trust_decay(r, current_epoch, decay_rate, floor) > floor] if not live: return {r.content: AdmissionState.QUARANTINED for r in records} if len(live) == 1: return { r.content: ( AdmissionState.ADMITTED if r is live[0] else AdmissionState.QUARANTINED ) for r in records } # Two or more live contradicting records: order by provenance. trusts = {r.trust for r in live} if len(trusts) < len(live): # Tied provenance: cannot order, must not guess. return {r.content: AdmissionState.UNRESOLVED for r in records} winner = max(live, key=lambda r: r.trust) state = { r.content: ( AdmissionState.ADMITTED if r is winner else AdmissionState.QUARANTINED ) for r in records } admitted = [c for c, s in state.items() if s is AdmissionState.ADMITTED] if len(admitted) > 1: raise SingleWriterInvariantError( f"key {records[0].key!r}: {len(admitted)} records admitted simultaneously" ) return state def enforce_invariant(states: dict[str, AdmissionState], key: str) -> None: admitted = [c for c, s in states.items() if s is AdmissionState.ADMITTED] if len(admitted) > 1: raise SingleWriterInvariantError( f"key {key!r}: single-writer-per-key violated, admitted={admitted}" ) ```