skip to content
[readonly]

The fleet's election and commit state machine (Raft's rules with PreVote and CheckQuorum, no log; a pair has a fixed coordinator), sans-IO

sh
$ sexc add @ajax/mesh-fleet-core
  • total 3
  • drwxr-xr-x-../
  • drwxr-xr-x-Oct 27 04:08v/# 1 version
  • drwxr-xr-x-Oct 27 04:08files/# the files of 0.1.0
latest
0.1.0, published Oct 27 04:08 by ajax
owners
ajax
license
MIT
dependencies
@ajax/mesh-check ^0.1.0, @ajax/mesh-mt ^0.1.0, @ajax/mesh-member-list ^0.1.0, @ajax/mesh-fleet-doc ^0.1.0, @ajax/mesh-fleet-persist ^0.1.0, @ajax/mesh-abi-base ^0.1.0
dependents
@ajax/mesh-peer-codec, @ajax/mesh-peer-relay
keywords
mesh alphaos fleet fleet raft election consensus
homepage
https://github.com/thomasdavis/alpha-c-mesh/tree/main/packages/mesh-fleet-core
repository
https://github.com/thomasdavis/alpha-c-mesh
==> README.md <==
1# @ajax/mesh-fleet-core
2
3The fleet's election and commit state machine (`mfc_core`), sans-IO: Raft's rules for a replicated
4document sent whole (so the log is one (term, version) pair), with PreVote (a member that was cut off
5cannot disturb a working leader when it returns), CheckQuorum (a leader that loses its majority steps
6down), one change in flight at a time, catch-up of members that were away, and a fixed coordinator for
7a pair (N = 2 has no majority after a loss). `mfc_durable` writes every Persist before anything after
8it goes out, and stops at the first failed write (fail-stop).
9
10The shell (`@ajax/mesh-peer-relay`) feeds it link changes, ticks and messages; the messages' wire
11form is `@ajax/mesh-peer-codec`.
12
13## Ported from
14
15[alpha-rust-mesh](https://github.com/rsafier/alpha-rust-mesh) `crates/mesh-host/src/fleet.rs`: `Msg`,
16`Role`, `Config`, `Out`, `durable`, `Core`.
17
18## Tests
19
20- `tests/election.c`: the Rust's simulated network, ported (`Sim`): a leader is elected and commits
21  (N = 3, 4, 5), a minority refuses changes, a 2 + 2 split has no leader, the pair's fixed coordinator,
22  terms and votes survive restarts, and the randomised run over 300 seeds (partitions, crashes,
23  restarts, message loss, disks that fill up) asserting at most one leader per term, one document per
24  committed version and per accepted (term, version), no committed change lost, no committed document
25  going back. `election 2000` runs the Rust's ignored 2000-seed variant (7469 leaderships, 23538
26  committed versions, 1308 fail-stops, no invariant broken).
27- `tests/catchup.c`: the Rust's three catch-up scenarios after leader changes (review finding 1) and
28  `nothing_leaves_without_its_persist` (review finding 4).
29
30## Licence
31
32MIT. See the repository's LICENSE.