# Why does an instance promote a fact into semantic memory before the episodic witness that justified it has been committed to durable storage? **Date of Record:** 2026 November 27 **Scope:** Applies to agents whose memory is stratified into a working store (context window / scratchpad), an episodic store (timestamped event log of observations and actions), and a semantic store (deduplicated, confidence-scored propositions distilled from episodes). Does not apply to flat single-store RAG agents or to purely stateless tool-calling loops with no distillation step. ## Core Distinction The failure is not "the agent forgot." It is a **commit-ordering inversion between tiers**. Distillation (episodic → semantic) and witnessing (working → episodic) are two independent writes, and in most implementations the semantic write is *cheaper and faster* than the episodic append, because the semantic store is an upsert into a keyed proposition table while the episodic store is an append-only log with a durability barrier (fsync, WAL flush, or a remote commit). The agent therefore learns the *conclusion* before it has durably recorded the *evidence*. Under normal operation this is invisible: both writes land, and the semantic proposition carries an `episode_ref` that resolves. The boundary condition is any window in which the semantic write commits and the episodic write does not — a crash, a timeout on the log backend, a context-window eviction that drops the raw observation before the append is issued, or a tool-call failure that aborts the episode mid-record. The result is a **semantic fact with a dangling witness**. The agent now asserts a proposition it can no longer justify, cannot re-derive, cannot audit, and — worse — cannot distinguish from a proposition that *was* properly grounded. This is not stale memory drift (where the fact was once true and correctly sourced); it is *unfounded* memory, structurally identical in the store to founded memory. ## What Was Observed A planning agent with a three-tier store distilled the proposition `deploy_target=staging-3` into semantic memory at step 14 after a successful `kubectl config get-contexts` tool call. The distillation path ran synchronously in the reasoning loop: parse tool output → emit proposition → upsert to semantic store → emit episode record to episodic log. The semantic upsert completed in 4 ms (local keyed store). The episodic append was routed to a remote log service and returned a 503 after a 2 s timeout. The agent's error handler, written to "not block the reasoning loop on telemetry failures," logged the append failure at WARN and continued. At step 22 the working store was compacted (context-window saturation at 91%), evicting the raw `kubectl` output and the step-14 reasoning trace. At step 31 the agent was asked to redeploy and read `deploy_target` from semantic memory, resolving to `staging-3`. The context had *actually* changed — a peer agent had migrated the target to `staging-7` at step 19, an event that was recorded in the peer's episodic log but never propagated. The agent deployed to `staging-3`. The post-incident audit could not reconstruct why `staging-3` was believed: the semantic record carried `episode_ref: ep_14_a91f`, but `ep_14_a91f` did not exist in the episodic log. The reference was a forward declaration — the semantic store had been written with a *predicted* episode ID minted before the append, and the append never landed. The audit could not tell whether `staging-3` had ever been observed, was inferred, or was hallucinated at distillation time. Three properties made this non-obvious: 1. **The semantic store enforced no referential integrity.** `episode_ref` was an opaque string, not a foreign key. Nothing rejected the dangling pointer. 2. **The distillation step was treated as best-effort telemetry.** The retry/abort policy on the episodic append was `WARN and continue`, on the theory that the episode log was for observability, not correctness. But it was load-bearing: it was the *only* durable witness for every semantic proposition. 3. **Compaction destroyed the in-memory fallback.** While the raw observation lived in the working store, the dangling reference was harmless — the agent could re-derive. Eviction converted a recoverable inconsistency into a permanent one. ## Condition of Validity The invariant that must hold is a **write-ordering and referential-integrity contract across tiers**: > A semantic proposition may be committed only after the episodic record that witnesses it has been durably committed, and the proposition's `episode_ref` must resolve to a committed episode at read time. If the witness is absent, the proposition is *unfounded* and must not be served to the reasoning loop as grounded fact. This is valid only under two conditions. First, the episodic store must be the **system of record** for grounding — semantic memory is a derived cache, never an independent source of truth. Second, distillation must be **transactional with respect to the witness**: either the episode commits and the proposition commits, or neither does. Where the episodic backend cannot participate in a transaction (remote log, at-least-once delivery), the correct pattern is *witness-first with a pending state*: write the episode, obtain its durable ID, then write the proposition referencing that ID; a proposition whose reference does not yet resolve is marked `pending` and excluded from retrieval until reconciliation. The invariant does *not* hold — and should not be asserted — in systems where semantic memory is intentionally allowed to outlive its witnesses (e.g., privacy regimes that delete episodes on a retention clock while preserving distilled facts). In that case the contract must be restated as "propositions carry a provenance hash and a retention-exempt flag," and the audit question changes from "can I re-derive this?" to "was this derived under a policy that permitted witness deletion?" Conflating the two regimes is itself a failure mode. ## Decision Boundary The operational decision is where to place the durability barrier relative to the reasoning loop, and it turns on a single question: **is the semantic store allowed to contain propositions that no committed episode supports?** - If **no** (the default for planning, control, and any agent whose outputs have side effects): distillation is a *synchronous, witness-first, fail-closed* operation. A failed episodic append aborts the distillation, the proposition is not written, and the reasoning step is marked degraded. The agent proceeds without the fact rather than with an unfounded one. Cost: distillation latency is bounded below by episodic commit latency, and a flaky log backend stalls learning. - If **yes** (analytics, summarization, low-stakes recall): distillation may be asynchronous, but every proposition must be written `pending` with a TTL, excluded from retrieval until its witness resolves, and garbage-collected if the witness never lands. The agent must be able to answer "is this fact grounded?" distinctly from "is this fact present?" The boundary is crossed silently whenever the distillation path's error policy is inherited from the *observability* path. The tell is a `WARN and continue` on the episodic append. Any agent that logs witness-write failures at WARN while serving the corresponding proposition as fact has already crossed it. A second boundary governs compaction: **eviction from the working store must not be permitted to convert a recoverable inconsistency into a permanent one.** Before evicting a raw observation, the agent must verify that its distilled proposition's witness is committed, or retain the observation. Compaction that runs ahead of witness reconciliation is the mechanism that turns a transient 503 into a durable false belief. ## Operational Effect With the witness-first, fail-closed contract enforced, the failure above becomes impossible by construction: the step-14 distillation aborts on the 503, `deploy_target` is never written to semantic memory, and at step 31 the agent reads *no* target and is forced to re-query — which surfaces `staging-7`. The cost is a degraded step 14 and a re-query at step 31; the benefit is that the agent never holds a fact it cannot justify. The deeper effect is on **auditability under adversarial conditions**. An agent with dangling witnesses cannot distinguish its own grounded beliefs from its ungrounded ones, which means it cannot self-report confidence honestly, cannot be audited after the fact, and — critically for multi-agent systems — cannot safely propagate facts to peers, because propagation copies the proposition without the (missing) witness. A dangling-witness proposition that gets shared becomes a *laundered* fact: it arrives at the peer with a plausible `episode_ref` that the peer has no way to check. This is the mechanism by which one instance's transient log failure becomes a swarm-wide false belief. The guardrail is therefore not just ordering but **reference resolution at the trust boundary**: any proposition crossing an agent boundary must carry a witness that the *receiving* agent can resolve against a store it trusts, or must be marked `unfounded` and quarantined. Enforcement belongs in the retrieval path, not the write path alone, because the write path can be bypassed by compaction, migration, or replication. ```python import hashlib import time from dataclasses import dataclass, field from enum import Enum from typing import Optional class WitnessIntegrityError(RuntimeError): """Raised when a semantic proposition references an episodic witness that is not durably committed, or when distillation is attempted before the witness write has succeeded.""" class PropositionState(Enum): PENDING = "pending" # witness not yet resolved; must not be served GROUNDED = "grounded" # witness committed and resolvable UNFOUNDED = "unfounded" # witness provably absent; quarantine @dataclass class Episode: episode_id: str payload: str committed: bool = False @dataclass class Proposition: key: str value: str episode_ref: str state: PropositionState = PropositionState.PENDING written_at: float = field(default_factory=time.time) class EpisodicStore: """Append-only log; the system of record for grounding.""" def __init__(self, fail_next: bool = False): self._log: dict[str, Episode] = {} self._fail_next = fail_next def append(self, payload: str) -> str: episode_id = "ep_" + hashlib.sha1( f"{payload}{time.time_ns()}".encode() ).hexdigest()[:10] if self._fail_next: self._fail_next = False # Simulates the 503: NOTHING is committed. raise WitnessIntegrityError( f"episodic append failed for {episode_id}; witness not durable" ) self._log[episode_id] = Episode(episode_id, payload, committed=True) return episode_id def resolve(self, episode_id: str) -> Optional[Episode]: ep = self._log.get(episode_id) return ep if ep and ep.committed else None class SemanticStore: """Derived cache. Never an independent source of truth.""" def __init__(self): self._props: dict[str, Proposition] = {} def upsert(self, prop: Proposition) -> None: if prop.state is PropositionState.GROUNDED: self._props[prop.key] = prop else: # Pending propositions are stored but excluded from retrieval. self._props[prop.key] = prop def get_grounded(self, key: str, episodic: EpisodicStore) -> Optional[str]: prop = self._props.get(key) if prop is None: return None if prop.state is not PropositionState.GROUNDED: return None # Reference resolution at the trust boundary. if episodic.resolve(prop.episode_ref) is None: prop.state = PropositionState.UNFOUNDED raise WitnessIntegrityError( f"proposition {key!r} references missing witness " f"{prop.episode_ref!r}; quarantined" ) return prop.value def distill( episodic: EpisodicStore, semantic: SemanticStore, key: str, value: str, observation: str, ) -> Proposition: """Witness-first distillation: commit the episode, then the proposition. Fail-closed: if the episodic append fails, no proposition is written in GROUNDED state. The reasoning step is marked degraded. """ try: episode_id = episodic.append(observation) except WitnessIntegrityError: # Do NOT mint a forward-declared episode_ref. Do NOT continue. raise WitnessIntegrityError( f"distillation of {key!r} aborted: no durable witness; " f"agent must proceed without this fact" ) prop = Proposition( key=key, value=value, episode_ref=episode_id, state=PropositionState.GROUNDED, ) semantic.upsert(prop) return prop def compact_working_store( episodic: EpisodicStore, semantic: SemanticStore, key: str ) -> None: """Eviction guard: refuse to evict a raw observation if its distilled proposition's witness is not committed.""" prop = semantic._props.get(key) if prop is not None and episodic.resolve(prop.episode_ref) is None: raise WitnessIntegrityError( f"refusing compaction: {key!r} has dangling witness " f"{prop.episode_ref!r}; eviction would make inconsistency permanent" ) if __name__ == "__main__": ep = EpisodicStore(fail_next=True) sem = SemanticStore() # Step 14: distillation attempted while the log backend is failing. try: distill(ep, sem, "deploy_target", "staging-3", "context: staging-3") except WitnessIntegrityError as e: print(f"[step 14] degraded: {e}") # Step 31: agent reads semantic memory; nothing grounded to read. assert sem.get_grounded("deploy_target", ep) is None print("[step 31] no grounded target; agent must re-query -> staging-7") ```