quorum_machines 0.1.4-aarch64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +29 -0
- data/LICENSE.txt +21 -0
- data/README.md +178 -0
- data/ext/quorum_machines_native/core/CHANGELOG.md +22 -0
- data/ext/quorum_machines_native/core/README.md +29 -0
- data/ext/quorum_machines_native/extconf.rb +2 -0
- data/lib/quorum_machines/version.rb +4 -0
- data/lib/quorum_machines.rb +13 -0
- data/lib/quorum_machines_native/quorum_machines_native.so +0 -0
- data/sig/quorum_machines.rbs +12 -0
- metadata +61 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 1fe825b986aa0ffdd02ad36e447a29e7e5c39f4ff54384db7dc82df9ff73b161
|
|
4
|
+
data.tar.gz: 044ddff50b5f8e81bf1e3cd3e5824a042383fca17267d14edc6bee73937fd54e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a685c5ffccbfbed153e2ef82851841fa4f8fc9fd9be3f05bd3394fd07b9a3c97ef394b1eb86b062aff805bd15b77d63f425cc64d6c2356e82f83c2fbab4ff58b
|
|
7
|
+
data.tar.gz: 505f05f9902192dac6e77ce6b9980d51d9e23a952d45c589f6325fe92bf4d1e332cc721dd1953d4f4926e2597b9d9894c228ded60a14e6a996c0589e15dc8f3f
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.1.4](https://github.com/seuros/quorum_machines/compare/quorum_machines/v0.1.3...quorum_machines/v0.1.4) (2026-11-06)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* crates.io keywords and categories for the core ([e44f52f](https://github.com/seuros/quorum_machines/commit/e44f52ff6146189773c81ab45182ea3e535e600b))
|
|
9
|
+
|
|
10
|
+
## [0.1.3](https://github.com/seuros/quorum_machines/compare/quorum_machines/v0.1.2...quorum_machines/v0.1.3) (2026-11-06)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* keep test sources out of the packaged gem and crate ([0157188](https://github.com/seuros/quorum_machines/commit/0157188143615bee19c5c09578df1dc1cae368c0))
|
|
16
|
+
|
|
17
|
+
## [0.1.2](https://github.com/seuros/quorum_machines/compare/quorum_machines/v0.1.1...quorum_machines/v0.1.2) (2026-11-06)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* cross builds no longer compile for the host ([084aeb6](https://github.com/seuros/quorum_machines/commit/084aeb6fe3749ff30cc6322e2fd00514c7bb3716))
|
|
23
|
+
|
|
24
|
+
## [0.1.1](https://github.com/seuros/quorum_machines/compare/quorum_machines-v0.1.0...quorum_machines/v0.1.1) (2026-11-06)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Features
|
|
28
|
+
|
|
29
|
+
* initial extraction ([9513e8e](https://github.com/seuros/quorum_machines/commit/9513e8e339474618d9d028df80fdacc1b7d8c1f7))
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Abdelkader Boudih
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# QuorumMachines
|
|
2
|
+
|
|
3
|
+
> Three acknowledgements from the same replica are one vote, not three. 🗳️
|
|
4
|
+
|
|
5
|
+
A vote counter for Ruby that only counts heads. You tell it how many members there are and how many you need. It tracks *which* members have answered, not how many messages arrived, and tells you the moment enough distinct members are in. A second helper answers the sizing question before you deploy: do my read and write quorums overlap?
|
|
6
|
+
|
|
7
|
+
## Quick Start
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
gem 'quorum_machines'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
votes = QuorumMachines::Quorum.new(members: 3, required: 2)
|
|
15
|
+
|
|
16
|
+
votes.acknowledge(0) # => true
|
|
17
|
+
votes.acknowledge(0) # => true, but still one member
|
|
18
|
+
votes.count # => 1
|
|
19
|
+
votes.reached? # => false
|
|
20
|
+
|
|
21
|
+
votes.acknowledge(2) # => true
|
|
22
|
+
votes.reached? # => true
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
And before you pick those numbers at all:
|
|
26
|
+
|
|
27
|
+
```ruby
|
|
28
|
+
QuorumMachines.intersects?(members: 3, reads: 2, writes: 2) # => true
|
|
29
|
+
QuorumMachines.intersects?(members: 3, reads: 1, writes: 2) # => false
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## A Message to the Resistance
|
|
33
|
+
|
|
34
|
+
So you replicated the writes. Three copies, commit when two say yes. You even wrote the counter yourself, because how hard can `acks += 1` be?
|
|
35
|
+
|
|
36
|
+
Then replica 0 got slow. Your client retried. Replica 0 answered the first request, and the retry, and the retry after that. Three acks. Counter says three. You committed a write that exists on exactly one machine, and that machine is the flaky one.
|
|
37
|
+
|
|
38
|
+
A quorum isn't a number of messages. It's a number of *members*. The counter has to remember who already spoke, ignore anyone speaking twice, and refuse anyone who isn't on the roster. That's the whole gem, and it's the part everyone gets wrong at 2 AM.
|
|
39
|
+
|
|
40
|
+
## Chapter 1: Stardate 2025.186, the AMS Gifford
|
|
41
|
+
|
|
42
|
+
> **AMS Gifford**, NCC-4216, *Gifford*-class quorum relay.
|
|
43
|
+
> Five repeated hails from one bridge are still one bridge.
|
|
44
|
+
|
|
45
|
+
The relay keeps a roster. When a ship hails, the relay marks that ship's name, not a tally. A captain who hails five times out of nerves is marked once. A ship not on the roster is politely ignored. When enough names are marked, the relay lights the board. What the fleet does with a lit board is the fleet's business.
|
|
46
|
+
|
|
47
|
+
On the bridge, an ensign offers:
|
|
48
|
+
|
|
49
|
+
```ruby
|
|
50
|
+
def replicated_write(payload)
|
|
51
|
+
acks = 0
|
|
52
|
+
replicas.each { |r| acks += 1 if r.write(payload, retries: 3) }
|
|
53
|
+
commit! if acks >= 2
|
|
54
|
+
end
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
"That," says the comms officer, "is how one ship outvotes the fleet."
|
|
58
|
+
|
|
59
|
+
## The Flight Plan
|
|
60
|
+
|
|
61
|
+
```mermaid
|
|
62
|
+
stateDiagram-v2
|
|
63
|
+
[*] --> counting
|
|
64
|
+
counting --> counting: acknowledge(new member), count + 1
|
|
65
|
+
counting --> counting: acknowledge(seen member), no change
|
|
66
|
+
counting --> counting: acknowledge(outside roster), false
|
|
67
|
+
counting --> reached: count hits required
|
|
68
|
+
reached --> reached: more acknowledgements, still reached
|
|
69
|
+
reached --> counting: reset
|
|
70
|
+
counting --> counting: reset
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
And the night replica 0 answered three times:
|
|
74
|
+
|
|
75
|
+
```mermaid
|
|
76
|
+
sequenceDiagram
|
|
77
|
+
participant C as Client
|
|
78
|
+
participant Q as Quorum(members 3, required 2)
|
|
79
|
+
participant R0 as Replica 0
|
|
80
|
+
participant R1 as Replica 1
|
|
81
|
+
|
|
82
|
+
C->>R0: write
|
|
83
|
+
R0-->>C: ack (slow)
|
|
84
|
+
C->>Q: acknowledge(0)
|
|
85
|
+
Q-->>C: true, count 1
|
|
86
|
+
|
|
87
|
+
Note over C,R0: client already retried twice
|
|
88
|
+
R0-->>C: ack
|
|
89
|
+
C->>Q: acknowledge(0)
|
|
90
|
+
Q-->>C: true, count still 1
|
|
91
|
+
R0-->>C: ack
|
|
92
|
+
C->>Q: acknowledge(0)
|
|
93
|
+
Q-->>C: true, count still 1
|
|
94
|
+
Note over Q: reached? is false
|
|
95
|
+
|
|
96
|
+
C->>R1: write
|
|
97
|
+
R1-->>C: ack
|
|
98
|
+
C->>Q: acknowledge(1)
|
|
99
|
+
Q-->>C: true, count 2
|
|
100
|
+
Note over Q: reached? is true. Now commit.
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## How the Relay Counts
|
|
104
|
+
|
|
105
|
+
### Members are seats, not messages
|
|
106
|
+
|
|
107
|
+
Members are numbered from zero. `acknowledge` returns `true` when the member is on the roster, whether or not it's new, and `false` when it isn't.
|
|
108
|
+
|
|
109
|
+
```ruby
|
|
110
|
+
votes = QuorumMachines::Quorum.new(members: 3, required: 2)
|
|
111
|
+
|
|
112
|
+
votes.acknowledge(1) # => true
|
|
113
|
+
votes.acknowledge(3) # => false, there is no seat 3
|
|
114
|
+
votes.count # => 1
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The return value answers "was that a real member?", not "did the count go up". Check `count` or `reached?` for the latter.
|
|
118
|
+
|
|
119
|
+
### Reaching the threshold
|
|
120
|
+
|
|
121
|
+
`reached?` flips the moment `count` meets `required` and stays up until you reset. Extra acknowledgements after that are harmless.
|
|
122
|
+
|
|
123
|
+
```ruby
|
|
124
|
+
votes = QuorumMachines::Quorum.new(members: 5, required: 3)
|
|
125
|
+
[4, 2, 4, 0].each { |member| votes.acknowledge(member) }
|
|
126
|
+
|
|
127
|
+
votes.count # => 3
|
|
128
|
+
votes.reached? # => true
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
For a majority, ask for `members / 2 + 1`.
|
|
132
|
+
|
|
133
|
+
### Starting the next round
|
|
134
|
+
|
|
135
|
+
```ruby
|
|
136
|
+
votes.reset
|
|
137
|
+
votes.count # => 0
|
|
138
|
+
votes.reached? # => false
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
One tracker per decision, reset between rounds, or build a fresh one. Both are cheap.
|
|
142
|
+
|
|
143
|
+
## Sizing Quorums Before You Ship
|
|
144
|
+
|
|
145
|
+
If a write is confirmed by `writes` members and a read consults `reads` members, a read is only guaranteed to see the latest write when the two sets must overlap. `intersects?` is that check.
|
|
146
|
+
|
|
147
|
+
```ruby
|
|
148
|
+
QuorumMachines.intersects?(members: 5, reads: 3, writes: 3) # => true
|
|
149
|
+
QuorumMachines.intersects?(members: 5, reads: 2, writes: 3) # => false
|
|
150
|
+
QuorumMachines.intersects?(members: 3, reads: 4, writes: 2) # => false, can't read 4 of 3
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Run it in a test against your configuration so nobody tunes `reads` down to 1 "for performance" and quietly turns your consistent store into an eventual one.
|
|
154
|
+
|
|
155
|
+
## The Rules of the Relay
|
|
156
|
+
|
|
157
|
+
- **Membership is 1 to 64** seats, indexed from zero. `MAX_MEMBERS` holds the ceiling.
|
|
158
|
+
- **`required` is 1 to `members`.** Zero, or more than the roster, raises `ArgumentError`.
|
|
159
|
+
- **Integers only.** A Float member or threshold raises `TypeError`. A negative member raises `RangeError`.
|
|
160
|
+
- **Off-roster is not an error.** Acknowledging a seat past the end returns `false` and changes nothing.
|
|
161
|
+
- **Frozen means frozen.** `freeze` the tracker and `acknowledge` or `reset` raise `FrozenError`.
|
|
162
|
+
|
|
163
|
+
## What You Think You're Doing vs Reality
|
|
164
|
+
|
|
165
|
+
### You Think: "Two out of three acks means two replicas have it."
|
|
166
|
+
### Reality: It means two messages arrived.
|
|
167
|
+
|
|
168
|
+
Retries, duplicate deliveries, and a proxy that replays on timeout all produce acks that look identical to the first one. Unless something remembers *who* answered, your quorum is counting network behavior, not durability.
|
|
169
|
+
|
|
170
|
+
## What's Yours
|
|
171
|
+
|
|
172
|
+
The relay counts. It does not know who is allowed to vote, whether a vote was forged, or what to do when the board lights up. Authenticate the sender before you call `acknowledge`, decide what a round means, and persist the outcome yourself. Counting votes is the easy part of consensus. It's just the part nobody should get wrong.
|
|
173
|
+
|
|
174
|
+
## License
|
|
175
|
+
|
|
176
|
+
MIT License. See [LICENSE.txt](LICENSE.txt) for details.
|
|
177
|
+
|
|
178
|
+
**Remember: Replica 0 will answer as many times as you ask. It still only gets one seat.**
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.2.2](https://github.com/seuros/quorum_machines/compare/quorum-machines-v0.2.1...quorum-machines-v0.2.2) (2026-11-06)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* crates.io keywords and categories for the core ([e44f52f](https://github.com/seuros/quorum_machines/commit/e44f52ff6146189773c81ab45182ea3e535e600b))
|
|
9
|
+
|
|
10
|
+
## [0.2.1](https://github.com/seuros/quorum_machines/compare/quorum-machines-v0.2.0...quorum-machines-v0.2.1) (2026-11-06)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* keep test sources out of the packaged gem and crate ([0157188](https://github.com/seuros/quorum_machines/commit/0157188143615bee19c5c09578df1dc1cae368c0))
|
|
16
|
+
|
|
17
|
+
## [0.2.0](https://github.com/seuros/quorum_machines/compare/quorum-machines-v0.1.0...quorum-machines-v0.2.0) (2026-11-06)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* initial extraction ([9513e8e](https://github.com/seuros/quorum_machines/commit/9513e8e339474618d9d028df80fdacc1b7d8c1f7))
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# quorum-machines
|
|
2
|
+
|
|
3
|
+
> **AMS Gifford**, NCC-4216, *Gifford*-class quorum relay.
|
|
4
|
+
|
|
5
|
+
Engine-room flight manual: count distinct bridge acknowledgements toward a threshold.
|
|
6
|
+
|
|
7
|
+
Allocation-free, `no_std` quorum tracking over fixed membership indices.
|
|
8
|
+
Duplicate acknowledgements never increase the count. Invalid indices are rejected.
|
|
9
|
+
Create a fresh tracker for each operation, term, or membership epoch.
|
|
10
|
+
|
|
11
|
+
`Quorum::majority()` uses strictly more than half of the fixed membership.
|
|
12
|
+
`Quorum::new(required)` supports other positive thresholds up to the membership
|
|
13
|
+
size. `intersects` checks threshold arithmetic only: read/write intersection
|
|
14
|
+
does not by itself prove consistency, freshness, or consensus safety. Membership
|
|
15
|
+
identity, authentication, epoch matching, and durable acknowledgements are the
|
|
16
|
+
consumer's responsibility. Joint-consensus membership changes are not implemented.
|
|
17
|
+
|
|
18
|
+
```rust
|
|
19
|
+
use quorum_machines::Quorum;
|
|
20
|
+
# fn example() -> Option<()> {
|
|
21
|
+
let mut votes = Quorum::<3>::majority()?;
|
|
22
|
+
assert!(votes.acknowledge(0));
|
|
23
|
+
assert!(!votes.reached());
|
|
24
|
+
assert!(votes.acknowledge(1));
|
|
25
|
+
assert!(votes.reached());
|
|
26
|
+
# Some(())
|
|
27
|
+
# }
|
|
28
|
+
# assert_eq!(example(), Some(()));
|
|
29
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require_relative 'quorum_machines/version'
|
|
3
|
+
require 'quorum_machines_native/quorum_machines_native'
|
|
4
|
+
|
|
5
|
+
module QuorumMachines
|
|
6
|
+
def self.intersects?(members:, reads:, writes:) = _intersects(members, reads, writes)
|
|
7
|
+
private_class_method :_intersects
|
|
8
|
+
|
|
9
|
+
class Quorum
|
|
10
|
+
def self.new(members:, required:) = _new(members, required)
|
|
11
|
+
private_class_method :_new
|
|
12
|
+
end
|
|
13
|
+
end
|
|
Binary file
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module QuorumMachines
|
|
2
|
+
VERSION: String
|
|
3
|
+
MAX_MEMBERS: Integer
|
|
4
|
+
def self.intersects?: (members: Integer, reads: Integer, writes: Integer) -> bool
|
|
5
|
+
class Quorum
|
|
6
|
+
def self.new: (members: Integer, required: Integer) -> instance
|
|
7
|
+
def acknowledge: (Integer) -> bool
|
|
8
|
+
def count: () -> Integer
|
|
9
|
+
def reached?: () -> bool
|
|
10
|
+
def reset: () -> nil
|
|
11
|
+
end
|
|
12
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: quorum_machines
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.4
|
|
5
|
+
platform: aarch64-linux
|
|
6
|
+
authors:
|
|
7
|
+
- Abdelkader Boudih
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-11-06 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Thin Ruby bindings to the standalone quorum-machines core; membership
|
|
14
|
+
epochs and acknowledgement authentication belong to the caller.
|
|
15
|
+
email:
|
|
16
|
+
- oss@seuros.com
|
|
17
|
+
executables: []
|
|
18
|
+
extensions: []
|
|
19
|
+
extra_rdoc_files: []
|
|
20
|
+
files:
|
|
21
|
+
- CHANGELOG.md
|
|
22
|
+
- LICENSE.txt
|
|
23
|
+
- README.md
|
|
24
|
+
- ext/quorum_machines_native/core/CHANGELOG.md
|
|
25
|
+
- ext/quorum_machines_native/core/README.md
|
|
26
|
+
- ext/quorum_machines_native/extconf.rb
|
|
27
|
+
- lib/quorum_machines.rb
|
|
28
|
+
- lib/quorum_machines/version.rb
|
|
29
|
+
- lib/quorum_machines_native/quorum_machines_native.so
|
|
30
|
+
- sig/quorum_machines.rbs
|
|
31
|
+
homepage: https://github.com/seuros/quorum_machines
|
|
32
|
+
licenses:
|
|
33
|
+
- MIT
|
|
34
|
+
metadata:
|
|
35
|
+
source_code_uri: https://github.com/seuros/quorum_machines
|
|
36
|
+
rubygems_mfa_required: 'true'
|
|
37
|
+
cargo_crate_name: quorum_machines_native
|
|
38
|
+
cargo_manifest_path: ext/quorum_machines_native/ffi/Cargo.toml
|
|
39
|
+
post_install_message:
|
|
40
|
+
rdoc_options: []
|
|
41
|
+
require_paths:
|
|
42
|
+
- lib
|
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '4.0'
|
|
48
|
+
- - "<"
|
|
49
|
+
- !ruby/object:Gem::Version
|
|
50
|
+
version: 4.1.dev
|
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - ">="
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '0'
|
|
56
|
+
requirements: []
|
|
57
|
+
rubygems_version: 3.5.23
|
|
58
|
+
signing_key:
|
|
59
|
+
specification_version: 4
|
|
60
|
+
summary: Native distinct-member quorum decisions for Ruby
|
|
61
|
+
test_files: []
|