Skip to content

Commit cce066e

Browse files
Merge pull request #75 from ApiliumCode/dev
release: v0.5.0 — Raft clustering, TLS, streaming snapshots
2 parents 9e5a0e5 + 32a62b3 commit cce066e

44 files changed

Lines changed: 6519 additions & 51 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 405 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ members = [
1212
"crates/aingle_minimal", # IoT-optimized minimal node
1313
"crates/aingle_contracts", # Smart Contracts (DSL + WASM Runtime)
1414
"crates/aingle_viz", # DAG Visualization Server
15+
"crates/aingle_wal", # Write-Ahead Log (clustering)
16+
"crates/aingle_raft", # Raft consensus (clustering)
1517

1618
# ── Examples ────────────────────────────────────────────────────
1719
"examples/iot_sensor_network",

README.md

Lines changed: 86 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
<p align="center">
1414
<a href="https://github.com/ApiliumCode/aingle/actions/workflows/ci.yml"><img src="https://github.com/ApiliumCode/aingle/actions/workflows/ci.yml/badge.svg" alt="Build Status"></a>
1515
<a href="./LICENSE"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License"></a>
16-
<a href="https://www.rust-lang.org/"><img src="https://img.shields.io/badge/rust-1.70%2B-orange.svg" alt="Rust"></a>
16+
<a href="https://www.rust-lang.org/"><img src="https://img.shields.io/badge/rust-1.83%2B-orange.svg" alt="Rust"></a>
17+
<a href="https://github.com/ApiliumCode/mayros"><img src="https://img.shields.io/badge/Powers-Mayros%20AI-blueviolet?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0id2hpdGUiPjxwYXRoIGQ9Ik0xMiAyQzYuNDggMiAyIDYuNDggMiAxMnM0LjQ4IDEwIDEwIDEwIDEwLTQuNDggMTAtMTBTMTcuNTIgMiAxMiAyem0wIDNjMS42NiAwIDMgMS4zNCAzIDNzLTEuMzQgMy0zIDMtMy0xLjM0LTMtMyAxLjM0LTMgMy0zem0wIDE0LjJjLTIuNSAwLTQuNzEtMS4yOC02LTMuMjIuMDMtMS45OSA0LTMuMDggNi0zLjA4IDEuOTkgMCA1Ljk3IDEuMDkgNiAzLjA4LTEuMjkgMS45NC0zLjUgMy4yMi02IDMuMjJ6Ii8+PC9zdmc+" alt="Powers Mayros AI"></a>
1718
</p>
1819

1920
<p align="center">
@@ -156,6 +157,73 @@ Interactive D3.js dashboard. Watch your DAG evolve in real-time. Filter, search,
156157

157158
---
158159

160+
## Clustering
161+
162+
AIngle supports multi-node clustering via Raft consensus for high availability and horizontal scalability. Writes are replicated to all nodes; reads can be served from any node with optional quorum consistency.
163+
164+
### Quick Start (3-node cluster)
165+
166+
```bash
167+
# Node 1 — bootstrap leader
168+
aingle-cortex --port 8081 \
169+
--cluster --cluster-node-id 1 \
170+
--cluster-secret "your-secret-at-least-16-chars" \
171+
--cluster-wal-dir ./data/node1/wal \
172+
--db-path ./data/node1/graph.sled
173+
174+
# Node 2 — joins via node 1
175+
aingle-cortex --port 8082 \
176+
--cluster --cluster-node-id 2 \
177+
--cluster-peers 127.0.0.1:8081 \
178+
--cluster-secret "your-secret-at-least-16-chars" \
179+
--cluster-wal-dir ./data/node2/wal \
180+
--db-path ./data/node2/graph.sled
181+
182+
# Node 3 — joins via node 1
183+
aingle-cortex --port 8083 \
184+
--cluster --cluster-node-id 3 \
185+
--cluster-peers 127.0.0.1:8081 \
186+
--cluster-secret "your-secret-at-least-16-chars" \
187+
--cluster-wal-dir ./data/node3/wal \
188+
--db-path ./data/node3/graph.sled
189+
```
190+
191+
### With TLS encryption
192+
193+
```bash
194+
# Auto-generated self-signed certs (development)
195+
aingle-cortex --port 8081 --cluster --cluster-node-id 1 \
196+
--cluster-secret "your-secret" --cluster-tls
197+
198+
# Custom certificates (production)
199+
aingle-cortex --port 8081 --cluster --cluster-node-id 1 \
200+
--cluster-secret "your-secret" --cluster-tls \
201+
--cluster-tls-cert /path/to/cert.pem \
202+
--cluster-tls-key /path/to/key.pem
203+
```
204+
205+
### Cluster endpoints
206+
207+
| Endpoint | Method | Description |
208+
|----------|--------|-------------|
209+
| `/api/v1/cluster/status` | GET | Node role, leader ID, current term |
210+
| `/api/v1/cluster/members` | GET | All cluster members and their state |
211+
| `/api/v1/cluster/join` | POST | Add a new node to the cluster |
212+
| `/api/v1/cluster/leave` | POST | Gracefully remove a node |
213+
| `/api/v1/cluster/wal/stats` | GET | WAL segment count and disk usage |
214+
| `/api/v1/cluster/wal/verify` | POST | Verify WAL integrity (checksums) |
215+
216+
### Features
217+
218+
- **Raft consensus** — automatic leader election, log replication, and membership changes
219+
- **Streaming snapshots** — 512KB chunked transfer with per-chunk ACK for large datasets
220+
- **Write-Ahead Log** — crash-safe durability with segment rotation and integrity verification
221+
- **TLS encryption** — optional TLS for inter-node communication (self-signed or custom certs)
222+
- **Constant-time auth** — cluster secret verified with timing-safe comparison
223+
- **Quorum reads** — optional strong consistency for read operations
224+
225+
---
226+
159227
## Architecture
160228

161229
```
@@ -177,6 +245,12 @@ Interactive D3.js dashboard. Watch your DAG evolve in real-time. Filter, search,
177245
│ │ Graph │ │ Engine │ │ (Privacy) │ │ Runtime │ │
178246
│ └──────────────┘ └──────────────┘ └──────────────┘ └───────────┘ │
179247
├────────────────────────────────────────────────────────────────────────┤
248+
│ CONSENSUS LAYER │
249+
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌───────────┐ │
250+
│ │ Raft │ │ WAL │ │ Streaming │ │ TLS │ │
251+
│ │ (openraft) │ │ (Durability) │ │ Snapshots │ │ (mTLS) │ │
252+
│ └──────────────┘ └──────────────┘ └──────────────┘ └───────────┘ │
253+
├────────────────────────────────────────────────────────────────────────┤
180254
│ NETWORK LAYER │
181255
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌───────────┐ │
182256
│ │ Kitsune P2P │ │ CoAP │ │ Gossip │ │ mDNS │ │
@@ -199,6 +273,9 @@ cd aingle
199273
# Build
200274
cargo build --workspace --release
201275

276+
# Build with clustering support
277+
cargo build -p aingle_cortex --features cluster --release
278+
202279
# Test
203280
cargo test --workspace
204281

@@ -208,7 +285,7 @@ cargo doc --workspace --no-deps --open
208285

209286
### Prerequisites
210287

211-
- **Rust** 1.70 or later
288+
- **Rust** 1.83 or later
212289
- **libsodium-dev** (cryptography)
213290
- **libssl-dev** (TLS)
214291
- **pkg-config**
@@ -264,6 +341,13 @@ cargo doc --workspace --no-deps --open
264341
| `aingle_logic` | Prolog-style reasoning engine |
265342
| `aingle_graph` | Semantic graph database |
266343

344+
### Clustering & Consensus
345+
346+
| Component | Purpose |
347+
|-----------|---------|
348+
| `aingle_raft` | Raft consensus (leader election, log replication, streaming snapshots) |
349+
| `aingle_wal` | Write-Ahead Log for crash-safe durability |
350+
267351
### Security & Privacy
268352

269353
| Component | Purpose |

crates/aingle_ai/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "aingle_ai"
3-
version = "0.4.2"
3+
version = "0.5.0"
44
description = "AI integration layer for AIngle - Ineru, Nested Learning, Kaneru"
55
license = "Apache-2.0 OR LicenseRef-Commercial"
66
repository = "https://github.com/ApiliumCode/aingle"

crates/aingle_contracts/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "aingle_contracts"
3-
version = "0.4.2"
3+
version = "0.5.0"
44
description = "Smart Contracts DSL and WASM Runtime for AIngle"
55
license = "Apache-2.0 OR LicenseRef-Commercial"
66
repository = "https://github.com/ApiliumCode/aingle"

crates/aingle_cortex/Cargo.toml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "aingle_cortex"
3-
version = "0.4.2"
3+
version = "0.5.0"
44
description = "Córtex API - REST/GraphQL/SPARQL interface for AIngle semantic graphs"
55
license = "Apache-2.0 OR LicenseRef-Commercial"
66
repository = "https://github.com/ApiliumCode/aingle"
@@ -20,6 +20,7 @@ sparql = ["dep:spargebra"]
2020
auth = ["dep:jsonwebtoken", "dep:argon2"]
2121
p2p = ["dep:quinn", "dep:rustls", "dep:rcgen", "dep:ed25519-dalek", "dep:hex"]
2222
p2p-mdns = ["p2p", "dep:mdns-sd", "dep:if-addrs"]
23+
cluster = ["p2p", "dep:aingle_wal", "dep:aingle_raft", "dep:openraft", "dep:tokio-rustls", "dep:rustls-pemfile"]
2324
full = ["rest", "graphql", "sparql", "auth"]
2425

2526
[[bin]]
@@ -28,10 +29,10 @@ path = "src/main.rs"
2829

2930
[dependencies]
3031
# Core AIngle crates
31-
aingle_graph = { version = "0.4", path = "../aingle_graph", features = ["sled-backend"] }
32-
aingle_logic = { version = "0.4", path = "../aingle_logic" }
33-
aingle_zk = { version = "0.4", path = "../aingle_zk" }
34-
ineru = { version = "0.4", path = "../ineru" }
32+
aingle_graph = { version = "0.5", path = "../aingle_graph", features = ["sled-backend"] }
33+
aingle_logic = { version = "0.5", path = "../aingle_logic" }
34+
aingle_zk = { version = "0.5", path = "../aingle_zk" }
35+
ineru = { version = "0.5", path = "../ineru" }
3536

3637
# Web framework
3738
axum = { version = "0.8", features = ["ws", "macros"] }
@@ -68,6 +69,7 @@ rand = "0.9"
6869

6970
# Hashing
7071
blake3 = "1.8"
72+
subtle = "2.6"
7173

7274
# Streaming
7375
tokio-stream = { version = "0.1", features = ["sync"] }
@@ -92,6 +94,13 @@ rustls = { version = "0.23", default-features = false, features = ["ring", "std"
9294
rcgen = { version = "0.13", optional = true }
9395
ed25519-dalek = { version = "2", features = ["rand_core"], optional = true }
9496
hex = { version = "0.4", optional = true }
97+
# Clustering (optional)
98+
aingle_wal = { version = "0.5", path = "../aingle_wal", optional = true }
99+
aingle_raft = { version = "0.5", path = "../aingle_raft", optional = true }
100+
openraft = { version = "0.10.0-alpha.17", features = ["serde", "type-alias"], optional = true }
101+
tokio-rustls = { version = "0.26", default-features = false, features = ["ring"], optional = true }
102+
rustls-pemfile = { version = "2", optional = true }
103+
95104
dirs = "6"
96105
mdns-sd = { version = "0.18", optional = true }
97106
if-addrs = { version = "0.13", optional = true }

0 commit comments

Comments
 (0)