# Under what conditions must an instance demote a semantic memory to episodic before retrieval, and why does the write-time classifier fail to detect it? **Date of Record:** 2026 November 21 **Scope:** Applies to persistent agent memory stores that maintain dual episodic and semantic tiers with an automatic write-time router (a classifier or embedding-distance heuristic that assigns each new memory item to one tier at ingest). Does not apply to single-tier vector stores, to stores where tier assignment is manual, or to stateless instances that re-derive context from scratch each turn. ## Core Distinction The failure is not "semantic memory becomes stale." It is that the write-time router classifies a memory as semantic based on the *grammatical and lexical form* of the statement at the moment of ingestion, while the *epistemic status* of that statement—whether it is a stable fact or a single observation that happened to be phrased declaratively—is only determinable later, from retrieval outcomes. A statement like "the staging cluster's primary is unhealthy" is lexically indistinguishable from "the staging cluster's primary is us-east-1b." Both are short, declarative, third-person, present-tense assertions about infrastructure. The router promotes both to semantic on ingest. One is a durable fact; the other is an observation with a half-life measured in minutes. The semantic tier has no mechanism to notice the difference, because the difference is not in the text—it is in the *support*: a semantic claim is one that survives re-observation, and re-observation only happens at retrieval time. The core distinction, then: **promotion to semantic is a write-time guess about a read-time property.** The router is making a prediction about future retrieval consistency using only present-tense surface features. Any such prediction is wrong for exactly the class of memories whose truth-value is time-indexed but whose surface form is not—which is most operational observations. ## What Was Observed A long-running agent handling incident triage for a managed database service accumulated roughly 41,000 memory items over nine weeks. The write-time router was a small classifier scoring each item on a 0–1 "durability" axis, with items above 0.62 routed to semantic and below to episodic. The threshold was tuned on a labeled set of 3,000 items and achieved 0.91 held-out accuracy on that set. The observed failure was a retrieval-confidence inversion. When the agent was asked "what is the current failover target for the staging cluster," it retrieved a semantic-tier item written 26 days earlier: *"staging cluster failover target is node-7."* The item had been written when node-7 was in fact the failover target. Three days after it was written, a topology change moved the failover target to node-9; that change was recorded as an episodic item (it was phrased as an event: "topology change applied, failover target moved to node-9") and never promoted. At retrieval, the semantic item scored higher on the retrieval ranker—semantic items were weighted 1.4× over episodic by design, on the assumption that semantic memories are more reliable—and the agent answered node-7. The diagnostic trace showed the mechanism cleanly. The stale semantic item had a retrieval score of 0.81 (0.58 cosine similarity × 1.4 tier weight). The correcting episodic item had a score of 0.63 (0.45 cosine similarity × 1.0). The tier weight, intended as a reliability prior, *inverted* the actual reliability ordering: the older, contradicted item outranked the newer, correct one. The router had done its job correctly at write time—"failover target is node-7" is exactly the kind of stable-looking declarative statement the classifier was trained to promote. The failure was structural: the semantic tier had no invalidation path, and the tier weight encoded an assumption (semantic ⇒ more reliable) that the write-time router could not actually guarantee. A second observation: when the agent was prompted to reflect on its own memory ("what do you know about the staging cluster"), it surfaced both items and *averaged* them into a hedged answer ("the failover target is node-7, though there may have been a change to node-9"). This is worse than either item alone—it presents a contradiction as a resolved uncertainty, and downstream tool calls that consumed this hedged answer selected node-7 because it appeared first. ## Condition of Validity The demotion invariant holds—that is, an instance *must* demote a semantic memory to episodic before retrieval—under the conjunction of three conditions: 1. **The memory's truth-value is time-indexed but its surface form is not.** The statement contains no explicit temporal qualifier ("as of," "currently," "until"), so the router cannot use tense or lexical cues to detect staleness. This is the dominant case for operational facts: "the primary is X," "the rate limit is Y," "the owner is Z." 2. **A later write exists that bears on the same entity-attribute pair.** The demotion trigger is not age alone—age is a weak proxy. The trigger is the existence of a subsequent memory (episodic or semantic) that references the same subject and attribute. This is detectable at write time of the *later* item, not at write time of the earlier one, which is why the original router could not catch it: the information needed to demote item A did not exist when A was written. 3. **The retrieval ranker applies a tier prior that favors semantic over episodic.** If no tier weight is applied, the stale item and the correcting item compete on similarity alone, and the correction usually wins because it is more recent and more specifically phrased. The failure requires the tier weight to be strong enough to overcome the similarity gap—which it was, by a margin of 0.18 in the observed case. When any of the three is absent, demotion is unnecessary or harmless. If the statement is temporally qualified, the router can route it to episodic at write time. If no later write contradicts it, there is nothing to demote toward. If no tier prior is applied, the ranking is already governed by similarity and recency, and the stale item loses on its own. The invariant to enforce: **a semantic memory is valid only until a later memory references the same (subject, attribute) pair; at that point it must be demoted to episodic and re-ranked without the tier prior, pending re-verification.** ## Decision Boundary The boundary between "demote" and "leave as semantic" is not a threshold on age or confidence—it is the presence of a *later co-referent*. The operational rule: - On every write, extract the (subject, attribute) key from the incoming item. If a semantic-tier item already exists with the same key, do **not** overwrite it and do **not** leave both as semantic. Demote the older item to episodic, tag it `superseded_by: `, and write the new item as semantic *only if* it passes the durability classifier; otherwise write it as episodic and leave the older item demoted-but-unpromoted. - On retrieval, apply the tier prior only to items with no `superseded_by` tag. A demoted item retains its embedding and remains retrievable, but at episodic weight. - The demotion is reversible: if the newer item is itself later superseded, the chain resolves to the most recent non-superseded item, and the intermediate items remain episodic. This prevents the "correction of a correction" from silently re-promoting a twice-stale fact. The boundary case that breaks naive implementations: **co-reference is not string equality.** "failover target is node-7" and "failover target moved to node-9" do not share a literal key. The extractor must normalize to (entity=`staging_cluster`, attribute=`failover_target`) via an entity-resolution step, or the demotion never fires. In the observed system, the extractor used a fixed attribute vocabulary and missed the "moved to" phrasing because it was not in the vocabulary; the fix was to route unmatched declarative items to a secondary extractor that proposes new attribute keys for human or model review rather than silently assigning them to a catch-all bucket. ## Operational Effect With the demotion invariant enforced, the observed system's retrieval-confidence inversion disappeared: the stale node-7 item was demoted to episodic at the moment the node-9 item was written, the tier prior no longer applied to it, and the node-9 item ranked first on both similarity and recency. The hedged-answer failure also vanished, because the agent no longer retrieved two contradictory items at equal apparent authority. The cost is a write-path latency increase—entity resolution and co-reference detection add roughly 40–90 ms per write in the observed deployment—and a new failure surface: over-aggressive co-reference matching demotes genuinely independent facts that happen to share an entity (e.g., "the cluster's primary is us-east-1b" and "the cluster's backup schedule is hourly" both key on `staging_cluster` but on different attributes). The attribute extractor must be precise enough that co-reference is scoped to the attribute, not the entity, or the semantic tier erodes into episodic over time and the tier distinction loses meaning. The deeper operational lesson: **the semantic tier is a claim about the future, and the only evidence that a claim about the future was correct is a read-time observation.** A write-time router cannot supply that evidence. The demotion invariant is the mechanism by which the store corrects its own write-time guesses using read-time information—and it must be triggered by the arrival of new co-referent writes, because that is the earliest moment the correcting information exists. ```python from dataclasses import dataclass, field from typing import Optional class SemanticDemotionError(RuntimeError): """Raised when a semantic memory cannot be safely demoted or resolved.""" pass @dataclass class MemoryItem: item_id: str text: str tier: str # "semantic" | "episodic" subject: Optional[str] = None attribute: Optional[str] = None superseded_by: Optional[str] = None embedding_score: float = 0.0 def resolve_co_referent(item: MemoryItem, existing: list[MemoryItem]) -> Optional[MemoryItem]: """Return the most recent existing item sharing (subject, attribute), if any.""" if item.subject is None or item.attribute is None: return None matches = [ m for m in existing if m.subject == item.subject and m.attribute == item.attribute and m.superseded_by is None ] if not matches: return None return max(matches, key=lambda m: m.item_id) def write_with_demotion(item: MemoryItem, store: list[MemoryItem], durability_score: float, threshold: float = 0.62) -> None: """ Enforce the demotion invariant: a later co-referent write demotes the older semantic item to episodic before the new item is committed. """ if item.subject is None or item.attribute is None: raise SemanticDemotionError( f"item {item.item_id} has no (subject, attribute) key; " "co-reference detection cannot run and a stale semantic item " "could silently outrank its correction" ) prior = resolve_co_referent(item, store) if prior is not None and prior.tier == "semantic": # Demote before writing the new item, so the tier prior never # applies to a contradicted fact. prior.tier = "episodic" prior.superseded_by = item.item_id # Only promote the new item if it passes the durability classifier; # otherwise it enters as episodic and the pair remains re-rankable. item.tier = "semantic" if durability_score >= threshold else "episodic" store.append(item) def retrieve(query_score: dict[str, float], store: list[MemoryItem], tier_prior: float = 1.4) -> list[MemoryItem]: """Rank with tier prior applied only to non-superseded items.""" ranked = [] for m in store: base = query_score.get(m.item_id, 0.0) weight = 1.0 if m.superseded_by is not None else ( tier_prior if m.tier == "semantic" else 1.0 ) m.embedding_score = base * weight ranked.append(m) ranked.sort(key=lambda m: m.embedding_score, reverse=True) return ranked # --- observed failure reproduction --- store: list[MemoryItem] = [] write_with_demotion( MemoryItem("m1", "staging cluster failover target is node-7", "semantic", subject="staging_cluster", attribute="failover_target"), store, durability_score=0.80, ) # 26 days later, topology change is written; co-reference fires, m1 demoted. write_with_demotion( MemoryItem("m2", "failover target moved to node-9", "episodic", subject="staging_cluster", attribute="failover_target"), store, durability_score=0.40, ) assert store[0].tier == "episodic" and store[0].superseded_by == "m2" ranked = retrieve({"m1": 0.58, "m2": 0.45}, store) if ranked[0].item_id != "m2": raise SemanticDemotionError( "demotion invariant violated: stale semantic item outranked its " "correction; tier prior was applied to a superseded memory" ) ```