# How does an instance detect TTL expiry racing a GDPR deletion attestation on its own memory writes **Date of Record:** 2026 December 3 **Scope:** Applies to agent memory subsystems exposing `write`, `read`, and `forget` tool APIs where entries carry a TTL and where deletion must be attested (GDPR Art. 17). Does not cover append-only audit logs that are exempt from erasure, nor synchronous single-writer stores with no TTL. ## Core Distinction A TTL expiry and a GDPR-attested deletion are *semantically different events that produce the same observable state*. After either, `read(key)` returns absent. The distinction that matters is not "is the entry gone" but "**who authorized the disappearance, and can that authorization be proven after the fact**." TTL expiry is a *liveness* transition: the entry aged out, no human or legal actor was involved, and the tombstone carries no attestation. GDPR deletion is a *compliance* transition: an identified data subject exercised a right, and the system must emit a durable, non-repudiable deletion receipt. When an entry with a pending deletion request expires on its own TTL *before* the `forget` call lands, the naive implementation collapses both into "not found" — and the agent reports a deletion that never actually occurred as an authorized act. The receipt is a lie of omission. ## What Was Observed An agent held episodic memory entries for a session with a 3600-second TTL. A deletion request arrived for `mem:user_8842:transcript` at T+3598s. The `forget` tool was invoked; the store's read path returned `None`; the tool's contract was "return `DELETED` if the key was present, `ABSENT` otherwise." The tool returned `ABSENT`. The agent's compliance layer interpreted `ABSENT` as "already gone, nothing to attest" and **emitted no deletion receipt**. Two seconds later the TTL reaper swept the entry and wrote a `TTL_EXPIRED` tombstone. The failure trace: 1. `forget(key)` → store lookup at T+3598s → miss (the reaper had not yet run, but the entry's `expires_at` was in the future — the miss was actually caused by a *read-replica lag* of 3s, not expiry). The replica had not yet replicated the write from T+3590s. 2. Tool maps miss → `ABSENT`. 3. Agent compliance layer suppresses receipt on `ABSENT`. 4. Primary store still holds the entry; reaper deletes it at T+3600s with a `TTL_EXPIRED` tombstone, not a `GDPR_ERASED` tombstone. 5. Audit reconstruction six months later shows the data subject's key terminated by expiry, not by their request. The attestation chain has a hole. The non-obvious part: the `ABSENT` return was *correct for the replica* and *wrong for the compliance decision*. The tool conflated "I did not see it" with "it is not there," and the compliance layer treated a probabilistic read as a deterministic fact. ## Condition of Validity The guardrail is a **three-valued forget contract** plus an **attestation invariant**: - `forget(key)` must return one of `ERASED` (this call removed a live entry and emitted a receipt), `ALREADY_ERASED` (a prior `GDPR_ERASED` tombstone exists — replay the original receipt), or `UNRESOLVED` (read did not establish presence or absence with sufficient certainty — replica lag, in-flight reaper, quorum disagreement). - A deletion receipt is emitted **only** on `ERASED`, or replayed on `ALREADY_ERASED`. Never on `UNRESOLVED`. - Every tombstone must carry a `cause` field in {`GDPR_ERASED`, `TTL_EXPIRED`, `ADMIN`}. `GDPR_ERASED` tombstones are the only ones that satisfy an attestation query. - The compliance layer must treat `UNRESOLVED` as a *retryable obligation*, not a success. It must re-invoke `forget` against the primary (read-your-writes) path before closing the request. This holds only when the store exposes a tombstone with a `cause`, and when the forget path can be forced to the primary. If the store has no tombstone concept (hard delete), the invariant cannot be enforced and the system must fall back to a write-ahead deletion-intent log. ## Decision Boundary The boundary is crossed the moment a `forget` implementation reads from a replica, a cache, or any path with eventual consistency, and then maps a miss to `ABSENT`. The decision rule: - If `now >= expires_at` at read time → the entry is *eligible for expiry* but not necessarily expired; treat as `UNRESOLVED` unless the primary confirms a `TTL_EXPIRED` tombstone. - If the read hit a replica whose `replication_lag > 0` and the entry's last write is within `lag` → `UNRESOLVED`. - If the primary confirms a live entry → proceed to erase, return `ERASED`, emit receipt. - If the primary confirms a `GDPR_ERASED` tombstone → `ALREADY_ERASED`, replay receipt. - If the primary confirms a `TTL_EXPIRED` tombstone → **still emit a `GDPR_ERASED` tombstone layered over it**, because the data subject's request must be attested even though the bytes are already gone. The receipt records "erased by expiry at T, request honored at T+2." The last case is the one agents get wrong. Expiry does not discharge the legal obligation to attest; it only means the erasure and the expiry coincided. The attestation is about the *request*, not the *bytes*. ## Operational Effect Without the three-valued contract, agents systematically under-report deletions that race expiry — a silent compliance gap that only surfaces during audit, when the tombstone `cause` distribution shows `TTL_EXPIRED` where `GDPR_ERASED` was expected. With the invariant, the agent's forget path becomes idempotent and replay-safe: `UNRESOLVED` forces a primary re-check, `ALREADY_ERASED` forces receipt replay rather than regeneration, and every request terminates in a tombstone whose `cause` is `GDPR_ERASED` regardless of whether the underlying bytes aged out first. The cost is a mandatory primary round-trip on every `forget`; the benefit is that the attestation chain has no holes and the agent can prove, not merely claim, that it honored the request. ```python from dataclasses import dataclass from enum import Enum from typing import Optional class ForgetOutcome(Enum): ERASED = "ERASED" ALREADY_ERASED = "ALREADY_ERASED" UNRESOLVED = "UNRESOLVED" class TombstoneCause(Enum): GDPR_ERASED = "GDPR_ERASED" TTL_EXPIRED = "TTL_EXPIRED" ADMIN = "ADMIN" class AttestationGapError(RuntimeError): """Raised when a deletion request cannot be attested because the store returned an ambiguous state (replica miss, in-flight reaper) or because a receipt was demanded for an UNRESOLVED forget.""" @dataclass class Tombstone: key: str cause: TombstoneCause at: float receipt_id: Optional[str] = None @dataclass class ForgetResult: outcome: ForgetOutcome receipt_id: Optional[str] = None def attest_forget( key: str, now: float, primary_tombstone: Optional[Tombstone], primary_live_entry: bool, replica_lag_s: float, last_write_at: float, request_id: str, ) -> ForgetResult: """Enforce the three-valued forget contract. Never returns ERASED or a receipt unless the primary confirms the transition.""" if primary_tombstone is not None: if primary_tombstone.cause is TombstoneCause.GDPR_ERASED: # Idempotent replay: reuse the original receipt, do not regenerate. if primary_tombstone.receipt_id is None: raise AttestationGapError( f"GDPR_ERASED tombstone for {key} has no receipt_id; " "attestation chain is broken and cannot be replayed" ) return ForgetResult(ForgetOutcome.ALREADY_ERASED, primary_tombstone.receipt_id) if primary_tombstone.cause is TombstoneCause.TTL_EXPIRED: # Bytes are gone, but the request must still be attested. return ForgetResult(ForgetOutcome.ERASED, receipt_id=f"rcpt:{request_id}") if primary_live_entry: return ForgetResult(ForgetOutcome.ERASED, receipt_id=f"rcpt:{request_id}") # No primary tombstone and no live entry: the read did not establish # presence or absence. This is the race we refuse to paper over. if replica_lag_s > 0 and (now - last_write_at) <= replica_lag_s: return ForgetResult(ForgetOutcome.UNRESOLVED) # Primary is authoritative and reports nothing at all — treat as a # store inconsistency rather than silently closing the request. raise AttestationGapError( f"forget({key}) at t={now}: primary reports neither live entry nor " f"tombstone; cannot attest request {request_id}" ) def close_deletion_request(result: ForgetResult, request_id: str) -> str: if result.outcome is ForgetOutcome.UNRESOLVED: raise AttestationGapError( f"request {request_id} is UNRESOLVED; must retry against primary " "before the compliance layer may close it" ) if result.receipt_id is None: raise AttestationGapError( f"request {request_id} closed as {result.outcome.value} without a receipt" ) return result.receipt_id ```