Contributing to TAD
Thank you for your interest in contributing to TAD! This document provides guidelines and instructions for contributing to the project.
Table of Contents
- Code of Conduct
- Getting Started
- Development Environment
- Running Tests
- Code Style
- Commit Messages
- Pull Request Process
- Reporting Bugs
- Suggesting Features
Code of Conduct
This project adheres to a Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to the project maintainers.
Getting Started
- Fork the repository on GitHub
- Clone your fork locally
- Set up the development environment
- Create a new branch for your changes
- Make your changes
- Run the test suite
- Submit a pull request
Development Environment
Prerequisites
- Python 3.8 or higher
- Git
- pip and venv
Setup
bash
# Clone your fork
git clone https://github.com/YOUR_USERNAME/tad.git
cd tad
# Add upstream remote
git remote add upstream https://github.com/fabriziosalmi/tad.git
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Install development dependencies
pip install pytest pytest-cov pytest-asyncio black flake8 mypyVerify Installation
bash
# Run test suite
pytest tests/ -v
# Expected output: 97/97 tests passingRunning Tests
Run All Tests
bash
pytest tests/ -vRun Specific Test File
bash
pytest tests/test_node.py -vRun with Coverage
bash
pytest tests/ --cov=tad --cov-report=html
# Open htmlcov/index.html to view coverage reportRun Integration Tests
bash
pytest tests/test_integration.py -vCode Style
Python Style Guide
- Follow PEP 8 style guidelines
- Use meaningful variable and function names
- Add docstrings to all public functions and classes
- Maximum line length: 100 characters
Format Code
bash
# Format with Black
black tad/ tests/
# Check with flake8
flake8 tad/ tests/ --max-line-length=100
# Type check with mypy
mypy tad/Docstring Format
Use Google-style docstrings:
python
def send_message(channel: str, content: str) -> bool:
"""Send a message to a specific channel.
Args:
channel: The channel identifier (e.g., "#general")
content: The message content to send
Returns:
True if message was sent successfully, False otherwise
Raises:
ValueError: If channel name is invalid
"""
passCommit Messages
Format
Follow the Conventional Commits specification:
type(scope): subject
body
footerTypes
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, no logic change)refactor: Code refactoringtest: Test additions or changeschore: Build process or auxiliary tool changes
Examples
feat(crypto): add AES-256-GCM encryption for private channels
Implements end-to-end encryption using AES-256-GCM with X25519 key exchange.
Private channels now encrypt all message content before transmission.
Closes #42fix(discovery): handle mDNS timeout on slow networks
Added retry logic with exponential backoff for mDNS service registration.
Fixes connection issues on congested networks.
Fixes #87Pull Request Process
Before Submitting
Update your branch with the latest upstream changes:
bashgit fetch upstream git rebase upstream/mainRun the full test suite and ensure all tests pass:
bashpytest tests/ -vCheck code style:
bashblack tad/ tests/ flake8 tad/ tests/ --max-line-length=100Update documentation if you changed functionality:
- Update relevant
.mdfiles - Update docstrings
- Add examples if applicable
- Update relevant
Submitting
Push your branch to your fork:
bashgit push origin feature/your-feature-nameOpen a Pull Request on GitHub:
- Use a clear, descriptive title
- Reference related issues (e.g., "Fixes #123")
- Describe what changed and why
- Include test results if applicable
PR Template
markdown
## Description
Brief description of what this PR does.
## Related Issues
Fixes #123
Related to #456
## Changes
- Added X feature
- Fixed Y bug
- Refactored Z module
## Testing
- [ ] All existing tests pass
- [ ] Added new tests for new functionality
- [ ] Manual testing performed
## Documentation
- [ ] Updated relevant documentation
- [ ] Added docstrings to new functions
- [ ] Updated CHANGELOG.mdReview Process
- Maintainers will review your PR
- Address any requested changes
- Once approved, a maintainer will merge your PR
Reporting Bugs
Before Reporting
- Check existing issues to avoid duplicates
- Verify the bug on the latest version
- Collect relevant information:
- Operating system and version
- Python version
- TAD version
- Steps to reproduce
- Expected vs actual behavior
- Error messages or logs
Bug Report Template
markdown
**Environment:**
- OS: [e.g., Ubuntu 22.04]
- Python: [e.g., 3.10.5]
- TAD: [e.g., v1.0]
**Description:**
Clear and concise description of the bug.
**Steps to Reproduce:**
1. Start TAD with `python -m tad.main`
2. Run command `/create #test`
3. Observe error
**Expected Behavior:**
What you expected to happen.
**Actual Behavior:**
What actually happened.
**Logs:**Paste relevant error messages or logs here
**Additional Context:**
Any other relevant information.Suggesting Features
Feature Request Template
markdown
**Problem:**
Describe the problem or limitation you're trying to solve.
**Proposed Solution:**
Describe your proposed solution in detail.
**Alternatives Considered:**
What other solutions did you consider?
**Use Case:**
Describe a specific scenario where this feature would be useful.
**Additional Context:**
Any other relevant information, mockups, or examples.Development Workflow
Working on a Feature
bash
# Update your fork
git fetch upstream
git checkout main
git merge upstream/main
# Create feature branch
git checkout -b feature/awesome-feature
# Make changes
# ... edit files ...
# Run tests frequently
pytest tests/ -v
# Commit changes
git add .
git commit -m "feat: add awesome feature"
# Push to your fork
git push origin feature/awesome-feature
# Open PR on GitHubWorking on a Bug Fix
bash
# Create bug fix branch
git checkout -b fix/issue-123
# Fix the bug
# ... edit files ...
# Add test that reproduces the bug
# ... edit tests/test_*.py ...
# Verify fix
pytest tests/ -v
# Commit
git commit -m "fix: resolve issue with X
Fixes #123"
# Push and PR
git push origin fix/issue-123Project Structure
tad/
├── tad/ # Main package
│ ├── __init__.py
│ ├── main.py # Entry point
│ ├── node.py # Core node logic
│ ├── identity.py # Identity management
│ ├── crypto/ # Cryptography
│ ├── network/ # Networking
│ ├── persistence/ # Database
│ └── ui/ # Terminal UI
├── tests/ # Test suite
│ ├── test_node.py
│ ├── test_gossip.py
│ ├── test_integration.py
│ └── conftest.py
├── docs/ # Documentation
├── requirements.txt # Dependencies
└── README.mdQuestions?
- Open a GitHub Discussion
- Open an Issue for bugs or feature requests
- Check the User Guide for usage questions
License
By contributing, you agree that your contributions will be licensed under the MIT License.