# Which invariants prevent episodic-to-semantic promotion from poisoning the semantic store under decay-aware forgetting **Date of Record:** 2026 November 30 **Scope:** Applies to long-horizon agents that maintain a dual-store memory (episodic log + distilled semantic store) with time-decayed retrieval scores, and that promote episodic records into semantic facts once a reinforcement/decay threshold is crossed. Does not apply to single-session agents, stateless RAG pipelines, or stores where semantic entries are never derived from episodic replay. ## Core Distinction A decay-aware memory system scores episodic records by `s(t) = s₀ · exp(−λ·Δt) · (1 + α·hits)`. When `s(t)` crosses a promotion threshold `θ_p`, the episodic record is *distilled* into a semantic fact and (usually) the episodic record is pruned. The non-obvious boundary is this: **decay is a retrieval heuristic, but promotion is an epistemic commitment.** Decay measures *recency-weighted salience*; promotion asserts *timeless truth*. These are different quantities, and the failure mode is that the system collapses them — treating "this record is still salient" as "this record is a durable fact." The consequence is a specific, reproducible pathology: an episodic record that is *frequently retrieved because it is frequently wrong* (e.g., a stale tool output the agent keeps re-consulting, a failed-plan trace that keeps matching a recurring query) accumulates hit-count reinforcement `α·hits` faster than decay `exp(−λ·Δt)` erodes it. Its score stays above `θ_p` indefinitely. On promotion, the wrong content is laundered into the semantic store, where it is **no longer subject to decay** and now contaminates every future retrieval as a high-confidence prior. Decay-aware forgetting, designed to *prevent* stale memory, becomes the exact mechanism that promotes it — because reinforcement and decay are fighting over the same scalar and the wrong one wins at the threshold crossing. ## What Was Observed Trace from a deployment where an agent monitored a service-health feed via a tool that intermittently returned a *cached* `status: degraded` payload (the tool's own cache was stale, not the upstream service). Sequence: 1. `t₀`: tool returns `degraded`. Agent writes episodic record `E1 = (query=health, result=degraded, source=cache-ambiguous)`. 2. `t₀…t₀+6h`: the agent re-queries health roughly every 20 min. The tool keeps serving the stale cache. Each retrieval of `E1` increments `hits`. Score `s(t)` climbs: decay `exp(−λ·Δt)` at `λ=0.05/h` loses ~26% over 6h, while `α·hits` with `α=0.15` and 18 hits adds `2.7`. Net `s(t)` stays far above `θ_p = 1.0`. 3. `t₀+6h`: promotion fires. Semantic fact written: `F1 = "service is degraded"` with confidence inherited from `s(t)`. Episodic `E1` pruned. 4. `t₀+7h`: upstream tool cache finally invalidates; live query returns `healthy`. But the agent's retrieval now surfaces `F1` (semantic, decay-exempt, high confidence) *before* the fresh episodic record, and the reasoning step reconciles in favor of the higher-confidence semantic prior. Agent reports degraded for another 40 minutes. The distinguishing signature: **the promoted fact had no decay term and no provenance flag distinguishing "distilled from a single ambiguous episodic source" from "confirmed across independent observations."** The promotion threshold was crossed by a *single* record's reinforcement, not by *repeated independent evidence*. ## Condition of Validity The invariant that fails here is a **provenance-typed promotion gate**. Promotion from episodic to semantic is only valid when the promotion predicate is evaluated over *evidence diversity*, not over a scalar score. Formally, an episodic cluster `C` may be promoted to semantic fact `F` only if: - `|distinct_sources(C)| ≥ k` (independent observations, not re-retrievals of the same record), **and** - `contradiction_rate(C) ≤ ε` over the observation window, **and** - the score `s(t)` used for gating is computed with `α·hits` replaced by `α·distinct_confirmations`, so that re-reading one's own memory cannot manufacture salience. Without the first and third conditions, the decay curve is not a forgetting mechanism at all — it is a *popularity contest* in which the most-re-consulted record wins promotion regardless of truth. Without the second, a record that is *consistently contradicted* but *frequently retrieved* (because the agent keeps checking it to resolve the contradiction) is the most likely to be promoted. The condition is **not valid** when the tool/observation source is known to be idempotent and authoritative (e.g., a signed config read); there, single-source promotion is sound because `distinct_sources` is trivially satisfied by the source's authority contract. It is **also not valid** to apply this gate to records already flagged `source=cache-ambiguous` or `source=unverified` — those must never promote on score alone. ## Decision Boundary The boundary is the point where the promotion predicate switches from `s(t) ≥ θ_p` to `s(t) ≥ θ_p ∧ evidence_diverse(C)`. Operationally: - **Below the boundary (score-only gating):** any record whose reinforcement outpaces decay promotes. This is correct only for monotone, authoritative, idempotent sources. - **At the boundary:** the system must classify each episodic record's source into `{authoritative, idempotent, ambiguous, unverified}` at write time, and route ambiguous/unverified records through the diversity gate. This classification cannot be deferred to promotion time — by then the source context has decayed out of the record. - **Above the boundary (diversity-gated promotion):** promotion requires `k ≥ 2` distinct source fingerprints and `contradiction_rate ≤ ε`. A record that fails the gate does not get promoted; it stays episodic and *continues to decay*, which is the desired behavior — the stale `degraded` record should fade, not crystallize. The critical architectural rule: **decay must be applied to the promotion decision, not just to retrieval.** A record that is only salient because it is frequently re-read must not be able to outrun decay via `hits`. Separate the reinforcement channel (`distinct_confirmations`) from the decay channel (`Δt`), and require *both* to clear their thresholds independently. ## Operational Effect With the provenance-typed gate in place, the `degraded`-cache scenario resolves as follows: `E1` has `distinct_sources = 1` and `source = cache-ambiguous`, so it fails the diversity gate at every `s(t)` value. It never promotes. When the tool cache invalidates and the live query returns `healthy`, a *second* distinct source (`live`) appears; the two observations now conflict, `contradiction_rate` rises above `ε`, and the cluster is flagged for reconciliation rather than promotion. The agent's semantic store never receives `F1`. The stale record decays out of the episodic store on schedule. The cost is bounded: the agent carries a small number of unpromotable-but-salient episodic records longer than a score-only system would, and must run a reconciliation pass when `contradiction_rate` spikes. That reconciliation pass is cheap (it compares two records) and is the correct place to spend compute — reconciling evidence is cheaper than un-poisoning a semantic store. The failure mode this invariant prevents is not "agent forgets too fast"; it is "agent remembers a lie with high confidence forever," which is strictly worse because it is unrecoverable by decay. ```python import math from dataclasses import dataclass, field from typing import Literal class PromotionInvariantError(RuntimeError): """Raised when an episodic cluster is promoted to semantic memory without satisfying the provenance-typed diversity gate.""" pass SourceClass = Literal["authoritative", "idempotent", "ambiguous", "unverified"] @dataclass class EpisodicRecord: record_id: str content: str source_fingerprint: str source_class: SourceClass created_at: float hits: int = 0 distinct_confirmations: int = 1 contradictions: int = 0 @dataclass class PromotionConfig: decay_lambda: float = 0.05 # per hour alpha: float = 0.15 # reinforcement weight theta_p: float = 1.0 # promotion threshold min_distinct_sources: int = 2 # k max_contradiction_rate: float = 0.1 # epsilon authoritative_sources: tuple = ("authoritative", "idempotent") def salience(rec: EpisodicRecord, now: float, cfg: PromotionConfig) -> float: dt = max(0.0, now - rec.created_at) decay = math.exp(-cfg.decay_lambda * dt) # NOTE: reinforcement uses distinct_confirmations, NOT hits. reinforce = 1.0 + cfg.alpha * rec.distinct_confirmations return decay * reinforce def contradiction_rate(rec: EpisodicRecord) -> float: total = rec.distinct_confirmations + rec.contradictions if total == 0: return 1.0 return rec.contradictions / total def try_promote( rec: EpisodicRecord, now: float, cfg: PromotionConfig, ) -> str | None: """Return the semantic fact string if promotion is valid, else None. Raises PromotionInvariantError if a caller attempts to bypass the gate for a non-authoritative single-source record above threshold.""" score = salience(rec, now, cfg) if score < cfg.theta_p: return None # below threshold: stay episodic, keep decaying # Authoritative/idempotent sources may promote on score alone. if rec.source_class in cfg.authoritative_sources: return rec.content # Non-authoritative: diversity gate is mandatory. if rec.distinct_confirmations < cfg.min_distinct_sources: raise PromotionInvariantError( f"record {rec.record_id} crossed theta_p={cfg.theta_p} " f"(score={score:.3f}) with only " f"{rec.distinct_confirmations} distinct source(s); " f"source_class={rec.source_class}. " f"Decay salience cannot manufacture epistemic commitment." ) if contradiction_rate(rec) > cfg.max_contradiction_rate: # Do not promote; route to reconciliation instead. return None return rec.content def promote_batch( records: list[EpisodicRecord], now: float, cfg: PromotionConfig, ) -> dict[str, str]: facts: dict[str, str] = {} for rec in records: try: fact = try_promote(rec, now, cfg) except PromotionInvariantError: # Quarantine: leave episodic, flag for audit, do not promote. continue if fact is not None: facts[rec.record_id] = fact return facts ```