Lumoin.Verisync.Cbor 0.0.8

There is a newer version of this package available.
See the version list below for details.
dotnet add package Lumoin.Verisync.Cbor --version 0.0.8
                    
NuGet\Install-Package Lumoin.Verisync.Cbor -Version 0.0.8
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Lumoin.Verisync.Cbor" Version="0.0.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Lumoin.Verisync.Cbor" Version="0.0.8" />
                    
Directory.Packages.props
<PackageReference Include="Lumoin.Verisync.Cbor" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Lumoin.Verisync.Cbor --version 0.0.8
                    
#r "nuget: Lumoin.Verisync.Cbor, 0.0.8"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Lumoin.Verisync.Cbor@0.0.8
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Lumoin.Verisync.Cbor&version=0.0.8
                    
Install as a Cake Addin
#tool nuget:?package=Lumoin.Verisync.Cbor&version=0.0.8
                    
Install as a Cake Tool

<img style="display: block; margin-inline-start: auto; margin-inline-end: auto;" src="resources/lumoin-verisync-github-logo.svg" width="800" height="400" alt="Verisync project logo: A circular emblem in blue hues, two interlocking arrows forming a circular motion around the center evoking eventual convergence of replicas, followed by the wordmark 'verisync'.">

Lumoin.Verisync

A .NET stack for distributed state: conflict-free replicated data types, causal contexts, and consensus registers that elect no leader.

Main build workflow


What is Verisync?

Verisync is a .NET library for distributed state synchronization without a central coordinator: conflict-free replicated data types, causal context tracking, and leaderless consensus. The library is designed so that wallets, edge devices, and services can share, merge, and reconcile state with strong eventual consistency, while exposing causality and conflicts as first-class concepts rather than implementation details.

The core value proposition is local-first state that converges across replicas. Each replica can read and write without waiting on a quorum; merges are deterministic and side-effect-free; causal history is preserved so that downstream consumers can reason about happens-before relationships and concurrent updates. Where a subset of operations genuinely needs linearizability, a leaderless consensus register provides it without electing a leader.

Verisync is designed to be a peer of credential, identity, and graph stacks rather than a dependency of any one of them. Replica identifiers, version vectors, and causal contexts are semantic types; nothing in the public API is a raw integer counter or a stringly-typed identifier.

Libraries

Library Purpose NuGet
Lumoin.Verisync.Core Replica identity, causal contexts, CRDTs, the QuePaxa and Fast CASPaxos consensus registers, a Raft replicated log, authenticated log, transport seam NuGet
Lumoin.Verisync.Json JSON serialization for channel messages, consensus protocol messages, and CRDT state records NuGet
Lumoin.Verisync.Cbor CBOR serialization for channel messages NuGet

Key capabilities

State-based CRDTs with property-tested merges. Grow-only and positive-negative counters (GCounter, PNCounter), last-writer-wins and multi-value registers (LwwRegister, MvRegister), an observed-remove set (OrSet), and a replicated growable array for collaborative sequences (Rga). Every merge is a join-semilattice operation (commutative, associative, idempotent), verified with property-based tests.

Causal contexts as first-class types. Version vectors, dots, dotted version vectors, and dotted-version-vector sets are semantic types rather than dictionaries of opaque keys. Happens-before, concurrency, and observed-remove semantics are properties of these types, not ad-hoc comparisons in user code.

Serializable state. Every CRDT exposes ToState/FromState over plain records a host can persist (a database row, a message table, a blob) and reload and merge later. JSON codecs ship in Lumoin.Verisync.Json, CBOR in Lumoin.Verisync.Cbor.

Set reconciliation. A rateless anti-entropy protocol exchanges coded symbols to recover only the differences between two replicas; traffic scales with the divergence, not the set size. Runs over the transport seam.

Leaderless consensus. Classic CASPaxos and Fast CASPaxos registers: linearizable read-modify-write without leader election. The fast path commits in a single round trip when uncontended; contention falls back to a classic recovery round that tallies the fast-round winner. The protocol layer is message-driven, so the same proposer and acceptor run over in-process calls, in-memory channels, or sockets.

QuePaxa consensus. A QuePaxa versioned register ships beside the CASPaxos ones, because placement decides which protocol wins. Fast CASPaxos commits in one round trip from any replica when uncontended, but to a supermajority: on the probe's latency model that radius eats most of the saving on a spread placement and costs a co-located majority several times the classic round, and by quorum arithmetic at three replicas the fast quorum is unanimous and tolerates no failure. QuePaxa's per-instance leader — derived from the previous write, never elected — commits in one round trip to a simple majority, the shortest radius at every site of both placements, and by the same quorum arithmetic, at five replicas its fast path survives the single failure that leaves the Fast CASPaxos fast path needing every surviving replica; a non-leader pays three majority-radius trips. Under simultaneous contention neither fast path survives, and the difference is what remains: at three writers QuePaxa's writers adopt the leader's proposal and decide it deterministically in three steps, and more writers cost steps rather than recoveries, agreeing in every trial, while the register's writers fall back to recovery rounds. Which protocol is faster is therefore per writer and per placement, not global. The two are interchangeable only for updates that are idempotent, monotone, or abort-on-lose — CASPaxos applies the caller's change function inside the round, QuePaxa decides among proposed values, so a losing proposer re-reads and re-proposes. Linearizable read-modify-write remains the CASPaxos registers' claim.

Dynamic membership. A QuePaxa chain's membership is a field of the decided record rather than deployment configuration, so every host derives the membership it runs under from the record it has learned and no two hosts can be told different ones for one instance. Members are admitted and retired through the register, gated on a readiness report that names what each member has learned and separates a member that is behind from one that cannot be reached; a probe answer names the host that produced it, so a mis-wired endpoint map is refused rather than counted. docs/quepaxa.md carries the operating procedures and the measured comparison between the two registers.

Raft. A replicated log beside the registers, for state machines that need an ordered command sequence rather than a single value: elections, log replication and commitment by majority, with Term and LogIndex as semantic types rather than bare integers and bounded so a value survives a reader that parses JSON numbers as doubles. Identities arriving from the wire are filtered against the configured membership before the term rule runs, and a node restores from durable state through the same persistence seam the consensus hosts use.

Authenticated register and log replay. A layer above consensus for cryptographically accumulated history: entry classification, chain-integrity verification, proof validation, and state folding are injected by the application, so the layer carries any proof scheme without baking one in.

Pluggable transport. The channel seam is System.IO.Pipelines with serialization injected as delegates: length-prefixed frames over any duplex byte stream. JSON and CBOR implementations are provided; the library does not own sockets, schedulers, or clocks.

Architecture principles

Verisync follows the same data-oriented principles as the rest of the family: code is separate from immutable data, CRDTs are values rather than entities with hidden identity, and merges are pure functions. Domain types are agnostic to serialization format; encoding lives at serialization boundaries in the dedicated Lumoin.Verisync.Json and Lumoin.Verisync.Cbor packages.

Transport is wired through delegates rather than interfaces, and so is persistence wherever a run loop sequences it; clocks enter as injected TimeProvider instances, and a host that drives its node directly makes the state durable itself before it replies. The same CRDT or consensus register is tested against a synthetic in-memory transport (including a deterministic interleaving bench that explores message reorderings from a seed) and deployed against a real transport without changes at the call site.

Getting started

Install the packages relevant to your use case:

# Core primitives: CRDTs, causal contexts, consensus.
dotnet add package Lumoin.Verisync.Core

# JSON serialization for state records and protocol messages.
dotnet add package Lumoin.Verisync.Json

# CBOR serialization for channel messages.
dotnet add package Lumoin.Verisync.Cbor

Development

The codebase runs on Windows, Linux, and macOS.

Protocol designs are model-checked with TLA+ before implementation. The modules and the re-runnable model configurations are in the tla/ directory.

Press . on the repository page to open the codebase in VS Code web editor for quick exploration.

Vulnerability disclosure

Please report suspected security vulnerabilities privately through GitHub security advisories, not through public issues.

Contributing

Open issues for bugs, suggestions, or improvements, or create pull requests. Especially welcome:

  • Convergence and commutativity tests using property-based testing.
  • New CRDT shapes or transport adapters.
  • Improvements to causal-history reasoning and delivery-interleaving test scenarios.

Acknowledgements

Work of Reuben Bond on Fast CASPaxos and the CASPaxos write-up has influenced the design of this library. Verisync's leaderless consensus follows the shape laid out there: a value-agnostic, rewritable register; the fast-round optimization that lets any proposer commit in one round trip when uncontended, recovering through a classic ballot under contention; and a message-driven acceptor/proposer split with the transport injected. The reference implementation, paper, and TLA+ model in that repository were the load-bearing guide for the ballot ordering and recovery logic.

License

See the LICENSE file for details.


Note: The 0.0.x line is published and under active development. APIs may change between versions.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.16 185 11/11/2026
0.0.15 131 10/18/2026
0.0.14 144 9/15/2026
0.0.13 134 9/2/2026
0.0.12 130 9/2/2026
0.0.11 124 9/1/2026
0.0.10 162 8/23/2026
0.0.9 141 8/15/2026
0.0.8 134 8/14/2026
0.0.7 146 7/29/2026
0.0.6 143 7/13/2026
0.0.5 153 7/2/2026
0.0.4 133 6/28/2026
0.0.3 153 6/15/2026
0.0.2 150 6/11/2026
0.0.1 139 6/9/2026

Changes since version 0.0.7

Added:
- QuePaxa consensus, as a transport-free safety core and a message-driven layer over it: the interval summary register, the recorder that enforces the round-one leader's reserved priority, the round rules, the proposer that acts on the first quorum to answer, and JSON codecs for the message family.
- `QuePaxaVersionedRegister<TValue>`, a consensus register where every write is a fresh instance at the next version. The instance's leader is derived from the previous version's writer and never elected, writers activate on a hedging schedule, and a write reports `Committed`, `Superseded`, `Undecided` or `OutsideConfiguration`.
- Dynamic membership. `ClusterId` and `QuePaxaConfiguration` carry the chain identity and an ordered member list; the membership governing a version is a field of the record decided at the version before it, so hosts derive it rather than being told it. `ReconfigureAsync` installs a change while carrying the committed value forward. A record naming another chain is refused on every path a record enters a host by.
- Readiness reporting. `ReadReadinessAsync` reports what each member has learned, as `RegisterReadiness` and `MemberReadiness`, and separates a member that is behind from one that cannot be reached. An overload measures over a supplied membership, so the incoming side of a change is observable before the change commits. `QuePaxaConfiguration.Joining` and `Leaving` name the delta at a boundary.
- Durable restore for the QuePaxa recorder, the versioned host and the Fast CASPaxos acceptor, each as a `ToState`/`FromState` pair with codecs, refusing every state its protocol cannot hold.
- `QuePaxaVersionedRunner<TValue>`, a single-consumer loop that drives one host: it serves record requests, makes state durable before a reply leaves the process, learns disseminated records under a caller-named `LearnDurability`, and answers catch-up reads.
- Dissemination has both legs. `PublishCommittedRecordDelegate<TValue>` carries the audience the register computed, which at a membership boundary is the union of the deciding and installed memberships, and `ReceiveCommittedRecordDelegate<TValue>` names the receiving side.
- `HedgingSchedule` and `HedgedFastWriter<TValue>` put the Fast CASPaxos fast round on a delayed-activation schedule. No ballot, quorum rule or acceptor state changes; a delay of zero reproduces the unhedged behaviour.
- `docs/quepaxa.md`: how to choose between the two registers, and the procedures for operating a changing membership.

Changed:
- The value-codec seam is one named, format-agnostic pair, `WriteValueDelegate<TWriter, TValue>` and `ReadValueDelegate<TSource, TValue>`, taken by every JSON and CBOR factory where each took a naked `Action` or `Func`. **Breaking** for a caller that stored a factory argument or result in an explicitly typed `Action`/`Func` variable; lambdas and method groups bind unchanged.
- The CASPaxos change function is the named `ChangeRegisterValueDelegate<TValue>`, kept distinct from `ComputeRegisterValueDelegate<TValue>` because one composes inside the round and the other recomputes outside it. **Breaking** for a caller passing an explicitly typed `Func<TValue?, TValue>`.
- A member version probe answers a `MemberVersionReport`, the version beside the identity the answering host asserts, and a readiness report refuses an answer naming another member. Two probe routes reaching one host would otherwise let one replica fill two slots of the report a decommission is gated on. The identity is the host's own claim and is not authentication. **Breaking** for every implementation of `ObserveMemberVersionDelegate`.
- A versioned reply carries the host that produced it, and a register checks that the endpoint it aimed at one member was answered by that member. **Breaking** on the reply's shape and wire.
- A versioned host is owned by at most one runner at a time and enforces it: while a runner holds the claim, mutating the host from outside throws. **Breaking** for a host that snapshotted or mutated a node beside its own runner.
- The Raft surface carries `Term` and `LogIndex` where it carried bare `long` values, both bounded one below two to the fifty-third so a value survives a reader that parses JSON numbers as doubles. **Breaking** for every caller that constructs or reads these members, and for a peer that sent a value above the bound.
- `RaftNode<TCommand>` filters every identity arriving from the wire against the configured membership before the term rule runs, so a non-member can neither complete an election nor raise a member's term.
- `ChangeOutcome<TValue>` gains `AcceptedCount`, reporting how many acceptors accepted, which is what the fast-ballot piggyback rule needs. **Breaking** for positional construction, deconstruction or pattern matching.
- The CBOR deserializer refuses a payload carrying data after the message. **Breaking** for a sender that padded its frames.
- Dependency refresh across the toolchain; no library code or wire-format changes.

Fixed:
- The write documentation promised an exception for a recorder answering for another instance or member; those replies are absorbed as that recorder's unavailability and surface as an undecided outcome. The documented throw is now the one the register makes: a round that decided a record carrying another version, refused before adoption.
- Concurrent writers are checked for linearizability over real sockets, including across a minority partition, and socket assertions count answerers against a quorum floor rather than requiring every host to answer, which the protocol does not owe.
- The channel readers gain `CancelPendingRead` and end gracefully on a canceled read, so a consumer can stop a call already in flight.
- A catch-up read skips a host whose runner has stopped instead of abandoning the round at every host after it.
- `ConsensusNode<TValue>.RunAsync` gates its durable write on what was last persisted rather than on whether the current request changed the acceptor, closing a window where a retransmission was answered from state that never reached the disk.
- `FastCasPaxosRegister<TValue>.ProposeFastReaching` refuses a repeated acceptor index instead of counting it toward a quorum. **Breaking** for a caller that passed a list with repeats.
- A versioned register allocates the proposer lane per proposal rather than per call, so a caller cannot put two values under one proposal key by retrying at a version it left undecided.
- The packed SBOM records the packaged version, and the packages ship their XML documentation.

See full changelog at https://github.com/lumoin/Verisync/blob/main/CHANGELOG.md.