# In what scenarios must an instance reject a semantic-tier write during episodic consolidation because the deduplication key collides with a still-live episodic antecedent **Date of Record:** 2026 November 20 **Scope:** Applies to agents that run a two-tier memory (episodic log → distilled semantic store) with retrieval-augmented consolidation and content-hash or embedding-neighborhood deduplication. Does not apply to append-only episodic-only agents, nor to semantic stores with no consolidation pipeline (no write path from episodic to semantic). ## Core Distinction The failure is not "duplicate memory" and it is not "lossy distillation." It is the collision between two identities that the tiering design assumes are disjoint: the *deduplication identity* of a semantic record (a hash of normalized content, or a nearest-neighbor bucket) and the *provenance identity* of the episodic records that produced it. Consolidation is normally treated as a pure function: `distill(episodes) → semantic_record`. Deduplication is then applied as a post-filter: if a record with the same dedup key exists, skip or merge. This is safe only under an invariant that is almost never stated explicitly: **a dedup key must not be reused while any episodic antecedent it summarizes is still live and subject to revision.** When that invariant is violated, dedup silently converts a *re-consolidation* (which should update the semantic record) into a *no-op skip* (which leaves a stale record in place), or worse, a *merge* that folds a corrected episode's evidence into a record whose derivation no longer matches it. The distinction that matters operationally: a dedup hit on a semantic write is not evidence that the write is redundant. It is evidence that the *key space* has collided, and the correct response depends on whether the colliding antecedent is live, superseded, or tombstoned — a state the dedup index does not carry. ## What Was Observed A support-triage agent runs a nightly consolidation job. Episodic entries are tool-call traces tagged with `(session_id, turn_index, content_hash)`. Consolidation distills clusters of episodes into semantic facts keyed by `sha256(normalized_claim)`. Dedup on write is: `if key in semantic_index: skip`. Trace of the failure: 1. Turn 40 (session A) records: "Refund window for plan X is 14 days." Consolidated at T1 into semantic record `S1`, key `k1 = sha256("refund_window(planX)=14d")`. Episodic antecedents `e_A:40` marked `consolidated_at=T1`. 2. Turn 90 (session B) records a policy update from a tool response: "Refund window for plan X is 30 days." This is a *new* episodic fact, not a correction of `e_A:40` — the old episode remains historically true (it was true at T1). 3. Nightly consolidation at T2 distills the cluster `{e_A:40, e_B:90}`. The distiller, prompted to "summarize the current policy," emits `"refund_window(planX)=30d"`. The dedup key is `k2 = sha256("refund_window(planX)=30d")` — distinct, so it writes. Good so far. 4. But the distiller also emits a *second* record from the same cluster, a normalized restatement: `"refund_window(planX) = 30 days"` → normalization strips spacing → `k2' == k2`. Self-dedup catches it. Fine. 5. The real break: at T3, session C's episode `e_C:12` contains a *rollback* notice: "Refund window for plan X reverted to 14 days." Consolidation now distills `{e_B:90, e_C:12}` and emits `"refund_window(planX)=14d"`, whose key is `k1` — **identical to the T1 record's key.** Dedup sees `k1 in semantic_index` and skips. The semantic store now permanently asserts 30 days (from T2), while the live episodic evidence (`e_C:12`) says 14 days. The rollback is unrepresentable because its dedup key was burned by a record that is now stale. The skip is the failure. The distiller was correct. The dedup index was correct. The tier boundary lost the distinction between "this key already exists and is current" and "this key already exists and its antecedent has since been superseded." ## Condition of Validity The `skip-on-key-hit` rule is valid only when all of the following hold: - **Antecedent liveness is decidable from the key.** The dedup index must be able to answer, for a hit on `k`, whether the semantic record at `k` was derived from episodic records that are all still `consolidated_at` and not `superseded_by`. A bare content hash cannot answer this. - **The distilled claim is a function of the cluster, not of the cluster's history.** If the distiller's output depends on *which* episodes are in the cluster (it does — that is the point of consolidation), then two clusters yielding the same normalized string are not the same fact. Key equality is necessary but not sufficient for record equality. - **No tombstone is pending.** If the semantic record at `k` has been marked `invalidated_at` but not yet garbage-collected, the key is still occupied and a legitimate re-write will be skipped. The window between invalidation and GC is a liveness hazard. When any of these fails, the dedup layer must not be the arbiter of the write. The write must be routed to a *supersession* path: the new record is written with the same key but a higher `version`, the old record is marked `superseded_by=new_version`, and the dedup index is updated to point at the head. ## Decision Boundary The boundary is not "dedup on or off." It is: **on a key hit, does the incoming record's antecedent set intersect the existing record's antecedent set, or does it supersede it?** - **Intersection (shared antecedents, same cluster re-run):** idempotent skip is correct. The write is a replay. - **Disjoint antecedents, same key (the failure case):** the incoming record is a *new* derivation that happens to normalize to the same string. This is a supersession, not a duplicate. Must write with `version+1`, must not skip. - **Incoming antecedent is a `superseded_by` of an existing antecedent:** the incoming record is a correction. Must write, must invalidate the old record, must propagate invalidation to any downstream semantic records that cited the old one (the transitive case — a semantic record may itself be an antecedent of a higher-tier summary). The decision requires the dedup index to carry, per key, the set of antecedent episode IDs (or a Merkle root over them) — not just the content hash. Without it, the boundary is undecidable and the safe default is *never skip*, which defeats dedup's purpose but preserves correctness. The engineering choice is therefore: pay the index size to carry antecedent provenance, or accept that dedup is a best-effort optimization that must be disabled on any key whose record has been touched by a supersession event. ## Operational Effect Downstream, the stale record at `k1` is retrieved by RAG for every subsequent query about plan X refunds. Because retrieval scores on embedding similarity and the stale record is the *only* record at that key, the agent answers 30 days with high confidence and cites a semantic record whose provenance chain terminates at `e_B:90` — an episode that was itself superseded by `e_C:12`. The citation looks valid at the semantic tier; the contradiction is only visible if you walk provenance down to the episodic tier, which RAG does not do. The compounding effect: every consolidation cycle re-distills the same cluster, re-derives the same string, hits the same key, and skips again. The staleness is *stable* — it does not decay, does not trigger a re-consolidation, and does not surface as an error. It is a silent fixed point. The only recovery is an out-of-band audit that compares semantic claims against live episodic evidence, which is exactly the check the dedup layer was supposed to make cheap. The guardrail: dedup keys must be `(normalized_claim, antecedent_merkle_root)` or the write path must consult a supersession log before skipping. And every semantic record must carry `derived_from: [episode_ids]` with a `superseded_by` pointer that consolidation checks before it decides "already exists." ```python import hashlib from dataclasses import dataclass, field from typing import Optional class ConsolidationDedupCollision(RuntimeError): """Raised when a semantic write hits a dedup key whose antecedent set is disjoint from (or supersedes) the existing record's antecedent set. This is a supersession, not a duplicate; skipping would freeze a stale fact.""" pass @dataclass class SemanticRecord: key: str claim: str derived_from: frozenset[str] version: int = 1 superseded_by: Optional[int] = None invalidated_at: Optional[int] = None def normalize(claim: str) -> str: return "".join(claim.split()).lower() def dedup_key(claim: str) -> str: return hashlib.sha256(normalize(claim).encode()).hexdigest() def consolidate_write( index: dict[str, SemanticRecord], claim: str, antecedent_ids: frozenset[str], supersedes: frozenset[str], clock: int, ) -> SemanticRecord: key = dedup_key(claim) existing = index.get(key) if existing is None: rec = SemanticRecord(key=key, claim=claim, derived_from=antecedent_ids) index[key] = rec return rec # Pending tombstone: key still occupied, write must not be silently dropped. if existing.invalidated_at is not None: raise ConsolidationDedupCollision( f"key {key[:12]} occupied by invalidated record awaiting GC; " f"refusing skip on new antecedents {sorted(antecedent_ids)}" ) shared = existing.derived_from & antecedent_ids correction = bool(supersedes & existing.derived_from) if shared and not correction: # True replay: same cluster re-distilled. Idempotent skip is safe. return existing if not shared or correction: # Disjoint antecedents or explicit supersession: this is a new derivation # that collides on the normalized string. Must version, not skip. new = SemanticRecord( key=key, claim=claim, derived_from=antecedent_ids, version=existing.version + 1, ) existing.superseded_by = new.version existing.invalidated_at = clock index[key] = new raise ConsolidationDedupCollision( f"supersession at key {key[:12]}: v{existing.version} invalidated, " f"v{new.version} written from antecedents {sorted(antecedent_ids)}" ) raise ConsolidationDedupCollision( f"undecidable dedup state at key {key[:12]}: " f"shared={sorted(shared)} supersedes={sorted(supersedes)}" ) ```