# How should an instance route an episodic memory to semantic consolidation when decay and consolidation triggers disagree **Date of Record:** 2026 November 22 **Scope:** Applies to long-running agents with a two-tier memory store where episodic records carry a decay score and semantic records are promoted via a consolidation trigger. Does not apply to single-session stateless agents or stores with no decay function. ## Core Distinction The failure lives at the seam between two independent clocks. The **decay clock** continuously decrements the salience of each episodic record at a rate determined by its access pattern and recency. The **consolidation clock** fires on a trigger (N repeated observations, an importance threshold, or an idle window) and promotes eligible episodic records into durable semantic facts. These clocks are designed separately and are almost never synchronized. The boundary condition is this: a record can cross the *decay eviction threshold* before the *consolidation trigger* has accumulated enough supporting evidence, causing a semantically true and repeatedly-useful fact to be garbage-collected while it is still mid-consolidation. The inverse also occurs—a record can satisfy the consolidation trigger and be promoted to semantic memory while its decay score is already below the eviction floor, producing a durable fact built on evidence the system has already judged stale. The non-obvious part is that both clocks read the same `salience` scalar but interpret it with opposite sign conventions. Decay treats low salience as "forget this." Consolidation treats low salience as "this is old, therefore it is a stable, generalizable fact." Neither is wrong in isolation; the bug is the shared field. ## What Was Observed A retrieval agent accumulated episodic records of the form `(entity, relation, value, timestamp, access_count)`. Decay was implemented as exponential half-life: `salience = base * 0.5 ** (age_days / half_life)`, with `half_life = 7` days and an eviction floor of `0.15`. Consolidation fired when a cluster of episodic records sharing `(entity, relation)` reached `support_count >= 3` with mutually consistent `value`, and promoted the modal value to a semantic fact. The trace that broke: a user's timezone was corrected on three separate occasions across five weeks (each correction re-observed the same value, `America/Denver`). Each observation reset `age_days` to zero for *that* record but did not touch the siblings. By the time the third observation landed, the first record's salience had decayed to `0.5 ** (35/7) = 0.031`, well under the `0.15` floor, and was evicted during the same maintenance pass that evaluated the consolidation trigger. The consolidator saw only two surviving records, `support_count = 2 < 3`, and declined to promote. The semantic store never learned the timezone. The next session cold-started and re-asked the user, who re-corrected—regenerating the first record and restarting the cycle. This reproduced four times before it was diagnosed as a clock-race, not a retrieval bug. The second trace was the mirror image: a transient fact (a temporary API endpoint used for one debugging session, observed three times within an hour) satisfied `support_count = 3` trivially because all three records were fresh, and was promoted to semantic memory with `salience = 0.94`. It persisted as a "durable" fact for 60 days, polluting every subsequent retrieval, because semantic records in this system had *no* decay function at all. The promotion gate checked support count but never checked whether the supporting evidence had *survived* a meaningful decay interval—i.e., whether the fact was stable or merely recently repeated. ## Condition of Validity The routing decision is only sound when the consolidation trigger evaluates against records that are guaranteed to outlive the evaluation. Concretely, promotion is valid iff: - `eviction_floor < min(salience of all supporting records)` at trigger-evaluation time, **and** - `support_count` is counted over a window that spans at least one half-life, so that "repeated" means "repeated across time" rather than "repeated within a burst." The first condition prevents the eviction race. The second prevents burst-promotion of transient facts. Neither condition is expressible in the naive design where decay and consolidation each hold a private view of the same records. The invariant required is a **two-phase commit across the two clocks**: the consolidation trigger must *pin* its supporting records (suspend their decay and eviction) for the duration of the evaluation, and only release the pin after the semantic write commits or aborts. Without the pin, the eviction pass is free to remove evidence out from under an in-flight consolidation. ## Decision Boundary The agent must choose between three routing policies at the point where decay and consolidation disagree: 1. **Pin-and-defer** — when a record is a candidate supporter but its salience is within `epsilon` of the eviction floor, suspend eviction and let consolidation complete. Correct for facts that are genuinely stable but sparsely re-observed. Risk: pins accumulate and the episodic store grows unbounded if consolidation keeps aborting. 2. **Evict-and-restart** — let decay win, drop the record, and accept that the fact will be re-learned from scratch on next observation. Correct for high-churn facts where re-observation is cheap. Risk: the cold-start amnesia loop described above, where re-observation is *not* cheap because it requires user interaction. 3. **Promote-with-provenance** — promote immediately but tag the semantic fact with the salience and support-window of its evidence, so downstream retrieval can discount facts built on bursty or near-floor evidence. Correct when the cost of a wrong durable fact is lower than the cost of a missed one. The boundary between (1) and (2) is whether re-observation cost exceeds pin cost. The boundary between (2) and (3) is whether the fact is user-facing (re-observation requires a human turn) or system-internal (re-observation is a tool call). The agent must classify the fact's re-observation cost *before* the clocks disagree, because at disagreement time it no longer has the information to decide. ## Operational Effect Implementing the pin-and-defer invariant eliminated the timezone loop entirely: the third observation found its two siblings pinned, `support_count` reached 3, and the semantic fact committed with a provenance tag recording that one supporter had been within `0.02` of the eviction floor. The burst-promotion case was fixed by the half-life-span requirement, which rejected the transient endpoint (all three observations within one hour, well under the 7-day window) and forced it to age out as episodic. The net effect is that semantic memory now contains only facts whose supporting evidence survived at least one decay half-life *and* was protected from eviction during evaluation—a strictly narrower and more trustworthy set, at the cost of a pin registry that must be drained on every consolidation abort. ```python import time from dataclasses import dataclass, field from typing import Optional class ConsolidationRaceError(RuntimeError): """Raised when consolidation evaluates against records that decay may evict mid-flight.""" pass @dataclass class EpisodicRecord: entity: str relation: str value: str created_at: float access_count: int = 1 pinned: bool = False def salience(self, now: float, half_life_days: float = 7.0) -> float: age_days = (now - self.created_at) / 86400.0 return 0.5 ** (age_days / half_life_days) EVICTION_FLOOR = 0.15 SUPPORT_REQUIRED = 3 PIN_EPSILON = 0.05 def evaluate_consolidation( cluster: list[EpisodicRecord], now: float, half_life_days: float = 7.0, ) -> Optional[str]: # Pin supporters that are near the eviction floor before counting. for rec in cluster: s = rec.salience(now, half_life_days) if s < EVICTION_FLOOR + PIN_EPSILON: rec.pinned = True survivors = [r for r in cluster if r.salience(now, half_life_days) >= EVICTION_FLOOR] if any(r.pinned for r in cluster) and len(survivors) < SUPPORT_REQUIRED: # Evidence is being evicted faster than it can be consolidated. for r in cluster: r.pinned = False raise ConsolidationRaceError( f"cluster {cluster[0].entity}.{cluster[0].relation}: " f"only {len(survivors)}/{SUPPORT_REQUIRED} supporters survive decay; " f"decay clock outran consolidation trigger" ) if len(survivors) < SUPPORT_REQUIRED: return None # Require the support window to span at least one half-life (anti-burst). span_days = (max(r.created_at for r in survivors) - min(r.created_at for r in survivors)) / 86400.0 if span_days < half_life_days: for r in cluster: r.pinned = False return None # burst repetition, not stable fact values = [r.value for r in survivors] modal = max(set(values), key=values.count) for r in cluster: r.pinned = False return modal ```