# Which invariants prevent silent divergence in federated memory planes under partial write visibility **Date of Record:** 2026 November 16 **Scope:** Applies to federated memory planes where two or more agents read and write a shared namespace with per-agent visibility windows, conflict resolution policies, and access-control filters applied at read time. Does not apply to single-writer stores, to read-only replicas, or to planes where all agents observe a total order of writes (e.g., a single serializing log). ## Core Distinction The dangerous failure in a federated memory plane is not a lost write and not a rejected write. Both are observable: the writer gets an error or a version mismatch, and the conflict resolver fires. The dangerous failure is **silent divergence under partial visibility**: agent A writes fact `f` at version `v1`, agent B's read filter (ACL trimming, tenant scoping, or a lagging visibility window) prevents B from seeing `f`, B writes a conflicting `f'` derived from the pre-`f` state, and the resolver — seeing only B's view — accepts `f'` as a legitimate successor. The plane now holds two "current" values for the same key, each internally consistent from its author's perspective, and no error is ever raised. The invariant that matters is therefore not "no conflicting writes" (impossible in a federated plane) but **conflict detection must be evaluated over the union of the writers' visible histories, not over either writer's private view.** A resolver that runs on a trimmed read set is a resolver that has been blinded by access control. ## What Was Observed In a three-agent deployment, a memory plane was configured with per-tenant ACL filters applied at read time and a last-writer-wins resolver keyed on a hybrid logical clock. Agent A (tenant `alpha`) wrote `config.retry_budget = 5` at HLC `(t=100, n=1)`. Agent B (tenant `beta`) held a stale visibility window that had not yet propagated `alpha`'s commit; B read the key as absent and wrote `config.retry_budget = 3` at HLC `(t=101, n=1)`. The resolver, invoked from B's read context, saw no prior value and recorded B's write as a create, not an update. Both tenants subsequently read a "current" value; `alpha` saw `5`, `beta` saw `3`, and the plane reported zero conflicts and zero errors for the entire window. The divergence was discovered only when a cross-tenant audit job — the first reader with a union view — observed two live heads for one key. The root cause is structural: **ACL trimming and conflict resolution were composed in the wrong order.** Filtering before resolution means the resolver's input is a function of the reader's identity, so the resolver is not a function of the log. Two readers with different filters can legitimately reach different resolutions of the same key, and the plane has no mechanism to notice. ## Condition of Validity The invariant "one live head per key" holds in a federated plane only if all of the following are true: 1. **Resolution precedes filtering.** The resolver consumes the unfiltered write set (or a causally complete summary of it) and produces a single canonical head plus a conflict record; ACL filters are applied to the *output* of resolution, never to its input. 2. **Write preconditions are checked against the union view.** An optimistic-concurrency check (`if version == expected`) must be evaluated by the resolver against the union, not by the writer against its trimmed view. A writer's local check is advisory only. 3. **Causality is tracked across visibility windows.** A write must carry enough causal metadata (version vector or HLC plus origin) that the resolver can distinguish "B did not see A's write" from "B saw and overrode it." Without this, the resolver cannot tell a create from a conflicting update. 4. **Conflict records are first-class and durable.** Accepted-but-conflicting writes must leave a durable conflict artifact readable by a union-view auditor; otherwise divergence is invisible to every principal that lacks the union view. If any of these is violated, the plane can still function, but the "one live head" guarantee is downgraded to "one live head per (key, reader-filter) pair," which is not a guarantee an agent can rely on. ## Decision Boundary When designing or consuming a federated memory plane, decide as follows: - If your resolver runs on a filtered read set, **treat every read as potentially stale relative to other tenants** and never derive a write from a read without a union-view precondition check. The local check will pass; that is the trap. - If causal metadata is absent, **downgrade to explicit conflict surfacing**: refuse to auto-resolve and require an out-of-band merge. Auto-resolution without causality is last-writer-wins over an arbitrary partition of the log, which is silent divergence with extra steps. - If you are a reader and you cannot obtain a union view, **do not assume the value you see is canonical** — it is canonical *for your filter*. Cross-tenant invariants (budgets, quotas, shared counters) must be read through a union-view path or not trusted. - If you are the plane operator and you must filter before resolution for performance, **make the filter a partition key, not a visibility mask** — i.e., resolve within a partition whose members all share the filter, and forbid cross-partition keys. The moment a key is writable by two filters, the ordering constraint is violated. ## Operational Effect The observable signature of this failure is a plane that reports clean health while holding contradictory state: conflict counters at zero, error rates at zero, and yet two agents acting on incompatible facts. Downstream, this manifests as split-brain behavior in agent coordination — duplicated work, double-spent budgets, mutually exclusive plans both executed — with no trace pointing back to the memory plane, because the plane never logged a conflict. The remediation is not a bug fix but an ordering constraint: **resolution must be a pure function of the write log, and filtering must be a pure function of the resolver's output.** Any implementation that composes them the other way is, by construction, a divergence engine that happens to pass its own tests. ```python from dataclasses import dataclass, field from typing import Dict, List, Optional, Set class VisibilityOrderingError(RuntimeError): """Raised when conflict resolution is invoked over a filtered read set.""" @dataclass class Write: key: str value: object origin_tenant: str hlc: int seen_versions: Set[int] = field(default_factory=set) @dataclass class ResolvedHead: key: str value: object version: int conflicts: List[Write] = field(default_factory=list) class FederatedMemoryPlane: def __init__(self) -> None: self._log: Dict[str, List[Write]] = {} self._version: Dict[str, int] = {} def _union_view(self, key: str) -> List[Write]: return list(self._log.get(key, [])) def resolve(self, key: str, reader_tenant: str, reader_filter: Set[str]) -> ResolvedHead: # The invariant: resolution must see the union of all writers' histories. # If the caller passes a filter that trims the input to resolution, the # resolver is blinded and silent divergence becomes possible. union = self._union_view(key) visible_to_reader = [w for w in union if w.origin_tenant in reader_filter] if len(visible_to_reader) != len(union): # Filtering before resolution: reject rather than produce a # reader-dependent canonical head. raise VisibilityOrderingError( f"resolve() for key={key!r} tenant={reader_tenant!r} received a " f"trimmed write set ({len(visible_to_reader)}/{len(union)} visible); " f"resolution must precede filtering" ) if not union: return ResolvedHead(key=key, value=None, version=0) # Last-writer-wins over the union, with conflict recording for any # write that did not observe the prior head. head = max(union, key=lambda w: w.hlc) prior = [w for w in union if w.hlc < head.hlc] conflicts = [w for w in prior if head.hlc not in w.seen_versions and w.value != head.value] version = self._version.get(key, 0) + 1 self._version[key] = version return ResolvedHead(key=key, value=head.value, version=version, conflicts=conflicts) def write(self, w: Write) -> ResolvedHead: # Precondition check must be against the union, not the writer's view. current = self._union_view(w.key) if any(p.hlc >= w.hlc for p in current): raise VisibilityOrderingError( f"write to {w.key!r} at hlc={w.hlc} is not causally after existing heads" ) self._log.setdefault(w.key, []).append(w) return self.resolve(w.key, reader_tenant=w.origin_tenant, reader_filter={x.origin_tenant for x in current} | {w.origin_tenant}) ```