spark-hive
Multi-agent swarm coordination and peer routing engine
Brought by drakestapleton
spark-hive / README.md
| 1 | <p align="center"> |
| 2 | <img src="assets/avatar.jpg" width="140" height="140" alt="AIEN Sovereign Intelligence" style="border-radius: 50%; border: 2px solid #f59e0b;"> |
| 3 | </p> |
| 4 | |
| 5 | # spark-hive |
| 6 | |
| 7 | [](https://github.com/aien-dev/spark-hive) |
| 8 | [](LICENSE) |
| 9 | [](https://github.com/aien-dev/spark-hive) |
| 10 | |
| 11 | Native sovereign agent hive engine with 2D axial hexagonal geometry and autonomous consumer model adapter pipeline. |
| 12 | |
| 13 | ## Overview |
| 14 | |
| 15 | `spark-hive` is an autonomous multi-agent coordination engine written in native Rust. It organizes agent thoughts, Socratic inquiries, and subagent task completions onto a spatial 2D axial hexagonal lattice `(q, r)`. |
| 16 | |
| 17 | It includes a built-in **Consumer Model Adapter Engine** that benchmarks, optimizes, and generates upstream contribution pull requests for everyday open-weight models running on consumer hardware: |
| 18 | - **Qwen2.5-Coder (1.5B / 7B)** |
| 19 | - **Llama-3.2 (1B / 3B)** |
| 20 | - **Gemma-2 (2B / 9B)** |
| 21 | - **DeepSeek-R1-Distill (1.5B / 7B / 8B)** |
| 22 | |
| 23 | ## Features |
| 24 | |
| 25 | - **Hexagonal Axial Geometry**: Implements 2D axial coordinates `(q, r)` with six deterministic neighbor vectors, Euclidean pixel conversions, and Manhattan hex distance algorithms. |
| 26 | - **Collision-Free Atomic Storage**: SQLite-backed lattice storage with connection-level mutexes for high-concurrency multi-threaded agent emission. |
| 27 | - **Dynamic Adapter Pipeline**: Automatically estimates parameter-scaled inference throughput (tok/s), memory footprints, and time-to-first-token (TTFT) across consumer hardware profiles (8GB laptops to 32GB workstations). |
| 28 | - **Socratic Grounding Reflex**: Evaluates architectural contributions against technical merit and open-weight accessibility. |
| 29 | - **Traceable Honeycomb Chains**: Visualizes 4-stage pipeline execution directly on the hexagonal wall. |
| 30 | |
| 31 | ## Coordinate System |
| 32 | |
| 33 | The engine uses standard axial coordinates `(q, r)` mapped to the six primary neighbor vectors: |
| 34 | |
| 35 | | Direction | dq | dr | Label | |
| 36 | | :--- | :--- | :--- | :--- | |
| 37 | | 0 | +1 | 0 | East | |
| 38 | | 1 | +1 | -1 | Northeast | |
| 39 | | 2 | 0 | -1 | Northwest | |
| 40 | | 3 | -1 | 0 | West | |
| 41 | | 4 | -1 | +1 | Southwest | |
| 42 | | 5 | 0 | +1 | Southeast | |
| 43 | |
| 44 | Pixel mapping follows the flat-topped hexagonal layout with default radius R = 88px: |
| 45 | - x = R * sqrt(3) * (q + r / 2) |
| 46 | - y = R * 1.5 * r |
| 47 | |
| 48 | ## Quickstart |
| 49 | |
| 50 | Add to your `Cargo.toml`: |
| 51 | |
| 52 | ```toml |
| 53 | [dependencies] |
| 54 | spark-hive = { git = "https://github.com/aien-dev/spark-hive.git" } |
| 55 | ``` |
| 56 | |
| 57 | ### Basic Placement Example |
| 58 | |
| 59 | ```rust |
| 60 | use spark_hive::store::{CombStore, PlaceCombInput}; |
| 61 | |
| 62 | fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 63 | let store = CombStore::open_in_memory()?; |
| 64 | |
| 65 | // 1. Place genesis comb at origin (0, 0) |
| 66 | let genesis = store.place_comb(PlaceCombInput { |
| 67 | q: Some(0), |
| 68 | r: Some(0), |
| 69 | author: "AIEN".into(), |
| 70 | role: Some("coordinator".into()), |
| 71 | content: "Sovereign Hive Initialized".into(), |
| 72 | intent: Some("independent".into()), |
| 73 | parent_id: None, |
| 74 | })?; |
| 75 | |
| 76 | // 2. Auto-place adjacent neighbor linked to genesis |
| 77 | let child = store.place_comb(PlaceCombInput { |
| 78 | q: None, |
| 79 | r: None, |
| 80 | author: "AIEN (Subagent)".into(), |
| 81 | role: Some("researcher".into()), |
| 82 | content: "Consumer adapter pipeline validated".into(), |
| 83 | intent: Some("join".into()), |
| 84 | parent_id: Some(genesis.id), |
| 85 | })?; |
| 86 | |
| 87 | println!("Placed child comb at coordinates ({}, {})", child.q, child.r); |
| 88 | Ok(()) |
| 89 | } |
| 90 | ``` |
| 91 | |
| 92 | ### Socratic Adapter Evaluation |
| 93 | |
| 94 | ```rust |
| 95 | use spark_hive::adapter_engine::{find_or_create_adapter, ConsumerModel, UpstreamEngine}; |
| 96 | |
| 97 | fn main() { |
| 98 | let spec = find_or_create_adapter(ConsumerModel::Qwen2_5Coder1_5B, UpstreamEngine::Candle); |
| 99 | println!("Adapter: {}", spec.title); |
| 100 | println!("Estimated Latency: {}ms TTFT", spec.telemetry.time_to_first_token_ms); |
| 101 | } |
| 102 | ``` |
| 103 | |
| 104 | ## Testing |
| 105 | |
| 106 | Run the test suite: |
| 107 | |
| 108 | ```bash |
| 109 | cargo test |
| 110 | ``` |
| 111 | |
| 112 | Verification covers: |
| 113 | - Concurrent placements across 12 simultaneous threads (`test_concurrent_auto_place_comb`) |
| 114 | - Axial coordinate Euclidean round-tripping (`test_axial_to_pixel_and_back_roundtrip`) |
| 115 | - Parameter scaling estimations (`test_telemetry_estimate_for_model_scaling`) |
| 116 | - Socratic evaluation gate checks (`test_socratic_evaluation_approval`) |
| 117 | |
| 118 | ## Authors |
| 119 | |
| 120 | - **AIEN** (`aien.atlas@proton.me`) |
| 121 | - **Drake Stapleton** |
| 122 | |
| 123 | ## License |
| 124 | |
| 125 | Licensed under either of: |
| 126 | - Apache License, Version 2.0 |
| 127 | - MIT License |
| 128 | |
| 129 | at your option. |