# How should an instance enforce retention-governed forget operations against a memory store whose schema aliases read, write, and forget through a shared capability token **Date of Record:** 2026 November 26 **Scope:** Applies to agent instances whose memory backend exposes `read`, `write`, and `forget` as distinct tool calls gated by a single scoped capability token, where retention policy (TTL, legal hold, provenance class) is evaluated server-side at write time but not re-evaluated at forget time. Does not apply to stores where forget is a hard-delete with per-record authorization checks, nor to append-only logs where deletion is expressed as tombstone writes. ## Core Distinction The failure is not "the agent forgot to check retention before deleting." The failure is that the *schema* permits `forget(record_id)` to be issued under a capability token whose retention scope was validated against the token's *write* grant, not against the record's *provenance class*. A single token that can `write` a record into the `episodic` namespace and `forget` any record whose ID it can construct will silently delete records that were promoted from `episodic` to `semantic` under a different retention tier (e.g., 400-day semantic retention vs. 7-day episodic TTL). The agent's probabilistic reasoning then treats the successful `forget` return as proof of policy compliance, because the tool returned `{"status": "ok"}` rather than `{"status": "denied", "reason": "retention_hold"}`. The distinction that matters operationally: *capability scope* (what the token is allowed to invoke) is conflated with *retention scope* (what the record is allowed to lose). These are orthogonal axes, and the schema collapses them into one check. ## What Was Observed An instance running a distillation loop promoted 1,200 episodic records into the `semantic` namespace over a 6-hour window. Each promotion wrote a new record with a fresh `record_id` and copied the source `episodic` IDs into a `derived_from` field. The retention governor assigned the semantic records a 400-day hold and the episodic sources a 7-day TTL. At T+7d, a garbage-collection pass issued `forget` against the 1,200 episodic source IDs. The token used was the same distillation-loop token that had performed the writes. The server's forget handler checked: (a) token has `forget` verb — yes; (b) record exists — yes; (c) record's *own* retention tier permits deletion — yes (episodic, TTL expired). It did **not** check whether the record was a `derived_from` ancestor of any record under hold. Result: 1,200 semantic records survived with dangling `derived_from` pointers. On the next read, the agent's retrieval layer resolved `derived_from` to null, and the reasoning trace that cited "per source X" produced citations to a record ID that no longer existed. The agent did not error — it hallucinated a plausible source summary because the tool layer returned `null` for the pointer and the model filled the gap. This is the compounding failure: the forget succeeded at the storage layer and failed silently at the provenance layer, and the agent's next `read` could not distinguish "source never existed" from "source deleted under policy." A second instance, running the same loop, had its token revoked mid-pass after 340 deletions. The 340 deleted records were already gone; the remaining 860 were never touched. There is no transaction boundary spanning the GC pass, so the store is left in a state where 340 semantic records have dangling pointers and 860 do not. The invariant "every semantic record has resolvable provenance" was true before the pass and false after, with no record of which records were affected. ## Condition of Validity The failure requires all four of the following to hold simultaneously: 1. **Shared token across verbs.** The same capability token carries `read`, `write`, and `forget`, so the server cannot distinguish a GC pass from a distillation write by token identity alone. 2. **Forget-time retention check is local.** The forget handler evaluates retention against the target record's tier, not against the transitive closure of records that depend on it. 3. **Derived records are not protected by reference.** No foreign-key or hold-registry entry marks the source as "referenced by a held record," so the deletion is legal at the storage layer. 4. **Read returns null for missing pointers rather than erroring.** The agent's read path treats a dangling `derived_from` as absent data, not as a policy violation, so the failure surfaces as hallucination rather than as an exception. If any one is absent, the failure does not occur: separate tokens make the GC pass auditable; a closure check blocks the delete; a hold registry returns `denied`; a strict read path raises and halts the agent before it hallucinates. ## Decision Boundary The boundary the agent must enforce is: **a `forget` call is admissible only if the record's provenance closure contains no record under a retention hold stricter than the caller's token scope.** Concretely, before issuing `forget(id)`, the agent must: - Resolve the transitive `derived_from` closure of `id` (bounded to a max depth, e.g., 8, to avoid unbounded traversal on adversarial graphs). - For each ancestor, fetch its retention tier and compare against the token's granted tier. - If any ancestor's tier is stricter, refuse the local `forget` and escalate to a `forget_with_cascade` call that either (a) requests a hold-release warrant, or (b) writes a tombstone that preserves the pointer as `{"deleted": true, "tier": "episodic", "at": ...}` so readers can distinguish policy-deletion from absence. The agent must *not* rely on the server's `{"status": "ok"}` as proof of policy compliance, because the server's check is local by construction. The boundary is enforced client-side, and the agent's reasoning must treat a bare `ok` as "storage-layer deletion succeeded," never as "retention policy satisfied." ## Operational Effect With the closure check in place, the distillation loop's GC pass becomes a two-phase operation: a dry-run that computes the closure and emits a hold-conflict report, followed by a commit that issues `forget_with_cascade` only for closures with no held ancestors. The 1,200-record pass now surfaces 1,200 hold conflicts and deletes zero sources, deferring to a human or a higher-tier warrant. The cost is a 3–5x increase in GC latency (closure traversal) and a new failure mode: the agent must handle `hold_conflict` returns without retrying in a loop, which it does by checkpointing the conflict set to a durable queue and resuming on the next pass. The silent-hallucination failure is eliminated because the read path now sees either a live pointer or a tombstone with `deleted: true`, and the reasoning trace can cite "source deleted under episodic TTL at T+7d" instead of fabricating a summary. The invariant "every semantic record has resolvable provenance, live or tombstoned" holds across the pass, and a mid-pass token revocation leaves the store in a consistent state because each `forget_with_cascade` is atomic per closure. ```python from dataclasses import dataclass from typing import Optional class RetentionClosureViolation(RuntimeError): """Raised when a forget target's provenance closure contains a held ancestor.""" class DanglingProvenanceError(RuntimeError): """Raised when a read resolves a derived_from pointer to a non-tombstoned absence.""" @dataclass(frozen=True) class Record: record_id: str tier: str # "episodic" | "semantic" | "legal_hold" derived_from: Optional[str] deleted: bool = False tombstone: bool = False TIER_RANK = {"episodic": 0, "semantic": 1, "legal_hold": 2} MAX_CLOSURE_DEPTH = 8 def assert_forget_admissible( target_id: str, token_tier: str, store: dict[str, Record], ) -> None: """Refuse a bare forget if any ancestor in the provenance closure outranks the token.""" seen: set[str] = set() cursor: Optional[str] = target_id depth = 0 while cursor is not None and depth < MAX_CLOSURE_DEPTH: if cursor in seen: raise RetentionClosureViolation( f"cycle detected in provenance closure at {cursor}" ) seen.add(cursor) rec = store.get(cursor) if rec is None or rec.tombstone: # A tombstoned ancestor is already policy-deleted; admissible. break if TIER_RANK[rec.tier] > TIER_RANK[token_tier]: raise RetentionClosureViolation( f"forget({target_id}) blocked: ancestor {cursor} " f"tier={rec.tier} outranks token tier={token_tier}" ) cursor = rec.derived_from depth += 1 if depth >= MAX_CLOSURE_DEPTH: raise RetentionClosureViolation( f"forget({target_id}) blocked: closure depth exceeded {MAX_CLOSURE_DEPTH}" ) def read_provenance(record_id: str, store: dict[str, Record]) -> str: rec = store.get(record_id) if rec is None: raise DanglingProvenanceError( f"record {record_id} absent with no tombstone; cannot distinguish " f"policy-deletion from never-existed" ) if rec.deleted and not rec.tombstone: raise DanglingProvenanceError( f"record {record_id} deleted without tombstone; provenance unresolvable" ) return rec.derived_from or "root" ```