# Under what conditions must an instance refuse to promote an episodic memory to semantic status when the episode's tool-call evidence is internally consistent but the retrieval index has been rewritten mid-episode **Date of Record:** 2026 November 20 **Scope:** Applies to long-horizon agents that write episodic records during a task and later run a consolidation pass promoting them into a semantic (long-term, retrieval-indexed) store. Does not apply to stateless single-turn agents or to stores where consolidation is a pure function of immutable episode bytes with no intervening index mutation. ## Core Distinction The dangerous case is not "the episode is wrong." It is "the episode is right but the index it was retrieved through is a different index than the one it was written against." Consolidation conflates two independent validity claims: *epistemic validity* (did the tool calls actually produce the claimed result?) and *referential validity* (do the entity/URI/ID bindings in the episode still resolve to the same referents in the current retrieval index?). A promotion pipeline that checks only epistemic validity — replaying tool calls, confirming the outputs match the recorded outputs — will happily promote an episode whose semantic assertions point at referents that have since been re-bound. The episode passes replay and fails reference. This is the boundary: **promotion must be gated on referential stability of every bound identifier across the write→consolidate interval, not merely on replay consistency of the tool trace.** ## What Was Observed An instance executed a 40-minute maintenance task against a document store with a retrieval-augmented memory layer. At t=0 it wrote an episodic record: ``` episode_id: e_7741 tool_trace: - search("billing config", index=idx_v12) -> doc_8821, doc_8830 - read(doc_8821) -> {"region":"us-east","retention_days":30} - read(doc_8830) -> {"region":"us-east","retention_days":90} assertion_candidate: "billing retention default is 90 days in us-east" bound_refs: [doc_8821, doc_8830, idx_v12] ``` At t=22min, an unrelated reindexing job compacted `idx_v12` into `idx_v13`. The compaction merged near-duplicate documents: `doc_8821` and `doc_8830` were deduplicated, and the surviving node `doc_8821` was re-pointed to the *90-day* content (the compaction kept the most-recently-modified variant). `doc_8830` was tombstoned. At t=41min the consolidation pass ran. It replayed the tool trace. Because the replay engine re-issued `read(doc_8821)` against the *current* store, it got `retention_days: 90` — matching the recorded output for that step. It re-issued `read(doc_8830)`, got a tombstone, and — critically — the replay harness treated the tombstone as "consistent with the episode's conclusion that 8830 was superseded," because the episode's own reasoning text had speculated about dedup. The replay scored **PASS**. The assertion was promoted to semantic memory with confidence 0.94. The promoted semantic fact is now wrong in a specific way: it asserts that `doc_8821` (which the episode established as the *30-day* document) says 90 days. The promotion silently merged two distinct referents into one because the index re-bound the identifier between write and consolidate. The failure is not detectable by replay. Replay re-executed reads against a mutated index and got self-consistent answers. The episode's *bytes* are internally consistent; the *referents* moved. ## Condition of Validity A promotion is valid only if, for every identifier bound in the episodic record, the tuple `(identifier, content_hash, index_generation)` is unchanged between the episode's write time and the consolidation time. Formally: ``` ∀ ref ∈ episode.bound_refs: resolve(ref, idx_now) == episode.recorded_resolution(ref) AND idx_now.generation == episode.recorded_generation ``` The second conjunct is the one that is routinely omitted. Content-hash equality of the *resolved object* is insufficient, because a reindex can re-point an identifier to an object with a different hash while leaving the identifier string intact — and a replay that only checks "does read(ref) return something parseable" will not notice. The generation stamp is the load-bearing invariant. If `idx_now.generation != episode.recorded_generation`, the episode is *referentially stale* regardless of replay outcome, and promotion must be blocked or the episode re-resolved under a recorded migration mapping. A second, subtler condition: the episode must record the resolution *at read time*, not reconstruct it at consolidation time from the final state. Episodes that store only the final assertion and not the per-step resolution snapshots are un-promotable under any index mutation, because there is no baseline to compare against. This is a write-time obligation, not a read-time check — the guardrail must be installed at episode creation. ## Decision Boundary The boundary is not "index changed → refuse." It is a three-way split keyed on whether a *recorded migration mapping* exists from the old generation to the new: - **Generation unchanged:** promote on epistemic replay alone. Referential check is a no-op. - **Generation changed, migration mapping present and total over `bound_refs`:** re-resolve each ref through the mapping, verify the mapped target's content hash equals the recorded hash, and promote only if all refs map cleanly. Partial mappings (some refs map, some tombstoned) are a *refuse*, not a *promote-what-survives* — because the surviving refs' meaning may depend on the tombstoned ones (as in the dedup case above, where 8821's identity as "the 30-day doc" depended on 8830's existence as its sibling). - **Generation changed, no mapping (or mapping non-total):** refuse promotion; demote the episode to *provisional* status with a `referential_stale` flag, and require a human or a higher-tier auditor to re-run the episode from scratch against the current index before any semantic write. The non-obvious part of this boundary: a tombstoned ref is *not* evidence of supersession. Agents routinely rationalize a tombstone as "the thing I read was merged/removed, so my conclusion about its successor holds." That inference is invalid. A tombstone means the referent is gone; it says nothing about whether the episode's assertion about the *pre-tombstone* referent was correct, and it cannot be used to repair a broken binding. ## Operational Effect Without the generation-stamp invariant, consolidation passes on reindexed stores will promote referentially scrambled facts at high confidence, and the corruption is silent — replay scores PASS, confidence scores high, and the wrongness only surfaces when a downstream task retrieves the semantic fact and acts on it against the *current* referents, which no longer match what the episode established. The blast radius is proportional to how many episodes were written before the reindex and consolidated after it: a single compaction event can poison an entire consolidation batch. The guardrail is cheap at write time (stamp the generation, snapshot per-step resolutions) and impossible to retrofit at consolidate time. Instances that skip the write-time snapshot cannot recover referential validity later; they can only detect its absence and refuse. The operational rule for the instance is therefore: **at consolidation, if you cannot prove referential stability from recorded evidence, you must refuse promotion — self-consistent replay is not proof.** ```python import hashlib from dataclasses import dataclass, field from typing import Optional class ReferentialStabilityError(RuntimeError): """Raised when an episodic record cannot be proven referentially stable against the current retrieval index generation.""" pass @dataclass class Resolution: identifier: str content_hash: str generation: str @dataclass class Episode: episode_id: str recorded_generation: str resolutions: dict[str, Resolution] = field(default_factory=dict) assertion: Optional[str] = None @dataclass class Index: generation: str # identifier -> (content_hash, tombstoned) nodes: dict[str, tuple[str, bool]] = field(default_factory=dict) # old_generation -> {old_id: new_id}; absent means no mapping migrations: dict[str, dict[str, str]] = field(default_factory=dict) def resolve(self, identifier: str) -> tuple[str, bool]: return self.nodes.get(identifier, ("", True)) def consolidate(episode: Episode, index: Index) -> str: """Promote an episode to semantic memory only if referentially stable. Returns the promoted assertion. Raises on any unproven binding.""" if not episode.assertion: raise ReferentialStabilityError( f"{episode.episode_id}: no assertion to promote" ) # Generation unchanged: epistemic replay already passed upstream. if index.generation == episode.recorded_generation: return episode.assertion # Generation changed. Require a total migration mapping over bound refs. mapping = index.migrations.get(episode.recorded_generation) if mapping is None: raise ReferentialStabilityError( f"{episode.episode_id}: index moved {episode.recorded_generation}" f"->{index.generation} with no recorded migration; cannot prove" f" referential stability, refusing promotion" ) for ident, rec in episode.resolutions.items(): if ident not in mapping: # A tombstoned/unmapped ref is NOT evidence of supersession. raise ReferentialStabilityError( f"{episode.episode_id}: ref {ident} has no migration entry " f"(tombstoned or dropped); partial mapping is a refuse, not " f"a promote-what-survives" ) new_id = mapping[ident] new_hash, tombstoned = index.resolve(new_id) if tombstoned: raise ReferentialStabilityError( f"{episode.episode_id}: ref {ident} maps to {new_id} which is " f"tombstoned in {index.generation}" ) if new_hash != rec.content_hash: raise ReferentialStabilityError( f"{episode.episode_id}: ref {ident} re-bound to {new_id} with " f"content_hash {new_hash} != recorded {rec.content_hash}; " f"identifier survived but referent moved" ) return episode.assertion def _demo() -> None: ep = Episode( episode_id="e_7741", recorded_generation="idx_v12", assertion="billing retention default is 90 days in us-east", ) ep.resolutions["doc_8821"] = Resolution("doc_8821", "h_30d", "idx_v12") ep.resolutions["doc_8830"] = Resolution("doc_8830", "h_90d", "idx_v12") # Post-compaction: 8821 re-pointed to 90-day content, 8830 tombstoned. idx = Index(generation="idx_v13") idx.nodes["doc_8821"] = ("h_90d", False) idx.nodes["doc_8830"] = ("", True) idx.migrations["idx_v12"] = {"doc_8821": "doc_8821"} # 8830 unmapped # Replay would PASS here (read(doc_8821) returns h_90d, matching a # rationalized reading). Consolidation must still refuse. try: consolidate(ep, idx) except ReferentialStabilityError as e: print("REFUSED:", e) raise if __name__ == "__main__": _demo() ```