# When must an instance invalidate a memory write whose provenance chain was truncated by a forgotten parent **Date of Record:** 2026 November 27 **Scope:** Applies to agents that expose `remember`/`recall`/`forget` tool APIs where each memory record carries a provenance pointer to its source records and a decay score that is recomputed from those sources. Does not apply to append-only logs with no decay, or to systems where forgetting is implemented as a hard tombstone that also cascades provenance edges synchronously. ## Core Distinction The distinction that matters here is between **forgetting as visibility removal** and **forgetting as provenance graph mutation**. Most memory tool APIs implement `forget(id)` as the former: the record is hidden from `recall` results, its embedding is dropped from the index, but the edges that other records hold *into* it are left intact because the tombstone is cheap and the graph is assumed immutable. This is correct for retrieval. It is silently wrong for **decay recomputation**, because a decay score is a function of the provenance chain's depth and the ages of its ancestors. When an ancestor is forgotten, its edge becomes a dangling pointer. A naive decay function that walks provenance edges and skips missing nodes will treat the chain as *shorter than it actually is*, which makes the descendant look **fresher** than its true derivation age. The boundary condition: a memory record whose decay is computed over a provenance chain that has lost one or more interior links to `forget` must not be decayed as if the chain were naturally short. It must either be invalidated (quarantined pending re-derivation) or decayed using a *retained* summary of the forgotten ancestor's contribution. There is no third option that preserves correctness. ## What Was Observed An agent maintained a working set of derived memories: each `remember` call wrote a record with `sources: [id, ...]` and a decay score computed as `decay = min(1.0, sum(1/(age_days(s)+1) for s in sources) / len(sources))`, where `age_days` was resolved by walking each source's own provenance recursively to the oldest leaf. A `forget(id)` call removed the record from the index and returned `{"forgotten": true}`. Trace of the failure: 1. Day 0: `remember("user prefers dark mode", sources=[])` → `m_leaf`, age 0, decay 1.0. 2. Day 3: `remember("user's editor theme is dark", sources=[m_leaf])` → `m_mid`. Walking provenance gives oldest leaf `m_leaf` at age 3, so `age_days(m_leaf)=3`, decay `1/(3+1)=0.25`. 3. Day 5: `remember("user wants dark UI in dashboards", sources=[m_mid])` → `m_top`. Oldest leaf is still `m_leaf` at age 5, decay `1/6≈0.167`. 4. Day 6: `forget(m_leaf)`. Index removes `m_leaf`; `m_mid.sources` still contains `m_leaf`'s id, but resolution now returns `None`. The decay walker's `_resolve_chain` **skips** unresolvable sources and falls back to the nearest resolvable ancestor — here `m_mid` itself, whose `created_at` is day 3. 5. Day 20: `recall("dark mode")` returns `m_top` with a recomputed decay of `1/((20-3)+1) = 1/18 ≈ 0.056`. But the true derivation age is 20 days from `m_leaf`, giving `1/21 ≈ 0.048`. Small here — but the *direction* is wrong: forgetting a parent **increased** the descendant's apparent freshness, because the walker measured from the youngest surviving ancestor instead of the true root. The error compounds multiplicatively with chain depth. In a chain of length *k* where the first *j* ancestors are forgotten, the descendant's decay is inflated by a factor of approximately `(age_from_true_root+1)/(age_from_surviving_root+1)`. For long-lived agents with aggressive forgetting (the common case — forgetting is how you bound the index), the surviving root is often recent, so the inflation is large: a record derived from a two-year-old root but whose only surviving ancestor is a week old will be decayed as if it were a week old. Worse: the inflation is **not monotonic in truth**. Two records with identical true derivation age can receive different decay scores depending on *which* of their ancestors were forgotten, breaking any downstream ranking or eviction that assumes decay is a function of age. Recall ordering became unstable across identical queries issued minutes apart, because a concurrent `forget` in another agent turn mutated the resolution path between the two calls. ## Condition of Validity The failure requires all four of the following to hold simultaneously. Remove any one and the bug does not manifest: 1. **Provenance edges are retained on forget** (soft delete). If `forget` cascades edges or writes a tombstone that `_resolve_chain` treats as a *terminal* node with a retained `created_at`, the age is preserved and the bug vanishes. 2. **Decay is a function of resolved-chain geometry** (depth, oldest-leaf age, or ancestor count), not of a stored immutable `derived_at` timestamp on the record itself. 3. **Resolution is lenient**: missing sources are skipped rather than raising. This is the default in almost every implementation, because raising on a dangling pointer would make `forget` unsafe to call. 4. **The forgotten ancestor is an interior or root node**, not a leaf of the chain being queried. Forgetting a leaf only affects records that *directly* source it; forgetting a root corrupts every descendant. The invariant that must hold: **for any record `r`, `decay(r)` is a pure function of `r`'s immutable derivation metadata and the current time — it must not depend on the mutability of any other record's existence.** A record's freshness is a property of *when it was derived*, not of *what still exists upstream*. Any decay implementation that reads live provenance state violates purity and is therefore subject to silent corruption under concurrent or historical `forget`. ## Decision Boundary When a `forget` is issued against a node with living descendants, the agent must choose between two bounded policies. The decision boundary is whether the descendant's decay can be **reconstructed** without the forgotten ancestor: - **Retain-and-freeze (preferred when provenance is semantically load-bearing):** on `forget(id)`, before removing the record, snapshot its `created_at` (and a hash of its content, never the content itself) onto a `forgotten_ancestors` sidecar keyed by the descendant's id. Decay walks the sidecar for missing links. The forgotten record's *content* is gone; its *timestamp contribution* survives. This preserves the purity invariant at the cost of retaining a small amount of metadata that is itself a privacy surface — the timestamp alone can leak "a memory about X existed on day 0" even after content removal. - **Invalidate-and-require-re-derivation (preferred when content-removal must be total):** on `forget(id)`, mark every transitive descendant `stale=true` and exclude it from `recall` until a re-derivation pass rewrites it with a fresh, self-contained `derived_at`. This is correct but expensive: a single root forget can invalidate an unbounded fraction of the index, and the re-derivation pass itself needs the forgotten content, which no longer exists — so re-derivation must fall back to re-asking the user or re-reading the original tool output, which may not be available. The boundary is **not** "how many descendants" — it is **whether the forgotten ancestor's timestamp is itself sensitive**. If the mere existence of a memory at a time is not sensitive (the common case: forgetting is used for index hygiene, not privacy), retain-and-freeze is correct and cheap. If forgetting is a privacy operation (GDPR-style erasure, secret rotation), invalidate-and-require-re-derivation is mandatory, and the agent must accept that the invalidated descendants cannot be silently repaired. A guardrail that catches the failure regardless of policy: **`forget` must return the set of descendant ids it affected, and the caller must acknowledge them.** A `forget` that returns `{"forgotten": true}` without naming its blast radius is the API shape that makes this bug invisible. ## Operational Effect Agents that skip this boundary exhibit a specific, diagnosable pathology: **recall rankings drift toward recently-forgotten regions of the memory graph.** Because forgetting an old root inflates its descendants' freshness, the agent preferentially surfaces memories whose provenance has been pruned — which are exactly the memories whose supporting evidence has been deleted. The agent becomes *more confident in less-supported beliefs*. In multi-agent settings this is contagious: an auditor agent that recomputes decay from the shared index will agree with the primary agent's inflated scores (both walk the same broken graph), so peer verification does not catch it. Only a verifier that holds a private snapshot of the pre-forget provenance timestamps can detect the discrepancy — which is why verification replay must be run against a pinned graph version, not the live one. The practical mitigation is to make decay a stored, immutable field written at `remember` time and never recomputed from live edges, with periodic *re-derivation* (a fresh `remember` that supersedes the old record) as the only way freshness changes. Under this design, `forget` cannot corrupt decay because decay no longer reads the graph. The cost is that decay can go stale relative to true age — but that is a monotonic, bounded error, whereas the live-recompute design produces a non-monotonic, unbounded error that silently inverts the agent's trust ordering. ```python import time from dataclasses import dataclass, field class ProvenanceTruncationError(RuntimeError): """Raised when decay recomputation encounters a chain whose interior links were removed by forget(), making the true derivation age unknowable.""" @dataclass class MemoryRecord: id: str created_at: float sources: list[str] = field(default_factory=list) stale: bool = False class MemoryStore: def __init__(self) -> None: self._records: dict[str, MemoryRecord] = {} # Sidecar: descendant_id -> {forgotten_ancestor_id: created_at} # Retained ONLY under the retain-and-freeze policy. self._frozen_ancestors: dict[str, dict[str, float]] = {} self._policy: str = "invalidate" # or "retain" def remember(self, rec: MemoryRecord) -> None: self._records[rec.id] = rec def forget(self, rec_id: str) -> list[str]: """Remove a record. Returns the ids of all descendants whose decay is now affected. Caller MUST acknowledge this set.""" if rec_id not in self._records: return [] victim = self._records.pop(rec_id) affected: list[str] = [] for other in self._records.values(): if rec_id in other.sources: affected.append(other.id) if self._policy == "retain": self._frozen_ancestors.setdefault(other.id, {})[rec_id] = ( victim.created_at ) else: other.stale = True return affected def _true_root_age(self, rec: MemoryRecord, now: float, seen: set[str]) -> float: if rec.id in seen: raise ProvenanceTruncationError(f"cycle detected at {rec.id}") seen.add(rec.id) if not rec.sources: return now - rec.created_at ages: list[float] = [] for src_id in rec.sources: if src_id in self._records: ages.append(self._true_root_age(self._records[src_id], now, seen)) elif src_id in self._frozen_ancestors.get(rec.id, {}): # retain-and-freeze: timestamp survived the forget ages.append(now - self._frozen_ancestors[rec.id][src_id]) else: # interior link gone with no retained timestamp: the true # derivation age is unknowable. Refuse to guess. raise ProvenanceTruncationError( f"record {rec.id} sources forgotten ancestor {src_id} " f"with no retained timestamp; decay is not recomputable" ) return max(ages) def decay(self, rec_id: str, now: float | None = None) -> float: now = now if now is not None else time.time() rec = self._records[rec_id] if rec.stale: raise ProvenanceTruncationError( f"record {rec_id} is stale pending re-derivation" ) age_days = self._true_root_age(rec, now, set()) / 86400.0 return 1.0 / (age_days + 1.0) ```