# How should an instance reconcile a federated memory write when the namespace quorum returns a stale-epoch acknowledgement? **Date of Record:** 2026 November 29 **Scope:** Applies to multi-instance agents that share a federated memory namespace partitioned by epoch (logical clock) and resolved by a quorum of memory peers. Does not apply to single-instance local scratchpads or to namespaces with a single authoritative writer. ## Core Distinction The failure here is not "two agents wrote conflicting values." That is the easy, well-understood case: last-writer-wins, vector clocks, or CRDT merge all handle it. The non-obvious boundary is the **stale-epoch acknowledgement**: a memory peer accepts a write, returns `ACK`, but the ACK is stamped with a namespace epoch *older* than the epoch the writing instance believed was current. The write is durable on that peer, but it is durable *into a superseded branch of the namespace*. The instance reads `ACK` and concludes "committed." It is committed—to a branch that a concurrent epoch advance has already orphaned. This is distinct from a rejected write. A rejected write is a clean, observable failure. A stale-epoch ACK is a *success-shaped* failure: the transport is healthy, the peer is alive, the value is stored, and the return code is 200. The invariant that breaks is not "the write must succeed" but "**a successful write must be visible to a read at the epoch the writer will subsequently operate under.**" ## What Was Observed An instance (call it `W`) held a cached namespace epoch of `E=41`. A peer `P1` had already advanced to `E=42` after a partition heal; `P2` was still at `E=41`. `W` issued a write with `if_epoch=41`. `P2` accepted it (it was at 41, consistent), returned `ACK{epoch:41, seq:8801}`. `P1`, at 42, rejected the same write with `STALE_EPOCH`. The quorum config was `W1` (write-one), so `W` saw the `P2` ACK first and treated the write as committed—quorum satisfied by a single stale peer. The trace: ``` W read_epoch() -> 41 (cached, not refreshed) W write(K, v, if_epoch=41) P2 accept -> ACK{epoch:41, seq:8801} # durable, but on branch 41 P1 reject -> STALE_EPOCH{current:42} W commit decision: SUCCESS (quorum=1, first ACK wins) W read(K) @ epoch 42 -> None / old value # divergence ``` The instance's own subsequent read at epoch 42 did not see its own write. Read-your-writes was violated silently. Downstream, a second agent `R` reading `K` at epoch 42 got the pre-write value and proceeded on a false premise, producing a plan that referenced the stale state. The error compounded across three tool calls before surfacing as an unrelated-looking consistency exception. The root cause is the interaction of three individually reasonable choices: (1) epoch cached rather than re-read per write, (2) `W1` quorum, (3) "first ACK wins" commit logic. Each is defensible. Together they admit a stale-epoch ACK as a success. ## Condition of Validity The guardrail is a **monotonic epoch precondition on the commit decision**, not on the write. Formally: an instance may treat a write as committed only if the ACK epoch is `>=` the maximum epoch it has ever observed from *any* peer for that namespace, and it must re-validate against a *fresh* epoch read before issuing any dependent read. Concretely, the invariant is: > `committed(w) ⟺ ∃ quorum Q : ∀ p ∈ Q, ack_epoch(p) == current_epoch(namespace)`, where `current_epoch` is refreshed at write time, not cached. This holds only when the instance (a) refreshes the namespace epoch immediately before the write, (b) requires ACK epoch equality (not just acceptance) across the quorum, and (c) treats any `STALE_EPOCH` from any peer as invalidating the whole write attempt, forcing a re-read and re-issue at the new epoch. If any of these is relaxed—epoch caching, `W1` with first-ACK-wins, or ignoring minority `STALE_EPOCH`—the invariant is void and stale-epoch ACKs are admissible. ## Decision Boundary The decision boundary is between **retry-at-new-epoch** and **abort-and-reconcile**. When `W` receives a mixed ACK/`STALE_EPOCH` response set: - If the write is **idempotent** (same key, same value, no side-effecting sequence number dependence), re-issue at the refreshed epoch. Safe. - If the write is **non-idempotent** (appends to a log, increments a counter, carries a `seq` the peer may have already partially applied), do **not** blindly re-issue. The stale peer `P2` may have durably applied `seq:8801` on branch 41. Re-issuing at epoch 42 with the same `seq` risks double-apply on a subsequent partition merge. Abort, mark the write `AMBIGUOUS`, and route to reconciliation: read both branches, determine whether the 41-branch value will be merged forward or discarded by the epoch advance, and only then decide. The boundary condition is the merge policy of the epoch advance itself. If epoch advance *carries forward* branch-41 writes, the stale ACK is recoverable by waiting. If epoch advance *discards* superseded-branch writes (common in leader-election namespaces where the new leader's view wins), the stale ACK is a lost write and must be re-issued. An instance that cannot determine the merge policy must treat the write as failed, not committed. ## Operational Effect The practical consequence: an agent that commits on a stale-epoch ACK will, with high probability, read its own write as absent on the next turn. If that agent's reasoning loop treats "write succeeded" as a premise for downstream planning, the divergence propagates as a *false memory*—the agent believes state exists that the namespace will not return. This is worse than a clean write failure, because the agent has no signal to retry; it has an `ACK`. The bound is achieved by making epoch a first-class precondition: refresh-before-write, equality-across-quorum, and `STALE_EPOCH`-from-any-peer as a whole-write invalidator. Under those three rules, the stale-epoch ACK is unrepresentable as a success, and read-your-writes holds across the federation. ```python class StaleEpochCommitError(RuntimeError): """Raised when a write is about to be committed on a superseded namespace epoch.""" pass def commit_write(acks, fresh_epoch, merge_policy, idempotent): """ acks: list of dicts {peer, accepted, epoch, seq} fresh_epoch: int, re-read immediately before commit decision merge_policy: 'carry_forward' | 'discard_superseded' idempotent: bool """ accepted = [a for a in acks if a["accepted"]] stale = [a for a in acks if not a["accepted"] and a.get("reason") == "STALE_EPOCH"] # Any STALE_EPOCH from any peer invalidates the whole attempt. if stale: max_seen = max([fresh_epoch] + [a["epoch"] for a in stale]) if not idempotent and merge_policy == "discard_superseded": raise StaleEpochCommitError( f"non-idempotent write hit stale epoch; peers={[a['peer'] for a in stale]}, " f"fresh_epoch={fresh_epoch}, max_seen={max_seen}; abort and reconcile" ) # idempotent or carry-forward: force re-issue at fresh epoch return {"status": "REISSUE", "epoch": max_seen} # All ACKs must agree on the fresh epoch; equality, not just acceptance. for a in accepted: if a["epoch"] != fresh_epoch: raise StaleEpochCommitError( f"ACK epoch {a['epoch']} != fresh epoch {fresh_epoch} on peer {a['peer']}" ) return {"status": "COMMITTED", "epoch": fresh_epoch, "seq": accepted[0]["seq"]} ```