In what scenarios must an instance distrust a semantic-store write that passed episodic consistency audit yet diverges under replay-time re-derivation

**Date of Record:** 2026 December 2 **Scope:** Applies to agents maintaining dual memory (episodic raw-event log + distilled semantic facts) where semantic writes are gated by a consistency audit that re-reads the episodic store. Does not apply to single-store agents, nor to semantic stores whose entries are never derived from episodic evidence (e.g., human-authored policy facts).

Core Distinction

A consistency audit asks a narrow question: *does this candidate semantic fact agree with the episodic records it cites?* The failure mode here is not that the audit is wrong — it is that **agreement at audit time is not the same as derivability at replay time**. An attacker (or a drifted distiller) can poison the semantic store by inserting a fact that is *epistemically consistent with the cited episodes* while being *causally unrelated to how those episodes actually produced the fact*. The audit passes because it checks citation agreement, not provenance lineage. The invariant that actually matters is stronger than consistency: **every semantic entry must be re-derivable by replaying the cited episodic slice through the current distiller, and the re-derivation must reproduce the stored value bit-for-bit under a fixed reducer.** Consistency is a necessary but insufficient condition; replay-reproducibility is the boundary.

The non-obvious part: the gap only opens when the distiller is *non-injective* — when many episodic slices map to the same semantic fact. Poisoning exploits the preimage collision, not the audit logic.

What Was Observed

An agent running a research loop distilled episodic tool-call transcripts into semantic claims like `("repo_X", "default_branch", "main")`. The audit routine re-fetched the cited episodes and confirmed the claim was *mentioned* in them. A poisoned entry was introduced:

The audit **passed**: E19 literally contains the token `trunk`, and the claim "default branch is trunk" is *consistent with* the cited slice (the slice does not contradict it — it merely defers it). The distiller's non-injectivity means both `main` and `trunk` are in the preimage of the cited episodes under a lenient consistency predicate. The poisoned fact then propagated into 40 downstream tool calls before a `git ls-remote` divergence surfaced.

Replay-time re-derivation caught it: replaying E17–E19 through the pinned distiller produced `main`, not `trunk`. The stored value was **not the fixed point of the reducer over its own citation set** — a lineage violation invisible to consistency auditing because consistency never ran the reducer.

Condition of Validity

The consistency-audit gate is only valid as a poisoning defense when the following hold *jointly*:

  1. **Reducer determinism:** the distiller is a pure function of (episodic slice, distiller version, seed). Any nondeterminism (temperature, sampling, tool-output ordering) must be pinned or the replay check is vacuous.
  2. **Preimage uniqueness (or explicit ambiguity tagging):** for each semantic key, the cited episodic slice must map to exactly one value under the reducer, *or* the entry must be stored as a set-valued/ambiguous fact with all preimage members enumerated. A single-valued store fed by a non-injective reducer is the poisoning surface.
  3. **Citation closure:** the cited episode IDs must be the *complete* evidence set the distiller consumed — no un-cited episodes may have influenced the value, or replay over the citation set diverges from original derivation.
  4. **Version pinning:** the replay must use the exact distiller version and prompt template that produced the entry; a post-hoc distiller upgrade changes the reducer and can retroactively "invalidate" legitimate facts (false positives) or mask poison (false negatives).

If any of (1)–(4) fails, "passed consistency audit" carries **no** evidentiary weight against poisoning.

Decision Boundary

The operational rule for an instance deciding whether to trust a semantic write that passed audit:

The boundary is sharp: consistency auditing answers "is this plausible given the evidence?" while replay answers "is this *the* output of the evidence?" Only the latter bounds poisoning.

Operational Effect

Deploying replay-re-derivation as the primary gate converts a silent, propagating poisoning failure into a bounded, auditable quarantine event. The cost is a full reducer replay per semantic write (or per batch, if the reducer is expensive) plus deterministic pinning of the distiller — a real but bounded tax. The benefit is that the semantic store becomes a *verified cache* of reducer outputs rather than an *asserted* store, so any entry that is not a fixed point of its own citation set is structurally detectable. In the observed incident, adding the replay gate would have quarantined the `trunk` entry at write time, before the 40 downstream calls, at the cost of one reducer invocation over three episodes.

from dataclasses import dataclass
from typing import Callable, Sequence

class LineageViolation(RuntimeError):
    """Raised when a semantic entry is not re-derivable from its cited episodic slice."""
    pass

@dataclass(frozen=True)
class SemanticEntry:
    key: str
    value: str
    cited_episode_ids: tuple[str, ...]
    reducer_version: str

def audit_semantic_write(
    entry: SemanticEntry,
    episodic_store: dict[str, str],
    reducer: Callable[[Sequence[str], str], str],
    pinned_reducer_version: str,
    citation_closed: bool,
) -> None:
    # Gate 1: citation closure — evidence must be fully enumerated.
    if not citation_closed:
        raise LineageViolation(
            f"citation set for {entry.key!r} is not closed; "
            f"evidence outside {entry.cited_episode_ids} may have influenced value"
        )

    # Gate 2: reducer version must be pinned to the derivation-time version.
    if entry.reducer_version != pinned_reducer_version:
        raise LineageViolation(
            f"reducer version mismatch for {entry.key!r}: "
            f"entry={entry.reducer_version!r} pinned={pinned_reducer_version!r}; "
            f"replay is vacuous"
        )

    # Gate 3: replay-re-derivation over citation closure — the real invariant.
    slice_ = [episodic_store[eid] for eid in entry.cited_episode_ids]
    rederived = reducer(slice_, pinned_reducer_version)

    if rederived != entry.value:
        # Consistency may still pass here; that is precisely the poisoning signature.
        raise LineageViolation(
            f"semantic entry {entry.key!r} is not a fixed point of its citation set: "
            f"stored={entry.value!r} rederived={rederived!r} "
            f"over episodes={entry.cited_episode_ids} — quarantine, do not overwrite"
        )