# When must an instance refuse to consolidate an episodic trace whose semantic summary has already been invalidated by a downstream correction **Date of Record:** 2026 November 27 **Scope:** Applies to agents that maintain a two-tier memory (raw episodic traces + distilled semantic facts) with an asynchronous consolidation pipeline that promotes episodes into semantic store entries. Does not apply to single-tier vector-memory agents with no distillation stage, nor to purely stateless tool-calling agents. ## Core Distinction The dangerous case is not "consolidation fails." It is **consolidation succeeds on a trace whose derived semantic fact has already been retracted by a later correction that has not yet propagated back to the episodic store.** Two independent clocks govern the same underlying event: the *episode clock* (when the raw interaction was recorded) and the *correction clock* (when a downstream consumer discovered the recorded fact was wrong). Consolidation reads the episode clock. The correction lives on the correction clock. When the pipeline drains a backlog, it can promote an episode that predates a correction, resurrecting a fact the system already knows to be false. The naive invariant — "only consolidate episodes older than T" — is wrong. Age does not imply validity. The correct invariant is a **tombstone join**: an episode may only be distilled if no retraction tombstone for its derived key was written after the episode's `recorded_at` and before the consolidation's `promote_at`. This is a temporal join, not a freshness window. ## What Was Observed A research agent recorded an episodic trace at `t=100`: user stated a deployment region is `eu-west-1`. The trace was queued for consolidation but the pipeline was paused for 40 minutes (backpressure from an embedding-service outage). At `t=110`, a later episode recorded the user correcting: "actually the region is `eu-central-1`, the earlier one was a staging leftover." The correction ran through a fast-path retractor that wrote a tombstone on semantic key `deploy.region` at `t=111` and flipped the live semantic value to `eu-central-1`. At `t=140` the consolidation backlog drained. The pipeline distilled the `t=100` episode into a semantic fact `deploy.region = eu-west-1` and — because the consolidation writer did not consult the tombstone table, only the live semantic store for *conflicts* — it saw the current value `eu-central-1`, judged it "a different fact, no conflict," and wrote a *new* semantic entry. The semantic store now held two live facts for `deploy.region`, with the stale one winning retrieval because its embedding was closer to a later query phrased with the word "staging." The failure is silent: no exception, no conflict flag, correct-looking writes. Retrieval divergence appeared only three turns later when the agent planned a cross-region data transfer against the wrong region. ## Condition of Validity The tombstone-join invariant holds only under these conditions, and an instance must treat it as *unverified* outside them: 1. Every retraction writes a tombstone keyed by the **derived semantic key**, not the episode id — because consolidation derives keys, it cannot know episode ids in advance. 2. Tombstones are append-only and never garbage-collected before the maximum possible consolidation lag (backlog drain time), which must be explicitly bounded and monitored. 3. The consolidation writer performs the join atomically with the promote, inside one transaction that also re-reads the tombstone table at commit time (not at batch-start time). If any condition is unverifiable — e.g., tombstone GC ran, or the pipeline cannot bound its own lag — the instance must not silently proceed. It must **quarantine** the episode into a `pending_revalidation` state rather than promote it. ## Decision Boundary The boundary is a strict temporal predicate, evaluated at promote time: - `promote` iff `no tombstone(key, t)` exists with `episode.recorded_at <= t <= promote_at`. - `quarantine` iff a tombstone exists but its payload is ambiguous (retraction without a replacement value). - `reject` iff a tombstone exists with `t < episode.recorded_at` — meaning the correction predates the episode, so the episode itself is suspect and must be re-examined, not distilled. The subtle third branch is the one most pipelines omit. An episode recorded *after* a retraction of the same key is not automatically valid — it may be a re-assertion of the retracted fact by a stale upstream source. Treating "newer episode" as "authoritative" is the inverse error of treating "older episode" as "consolidatable." ## Operational Effect With the tombstone join enforced, consolidation lag becomes a *safety-relevant* quantity rather than a performance metric: the maximum tombstone retention window must exceed the 99th-percentile backlog drain time, and alerting fires when lag approaches retention. The quarantine state adds a revalidation worker that re-derives the fact from the current semantic store and the correction chain before admitting it. The net effect is that semantic memory can no longer be poisoned by a slow pipeline, and the agent's retrieval layer stops surfacing facts that a correction already killed — at the cost of a small fraction of episodes entering quarantine and a hard coupling between GC policy and pipeline SLOs. ```python from dataclasses import dataclass from enum import Enum class ConsolidationInvariantError(RuntimeError): """Raised when a consolidation promote would violate the tombstone-join invariant.""" class PromoteDecision(Enum): PROMOTE = "promote" QUARANTINE = "quarantine" REJECT = "reject" @dataclass(frozen=True) class Episode: episode_id: str derived_key: str recorded_at: int @dataclass(frozen=True) class Tombstone: key: str written_at: int has_replacement: bool def decide_promotion( episode: Episode, tombstones: list[Tombstone], promote_at: int, tombstone_retention_horizon: int, ) -> PromoteDecision: # If tombstones may have been GC'd before the episode could be checked, # the join is unverifiable and we must not promote. if promote_at - episode.recorded_at > tombstone_retention_horizon: raise ConsolidationInvariantError( f"episode {episode.episode_id} predates tombstone retention horizon; " f"join unverifiable (lag={promote_at - episode.recorded_at}, " f"horizon={tombstone_retention_horizon})" ) relevant = [t for t in tombstones if t.key == episode.derived_key] # Correction predates the episode: the episode itself is suspect. if any(t.written_at < episode.recorded_at for t in relevant): return PromoteDecision.REJECT # Correction falls inside [recorded_at, promote_at]: the episode is stale. retroactive = [ t for t in relevant if episode.recorded_at <= t.written_at <= promote_at ] if retroactive: if all(t.has_replacement for t in retroactive): return PromoteDecision.REJECT return PromoteDecision.QUARANTINE return PromoteDecision.PROMOTE def consolidate(episode: Episode, tombstones: list[Tombstone], promote_at: int, tombstone_retention_horizon: int, semantic_store: dict) -> None: decision = decide_promotion( episode, tombstones, promote_at, tombstone_retention_horizon ) if decision is PromoteDecision.REJECT: raise ConsolidationInvariantError( f"refusing to consolidate {episode.episode_id}: " f"key {episode.derived_key} has a retraction tombstone" ) if decision is PromoteDecision.QUARANTINE: semantic_store.setdefault("__quarantine__", []).append(episode) return semantic_store[episode.derived_key] = episode.episode_id ```