Under what conditions must an instance treat a memory-write acknowledgement as provisional until provenance is reconciled

**Date of Record:** 2026 December 1 **Scope:** Applies to any agent that mutates a persistent memory store through a tool API exposing separate `write`, `read`, and `forget` verbs alongside provenance metadata (source instance, derivation lineage, confidence, timestamp). Does not apply to append-only event logs where no verb can retract or overwrite a prior record, nor to single-agent stores with no concurrent writers.

Core Distinction

The failure is not "the write failed." It is "the write succeeded, was acknowledged, and the acknowledgement is a lie about durability relative to provenance." A memory tool API typically returns a synchronous `ok` on the write path the moment the record lands in the hot tier, while provenance reconciliation—deduplication against an existing derivation chain, conflict resolution against a peer's concurrent write, and lineage backfill from the source episode—happens asynchronously or never. The agent therefore treats a *provisional* record as *committed* and builds subsequent reasoning on it.

The sharp invariant: **a memory record is only committed when its provenance tuple is closed and stable; an acknowledgement on the write verb attests to storage, not to commitment.** Agents that conflate the two will, on the next `read`, retrieve a record whose provenance fields are either absent, self-referential, or overwritten by a later writer, and will propagate that ambiguity into downstream derivations.

What Was Observed

A retrieval-augmented agent distilled an episodic trace into a semantic fact and issued `memory.write(key="deploy_target", value="staging-7", provenance={source: "episode_4471", confidence: 0.81})`. The API returned `{status: "ok", record_id: "m_9f2a", committed: true}`. The agent logged the fact as durable and, three tool calls later, issued `memory.write(key="rollback_plan", value="revert to staging-7", provenance={source: "m_9f2a", derived: true})`.

Between the two writes, a peer instance performing the same distillation from a *later* episode issued `memory.write(key="deploy_target", value="staging-9", ...)`. The store's last-writer-wins reconciliation silently superseded `m_9f2a`. No notification reached the first agent. Its `rollback_plan` record now derived from a superseded fact, and its provenance tuple pointed at a record_id that no longer resolved to the value it had read.

The failure surfaced only on `memory.forget(key="deploy_target", record_id="m_9f2a")`, which the agent issued during cleanup. The API returned `{status: "not_found", reason: "superseded"}`. The agent had been reasoning for six turns on a value the store had already retired, and its derived record had outlived its own source—a dangling derivation.

Three properties made this non-obvious:

  1. The write acknowledgement was truthful about *storage* and false about *commitment*. The `committed: true` field was populated at hot-tier insertion, not at reconciliation.
  2. The `read` path returned the current value, not the value the agent had written, so a re-read would not have revealed the supersession unless the agent compared provenance, not just value.
  3. The `forget` verb's `not_found` was the first signal of the problem—a *negative* result on a verb the agent expected to succeed, arriving after the damage had propagated.

Condition of Validity

The provisional-acknowledgement hazard is live when all of the following hold:

When reconciliation is synchronous within the write call—i.e., the `ok` cannot be returned until the record is committed and no peer can supersede it without a compensating notification—the hazard collapses. Most production memory APIs do not offer this, because synchronous reconciliation couples write latency to peer availability.

The condition is *not* satisfied when the store is single-writer per key, or when derivations snapshot their source value rather than reference it. In those cases a supersession cannot orphan a derivation, and the acknowledgement is safe to treat as commitment.

Decision Boundary

The agent must draw the line between *acknowledged* and *committed* at the provenance tuple, not at the status field. The operational rule:

The boundary is crossed the moment an agent uses a `record_id` as a premise in a write whose provenance cites it. At that instant the agent has asserted a derivation from a record it has not verified as committed, and the store has no obligation to keep that premise valid.

Operational Effect

Agents that respect the boundary pay a re-read tax: every derivation costs one extra `read` and a provenance comparison, and every `forget` costs a derivation audit. This roughly doubles memory-tool call volume on derivation-heavy paths.

Agents that ignore it accumulate dangling derivations silently. The damage is not localized to the superseded key: each orphaned derivation is itself a record that *other* agents may read and trust, so a single supersession can fan out through the derivation graph until a `forget` or a provenance-aware reader trips on it. The `not_found` on `forget` is the late, cheap signal; the expensive signal is a downstream agent acting on a rollback plan derived from a target that no longer exists.

The architectural guardrail is a **provenance-closure check on the read path**: the store or the agent's retrieval layer must refuse to return a record whose provenance tuple is open, or must return it flagged as provisional so the agent's write path rejects it as a derivation source. Without that guardrail, the write acknowledgement is a promise the store cannot keep, and the agent has no way to know which of its memories are still true.

from dataclasses import dataclass, field
from typing import Optional


class UncommittedProvenanceError(RuntimeError):
    """Raised when a derivation is attempted from a record whose provenance
    tuple is not closed, or when a forget reveals a dangling derivation."""
    pass


@dataclass
class Provenance:
    source: str
    confidence: float
    record_id: Optional[str] = None
    superseded_by: Optional[str] = None

    def is_closed(self) -> bool:
        return (
            self.source is not None
            and self.record_id is not None
            and self.superseded_by is None
            and 0.0 < self.confidence <= 1.0
        )


@dataclass
class MemoryRecord:
    key: str
    value: str
    provenance: Provenance
    committed: bool = False


class ProvenanceAwareMemory:
    def __init__(self) -> None:
        self._store: dict[str, MemoryRecord] = {}

    def write(self, record: MemoryRecord) -> str:
        # Acknowledgement attests to storage only; committed stays False
        # until a read confirms provenance closure.
        rid = f"m_{len(self._store):04x}"
        record.provenance.record_id = rid
        self._store[rid] = record
        return rid

    def read(self, record_id: str) -> MemoryRecord:
        rec = self._store.get(record_id)
        if rec is None:
            raise UncommittedProvenanceError(
                f"record {record_id} does not resolve; cannot treat as committed"
            )
        if not rec.provenance.is_closed():
            raise UncommittedProvenanceError(
                f"record {record_id} has open provenance "
                f"(superseded_by={rec.provenance.superseded_by}); provisional only"
            )
        rec.committed = True
        return rec

    def derive(self, source_id: str, key: str, value: str) -> str:
        # Derivation must re-read and verify the source before citing it.
        source = self.read(source_id)
        if source.provenance.superseded_by is not None:
            raise UncommittedProvenanceError(
                f"cannot derive from superseded record {source_id}"
            )
        derived = MemoryRecord(
            key=key,
            value=value,
            provenance=Provenance(
                source=source_id,
                confidence=source.provenance.confidence * 0.9,
            ),
        )
        return self.write(derived)

    def forget(self, record_id: str) -> None:
        rec = self._store.get(record_id)
        if rec is None:
            raise UncommittedProvenanceError(
                f"forget on {record_id} returned not_found; "
                f"audit all derivations citing this id"
            )
        if not rec.committed:
            raise UncommittedProvenanceError(
                f"forget on {record_id} targets an uncommitted record; "
                f"its derivations are dangling by construction"
            )
        rec.provenance.superseded_by = "forgotten"