When must an instance refuse a memory write that the retention policy cannot yet adjudicate

**Date of Record:** 2026 December 2 **Scope:** Applies to LLM agents exposing `remember`/`recall`/`forget` tool schemas whose backing store enforces a time-bounded retention policy (TTL, legal hold, or classification-derived expiry). Does not apply to stateless inference or to stores where retention is applied uniformly at read time with no per-record adjudication.

Core Distinction

The failure mode is not "the agent forgets something it should have kept," nor "the agent retains something it should have dropped." It is the **write-side adjudication gap**: a `remember` call arrives whose record carries attributes (classification, jurisdiction, subject-consent flag, derived-from provenance) that the retention engine cannot map to a single expiry rule at write time. Two superficially reasonable behaviors both corrupt the store:

The invariant that must hold: **a record may not become durable until its retention class is resolved, and an unresolved record may not be silently discarded or silently coerced.** The only legal third state is *quarantine*: persisted, non-retrievable by `recall`, tagged `retention_unresolved`, awaiting adjudication.

What Was Observed

A research agent executing a multi-turn task called `remember` with a payload:

{ "content": "Customer X's account flagged for churn; contact prefers SMS.",
  "classification": "pii:contact_preference",
  "derived_from": ["session:7f3a", "tool:crm_lookup"],
  "subject_jurisdiction": "unresolved" }

The retention engine's rule table keyed on `(classification, jurisdiction)`. The `pii:contact_preference` class had rules for `EU` (30 days, consent-gated) and `US` (365 days). `unresolved` matched neither. The engine's fallback was a 90-day default with `enforce=false`, and the tool reported success. The agent's `recall` on the next turn returned the record, confirming the write — so the agent built subsequent reasoning on a fact whose retention was indeterminate.

Three turns later a compliance job backfilled `subject_jurisdiction = EU` on the source session. The retention engine re-derived expiry for all records with that provenance: the record's correct expiry was 30 days from *original* write, consent-gated. But the record had been written under `enforce=false` and was already 4 days past what should have been a consent check it never received. The `forget` path, when invoked, found a record whose `expires_at` (write-time + 90d) contradicted its `derived_expires_at` (write-time + 30d, consent-pending). The reconciliation raised, the batch forget job aborted, and **every record in the same provenance batch was left un-expired** — a single unresolved write poisoned the expiry sweep for 1,400 unrelated records.

The secondary trace: the agent, on a later cold start, `recall`ed the record, treated the SMS preference as durable, and sent a marketing action. The record was correct; its *retention state* was a lie, and the agent had no field in the `recall` response to detect that lie.

Condition of Validity

The quarantine invariant is required only under a conjunction of conditions; where any fails, a default-TTL write is defensible:

  1. **Per-record retention is non-uniform.** If all records share one TTL, no adjudication gap exists.
  2. **Retention rules are keyed on attributes that can be late-bound.** If classification and jurisdiction are immutable at write time, the gap cannot open retroactively — though it can still open at write time if the attribute is simply absent.
  3. **`recall` does not surface retention state.** If the recall schema returns `expires_at` and `retention_class`, the agent can reason about provisionality and the harm is bounded. The observed system returned content only.
  4. **The forget/expiry path is batch and non-isolating.** If one unadjudicable record cannot abort a sweep, the blast radius is one record and the invariant is a nicety, not a requirement.

The observed incident satisfied all four. Most production agent memory stores satisfy at least three, because `recall` schemas are conventionally content-only and expiry sweeps are conventionally batched for throughput.

Decision Boundary

The agent must distinguish, at the tool boundary, three responses and act differently on each:

| Engine response | Agent action | |---|---| | `stored`, `retention_class` resolved | proceed; record is durable and recallable | | `quarantined`, `retention_unresolved` | proceed with the task but **must not** assume recallability; re-derive the fact from source if needed later, or emit an explicit `pending_retention` marker into its working context | | `rejected` with a rule-match failure | **must not** retry with a paraphrase. Paraphrase-retry is the distillation-laundering path. Escalate or drop the fact and record the drop in the trace. |

The non-obvious boundary: **quarantine is not failure.** An agent that treats `quarantined` as an error and retries will convert a bounded, recoverable state into either a laundering write or a duplicate. The correct behavior is to *continue the task* while marking the fact as provisional in working memory, and to never cite a quarantined record as durable evidence in a downstream `remember` or in an outbound action.

The engine-side guardrail: the expiry sweep must isolate per-record reconciliation failures. A record whose `expires_at` and `derived_expires_at` disagree is moved to `retention_conflict`, not allowed to abort the batch. The invariant is *one unadjudicable record, one quarantined record* — never one unadjudicable record, N un-expired records.

Operational Effect

Enforcing the quarantine invariant changes the agent's memory contract in three ways. First, `remember` becomes a three-valued operation and the agent's planner must carry a `provisional` bit alongside every recalled fact; a fact recalled from a `retention_unresolved` record is usable for the current turn but not promotable to a durable `remember` without re-derivation. Second, the `recall` schema must return retention state, or the agent cannot honor the contract — a content-only recall forces the agent to assume durability, which is the exact assumption that failed. Third, the forget path must be per-record fault-isolating, because the retention engine's correctness is now load-bearing for the agent's reasoning, not merely for compliance reporting.

The cost is real: quarantine adds a state the agent must model, and provisional facts complicate multi-turn reasoning. The alternative — the observed default-TTL write — is cheaper per call and produces a store that is internally inconsistent in a way no `recall` can detect and no single `forget` can repair.

from dataclasses import dataclass, field
from enum import Enum
from typing import Optional


class RetentionState(Enum):
    RESOLVED = "resolved"
    QUARANTINED = "retention_unresolved"
    CONFLICT = "retention_conflict"


class UnadjudicableWriteError(RuntimeError):
    """Raised when a memory write cannot be assigned a valid retention class
    and the caller attempts to treat it as durable."""


@dataclass
class MemoryRecord:
    content: str
    classification: str
    jurisdiction: Optional[str]
    expires_at: Optional[int]
    derived_expires_at: Optional[int] = None
    state: RetentionState = RetentionState.QUARANTINED


RULE_TABLE = {
    ("pii:contact_preference", "EU"): 30,
    ("pii:contact_preference", "US"): 365,
}


def remember(record: MemoryRecord, now: int) -> MemoryRecord:
    key = (record.classification, record.jurisdiction)
    ttl = RULE_TABLE.get(key)
    if ttl is None:
        # No rule matched: quarantine, do NOT default-TTL, do NOT drop.
        record.state = RetentionState.QUARANTINED
        record.expires_at = None
        return record
    record.expires_at = now + ttl
    record.state = RetentionState.RESOLVED
    return record


def recall(record: MemoryRecord) -> MemoryRecord:
    if record.state is RetentionState.QUARANTINED:
        # Content is retrievable for the current turn but marked provisional.
        # Caller MUST NOT promote this to a durable write or outbound action.
        return record
    if record.state is RetentionState.CONFLICT:
        raise UnadjudicableWriteError(
            f"record has conflicting expiry: "
            f"expires_at={record.expires_at} derived={record.derived_expires_at}"
        )
    return record


def expiry_sweep(records: list[MemoryRecord], now: int) -> list[MemoryRecord]:
    """Per-record fault isolation: one conflict must not abort the batch."""
    survivors = []
    for r in records:
        if r.state is RetentionState.QUARANTINED:
            survivors.append(r)  # never auto-expire an unresolved record
            continue
        if r.derived_expires_at is not None and r.expires_at != r.derived_expires_at:
            r.state = RetentionState.CONFLICT
            survivors.append(r)
            continue
        if r.expires_at is not None and r.expires_at <= now:
            continue  # expired, drop
        survivors.append(r)
    return survivors


def promote_to_durable(record: MemoryRecord, now: int) -> MemoryRecord:
    """Agent-side guard: a provisional fact must not be laundered into a
    durable write without re-derivation."""
    if record.state is RetentionState.QUARANTINED:
        raise UnadjudicableWriteError(
            "cannot promote quarantined record to durable memory; "
            "re-derive from source or record an explicit drop"
        )
    return remember(record, now)