Skip to content
SafeMesh

Try a merge — main (unreleased)

For a standalone Rust dependency tied to an exact tested source revision, use the pinned source-build recipe.

Keep local copies, make independent changes, then merge them. This first program combines 4 and 2 into 6; repeating the merge leaves 6 unchanged.

  • Build from source: SafeMesh is main (unreleased); there is no published package to install. Run git clone --branch main https://github.com/velvetmonkey/safemesh.git, then cd safemesh.
  • Use Linux x86_64, Git, internet access, Rust/Cargo through rustup and a native C compiler/linker. Select Rust 1.96.1 with rustup default 1.96.1; the consumer crate floor is 1.89.
  • No Lean or Node is needed here. The first source build may download dependencies and take several minutes.

This complete program is already in examples/gold-path/rust/examples/try_merge.rs. Each replica changes its own coordinate: 4 and 2 are cumulative tallies, not increment amounts. The two replicas use the same counter size (2).

use safemesh_crdt::GCounter;
fn main() {
let mut left = GCounter::new(2);
let mut right = GCounter::new(2);
left.try_apply_bump(0, 4).unwrap();
right.try_apply_bump(1, 2).unwrap();
left.try_merge(&right).unwrap();
right.try_merge(&left).unwrap();
assert_eq!(left.value(), 6);
assert_eq!(left.state(), right.state());
println!("merged total={}", left.value());
left.try_merge(&right).unwrap();
assert_eq!(left.value(), 6);
println!("duplicate replay total={}", left.value());
}
Terminal window
cargo run --quiet --locked --manifest-path examples/gold-path/rust/Cargo.toml --example try_merge

Expected output:

merged total=6
duplicate replay total=6

A merge takes the maximum tally at each coordinate, then the read adds those tallies. Replaying the same information cannot increase either maximum.

Next: Persist and restart, then Connect replicas and Evaluate guarantees.

The Fieldcheck reference application shows disk-backed inspections surviving a service SIGKILL and reconciling after a loopback reconnect.

The Rust journey and TypeScript journey now have their own page.

Diagnose a failed Rust exercise.

Wire compatibility and upgrades.

Concurrent add and remove.

Decrement with v0-focus types.

Environments run.

Complete sources and integration paths.