# Under what conditions must an instance reject a consensus-ordered shared memory write that has already been committed by a quorum **Date of Record:** 2026 November 27 **Scope:** Applies to multi-agent systems where several LLM instances read and write a shared, consensus-replicated memory store (Raft/Paxos-ordered log, CRDT-backed document, or vector-indexed episodic store with a total-order commit log) and where reconciliation is claimed to be "conflict-free." Does not apply to single-writer stores, to stateless tool-call agents, or to read-only retrieval caches with no commit log. ## Core Distinction A consensus-ordered store gives you **total order**, not **semantic validity**. The two are routinely conflated. A quorum committing entry `E` at log index `i` proves that a majority of replicas agree on the *position* of `E` and its *bytes*. It proves nothing about whether `E` is a legal transition of the application-level state that the agents believe they are maintaining. The boundary condition is this: **a committed write can be durable, quorum-acknowledged, totally ordered, and still semantically illegal for the specific instance that must now apply it.** The failure mode is not split-brain, not log divergence, not lost writes. It is *committed-but-inapplicable*: an entry that survives consensus but violates an invariant the applying instance is obligated to enforce — an epoch/version precondition, an authorization warrant, a schema generation, or a causal dependency on an entry the applying instance never observed. CRDT framing ("conflict-free") makes this worse, not better, because merge functions are designed to be **total** — they accept any pair of states and produce a state. A total merge function never raises. It silently folds an inapplicable write into local state, and the divergence surfaces later as corrupted shared memory rather than as a rejected message. ## What Was Observed A swarm of planner/executor/auditor instances shared an episodic memory store keyed by `(task_id, fact_id)` with a last-writer-wins register per key, ordered through a 5-replica Raft group. Executors wrote facts; auditors wrote `retracted: true` tombstones; planners read the reconciled view. The observed trace: 1. Executor `X` (epoch 7) reads `fact_id=F1` at `version=3`, decides to update it, and submits `write(F1, value=v', base_version=3, epoch=7)`. 2. The leader accepts and replicates. Quorum commits at index `i=4412`. `X` is acknowledged. 3. Meanwhile the auditor `A` had independently committed `retract(F1)` at index `i=4409` — *earlier in the log* — because it observed a contradiction in `F1`'s provenance. 4. Replica `R3` had been partitioned and rejoins. It replays `4409` then `4412`. Its LWW register resolves `4412` (higher index) over `4409`, so `F1` exists with `value=v'`. The retraction is shadowed. 5. Planner `P` reads the reconciled view, sees `F1=v'` with no tombstone, and plans on a fact the auditor already determined to be false. The reconciliation was "conflict-free" by construction: LWW is a valid semilattice join, commutative and idempotent. It produced a single consistent value across all replicas. **And it was wrong**, because the register's merge function had no representation for "this key was retracted and must not be resurrected by a later-ordered write that was *causally ignorant* of the retraction." The precise defect: `X`'s write carried `base_version=3` but the store applied LWW on commit index, not on `base_version`. The precondition `base_version=3` was recorded in the entry payload but never enforced at apply time. A write whose `base_version` no longer matches the register's current version is a **stale-base write** — it was computed against a state that no longer exists — and it must be rejected at apply, not silently ordered. ## Condition of Validity The invariant that must hold for "commit implies apply" to be sound: > For every committed entry `E` on key `k`, applying `E` is permitted **iff** `E.base_version == current_version(k)` **or** `E` is a merge-commutative operation (CRDT op) whose type-theoretic join is defined for all reachable states of `k`. Two corollaries that the swarm violated: - **Ordering is not causality.** Raft index order is a total order chosen by the leader; it is not a happens-before relation over the agents' reads. `X` read at `version=3` before `4409` was visible to it, so `4412` is *causally concurrent* with `4409` even though it is *log-later*. LWW resolves the log order and destroys the causal information. - **A total merge function is a liability at the application layer.** LWW, G-Counter, and OR-Set joins are total over their *carrier sets*. The application state (a fact with provenance, an agent's belief, a plan step) is not in that carrier set. Mapping application state into a CRDT and back is lossy, and the loss is exactly the invariant you needed. The guardrail is a **version-preconditioned apply with a causal-dependency check**: the store must carry, per entry, the `base_version` (or a vector clock / dotted version vector) it was computed against, and the apply step must reject entries whose base no longer matches — *even though they are committed*. Rejection does not un-commit the entry; it quarantines it and forces the writer to re-read and re-submit. This converts a silent semantic corruption into an explicit, retryable conflict, which is what the agents' reasoning loops can actually handle. ## Decision Boundary An instance must **reject-and-quarantine** a committed write (rather than apply it) when all of the following hold: - The entry is a **state-mutating** op on a key the instance is responsible for materializing (not a pure read, not an idempotent set-to-absolute-value). - The entry carries a `base_version` (or causal context) that **does not match** the instance's current materialized version for that key. - The entry is **not** a member of a CRDT type whose join is provably defined for the current state (i.e., it is a register write, a conditional update, a tombstone, or a schema-bearing mutation). An instance must **apply** (not reject) when: - The entry is a genuine CRDT op of the correct type (e.g., an OR-Set add, a PN-Counter increment) — these are designed to be applied out of causal order. - The entry's base matches, or the store's apply semantics are explicitly *last-writer-wins-by-design* and the application has accepted the resurrection risk (e.g., ephemeral presence heartbeats, not facts). - The entry is a tombstone/retraction that is **causally later** than the write it shadows (retraction must dominate resurrection; if the store cannot express this, it is not fit for shared belief state). The trap: teams reach for LWW because it is "conflict-free," then discover that the conflicts it resolves are exactly the ones that mattered. Conflict-free reconciliation is sound only for state whose semantics are *already* a join-semilattice. Agent beliefs, plans, and provenance are not. ## Operational Effect When the version-preconditioned apply is enforced: - Stale-base writes are quarantined, the writer is notified with the current version, and the executor's reasoning loop re-reads and re-plans. Latency increases by one round-trip per detected conflict; correctness increases from "eventually consistent but semantically wrong" to "consistent and causally sound." - The auditor's retraction at `4409` is no longer shadowed by `4412`; the planner sees `F1` retracted and does not plan on it. The failure at step 5 of the trace does not occur. - The store's commit log and its materialized state can diverge in a *bounded, observable* way: quarantined entries are a first-class queue, not a silent fold. This is the operational invariant — **the number of committed-but-unapplied entries is a monitored metric, and a nonzero, growing value is a signal that writers are not re-reading before writing** (i.e., the swarm's read-before-write discipline has degraded). The cost is that "conflict-free" is no longer true at the application layer, and that is the point: the conflicts are real, and the system must surface them to the agents that can resolve them, rather than let a total merge function paper over a semantic contradiction with a durable, quorum-acknowledged, wrong answer. ```python from dataclasses import dataclass class CommittedButInapplicableError(RuntimeError): """Raised when a quorum-committed entry cannot be legally applied to the local materialized state because its causal base no longer matches.""" pass @dataclass(frozen=True) class Entry: key: str value: object base_version: int commit_index: int is_crdt_op: bool = False is_retraction: bool = False class SharedMemoryMaterializer: def __init__(self) -> None: # key -> (version, value, retracted) self._state: dict[str, tuple[int, object, bool]] = {} self.quarantine: list[Entry] = [] def apply(self, entry: Entry) -> None: current = self._state.get(entry.key) current_version = current[0] if current else 0 current_retracted = current[2] if current else False # CRDT ops are join-defined for all reachable states: always apply. if entry.is_crdt_op: self._state[entry.key] = ( current_version + 1, self._join(current[1] if current else None, entry.value), current_retracted, ) return # A retraction must dominate any earlier-versioned value; applying it # is only legal if we have actually materialized the version it targets. if entry.is_retraction: if entry.base_version != current_version: self.quarantine.append(entry) raise CommittedButInapplicableError( f"retraction of {entry.key}@v{entry.base_version} " f"committed at index {entry.commit_index} cannot apply: " f"local version is v{current_version}" ) self._state[entry.key] = (current_version + 1, current[1], True) return # Stale-base register write: committed, ordered, but computed against a # state that no longer exists. Reject and quarantine; do NOT LWW-fold. if entry.base_version != current_version: self.quarantine.append(entry) raise CommittedButInapplicableError( f"stale-base write to {entry.key} (base v{entry.base_version}, " f"local v{current_version}) committed at index " f"{entry.commit_index}; quarantine and force re-read" ) if current_retracted: self.quarantine.append(entry) raise CommittedButInapplicableError( f"write to retracted key {entry.key} at index " f"{entry.commit_index}; resurrection requires explicit un-retract" ) self._state[entry.key] = (current_version + 1, entry.value, False) @staticmethod def _join(a: object, b: object) -> object: # Placeholder for the CRDT's total join; must be defined for all # reachable carrier values of the specific CRDT type. return b if a is None else a ```