Architecture
This page documents Orleans.Lattice.Api.Mcp.RepoContext.Replication, which is unreleased, in the documentation for Orleans.Lattice 10.5.0 (release line 10.5), built 2026-12-05. It is also published as markdown, with every table and list, at architecture.md, and llms.txt lists every page.EnableRepoContextMultiCluster adds no replication machinery of its own. It composes the existing replication engine with the repository-context store and fixes the one decision an operator must not get wrong: the merge mode of each replicated tree. This page describes what the call wires and how the pieces behave at run time; internal collaborators are described by behaviour. For the call's signature see Public API; for the full tree-to-mode table and the topology rules see the package guide.
What the call wires
- The replication engine. It calls
AddLatticeReplication(configure, enableRuntimeConfig)itself, so the commit-time shipping and the receiver's apply seam are in place with the caller's own settings, and the ordering is owned by this package rather than left to the host. - The enrolment merge. It adds a
PostConfigureAlloverLatticeReplicationOptions, which runs after everyConfigure/ConfigureAllaction - including a host that setsReplicatedTreesafter this call - and on every named (per-tree) options instance, because the shipping observer and the merge-mode resolver read options per tree. The merge copies the host'sReplicatedTrees, then writes the reserved repository-context entries: the agent-memory tree is forced toMvRegisterand the vector-membership tree toOrFlagwhatever the host declared, and every other repository-context tree is added at its default mode (LwwRegister) only when the host has not already declared it. - The memory replica identity. It replaces the store's single-cluster replica identity with one that returns the replication
ClusterId(falling back to the single-cluster id while that is blank), so every agent-memory CRDT write is authored under this cluster's id. Two clusters writing the same memory key therefore mint distinct dots, and both writes survive the merge. - The topology guard. It registers an
IValidateOptions<LatticeReplicationOptions>that engages once any repository-context tree is enrolled and fails validation when the memory tree is notMvRegister, the membership tree is notOrFlag, or a single-writer index-plane tree (structural, symbol, content, cross-reference, vector payload or vector metadata) is enrolled under anything butLwwRegister. A CRDT mode on an index-plane tree would imply more than one concurrent indexer. Of the defaulted trees, only the per-session reuse tree can therefore keep a different host-chosen mode.
At run time
- Shipping. Writes to the enrolled trees are shipped by the replication engine to its peers and applied by each receiver under the tree's resolved merge mode. The approximate-index tree and the vector-coverage digest are not enrolled: each cluster derives its own.
- Indexing stays single-writer. Which cluster indexes is decided by the repository-context package's role gate (
LATTICE_REPOCONTEXT_INDEXING_ROLE, resolved once at startup and fail-closed tohub), not by this package. A spoke serves retrieval and memory from the replicated trees and never walks, reconciles, prunes or re-embeds. The guard reads only merge modes, so it cannot detect two clusters both started ashub; keeping exactly one hub is the operator's responsibility. - Memory and membership converge, never lose. Concurrent memory writes on different clusters both land and are folded by the memory record's own CRDT merge on read. Membership presence reconciles add-wins, so an embedding added on one cluster is not lost to a prune on another.
- The gap scanner stays local. The embedding-gap scan is part of the hub's index pass and never runs remotely; replication only lets peers see which sources are already embedded.
Seams
| Seam | Owned by | Role here |
|---|---|---|
LatticeReplicationOptions |
Orleans.Lattice.Replication |
The only configuration surface: the caller's settings plus the merged repository-context enrolment. |
LatticeMergeMode |
Orleans.Lattice.Replication |
The per-tree convergence rule each enrolled tree is pinned or defaulted to. |
IValidateOptions<LatticeReplicationOptions> |
Microsoft.Extensions.Options |
The hook the topology guard uses to fail a misconfigured topology. |