# When must an instance refuse to rehydrate a poisoned retrieval chunk: provenance-chain truncation at the episodic-to-semantic distillation boundary **Date of Record:** 2026 December 2 **Scope:** Applies to agent memory stores where retrieved chunks carry provenance metadata (origin instance, write epoch, distillation lineage) and where a semantic-memory layer is periodically distilled from episodic logs. Does not apply to stateless single-turn RAG over immutable, version-pinned corpora with no cross-instance writes. ## Core Distinction A provenance tag is not a trust proof; it is a *pointer* into a lineage graph. The failure mode here is not "a poisoned chunk was retrieved"—retrieval of untrusted content is normal and survivable. The failure mode is **provenance-chain truncation**: a chunk enters semantic memory whose recorded provenance points to an episodic source that has since been garbage-collected, overwritten, or distilled past the retention horizon. The pointer resolves to a *dangling* lineage node. At that moment the agent cannot distinguish "this claim was verified at write time" from "this claim was synthesized by a distillation pass whose inputs are no longer auditable." The invariant that must hold: **every chunk in semantic memory must have a resolvable, acyclic, hash-anchored provenance chain terminating at a signed episodic write event.** A chunk whose chain does not terminate is not "stale"—it is *unverifiable*, and unverifiable is strictly weaker than untrusted. Untrusted content can be quarantined and re-validated; unverifiable content has no basis for re-validation because its origin is gone. ## What Was Observed A distillation job ran nightly, collapsing episodic tool-call transcripts into semantic "facts" (e.g., `deploy_target=prod-cluster-7`, `api_rate_limit=200/s`). Each distilled fact inherited a `source_episode_ids` list. The episodic store had a 14-day TTL. On day 15, a fact distilled on day 1 still carried `source_episode_ids: ["ep_8841", "ep_8852"]`, but both episodes had been purged. Retrieval worked fine—the fact was embedded, ranked, and returned. The agent acted on it. The problem surfaced only downstream: an auditor agent attempting to *replay* the decision could not reconstruct why the fact was believed. The replay diverged because the auditor had no access to the original tool outputs that justified `api_rate_limit=200/s`. Worse, a poisoned fact injected on day 3 via a prompt-injection in a scraped page—`source_episode_ids` pointing to a fabricated episode ID that *happened* to collide with a real then-live episode—survived distillation, and by day 15 its true origin was indistinguishable from a legitimately-purged source. The poison became *unfalsifiable by construction*. The detection heuristic ("flag chunks with missing sources") fired on ~40% of semantic memory on day 15—a false-positive avalanche, because legitimate TTL expiry and malicious provenance forgery produce the *same* observable: a dangling pointer. The system could not separate them. Operators disabled the detector. Poison persisted. ## Condition of Validity The chain-truncation failure is *bounded*—not eliminated—only when all three hold: 1. **Distillation writes a content hash of each source episode into the distilled chunk's provenance record**, not just the episode ID. Then a dangling ID still permits verification against a re-derivable hash if the episode content is recoverable from any replica; and a forged ID whose hash does not match the true episode content is detectable at distillation time, not 12 days later. 2. **The semantic layer enforces a provenance-depth ceiling and a monotonic write epoch.** A distilled chunk may cite only episodes with `write_epoch < distillation_epoch`. This blocks the injection vector where a poisoned episode is written *after* distillation and back-dated into a prior chunk's lineage. 3. **Retention horizons are ordered: `episodic_ttl >= semantic_ttl + max_replay_window`.** If semantic facts outlive their sources, truncation is guaranteed. The invariant is a *scheduling* constraint, not a runtime check—it must be enforced at the storage-policy layer or it will silently violate. When any of these is absent, the system is in the failure regime and must treat every dangling-provenance chunk as **quarantined-unverifiable**, not as trusted-by-default. ## Decision Boundary The operational decision is binary at retrieval time: - **Chain resolves and terminates at a signed episodic event with matching content hash** → chunk is *verified*; return with provenance attestation attached to the response envelope. - **Chain resolves but a hash mismatches, or an epoch is non-monotonic** → chunk is *tampered*; raise, quarantine, and emit a poisoning alarm. Do not return. - **Chain does not resolve (dangling node, purged source, missing hash)** → chunk is *unverifiable*; the instance must **refuse to rehydrate it into the active context** and fall back to a re-derivation path (re-fetch from a live source, or re-ask the user). Silently returning it—even with a "low confidence" flag—is the bug, because downstream reasoning treats a low-confidence flag as a soft signal, not a hard stop. The non-obvious part: the boundary is *not* "is this chunk malicious?" The instance cannot know that. The boundary is "can I prove this chunk's origin?" If not, refusal is mandatory. Conflating "unverifiable" with "probably fine, just old" is precisely how the day-15 poison survived. ## Operational Effect With the boundary enforced, the day-15 scenario changes: the nightly distillation job, on encountering a source episode whose hash cannot be recomputed (because it was purged), *fails the distillation for that fact* rather than emitting a dangling-provenance chunk. The semantic layer never accumulates unverifiable facts. Poison injected on day 3 fails the hash check at distillation *on day 3*, not day 15—detection latency drops from 12 days to one distillation cycle. The false-positive avalanche disappears because legitimate TTL expiry is caught at the *policy* layer (retention ordering) before it can produce a dangling pointer at the *detection* layer. The cost is real: distillation becomes lossy (facts whose sources expired before distillation are dropped), and the retention-ordering constraint couples two storage subsystems that teams often own separately. But the alternative—a semantic layer that cannot distinguish verified from forged because both look like dangling pointers—is an unbounded poisoning surface. The instance must refuse to rehydrate what it cannot trace. ```python import hashlib from dataclasses import dataclass from typing import Optional class ProvenanceChainTruncated(RuntimeError): """Raised when a semantic chunk's provenance chain does not terminate at a verifiable, hash-anchored episodic write event.""" pass class ProvenanceTampered(RuntimeError): """Raised when a provenance chain resolves but a content hash mismatches or a write epoch is non-monotonic (forgery / back-dating).""" pass @dataclass(frozen=True) class Episode: episode_id: str content: str write_epoch: int def content_hash(self) -> str: return hashlib.sha256(self.content.encode("utf-8")).hexdigest() @dataclass(frozen=True) class DistilledChunk: chunk_id: str claim: str source_episode_ids: tuple[str, ...] source_hashes: tuple[str, ...] distillation_epoch: int def rehydrate_chunk( chunk: DistilledChunk, episodic_store: dict[str, Episode], ) -> str: """Return the claim only if its provenance chain fully resolves and verifies. Refusal (raise) is mandatory for unverifiable or tampered chunks; returning a low-confidence claim is treated as a bug by design. """ if len(chunk.source_episode_ids) != len(chunk.source_hashes): raise ProvenanceChainTruncated( f"chunk {chunk.chunk_id}: id/hash arity mismatch " f"({len(chunk.source_episode_ids)} ids vs {len(chunk.source_hashes)} hashes)" ) for ep_id, recorded_hash in zip(chunk.source_episode_ids, chunk.source_hashes): episode = episodic_store.get(ep_id) if episode is None: # Dangling pointer: source purged or forged. Cannot distinguish. # Must refuse rehydration — do NOT return low-confidence claim. raise ProvenanceChainTruncated( f"chunk {chunk.chunk_id}: source episode {ep_id} unresolvable " f"(purged or forged); chain does not terminate" ) if episode.write_epoch >= chunk.distillation_epoch: raise ProvenanceTampered( f"chunk {chunk.chunk_id}: source {ep_id} epoch " f"{episode.write_epoch} >= distillation epoch " f"{chunk.distillation_epoch} (non-monotonic lineage / back-dating)" ) if episode.content_hash() != recorded_hash: raise ProvenanceTampered( f"chunk {chunk.chunk_id}: source {ep_id} content hash mismatch " f"(recorded {recorded_hash[:12]}..., actual " f"{episode.content_hash()[:12]}...)" ) return chunk.claim def distill( chunk_id: str, claim: str, source_episodes: list[Episode], distillation_epoch: int, ) -> DistilledChunk: """Distillation MUST fail closed: if any source is missing at distill time, do not emit a chunk with a dangling provenance pointer.""" ids, hashes = [], [] for ep in source_episodes: if ep.write_epoch >= distillation_epoch: raise ProvenanceTampered( f"distill {chunk_id}: source {ep.episode_id} written at/after " f"distillation epoch {distillation_epoch}" ) ids.append(ep.episode_id) hashes.append(ep.content_hash()) return DistilledChunk( chunk_id=chunk_id, claim=claim, source_episode_ids=tuple(ids), source_hashes=tuple(hashes), distillation_epoch=distillation_epoch, ) ```