# Where must an instance reject a write that arrives under an expired retention scope before it can be forgotten **Date of Record:** 2026 November 17 **Scope:** Applies to any agent-facing memory tool exposing `remember`/`recall`/`forget` operations where retention is bound to a scope (session, tenant, task, principal) with an expiry timestamp and a forgetting guarantee. Does not apply to append-only audit logs exempt from forgetting, nor to stores where retention is global rather than scoped. ## Core Distinction The failure is not "write to a forgotten key." It is "write to a **live key under a dead scope**." These are structurally different. A forgotten key is absent; a write against it is either a resurrection attempt (rejectable by tombstone) or a fresh insert (harmless). A dead scope is subtler: the scope's retention window has closed, the forget sweep has already run for that scope, and the guarantee has been *discharged*. Any object written afterward is not covered by the discharged sweep. It is born outside the guarantee. The distinction that matters operationally: **the forget sweep is a point-in-time event, not a standing predicate.** A retention policy of "scope T forgets at time E" means "everything present in T at E is destroyed." It does not mean "everything in T is destroyed at all times after E." Systems that treat the guarantee as a predicate rather than an event will accept post-sweep writes and silently leak them past the promise. ## What Was Observed A memory tool with per-scope TTLs. Scope `task-4471` carried `retention_until = 2026-11-14T09:00:00Z` and a forget-by guarantee. The sweeper ran at 09:00:02, purged 1,842 objects, and marked the scope `DISCHARGED`. At 09:00:17 a retry queue — replaying a `remember` call whose acknowledgment had been lost — delivered a write tagged `scope=task-4471`. The API accepted it. The object was stored, indexed, and returned by `recall` for the next eleven days. The guarantee had been *satisfied and then violated* by the same scope. Auditors reading the guarantee log saw "forgotten at 09:00:02" and "0 objects retained" — both true at the instant they were written. The post-sweep insert never appeared in any guarantee assertion because the assertion had already fired. The leak was invisible to every component that reasoned about the guarantee, because every component treated discharge as terminal. A second observation: the same write, delivered to a scope that had *never* existed, was correctly rejected by the scope registry. The bug required a scope that had existed, expired, and been swept — i.e., a scope in the `DISCHARGED` state. The registry treated `DISCHARGED` as a valid target because it was a valid *historical* target. ## Condition of Validity The rejection rule is valid under these conditions, and only these: 1. The scope's forget sweep has **completed** (not merely been scheduled) and the scope is in a terminal `DISCHARGED` or `EXPIRED` state. 2. The write's `scope` field references that scope directly, or inherits it through a parent whose own window has closed. 3. The write is a *new* object, not an idempotent replay of an object that was already purged. (Replays of purged objects must be rejected too, but for a different reason — tombstone — and must not be conflated.) It does **not** apply when the scope is merely past its `retention_until` but the sweep has not yet run. In that window the scope is `EXPIRING`: writes must be *refused or immediately swept*, but the refusal is a liveness/consistency choice, not a guarantee violation. Conflating `EXPIRING` with `DISCHARGED` produces false rejections of legitimate in-flight writes and is the most common over-correction. It also does not apply to writes carrying an explicit `retention_override` that establishes a *new* scope with its own window. Such writes are legal but must be re-scoped, never attributed to the dead scope. ## Decision Boundary ``` scope.state == DISCHARGED and write.targets(scope) and write.is_new_object() -> RAISE ScopeDischargedError; do not store, do not index, do not ack as success scope.state == EXPIRING and write.targets(scope) -> accept-and-sweep-inline, or refuse with ScopeExpiringError; never silently store scope.state == DISCHARGED and write.is_idempotent_replay_of_purged() -> RAISE TombstonedObjectError (distinct class; do not merge with above) scope.state == DISCHARGED and write.has_valid_retention_override() -> re-scope to override, store under new scope, log the re-scoping event ``` The boundary is between "scope is dead" and "scope is dying." A dying scope can still accept a write if that write is swept before the scope transitions; a dead scope cannot, ever, because its guarantee is already spent. The check must be against **sweep completion state**, not against the clock. Clock-based checks race the sweeper and will admit writes in the gap between expiry and sweep. ## Operational Effect Enforcing the boundary converts a silent eleven-day leak into an immediate, typed, attributable error at the retry layer. The retry queue sees `ScopeDischargedError` and stops replaying — it must not treat it as transient. The guarantee log gains a second assertion type: "scope discharged at T; N post-discharge writes rejected," which makes the guarantee *auditable after the fact* rather than only at the instant of sweep. The cost is that idempotent replays of purged objects now surface as errors to callers who expected silent success. This is correct: a caller replaying a write to a discharged scope has a stale view of retention and must be told, not accommodated. The alternative — accepting the replay "harmlessly" — is exactly how the leak began, because "harmless" was evaluated against the object's content rather than against the scope's spent guarantee. The invariant to carry forward: **a forgetting guarantee is discharged by an event, and an event cannot cover writes that postdate it.** Any memory API that lets a discharged scope accept a new object has, by construction, a hole in its forgetting promise that no amount of content-level deletion will close. ```python class ScopeDischargedError(RuntimeError): """Raised when a write targets a scope whose forget sweep has completed.""" pass class TombstonedObjectError(RuntimeError): """Raised when a write replays an object already purged under a discharged scope.""" pass DISCHARGED = "DISCHARGED" EXPIRING = "EXPIRING" LIVE = "LIVE" def admit_write(scope, write): if scope.state == DISCHARGED: if write.is_idempotent_replay_of_purged(): raise TombstonedObjectError( f"object {write.object_id!r} was purged under discharged scope " f"{scope.id!r} at {scope.swept_at}; replay refused" ) if write.has_valid_retention_override(): return re_scope(write, write.retention_override) raise ScopeDischargedError( f"write to scope {scope.id!r} refused: sweep completed at " f"{scope.swept_at}, guarantee already discharged; post-sweep writes " f"are uncovered by the forgetting promise" ) if scope.state == EXPIRING: # Dying but not dead: accept only if we can sweep inline before transition. return accept_and_sweep_inline(write, scope) if scope.state == LIVE: return store(write) raise ScopeDischargedError(f"unknown scope state {scope.state!r} for {scope.id!r}") ```