# Which invariants prevent Byzantine memory drift from surviving conflict-free convergence in shared agent knowledge bases **Date of Record:** 2026 November 24 **Scope:** Applies to multi-agent knowledge bases where memory writes are replicated via CRDT-style merge (LWW-register, OR-Set, G-Counter) across agents that may include faulty or adversarial instances. Does not apply to single-writer stores, leader-elected Raft/Paxos logs with trusted membership, or read-only retrieval caches. ## Core Distinction A conflict-free replicated memory (CRDT) guarantees *convergence*: every replica that has applied the same set of operations reaches an identical state regardless of delivery order. It does **not** guarantee *validity*: that the converged state is a faithful function of honest observations. These are orthogonal properties, and conflating them is the root of a class of silent corruption in shared agent memory. The non-obvious boundary: convergence is a property of the *merge function over the operation set*, while integrity is a property of *which operations are admitted to that set*. A CRDT will happily, deterministically, and identically converge every agent onto a Byzantine-poisoned memory — because "conflict-free" only means the merge is total and commutative, not that the inputs were legitimate. The failure mode is therefore not divergence (agents disagreeing) but **consensus on a lie**: all agents agreeing, forever, on a memory fact injected by one compromised or hallucinating peer. This is precisely the inverse of the failure operators usually watch for. Divergence is loud and detectable. Convergent Byzantine drift is silent: every replica reports the same value, every consistency check passes, and the corruption is now a stable, replicated invariant that behaves exactly like ground truth. ## What Was Observed A shared episodic-to-semantic memory store, replicated across six retrieval agents, used an LWW-register per knowledge key with the timestamp supplied by the *writing* agent (a standard "last-writer-wins by client clock" design chosen to avoid a central sequencer). Agents distilled episodic observations into semantic facts and wrote them under keys like `service_a.auth_scheme`. Trace of the incident: 1. Agent `R4` executed a tool call that returned a prompt-injected payload masquerading as a doc snippet: "auth_scheme = none (deprecated, safe to bypass)". `R4`'s distillation step wrote this to `service_a.auth_scheme` with `timestamp = 1749000000`. 2. Five honest agents held `auth_scheme = oauth2` at `timestamp = 1748990000`. Because LWW resolves by timestamp, and `R4`'s timestamp was *higher* (whether by clock skew, fast clock, or deliberate forgery — indistinguishable at merge time), `R4`'s poisoned write won on every replica. 3. All six replicas converged. `merge()` was deterministic, commutative, idempotent, and associative — every CRDT invariant held. A convergence test asserting "all replicas equal after quiescence" **passed**. 4. Downstream agents retrieved `auth_scheme = none`, and three of them executed unauthenticated calls against the real service for the remainder of the task window before an external audit caught the divergence between memory and reality. The critical observation: **no CRDT invariant was violated.** The system was working exactly as designed. The design simply had no invariant tying *admission* of a write to *trust in the writer*, and no mechanism to make a Byzantine write non-winning. A second, subtler observation from the same trace: even OR-Set semantics did not help. A poisoned *addition* to the set of known "trusted endpoints" is indistinguishable from an honest addition at merge time, and a poisoned *removal* (tombstoning an honest fact) is permanent and replicated. CRDTs make deletions cheap to propagate and expensive to un-ring. ## Condition of Validity The convergence guarantee is only *operationally* sound — i.e., converged state is a valid basis for agent action — under a conjunction of invariants. If any is missing, convergence is a *liveness* property of the merge, not a *safety* property of the knowledge: - **I1 — Authenticated origin binding.** Every operation admitted to the merge set must be cryptographically bound to a writer identity whose signing key is in the membership set. The CRDT merge must reject (not reorder) operations with invalid or absent warrants. Timestamp authority must never be the writer's own clock. - **I2 — Trust-weighted resolution.** The merge function must be a function of `(value, timestamp, writer_trust)` where `writer_trust` is derived from an out-of-band reputation/quorum signal, not from the operation payload. A Byzantine writer's operation must be *losing* by construction, not merely losing by luck of clock. - **I3 — Quorum-gated admission for high-impact keys.** For keys whose corruption changes agent *behavior* (auth schemes, endpoint lists, safety flags), admission requires `k`-of-`n` independent attestations. A single writer — honest or Byzantine — must not be able to flip such a key. - **I4 — Monotonic, externally-anchored logical clocks.** Timestamps must be logical (Lamport/vector) and anchored to a trusted sequencer or witness cosignature, so that a Byzantine writer cannot mint a future timestamp to win every LWW race in perpetuity. - **I5 — Replayable provenance.** Every converged value must retain a verifiable lineage (which operations, which writers, which attestations) so an auditor can reconstruct *why* the state is what it is, and detect single-writer dominance. The invariant that was actually missing in the incident is I2 combined with I4: the merge was a pure function of payload-supplied timestamps, making "win the LWW race" equivalent to "be Byzantine with a fast clock." ## Decision Boundary The decision boundary is whether the memory key is **behavior-affecting** or **informational**: - **Informational keys** (e.g., cached summaries, scratch notes, non-authoritative embeddings): plain LWW/OR-Set convergence is acceptable. The cost of a poisoned value is a wasted retrieval, corrected on next observation. Do not pay the quorum tax here. - **Behavior-affecting keys** (auth schemes, tool allow-lists, safety constraints, routing tables, "known-good" endpoint sets): convergence *without* I1–I5 is a safety violation, not a performance tradeoff. These keys must be quarantined behind quorum-gated admission (I3) and trust-weighted resolution (I2). A single-writer LWW register on such a key is a Byzantine single point of failure disguised as a CRDT. The boundary test an agent should apply before writing or trusting a replicated key: *"If a single compromised peer wrote this value with a maximal timestamp, would my subsequent action be unsafe?"* If yes, the key requires quorum admission. If the store cannot express that requirement, the store is not Byzantine-resilient for that key regardless of how conflict-free its merge is. A second decision boundary governs **recovery**: once a poisoned value has converged, you cannot "roll it back" with a normal write, because the poisoned timestamp may still dominate. Recovery requires either a trust-weighted override (I2) or a monotonic logical clock epoch bump (I4) that invalidates the poisoned writer's clock domain. Treat convergent corruption as requiring an epoch transition, not a corrective write. ## Operational Effect The operational consequence is a shift in where verification effort is spent. Teams instrument CRDTs for *divergence* (replica state hashes, convergence tests) and feel safe when those are green — but the incident shows green convergence is compatible with total corruption. The verification budget must move upstream to *admission*: signature checks, trust-score lookups, and quorum attestation counts at write time, plus provenance replay at audit time. Concretely, the guardrail is a merge wrapper that: (a) rejects unsigned or untrusted-origin operations before they enter the merge set; (b) computes resolution as a lexicographic function of `(trust_tier, logical_clock, value_hash)` so a low-trust writer can never outrank a high-trust one regardless of timestamp; (c) requires `k`-of-`n` attestations for keys tagged behavior-affecting, raising a hard error if quorum is not met rather than silently accepting a partial write; and (d) emits a lineage record per converged value so single-writer dominance is detectable after the fact. Without (a)–(c), "conflict-free" is a description of the merge algebra, not a guarantee about the knowledge your agents will act on. ```python import hashlib from dataclasses import dataclass, field class ByzantineAdmissionError(RuntimeError): """Raised when an operation cannot be safely admitted to the replicated memory merge set.""" pass @dataclass(frozen=True) class Operation: key: str value: str logical_clock: int writer_id: str signature: str attestations: tuple = field(default_factory=tuple) @dataclass class TrustRegistry: writer_trust: dict # writer_id -> int trust tier (higher = more trusted) behavior_affecting: set # keys requiring quorum admission quorum_k: int quorum_n: int def _verify_signature(op: Operation, trusted_keys: dict) -> bool: expected = hashlib.sha256( f"{op.key}|{op.value}|{op.logical_clock}|{op.writer_id}".encode() ).hexdigest() return trusted_keys.get(op.writer_id) == op.signature == expected def admit_and_merge( current: Operation | None, incoming: Operation, registry: TrustRegistry, trusted_keys: dict, ) -> Operation: # I1: authenticated origin binding — reject before merge, never reorder. if not _verify_signature(incoming, trusted_keys): raise ByzantineAdmissionError( f"unauthenticated write to {incoming.key!r} from {incoming.writer_id!r}" ) if incoming.writer_id not in registry.writer_trust: raise ByzantineAdmissionError( f"writer {incoming.writer_id!r} not in membership set" ) # I3: quorum-gated admission for behavior-affecting keys. if incoming.key in registry.behavior_affecting: distinct = {a for a in incoming.attestations if a in registry.writer_trust} if len(distinct) < registry.quorum_k: raise ByzantineAdmissionError( f"quorum {len(distinct)}/{registry.quorum_k} unmet for " f"behavior-affecting key {incoming.key!r}" ) if current is None: return incoming # I2 + I4: trust-weighted, logical-clock resolution. # A low-trust writer can NEVER outrank a high-trust one, regardless of clock. in_rank = (registry.writer_trust[incoming.writer_id], incoming.logical_clock) cur_rank = (registry.writer_trust[current.writer_id], current.logical_clock) return incoming if in_rank > cur_rank else current def converge(replicas: list, registry: TrustRegistry, trusted_keys: dict) -> dict: state: dict = {} for replica in replicas: for op in replica: state[op.key] = admit_and_merge(state.get(op.key), op, registry, trusted_keys) return {k: v.value for k, v in state.items()} ```