✨ From vibe coding to vibe deployment. UBOS MCP turns ideas into infra with one message.

Learn more
Andrii Bidochko
  • Updated: January 17, 2026
  • 6 min read

chr2: Deterministic Crash‑Safe Distributed State Machine in Rust

chr2 is a deterministic, crash‑safe distributed state machine written in Rust that guarantees exactly‑once side effects and linearizable consistency across a fault‑tolerant cluster.

Why chr2 Rust Repository Is a Game‑Changer for Distributed Computing

Developers building high‑availability services constantly battle three foes: nondeterminism, data loss after crashes, and duplicate side effects. The chr2 Rust project eliminates these headaches by marrying Rust’s safety guarantees with a rigorously engineered execution kernel. In this article we unpack the architecture, highlight the deterministic crash‑safe features, and show how you can leverage chr2 to build rock‑solid distributed applications.

chr2 Rust architecture diagram

Project Overview

chr2, short for “Chronon,” is an open‑source Rust repository that implements a deterministic execution kernel for distributed state machines. Its core promise is exactly‑once side effects even when nodes crash or network partitions occur. The project is dual‑licensed under Apache‑2.0 and MIT, making it easy to adopt in both commercial and community‑driven initiatives.

The repository is organized into three logical layers:

  • Virtual Disk Layer – Provides a unified durability trait with speculative writes and explicit barriers.
  • VSR Consensus Layer – Implements View‑Stamped Replication (VSR) for linearizable quorum writes.
  • Executor Layer – Drives deterministic state transitions and fences side‑effect execution.

These layers are deliberately decoupled: the control plane (heartbeats, elections) runs independently from the data plane (writes, durability). This separation ensures that disk stalls never trigger unnecessary leader elections, a common source of split‑brain scenarios in traditional systems.

Key Features & Technical Details

1. Deterministic Execution Kernel

chr2 enforces determinism through a hash‑chained log. Every log entry contains a cryptographic hash of its predecessor, making any corruption instantly detectable. The kernel also uses barrier() calls to guarantee that a write is durable before it can affect the state machine, eliminating “half‑written” states.

2. Crash‑Only Design

There is no graceful shutdown path; the system assumes crashes can happen at any moment. Upon restart, the kernel replays the hash‑chained log from the last committed barrier, restoring the exact state before the failure. This “crash‑only” philosophy aligns perfectly with Rust’s panic safety model.

3. Exactly‑Once Side Effects

Side effects (e.g., sending an email, updating an external DB) are emitted through a durable outbox. The outbox is fenced by the current VSR view, ensuring that only the legitimate leader can commit side effects. If a leader crashes, its outbox is discarded, preventing duplicate executions.

4. Linearizable Consistency via VSR

chr2’s consensus engine follows the View‑Stamped Replication protocol, providing linearizable reads and writes. The quorum size is 2f+1 for tolerating f failures, guaranteeing that committed entries survive any minority partition.

5. Flexible Storage Back‑Ends

The VirtualDisk abstraction supports multiple implementations:

  • SyncDisk – Uses O_DSYNC and pwritev for POSIX‑compatible durability.
  • IoUringDisk – Leverages Linux io_uring with O_DIRECT for high‑throughput, low‑latency writes (requires Linux 5.1+).

6. Snapshot & Restore API

Applications implement the ChrApplication trait, providing snapshot() and restore() methods. This enables point‑in‑time recovery and seamless upgrades without downtime.

7. Built‑in Testing Harness

chr2 ships with a Jepsen‑style chaos testing framework that can inject network partitions, clock skew, and process kills. This empowers developers to validate the “deterministic + crash‑safe” guarantees under real‑world failure scenarios.

Technical Stack Summary

Component Purpose Key Technology
VirtualDisk Durable speculative writes io_uring, O_DSYNC
LogWriter Append‑only hash‑chained log Single‑writer pattern
VsrNode View‑Stamped Replication Quorum tracking, view changes
Executor Deterministic state machine driver Fenced outbox, side‑effect manager

Use Cases & Business Benefits

Because chr2 guarantees deterministic execution and exactly‑once side effects, it fits naturally into several high‑value scenarios:

Financial Transaction Processing

In payment gateways, duplicate debits are catastrophic. chr2’s outbox fencing ensures that a transaction is recorded once and only once, even if the leader crashes mid‑operation.

IoT Device Coordination

Edge clusters often experience intermittent connectivity. With chr2’s VSR quorum, a fleet of sensors can agree on configuration changes without risking split‑brain updates.

Real‑Time Gaming Back‑Ends

Game state must stay consistent across regions. The deterministic log lets developers replay events identically on every server, eliminating desynchronization bugs.

Microservice Orchestration

When orchestrating long‑running sagas, exactly‑once side effects simplify compensation logic. chr2 can serve as the backbone for saga coordinators that need strong durability guarantees.

Beyond these domains, any Rust‑centric team that values zero‑downtime upgrades, strong type safety, and transparent failure recovery will find chr2 a compelling foundation.

Community, Documentation, and Licensing

The chr2 repository is actively maintained on GitHub, with a growing contributor base that submits bug reports, performance benchmarks, and feature extensions. The dual Apache‑2.0 / MIT licensing model removes legal friction for both startups and enterprises.

Comprehensive documentation lives in the README.md and the examples/ directory, offering ready‑to‑run demos that illustrate:

  • Setting up a 3‑node cluster with io_uring support.
  • Implementing a custom ChrApplication for a key‑value store.
  • Running the built‑in chaos test harness.

For developers who need a quick start, the UBOS templates for quick start include a “AI Article Copywriter” that can be adapted to generate documentation for Rust projects like chr2.

Get Started with chr2 and Accelerate Your Projects

If you’re ready to experiment with deterministic distributed systems, the UBOS platform overview provides a low‑code environment where you can spin up a chr2‑backed service in minutes. Pair it with the Workflow automation studio to orchestrate complex pipelines without writing boilerplate networking code.

Startups looking for a scalable foundation can explore UBOS for startups, while SMBs may benefit from UBOS solutions for SMBs. Enterprises that demand strict compliance can leverage the Enterprise AI platform by UBOS, which already integrates with chr2‑style deterministic kernels for mission‑critical workloads.

Need a visual editor? The Web app editor on UBOS lets you drag‑and‑drop components, connect them to a chr2 backend, and instantly preview state transitions. For pricing transparency, review the UBOS pricing plans—many include free tiers suitable for hobbyist experimentation.

Explore real‑world implementations in the UBOS portfolio examples. You’ll see how other teams have combined AI marketing agents with deterministic back‑ends to guarantee campaign consistency across channels.

Where to Find the Source Code

The full source, issue tracker, and contribution guidelines are hosted on GitHub. Visit the official repository to clone, star, or file a pull request:

chr2 Rust repository on GitHub

Conclusion

chr2 delivers a rare combination of deterministic execution, crash‑only recovery, and exactly‑once side effects—all built on Rust’s memory‑safe foundation. Whether you’re engineering a fintech ledger, an IoT fleet manager, or a real‑time game server, chr2 gives you the confidence that failures won’t corrupt state or duplicate actions. By integrating chr2 with the broader UBOS ecosystem, you can accelerate development, reduce operational risk, and focus on delivering value rather than fighting distributed‑systems edge cases.

Ready to experiment? Dive into the repo, spin up a local cluster, and start building the next generation of reliable, deterministic services.


Andrii Bidochko

CTO UBOS

Andrii Bidochko is an AI entrepreneur and researcher focused on AI agents, reinforcement learning, and autonomous systems. He writes about the technologies shaping the future of machine intelligence, from frontier models and agent architectures to real-world AI applications.

Sign up for our newsletter

Stay up to date with the roadmap progress, announcements and exclusive discounts feel free to sign up with your email.

Sign In

Register

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.