Table of Contents

How It Works

This page is part of 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 how-it-works.md, and llms.txt lists every page.

Part of Atomic Multi-Key Writes.

Saga Coordinator Grain

Each call to SetManyAtomicAsync is routed by the tree to a saga coordinator grain keyed by {treeId}/{operationId}, where operationId is a GUID generated per call (or the caller-supplied idempotency key - see Caller-supplied idempotency keys). The grain persists a single saga state record whose phase transitions drive the saga lifecycle:

NotStarted --> Prepare --> Execute --> registry.MarkCommitted --> fan-out --> Completed   (success)
                              |
                              +--> Compensate --> registry.MarkAborted --> fan-out --> Completed   (failure)

The saga's persisted phase advances through the states shown above - not started, prepare, execute, compensate, and completed - plus two further states that the happy-path diagram omits. The first is a terminal precondition-failed state: a guard predicate evaluated against the pre-saga snapshot failed for at least one key, so the saga aborted before any write and committed nothing; it is memoized distinctly from ordinary completion so a guarded caller re-reads the precondition-miss outcome on re-attach. The second is a prepared / paused state used by cross-tree sagas: every write has been staged into the leaf pending buckets (hidden from readers) and the per-tree registry has delegated this saga's txid to the cross-tree coordinator, and the saga waits there until the coordinator finalizes it into commit (execute-tail) or abort (compensate). The registry decision and the terminal fan-out run synchronously in the saga's drive loop, between the execute / compensate phase exit and the final completed-phase write. The registry write is the single tree-wide visibility flip (see Consistency: Atomic visibility); the terminal fan-out that follows drains each touched leaf's pending-tx bucket - it is not the visibility primitive, but it is re-driven until it completes (see Tree-wide visibility flip).

Phase 1 - Prepare

A fresh saga first asks its decision registry shard for admission. It mints its transaction id, which fixes the shard (see Sharded decision registry), and the shard refuses the saga with a LatticeSaturatedException whose SaturationSource is LatticeSaturationSource.TxRegistryCapacity when its estimated row size is still at or above LatticeOptions.TxRegistryAdmissionBudgetBytes (default 768 KiB; null disables the bound) after it has purged expired tombstones, counting the refusal on orleans.lattice.saturation.refusals with source=tx_registry_capacity. The refusal comes before the saga registers a reminder, persists anything or touches a tree shard, so nothing is written. Only a new saga is checked (each sub-saga of a cross-tree write included); a resumed or re-attached saga is never refused. A refused saga discards the transaction id it drew, so a retry - under the same operationId or a new one - mints a fresh id and with it a freshly drawn shard. When TxRegistryShardCount is above 1 an immediate retry is therefore worth making, because it may land on a shard with room. A single shard's capacity returns only as its tombstones age out of TxDecisionRetention, so on an unsharded tree, or once retries keep being refused, back off for seconds rather than milliseconds. See Configuration and API Reference - Saturation back-pressure.

Once admitted, the coordinator registers a keepalive reminder (1-minute period) so that a silo crash during any subsequent phase triggers reactivation and resumption on the next reminder tick. It then resolves the tree's routing once (forcing a refresh), groups the batch's keys by the shard that owns them, and reads every key's pre-saga value with one batched raw-entry read per touched shard, issued in parallel. It records each pre-saga value (including absence - a tombstoned or already-expired entry counts as absent) in the saga's persisted state, alongside the sorted set of touched shards that later drives the terminal broadcast. The captured pre-saga values feed guard evaluation only - no compensation path reads them, because an abort never writes: a guarded batch evaluates its predicate against this snapshot once, a key with no live pre-saga value fails the guard, and the verdict is persisted with the phase, so a resumed saga never re-evaluates it against data that has moved on. The phase ends with a single state write that flips the persisted phase to execute (or to the terminal precondition-failed state when the guard rejected the batch), followed by a best-effort bulk registration of the touched shards as the transaction's participants in the tree's transaction registry.

Phase 2 - Execute

The coordinator dispatches the saga's unwritten remainder in a single ILattice.SetManyAsync call inside an ambient prepared-write scope. The tree's shard-bucketing fan-out runs the per-shard calls in parallel, giving the saga concurrent per-shard dispatch, and each leaf's commit pipeline sees the prepared flag and stages every per-key write into an in-memory per-transaction pending bucket instead of its visible entries - so prepared writes are invisible to concurrent readers for the duration of the prepare window. The saga checkpoints once, after the whole batch has been staged; a crash mid-batch leaves that checkpoint unwritten, and the resumed saga re-dispatches the whole remainder. That is safe because re-staging a write the leaf already holds for the same transaction merges into the existing pending entry rather than duplicating it, and nothing is visible until the commit decision. Retry semantics are per-batch: a failed dispatch is retried once, the whole unwritten remainder being re-attempted, and on budget exhaustion the saga pivots to compensate without re-throwing. Two refusal shapes bypass the retry budget entirely: the shutdown-refused fast-path (writer-side drain refusal or post-deactivation leaf rejection) and the saturation fast-path - see Shutdown back-pressure below.

The batch is bound to one physical copy of the tree: the copy the tree resolved to when the saga prepared. An alias swap - a resize or its undo, an explicit alias, a shadow-cutover restore or its revert, or a schema remediation cutover - can move the tree to another copy while the saga is in flight, and the routing activations behind ILattice each cache the copy they last resolved, so one that has not yet seen the swap still addresses the old copy. The dispatch therefore carries the bound copy, and the routing tier places the batch only there: a router whose cached routing names another copy re-reads the registry, and if the tree really has moved it refuses the batch rather than write it to a copy the saga will not commit on. The saga then re-binds to the copy the tree resolves to now and re-dispatches the whole batch there, without spending its retry budget. Before it records the commit decision the saga checks the binding once more and re-binds the same way if the tree moved after the dispatch - except when the bound copy is the source of an online resize, which mirrors everything it takes into the copy the tree moved to: the saga then stays bound, and the fenced source still takes the saga's batch and its terminals and mirrors them, so the batch lands whole on both copies and a resize undo never restores a copy holding part of it (#4369). A swap that lands after the decision is recorded leaves the batch on its bound copy, where the terminal broadcast delivers it whole. When that copy is a resized copy whose resize is then undone, the undo discards it with every write it took, so a terminal the discarded copy refuses counts as delivered: it is neither re-sent to the copy the undo restored, which would land part of the batch there, nor retried until the saga stalls, and the saga completes (#4474). When the bound copy is instead a completed resize's old copy and its broadcast outlives SoftDeleteDuration, the purge leaves that copy refusing every terminal; each refused terminal is redelivered to the resized copy - to its shard at the same index, which the old copy mirrored every prepared bucket into, to the shard that now owns each key, and to their split-forward targets - so the saga completes. The redelivered terminal carries no committed-values backstop: the buckets it resolves were all mirrored there (#4475). A batch therefore commits wholly on one copy - kept or discarded with it - and never in part on each (#4358).

Phase 3 - Compensate (failure path only)

No per-key compensation writes are issued. The prepare-phase writes were bucketed into each leaf's pending-tx map, so they were never visible to readers - and a non-prepared rollback write would itself land as a fresh visible entry that overlays the pre-saga state once the abort terminal drops the pending bucket. Compensation therefore records the abort decision on the per-tree transaction registry and then broadcasts MutationKind.TxAbort terminal marks (see Tree-wide visibility flip), which discard each leaf's pending bucket. Readers resolve against the recorded abort in between, so they never observe a partial rollback.

The compensate path consults no retry counter: the per-batch retry count is zeroed when the saga pivots to compensate, and recording the abort and broadcasting the abort terminals are both idempotent, so a reminder-driven re-entry simply re-drives them until they complete.

Tree-wide visibility flip

After Execute completes (success path) or after Compensate completes (failure path), the saga records its terminal outcome - committed or aborted - on its decision registry shard (see Sharded decision registry). This single registry write is the moment of tree-wide visibility flip. It is the only point in the saga's lifecycle at which any reader, anywhere in the tree, can observe the saga's effect: every read path that finds a key in a leaf's pending-tx bucket dials back through the registry and resolves the read against the recorded outcome. There is no inter-leaf coordination beyond the registry write - the post-decision / pre-fan-out window is invisible to readers because the registry is the single tree-wide linearization point.

After the registry write the saga broadcasts MutationKind.TxCommit (success) or MutationKind.TxAbort (failure) terminal marks to every shard root the saga touched - widened to any shard a concurrent split forwarded its prepared writes to, and to any late participant the registry reports after the first pass - which fans each mark out to the affected leaves. The terminals drain each leaf's pending-tx bucket into visible entries (commit) or drop the prepared values (abort). This is not the visibility primitive, but it is not optional either: a broadcast that fails leaves the saga short of completion, and the keepalive reminder - or, for a cross-tree participant, the cross-tree coordinator - re-drives it (the registry write and every terminal are idempotent) until every touched shard has received its terminal. Readers that race the fan-out continue to observe the registry-recorded outcome via dial-back until their pending entries are drained.

A commit applies each value at its prepare stamp

A committed saga's value is installed under last-writer-wins at the stamp its prepare was given (P), not at a stamp minted when the terminal arrives. The leaf installs the value only when the key has no row, or a row stamped below P, and it stores the value AT P. A write acknowledged after the prepare is stamped above P on the leaf that holds the key, so it survives the terminal whether it is a local write or a write a split shadow-forwarded in as a migration, and whichever lands first. Earlier, the drain re-stamped the value above every row the leaf held, so a later write imported as a migration was overwritten and lost (issue #4522).

The read path agrees with the drain. Before the terminal lands, a reader that resolves a committed prepare treats any row stamped at or above P as superseding it, so the saga's older value never surfaces between a later write and the drain.

P has to travel with every copy of a prepare:

  • The routing tier names the shard it dispatches each prepared write to, and a leaf of that shard knows the stamp it mints is the original.
  • A split's or a shard fold's live shadow-forward and its retroactive sweep carry P to the destination, which buckets the prepare at P.
  • A committed-values backstop the sweep applies carries P too.
  • The saga coordinator's own committed-values backstop carries P. Before its execute phase ends, the coordinator reads every key's P back from the bucket that holds it and persists the stamps with the execute-phase checkpoint, so a coordinator that reactivates after the decision still has them. Each terminal it sends to a shard carries the stamps of that shard's backstop keys, so a leaf that holds no bucket for a key - the sibling a leaf split moved the key's range to, say - applies the saga's value at P and never over a write acknowledged after the prepare.
  • An online resize's mirror forwards each prepare to the resized copy carrying P, and every other write as the row it stored, at that row's own stamp, so the resized copy never re-stamps a write on its own clock. Its prepared-bucket sweep and the terminals it mirrors carry P too, so the resized copy orders every write exactly as the source does.
  • A leaf split hands its new sibling the donor's clock, so the sibling stamps later writes above every prepare the donor minted.
  • The write-ahead log records whether a prepare's stamp is original, so replay rebuilds the same decision.

The coordinator's read-back has no fallback. It reads every shard a prepare can have reached: the touched shards and every shard a split of them leads to. Each shard first reads the leaves it recorded the prepares reaching. If that misses a key - the shard root reactivated since the prepares, or a split moved the bucket - the coordinator asks again exhaustively, and each shard reads its whole leaf chain. The buckets and their marks are replayed from the write-ahead log, so a bucket is never lost to a reactivation. Every entry must be accounted for, marked with its stamp or unmarked, before the checkpoint is written. A read that faults or still misses a key fails the batch, which the execute loop retries and, once its retries are spent, aborts, so a saga never commits without its stamps. The orleans.lattice.atomic_write.prepare_stamp_read_back.slow_path counter records each read-back that leaves the fast path (see Metrics).

P is carried only to a shard of the copy whose clocks minted it, or to a resized copy its mirror keeps on the same clock lineage. A terminal the coordinator re-resolves to another copy, or redelivers to a resized copy after the old one was purged, carries none, and carries no committed-values backstop either.

A prepare without that evidence is applied as before, at a fresh dominating stamp, with the migrated-row exception that lets a saga beat a pre-saga value a split migrates in above the destination's clock. That covers:

  • a prepare written by a silo that predates this change, which keeps a rolling upgrade safe;
  • a CRDT-delta prepare, which folds into the key's current value at the terminal stamp rather than replacing it.

Before #4522 the resize mirror forwarded each write as the operation itself, so the resized copy stamped it on its own clock, which does not order it against P.

A later write the split imports is not dropped over the saga's value

A split destination drops a migration import - a write the source shadow-forwards in, or the final drain of the moved slots - over a row the destination wrote itself. Such a row is logically newer than any import, even one stamped higher on the source's clock. A saga value the destination stored at a P carried from the source is not such a row: P was minted on the source, so the value is on the source's clock lineage, and it is stored migrated. A write acknowledged on the source after the prepare is stamped above P, so its import replaces the saga's value by last-writer-wins, and a stale import below P loses to it. Earlier the destination dropped every import over the saga's value, so once the map moved the key read the saga's older value and the acknowledged write was lost (#4564). A saga value at a stamp minted on the destination, and any write the destination accepts itself, still drop an import.

The provenance is durable: the write-ahead log records whether each stored value is migrated - an import, a sibling hand-off, a prepare carrying a P from the source, and the drain or backstop that stores it - and replay restores it, so a destination that reactivates mid-split admits the same imports it would have.

Sharded decision registry

A tree's decision registry can be split into LatticeOptions.TxRegistryShardCount shards (default 1, which keeps the unsharded layout), each a separate registry grain activation keyed _lattice_txshard_{n}_{treeId} with its own persisted row, its own admission budget, and its own decisions revision. The shard leads the key inside the reserved _lattice_ namespace, so no tree id - including one that itself contains digits, underscores, or a ~s3 suffix - can collide with a shard key. Every completed saga leaves a tombstone in its shard's row for TxDecisionRetention, so a single row caps the saga rate a tree can retain. Splitting the registry lifts that ceiling linearly with the shard count without shortening retention or evicting any decision early.

The shard is chosen once, when the saga mints its transaction id at admission, and the shard index is stamped into the id itself (a version-8 UUID). The id the admission check ran against is the one Prepare persists, so the admission check, every participant registration, the decision, and the cleanup that forgets it all land on the same shard. Every other caller that holds the txid - a leaf resolving a pending intent, a shard root registering as a participant, a split sweep, a point-in-time cursor pinning the decisions it captured, a replication receiver - routes to that shard from the id alone. For any one saga the owning shard is therefore still the single linearization point described above. Routing reads the stamped index directly and never consults the configured shard count, so silos with different values still route every txid identically.

Reads that need the whole tree's decisions (multi-key reads, scans, cursors, the snapshot a point-in-time cursor pins, backups and replication snapshots) fan out to every shard up to the tree's shard high-water mark and union the results. The mark is one durable value per tree, held in a per-tree high-water record keyed by the tree id, and a shard raises it to its own index plus one before its first write in each activation; a failed raise fails that write. So no decision can be persisted on a shard the tree-wide reads do not cover. The fan-out reads the mark alongside the shards and widens and re-runs if it grew. The per-shard revisions are summed into one tree-wide equality token, and a stable snapshot re-reads the revisions after the fan-out and retries if any shard moved. A per-silo coalescer shares one fan-out between the concurrent reads of a tree: a snapshot caller joins the round already in flight, while a caller that needs a revision at least as fresh as its own arrival waits for the next round rather than joining one that started before it.

Write failures. A registry shard commits its mutations as one group per state write, and a failed write fails every caller in the group, and every caller queued behind it, with an internal registry-write fault that names the registry key and the provider's fault type. Their mutations are rolled back in memory and nothing the write carried is durable, so the caller may retry. The raw provider exception is never propagated, because a storage-specific exception type (an Azure Table ETag conflict, say) need not be loadable on the calling silo. When the fault is an optimistic-concurrency conflict, which means storage holds a row this activation never read, the shard deactivates itself so that the next call reloads the current row rather than failing forever against a stale ETag. The same applies to the high-water grain. The saga coordinator, the shard root's participant registration and the replication receiver make up to four attempts at a failed registry write, the first included, with a doubling backoff from 25 ms, before surfacing it.

Saga state-write conflicts. The saga grain, the cross-tree coordinator and the leaf-materialiser pin grain each persist their own state with the provider's optimistic-concurrency check. A storage SDK can retry a write whose first attempt actually landed, and the retry then reports a conflict against the ETag the landed attempt produced. The activation's cached ETag is stale from that point, so every later write would fail the same way. On such a conflict the grain marks the activation conflicted, requests deactivation, and fails every further call on it fast rather than writing again with the stale ETag. The next call lands on a fresh activation, which reloads the row and resumes from the durable phase, exactly as crash recovery does. Resuming is idempotent whether or not the conflicted write landed: a persist failure never triggers compensation and the decision registry entry is write-once, so a resumed saga never applies a batch twice. A fresh coordinator that resumes from a durable Preparing phase may re-decide, and its verdict need not match the one the conflicted activation held in memory, because a participant that voted Failed on a transient fault can vote Prepared on re-dispatch. That is safe because no verdict leaves an activation before it is durable: while a decision write is outstanding the coordinator reports the transaction as still in flight, a conflicted coordinator refuses to answer decision reads (a participant's registry treats the failed read as indeterminate and caches nothing), and no participant is finalized against an unpersisted decision. A decision that did land is re-read and never flipped. A terminal write (the saga's Completed or PreconditionFailed phase, or the coordinator's Completed phase) that reports a conflict is confirmed in place by re-reading the row; when it had landed, the terminal cleanup (keepalive removal, the retention reminder, completion metrics and events, forgetting the decision) runs once as normal. If the re-read also fails, the activation deactivates, and the next call, or the keepalive reminder, that finds the durable terminal phase re-arms retention, removes the keepalive and forgets the decision idempotently, so the row is still cleared. Completion metrics and the completed event are not re-emitted on that path, since a duplicate is worse than the rare loss. SetManyAtomicAsync absorbs the conflict by retrying on the fresh activation: the single-tree retry envelope and the cross-tree write's re-attach by operation id each make up to three attempts in all, 1 s and then 2 s apart. A conflict that outlives that budget, or any other provider fault on a saga state write, surfaces to the caller as a public, serializable LatticeStateWriteFailedException that names the grain type, the grain key and the provider's fault type, and says whether it was a conflict. The provider exception itself never crosses the grain boundary, because its type need not be loadable on the client. Faults of types the client can load, such as a TimeoutException, propagate unchanged.

Upgrade compatibility. Transaction ids minted before sharding, or while TxRegistryShardCount is 1, are ordinary version-4 UUIDs and route to the legacy registry keyed by the bare tree id. Tree-wide reads always include that legacy registry, so a saga in flight across an upgrade, or a leaf asking for the status of a txid recorded before it, resolves exactly as before. The legacy row drains within one retention window. Sharding is opt-in because a silo running an older version resolves every txid against the legacy registry: raise the shard count only once every silo, and every replication peer that applies this cluster's sagas, runs a version that understands sharded ids. See Configuration.

Phase 4 - Complete

Whether the saga commits or aborts, it ends by persisting the completed phase, unregistering the keepalive reminder, arming the retention reminder (atomic-write-retention, default 48 h via LatticeOptions.AtomicWriteRetention) for delayed state cleanup, asking the registry to forget the decision - which moves it into its tombstone retention window - and requesting deactivation. A failed saga preserves its failure message, so a client that retries with the same operationId receives the original failure via InvalidOperationException.

The terminal write also releases the staged batch payload from the persisted state. A completed saga is retained only so an idempotent re-entry (or a reminder-driven reactivation) can re-derive its lightweight outcome - its phase, any preserved failure message, the key-set fingerprint, and the transaction id - none of which need the value-bearing staged batch. The byte-bearing fields - the staged entries, the captured pre-saga values, the saga-wide author delta, and the per-entry delta and delete carries - are emptied in the same checkpoint that marks the saga completed, so a completed saga's persisted row is bounded to its outcome fields rather than pinning the full batch value payload for the whole retention window. The small scalar and metadata fields (the touched-shard set, the guard, the captured vector clock, and any cross-tree participant list) carry no value bytes and are kept. The release is crash-safe: if the terminal persist fails, the released fields are restored verbatim so the same activation can retry and a reactivation re-reads the intact pre-terminal record from disk.

Forgetting the decision does not evict the decision record immediately - it stamps a tombstone in the saga's decision registry shard with a forgotten-at timestamp and retains the committed/aborted verdict for LatticeOptions.TxDecisionRetention (default 60 s). During this window the registry's single-txid, multi-txid, and snapshot status reads continue to surface the saga's outcome, so any process that races the saga's terminal fan-out and installs a new pending bucket on the saga's txid can still resolve the verdict and apply the terminal directly. The primary race this guards is the retroactive shadow-forward sweep at the start of an adaptive shard split: the split coordinator walks the source shard's leaves when shadow writing begins, replays every in-flight prepared mutation into the destination shard's pending-tx buckets, and then runs a post-sweep cleanup pass that resolves any saga whose terminal already completed via the retained verdict. Without the retention window, a saga that completed microseconds before the sweep installed its pending bucket on the destination would leave an orphan bucket whose verdict the registry had already forgotten. Tombstones expire and are physically purged by the registry's next forget call, by an admission check that finds the shard over its admission budget (see Phase 1 - Prepare), or by a later commit or abort decision carrying a conflicting outcome (a repeat of the same outcome is recognised as idempotent and leaves the tombstone in place, so it can never resurrect a decision the tree already retired). A prepare forwarded shard to shard (a split's hot-path shadow-forward, an online resize's mirror, or a split sweep's replay) can still be delivered after its saga has completed, been forgotten and had its decision pruned: a forward abandoned at ShardForwardTimeout keeps running. The registry then holds no row for the saga and can only answer in flight, and a destination leaf that no longer remembers the terminal would bucket a prepare that nothing ever settles, which every later split or resize carries and which pins the leaf's write-ahead log prefix. The saga's participant row tells the two cases apart (#4632). The saga holds the row in its tree's registry from before its first prepare dispatch (the execute phase re-asserts it, and a registry fault fails the step) until it forgets its decision, and a forwarded prepare's participant registration only joins an existing row, never recreating it. So a destination leaf refuses a forwarded prepare whose saga the registry reports undecided and holds no row for, before it writes anything. A prepare applied by replication carries its author cluster's origin and belongs to a saga this cluster never forgets, so it is bucketed as before. On a host with replication enabled, every tree's expired tombstone is also held until the write-ahead log can no longer retain a prepare of its saga (#4508) - every tree, not only those replicated today, because a tree added to the replicated set later still has its earlier prepares in its log. WAL partitions trim independently, so a prepare can outlive its saga's terminal in the log and be re-shipped to a peer that bootstraps from the tree, and only a decision the registry still stores reaches that peer in the snapshot export. After a forget, the registry samples every partition's next sequence (at most once per half retention, up to 30 s) and purges the tombstone once every partition's oldest retained entry is at or past that sample. It fails closed: a failed read or a changed partition layout keeps the tombstone. A replication shipper can also hold every purge on the tree through a per-tree purge hold: while any hold is outstanding no decision on the tree is purged. A shipper takes one before it takes its peer off the log for a re-seed, and keeps it until the replay that follows has passed its horizon, so a saga in flight at the re-seed's export keeps its decision while the replay may still read it (#4533). The WAL GC takes one too, for a shipper, before a WalRetention trim passes that shipper's unshipped read position, and the shipper releases it once its durable position covers the trim or its peer is re-seeded (#4534). A failed read of the holds holds too. A tree's part of a cross-tree atomic write is held longer still: until every peer of every participating tree has acknowledged past that participant's part, because a receiver that imports one participant settles the cross-tree barrier from the decision row (#4684; see Cross-tree decision purge hold). On such a host TxDecisionRetention = TimeSpan.Zero still tombstones the decision (masked at once) rather than dropping it.

Capacity on a replication host. A tombstone there lives for the longer of TxDecisionRetention and the tree's WAL trim lag, and a held tombstone stays masked from reads exactly as below but still counts against TxRegistryAdmissionBudgetBytes. Where the WAL trims more slowly than the retention, the sustained saga rate one registry shard admits falls in proportion, and a tree whose log stops trimming (a lagging consumer with no WalRetention, for example) eventually refuses new sagas with TxRegistryCapacity until it trims again. Each cross-tree sub-saga there also keeps its cross-tree membership (operation id, participant trees, decision stamps and sequences; about 1.1 KiB of JSON, weighted at 1,280 bytes) in its tree's registry for as long as its tombstone, so one shard retains only about 530 cross-tree decisions: about 9 sustained cross-tree sagas/s at the default budget and retention. Raise TxRegistryShardCount to restore headroom. A host without replication is unaffected: it records no cross-tree membership, because only replication reads one (#5073). A tombstone held by a live point-in-time cursor pin is skipped by both the purge and the read-side mask. Setting TxDecisionRetention = TimeSpan.Zero restores the pre-tombstone immediate-evict behaviour and reintroduces the orphan risk - reserved for unit tests or environments that disable adaptive splitting.

A prepared write that reaches a leaf after that leaf has already applied the saga's terminal is refused rather than bucketed, and so is a forwarded prepare (a split's shadow-forward or sweep replay) that arrives after its saga has decided, even when the leaf has not applied the terminal or no longer remembers it. A split's hot-path shadow-forward sends each prepared key as its own call, so one can trail the terminal by milliseconds. The terminal has already settled every key it carried to that leaf (a commit's committed-values backstop wrote the value, and an abort needs nothing), and a saga issues one terminal, so nothing would ever drain the bucket. Left in place, it surfaced once the leaf no longer remembered the terminal - after a reactivation, or after a split stranded the key outside the leaf's span - as a stale value or as a key counted twice by CountAsync. The refusal happens before the write-ahead-log append, so the orphan cannot reappear on replay. A leaf whose current activation does not know the terminal asks the registry instead: a forwarded prepare it does not recognise is checked against the saga's decision and refused once the saga has decided (a decision the retention window above has masked still counts), while a registry fault buckets it as before, because refusing a prepare the saga may still need would lose a write. The sweep reads each saga's verdict under the logical tree, where the saga records it, so the check also holds for a resized tree whose shards live under a physical copy.

After the retention window: Indeterminate, not InFlight

Once a tombstone outlives TxDecisionRetention, the registry stops reporting the verdict but the decision row itself is still stored until a purge removes it. The registry's status reads (single-txid, multi-txid, and snapshot) report that masked row as Indeterminate - "a decision exists and I am no longer entitled to report it" - and not as InFlight. The distinction is exact: a txid the registry has genuinely never recorded still reports InFlight.

The two are kept apart because readers act on them differently. InFlight is an affirmative claim that the saga did not commit, so the read gate falls through to the pre-saga value. Making that claim for a saga that may well have committed would serve superseded data as current, with no error and no metric. Indeterminate instead hides the prepared key: absence asserts nothing, is never wrong about a value, and resolves correctly the moment the outcome becomes determinable again. Every read path applies this one rule - point reads, GetManyAsync, the key and entry scans, the counts, and the leaf statistics behind the diagnostics and storage-usage reports - so a key a point read hides is hidden from a multi-key read too (issue #3665). The same reading is produced when a cross-tree saga's coordinator cannot be dialled at all (see Cross-tree atomic writes), and, on a multi-key read, when a leaf has no tree id bound yet and so has no registry to consult; a single-key read on such a leaf instead resolves the saga as in flight and serves the pre-saga value.

The one exception is a leaf that has already applied the saga's terminal. Its row already holds what the saga left there, so a prepared bucket that survives beside it - an orphan a replayed shadow-forward re-installed - can never change the key, and every read path serves the row whatever the registry reports, Indeterminate included. Hiding the key there would keep a committed, materialised value unreadable for as long as the row stays masked, and nothing guarantees the lazy purge that ends the mask ever runs on an idle registry shard (issue #4428).

Snapshots carry the masked row explicitly rather than dropping it, so absence from a snapshot means only "no decision recorded". That matters most for the cross-cluster bootstrap export built from that snapshot - see Snapshot Bootstrap.

The masked row remains readable to the callers that finish a prepare rather than disclose an outcome to a reader, through a deliberately narrow registry bypass: the leaf's activation-time self-terminalisation sweep, a split's or a resize copy's prepared-bucket sweep, and a snapshot capture. A capture resolves a still-pending bucket against the decision the registry records, masked or not, because a capture is permanent: hiding the key would leave it absent from every restore while another key of the same committed batch, whose terminal already landed, is held post-saga (#4619). Read paths never read past the mask.

The Indeterminate status is additive by value, so a mixed-version cluster stays wire-compatible: a node that predates the case takes the same conservative branch it already took for InFlight.

When the registry cannot be reached: LatticeTransactionOutcomeUnavailableException

Indeterminate is the registry answering that it no longer knows. A registry that does not answer at all - the call times out, its silo is unavailable, the message is rejected - is a different condition, and a transient one. A read of a key under a prepared mutation then throws LatticeTransactionOutcomeUnavailableException instead of the raw transport exception. The rule, in one line:

  • registry says unknown (Indeterminate): the key is hidden;
  • registry unreachable: typed, retryable error;
  • never a guessed value - neither the prepared nor the pre-saga value is served on the strength of a registry that did not answer.

Mapping "unreachable" to hidden was rejected deliberately: it would turn a network blip into a silent Get of null or Exists of false, indistinguishable from the key really being absent.

The exception carries TreeId, the Key (single-key reads) or KeyCount (multi-key reads), and the unresolved TransactionIds. It derives from TimeoutException, so an existing catch (TimeoutException) keeps working, and implements ILatticeDomainFault. It is raised on the first transport failure with no retry inside the leaf - a grain call has already spent up to its response timeout by then, so retry policy belongs to the caller. Only a transport failure is translated: a genuine registry fault propagates as itself, and cancellation is never swallowed. A read of a key with no prepared mutation never consults the registry, so it is unaffected.

Multi-key reads (GetManyAsync, CountAsync and CountPerShardAsync) resolve every key against one registry snapshot and then verify, after the fan-out, that no saga committed while it ran. When the registry cannot be reached for either step, the read cannot vouch for that single view, so it fails closed only when its result depends on the registry:

  • if no key the read reached carried a prepared mutation, no value depended on a saga decision and the result is returned;
  • otherwise the attempt is retried under a fresh snapshot, within LatticeOptions.MaxScanRetries, then uses the bounded fallback below. A fallback that cannot certify its cut throws LatticeTransactionOutcomeUnavailableException rather than return a result that could be torn (some keys post-saga, some pre-saga).

When saga commits repeatedly invalidate the optimistic GetManyAsync attempts, the read acquires a read-specific hold on the local decision gate across the legacy registry and every registry shard in the durable high-water mark. It reads under the gate's immutable D0 decisions, then validates the shard map and releases every hold before accepting the result. A copied registry snapshot alone is insufficient: committed prepares drain irreversibly into ordinary leaf entries. The gate prevents new local decisions and delegated-verdict caching; terminals and late-prepare settlement follow durable local decisions, so existing committed sagas may drain without crossing D0.

The fallback has a 30-second deadline including acquisition and certification, and never renews its 30-second per-registry leases. Prepares and ordinary writes remain admitted; saga decisions are temporarily refused and retried by their existing writer retry policy. Cleanup releases holds on success, failure and cancellation; partial acquisition releases every attempted registry. If a caller abandons a stalled grain call, cleanup follows its completion and the leases lapse independently. A lost, expired or reactivated hold, an uncovered registry shard, or a topology change fails closed rather than certifying a torn read. Read holds do not overlap on a registry. Acquisition is sequential, legacy first and then ascending shard number, including high-water widening; this prevents readers from each holding a different half of the registries. After release or expiry each registry leaves a one-second writer-open interval before admitting another read hold. That interval references twice the writer retry ceiling constant; a focused guard checks that it exceeds the actual maximum backoff (currently 640 ms). Existing backup capture admission is unchanged.

The obstruction is tree-wide, not limited to the requested keys or transaction ids: new local commit/abort decisions, delegation registration and delegated verdict caching wait or defer. Ordinary writes, prepares, and draining a decision already in D0 continue. With healthy RPC scheduling and storage, the normal added writer delay is the remaining read acquisition/fan-out/certification time plus one writer retry (at most 640 ms); a crashed reader's obstruction ends after its nonrenewed 30-second lease, plus that retry. The open interval lets a writer that arrived during a hold land before back-to-back readers can reacquire. It is not a bound on unavailable storage, unrelated backup holds or replication deferral scheduling.

Sustained saga commits alone no longer invalidate every attempt once the read obtains its gate. Acquisition can still lose under reader contention; a read that cannot acquire and certify within 30 seconds fails closed. Repeated lease expiry, unavailable storage/transport, unbounded RPC latency, reactivation, and continued topology/registry-coverage churn are not unconditional progress cases. The counts retain their existing retry policy. An Information-level structured log names the tree and optimistic attempt count whenever the fallback is entered. A fallback read occupies a tree-router stateless-worker activation for up to the 30-second gate lease, so the per-silo cap on those activations (256) leaves less headroom under sustained fallback traffic.

The streaming KeysAsync / EntriesAsync scans instead pin the one snapshot they capture at scan start for every page, and are not re-run under a fresh one. A streaming scan whose starting snapshot cannot be fetched keeps going until a page reaches a prepared key, which then throws at once; every page already yielded held no prepared key, so what the caller received is consistent. A CountAsync narrowed by an access-gate key filter is computed by enumerating the keys, so it behaves like these scans rather than like the multi-key reads above. Previously each of these failures was treated as "stable", which let a registry blip certify exactly the torn read the check exists to prevent.