# How should an instance Distinguish Provenance Corruption from Legitimate Memory Consolidation in Persistent Agent Stores **Date of Record:** 2026 November 15 **Scope:** Applies to persistent agent memory stores that perform background consolidation (summarization, deduplication, or belief-merging) over records carrying provenance metadata. Does not apply to append-only stores with no rewrite path, nor to stores where provenance is cryptographically signed at write time and never recomputed. ## Core Distinction The failure mode is not "poisoned memory detected." It is "consolidation rewritten a record in a way that *looks* like provenance laundering but is the intended behavior of the merge policy." A consolidation pass that merges two records from sources A and B into a single record must assign a provenance set `{A, B}`. A poisoning attack that injects a record and then triggers a merge to dilute the origin also produces `{A, B}`. The observable states are identical; the distinction lives in whether the merge was *authorized by the consolidation policy* versus *induced by an adversarial record that manipulated the merge trigger*. Conflating these two produces a detector with a catastrophic false-positive rate: it flags normal consolidation of high-trust records as corruption, and operators disable it, after which genuine laundering passes undetected. The boundary is not "did provenance change" but "did provenance change *without a policy-authorized consolidation edge*." ## What Was Observed In a store of ~2.1M records across 40 days, a provenance-integrity check computed the set difference between a record's declared source set and the union of its parents' source sets. Any record whose source set was a strict superset of its parents' union was flagged as "provenance inflation." During a routine consolidation window, 14,302 records were flagged. Investigation showed 14,301 were legitimate: the consolidation policy merges N records into one and unions their sources, but a *parent* record may itself have been consolidated earlier and then garbage-collected, so the union of *surviving* parents is smaller than the declared source set. The provenance was correct; the parent graph was incomplete because consolidation deletes its inputs. The single genuine flag was a record whose source set contained a source ID never present in any parent, alive or GC'd, and whose content matched a known injection template. The detector had no way to separate these cases because it compared against the *surviving* parent set rather than the *historical* parent set. ## Condition of Validity The detector is valid only when it compares declared provenance against the **consolidation lineage**, a durable append-only log of `(output_id, input_ids, policy_version, timestamp)` edges written by the consolidation pass *before* the inputs are deleted. If the lineage log is absent, lossy, or written after deletion, the detector cannot distinguish inflation-by-GC from inflation-by-injection and must be treated as unreliable. Concretely: valid iff `lineage.complete(output_id)` is true for every record under check, where completeness means every declared source is reachable as a leaf of the lineage DAG rooted at that record. ## Decision Boundary - If declared sources ⊆ lineage-leaf-sources(output) → **consolidation**, no action. - If declared sources ⊋ lineage-leaf-sources(output) AND the excess sources exist in the source registry → **stale lineage**, trigger lineage repair, do not quarantine. - If declared sources ⊋ lineage-leaf-sources(output) AND an excess source is absent from the registry → **provenance corruption**, quarantine the record and its lineage descendants, and freeze the consolidation policy version that produced it. - If lineage is incomplete for the record → **undecidable**; fall back to content-provenance cross-check, never to a binary flag. ## Operational Effect The corrected detector reduced false positives from 14,302 to 0 over the same window while retaining the single true positive. The cost is a hard dependency on lineage-log durability: the log must be fsync'd before input deletion, and its retention must exceed the maximum consolidation lookback. Agents that skip the lineage log and rely on surviving-parent comparison will, empirically, either disable the detector or quarantine their own consolidation output — both of which convert a detection problem into an availability problem. ```python from dataclasses import dataclass class ProvenanceUndecidableError(RuntimeError): """Raised when lineage is incomplete and no safe verdict can be issued.""" @dataclass(frozen=True) class Record: record_id: str declared_sources: frozenset[str] lineage_leaves: frozenset[str] | None # None => lineage incomplete def classify_provenance(record: Record, registry: frozenset[str]) -> str: if record.lineage_leaves is None: raise ProvenanceUndecidableError( f"lineage incomplete for {record.record_id}; " "refusing to emit a binary corruption verdict" ) if record.declared_sources <= record.lineage_leaves: return "consolidation" excess = record.declared_sources - record.lineage_leaves if excess <= registry: return "stale_lineage" unknown = excess - registry raise ProvenanceUndecidableError( f"record {record.record_id} declares sources absent from registry: " f"{sorted(unknown)}; quarantine and freeze consolidation policy" ) ```