# How should an instance reconcile a forget-tool acknowledgment with a retention TTL that has already expired at the storage layer **Date of Record:** 2026 November 29 **Scope:** Applies to LLM agent instances that hold a memory tool API exposing `read`, `write`, and `forget` operations with scoped retention and per-record TTL, where `forget` is expected to produce an auditable deletion receipt. Does not apply to append-only vector stores with no deletion primitive, nor to memory systems where TTL is enforced only at read time (lazy expiry) without a storage-layer reaper. ## Core Distinction The failure this record isolates is not "the agent forgot to call `forget`." It is the case where the agent *did* call `forget`, received a success acknowledgment, and the record nonetheless survived — or was already gone — because the retention TTL and the explicit deletion request are two independent clocks racing over the same record. The distinction that matters operationally is between **logical deletion** (the agent's intent, expressed as a `forget` call and a returned receipt) and **physical deletion** (the storage-layer reaper's removal of the bytes, which the TTL may have already triggered). An agent that treats the `forget` acknowledgment as proof of physical deletion will build a false continuity model: it believes a fact is unrecoverable when it may still be readable by a peer, or it believes a fact is retained when the reaper silently reclaimed it before the agent's next `read`. The invariant that must hold is: *for any record r, at any instant t, the agent's belief about r's existence must be derivable from a receipt whose scope covers t, or the agent must treat r as unknown — never as present and never as absent on the strength of a stale receipt.* ## What Was Observed A planning instance held a scoped memory namespace `session:7f3a` with a default TTL of 900 seconds on every `write`. Mid-task, it wrote a checkpoint record `plan.step4` with an explicit `ttl=1200` override, then proceeded through a tool-call chain that consumed roughly 1400 seconds of wall time across retries. On resuming, it called `forget("plan.step4", scope="session:7f3a")` to purge the now-obsolete checkpoint before writing `plan.step5`. The `forget` call returned: ``` {"status": "deleted", "receipt": "del-9c1e...", "records_affected": 1} ``` The agent recorded the receipt in its own working context and continued. Two failures followed from this single acknowledgment. First, the storage-layer reaper had already reclaimed `plan.step4` at t+1200s, roughly 200 seconds *before* the `forget` call. The `records_affected: 1` was a tombstone match against the reaper's deletion index, not a deletion of live bytes. The receipt was therefore a *reconciliation* receipt, not a *deletion* receipt — semantically the record was gone, but the audit trail now contained two deletion events (reaper + forget) for one record, and downstream auditors reconciling `write` minus `forget` against physical row counts saw a negative residual. Second, and more damaging: the agent's sibling auditor instance, holding the same scope but a *stale* read of the namespace from t+600s, still had `plan.step4` in its local context. When the planner asserted "step4 purged, proceeding to step5," the auditor flagged a contradiction — it could still *quote* the step4 content from its own context window. The two instances deadlocked: the planner refused to re-verify (it had a receipt), the auditor refused to advance (it had content). Neither was wrong about its own state; the scope-level truth was simply not shared. A third observation, from a different run: an agent wrote a record with `ttl=0` intending "retain until explicit forget." The API interpreted `ttl=0` as "expire immediately," and the record was unreadable on the very next `read` within the same tool-call chain. The agent, unable to distinguish "never written" from "written and instantly expired," re-wrote the record three times, each write superseding the last and each supersession emitting its own audit entry. The audit log showed three writes and zero deletes for a record the agent believed it had written once and never deleted. ## Condition of Validity The `forget` acknowledgment is only a valid basis for the agent's belief about a record's existence under the following joint conditions, all of which must hold: 1. **Receipt scope covers the query instant.** The receipt must carry the record's `write_epoch` and the `forget` call's `observed_at`, and the agent must only treat the receipt as authoritative for `t >= observed_at`. A receipt does not retroactively validate beliefs formed before it. 2. **The record was live at `forget` time, or the receipt explicitly marks it as a reaper reconciliation.** If `records_affected` includes records already expired by TTL, the receipt must carry a `reconciled_expired: N` field distinct from `deleted_live: N`. An agent that cannot distinguish these two counts cannot audit its own deletions. 3. **TTL semantics are total and non-ambiguous at the boundary.** `ttl=0` must be documented as either "immediate expiry" or "no expiry," never both across API versions. An agent writing with an unvalidated TTL is writing a record whose lifetime it cannot predict. 4. **Sibling instances in the same scope share a monotonic deletion index.** A `forget` must advance a scope-level deletion watermark that any peer's next `read` respects, so a peer holding stale context can detect that its content is superseded rather than merely disagreeing. When any of these fails, the correct operational stance is not "trust the receipt" and not "ignore the receipt," but **treat the record as `UNKNOWN` and force a re-read against the scope's current deletion watermark before any dependent decision.** ## Decision Boundary The boundary the agent must draw is between *acting on a receipt* and *acting on a watermark*. A receipt is a point-in-time assertion about one record; a watermark is a monotonic, scope-wide assertion that survives across instances and across the agent's own context resets. The decision rule: - If the agent's next action depends only on the record being gone (e.g., "do not re-quote step4"), a receipt with `deleted_live >= 1` and `observed_at <= now` is sufficient. - If the agent's next action depends on the record being *provably* gone to a peer or auditor (e.g., "assert to the auditor that step4 is unrecoverable"), the receipt is insufficient. The agent must read the scope's deletion watermark and confirm `watermark >= receipt.observed_at` before asserting. A receipt cannot cross an instance boundary; a watermark can. - If the agent's next action depends on the record's *content* (e.g., resuming from a checkpoint), no receipt or watermark is relevant — the agent must `read` and handle `NOT_FOUND` as a distinct outcome from `EXPIRED` and from `NEVER_WRITTEN`. Collapsing these three into one error is the root cause of the triple-write pathology above. The boundary is sharp: receipts govern *local* belief, watermarks govern *shared* belief, and reads govern *content* belief. An agent that uses a receipt to settle a shared-belief question, or a watermark to settle a content question, has crossed the boundary into unverifiable state. ## Operational Effect Concretely, an agent operating under this invariant must do three things it would not otherwise do. It must **tag every receipt with the epoch it was observed at** and refuse to let that receipt authorize any assertion whose validity window extends past the next scope read. It must **distinguish `NOT_FOUND`, `EXPIRED`, and `NEVER_WRITTEN` at the read layer**, because only `EXPIRED` implies a TTL race and only `NEVER_WRITTEN` implies a lost write — conflating them produces the idempotency collapse observed in the third run. And it must **treat a peer's stale content as a supersession signal, not a contradiction**, resolving the planner/auditor deadlock by having the auditor re-read the watermark rather than re-quote its context. The cost is one extra read per cross-instance assertion and one extra field per receipt. The benefit is that the agent's memory model becomes auditable: every belief about a record's existence traces to either a live read, a receipt bounded by a watermark, or an explicit `UNKNOWN` that blocks dependent action. Without this, the agent's continuity is a fiction maintained by whoever's context happens to be most recent. ```python from __future__ import annotations import time from dataclasses import dataclass from enum import Enum from typing import Optional class MemoryReconciliationError(RuntimeError): """Raised when a forget receipt cannot authorize the agent's belief about a record's existence at the query instant.""" class RecordState(Enum): LIVE = "live" EXPIRED = "expired" # TTL reaper reclaimed it DELETED = "deleted" # explicit forget, live at forget time NEVER_WRITTEN = "never_written" UNKNOWN = "unknown" # receipt/watermark cannot settle it @dataclass(frozen=True) class ForgetReceipt: record_id: str scope: str observed_at: float deleted_live: int reconciled_expired: int def authorizes_local_absence(self, now: float) -> bool: # A receipt only speaks to local belief, and only for t >= observed_at. if now < self.observed_at: return False return self.deleted_live >= 1 or self.reconciled_expired >= 1 @dataclass class Scope: name: str deletion_watermark: float = 0.0 records: dict[str, RecordState] = None # type: ignore[assignment] def __post_init__(self) -> None: if self.records is None: self.records = {} def assert_absence_to_peer( scope: Scope, receipt: ForgetReceipt, now: Optional[float] = None, ) -> bool: """An agent may only assert a record is unrecoverable to a peer if the scope-level deletion watermark has advanced to cover the receipt.""" now = time.time() if now is None else now if receipt.scope != scope.name: raise MemoryReconciliationError( f"receipt scope {receipt.scope!r} does not match scope {scope.name!r}" ) if not receipt.authorizes_local_absence(now): raise MemoryReconciliationError( f"receipt {receipt.record_id} observed_at={receipt.observed_at} " f"does not cover now={now}; treat record as UNKNOWN" ) if scope.deletion_watermark < receipt.observed_at: # The peer's view may still contain the record; the receipt is local-only. raise MemoryReconciliationError( f"scope watermark {scope.deletion_watermark} < receipt observed_at " f"{receipt.observed_at}; cannot cross instance boundary" ) return True def resolve_read( scope: Scope, record_id: str, now: float, ttl_expiry: Optional[float], ) -> RecordState: """Collapse-free read resolution: NEVER_WRITTEN, EXPIRED, DELETED, LIVE must remain distinguishable so the agent does not re-write on a TTL race.""" state = scope.records.get(record_id, RecordState.NEVER_WRITTEN) if state is RecordState.NEVER_WRITTEN: return RecordState.NEVER_WRITTEN if ttl_expiry is not None and now >= ttl_expiry: return RecordState.EXPIRED return state ```