Thank you for your interest in contributing to Governor! This document provides guidelines and instructions for contributing.
By participating in this project, you agree to abide by our Code of Conduct.
-
Fork and clone the repository
git clone https://github.com/shreyas-lyzr/governor.git cd governor -
Create a virtual environment
python3 -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install development dependencies
pip install -e .[dev]
-
Run tests to verify setup
pytest tests/ -v
git checkout -b feature/your-feature-name
# or
git checkout -b fix/your-bug-fix- Write clean, readable code
- Follow existing code style
- Add docstrings to all public APIs
- Keep functions focused and small
All new features and bug fixes should include tests:
# tests/test_your_feature.py
import pytest
from governor import govern
@pytest.mark.asyncio
async def test_your_feature():
"""Test description."""
# Your test code here
assert result == expected# Run tests
pytest tests/ -v --cov=governor
# Run linter
ruff check governor/ tests/
# Format code
ruff format governor/ tests/
# Type checking (optional but recommended)
mypy governor/ --ignore-missing-importsWrite clear, descriptive commit messages:
git add .
git commit -m "feat: add approval timeout configuration
- Add timeout_seconds parameter to ApprovalPolicy
- Update documentation with timeout examples
- Add tests for timeout behavior"Commit Message Format:
feat:New featurefix:Bug fixdocs:Documentation changestest:Adding or updating testsrefactor:Code refactoringperf:Performance improvementschore:Maintenance tasks
git push origin feature/your-feature-nameThen create a Pull Request on GitHub with:
- Clear title and description
- Reference any related issues
- Screenshots if UI-related
- Test results/coverage
- Follow PEP 8
- Use type hints for all function signatures
- Maximum line length: 100 characters
- Use
async/awaitfor asynchronous code
- All public APIs must have docstrings
- Use Google-style docstrings:
async def approve_request(
request_id: str,
approver: str,
reason: str
) -> bool:
"""
Approve a pending request.
Args:
request_id: Unique identifier for the request
approver: Email or ID of the approver
reason: Reason for approval
Returns:
True if approval was successful
Raises:
ValueError: If request_id is invalid
"""
pass- Aim for >80% code coverage
- Write unit tests for all new code
- Include integration tests for features
- Test both success and failure cases
- Use descriptive test names
@pytest.mark.asyncio
async def test_approval_policy_blocks_execution_without_approval():
"""Test that ApprovalPolicy blocks execution when approval is not provided."""
# Test implementationgovernor/
├── governor/ # Main package
│ ├── core/ # Core execution engine
│ ├── policies/ # Policy implementations
│ ├── approval/ # Approval system
│ ├── background/ # Background job queue
│ ├── storage/ # Storage backends
│ ├── events/ # Event system
│ ├── compliance/ # Compliance modules
│ └── utils/ # Utilities
├── tests/ # Test suite
├── examples/ # Example code
└── docs/ # Documentation
- Create policy file in
governor/policies/ - Inherit from
Policybase class - Implement
evaluate()method - Add to
governor/policies/__init__.py - Write tests in
tests/test_policies.py - Add example in
examples/ - Update documentation
- Create backend file in
governor/storage/ - Inherit from
StorageBackendbase class - Implement all abstract methods
- Add to
governor/storage/__init__.py - Write tests in
tests/test_storage.py - Update
pyproject.tomlwith optional dependency - Add documentation
- Keep README.md up to date
- Add examples for new features
- Update DEPLOYMENT.md for infrastructure changes
- Include docstrings in all public APIs
Include:
- Governor version
- Python version
- Operating system
- Minimal reproducible example
- Expected vs actual behavior
- Stack trace if applicable
Include:
- Use case description
- Proposed API/interface
- Example code showing usage
- Alternative solutions considered
- Open a Discussion
- Join our community chat (if available)
- Check existing issues and documentation
By contributing, you agree that your contributions will be licensed under the MIT License.