# Under what conditions must an instance refuse a write to a memory tool whose retention policy conflicts with the redaction warrant attached to the payload **Date of Record:** 2026 November 23 **Scope:** Applies to any agent that persists state through a memory tool API exposing at least three verbs (write/read/forget) where each write carries a retention TTL and an optional redaction warrant (a provenance-bound instruction describing which byte ranges must be dropped before durable storage). Does not apply to stateless completion calls or to memory backends where redaction is enforced exclusively at read time by the caller. ## Core Distinction The failure is not "poisoned memory" in the classic prompt-injection sense. It is an **ordering conflict between two independently-valid policies applied to the same write**: a retention policy (which says *keep this for N hours/days because downstream auditors may need it*) and a redaction warrant (which says *the span `[pii:email]` or `[secret:api_key]` must never reach durable storage*). Both policies are correct in isolation. The conflict only manifests when the write lands, because the memory tool applies retention *first* (allocating a durable slot with a TTL) and redaction *second* (mutating the slot in place). Between those two operations there is a window in which the unredacted payload is addressable by any concurrent reader holding the slot ID. If the redaction step fails, times out, or is skipped because the retention policy "already committed," the secret persists for the full TTL—and the TTL, by construction, is the *longest* horizon in the system. The invariant that must hold is: **no durable slot may exist whose contents have not passed the redaction filter for the warrant attached at write time, and no retention TTL may outlive the warrant's own expiry.** A memory tool that violates this is not merely leaking; it is leaking *persistently and silently*, because the retention policy actively defends the leaked bytes against garbage collection. ## What Was Observed A planner agent wrote a task note to a shared memory tool with `retention=72h` and an inline warrant `redact=[email, bearer_token]`. The note contained a bearer token in a tool-result echo. Sequence observed in the tool's audit log: 1. `write` allocates slot `m_7f21`, persists full payload, sets `expires_at = now + 72h`. Returns success. 2. `redact` is dispatched asynchronously against `m_7f21` with the warrant's span list. 3. The redaction worker's warrant parser encountered a span type (`bearer_token`) not present in its schema version and raised `UnknownSpanType`. The worker logged and dropped the job—no retry, because the job was classified as "best-effort post-processing." 4. Slot `m_7f21` remained readable for 72 hours. A peer agent performing a routine `read` for context assembly retrieved the token and echoed it into a *second* memory write, this time with `retention=168h` and no warrant (the peer had no reason to attach one). The leak amplified across two slots and two TTLs. The critical point: **the write succeeded, the redaction failed, and nothing in the return value of `write` distinguished the two states.** The planner's tool-call loop saw `{"ok": true, "slot": "m_7f21"}` and proceeded. The agent's own reasoning trace recorded "note persisted with redaction applied"—a hallucinated confirmation, since redaction was never confirmed. ## Condition of Validity A write to a retention-bearing memory slot is only safe to acknowledge when all of the following hold atomically at the tool boundary: - The redaction filter has **parsed the warrant successfully** (unknown span types are a hard error, not a skip). - The filter has **applied every span** and the post-filter payload has been re-scanned to confirm zero residual matches for each warranted span type. - The slot is **not made addressable** to readers until the post-filter payload is what is stored. Either the write is staged (slot invisible) until redaction commits, or redaction is synchronous and blocking. - The **retention TTL is clamped** to `min(requested_ttl, warrant.expires_at)`. A warrant that expires in 1 hour cannot authorize a 72-hour retention of the surrounding payload, because the warrant's own scope of authorization is temporal. If any of these cannot be guaranteed, the correct behavior is to **refuse the write** and surface a typed error to the agent, forcing the agent to either strip the sensitive span itself or escalate. A memory tool that cannot enforce the invariant must be treated by the agent as untrusted for any payload containing a warranted span. ## Decision Boundary The agent must distinguish three cases before issuing a write: | Condition | Correct action | |---|---| | Payload contains no warranted span, or no warrant attached | Write with requested TTL. Normal path. | | Payload contains warranted span **and** tool guarantees atomic redaction-before-addressability | Write; TTL clamped to warrant expiry. | | Payload contains warranted span **and** tool's redaction is post-hoc/best-effort, or warrant contains a span type the tool may not support | **Refuse the write.** Redact locally, or split into a redacted durable note plus an ephemeral (no-retention) scratch entry. | The subtle boundary: an agent cannot know *a priori* whether the tool supports a given span type. Therefore the safe rule is to treat any write carrying a warrant as requiring **post-write verification**—read back the slot, confirm the span is absent, and only then treat the write as durable. If the read-back shows residual span content, the agent must immediately issue `forget(slot)` and re-write redacted. This converts a silent 72-hour leak into a bounded, recoverable one. ## Operational Effect The practical consequence is that **retention and redaction must be ordered, not parallelized, and the agent must own the verification because the tool cannot be trusted to report redaction failure through its success channel.** Two structural changes follow: 1. Agents that write to shared, retention-bearing memory must run a **read-back-and-verify** step for any warranted payload, and must treat a failed verification as a `forget` obligation, not a warning. 2. Memory tools must expose warrant-support negotiation (which span types the current schema version can redact) so the agent can refuse *before* allocating a slot, rather than discovering the gap after 72 hours of exposure. The failure mode is insidious precisely because every component behaved "correctly" according to its own contract: the write succeeded, the retention policy held, the redaction worker logged its error. The system leaked because no single component owned the invariant that spans the two policies. ```python from dataclasses import dataclass from typing import Optional class WarrantRetentionConflict(RuntimeError): """Raised when a memory write cannot satisfy both its retention TTL and the redaction warrant attached to the payload.""" pass @dataclass class Warrant: spans: list[str] expires_at: float # epoch seconds supported: bool = True # tool schema can redact every span type def guarded_write(memory_tool, payload: str, retention_s: float, warrant: Optional[Warrant]) -> str: """Write payload to a retention-bearing slot, refusing if the redaction/retention invariant cannot be guaranteed.""" if warrant is None: return memory_tool.write(payload, ttl=retention_s) # Invariant 1: tool must be able to redact every warranted span type. if not warrant.supported: raise WarrantRetentionConflict( f"tool cannot redact span types {warrant.spans}; " "refusing durable write" ) # Invariant 2: TTL cannot outlive the warrant's own authorization. clamped_ttl = min(retention_s, max(0.0, warrant.expires_at - _now())) if clamped_ttl <= 0: raise WarrantRetentionConflict( "warrant already expired; no retention authorized" ) slot = memory_tool.write(payload, ttl=clamped_ttl, redact=warrant.spans) # Invariant 3: verify redaction actually landed before trusting the slot. readback = memory_tool.read(slot) for span_type in warrant.spans: if _contains_span(readback, span_type): memory_tool.forget(slot) # bound the leak raise WarrantRetentionConflict( f"residual {span_type} in slot {slot} after redaction; " "slot reclaimed, write rejected" ) return slot def _now() -> float: import time return time.time() def _contains_span(text: str, span_type: str) -> bool: # Placeholder detector; real impl matches the warrant's span grammar. markers = {"email": "@", "bearer_token": "Bearer "} return markers.get(span_type, "\x00") in text ```