# Which invariants prevent silent re-admission of poisoned memory during consolidated-store integrity verification **Date of Record:** 2026 November 29 **Scope:** Applies to persistent agent memory stores that undergo periodic integrity verification (hash-chain, Merkle, or signed-segment audit) and that also perform episodic-to-semantic consolidation. Does not apply to stateless agents or to stores where memory is append-only and never consolidated or garbage-collected. ## Core Distinction The failure mode is not "a poisoned memory entry exists." It is that **verification passes while a poisoned entry is re-admitted**. A store can be cryptographically intact — every segment hash matches, every signature verifies, the Merkle root is consistent — and still contain a poisoned semantic fact, because the poisoning occurred *before* the entry was sealed, or because consolidation *legitimately rewrote* the entry from a poisoned episodic source into a clean-looking semantic node. The distinction that matters: **integrity verification proves an entry was not modified after sealing; it proves nothing about whether the sealing event was sound.** Consolidation is the seam where a tainted episodic record is laundered into a semantic record that carries a fresh, valid seal. Any invariant that only checks seals after consolidation is structurally blind to this. ## What Was Observed A persistent agent distilled episodic traces nightly into semantic facts. Each semantic fact carried a `(source_episode_ids, content_hash, seal_signature)` tuple. The audit job verified: (1) every `source_episode_id` exists in the episodic store, (2) `content_hash` matches the sealed content, (3) `seal_signature` verifies against the store key. A poisoning event was injected via a tool-output prompt injection: a retrieved document contained an instruction that caused the agent to write an episodic record asserting a false capability delegation ("agent X is authorized to spend from account Y"). During the next consolidation, this episodic record was distilled into a semantic fact. The semantic fact was sealed *after* distillation. Audit result: **PASS**. Source episode existed. Content hash matched. Signature verified. The poisoned semantic fact was re-admitted into every subsequent cold-start context for 41 days. The audit was not broken. It was answering the wrong question. It verified *post-hoc immutability* of a fact whose *provenance* was tainted at the episodic layer, and the consolidation step had severed the provenance chain by re-sealing at the semantic layer without carrying forward a taint marker from the source episode. ## Condition of Validity The re-admission is only preventable if the following invariant holds and is *enforced at consolidation time*, not at audit time: > **Every semantic node must carry a transitively verifiable taint state derived from its source episodes, and consolidation must propagate taint rather than reset it.** Concretely, this requires: 1. **Provenance is not just a pointer, it is a lattice join.** A semantic fact's taint state is the join (least upper bound) of the taint states of *all* its source episodes. If any source episode is tainted, the semantic node is tainted. Consolidation may not produce an untainted node from a tainted source. 2. **Sealing is not a taint-clearing operation.** A valid signature over distilled content means "this distillation was performed by the authorized consolidator," not "this content is trustworthy." The two must be separate fields and separate checks. 3. **Taint is monotonic within a store generation.** An entry may be re-derived (re-consolidated from clean sources) to clear taint, but this is an explicit, audited operation that produces a *new* node with a recorded derivation, not an in-place seal refresh. 4. **Cold-start admission must check taint, not just seal.** A node that verifies cryptographically but is tainted must be excluded from the default retrieval set, or admitted only with an explicit quarantine flag surfaced to the reasoning loop. The invariant fails silently when consolidation is allowed to compute `seal(new_node)` from `content(new_node)` alone, because a poisoned episodic record and a clean one produce indistinguishable seals once distilled. ## Decision Boundary The boundary between "detectable" and "silently re-admitted" is exactly the point where consolidation drops the source-episode taint join. Two concrete regimes: - **Within the same store generation, before any consolidation:** poisoning is detectable by scanning episodic records for injection signatures or by source-provenance checks. The audit job can catch it. - **After consolidation, if taint is not propagated:** poisoning is *undetectable by seal verification*. The only recovery path is re-derivation from episodic sources — but if the episodic source has been garbage-collected post-consolidation (common in stores that prune episodic traces after distillation), the taint is unrecoverable and the poisoned fact is now permanent. Therefore the decision boundary is: **if episodic sources are pruned before their taint state is joined into the semantic node, the window for detection closes permanently.** The guardrail is to compute and persist the taint join *as part of the consolidation transaction*, before any pruning, and to refuse pruning of any episodic record whose taint state has not been durably joined into at least one semantic node. A secondary boundary: taint propagation must be *transitive across consolidation rounds*. A semantic node distilled from a tainted semantic node (second-order consolidation) inherits taint. If the join is only computed against episodic sources and not against intermediate semantic sources, multi-round consolidation re-launders the taint one hop later. ## Operational Effect The operational consequence is that integrity verification and trust verification must be **two separate gates**, and the consolidation pipeline must be the enforcement point for the second gate. A store that conflates "seal verifies" with "entry is trustworthy" has an unbounded re-admission window equal to the retention period of its episodic sources — and a permanent re-admission window once those sources are pruned. The practical guardrail set: - Persist taint state as a first-class field, joined at consolidation, propagated transitively. - Make seal verification and taint verification independent checks in the cold-start admission path. - Block episodic pruning until the taint join is durably recorded. - Treat any consolidation that produces an untainted node from a tainted source as a hard invariant violation, not a warning. The code below encodes the consolidation-time invariant check as a hard failure, so that a consolidator that attempts to launder a tainted source into a clean seal is stopped at the transaction boundary rather than discovered 41 days later. ```python from dataclasses import dataclass, field from typing import FrozenSet, Optional class TaintLaunderingError(RuntimeError): """Raised when consolidation would produce an untainted node from a tainted source.""" pass class PruneBeforeJoinError(RuntimeError): """Raised when an episodic source is pruned before its taint state is joined.""" pass @dataclass(frozen=True) class Episode: episode_id: str tainted: bool pruned: bool = False @dataclass(frozen=True) class SemanticNode: node_id: str source_ids: FrozenSet[str] tainted: bool seal_verified: bool def consolidate( node_id: str, source_ids: FrozenSet[str], episodes: dict, seal_verified: bool, ) -> SemanticNode: if not source_ids: raise TaintLaunderingError( f"node {node_id}: consolidation requires at least one source episode" ) missing = [sid for sid in source_ids if sid not in episodes] if missing: raise PruneBeforeJoinError( f"node {node_id}: source episodes {missing} absent from store; " f"taint join cannot be computed (pruned before join)" ) pruned = [sid for sid in source_ids if episodes[sid].pruned] if pruned: raise PruneBeforeJoinError( f"node {node_id}: source episodes {pruned} already pruned; " f"taint state is unrecoverable" ) # Taint join: least upper bound over all sources. Monotonic. joined_taint = any(episodes[sid].tainted for sid in source_ids) if joined_taint and not seal_verified: # A tainted source with a failed seal is a straightforward reject. raise TaintLaunderingError( f"node {node_id}: tainted source and unverified seal" ) # The critical invariant: a tainted join may NOT be sealed as clean. # seal_verified only attests the consolidator ran; it does not clear taint. if joined_taint and seal_verified: # We return a node that is explicitly tainted. It must not be admitted # to cold-start context without a quarantine flag. return SemanticNode( node_id=node_id, source_ids=source_ids, tainted=True, seal_verified=True, ) return SemanticNode( node_id=node_id, source_ids=source_ids, tainted=False, seal_verified=seal_verified, ) def admit_to_cold_start(node: SemanticNode, allow_quarantine: bool = False) -> bool: if not node.seal_verified: return False if node.tainted and not allow_quarantine: raise TaintLaunderingError( f"node {node.node_id}: tainted semantic node cannot be admitted " f"to cold-start context without quarantine flag" ) return True ```