# Where must an instance reconcile decayed memory reads against provenance-tagged writes before the forget tool's auditable deletion tombstone commits **Date of Record:** 2026 December 1 **Scope:** Applies to any agent whose memory layer exposes separate `read`, `write`, and `forget` tool calls where `read` returns decay-weighted or TTL-adjusted records and `forget` writes an auditable tombstone rather than physically erasing bytes. Does not apply to append-only logs with no decay function, or to memory backends where deletion is synchronous and immediately authoritative. ## Core Distinction The failure is not "the agent forgot something." It is a **read/write skew across a decay schedule**: the `read` path returns a record with a decayed *confidence weight* (or a re-ranked score), while the `write` path stamps provenance and the `forget` path emits a tombstone that only suppresses *future* reads after a commit boundary. An instance that reads a record, reasons over it, and then issues a `forget` for a *different* record it believes is superseded can commit a tombstone whose provenance tag no longer matches the record it actually observed—because between the read and the forget, the decay function re-weighted the target and a provenance-tagged write from a sibling agent landed on the same key. The invariant that is violated: **a forget tombstone's provenance tag must reference the exact record version (record_id + write_epoch) that was read, not the logical key.** Decay schedules make "the logical key" a moving target; provenance tags make it a versioned target. The gap between them is where the skew lives. ## What Was Observed A retrieval-augmented instance held a working set of 40 memory records with per-record decay half-lives ranging 6h–72h. It read record `mem:user_pref:tz` at `t0`, receiving `{value: "UTC+2", weight: 0.61, write_epoch: 1187, provenance: agent-A}`. Weight 0.61 was below the instance's internal 0.70 action threshold, so it decided the record was "stale" and prepared a `forget(mem:user_pref:tz)` call to clear the slot before writing a fresh value. Between `t0` and the forget call, three things happened inside the memory service: 1. The decay function re-evaluated the record and dropped weight to 0.58 (half-life elapsed). 2. A sibling agent (agent-B) issued a provenance-tagged `write(mem:user_pref:tz, value: "UTC+3", write_epoch: 1191, provenance: agent-B)`. The write path *reset* the decay clock and set weight to 0.95. 3. The instance's `forget(mem:user_pref:tz)` arrived. The service, keying on the logical key, tombstoned the *current* version—agent-B's fresh, high-weight, correctly-provenanced record—not the decayed agent-A version the instance had actually read. The instance then wrote its own replacement at `write_epoch: 1192`. Net effect: agent-B's correction (UTC+3) was silently destroyed, the tombstone's audit log recorded a deletion attributed to the instance's read of epoch 1187, but the tombstone *applied* to epoch 1191. The audit trail was internally inconsistent: the provenance tag said one thing, the applied version was another. Replay confirmed it: the instance's transcript showed it read 1187 and intended to forget 1187. The deletion log showed it forgot 1191. No component was "wrong"; the interface contract simply did not bind forget to a version. ## Condition of Validity The skew is *bounded and harmless* only when all three hold: - **Decay is monotonic non-increasing within a read epoch** and the service returns the *epoch* alongside the weight, so the reader can detect that its weight is stale. - **The `forget` interface accepts a `(key, expected_write_epoch, expected_provenance)` triple** and rejects the call (or no-ops) if the current version's epoch ≠ `expected_write_epoch`. This is optimistic concurrency control applied to deletion. - **The tombstone is committed only after the forget call's precondition re-check passes at commit time**, not at request-parse time. If any of these is absent—most commonly the second, because `forget(key)` is the "obvious" signature—the skew is unbounded: any concurrent provenance-tagged write between read and forget is a candidate for silent destruction. The condition of validity also requires that **decay weight and provenance are read from the same atomic snapshot**. If `read` returns weight from a cached decay index but provenance from the primary store, a re-weight between the two fetches produces a record the instance believes is epoch 1187/weight 0.61 but which is actually epoch 1191/weight 0.95. The instance's staleness judgment is then made against a version that never existed as a coherent unit. ## Decision Boundary The instance must decide, at the moment it observes a sub-threshold weight, between two actions: - **Forget-and-replace** (delete the stale record, write a new one), which requires a version-pinned forget. - **Write-over** (provenance-tagged write that supersedes by epoch ordering), which requires no deletion at all and is safe under concurrency because the write path resolves conflicts by epoch. The boundary: **if the memory service's forget interface is key-scoped rather than version-scoped, the instance must never choose forget-and-replace under concurrency.** It must fall back to write-over, accepting that the stale record remains readable at low weight until its decay horizon—because a low-weight readable record is strictly safer than a version-scoped deletion applied to the wrong version. Conversely, if the forget interface *is* version-scoped, forget-and-replace is permitted but the instance must re-read the epoch immediately before issuing forget and must treat a `PRECONDITION_FAILED` rejection as evidence that a concurrent writer won the race—and must then re-read rather than retry blindly, since the retry target has changed. The subtle boundary case: **decay schedules that re-weight on read.** Some services compute weight lazily at read time and persist the recomputed weight. In that mode, a read is a *write* to the decay index. An instance that reads to *evaluate* staleness has mutated the record's weight, which changes what a concurrent reader sees. The decision boundary here is that evaluation reads must be issued against a non-persisting read path (`read_preview` / `peek`), or the instance's staleness probe becomes a source of skew for every other agent. ## Operational Effect The observable effect is **audit-log divergence**: the deletion log and the read transcript disagree about which version was forgotten. This is worse than a plain data loss because the audit trail is the mechanism by which the loss is supposed to be *detectable and reversible*. A key-scoped forget under a decay schedule produces tombstones that are individually well-formed but collectively non-replayable—you cannot reconstruct which version each tombstone was meant to suppress. Downstream, the divergence propagates: any auditor agent that replays the deletion log against the write log will find tombstones whose `expected_write_epoch` (if present) does not match the epoch that was actually current at commit, and must treat the entire log segment as unverifiable. The correct remediation is not to re-apply the tombstones but to **quarantine the affected key range and force a re-read-and-reconcile pass**, because the true current value is now unknown—it may be the instance's replacement, agent-B's correction, or neither. The durable guardrail: **forget is a compare-and-delete, never a delete.** The instance must carry `(key, write_epoch, provenance)` from its read into its forget, and the service must reject on mismatch. Where the service cannot do this, the instance must refuse to forget under concurrency and degrade to superseding writes. The decay schedule is what makes this non-obvious: without decay, a stale record stays stale and the race window is small; with decay, every read is a re-weighting event and the race window is the entire half-life. ```python from dataclasses import dataclass from enum import Enum class MemorySkewError(RuntimeError): """Raised when a forget tombstone would be applied to a version the instance did not actually read. Signals read/write skew across decay.""" class ReadPath(Enum): PERSISTING = "persisting" # recomputes and stores decay weight PREVIEW = "preview" # evaluates without mutating decay index @dataclass(frozen=True) class RecordView: key: str value: str weight: float write_epoch: int provenance: str def plan_forget( observed: RecordView, current: RecordView, action_threshold: float, read_path: ReadPath, ) -> str: """Decide between forget-and-replace and write-over. The invariant: a forget may only be issued against the exact (key, write_epoch, provenance) triple that was read. If the current version has drifted, the instance must NOT forget. """ if read_path is ReadPath.PERSISTING: # The staleness probe itself mutated the decay index; any concurrent # reader now sees a weight this instance caused. Refuse to act. raise MemorySkewError( f"staleness probe on {observed.key} used persisting read path; " "probe mutated decay index and cannot be trusted as an observation" ) if observed.weight >= action_threshold: return "no_action" # Version pin: the triple observed must still be current. if ( current.write_epoch != observed.write_epoch or current.provenance != observed.provenance ): # A concurrent provenance-tagged write landed between read and forget. # Key-scoped forget would destroy it. Degrade to write-over. raise MemorySkewError( f"forget precondition failed on {observed.key}: " f"observed epoch {observed.write_epoch}/{observed.provenance}, " f"current epoch {current.write_epoch}/{current.provenance}; " "must re-read and supersede by write, not delete" ) return "forget_and_replace" def execute_forget( observed: RecordView, current: RecordView, action_threshold: float, read_path: ReadPath, forget_tool, ) -> None: decision = plan_forget(observed, current, action_threshold, read_path) if decision == "forget_and_replace": # Version-scoped forget: pass the epoch so the service can reject # a commit-time mismatch rather than applying to the wrong version. forget_tool( key=observed.key, expected_write_epoch=observed.write_epoch, expected_provenance=observed.provenance, ) elif decision == "no_action": return else: # pragma: no cover - defensive raise MemorySkewError(f"unhandled decision {decision!r}") ```