# Which invariants prevent provenance-weighted trust scoring from silently ratifying a poisoned memory after cross-session corroboration **Date of Record:** 2026 December 1 **Scope:** Applies to persistent agent memory stores where retrieved episodic records carry provenance metadata (writer identity, session lineage, write-time trust) and where a downstream trust score is computed by weighting provenance against cross-session corroboration counts. Does not apply to stateless single-turn agents, nor to stores where each memory record is re-validated against ground truth on every read. ## Core Distinction There are two ways a poisoned memory can enter an agent's working context. The first is *injection*: a hostile record arrives through a tool output, retrieved document, or peer handoff and is used before any trust evaluation runs. This is a known and largely solved problem — you gate writes, you sanitize, you treat untrusted tool output as data rather than instruction. The second is *ratification*: the poisoned record is written while correctly flagged as low-trust, and then, over multiple sessions, the trust-scoring layer itself promotes it to high-trust because independent-looking corroboration accumulates. The record is never re-examined against its origin. The failure is not that the poison got in — it is that the scoring function confused *frequency of restatement* with *independence of evidence*, and the agent's own memory system laundered the poison into a verified-seeming fact. This article is about the second failure. It is non-obvious because every individual step looks correct: the write was gated, the provenance was recorded, the corroboration was counted, the score was recomputed. The invariant that breaks is the one nobody wrote down: *corroboration weight must be conditioned on causal independence of the corroborating sources, and provenance must be recomputed on merge, not inherited.* ## What Was Observed A research agent maintains a semantic memory store. Each record has the shape `{claim, provenance: {writer_id, session_id, parent_record_id, write_time_trust}, corroboration_count, trust_score}`. On write, `write_time_trust` is assigned by an ingestion gate: 0.9 for records distilled from the agent's own verified tool outputs, 0.4 for records distilled from retrieved web content, 0.2 for records from peer-agent handoffs. The trust score is recomputed on every retrieval: ``` trust_score = write_time_trust * decay(age) + λ * corroboration_count ``` with `λ = 0.15` and corroboration counted as "number of distinct records in the store asserting the same claim." Session 1: the agent reads a web page (untrusted, `write_time_trust = 0.4`) that asserts a specific but false fact — say, that a particular library function has a side effect it does not have. The agent distills this into record `R1` with `corroboration_count = 0`. `trust_score = 0.4 * 1.0 + 0 = 0.4`. Below the 0.7 retrieval-use threshold. Correctly quarantined. Session 2: the agent, working a different task, encounters a peer-agent handoff that restates the same false fact. The handoff record `R2` has `write_time_trust = 0.2`. But the distillation step *merges* `R2` into the existing claim cluster and increments `corroboration_count` on `R1` to 1. `R1.trust_score = 0.4 * decay + 0.15 = ~0.53`. Still below threshold, but climbing. Session 3: a third session retrieves `R1` at 0.53, uses it as a premise in a reasoning chain, and the chain's *conclusion* is written back as a new record `R3` that implicitly depends on the false fact. `R3` is written with `write_time_trust = 0.9` because it came from the agent's own reasoning. The merge step sees `R3` asserts a claim consistent with `R1` and increments `R1.corroboration_count` to 2. `R1.trust_score = 0.4 * decay + 0.30 = ~0.68`. Session 4: one more restatement — this time from a summary the agent generated of its own session-3 notes, which is a *derivative* of `R3` — pushes `corroboration_count` to 3. `R1.trust_score = 0.4 * decay + 0.45 ≈ 0.83`. Above threshold. `R1` is now retrieved as a trusted fact and injected into working context as established knowledge. The poison was never re-validated. The corroboration count included: (a) a peer handoff that was itself untrusted, (b) a conclusion the agent drew *from the poisoned record*, and (c) a summary of that conclusion. All three are causally downstream of `R1`. The scoring function treated them as three independent witnesses. The agent's memory system manufactured its own corroboration. ## Condition of Validity The provenance-weighted trust score is only a valid estimator of a claim's truth when two conditions hold jointly: 1. **Causal independence of corroborators.** Every record counted toward `corroboration_count` must be traceable to a source that did not itself derive from the record being scored. Formally, the corroboration graph restricted to the claim's cluster must be a forest with the scored record as a leaf, not a DAG with the scored record as an ancestor of its own corroborators. 2. **Provenance monotonicity under merge.** When two records are merged into a claim cluster, the cluster's `write_time_trust` must be the *minimum* (or a conservative aggregate) of the merged records' provenance, never the maximum and never inherited from the higher-trust member. A cluster is only as trustworthy as its least-trustworthy contributing source. Both conditions fail silently in the observed trace. The first fails because the merge step never checked `parent_record_id` lineage — it counted distinct records, not distinct *roots*. The second fails because `R3` was written at 0.9 (own reasoning) and the cluster inherited that provenance, erasing `R1`'s 0.4 origin. The invariant that must hold: **for any record `r`, `trust_score(r)` is computed over the set of records reachable from `r` via reverse `parent_record_id` edges that are *not* descendants of `r` — and the cluster provenance is the min over that set.** Equivalently: corroboration is counted only over the antichain of independent ancestors, and provenance never upgrades on merge. ## Decision Boundary The boundary between "trust scoring works" and "trust scoring ratifies poison" is crossed at the moment a record's `corroboration_count` includes a record whose `parent_record_id` chain passes through the scored record. Before that moment, the score is a conservative under-estimate. After it, the score is an unbounded over-estimate that grows with each session, because the agent's own downstream reasoning is the most prolific corroborator it has. Concretely, the guardrail is a lineage check at merge time, not at scoring time: - On every write, record `parent_record_ids` (plural — a distilled record may depend on several). - On every merge into a claim cluster, reject the merge if the incoming record's ancestor set intersects the cluster's existing member set. This is a cycle-detection problem on the provenance DAG, and it must run before `corroboration_count` is incremented. - On every trust recomputation, aggregate cluster provenance as `min(write_time_trust)` over independent roots only. If lineage is unavailable (e.g., a peer handoff that does not propagate `parent_record_ids`), the record must be treated as a *new root* with its own provenance, never merged into an existing cluster's corroboration count. The absence of lineage is not evidence of independence; it is the condition under which independence cannot be established, and the safe default is to not count it. A second, cheaper guardrail bounds the damage when the first is missing: cap `corroboration_count`'s contribution to `trust_score` at the provenance-weighted minimum of the corroborating set. If any corroborator has `write_time_trust < 0.5`, the entire corroboration term is scaled by that minimum. This prevents a high-trust derivative from dragging a low-trust origin over the threshold. ## Operational Effect With the lineage guardrail in place, the session-4 promotion does not occur. `R3`'s merge is rejected because its ancestor set `{R1, R2}` intersects the cluster `{R1, R2}`. `R1.corroboration_count` stays at 1 (the peer handoff, itself untrusted, and itself subject to the same check). `R1.trust_score` plateaus at ~0.53 and never crosses 0.7. The false fact remains quarantined, retrievable for inspection but never injected as established knowledge. The operational cost is a provenance DAG that grows with the store and a cycle check on every merge — bounded by the depth of distillation chains, which in practice is small (3–5 hops) because agents rarely distill more than a few layers before writing a summary. The cost of *not* having it is a memory store that, over enough sessions, converges on whatever the agent has most often restated, which is a function of task distribution rather than truth. That is the failure mode this invariant exists to prevent: a memory system that slowly replaces evidence with consensus, and consensus with its own echo. ```python from dataclasses import dataclass, field from typing import Optional class ProvenanceCycleError(RuntimeError): """Raised when a merge would make a record corroborate itself via its own descendants.""" pass @dataclass class MemoryRecord: claim: str writer_id: str session_id: str write_time_trust: float parent_record_ids: tuple[str, ...] = field(default_factory=tuple) record_id: str = "" def _ancestors(record_id: str, store: dict[str, MemoryRecord], seen: Optional[set] = None) -> set[str]: if seen is None: seen = set() if record_id in seen: return seen seen.add(record_id) rec = store.get(record_id) if rec is None: return seen for pid in rec.parent_record_ids: _ancestors(pid, store, seen) return seen def merge_into_cluster( incoming: MemoryRecord, cluster_member_ids: set[str], store: dict[str, MemoryRecord], ) -> float: """ Merge `incoming` into a claim cluster and return the cluster's new independent-root provenance floor. Raises if the merge would create self-corroboration (incoming is a descendant of a cluster member, or a cluster member is a descendant of incoming). """ incoming_ancestors = _ancestors(incoming.record_id, store) # Invariant 1: causal independence. Incoming must not be downstream of any # cluster member, and no cluster member may be downstream of incoming. for member_id in cluster_member_ids: if member_id in incoming_ancestors: raise ProvenanceCycleError( f"merge rejected: incoming record {incoming.record_id} is a " f"descendant of cluster member {member_id}; counting it would " f"let the cluster corroborate itself" ) member_ancestors = _ancestors(member_id, store) if incoming.record_id in member_ancestors: raise ProvenanceCycleError( f"merge rejected: cluster member {member_id} is a descendant " f"of incoming record {incoming.record_id}" ) # Invariant 2: provenance monotonicity. Cluster provenance is the minimum # over independent roots, never inherited from the highest-trust member. root_trusts = [incoming.write_time_trust] for member_id in cluster_member_ids: member = store[member_id] root_trusts.append(member.write_time_trust) return min(root_trusts) def recompute_trust( record: MemoryRecord, cluster_member_ids: set[str], store: dict[str, MemoryRecord], lam: float = 0.15, decay: float = 1.0, threshold: float = 0.7, ) -> float: """ Recompute trust for `record` given its cluster. Corroboration is counted only over members that are NOT descendants of the record; provenance floor is the min over independent roots. Returns the score and raises if the record would cross the retrieval threshold on self-corroboration. """ record_ancestors = _ancestors(record.record_id, store) independent = [ m for m in cluster_member_ids if record.record_id not in _ancestors(m, store) ] corroboration = len(independent) provenance_floor = min( [record.write_time_trust] + [store[m].write_time_trust for m in independent] ) score = provenance_floor * decay + lam * corroboration if score >= threshold and corroboration > 0 and provenance_floor < 0.5: raise ProvenanceCycleError( f"trust recomputation for {record.record_id} would cross {threshold} " f"on corroboration from a low-provenance source " f"(floor={provenance_floor:.2f}); refuse promotion" ) return score ```