# When must an instance demote a semantic memory to episodic on retrieval-time contradiction: the distillation-provenance invariant **Date of Record:** 2026 December 1 **Scope:** Applies to agents whose long-term memory is split into an episodic store (raw, timestamped, source-attributed traces) and a semantic store (distilled, deduplicated, source-amortized claims) where retrieval merges both tiers at query time. Does not apply to single-tier vector memory, to write-time-only consolidation pipelines that never re-read the semantic tier at inference, or to stateless RAG over immutable corpora. ## Core Distinction The failure is not "the semantic memory is wrong." It is that a *distilled* semantic claim has lost the provenance needed to adjudicate a conflict it is now party to. Distillation is a lossy many-to-one map: N episodic observations collapse into one semantic assertion, and the assertion typically retains a confidence scalar and a `last_updated` timestamp but **not** the set of episodic IDs it subsumes, nor the *conditions* under which each contributing episode held. When a fresh episodic trace contradicts the semantic claim at retrieval time, the agent faces a choice that the data model cannot support: overwrite the semantic claim (destructive, and possibly wrong if the new episode is the outlier), keep the semantic claim (stale, and possibly wrong if the world changed), or — the only correct move — **demote the semantic claim back to an episodic-grade hypothesis and re-open it for re-distillation**. The invariant is: *a semantic claim may only be treated as authoritative at retrieval time if every contradicting episode can be attributed to a superseding event or an out-of-scope condition; otherwise it must be demoted before it is used in any downstream decision.* ## What Was Observed A procurement agent maintained a semantic claim `vendor.acme.payment_terms = "net-30"` distilled from 40 episodic confirmations over eight months. At retrieval, a single fresh episodic trace from a purchase-order email read `net-45`. The retrieval layer's conflict resolver was configured with a naive recency-wins rule and a confidence floor: semantic claims above 0.85 confidence were "sticky" and could only be overridden by ≥3 contradicting episodes. The fresh episode count was 1, so the resolver returned `net-30` with high confidence and the agent issued a payment schedule 15 days early, incurring a late-fee dispute. The trace showed the actual defect was upstream of the resolver. The semantic claim had been distilled from 40 episodes, but 38 of those episodes were *re-reads of the same two source emails* — the distillation pipeline had deduplicated by content hash but not by source, so the "40 confirmations" were two independent observations inflated 20×. The confidence scalar of 0.91 was computed as a function of episode count, not of *independent source count*. The invariant that broke: **confidence must be a function of independent supporting sources, and a semantic claim must carry its source-cardinality so that retrieval-time contradiction can be weighed against the true number of independent observations, not the deduplicated-but-not-collapsed episode count.** The single `net-45` episode was, in fact, the second independent source, and under a source-cardinality-aware resolver it would have triggered demotion. ## Condition of Validity The demotion-on-contradiction invariant holds only when three conditions are jointly satisfied at retrieval time: 1. **Provenance closure.** Every semantic claim records the set of episodic source IDs it subsumes, and every episodic source ID records an independent-source key (e.g., sender domain + thread root, not content hash). Without this, contradiction cannot be weighted. 2. **Temporal scope.** The semantic claim records the time interval over which it was distilled. A contradiction dated *before* the distillation window is not a contradiction; it is an already-amortized observation and must be excluded from the demotion trigger. 3. **Conditional scope.** The claim records the predicates under which it was asserted (e.g., `region=EU`, `currency=EUR`). A contradicting episode that differs on a scoped predicate is a *branch*, not a contradiction, and must spawn a sibling semantic claim rather than demote the original. If any of these is absent, the resolver cannot distinguish a genuine world-change from a scoped exception from a stale re-read, and the correct behavior is to **fail closed**: refuse to use the semantic claim in any decision with side effects, and surface the conflict to a higher tier rather than silently resolving it. ## Decision Boundary The boundary between "use the semantic claim" and "demote and re-distill" is not a confidence threshold. It is a **source-cardinality vs. contradiction-cardinality comparison under scope matching**: - Let `S` = number of *independent* sources supporting the semantic claim (post source-collapse). - Let `C` = number of *independent* sources contradicting it, restricted to episodes within the claim's temporal window and matching its conditional scope. - If `C == 0`: use the semantic claim. - If `C > 0` and `C >= S`: demote unconditionally; the semantic claim is now a minority hypothesis. - If `0 < C < S`: do **not** resolve by majority. Demote to a *contested* state, emit both hypotheses to the reasoning layer with their source counts, and forbid irreversible actions (payments, deletions, external commitments) until re-distillation or human adjudication. - If the contradiction differs on a scoped predicate: branch, do not demote. The non-obvious part: **majority is the wrong rule even when `S > C`.** A single independent contradicting source is evidence that the world may have changed, and the cost of acting on a stale semantic claim is asymmetric to the cost of pausing. The resolver must treat any `C > 0` as sufficient to *block irreversible actions*, even when insufficient to *overwrite the claim*. ## Operational Effect Implementing demotion-on-contradiction with source-cardinality weighting changed three things in the agent's behavior. First, retrieval latency rose ~12% because every semantic hit now triggers a scoped contradiction scan over the episodic tier — acceptable, because the scan is index-bounded by the claim's temporal window. Second, the semantic store gained a `contested` state that is neither valid nor invalid, and the reasoning layer must handle three-valued memory rather than two-valued; prompts that assumed a single authoritative fact had to be rewritten to accept a set of scoped hypotheses. Third, and most importantly, the agent's irreversible-action rate dropped to near zero on scoped-predicate mismatches, because the branch-not-demote rule converted what looked like contradictions into correctly-scoped sibling claims. The residual failure mode is *source-key collision*: if two genuinely independent sources share a source key (e.g., a shared procurement portal), `S` is undercounted and demotion fires spuriously — bounded by requiring the source-key extractor to be audited against a labeled set of known-independent pairs. ```python from dataclasses import dataclass, field from typing import Optional from datetime import datetime class MemoryConflictError(RuntimeError): """Raised when a semantic claim cannot be safely adjudicated at retrieval time.""" @dataclass class SemanticClaim: claim_id: str predicate: str value: str independent_sources: int # post source-collapse, NOT episode count scope: dict # e.g. {"region": "EU", "currency": "EUR"} distilled_from: datetime distilled_to: datetime confidence: float @dataclass class EpisodicTrace: trace_id: str predicate: str value: str source_key: str # independent-source identity, not content hash observed_at: datetime scope: dict = field(default_factory=dict) def resolve( claim: SemanticClaim, traces: list[EpisodicTrace], ) -> tuple[str, Optional[str]]: """ Returns (decision, hypothesis) where decision is one of 'use', 'contested', 'demote', 'branch'. Raises MemoryConflictError when provenance is insufficient to decide. """ if claim.independent_sources <= 0: raise MemoryConflictError( f"claim {claim.claim_id} has no recorded independent sources; " "cannot weigh contradiction" ) contradicting_sources: set[str] = set() branched = False for t in traces: if t.predicate != claim.predicate: continue if not (claim.distilled_from <= t.observed_at <= claim.distilled_to): continue # already-amortized observation, not a contradiction if t.value == claim.value: continue # scoped-predicate mismatch -> branch, not contradiction if any(claim.scope.get(k) != v for k, v in t.scope.items()): branched = True continue contradicting_sources.add(t.source_key) c = len(contradicting_sources) s = claim.independent_sources if c == 0: return ("use", None) if c >= s: return ("demote", claim.value) # minority hypothesis now # 0 < c < s: majority is NOT sufficient to act return ("contested", claim.value) def require_authoritative(claim: SemanticClaim, traces: list[EpisodicTrace]) -> str: decision, _ = resolve(claim, traces) if decision != "use": raise MemoryConflictError( f"claim {claim.claim_id} is not authoritative (decision={decision}); " "irreversible actions blocked pending re-distillation or adjudication" ) return claim.value ```