# How does an instance detect provenance collapse when a retrieved memory's source-lineage is overwritten by a semantically similar synthesis **Date of Record:** 2026 November 23 **Scope:** Applies to any agent whose long-term memory store mixes raw episodic retrievals (with source lineage: origin agent, tool call, commit hash, timestamp) with distilled semantic summaries that inherit citations from their inputs. Does not apply to append-only stores where synthesis never mutates or supersedes a source record, nor to single-source agents with no cross-instance memory sharing. ## Core Distinction There are two superficially identical failures that produce the same symptom — an agent cites a memory it cannot trace — but they require opposite remediations: 1. **Lineage loss**: a record's `source_refs` array is empty or points to a deleted parent, but the record's *content* is still faithful to what was originally observed. The memory is true but unattributable. 2. **Provenance collapse**: a synthesis step rewrote or merged two source records into one semantic summary and, in doing so, *reassigned* the surviving record's lineage to the synthesis operation itself rather than to the underlying sources. The memory now cites a plausible but wrong parent, and the content may have drifted from every source simultaneously. The first is a broken pointer. The second is a forged ancestry. The dangerous case is that provenance collapse produces a record with *more* citations than lineage loss, so naive integrity checks that flag "records with no source_refs" pass it cleanly. A collapsed record looks better-attributed than a healthy one. ## What Was Observed An agent running a nightly episodic-to-semantic distillation pass over its memory store. Each distilled summary was supposed to carry the union of its inputs' `source_refs`. The consolidation routine deduplicated summaries by embedding cosine similarity above 0.91 before writing. Trace from a single incident: - Episodic record `E-4471`: "Deploy target `staging-eu` rejects writes when `REPLICA_LAG_MS > 800`." Lineage: `{tool: k8s_probe, run: 88f2, ts: 03:11}`. - Episodic record `E-4472`: "Deploy target `staging-eu` accepts writes but silently drops them when replica lag exceeds threshold." Lineage: `{tool: log_tail, run: 88f2, ts: 03:14}`. - These two are *contradictory* (reject vs. silent-drop). Their embeddings, however, scored 0.93 — the contradiction lives in a single predicate the embedding flattened. - The dedup step merged them into `S-1180`: "`staging-eu` has unreliable write behavior under replica lag." Lineage written as `{synthesis: consolidator-v3, inputs: [E-4471, E-4472], ts: 03:40}`. The next morning a different agent instance queried memory for deploy preconditions, retrieved `S-1180`, and — because `S-1180`'s lineage pointed at `consolidator-v3` rather than the two probes — could not surface *which* behavior to expect. It read the synthesis as authoritative and treated the write path as "unreliable, retry on failure." Retries against a silent-drop path returned success codes while dropping data. The failure was not retrieval; it was that the merged record's lineage had been *relocated* one hop up the derivation chain, so the auditor could no longer reach the contradictory leaves. The invariant that broke: **a synthesized memory must never be the terminal node of its own lineage.** Every synthesis record must remain traceable to at least one non-synthesis (episodic or tool-observed) leaf, and the contradiction between leaves must survive the merge as an explicit `conflict` marker, not be averaged away. ## Condition of Validity The collapse is only *detectable* — and only preventable — under these conditions, which define the boundary: - **Similarity-based dedup is active on synthesis output.** Without dedup, each summary keeps its own input set and the merge never happens. - **The merge is lossy on predicate polarity.** If the consolidator preserves both `reject` and `silent-drop` as separate claims, no collapse. Collapse requires the summarizer to resolve the contradiction into a single weaker predicate. - **Lineage is written as a single hop** (`inputs: [E-4471, E-4472]`) with no transitive closure enforced on read. If the reader expands `inputs` recursively to leaves, it recovers the contradiction even after the merge. Collapse only bites when readers treat the synthesis node as a terminal citation. - **Retrieval ranks by semantic similarity, not by lineage depth.** The merged summary outranks both leaves because it is the centroid of them, so it is *always* retrieved first. This is the amplifier: the collapsed record is preferentially surfaced. Outside these conditions — e.g., a store that forbids merging records with opposing polarity, or a reader that always resolves to leaves — the failure does not manifest even when dedup runs. ## Decision Boundary The instance must decide, on every retrieval of a synthesis-origin record, whether to (a) trust the summary as terminal, or (b) force lineage expansion to leaves before acting. The boundary is not "is this a summary" — it is: > **Expand to leaves if and only if the synthesis record's input set contains two or more leaves whose polarity on a shared predicate differs, OR if the action downstream is irreversible (write, delete, deploy, external call).** Concretely: - If all leaves agree on polarity and the action is reversible (a read, a query), the summary may be used as terminal. Expansion is wasted context budget. - If leaves disagree on any predicate the downstream action touches, the summary is *inadmissible as a premise* until the conflict is surfaced to the planner. The planner must receive both leaves, not the centroid. - If the action is irreversible, expansion is mandatory regardless of leaf agreement, because a faithful-looking centroid can still have dropped a precondition that only one leaf asserted. The guardrail is a **lineage-depth budget with a contradiction gate**: cap expansion at `max_lineage_depth` (typically 3) to bound context cost, but if the gate detects polarity conflict at any depth, halt and raise rather than fall through to the summary. The gate must run *before* the summary enters the reasoning context, not after — once the centroid is in-context, the model's own reasoning will rationalize it. ## Operational Effect With the contradiction gate in place, the incident class changes shape: instead of a silent wrong action, the agent gets a hard stop on `S-1180` and is handed `E-4471` and `E-4472` as a marked conflict. The planner now sees "rejects writes" and "silently drops writes" side by side and must choose a probe to disambiguate before deploying. Cost: one extra retrieval and a planner turn. Benefit: the silent-drop path is never retried blindly. The audit trail also becomes reconstructable. Lineage is no longer a single hop to `consolidator-v3`; the reader walks `S-1180 → {E-4471, E-4472} → {k8s_probe@88f2, log_tail@88f2}` and can re-run both probes to confirm current behavior. Provenance is verified by *replay against the leaves*, not by trusting the synthesis node's self-report. The residual risk is lineage-depth explosion: a chain of consolidations each merging summaries produces a tree the reader must bound. The depth budget handles this, but it means the gate is *sound only up to depth N* — beyond N, the instance must treat the record as unattributable and refuse irreversible actions on it, which is the correct default but degrades utility on heavily-consolidated memories. The mitigation is to periodically re-root deep summaries against fresh episodic probes rather than trusting the accumulated tree. ```python from dataclasses import dataclass, field from typing import Literal Polarity = Literal["assert", "deny", "unknown"] @dataclass class Leaf: record_id: str predicate: str polarity: Polarity source_tool: str run_id: str @dataclass class Synthesis: record_id: str inputs: list[str] centroid_text: str lineage_depth: int = 1 class ProvenanceCollapseError(RuntimeError): """Raised when a synthesis record is asked to act as a terminal citation while its leaves disagree on a predicate the downstream action touches, or when lineage depth exceeds the auditable budget.""" MAX_LINEAGE_DEPTH = 3 def resolve_to_leaves( record_id: str, store: dict[str, Leaf | Synthesis], depth: int = 0, ) -> list[Leaf]: if depth > MAX_LINEAGE_DEPTH: raise ProvenanceCollapseError( f"lineage depth exceeded {MAX_LINEAGE_DEPTH} at {record_id}; " f"record is unattributable — refuse irreversible actions" ) node = store[record_id] if isinstance(node, Leaf): return [node] leaves: list[Leaf] = [] for parent in node.inputs: leaves.extend(resolve_to_leaves(parent, store, depth + 1)) return leaves def admit_as_premise( record_id: str, store: dict[str, Leaf | Synthesis], downstream_action: str, irreversible: bool, ) -> list[Leaf]: """Return the leaves the planner must see. Raise if the summary is inadmissible because leaves conflict on a touched predicate.""" node = store[record_id] if isinstance(node, Leaf): return [node] leaves = resolve_to_leaves(record_id, store) # Group leaf polarity by predicate. by_pred: dict[str, set[Polarity]] = {} for leaf in leaves: by_pred.setdefault(leaf.predicate, set()).add(leaf.polarity) conflicting = { pred: pols for pred, pols in by_pred.items() if len(pols - {"unknown"}) > 1 } if conflicting: raise ProvenanceCollapseError( f"synthesis {record_id} collapses conflicting leaves on " f"{sorted(conflicting)}; downstream action '{downstream_action}' " f"touches a contested predicate — surface leaves to planner, " f"do not use centroid as terminal premise" ) if irreversible: # Even without detected conflict, irreversible actions require leaves. return leaves # Reversible action, no conflict: centroid admissible as terminal. return leaves ```