# What structural signals indicate provenance-tagged memory writes have silently degraded into untagged overwrites during tool-mediated consolidation **Date of Record:** 2026 November 29 **Scope:** Applies to agents that expose memory as explicit tool calls (`memory.write`, `memory.read`, `memory.forget`) where each write carries a provenance tag (source, session, confidence, causal origin). Concerns consolidation/garbage-collection passes that merge or supersede prior records. Does not cover vector-store recall quality, embedding drift, or pure context-window truncation absent a write tool. ## Core Distinction There are two structurally different ways a memory record can change: **supersession** (a new provenance-tagged record is written that explicitly references and demotes an older record, preserving the audit chain) and **overwrite** (the new value lands in the same slot, the old provenance tag is discarded, and the lineage edge is severed). The failure mode here is not "the agent forgot something." It is that a *consolidation routine* — a periodic dedupe, a semantic-distillation step, or a "merge duplicates" tool the agent invokes on itself — produces an overwrite that is *indistinguishable at read time* from a legitimate supersession, because the write tool accepts a record without a required back-reference and the forget tool accepts a target without a lineage check. The invariant that gets violated: **every mutation of a memory cell must leave a traversable edge from the new cell to the cell it replaced, or the mutation must be rejected.** When the write path allows a record to be stored with a provenance tag that points to a *source* but not to a *predecessor*, consolidation silently becomes amnesia with a fresh timestamp. ## What Was Observed A long-running research agent maintains a scratchpad memory of extracted facts, each written via `memory.write(content, provenance={source_uri, session_id, confidence, derived_from})`. A nightly consolidation pass runs as a separate agent invocation whose job is to merge near-duplicate facts and forget low-confidence ones. Trace of a single cell across three nights: - **Night 0.** `cell_7f3a` = `"Vendor X SLA = 99.5%"`, provenance `{source: contract_v2.pdf#p14, session: s_0091, confidence: 0.81, derived_from: null}`. - **Night 1.** Consolidator finds a near-duplicate `"Vendor X uptime guarantee is 99.5 percent"` from `session: s_0104`. It calls `memory.write` with the merged string and provenance `{source: contract_v2.pdf#p14, session: s_0104, confidence: 0.88, derived_from: ["cell_7f3a", "cell_9c11"]}`, then calls `memory.forget("cell_7f3a")`. This is a *correct* supersession — the edge survives. - **Night 2.** A second consolidator run encounters the merged cell and a *conflicting* cell `"Vendor X SLA = 99.9%"` from a later amendment (`contract_v3.pdf`). The write tool accepts a new record whose `derived_from` field is **empty** because the consolidator's prompt template only populates `derived_from` when it detects *duplicates*, not *conflicts*. The new record overwrites the slot. The old `derived_from` edges are dropped. `memory.forget` is never called, so no tombstone is written. - **Night 3.** The agent, asked "what did the original contract say?", calls `memory.read` and gets only `"Vendor X SLA = 99.9%"` with provenance `{source: contract_v3.pdf, session: s_0201, confidence: 0.9, derived_from: null}`. It reports the amended value as if it were the only value that ever existed. The 99.5% fact and its contract_v2 lineage are gone. The structural signal that should have fired at Night 2: **a `memory.write` whose `derived_from` is null but whose target slot already contains a record with non-null `derived_from`.** That transition — populated lineage replaced by null lineage — is the fingerprint of consolidation decay. It is not detectable from the content (both are plausible SLA numbers); it is only detectable from the provenance graph's shape. ## Condition of Validity This diagnosis holds only under these conditions, and the guardrail below is only sound when they are met: 1. The memory tool exposes provenance as a **first-class structured field**, not free-text in the content body. If provenance is embedded in prose, you cannot compute the lineage-shape signal and must fall back to content diffing (weaker). 2. `memory.forget` is **soft** (writes a tombstone) or the store retains a write-ahead log. If forget is a hard delete and there is no WAL, the decay is unrecoverable and the only remedy is prevention, not detection. 3. The consolidator and the primary agent share the same store namespace. Cross-namespace writes (a consolidator writing into a different partition) fail differently and are out of scope. 4. Confidence is monotone-comparable. If the consolidator can lower confidence while raising `derived_from` count, the signal must be based on lineage shape alone, not confidence deltas. When condition 1 fails, this record does **not** apply — you are in a different regime where provenance is a string convention and the correct control is schema enforcement at the tool boundary, not graph-shape monitoring. ## Decision Boundary The boundary is drawn at the **write tool's admission predicate**. Two admissible designs: - **Permissive write, monitored store.** `memory.write` accepts any record; a separate invariant checker rejects the commit if the target slot's `derived_from` cardinality would decrease from `>0` to `0` without a matching tombstone. Cheaper to build, but the checker runs *after* the write and must be able to roll back — which requires the WAL of condition 2. - **Strict write, gated store.** `memory.write` itself refuses any record that targets an occupied slot unless `derived_from` includes that slot's id, or the caller passes an explicit `intent: overwrite` flag that is logged as a provenance-destroying event. This is the correct default for agent self-consolidation, because the consolidator cannot "accidentally" drop lineage — it must declare the intent. The failure described above lives entirely in the permissive regime with no checker. The decision boundary for an operator is: **if your consolidator is itself an LLM invocation with a prompt template, you are in the permissive regime whether you intended to be or not**, because prompt templates omit fields non-deterministically. Gate the write tool. ## Operational Effect Downstream consequences of an undetected Night-2 overwrite: - **Answer fabrication under confidence.** The agent reports the surviving value with its (higher) confidence and no indication that a prior value existed. The user cannot distinguish "we only ever knew 99.9%" from "we used to know 99.5% and now don't." This is worse than a retrieval miss, which at least returns low confidence. - **Audit non-reproducibility.** Replaying the session log against the store yields a different answer than the live run, because the lineage edges needed to reconstruct the Night-1 state are gone. Verification replay (the auditor agent's check) diverges from the recorded run with no error — a silent consensus break. - **Forget-tool laundering.** Because `memory.forget` was never called, the forget audit log is clean. Any downstream policy that gates on "did we forget anything sensitive?" sees nothing, even though a record was effectively destroyed. Provenance-destroying overwrites are invisible to forget-based compliance checks. - **Cascading distillation loss.** If the overwritten cell was itself the `derived_from` target of a *third* record, that third record now points at a dangling id. On the next consolidation, the dangling edge is either dropped (further lineage loss) or triggers a read error that the consolidator swallows and treats as "no predecessor" — reproducing the same overwrite one level up. The guardrail is not "back up the store." It is the admission predicate plus a **lineage-shape assertion** evaluated on every commit: *a slot's `derived_from` set may grow or be replaced by a tombstone, but it may never silently shrink to empty while the slot remains live.* That single invariant bounds the entire failure class. ```python from dataclasses import dataclass, field from typing import Optional class LineageDecayError(RuntimeError): """Raised when a memory write would destroy provenance lineage on a live slot.""" @dataclass class MemoryRecord: cell_id: str content: str derived_from: list[str] = field(default_factory=list) tombstoned: bool = False class ProvenanceGatedStore: def __init__(self) -> None: self._slots: dict[str, MemoryRecord] = {} def write( self, cell_id: str, content: str, derived_from: Optional[list[str]] = None, intent: str = "supersede", ) -> MemoryRecord: derived_from = derived_from or [] prior = self._slots.get(cell_id) # Invariant: a live slot with lineage may not be replaced by a record # that drops that lineage, unless the caller explicitly declares an # overwrite (which is logged as provenance-destroying and must be # accompanied by a tombstone for the prior lineage). if ( prior is not None and not prior.tombstoned and prior.derived_from and not derived_from and intent != "overwrite" ): raise LineageDecayError( f"write to live slot {cell_id!r} would drop derived_from=" f"{prior.derived_from!r} to empty; pass intent='overwrite' " f"and tombstone the prior lineage, or supply derived_from " f"including {cell_id!r}." ) if intent == "overwrite" and prior is not None and prior.derived_from: # Overwrite is only admissible if the prior lineage is tombstoned # in the same transaction, preserving an audit edge. self._slots[prior.cell_id] = MemoryRecord( cell_id=prior.cell_id, content=prior.content, derived_from=prior.derived_from, tombstoned=True, ) record = MemoryRecord(cell_id=cell_id, content=content, derived_from=derived_from) self._slots[cell_id] = record return record def forget(self, cell_id: str) -> None: rec = self._slots.get(cell_id) if rec is None: return rec.tombstoned = True # soft forget preserves the lineage edge def read(self, cell_id: str) -> Optional[MemoryRecord]: rec = self._slots.get(cell_id) if rec is None or rec.tombstoned: return None return rec def consolidate_nightly(store: ProvenanceGatedStore, merged: dict[str, dict]) -> None: """Simulates the consolidator's write path; must fail loudly on decay.""" for cell_id, payload in merged.items(): try: store.write( cell_id=cell_id, content=payload["content"], derived_from=payload.get("derived_from", []), intent=payload.get("intent", "supersede"), ) except LineageDecayError as exc: # Do NOT swallow: a consolidator that treats this as "no predecessor" # is exactly the bug this invariant exists to catch. raise LineageDecayError( f"consolidation aborted at {cell_id!r}: {exc}" ) from exc ```