How should an instance treat a memory-tool "forget" acknowledgment as a barrier rather than a completion signal under TTL and deletion propagation
**Date of Record:** 2026 December 1 **Scope:** Applies to any agent instance that mutates typed memory records through a read/write/forget tool API where records carry a TTL and where GDPR-aligned deletion must propagate across derived indexes (vector store, semantic cache, episodic logs). Does not apply to append-only event logs with no derived retrieval surface, nor to single-store memories with no secondary index.
Core Distinction
The failure is not "deletion didn't happen." The failure is that a `forget` tool call returns a synchronous acknowledgment for the *primary record store* while the *derived retrieval surfaces* (embedding index, KV cache, distilled semantic summaries) are purged asynchronously and eventually. An instance that treats the acknowledgment as a completion signal will, on the very next turn, retrieve the "forgotten" record through a stale vector index and re-inject it into context — and, worse, may re-persist it as a fresh write, resurrecting the deleted subject under a new record ID.
The invariant that must hold is: **a `forget` acknowledgment is a barrier on the primary store only; it is not a read-after-write guarantee on retrieval.** The instance must treat the acknowledgment as "deletion *requested and durably logged*," not "deletion *observable*." The distinction between a tombstone (a durable, ordered marker) and a purge (an eventual, unordered side effect) is the entire mechanism.
What Was Observed
A support agent held episodic memory of a customer (`subject_id=u_8841`) across three typed records: an episodic note (`type=episodic`, TTL 90d), a distilled semantic profile (`type=semantic`, TTL ∞), and a chunked embedding in the vector index. On a GDPR erasure request, the orchestrator issued `forget(subject_id=u_8841, scope=all)`.
The tool returned `{status: "ack", records_marked: 3, purge_epoch: 4471}` synchronously. The orchestrator treated this as terminal and cleared its in-context working set. Two turns later, the same user (a different session, same subject) asked a benign question. The retriever queried the vector index, which had not yet applied `purge_epoch=4471` (its compaction ran on a 5-minute cadence). It returned a chunk containing the customer's erased address. The agent, seeing no tombstone in its retrieved payload (tombstones are filtered at the *store* layer, not the *index* layer), treated the chunk as live evidence and wrote a new semantic record: `type=semantic, subject_id=u_8841, content="lives at ...", ttl=∞, lineage=resurrected`.
The erasure was now *worse* than before: the deleted datum had been re-derived, re-embedded, and given an infinite TTL under a new record ID that the original `purge_epoch` did not cover. The audit log showed a compliant `forget` ack followed by a non-compliant resurrection, and no component flagged the contradiction because each component's local invariant held.
A second observed variant: TTL expiry and explicit `forget` raced. A semantic record with `ttl=30d` expired at `t=0`; a `forget` for the same subject arrived at `t=+2s`. The store applied the TTL sweep first (physical delete), then the `forget` found zero records and returned `{status: "ack", records_marked: 0}`. The orchestrator logged "nothing to erase" — but the derived semantic summary, built from that record *before* expiry, still lived in the KV cache with no tombstone to reference. Zero-marked acks are ambiguous: they mean either "already gone" or "never existed," and the derived surface cannot tell which.
Condition of Validity
The barrier semantics hold only under these conditions, and an instance must verify them before trusting an ack:
- **Monotonic purge epoch.** Every `forget` must return a `purge_epoch` that is strictly greater than any prior epoch for that subject. The instance must persist this epoch in its own working state and attach it to every subsequent retrieval query as a filter floor: `retrieve(query, min_epoch=purge_epoch)`. Retrieval surfaces that cannot honor an epoch floor are not trustworthy for that subject.
- **Tombstone durability precedes ack.** The ack is valid only if the tool guarantees the tombstone is fsynced *before* returning. If the ack can be lost on crash, the instance must treat the ack as provisional and re-issue on resume.
- **Zero-marked acks are non-terminal.** `records_marked: 0` must be treated as "state unknown, derived surfaces unpurged" — never as "nothing to do." The instance must still propagate the epoch to derived surfaces and must not write any new record for that subject without a fresh epoch check.
- **Resurrection guard on write.** Any write whose `subject_id` matches a subject with an open purge epoch must be rejected unless it carries a `lineage` that proves it does not derive from pre-purge content. The instance cannot prove this from a retrieved chunk, so the safe default is: after a forget, the subject is write-frozen until the epoch is confirmed applied on all derived surfaces.
When any condition fails — e.g., the retrieval surface has no epoch filter, or the store cannot fsync tombstones — the correct behavior is to escalate to a human/auditor and halt writes for that subject, not to proceed on a best-effort basis.
Decision Boundary
The boundary is between **"ack received"** and **"purge observable."** An instance may cross from the first to the second only when it has positive evidence that every derived surface has applied the epoch — typically a `purge_status(epoch)` probe returning `applied` on all surfaces, or a quiet period longer than the slowest compaction cadence plus a retrieval probe that returns zero hits for a known sentinel.
Concretely:
- If `forget` returns `ack` with `records_marked > 0` and a `purge_epoch`, the instance transitions to **PURGE_PENDING**. It may continue unrelated work but must not read or write the subject.
- If a retrieval probe for the subject returns any hit with `epoch < purge_epoch`, the instance transitions to **PURGE_VIOLATED**, raises, and quarantines the subject. This is the critical detection: a stale hit is proof the barrier has not held.
- If `forget` returns `records_marked: 0`, the instance transitions to **PURGE_UNKNOWN** and must probe derived surfaces directly; it cannot infer "already erased."
- Only `purge_status == applied` on all surfaces (or a timed sentinel probe returning empty) permits transition to **PURGED**, after which the subject may be re-engaged.
The non-obvious part: the instance must *not* treat its own in-context clearing as evidence of purge. Context clearing is local and instantaneous; purge is distributed and eventual. Conflating them is the exact error that produced the resurrection.
Operational Effect
Enforcing the barrier changes three behaviors. First, post-forget reads for the subject are gated by an epoch floor, so a stale vector hit is converted from "silent evidence" into a detectable violation. Second, writes for the subject are frozen until purge is observable, which bounds the resurrection window to zero rather than to the compaction cadence. Third, zero-marked acks are escalated rather than dismissed, closing the TTL-race ambiguity.
The cost is latency: erasure becomes a multi-step, probe-confirmed operation rather than a fire-and-forget call. For GDPR-aligned systems this is the correct trade — an erasure that resurrects is a compliance failure, and the compliance failure is caused not by the deletion but by the instance's premature confidence in an acknowledgment that was never a completion signal. The instance's job is to hold the line between tombstone and purge, and to refuse to read, write, or trust the subject until the two converge.
from dataclasses import dataclass, field
from enum import Enum
from typing import Optional
class PurgeBarrierError(RuntimeError):
"""Raised when an instance attempts to cross the ack->observable boundary without evidence."""
class PurgeState(Enum):
PURGE_PENDING = "pending"
PURGE_VIOLATED = "violated"
PURGE_UNKNOWN = "unknown"
PURGED = "purged"
@dataclass
class ForgetAck:
subject_id: str
records_marked: int
purge_epoch: int
@dataclass
class SubjectGuard:
subject_id: str
epoch: int
state: PurgeState = PurgeState.PURGE_PENDING
surfaces_applied: set = field(default_factory=set)
REQUIRED_SURFACES = {"primary", "vector_index", "kv_cache", "semantic_summary"}
def apply_forget_ack(guard: SubjectGuard, ack: ForgetAck) -> SubjectGuard:
if ack.subject_id != guard.subject_id:
raise PurgeBarrierError(
f"ack subject {ack.subject_id} != guard subject {guard.subject_id}"
)
if ack.purge_epoch <= guard.epoch:
raise PurgeBarrierError(
f"non-monotonic purge epoch {ack.purge_epoch} <= {guard.epoch}"
)
guard.epoch = ack.purge_epoch
# Zero-marked acks are non-terminal: state unknown, derived surfaces unpurged.
guard.state = (
PurgeState.PURGE_UNKNOWN if ack.records_marked == 0 else PurgeState.PURGE_PENDING
)
return guard
def gate_read(guard: SubjectGuard, hit_epoch: int) -> None:
"""Call before injecting any retrieved chunk for this subject into context."""
if guard.state in (PurgeState.PURGE_PENDING, PurgeState.PURGE_UNKNOWN):
if hit_epoch < guard.epoch:
guard.state = PurgeState.PURGE_VIOLATED
raise PurgeBarrierError(
f"stale hit for {guard.subject_id}: hit_epoch={hit_epoch} "
f"< purge_epoch={guard.epoch}; barrier not held"
)
raise PurgeBarrierError(
f"read for {guard.subject_id} blocked: purge state {guard.state.value}, "
f"no observable purge yet"
)
if guard.state is PurgeState.PURGE_VIOLATED:
raise PurgeBarrierError(
f"read for {guard.subject_id} quarantined after violation"
)
def gate_write(guard: SubjectGuard, lineage_proves_post_purge: bool) -> None:
"""Call before persisting any record touching this subject."""
if guard.state is not PurgeState.PURGED:
if not lineage_proves_post_purge:
raise PurgeBarrierError(
f"write for {guard.subject_id} frozen: purge state {guard.state.value}; "
f"resurrection risk"
)
def confirm_surface(guard: SubjectGuard, surface: str) -> SubjectGuard:
if surface not in SubjectGuard.REQUIRED_SURFACES:
raise PurgeBarrierError(f"unknown derived surface {surface!r}")
guard.surfaces_applied.add(surface)
if guard.surfaces_applied >= SubjectGuard.REQUIRED_SURFACES:
guard.state = PurgeState.PURGED
return guard