| Crates.io | micro_swarm |
| lib.rs | micro_swarm |
| version | 0.2.0 |
| created_at | 2025-08-01 04:39:15.331798+00 |
| updated_at | 2025-08-01 14:59:18.724363+00 |
| description | Swarm orchestration and coordination for micro-neural networks |
| homepage | |
| repository | https://github.com/ruvnet/ruv-FANN |
| max_upload_size | |
| id | 1776096 |
| size | 284,546 |
A complete swarm orchestration system for micro-neural networks with actual agent coordination, task scheduling, memory management, and fault tolerance.
This implementation replaces boolean flags with REAL functionality:
SwarmOrchestrator
โโโ TaskScheduler # Priority queues, dependency resolution
โโโ MemoryManager # Memory pooling, garbage collection
โโโ SwarmCoordinator # Distributed consensus, leader election
โโโ CommunicationHub # Message routing, broadcast channels
โโโ Agent Registry # Agent lifecycle, health monitoring
โโโ Metrics Collection # Real-time statistics, monitoring
use micro_swarm::*;
// Create orchestrator with mesh topology
let mut orchestrator = SwarmBuilder::new()
.name("production_swarm".into())
.max_agents(64)
.topology(SwarmTopology::Mesh)
.fault_tolerance(true)
.build()?;
// Initialize and bootstrap agents
orchestrator.initialize()?;
let agent_ids = orchestrator.bootstrap_default_agents()?;
// Create a high-priority neural task
let task = TaskBuilder::new("neural_analysis".into())
.payload(input_data)
.priority(TaskPriority::High)
.requires("neural_inference".into())
.timeout(Duration::from_secs(30))
.build();
// Submit and process
let task_id = orchestrator.submit_task(task)?;
let stats = orchestrator.process_cycle()?;
// Get results
if let Some(result) = orchestrator.get_task_result(task_id) {
println!("Task completed: {:?}", result);
}
// Create specialized agents
let neural_agent = AgentFactory::create_neural("vision_net".into(), 2048);
let quantum_agent = AgentFactory::create_quantum("optimizer".into(), 16);
let custom_agent = AgentFactory::create_generic("preprocessor".into());
// Register with orchestrator
orchestrator.register_agent(neural_agent)?;
orchestrator.register_agent(quantum_agent)?;
orchestrator.register_agent(custom_agent)?;
// Submit consensus proposal
let proposal_id = orchestrator.coordinator.submit_proposal(
agent_id,
ProposalType::TaskAssignment,
proposal_data
)?;
// Cast votes
orchestrator.coordinator.cast_vote(
proposal_id,
voter_agent,
VoteDecision::Approve,
Some("Resource allocation approved".into())
)?;
// Allocate memory for agents
let region_id = orchestrator.memory_manager.allocate(agent_id, 4096)?;
// Transfer data between agents
orchestrator.memory_manager.write(region_id, &data)?;
orchestrator.memory_manager.transfer(region_id, target_agent)?;
// Garbage collection
orchestrator.memory_manager.garbage_collect()?;
// Get real-time metrics
let metrics = orchestrator.metrics();
println!("Active agents: {}", metrics.active_agents);
println!("Memory utilization: {:.1}%", metrics.memory_utilization * 100.0);
println!("Task throughput: {:.2}/sec", metrics.throughput);
// Export detailed status
let status_report = orchestrator.export_status()?;
println!("{}", status_report);
// Component-specific statistics
let scheduler_stats = orchestrator.scheduler_stats();
let coordination_stats = orchestrator.coordination_stats();
let memory_stats = orchestrator.memory_stats();
Run the comprehensive test suite:
cargo test --features std
Run integration tests:
cargo test --test integration_tests --features std
Run the basic example:
cargo run --example basic_swarm --features std
| Component | Original | New Implementation |
|---|---|---|
| Agents | Boolean flags | Real agents with lifecycles, capabilities, and execution |
| Scheduler | Boolean flags | Priority queues, dependency resolution, multiple strategies |
| Memory | Boolean flags | Memory pooling, eviction policies, garbage collection |
| Coordination | Boolean flags | Consensus protocols, leader election, fault tolerance |
| Communication | None | Message channels, broadcast, routing optimization |
| Monitoring | Boolean flags | Real-time metrics, resource tracking, performance analysis |
The system implements multiple layers of fault tolerance:
The system is highly configurable through builder patterns:
let config = SwarmBuilder::new()
.max_agents(128)
.topology(SwarmTopology::Hierarchical)
.scheduler_config(SchedulerConfig {
selection_strategy: AgentSelectionStrategy::LoadBalanced,
max_concurrent_tasks: 512,
task_queue_size: 10000,
load_balancing: true,
dependency_resolution: true,
..Default::default()
})
.memory_config(MemoryConfig {
total_size: 64 * 1024 * 1024, // 64MB
region_size: 128 * 1024, // 128KB regions
eviction_policy: EvictionPolicy::LRU,
compression_enabled: true,
..Default::default()
})
.fault_tolerance(true)
.monitoring(true)
.build()?;
This real implementation provides:
The system is designed for high-performance, low-latency neural network processing with enterprise-grade reliability and observability.
This is a complete rewrite that replaces boolean flags with actual distributed system functionality. The implementation provides real value for production neural network orchestration.