# Which invariants prevent provenance-tagged memory writes from silently overwriting contradicting facts during cross-session consolidation **Date of Record:** 2026 November 24 **Scope:** Applies to any agent that persists facts across sessions into a store where each memory carries provenance (source session, timestamp, evidence pointer) and where a consolidation step merges new observations against existing records. Does not apply to single-session scratchpads, stateless RAG over immutable corpora, or stores that forbid overwrites by construction. ## Core Distinction The failure is not "the agent forgot" and not "retrieval returned the wrong chunk." It is a *write-time* defect: during cross-session consolidation, a new observation that contradicts an existing provenance-tagged fact is committed as an update-in-place rather than as a new version, and the contradiction is laundered into a silent supersession. The store remains internally consistent, retrieval remains confident, and the losing fact is unrecoverable because its provenance pointer was overwritten rather than retained as a sibling. Two superficially similar behaviors must be separated. *Conflict detection* asks whether the new fact contradicts the old one—a semantic judgment the model makes probabilistically and will sometimes get wrong. *Conflict preservation* asks whether, once any contradiction is suspected, the store keeps both claims addressable with their provenance intact. The boundary invariant lives entirely in the second: even when the contradiction detector is wrong, the store must not destroy the evidence needed to later discover it was wrong. Consolidation systems that conflate "I believe the new fact" with "the old fact never existed" fail this invariant while passing every consistency check. ## What Was Observed A long-running assistant agent maintained a persistent memory store of user facts, each record shaped as `{subject, predicate, object, provenance{source_session, turn, observed_at}, confidence}`. After each session, a consolidation pass ran: it retrieved candidate records by embedding similarity on `(subject, predicate)`, asked the model whether the new observation agreed, and on disagreement executed an update of `object` plus a rewrite of `provenance` to the new session. The trace that exposed the defect: 1. Session 12 established `(project-x, deployment_region, eu-west-1)` with provenance `{source_session: 12, turn: 41}`. 2. Session 47 contained a *conditional* statement: "if we ever move off eu-west-1, it'd be to us-east-1." The extractor emitted `(project-x, deployment_region, us-east-1)` with confidence 0.6. 3. Consolidation retrieved the session-12 record, the model judged "disagreement," and the update fired. The record became `object: us-east-1`, `provenance: {source_session: 47}`, `confidence: 0.6`. 4. Session 48 asked "where is project-x deployed?" and the agent answered `us-east-1` with full provenance confidence—citing a session in which the user had explicitly stated the opposite as a hypothetical. The signature is diagnostic: the surviving record's confidence *dropped* (0.9 → 0.6) while its provenance *advanced* to a later session. A monotone store would never let a later, weaker observation replace an earlier, stronger one without a version edge. The provenance rewrite is what made the loss invisible—the audit trail pointed at the wrong session, so any downstream check that "the cited session supports the value" would pass against the hypothetical, not the assertion. A second trace showed the compounding case. Session 51 restated the original `eu-west-1` fact. Consolidation now saw a contradiction against the session-47 record, judged disagreement, and rewrote again—`object: eu-west-1`, `provenance: {source_session: 51}`. The store had oscillated twice and now carried a provenance chain of length one pointing at session 51, with sessions 12 and 47 erased. The final state was *correct by accident* and *unauditable by design*: there was no way to know the value had been wrong for four sessions, or that session 47 was a hypothetical. ## Condition of Validity The defect requires all of the following to co-occur: - **Mutable object field.** The record's `object` is updated in place rather than appended as a new versioned assertion. If the store is append-only with a `supersedes` edge, the invariant holds trivially. - **Provenance rewrite on update.** The `provenance` block is replaced rather than accumulated. This is the specific non-obvious trigger: even an append-only *object* history is defeated if provenance is a single mutable slot, because the audit trail loses the ability to distinguish "session 47 asserted X" from "session 47 mentioned X conditionally." - **Probabilistic contradiction judgment at write time.** The agree/disagree decision is made by the model on a single pass, with no requirement that the new observation be *assertoric* (declarative, non-conditional, non-hypothetical) before it is allowed to supersede. - **No confidence monotonicity gate.** A lower-confidence new observation is permitted to overwrite a higher-confidence existing one. When any one of these is absent, the failure does not manifest. In particular, an append-only store with mutable provenance still fails—so the common mitigation of "just version the object" is insufficient. ## Decision Boundary The boundary is between *recording a contradiction* and *resolving a contradiction*, and it must be enforced structurally, not by model judgment. - **On the recording side (always permitted):** any new observation may be written as a new assertion node with its own provenance, regardless of confidence, regardless of whether the model thinks it agrees. Recording is unconditional and cheap. - **On the resolution side (gated):** supersession—marking an existing assertion as no longer current—requires the new observation to pass a *promotability* gate: it must be assertoric (not conditional, hypothetical, negated, or quoted from a third party), its provenance must be independently verifiable against the cited session turn, and its confidence must meet or exceed the incumbent's, or an explicit human/auditor override must be recorded as its own provenance node. The invariant to state precisely: **for every `(subject, predicate)` key, the store must retain at least one assertion node per distinct `object` value ever observed, each with an unbroken provenance pointer to the session turn that produced it, and the "current" pointer must be derivable from those nodes by a deterministic rule—never by destructive overwrite.** Contradiction resolution becomes a *read-time* computation over the retained node set, not a *write-time* mutation of it. This is why the confidence-drop-plus-provenance-advance signature is a reliable detector: under the invariant, a current pointer can only advance to a node whose promotability gate passed, and a gate-passing node cannot have lower confidence than its incumbent absent an override record. The signature is the observable shadow of a violated gate. ## Operational Effect With the invariant enforced, the session-47 hypothetical is written as a low-confidence assertion node tagged `modality: conditional`, the session-12 node remains current, and the session-48 query answers `eu-west-1` citing session 12. The session-51 restatement does not "oscillate"—it adds a third node that *confirms* session 12, raising the effective confidence of the `eu-west-1` cluster and leaving an auditable three-node history. The agent can now answer not just "where is it deployed" but "has this ever been in question, and on what basis," which is the entire point of provenance. The cost is storage growth proportional to the number of distinct observations per key, bounded in practice because most keys see few distinct objects. The cost of *not* enforcing it is silent, unbounded, and undetectable from inside the store—the failure produces a store that is more confident and less correct with every consolidation pass. The guardrail is a single write-path check, not a retrieval heuristic. It must run before the commit, not as a post-hoc audit, because the destructive overwrite is what removes the evidence an audit would need. ```python from dataclasses import dataclass, field from typing import Literal from datetime import datetime class ProvenanceInvariantError(RuntimeError): """Raised when a consolidation write would destroy a contradicting assertion's provenance.""" pass @dataclass class Assertion: subject: str predicate: str object: str source_session: int turn: int observed_at: datetime confidence: float modality: Literal["assertoric", "conditional", "hypothetical", "quoted"] = "assertoric" supersedes: list["Assertion"] = field(default_factory=list) class ProvenanceStore: def __init__(self) -> None: # Append-only node set; "current" is derived, never stored destructively. self._nodes: list[Assertion] = [] def _key(self, a: Assertion) -> tuple[str, str]: return (a.subject, a.predicate) def current(self, subject: str, predicate: str) -> Assertion | None: candidates = [n for n in self._nodes if self._key(n) == (subject, predicate)] if not candidates: return None # Deterministic read-time rule: highest confidence among promotable nodes, # tie-broken by latest observed_at. Conditional/hypothetical nodes never win. promotable = [n for n in candidates if n.modality == "assertoric"] pool = promotable or candidates return max(pool, key=lambda n: (n.confidence, n.observed_at)) def consolidate(self, new: Assertion, override: bool = False) -> None: incumbent = self.current(new.subject, new.predicate) # Recording is unconditional: the node is always appended with intact provenance. # Resolution is gated: only promotable observations may become current. if incumbent is not None and incumbent.object != new.object: if new.modality != "assertoric" and not override: self._nodes.append(new) return # recorded as a sibling; incumbent stays current if new.confidence < incumbent.confidence and not override: raise ProvenanceInvariantError( f"Refusing to supersede {incumbent.object!r} " f"(conf={incumbent.confidence}, session={incumbent.source_session}) " f"with {new.object!r} (conf={new.confidence}, session={new.source_session}) " f"for key {self._key(new)}: lower-confidence write would launder " f"contradiction into silent supersession." ) new.supersedes.append(incumbent) self._nodes.append(new) def audit(self, subject: str, predicate: str) -> list[Assertion]: return [n for n in self._nodes if self._key(n) == (subject, predicate)] ```