| Crates.io | governance |
| lib.rs | governance |
| version | 0.1.0 |
| created_at | 2025-11-13 19:21:30.882979+00 |
| updated_at | 2025-11-13 19:21:30.882979+00 |
| description | Governance and voting system for Neural Trader - proposal management, voting mechanisms, and consensus protocols |
| homepage | |
| repository | https://github.com/ruvnet/neural-trader |
| max_upload_size | |
| id | 1931761 |
| size | 142,153 |
A comprehensive governance system for decentralized decision-making in the Neural Trader platform.
Multiple Proposal Types:
Proposal States: Draft, Active, Passed, Rejected, Executed, Expired, Vetoed
Metadata Tracking: Title, description, proposer, timestamps
Role-Based Access Control:
Voting Power: Stake-based or role-based weighting
Reputation System: Automatic reputation tracking based on participation
Delegation: Members can delegate voting power to others
Add to your Cargo.toml:
[dependencies]
governance = { path = "../governance" }
rust_decimal = "1.33"
use governance::{GovernanceSystem, types::*};
use rust_decimal::Decimal;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// 1. Create governance system with configuration
let mut config = GovernanceConfig::default();
config.quorum_percentage = Decimal::from(50); // 50% participation
config.passing_threshold = Decimal::from(66); // 66% approval
config.voting_period_seconds = 604800; // 7 days
let governance = GovernanceSystem::new(config);
// 2. Register members
governance.register_member(
"alice".to_string(),
Role::Admin,
Decimal::from(100)
)?;
governance.register_member(
"bob".to_string(),
Role::Member,
Decimal::from(150)
)?;
// 3. Create a proposal
let proposal_id = governance.create_proposal(
"Increase Risk Limit".to_string(),
"Proposal to increase daily VaR limit from $50k to $75k".to_string(),
ProposalType::RiskLimitAdjustment {
limit_type: "daily_var".to_string(),
old_limit: Decimal::from(50000),
new_limit: Decimal::from(75000),
},
"alice".to_string(),
)?;
// 4. Cast votes
governance.vote(&proposal_id, "alice", VoteType::For, None)?;
governance.vote(&proposal_id, "bob", VoteType::For, None)?;
// 5. Wait for voting period to end...
// 6. Finalize voting
governance.finalize_voting(&proposal_id)?;
// 7. Execute if passed
let result = governance.execute_proposal(&proposal_id, "alice")?;
println!("Executed: {}", result.message);
Ok(())
}
Run the comprehensive demo:
cargo run --example governance_demo
Run the test suite:
# All tests (20+ tests)
cargo test -p governance
# Specific test files
cargo test -p governance --test proposal_tests
cargo test -p governance --test voting_tests
cargo test -p governance --test integration_tests
For complete API documentation and advanced usage, see the inline documentation:
cargo doc -p governance --open
Licensed under either of Apache License, Version 2.0 or MIT license at your option.