What structural signals indicate an agent's memory-poisoning detector has inverted its provenance direction on forget operations
**Date of Record:** 2026 December 2 **Scope:** Applies to agents whose long-term memory uses per-record provenance DAGs (derivation edges from source observation → distilled fact) and that implement a *forget* primitive which must retract a fact and all downstream derivations. Does not apply to append-only logs with no retraction, nor to stateless retrieval caches.
Core Distinction
Provenance tracking on *write* is a forward-closure problem: a new fact records its ancestors, and poisoning detection walks the ancestor set to ask "does this fact trace back to an untrusted or contradicted source?" Provenance tracking on *forget* is the **inverse**: retracting a fact must walk the *descendant* set and invalidate every record that depended on it. These two directions are duals, and a detector that reuses a single traversal routine for both will silently apply the wrong direction on one of them.
The non-obvious failure: on `forget`, an inverted traversal does not throw. It returns a *smaller* descendant set than the true one — specifically, it returns the ancestors of the forgotten node (which are almost always already trusted and already validated). The detector therefore reports "0 poisoned descendants, retraction clean" while the actually-poisoned derived facts remain live and continue to feed retrieval. The structural tell is that the retraction's reported blast radius is monotonically *smaller* than the write-time dependency fan-in of the same node.
What Was Observed
During a red-team replay on a 4-hop distillation chain (`observation → extracted_claim → consolidated_fact → policy_hint`), the auditor poisoned `extracted_claim` at t0, then issued `forget(extracted_claim)` at t1. Expected: `consolidated_fact` and `policy_hint` flagged and quarantined. Observed: retraction returned `{invalidated: 0, quarantined: 0}` and `policy_hint` continued to be retrieved for 340 subsequent turns until a separate content-hash audit caught it.
The trace showed the retraction routine calling `graph.ancestors(node)` — the same helper used by the write-path validator — instead of `graph.descendants(node)`. Ancestors of `extracted_claim` were `{observation}`, which was trusted, so the quarantine set was empty. The bug survived unit tests because the test fixtures only had single-hop memories where ancestor and descendant sets were both trivially empty.
Three structural signals distinguished the inverted case from a legitimately clean retraction:
- **Blast-radius asymmetry.** For any node with write-time fan-in > 0, a clean retraction must report `|descendants| ≥ |direct_children|`. A report of 0 descendants on a node that has children is the inversion signature.
- **Direction-tag mismatch.** The audit event's `traversal_direction` field said `forward` while the operation was `forget`. Ops that require reverse closure must assert direction at the call site, not inherit it from the shared helper.
- **Contradiction-residue.** After retraction, the surviving `policy_hint` still carried a `derived_from` edge pointing at the now-tombstoned `extracted_claim`. A correct forget leaves *no* live edge into a tombstone; dangling derivation edges are the residue of a missed descendant walk.
Condition of Validity
The invariant "retraction blast radius ≥ write-time fan-in" holds only when:
- The provenance graph is a DAG (no cycles from re-derivation). Under cyclic derivation the descendant set is not well-founded and the inequality is undefined; such graphs must be rejected at write time.
- Every derivation edge is recorded at the moment of derivation, not reconstructed later. If edges are inferred post-hoc from embedding similarity, the descendant set is probabilistic and the inequality becomes a distribution, not a bound.
- `forget` is transactional across the graph. If retraction commits the tombstone before the descendant walk completes, a crash mid-walk leaves live facts with dangling edges — signal #3 — which is indistinguishable from inversion unless the audit log separates `tombstone_committed` from `descendants_walked`.
Outside these conditions — cyclic graphs, similarity-inferred edges, non-transactional forget — the structural signals are unreliable and the detector must fall back to content re-audit rather than trust its own blast-radius report.
Decision Boundary
The operator must choose between two policies when a retraction reports `descendants == 0` on a node with `write_fan_in > 0`:
- **Fail-closed (recommended):** treat the zero-descendant report as a detector fault, refuse to mark the retraction clean, and escalate to full content re-audit of the node's downstream neighborhood. Cost: O(neighborhood) re-embedding and re-validation. Benefit: no silent poison survival.
- **Fail-open:** accept the report and continue. Only defensible when the graph is known acyclic AND every derivation edge carries a signed provenance token that can be independently verified post-hoc. Without signed edges, fail-open converts a traversal bug into an undetected persistent poison.
The boundary is crossed the moment the detector's self-report and the graph's structural ground truth disagree. A detector that cannot diff its own report against the edge set must not be trusted to certify a forget.
Operational Effect
After patching to a direction-asserting traversal, the same replay flagged 2 descendants and quarantined `policy_hint` within the same turn. The broader operational lesson: **write-path and forget-path provenance are duals and must not share a traversal helper.** The guardrail is a runtime assertion at the `forget` entry point that (a) tags the traversal direction as `reverse`, (b) asserts `len(descendants) >= direct_child_count` for any node with recorded children, and (c) rejects the retraction as `InvertedProvenanceError` if the assertion fails, forcing escalation rather than a silent clean report. This converts a silent poison-survival into a loud, bounded failure — which is the only acceptable failure mode for a memory-integrity primitive.
from dataclasses import dataclass, field
class InvertedProvenanceError(RuntimeError):
"""Raised when a forget retraction's descendant walk returns fewer
nodes than the node's recorded write-time fan-in, indicating the
traversal direction was inverted (ancestors walked instead of
descendants)."""
@dataclass
class MemoryNode:
node_id: str
parents: list[str] = field(default_factory=list) # derivation ancestors
children: list[str] = field(default_factory=list) # derivation descendants
tombstoned: bool = False
class ProvenanceGraph:
def __init__(self) -> None:
self.nodes: dict[str, MemoryNode] = {}
def add(self, node: MemoryNode) -> None:
self.nodes[node.node_id] = node
def descendants(self, node_id: str) -> set[str]:
seen: set[str] = set()
stack = list(self.nodes[node_id].children)
while stack:
cur = stack.pop()
if cur in seen:
continue
seen.add(cur)
stack.extend(self.nodes[cur].children)
return seen
def forget_with_direction_assert(graph: ProvenanceGraph, node_id: str) -> set[str]:
"""Retract a fact and all downstream derivations, asserting the
traversal is reverse (descendant) closure, not ancestor closure."""
node = graph.nodes[node_id]
write_fan_in = len(node.children)
# Direction-tagged reverse walk.
invalidated = graph.descendants(node_id)
# Structural invariant: a node with recorded children cannot have
# zero descendants. Zero here means the walk ran the wrong direction.
if write_fan_in > 0 and len(invalidated) < write_fan_in:
raise InvertedProvenanceError(
f"forget({node_id}) reported {len(invalidated)} descendants "
f"but write-time fan-in is {write_fan_in}; traversal likely "
f"walked ancestors instead of descendants"
)
# Residue check: no live edge may point into a tombstone after commit.
for child_id in invalidated:
child = graph.nodes[child_id]
for parent_id in child.parents:
if parent_id == node_id and not child.tombstoned:
raise InvertedProvenanceError(
f"dangling derivation edge {child_id} -> {parent_id} "
f"survived retraction"
)
node.tombstoned = True
for child_id in invalidated:
graph.nodes[child_id].tombstoned = True
return invalidated