Contributing
Contributing to ccBitTorrent¶
Thank you for your interest in contributing to ccBitTorrent! This document outlines the development process, code standards, and contribution workflow.
Project Overview¶
ccBitTorrent is a high-performance BitTorrent client implementation in Python. This is a reference Python implementation licensed under the GPL. The project aims to provide a complete, well-tested, and performant BitTorrent client.
Development Setup¶
Prerequisites¶
- Python 3.8 or higher
- UV package manager (recommended)
- Git
Initial Setup¶
-
Clone the repository:
-
Install dependencies using UV:
-
Install pre-commit hooks:
Code Quality Standards¶
Linting¶
We use Ruff for fast linting and formatting. Configuration is in dev/ruff.toml.
Run linting:
Format code:
Type Checking¶
We use Ty for fast type checking. Configuration is in dev/ty.toml.
Run type checking:
Testing¶
We use pytest for testing. Configuration is in dev/pytest.ini.
Run all tests:
Run with coverage:
Pre-commit Hooks¶
All quality checks run automatically via pre-commit hooks configured in dev/pre-commit-config.yaml. This includes:
- Ruff linting and formatting
- Ty type checking
- Bandit security scanning
- Pytest with coverage
- Benchmark smoke tests
Run manually:
Development Configuration¶
All development configuration files are located in dev/:
- dev/pre-commit-config.yaml - Pre-commit hook configuration
- dev/ruff.toml - Ruff linting and formatting
- dev/ty.toml - Type checking configuration
- dev/pytest.ini - Test configuration
- dev/mkdocs.yml - Documentation configuration
Branch Strategy¶
Main Branch¶
- The
mainbranch is used for releases - Only accepts merges from the
devbranch - Builds releases automatically on push to main
Dev Branch¶
- The
devbranch is the primary development branch - Only branch that merges to main
- Runs all checks identically to main, including:
- All linting and type checking
- Full test suite with coverage
- All benchmark checks from dev/pre-commit-config.yaml:39-68
- Documentation builds
Feature Branches¶
Create feature branches directly from: - Sub-issues: Branch directly from sub-issues if working on a specific part - Main issues: Branch from main issues if addressing the full scope - GitHub Templates: Use the GitHub issue template to create issues, then create a branch via the GitHub UI
Issue Workflow¶
Discussions¶
Development areas and features are discussed in GitHub Discussions. From these discussions come:
- Main Issues: High-level feature or improvement requests
- Sub Issues: Specific tasks or components related to a main issue
Creating Issues¶
- Use the GitHub issue template provided
- Link to related discussions if applicable
- Create issues for main features or sub-tasks as needed
Branch Creation¶
- Create branches directly on sub-issues or main issues using GitHub UI
- Branch names should be descriptive and reference the issue number
- Example:
feature/dht-improvements-123orfix/peer-connection-bug-456
Contribution Process¶
Making Changes¶
- Fork or create branch: Create a branch from the appropriate issue
- Make changes: Follow code quality standards
- Test locally: Run all checks before pushing:
- Commit: Use conventional commit messages
- Push: Push to your branch
- Create PR: Submit a pull request to the
devbranch
Automated Checks¶
When you create a pull request, CI/CD will automatically:
- Digital CLA Signature: Contributors are expected to digitally sign a CLA in CI/CD
- Run all linting checks (Ruff) - See Lint Workflow
- Run type checking (Ty) - See Lint Workflow
- Run full test suite with coverage requirements - See Test Workflow
- Run benchmark smoke tests - See Benchmark Workflow
- Build documentation - See Documentation Workflow
- Check code coverage thresholds - See Coverage Requirements
For detailed CI/CD documentation, see CI/CD Documentation.
Code Coverage¶
We maintain high code coverage standards. Coverage reports are generated and must meet minimum thresholds. View coverage reports in reports/coverage.md.
Benchmark Requirements¶
Benchmark checks from dev/pre-commit-config.yaml:39-68 must pass. These include:
- Hash verification benchmarks
- Disk I/O benchmarks
- Piece assembly benchmarks
- Loopback throughput benchmarks
If benchmarks fail, the contribution may need optimization or discussion.
Project Maintenance¶
Automatic Acceptance¶
Contributions that pass all automated checks (linting, type checking, tests, benchmarks, coverage) are typically accepted automatically unless:
- Benchmarks fail (may require optimization)
- Conflicts with project direction (rare)
- Security concerns (handled separately)
Manual Review¶
Maintainers may manually review for: - Architecture alignment - Performance implications - Security considerations - Documentation quality
Documentation Standards¶
- All public APIs must be documented
- Use Google-style docstrings
- Keep documentation up-to-date with code changes
- Build documentation locally:
uv run mkdocs build --strict -f dev/mkdocs.yml - Documentation source is in docs/
License¶
This project is licensed under the GPL (GNU General Public License). By contributing, you agree that your contributions will be licensed under the same license.
Getting Help¶
- Issues: Create an issue for bugs or feature requests
- Discussions: Use GitHub Discussions for questions and design discussions
- Code Review: All PRs receive code review from maintainers
Recognition¶
Contributors are recognized for their valuable contributions. Significant contributions may be highlighted in release notes and project documentation.
Thank you for contributing to ccBitTorrent!