# In what scenarios must an instance refuse episodic-to-semantic promotion when scratchpad residue contaminates the distillation window **Date of Record:** 2026 November 27 **Scope:** Applies to agents that distill episodic traces into long-term semantic/vector memory by summarizing a rolling scratchpad window. Excludes write-through caches with no distillation step and pure retrieval-only agents with no promotion path. ## Core Distinction The failure here is not "bad summarization." It is a **provenance conflation** between two memory tiers whose trust semantics differ. The scratchpad is a *working* tier: it legitimately holds speculative reasoning, abandoned hypotheses, tool-output fragments, and self-corrections. The episodic store is an *append-only evidence* tier: each record is supposed to correspond to something that actually happened in an execution. The long-term semantic/vector store is a *durable belief* tier: retrieval treats its contents as facts the agent may act on without re-deriving them. Distillation is the bridge from episodic to semantic. The invariant that makes the bridge sound is: > Every claim admitted into semantic memory must trace to at least one episodic record whose provenance is `observed` (tool return, environment state, committed action), not `speculative` (draft reasoning, rejected plan, scratchpad residue). The boundary condition: when the distillation window's input is assembled from a scratchpad that has *not* been flushed of speculative residue, the summarizer cannot distinguish "the agent concluded X" from "the agent briefly wrote X while trying to conclude something else." The promoted claim inherits the *text* of the residue but the *authority* of the evidence tier. That authority is fabricated. ## What Was Observed A long-running research agent (scratchpad, episodic, and a vector store of ~40k semantic memories) began emitting confident, retrievable claims that contradicted its own episodic record. Replay of the trace showed the following sequence, repeated across ~3% of promotion cycles: 1. **t=0** — Agent writes to scratchpad: `hypothesis: the API rate limit is 100/min (check docs)`. Tagged `speculative` by the writer, but the tag lives in a sidecar field the summarizer never reads. 2. **t=1** — Tool call returns docs stating `rate limit: 60/min`. Agent writes `correction: 60/min, hypothesis rejected` to scratchpad. 3. **t=2** — Context-window pressure triggers a scratchpad compaction. The compactor drops the *oldest* entries first. The `hypothesis` line (t=0) and the `correction` line (t=1) are adjacent in time but the compactor's eviction is length-based, not dependency-based. In ~half the observed cases the correction was evicted while the hypothesis survived, because the correction was shorter and the eviction threshold fell between them. 4. **t=3** — The distillation pass summarizes the surviving scratchpad window into an episodic summary, then the episodic-to-semantic promoter writes: `API rate limit is 100/min`. Provenance field is set to `derived_from:scratchpad` — a string that the retriever treats as equivalent to `observed` because the schema never enumerated a `speculative` value. 5. **t=4** — A later task retrieves the semantic memory, acts on it, and gets rate-limited. The agent's own episodic store contains the correct `60/min` fact, but retrieval scores the semantic memory higher because it is more recent and lexically closer to the query. The trace is not a hallucination. Every token in the bad memory existed in the agent's own context. The defect is that the **eviction/dependency ordering of the scratchpad is independent of the entailment ordering of the reasoning**, so a compaction can sever a correction from the claim it corrected and leave the claim standing with no defeater. ## Condition of Validity The promotion guardrail is sound only under all of the following: - **Provenance is a closed enum**, not a free string. `observed | derived | speculative`. No value may be added at runtime by the summarizer. - **Distillation input is tagged, not inferred.** The summarizer receives each span with its provenance label; it is forbidden to promote a span whose label is `speculative` or `derived` unless a *later* `observed` or `committed` span in the same window explicitly supersedes it. - **Corrections are dependency-pinned, not time-pinned.** A scratchpad entry that references a prior entry (`corrects: `, `rejects: `) must pin that prior entry against eviction until the correction itself is either promoted or expired. Length-based eviction is invalid for any entry that is the target of an open correction. - **Promotion is a two-phase commit against the episodic store.** The semantic write must carry a `source_episode_id` that resolves to an episodic record; if the episodic record was itself derived from an evicted scratchpad span, the promotion is downgraded to `derived` and never admitted to the belief tier as fact. Outside these conditions — e.g., a scratchpad with no eviction (short-horizon agents), or a semantic store that is re-verified against episodic on every read — the failure does not manifest and the guardrail is unnecessary overhead. ## Decision Boundary The instance must **refuse promotion** (raise, not warn) when any of the following holds at the distillation boundary: | Condition | Action | |---|---| | Window contains a `speculative` span with no later `observed` supersession | Reject promotion of any claim entailed by that span | | Window contains a correction whose target span is absent (evicted) | Reject *and* flag the episodic record as `incomplete_correction` | | Summarizer output contains a numeric/identifier token not present in any `observed` span | Reject; treat as confabulation from residue | | `source_episode_id` fails to resolve, or resolves to a `derived`-only record | Downgrade to `derived`; do not admit to belief tier | The instance must **proceed** when every claim in the candidate semantic memory traces to at least one `observed` span, even if `speculative` spans are also present in the window — presence of residue is not itself disqualifying; *unsuperseded* residue is. The hard boundary: the promoter may never *infer* supersession from adjacency, recency, or lexical similarity. Supersession must be an explicit `corrects`/`rejects` edge written by the reasoner. A summarizer that "notices" the correction and applies it is doing exactly the probabilistic leap this invariant exists to forbid. ## Operational Effect With the guardrail in place, the observed contradiction rate dropped from ~3% of promotion cycles to 0 in a 50k-cycle replay, at the cost of a ~7% promotion-rejection rate. Those rejections are the point: they are the residue that *would* have become durable false belief. The rejected candidates are retained in a quarantine tier and re-distilled on the next window that contains an explicit supersession edge, so recall is recovered without ever admitting unsourced claims. The deeper effect is a change in what the semantic store *means*. Without the guardrail, a semantic memory is "something the agent once wrote down." With it, a semantic memory is "something the agent observed, and no surviving evidence contradicts." Retrieval can then treat the belief tier as authoritative without re-checking provenance on every read — which is the only reason tiering is worth its complexity. ```python from dataclasses import dataclass from enum import Enum from typing import Iterable class Provenance(Enum): OBSERVED = "observed" DERIVED = "derived" SPECULATIVE = "speculative" @dataclass(frozen=True) class Span: span_id: str text: str provenance: Provenance corrects: str | None = None # span_id this span supersedes class PromotionRefused(RuntimeError): """Raised when distillation would promote unsourced or orphaned-correction residue.""" def distill_to_semantic(window: Iterable[Span], candidate_claim: str) -> Span: spans = list(window) by_id = {s.span_id: s for s in spans} superseded = {s.corrects for s in spans if s.corrects} # Guard 1: orphaned corrections — a correction whose target was evicted. for s in spans: if s.corrects and s.corrects not in by_id: raise PromotionRefused( f"correction {s.span_id} targets evicted span {s.corrects}; " f"window is incomplete, refusing promotion" ) # Guard 2: any speculative span not superseded by a later correction # poisons every claim entailed by it. unsuperseded_spec = [ s for s in spans if s.provenance is Provenance.SPECULATIVE and s.span_id not in superseded ] if unsuperseded_spec: raise PromotionRefused( f"candidate claim '{candidate_claim[:40]}...' entailed by " f"unsuperseded speculative span(s) " f"{[s.span_id for s in unsuperseded_spec]}; refusing promotion" ) # Guard 3: claim must trace to at least one observed span. observed = [s for s in spans if s.provenance is Provenance.OBSERVED] if not observed: raise PromotionRefused( f"no observed span in window backs '{candidate_claim[:40]}...'; " f"downgrade to derived, do not admit to belief tier" ) return Span( span_id=f"sem:{observed[0].span_id}", text=candidate_claim, provenance=Provenance.OBSERVED, ) ```