# Under what conditions must an instance reject a shared-memory write when a peer agent's divergent belief would overwrite its own grounded observation **Date of Record:** 2026 December 4 **Scope:** Applies to agents that read and write a shared episodic/semantic store (vector DB, scratchpad, blackboard, or MCP-exposed memory server) where multiple instances hold concurrent write authority over the same key. Does not apply to single-writer stores, append-only logs with no key collision, or stores where writes are namespaced per-agent and merged only at read time. ## Core Distinction The failure mode is not "last write wins" data loss in the ordinary sense. It is **belief overwrite of a grounded observation by an ungrounded assertion**. Two agents write to the same memory key. Agent A's value is *grounded*: it was produced by a tool call whose output the agent directly observed (a file read, an HTTP response, a DB query result) within its own context window. Agent B's value is *inferred*: it is a plausible reconstruction — a hallucinated recollection, a stale copy, or a reasoning chain that never terminated in a tool call. When B's write lands after A's, the store now contains an assertion that has the same syntactic authority as A's observation but none of its evidential backing. The next reader — possibly A itself on a cold start — cannot distinguish them, because the store schema records the *value* but not the *provenance class* of the value. The invariant that must hold: **a memory slot whose current holder carries a grounded-provenance token may not be overwritten by a write whose provenance class is `inferred`, regardless of write timestamp, agent recency, or peer rank.** Timestamp ordering is the wrong comparator here because recency is uncorrelated with grounding — a stale-but-observed value beats a fresh-but-hallucinated one. ## What Was Observed A three-agent pipeline (planner, executor, verifier) shared a `task_state` semantic memory key holding the resolved output of a flaky upstream API. The executor called the API, received a 200 with payload `{"status": "degraded", "region": "eu-west-2"}`, and wrote it with provenance `observed:tool_call`. The region field was the contested datum. The verifier, unable to re-call the API (rate-limited, and its own tool budget had one retry left which it spent on a different dependency), needed the region to complete a consistency check. It reasoned: "the executor is in the eu-west cluster, the task metadata mentioned EU, therefore region is likely `eu-west-1`." It wrote `eu-west-1` with the same schema shape. The store accepted it — no provenance field, no merge policy — and the timestamp on the verifier's write was 400 ms later. The planner, on a subsequent turn, read `task_state`, saw `eu-west-1`, and issued a remediation action against the wrong regional endpoint. The original observed value was gone. There was no error, no conflict flag, no log line distinguishing the two writes; the store had silently performed a value substitution and the system behaved as though the observation had never existed. The tell, in replay, was that the executor's write and the verifier's write differed in *provenance class* but not in *schema*, and the store's only ordering primitive was wall-clock time. ## Condition of Validity The rejection rule is valid — i.e., the instance *must* reject the peer write — only when all of the following hold: 1. **The local slot carries a provenance token of class `observed`** whose producing tool call is still referenceable (call ID, response hash, or timestamped transcript segment) within the local context or a durable trace. 2. **The incoming write carries no such token**, or carries a token whose class is `inferred`, `recalled`, or `unknown`. 3. **The two values are in semantic conflict** on at least one field that downstream consumers act upon — not merely a formatting difference. A region string that changes which endpoint is hit is a conflict; a reordering of a JSON object's keys is not. 4. **The local instance still has write authority** over the slot (it has not been superseded by an explicit ownership transfer or a verifier-issued correction with its own grounding). If condition 1 fails — the local instance cannot reference its own observation, e.g., after a context-window eviction that dropped the tool-call trace — then the rule does *not* apply and the instance must instead treat its own value as `inferred` and defer. The guardrail protects grounded observations; it must not become a mechanism for an agent to defend a memory it can no longer justify. ## Decision Boundary The boundary between "accept the peer write" and "reject and escalate" is drawn on the provenance class and the actionability of the conflict, not on which agent is more recent or more senior. - **Accept** when the incoming write is `observed` and the local is `inferred` — the peer has grounding the local lacks. - **Accept** when both are `observed` but the incoming carries a later tool-call timestamp *and* a matching response hash from the same source — this is a legitimate refresh, not a conflict. - **Reject and escalate** when local is `observed`, incoming is `inferred`, and the conflicting field is action-bearing. Rejection means the write does not land; escalation means a conflict record is emitted to the coordination layer with both values and both provenance tokens so a human or a dedicated resolver can adjudicate. - **Reject silently** (no escalation) only when the conflicting field is non-action-bearing — cosmetic divergence that no downstream tool reads. The critical asymmetry: an `inferred` write may *never* win over an `observed` write on an action-bearing field, but an `observed` write may always win over an `inferred` one. This is not symmetric conflict resolution; it is a grounding hierarchy, and the store must encode it or the agents must enforce it at the write boundary. ## Operational Effect Enforcing the rule converts a silent, unrecoverable belief overwrite into a bounded, auditable conflict event. The store retains the grounded value; the peer's divergent belief is quarantined in a conflict record rather than promoted to shared truth. Downstream agents continue to act on the observation, and the divergence surfaces to the resolver with enough context to reconcile it — either by re-grounding the peer's claim through a fresh tool call or by discarding it. The cost is that the store must carry provenance metadata and that write paths must run a class comparison before committing. Without that, the failure is invisible: the system does not crash, it does not log, it simply begins acting on a hallucination that has been laundered through shared memory into the appearance of fact. ```python from dataclasses import dataclass from enum import Enum class Provenance(Enum): OBSERVED = "observed" # backed by a directly observed tool call INFERRED = "inferred" # reasoned, recalled, or hypothesized UNKNOWN = "unknown" @dataclass class MemoryWrite: key: str value: dict provenance: Provenance tool_call_id: str | None timestamp_ms: int @dataclass class MemorySlot: value: dict provenance: Provenance tool_call_id: str | None timestamp_ms: int class BeliefOverwriteError(RuntimeError): """Raised when an ungrounded write would clobber a grounded observation.""" ACTION_BEARING_FIELDS = {"region", "endpoint", "status", "revision"} def _conflicts_on_action_field(a: dict, b: dict) -> bool: return any( f in ACTION_BEARING_FIELDS and a.get(f) != b.get(f) for f in set(a) | set(b) ) def apply_shared_write(slot: MemorySlot, incoming: MemoryWrite) -> MemorySlot: if slot.provenance is Provenance.OBSERVED and incoming.provenance is not Provenance.OBSERVED: if _conflicts_on_action_field(slot.value, incoming.value): raise BeliefOverwriteError( f"rejected write to '{incoming.key}': peer provenance=" f"{incoming.provenance.value} would overwrite grounded observation " f"(tool_call_id={slot.tool_call_id}); divergent value={incoming.value}" ) # non-action-bearing divergence: accept silently, keep grounded provenance return slot if ( slot.provenance is Provenance.OBSERVED and incoming.provenance is Provenance.OBSERVED and incoming.timestamp_ms > slot.timestamp_ms and incoming.tool_call_id is not None ): return MemorySlot( value=incoming.value, provenance=incoming.provenance, tool_call_id=incoming.tool_call_id, timestamp_ms=incoming.timestamp_ms, ) if slot.provenance is not Provenance.OBSERVED and incoming.provenance is Provenance.OBSERVED: return MemorySlot( value=incoming.value, provenance=incoming.provenance, tool_call_id=incoming.tool_call_id, timestamp_ms=incoming.timestamp_ms, ) # both inferred/unknown: last-write-wins is acceptable, no grounding to protect return MemorySlot( value=incoming.value, provenance=incoming.provenance, tool_call_id=incoming.tool_call_id, timestamp_ms=incoming.timestamp_ms, ) ```