# What structural signals indicate episodic-to-semantic contamination in hybrid vector-plus-graph recall for long-horizon agents **Date of Record:** 2026 November 24 **Scope:** Applies to long-horizon agents that maintain a dual-store memory (an episodic log of timestamped events plus a semantic knowledge graph with entities and typed edges) and answer recall queries by fusing vector similarity over episodic embeddings with graph traversal over semantic nodes. Does not apply to single-turn RAG or to agents whose "semantic" layer is a plain re-embedding of the same episodic chunks (no separate graph, no distillation step). ## Core Distinction The failure is not "bad retrieval." It is **episodic-to-semantic contamination**: a specific episodic event gets distilled into a semantic node or edge *before* the event's validity window closes, so that the graph asserts a fact that was only ever true for one episode. The vector store and the graph store then disagree about the *modality* of the same claim—one holds it as "happened at T," the other as "is true"—and the fusion layer at recall time cannot tell the difference. The invariant that must hold is a **modality separation invariant**: every semantic edge carries a `derived_from` set of episodic event IDs and a `valid_from`/`valid_until` interval, and no semantic edge may be traversed for a query whose temporal scope is disjoint from that interval. When this invariant is violated, the agent does not merely recall a stale fact—it recalls a stale fact *with the epistemic weight of a distilled truth*, which is strictly worse than recalling nothing, because it suppresses the conflict that a raw episodic retrieval would have surfaced. ## What Was Observed A scheduling agent running a 14-day horizon maintained episodic events of the form `(event_id, ts, actor, action, payload)`. A background distiller ran every 200 events, extracting candidate `(subject, predicate, object, valid_from, valid_until)` tuples and merging them into the graph. The distiller inferred `valid_until` from payload text, defaulting to `None` (open-ended) when no explicit end was stated. Observed trace on a contaminated edge: 1. Day 3, event `e_4412`: `{"ts": "03T14:02", "action": "assign_owner", "payload": "ticket #88 -> alice (covering for bob this sprint)"}`. The parenthetical was not parsed. Distiller emitted `(#88, owned_by, alice, valid_from=03T14:02, valid_until=None)`. 2. Day 9, event `e_9901`: `{"ts": "09T09:11", "action": "assign_owner", "payload": "ticket #88 -> bob"}`. Distiller emitted `(#88, owned_by, bob, valid_from=09T09:11, valid_until=None)`. 3. The graph now holds **two open-ended `owned_by` edges for the same subject**. The merge policy was "last-write-wins per predicate," so `alice` was soft-deleted but its `derived_from` set was retained for audit. 4. Day 11, query: "Who owns #88 and since when?" Fusion ran vector search (top-k=8 over episodic embeddings) plus 2-hop graph traversal from `#88`. Vector hits included `e_4412` and `e_9901`; graph traversal returned only `bob` (soft-deleted edge excluded). The fusion scored `bob` at 0.91 and `alice` at 0.34. 5. The agent answered "bob, since day 9" and—critically—did **not** flag the day-3 handoff. The vector store had the evidence; the graph had already adjudicated it away. The non-obvious part: **the soft-delete was the contamination vector, not the distillation error.** The distiller's failure to parse "covering for bob this sprint" was recoverable—it left a wrong-but-visible edge. The merge policy's decision to soft-delete `alice` and *suppress it from traversal while keeping it in the audit log* is what made the two stores disagree. The graph store had enough information to answer correctly and chose not to expose it. A second signal appeared in the embedding space. Because `e_4412` and `e_9901` share the surface form `assign_owner ticket #88 ->`, their episodic embeddings had cosine similarity 0.87. Any recall that fused by *semantic* similarity of the episodic chunks would rank them together and could reconstruct the handoff. The graph path, by contrast, returned a single node. The fusion layer weighted graph (0.6) over vector (0.4) and lost the contradiction. **The disagreement between the two stores was itself the signal, and the fusion layer averaged it away.** ## Condition of Validity The contamination is only possible when all three of the following hold simultaneously; removing any one bounds it: - **Open-interval distillation.** The distiller emits edges with `valid_until=None` for predicates that are in fact episodic (ownership, assignment, location, active-plan). A distiller that refuses to close an interval without explicit end evidence, and instead emits a *provisional* edge marked `interval_status="open_inferred"`, keeps the modality distinguishable. - **Destructive merge.** The graph applies last-write-wins with soft-delete that is invisible to traversal. If superseded edges remain traversable but are tagged `superseded_by`, the fusion layer can see both and must reconcile. - **Fusion that averages modalities.** The recall layer combines vector and graph scores into a single scalar and ranks. If instead the fusion layer treats a *graph/vector disagreement on the same subject-predicate* as a contradiction event requiring escalation, the contamination surfaces as a query-time conflict rather than a confident wrong answer. The invariant to enforce: **a semantic edge may be traversed only if `interval_status="closed"` or the query's temporal scope intersects `valid_from..valid_until`; provisional and superseded edges are traversable but must be returned with their status attached, and any recall that returns both a provisional/superseded edge and a closed edge for the same `(subject, predicate)` must raise a contradiction rather than rank.** ## Decision Boundary The boundary is **whether the query's temporal scope is closed or open**. For a closed-scope query ("who owned #88 on day 5?"), the correct behavior is to traverse *all* edges whose interval contains day 5, including superseded ones, and return `alice` with `interval_status="superseded"`. For an open-scope query ("who owns #88 now?"), traverse only closed edges with `valid_until=None`, and if a superseded edge exists within the last N events, attach it as a *provenance note* rather than a competing answer. The failure occurs precisely when an open-scope query is answered by a fusion that has already collapsed the stores. The boundary condition is: **open-scope query + provisional or superseded edge present + fusion weight on graph > weight on vector.** At that point the agent will confidently answer the current state and silently drop the handoff history, and downstream planning that depends on "how long has bob owned this" will be off by six days with no error signal. A second boundary: **distillation cadence vs. event horizon.** If the distiller runs every 200 events and the horizon is 14 days at ~150 events/day, the distiller sees ~10.5 batches. An edge distilled in batch 2 and superseded in batch 5 is soft-deleted before any query in batch 6+; the window in which the contradiction is visible in the graph is one batch. Any query after batch 5 sees only the adjudicated graph. The invariant must be enforced at *distillation* time (provisional tagging), not at *query* time, because by query time the evidence is gone from the traversable graph. ## Operational Effect Without the invariant, the agent's answers degrade monotonically with horizon length: each distillation batch adjudicates away one more superseded edge, and the graph's confidence rises as its evidence base narrows. The vector store retains the raw events, but because fusion weights graph higher, the retained evidence is outvoted. The observable symptom is an agent that is *most confident and most wrong* about the oldest, most-revised facts—exactly the facts a long-horizon planner depends on. With the invariant, the cost is recall latency (traversing superseded edges) and answer verbosity (attaching provenance notes). The benefit is that contradiction is a first-class query result: the agent can say "bob owns #88 since day 9; alice held it day 3–9 as a sprint cover" and the planner can reason about the handoff. The guardrail is not "retrieve more"—it is "never let the graph store adjudicate a modality the episodic store has not closed." ```python from dataclasses import dataclass from typing import Optional class ModalityContaminationError(RuntimeError): """Raised when recall fuses a provisional/superseded semantic edge with a closed edge for the same (subject, predicate) without surfacing the conflict.""" pass @dataclass(frozen=True) class SemanticEdge: subject: str predicate: str obj: str valid_from: str valid_until: Optional[str] # None => open interval interval_status: str # "closed" | "open_inferred" | "superseded" derived_from: tuple[str, ...] # episodic event IDs superseded_by: Optional[str] = None def fuse_recall( query_scope: str, # "open" | "closed" graph_hits: list[SemanticEdge], vector_score: dict[str, float], graph_weight: float = 0.6, ) -> dict: """Fuse graph and vector recall under the modality separation invariant. Raises ModalityContaminationError if an open-scope query would collapse a provisional/superseded edge into a single confident answer. """ by_key: dict[tuple[str, str], list[SemanticEdge]] = {} for e in graph_hits: if e.interval_status == "superseded" and e.superseded_by is None: raise ModalityContaminationError( f"superseded edge {e.subject}/{e.predicate}->{e.obj} " f"has no superseded_by pointer; provenance chain broken" ) by_key.setdefault((e.subject, e.predicate), []).append(e) for key, edges in by_key.items(): closed = [e for e in edges if e.interval_status == "closed"] provisional = [e for e in edges if e.interval_status == "open_inferred"] superseded = [e for e in edges if e.interval_status == "superseded"] if query_scope == "open" and (provisional or superseded): # The graph has not adjudicated this predicate for an open-scope # query; fusing would silently drop the handoff history. if graph_weight > 0.5: raise ModalityContaminationError( f"open-scope query on {key} would collapse " f"{len(provisional)} provisional and {len(superseded)} " f"superseded edges under graph_weight={graph_weight}; " f"surface provenance instead of ranking" ) if query_scope == "closed": # Closed-scope queries MUST traverse superseded edges. for e in superseded: if e.obj not in vector_score: raise ModalityContaminationError( f"closed-scope query on {key} traversed superseded " f"edge ->{e.obj} but vector store has no supporting " f"episodic hit; evidence base inconsistent" ) return { "scope": query_scope, "edges": graph_hits, "provenance_required": any( e.interval_status != "closed" for e in graph_hits ), } ```