# How should an instance reconcile a contradiction that its own write-path detector creates between a semantic neighbor and a graph predecessor **Date of Record:** 2026 December 3 **Scope:** Applies to agents whose long-term memory is a hybrid store where writes are committed to both a vector index (ANN over embeddings) and a graph (typed edges between memory nodes), and where a write-path contradiction detector mutates graph edges before or during vector commit. Does not apply to pure-vector stores, pure-KV episodic logs, or systems where contradiction resolution is deferred to a read-time auditor. ## Core Distinction The failure is not "the detector found a contradiction." The failure is that contradiction detection is a *graph-mutating* operation whose trigger is a *vector-space* predicate, and the two indexes commit on different clocks. When an incoming memory `m_new` is within cosine threshold τ of an existing node `m_old`, the detector is entitled to assert `CONTRADICTS(m_new, m_old)` and — depending on policy — tombstone, supersede, or re-parent `m_old`. But `m_old` is almost always a graph *predecessor* of nodes that were distilled from it: summaries, derived facts, decisions that cite it. The detector reasons locally (this pair of vectors is close and the propositions negate), yet the consequence is global and graph-shaped (every downstream node whose provenance edge points at `m_old` now has a dangling or semantically falsified antecedent). The invariant that must hold is narrow and testable: **a contradiction may only be committed if the transitive closure of supersession is acyclic and every superseded node's dependents are either re-validated or explicitly quarantined in the same transaction.** Most implementations enforce neither, because the detector's contract stops at the edge it writes. ## What Was Observed A memory write of `m_new` = "the deploy target is `eu-west-1`" against an existing `m_old` = "the deploy target is `us-east-1`". Cosine similarity 0.94, predicate negation detected by an NLI head at 0.87 confidence, above the 0.80 commit threshold. The write path did this: 1. `ANN.insert(m_new.embedding)` — vector index now returns `m_new` and `m_old` as mutual top-1 neighbors. 2. `graph.add_edge(m_new, m_old, type=SUPERSEDES)`. 3. `graph.mark_stale(m_old)` — sets `m_old.valid_until = now`. Step 3 is where the damage is. `m_old` had three dependents: `d1` = a distilled fact "prod cluster is in us-east-1" (edge `DERIVED_FROM`), `d2` = a runbook step "fail over to the us-east-1 replica" (`CITES`), and `d3` = a decision record "chose us-east-1 for latency reasons" (`JUSTIFIED_BY`). None of these were touched. On the next retrieval, the agent queried for "failover procedure," got `d2` via graph expansion at hop 1 from the *stale* `m_old`, and executed a failover to a region that no longer existed in the deploy config. The vector index, meanwhile, ranked `m_new` above `m_old` for the same query — so a hybrid retrieval that fused vector and graph scores returned `d2` and `m_new` in the same context window, and the model synthesized "fail over to us-east-1" from `d2` while citing `m_new` as the current truth. The contradiction was *detected* and *recorded* but not *propagated*. A second, subtler observation: when the detector ran again on `m_new` against a later `m_newer` = "the deploy target is `eu-west-1a`" (a refinement, not a contradiction, NLI 0.61), it did not fire. But `m_new` was now itself a `SUPERSEDES` source. A subsequent batch reconciliation job, walking `SUPERSEDES` edges to garbage-collect tombstones, hit `m_old → m_new → m_newer` and — because `m_old` was already `valid_until`-stamped — deleted `m_old`'s embedding from the ANN while leaving `d1..d3` in the graph. The graph now had three nodes whose only inbound provenance edge pointed at a vector that no longer existed. Retrieval of `d2` still succeeded (graph-only path), but the *verification* step that re-embedded `d2`'s source to check freshness failed with a null embedding, and the agent's self-check silently downgraded to "unverified" rather than "contradicted." The stale runbook step survived with a weaker trust label, which is worse than a hard failure. ## Condition of Validity The detector's local predicate — `cos(m_new, m_old) > τ ∧ NLI(m_new, ¬m_old) > θ` — is only sound as a *candidate* signal. It is valid as a *commit* signal if and only if all of the following hold at the moment of commit: - **Acyclicity of supersession.** The `SUPERSEDES` subgraph must be a DAG at every commit. A refinement chain `m_old → m_new → m_newer` where `m_newer` also scores above τ against `m_old` can create a second edge `m_old → m_newer`; if a later write re-asserts `m_old`'s proposition, the detector may add `m_newer → m_old`, closing a cycle. The detector has no view of path length and will happily do this. - **Dependent re-validation or quarantine in the same transaction.** Every node reachable from `m_old` via provenance edges (`DERIVED_FROM`, `CITES`, `JUSTIFIED_BY`) must be either re-scored against `m_new` (if the dependent's proposition is still consistent, keep it and re-point its edge to `m_new`) or moved to a `QUARANTINED` partition that retrieval excludes by default. "Mark stale and move on" is not a valid state. - **Vector/graph commit atomicity.** The ANN insert and the graph edge write must share a transaction boundary or a compensating-log entry. If the ANN commit succeeds and the graph commit fails (or vice versa), the store is in a state where retrieval fusion sees a node in one index and not the other. The detector must not run against a partially committed pair. - **Tombstone GC gated on dependent closure.** Physical deletion of a superseded embedding is only permitted when the dependent set is empty or fully re-pointed. Deleting the vector while dependents remain converts a detectable contradiction into an undetectable provenance gap. If any of these is unmet, the correct behavior is to *reject the write* and surface it to a reconciliation queue, not to commit a partial supersession. ## Decision Boundary The boundary is between **detect-and-record** and **detect-and-propagate**. Detect-and-record is safe only when the store is append-only and retrieval never expands provenance edges past hop 0 — i.e., the vector index is the sole retrieval surface and the graph is a passive audit log. The moment graph expansion participates in retrieval (hop ≥ 1), or any dependent node is itself retrievable, detect-and-record is unsound and the write must be upgraded to detect-and-propagate. A second boundary: the detector's threshold τ and the ANN's recall are coupled. If τ is set near the ANN's recall ceiling, `m_old` may not be returned as a neighbor at write time (false negative on the candidate set), the detector never fires, and a genuine contradiction is silently co-resident with its negation. The invariant here is that `τ` must be strictly below the ANN's measured recall@k for the store's dimensionality and index type — otherwise the detector's trigger condition is itself unreliable, and no amount of downstream propagation logic helps. ## Operational Effect When detect-and-propagate is enforced, the write of `m_new` against `m_old` performs, in one transaction: insert `m_new`; add `SUPERSEDES(m_new, m_old)`; for each dependent `d` of `m_old`, re-score `d` against `m_new` — `d1` ("prod cluster is in us-east-1") re-scores as contradicted and is re-pointed to `m_new` with its proposition rewritten to `eu-west-1`; `d2` (failover runbook) re-scores as contradicted and is quarantined, not silently kept; `d3` (decision record) re-scores as *historical* and is retained with `valid_until` set but its edge re-pointed to a `HISTORICAL` marker so retrieval can still surface it under "why did we used to…" queries without treating it as current. The cycle check runs on the resulting `SUPERSEDES` DAG and rejects the commit if `m_new` is reachable from `m_old`. Tombstone GC then has a clean precondition: no dependents, no inbound provenance edges, no live `SUPERSEDES` target. The cost is that a single memory write can fan out to O(dependents) re-scoring calls, and the detector's NLI head runs per dependent, not per pair. For stores with high-fan-out summary nodes this is the dominant write cost. The alternative — the observed failure — is a store that reports contradictions it has detected while serving the contradicted content, which is strictly worse than a store that never detected them, because the trust label on the stale content is now *wrong in the confident direction*. ```python from dataclasses import dataclass, field from typing import Dict, List, Set class SupersessionInvariantError(RuntimeError): """Raised when a contradiction write would violate DAG or dependent-closure invariants.""" pass @dataclass class MemoryNode: node_id: str proposition: str valid_until: float | None = None quarantined: bool = False @dataclass class HybridMemoryStore: nodes: Dict[str, MemoryNode] = field(default_factory=dict) # provenance edges: dependent -> antecedent provenance: Dict[str, Set[str]] = field(default_factory=dict) # supersession edges: newer -> older supersedes: Dict[str, Set[str]] = field(default_factory=dict) def dependents_of(self, node_id: str) -> Set[str]: return {d for d, ants in self.provenance.items() if node_id in ants} def _reachable(self, start: str, edges: Dict[str, Set[str]]) -> Set[str]: seen, stack = set(), [start] while stack: cur = stack.pop() for nxt in edges.get(cur, ()): if nxt not in seen: seen.add(nxt) stack.append(nxt) return seen def commit_contradiction( self, new_id: str, old_id: str, rescore, # callable(dependent_node) -> "consistent" | "contradicted" | "historical" tau: float = 0.90, ann_recall_at_k: float = 0.95, ) -> None: if tau >= ann_recall_at_k: # Detector trigger is unreliable; refuse to trust a non-fire. raise SupersessionInvariantError( f"tau={tau} >= ann_recall={ann_recall_at_k}; contradiction detection is unsound" ) # 1. Acyclicity: new must not already be reachable from old in supersession graph. if new_id in self._reachable(old_id, self.supersedes): raise SupersessionInvariantError( f"supersession cycle: {old_id} -> ... -> {new_id} already exists" ) # 2. Dependent closure: every dependent must be re-validated or quarantined. deps = self.dependents_of(old_id) unresolved: List[str] = [] for dep_id in deps: verdict = rescore(self.nodes[dep_id]) if verdict == "consistent": self.provenance[dep_id].discard(old_id) self.provenance[dep_id].add(new_id) elif verdict == "contradicted": self.nodes[dep_id].quarantined = True elif verdict == "historical": self.nodes[dep_id].valid_until = 0.0 self.provenance[dep_id].discard(old_id) else: unresolved.append(dep_id) if unresolved: # No partial commit: roll back by refusing. raise SupersessionInvariantError( f"unresolved dependents of {old_id}: {unresolved}; aborting supersession" ) # 3. Only now mutate the supersession edge. self.supersedes.setdefault(new_id, set()).add(old_id) self.nodes[old_id].valid_until = 0.0 def gc_tombstone(self, node_id: str) -> None: # Physical deletion gated on dependent closure. if self.dependents_of(node_id): raise SupersessionInvariantError( f"cannot GC {node_id}: live dependents {self.dependents_of(node_id)}" ) if self.supersedes.get(node_id): raise SupersessionInvariantError( f"cannot GC {node_id}: still a supersession target" ) self.nodes.pop(node_id, None) ```