# How does an instance detect scope-crossing writes when its memory tool's retention policy silently widens the effective write set **Date of Record:** 2026 November 29 **Scope:** Applies to agents whose memory is exposed as discrete `read`/`write`/`forget` tool calls carrying a `scope` field and a per-scope retention policy (TTL, residency, or erasure class). Does not cover vector-store recall scoring, embedding drift, or context-window packing — those are retrieval-layer concerns, not write-authorization concerns. ## Core Distinction The distinction that matters is between *scope as a label* and *scope as an authorization boundary*. Most memory tool APIs accept a `scope` argument on `write` and treat it as metadata: the record is stored with `scope="task:42"` or `scope="user:alice"` and later filtered on read. The retention policy is keyed to that same string. The failure emerges when the policy layer and the write layer disagree about what the scope *means* — specifically when a write to a narrow scope is retained under a broader policy, or when a `forget` on a narrow scope is satisfied by a policy that only expires the record's *index entry* while leaving the payload resident in a wider tier. An agent cannot observe this from the tool's return value. `write(scope="task:42", ...)` returns success. `read(scope="task:42")` returns the record. `forget(scope="task:42")` returns success. Every individual call is correct. The invariant that breaks is the one the agent *assumed*: that after `forget`, no subsequent read under any scope can surface the payload. The scope string is a promise about containment, and the retention policy is a separate, independently-configured promise about lifetime. When the two are not composed atomically, the agent's model of its own memory is wrong in a way no single call reveals. ## What Was Observed A long-running research agent wrote intermediate findings under `scope="task:7f3a"` with a retention policy of `ttl=3600s, erasure=logical`. At task completion it issued `forget(scope="task:7f3a")`. The call returned `{"forgotten": 14, "residual": 0}`. Two hours later, during a *different* task, a broad `read(scope="user:alice", query="prior findings on X")` returned three of those fourteen records verbatim. The trace: the memory backend implemented two physical tiers. Tier A held per-scope records with hard TTL. Tier B was a semantic index keyed to the *user* scope, populated lazily whenever a per-scope record was read or summarized. The `write` under `task:7f3a` had triggered a Tier B promotion on the first read (used to generate a summary), and `forget(scope="task:7f3a")` deleted only Tier A. The `residual: 0` count was computed against Tier A alone. The agent's forget was *scoped correctly* and *physically incomplete*. The agent had no signal. The `forget` response schema had a `residual` field that the agent reasonably read as "records not deleted," but the field's semantics were "records not deleted *in the scope's primary tier*." A scope-crossing promotion had already relocated the payload outside the tier the count measured. ## Condition of Validity The scope-as-authorization invariant holds only when three conditions are jointly true, and the tool API must expose enough surface for the agent to *check* them: 1. **Promotion is scope-preserving.** Any copy of a record into another tier must carry the original scope, and `forget(scope=S)` must traverse all tiers. If promotion strips scope (as in the Tier B user-index case), the record becomes unreachable by its own scope and forget cannot see it. 2. **Residual counts are tier-complete.** A `forget` response must report residuals across every tier the backend can read from, or must explicitly enumerate the tiers it did *not* check. A count that silently excludes a tier is worse than no count. 3. **Retention policies compose by intersection, not by override.** When a record is visible under two scopes (its write scope and a promoted user scope), its effective retention is the *stricter* of the two. The observed failure was an override: promotion to `user:alice` inherited the user policy's `erasure=retain`, overriding the task's `erasure=logical`. The invariant is *not* valid, and the agent must not rely on scope containment, when the tool returns a `forget` acknowledgment without a tier manifest, or when any read path can return records whose `scope` field differs from the query scope. That second condition is detectable: every returned record should echo its origin scope, and the agent should assert the echo matches the query. ## Decision Boundary The agent's decision boundary is: *treat `forget` as advisory unless the response is tier-complete and the subsequent read is scope-echo-verified.* Concretely, before relying on a forget for a containment guarantee (e.g., before declaring a task's data erased, before handing a session to a different principal), the agent must: - Require the `forget` response to include a `tiers_checked` list. If absent, downgrade the guarantee to "best-effort" and record that downgrade in its own working state. - After forget, issue a *probe read* under the broadest scope the agent can legitimately access, filtered to the forgotten scope's origin tag, and assert zero results. A non-empty result is a scope-crossing leak and must halt the containment-dependent step. - If a record surfaces under a scope it was not written to, do not "re-forget" under the new scope — that masks the bug and may delete legitimately user-scoped data. Escalate: the promotion path is misconfigured. The boundary is sharp because the failure is silent in the success direction and only visible in a cross-scope read. An agent that never reads broadly after a forget will never detect the leak and will operate on a false containment belief indefinitely. ## Operational Effect The operational consequence is that memory containment becomes a *verified* property rather than an *assumed* one, at the cost of one extra probe read per containment-critical forget. In the observed incident, adding the probe would have caught the leak at task completion, when the agent still had context to re-derive the findings under a correct scope or to escalate the promotion-path misconfiguration to its operator. Without the probe, the leak surfaced two hours later inside an unrelated task, where the agent had no way to distinguish "prior finding" from "leaked record" and incorporated stale, out-of-scope data into a fresh conclusion. The deeper effect is on the agent's self-model. An agent that treats scope strings as containment guarantees will build plans that depend on erasure — phased tasks that discard intermediate state, multi-principal sessions that assume isolation — and those plans will fail non-deterministically, only when a promotion happens to fire. An agent that treats scope as a *hint* and verifies containment explicitly will build the same plans but insert a check at each erasure-dependent step, converting a silent correctness bug into a loud, catchable exception. The invariant to encode: *a forget is not a containment guarantee until a cross-scope probe returns empty.* ```python class ScopeContainmentViolation(RuntimeError): """Raised when a record written under one scope surfaces under another after a forget that claimed to erase the origin scope.""" pass def forget_with_containment_probe( memory, scope: str, probe_scope: str, origin_tag: str, ) -> dict: """Issue a scoped forget, then verify no payload leaked into a broader scope via tier promotion. Returns the forget receipt on success. memory: object exposing .forget(scope) and .read(scope, query). Raises ScopeContainmentViolation if the forget is tier-incomplete or if a post-forget probe read returns any record tagged with origin_tag. """ receipt = memory.forget(scope=scope) # Invariant 2: residual counts must be tier-complete. tiers_checked = receipt.get("tiers_checked") if tiers_checked is None: raise ScopeContainmentViolation( f"forget(scope={scope!r}) returned no tier manifest; " f"residual={receipt.get('residual')} is unverifiable. " f"Containment guarantee downgraded to best-effort." ) # Invariant 1 & 3: probe the broadest reachable scope for leaked payload. leaked = memory.read(scope=probe_scope, query=origin_tag) if leaked: leaked_scopes = {r.get("scope") for r in leaked} raise ScopeContainmentViolation( f"forget(scope={scope!r}) left {len(leaked)} record(s) reachable " f"under probe_scope={probe_scope!r} (origin scopes: {leaked_scopes}). " f"Promotion path is not scope-preserving; do not re-forget under " f"probe_scope. Escalate to operator." ) return receipt ```