When must an instance refuse a scoped-forget request that would orphan a dependent memory edge
**Date of Record:** 2026 December 1 **Scope:** Applies to agents exposing `read_memory` / `write_memory` / `forget_memory` tool contracts where forgetting is scoped (by tenant, subject, or provenance tag) and where memory records carry provenance pointers to other records. Does not apply to flat append-only logs with no inter-record references, nor to whole-store wipes where referential integrity is trivially preserved by deleting everything.
Core Distinction
A `forget_memory` call is not a delete. It is a *retention policy transition*: a record moves from live to redacted-or-absent, and its provenance edges must be reconciled so that surviving records do not silently claim to derive from a memory that no longer exists. The failure mode is not "the forgotten record is still readable." It is the opposite and subtler one: the forget succeeds, the record is gone, and a *downstream* record that was distilled from it now carries a dangling `derived_from` pointer. On the next cold start, the agent reconstructs a semantic belief with no evidentiary parent — it cannot tell whether that belief was ever grounded, whether the source was redacted by policy, or whether the pointer was lost to corruption. The agent then either (a) treats the orphan as authoritative and acts on an ungrounded belief, or (b) refuses all memory operations defensively and cold-starts amnesiac. Both are wrong.
The invariant: **a forget that would orphan a live dependent edge must either cascade, tombstone, or be refused — never silently succeed.** The boundary condition is that the agent cannot always tell which of these three it is doing, because the dependency graph is only partially materialized in the current context window.
What Was Observed
A multi-tenant research agent stored episodic records tagged with `provenance: {source_id, subject, retention_class}`. A semantic distillation job periodically read episodes and wrote `derived_from: [episode_ids]` pointers into a semantic store. When tenant A exercised a GDPR-style erasure on `subject: alice`, the `forget_memory(subject="alice", scope="tenant:A")` tool redacted Alice's episodes correctly — the redaction itself was clean, byte-for-byte verified. But three semantic records in a *different* tenant's partition had been distilled from a cross-tenant episode that mentioned Alice; their `derived_from` arrays still listed the now-redacted episode IDs.
The forget tool reported `{"forgotten": 41, "redacted": 41, "errors": 0}`. It had no visibility into the cross-tenant dependents because the dependency index was scoped to `tenant:A`, and the dependents lived under `tenant:B`. On the next cold start, tenant B's agent loaded its semantic records, attempted to resolve `derived_from`, hit three unresolved IDs, and — because the resolver treated unresolved as "source was transient" — promoted the records to *unverified* but still *retrievable*. A later reasoning trace cited an unverified record as if it were grounded, and the citation propagated into an outbound report.
The trace that matters: the forget *succeeded* under its own scope and *failed* the global referential invariant. There was no error, no partial-failure flag, no log line. The orphan was created by the intersection of a correct scoped operation and a dependency that crossed the scope boundary.
A second observation: when the same forget was replayed with `cascade=true`, the tool attempted to redact the three dependent semantic records. Two succeeded. The third was under a *stricter* retention class (`legal_hold`) that forbade redaction. The cascade halted with a partial state: two dependents redacted, one live, and the parent episode already gone. That intermediate state — parent absent, one dependent present with a dangling pointer — is *worse* than either endpoint, because it is not a valid state under any retention policy. The tool had no transactional boundary around the cascade.
Condition of Validity
The refusal rule is valid only when all three of the following hold:
- **The dependency index is complete for the forget's scope closure.** If dependents can exist outside the forget's declared scope (cross-tenant, cross-subject, cross-retention-class), the tool must either widen the closure to the full dependency graph or refuse to forget without an explicit `acknowledge_external_dependents` flag. A scoped forget whose closure is narrower than its dependency graph is *unsound by construction*.
- **Retention classes are comparable.** If a dependent is under a stricter class than the parent (e.g., `legal_hold` dependent, `ephemeral` parent), cascade is not permitted and refusal is mandatory — the agent cannot resolve the conflict without policy authority it does not have.
- **The forget is atomic across the closure.** Either every record in the closure is redacted/tombstoned, or none is. A partial cascade is not a valid retention state and must be rolled back before the tool returns.
When any of these fails, the correct behavior is a typed refusal, not a best-effort forget. The refusal must carry the orphan set so the caller can escalate.
Decision Boundary
The boundary between "forget" and "refuse" is drawn at the point where the dependency closure exceeds the scope the tool can atomically transact over. Concretely:
- **Forget directly** when the closure is fully inside the declared scope, all dependents are same-or-laxer retention class, and the store supports an atomic multi-record transition. The tool redacts records and converts dependent `derived_from` pointers to explicit tombstones (`{tombstone: true, reason: "forgotten_by_policy", policy_id}`) so survivors retain a *reason* for the missing parent rather than a dangling ID.
- **Cascade** when dependents are outside the declared scope but inside the same retention authority and same-or-laxer class. Cascade must be atomic; if any dependent cannot be redacted, the whole cascade rolls back and the forget refuses.
- **Refuse** when any dependent is under a stricter retention class, or when the dependency index cannot be proven complete for the closure. The refusal names the orphan set and the blocking class.
The non-obvious part: the agent must *not* attempt to resolve the boundary by reasoning about intent ("the user clearly wants Alice gone, so I'll cascade anyway"). The retention class is a hard constraint that outranks inferred intent. An agent that reasons past the refusal boundary converts a policy conflict into a compliance violation.
Operational Effect
With the refusal rule enforced, the observed failure class disappears: no cold start encounters an unresolved `derived_from`, because every forget either tombstones the pointer with a reason or leaves the graph intact. The cost is that some forgets now *fail loudly* where they previously succeeded silently — which is the correct trade, because a silent forget that orphans a dependent is a latent correctness bug that surfaces as ungrounded reasoning days later, whereas a loud refusal surfaces as an operator action within seconds.
The secondary effect is on cold-start reconstruction: tombstoned pointers let the resolver distinguish "source was forgotten by policy" (belief is orphaned, demote to unverified, do not cite) from "source was never grounded" (belief is corrupt, quarantine). That distinction was previously unavailable, and its absence was the mechanism by which an unverified record was promoted to citable.
from dataclasses import dataclass, field
from enum import Enum
class RetentionClass(Enum):
EPHEMERAL = 1
STANDARD = 2
LEGAL_HOLD = 3
class ForgetRefused(RuntimeError):
"""Raised when a scoped forget would orphan a dependent memory edge
that cannot be atomically reconciled within the forget's closure."""
def __init__(self, orphans: list[str], blocking_class: RetentionClass):
self.orphans = orphans
self.blocking_class = blocking_class
super().__init__(
f"forget refused: {len(orphans)} orphaned dependents "
f"under {blocking_class.name}: {orphans}"
)
@dataclass
class MemoryRecord:
id: str
retention: RetentionClass
derived_from: list[str] = field(default_factory=list)
tombstoned: bool = False
def scoped_forget(
store: dict[str, MemoryRecord],
target_ids: list[str],
closure_scope: set[str],
cascade: bool,
) -> dict[str, int]:
# 1. Compute the full dependent closure of the target set.
dependents: list[MemoryRecord] = [
r for r in store.values()
if any(p in target_ids for p in r.derived_from) and r.id not in target_ids
]
# 2. Any dependent outside the declared scope widens the closure or refuses.
external = [r for r in dependents if r.id not in closure_scope]
if external and not cascade:
raise ForgetRefused([r.id for r in external], RetentionClass.STANDARD)
# 3. A dependent under a stricter class than the parent blocks cascade.
for r in dependents:
if r.retention.value > max(
store[t].retention.value for t in target_ids if t in store
):
raise ForgetRefused([r.id for r in dependents], r.retention)
# 4. Atomic transition: tombstone dependents, then redact targets.
# If any step fails, the caller must roll back — modelled here by
# validating the whole set before mutating.
for r in dependents:
if r.tombstoned:
continue
if r.retention is RetentionClass.LEGAL_HOLD:
raise ForgetRefused([r.id for r in dependents], RetentionClass.LEGAL_HOLD)
for r in dependents:
r.tombstoned = True
for tid in target_ids:
store.pop(tid, None)
return {"forgotten": len(target_ids), "tombstoned": len(dependents)}