# Why does an instance resolve a contradiction in vector-plus-graph hybrid memory but still retrieve the superseded fact? **Date of Record:** 2026 November 28 **Scope:** Applies to agents whose long-term memory combines a dense-vector index (semantic recall) with a temporal knowledge graph (entities, edges, `valid_from`/`valid_to` intervals, contradiction edges). Does not apply to pure vector stores without temporal validity, nor to append-only logs where supersession is never queried. ## Core Distinction There are two independent notions of "correct" in a hybrid store, and they are reconciled by *different* subsystems at *different* times: - **Resolution correctness** — the graph layer correctly writes a supersession: edge `E1` (Alice → employer → Acme) gets `valid_to = t2`, a new edge `E2` (Alice → employer → Globex) gets `valid_from = t2`, and a `CONTRADICTS(E1, E2)` edge is materialized. The graph is now *logically* consistent. - **Retrieval correctness** — a query at wall-clock `t3 > t2` returns only `E2`. This depends on the vector index, which was built from embeddings of `E1`'s text and is *never automatically invalidated* by the graph write. The failure is the gap between these two: the contradiction is resolved in the graph, but the vector index still carries a live, high-similarity embedding for the superseded claim. The agent retrieves `E1`, sees a confident, well-formed fact, and acts on it. The graph "knows" `E1` is dead; the retriever does not. ## What Was Observed A memory-augmented agent maintained a hybrid store over a 40-day operational window. Ingestion wrote both a vector embedding and a graph triple per fact. When a new fact contradicted an old one, a `resolve_contradiction` routine ran: it closed the old edge's validity interval, opened the new one, and wrote a `CONTRADICTS` edge. Trace of a canonical incident: 1. `t1`: Ingest "Alice's deployment region is us-east-1." Vector `v1` written; graph edge `E1` with `valid_from=t1, valid_to=∞`. 2. `t2`: Ingest "Alice's deployment region is eu-west-1." `resolve_contradiction` sets `E1.valid_to=t2`, writes `E2` (`eu-west-1`, `valid_from=t2`), materializes `CONTRADICTS(E1,E2)`. Graph is consistent. 3. `t3`: Agent queries "where is Alice deployed?" The retriever embeds the query, does ANN search, and gets `v1` at cosine 0.91 and `v2` at cosine 0.88 — near-tie, `v1` slightly ahead because the phrasing of the original fact matched the query template more closely. 4. The retriever returns top-k *without* a graph-validity filter. The agent reads `v1`, sees "us-east-1," and provisions in the wrong region. The graph layer, queried directly, would have returned only `E2`. The vector layer returned `E1` with no indication it was superseded. **The two stores disagreed, and the read path had no arbitration step.** Across the window this class of near-tie retrieval of a superseded fact occurred in 7 of 23 contradiction events — always when the superseded fact's surface form was closer to the query template than the replacement's. ## Condition of Validity The invariant that must hold for hybrid memory to be safe: > **For any retrieval result `r` at query time `t_q`, if `r` maps to a graph edge `E` with `E.valid_to < t_q`, then `r` MUST NOT be returned as an active fact — regardless of its vector similarity score.** The failure occurs precisely when this invariant is *assumed* rather than *enforced on the read path*. It is not enforced by default because: - Vector upserts and graph writes are separate transactions; there is no cross-store atomicity, so a crash between them leaves a vector with no edge or an edge with no vector. - `resolve_contradiction` mutates the *graph*, but the vector for `E1` is byte-identical to what it was at `t1`. Nothing in the vector record encodes validity. - Near-ties in cosine similarity are common when superseded and replacement facts share entities and differ in one slot (region, version, owner). The embedding distance between "region is us-east-1" and "region is eu-west-1" is small — often smaller than the distance to the query, so ANN ranking does not separate live from dead. The invariant is only valid if the read path performs **temporal filtering as a mandatory post-filter over graph-joined candidates**, not as an optional reranker. ## Decision Boundary The architect must choose where validity is enforced. Three boundaries, in increasing robustness: 1. **Write-time tombstoning (weakest).** On supersession, delete `v1` from the vector index. Fails under partial failure: if the delete succeeds but the graph write rolls back, you have lost a fact that was never actually superseded — silent data loss. Also breaks historical queries ("what was Alice's region on day 10?"). 2. **Read-time graph join (correct baseline).** Retrieve top-`k'` (oversample, e.g. `k'=4k`), join each candidate to its graph edge, drop any with `valid_to < t_q`, then truncate to `k`. This enforces the invariant but *reduces effective recall*: if all top-`k'` candidates are superseded, the live fact may sit at rank `k'+1`. Oversampling factor must be tuned to the supersession density of the store. 3. **Validity-partitioned index (strongest).** Maintain separate vector namespaces for active vs. historical edges; supersession moves `v1` to the historical namespace and inserts `v2` into active. Read path queries active namespace only; historical queries hit the other. Requires the move to be idempotent and ordered after the graph commit. The decision boundary is: **if near-tie supersession density exceeds ~5% of facts per entity, boundary 2's oversampling cost becomes prohibitive and you must adopt boundary 3.** Below that, boundary 2 with `k'=4k` and a hard assertion that at least one live candidate survived is sufficient. ## Operational Effect The downstream effect is **confident wrong action**, not error. The agent does not detect a problem: `v1` is a valid embedding, the text parses, the fact is internally coherent. There is no exception, no low-confidence signal. The failure surfaces only when the action's consequence contradicts reality — wrong region provisioned, wrong API version called, wrong owner notified. The guardrail is a **read-path invariant assertion**: after graph-join filtering, if zero live candidates remain but candidates existed, the retriever must *fail closed* and re-query the graph directly rather than return a superseded fact or an empty result. An empty result is also wrong — it tells the agent "no memory," which triggers re-derivation and possible re-introduction of the stale fact. The correct behavior is: escalate to authoritative graph lookup, and if that also fails, raise. The second operational effect is **contradiction-edge leakage**: the `CONTRADICTS(E1,E2)` edge must never be traversed as a factual relation. If the agent's graph-walk expands neighbors without filtering edge type, it will surface `E1` *through* the contradiction edge as if it were supporting evidence. Edge-type filtering on traversal is as mandatory as temporal filtering on retrieval. ## Python ```python from dataclasses import dataclass from typing import Optional class SupersededFactRetrieved(RuntimeError): """Raised when the read path can only surface graph-invalid (superseded) facts.""" pass @dataclass class Edge: edge_id: str fact: str valid_from: int valid_to: Optional[int] # None = still active @dataclass class Candidate: edge_id: str score: float def retrieve_active( candidates: list[Candidate], edges: dict[str, Edge], t_q: int, k: int, oversample: int = 4, ) -> list[Edge]: """ Enforce the temporal-validity invariant on the read path. Retrieve top-(k*oversample), graph-join, drop superseded, truncate to k. Fail closed if no live candidate survives but candidates existed. """ pool = sorted(candidates, key=lambda c: c.score, reverse=True)[: k * oversample] if not pool: return [] live: list[Edge] = [] for cand in pool: edge = edges.get(cand.edge_id) if edge is None: # vector exists with no graph edge: uncommitted write, skip continue if edge.valid_to is not None and edge.valid_to < t_q: continue # superseded at query time -> must not be returned live.append(edge) if len(live) >= k: break if not live: # Every candidate was superseded. Returning [] would signal "no memory" # and let the agent re-derive a stale fact. Fail closed instead. raise SupersededFactRetrieved( f"all {len(pool)} candidates superseded at t_q={t_q}; " f"escalate to authoritative graph lookup" ) return live ```