Thank you for your interest in contributing to Monkey Troop! This document provides guidelines for contributing to the project.
- Rust 1.75 or later
- Python 3.11 or later
- Docker and Docker Compose
- Git
# Clone the repository
git clone https://github.com/monkeytroop/monkey-troop.git
cd monkey-troop
# Build Rust workspace
cargo build
# Set up Python environment
cd coordinator
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
pip install -e ".[dev]" # Install dev dependencies
cd ..# Rust tests
cargo test --workspace
# Python tests (requires PostgreSQL and Redis)
cd coordinator
# Set up test environment variables
export DATABASE_URL=postgresql://postgres:testpass@localhost:5432/test_troop
export REDIS_URL=redis://localhost:6379
pytest -v
# Integration tests with Docker
docker-compose -f docker-compose.test.yml up --abort-on-container-exit
# Test with vLLM (optional - requires vLLM installed)
export VLLM_HOST=http://localhost:8000
vllm serve meta-llama/Llama-3-8B --port 8000 &
cargo test --workspaceWhen adding new database features, create migrations:
cd coordinator
# Create a new migration
alembic revision --autogenerate -m "add_my_feature"
# Apply migrations
alembic upgrade head
# Rollback one migration
alembic downgrade -1
# Check current version
alembic currentMigration Best Practices:
- Always test migrations in a dev environment first
- Include both
upgrade()anddowngrade()functions - Use descriptive migration messages
- Add indexes for frequently queried columns
- Never modify existing migrations once merged to main
Rust:
- Follow standard Rust formatting:
cargo fmt - Run clippy:
cargo clippy --all-targets - Fix warnings before committing
Python:
- Format with Black:
black . - Sort imports with isort:
isort . - Lint with flake8:
flake8 --max-line-length=120 . - Type hints are encouraged (checked with mypy)
The system supports streaming for chat completions:
# Client request with streaming
{
"model": "llama3:8b",
"messages": [...],
"stream": true # Enable Server-Sent Events
}Implementation Notes:
- Client: Passes through SSE stream from worker
- Worker: Passes through SSE stream from Ollama
- No buffering in the pipeline for streaming responses
- Content-Type:
text/event-stream
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes
- Run tests and linters
- Commit with clear messages
- Push to your fork
- Open a Pull Request
Use clear, descriptive commit messages:
feat: add proof-of-hardware benchmark
fix: resolve JWT expiration bug
docs: update deployment guide
refactor: simplify heartbeat logic
When reporting issues, include:
- Clear description of the problem
- Steps to reproduce
- Expected vs actual behavior
- System information (OS, Rust/Python version, GPU model)
- Relevant logs
We welcome feature requests! Please:
- Check existing issues first
- Describe the use case
- Explain how it aligns with the project goals
By contributing, you agree that your contributions will be licensed under the MIT License.