Architecture
This page documents Orleans.Lattice.Api.Data 10.5.0, 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.The data facade is a thin, stateless adapter between the transport-agnostic ILatticeDataApi contract and the core ILattice tree surface. It holds no data of its own, keeps no cache, and implements no authorization of its own: every operation becomes a call on the same public tree surface an in-cluster client uses, so the core access gate, write admission, schema enforcement and replication behave exactly as they would for that client.
Registration
AddLatticeDataApi checks that the core lattice has already been registered on the silo builder (it fails fast otherwise), binds LatticeApiDataOptions, and registers one silo-singleton implementation of ILatticeDataApi with TryAdd, so a host that registered its own implementation first keeps it. Nothing else is installed: there are no grains, no background services and no hosted endpoints in this package. A remote endpoint exists only when a host also adds a transport binding such as Orleans.Lattice.Api.Data.Grpc.
Request path
Every verb follows the same three steps:
- Validate. Required arguments are checked first (
ArgumentException/ArgumentNullException), and a cancelled token is honoured before any grain call. - Resolve the tree. The caller's tree name is passed through
ITenantContextResolver.ResolveEffectiveTreeIdAsync, and the resulting effective id addresses theILatticegrain. With no tenancy add-on the resolver completes synchronously and returns the name unchanged, so the common path neither allocates nor awaits. The same effective id is used for authorization and for the operation, so a call cannot authorize one tree and act on another. - Delegate. The verb calls the matching
ILatticemethod (or core extension) with the caller's arguments. The caller identity is whatever ambient credential the transport stamped before calling the facade; the facade never inspects it.
The per-operation routing is tabulated in Surface (v1). The behaviours that are specific to this adapter are:
- Reads do not create trees. A point read or the first page of a range read probes
TreeExistsAsyncfirst and answers an empty result for an unknown tree, rather than activating (and so registering) one. Point and range deletes do not probe here: their unknown-tree no-op lives in the core grain, after the delete gate, so an unauthorized caller still receives a denial rather than a no-op-shaped answer. - Range deletes drain in steps.
DeleteRangeAsyncdrives the core resilient range-delete drain with a step size ofLatticeApiDataOptions.RangeDeleteStepSize(floored at1) and returns the total count removed. - Range reads are one bounded page per call. The first call opens an entry cursor over the requested bounds; the cursor id is returned as the continuation token while more entries remain, and the cursor is closed as soon as a page drains. The page size is the request's size, or
DefaultRangePageSizewhen unset, clamped toMaxRangePageSizeand never below1. A continuation token that names an unknown, drained, closed or expired cursor is reported asArgumentException, a client error rather than a server fault. - Values are returned raw. A point read reports the stored bytes with the key's merge mode and
Raw = true; a range-read page flags every entry raw and leaves its merge mode unset. Typed CRDT values are read through the typed CRDT verbs, which decode them. - Cross-tree batches resolve every slice. Each slice's tree name goes through the same tenant resolution, delete keys are carried alongside the upserts with per-entry delete flags, and the whole set is handed to the grain-factory cross-tree atomic coordinator in one call. The coordinator's outcome is returned unchanged.
- Streamed bulk writes reuse the bulk path. The facade does not override
SetManyStreamAsync; the contract's default member cuts the entry stream into batches ofDataSetManyStreamOptions.BatchSizeand writes each throughSetManyAsync. When a batch is refused for one entry's sake - an unauthorized key, a schema rejection, or an invalid write - it is written again one entry at a time throughSetAsync, so every other entry lands and each refusal is reported against its own key; any other fault ends the stream. Memory is bounded by the batch, never by the stream. - The capability probe asks the gate, not the tree.
ProbeCapabilitiesAsynccomposes the tree name under the active tenant (a refused tenant reports no capability rather than throwing), then asks the registered access gate whether the caller mayWriteandDelete- at the key, applying any per-key filter, or, with no key, whether the caller holds any grant for the operation in the tree (an anonymous caller holds none). No tree is read or written. With no authorization add-on registered, or inside a system-origin scope, both are reported allowed.
Typed CRDT verbs
The typed CRDT methods follow the same validate-resolve-delegate shape, calling the core typed CRDT extension methods on the resolved tree. Writes resolve the tree directly, so the first write to an unknown tree creates it; every read verb goes through the same existence probe as a point read and answers the primitive's empty result (zero, false, null for a max or min register, or an empty list or map) for an unregistered tree instead of creating it. Validation that belongs to a primitive - for example a negative counter amount - is enforced there and surfaces to the caller unchanged; see Typed CRDT facade verbs.
Where enforcement happens
| Concern | Enforced by |
|---|---|
| Transport admission (is this caller allowed to reach the endpoint at all) | The transport binding, for example the gRPC binding's ILatticeDataApiAuthorizer. |
| Per-tree / per-key rights | The core access gate, reached through ILattice with the ambient credential. |
| Tenant namespace and tenant access | ITenantContextResolver, plus the data plane's refusal to write into a tenant namespace the active tenant does not own. |
| Quotas, saturation, schema policy, replication merge mode | The core tree, unchanged by this facade. |
Source map
- Registration
- Options
- Facade - point, bulk, atomic and range verbs
- Facade - typed CRDT verbs
- Facade - capability probe
- Shared contract