Contributing to The DETERMINATOR¶
Thank you for your interest in contributing to The DETERMINATOR! This guide will help you get started.
Note on Project Names: "The DETERMINATOR" is the product name, "DeepCritical" is the organization/project name, and "determinator" is the Python package name.
Git Workflow¶
main: Production-ready (GitHub)dev: Development integration (GitHub)- Use feature branches:
yourname-dev - NEVER push directly to
mainordevon HuggingFace - GitHub is source of truth; HuggingFace is for deployment
Repository Information¶
- GitHub Repository:
DeepCritical/GradioDemo(source of truth, PRs, code review) - HuggingFace Space:
DataQuests/DeepCritical(deployment/demo) - Package Name:
determinator(Python package name inpyproject.toml)
Dual Repository Setup¶
This project uses a dual repository setup:
- GitHub (
DeepCritical/GradioDemo): Source of truth for code, PRs, and code review - HuggingFace (
DataQuests/DeepCritical): Deployment target for the Gradio demo
Remote Configuration¶
When cloning, set up remotes as follows:
# Clone from GitHub
git clone https://github.com/DeepCritical/GradioDemo.git
cd GradioDemo
# Add HuggingFace remote (optional, for deployment)
git remote add huggingface-upstream https://huggingface.co/spaces/DataQuests/DeepCritical
Important: Never push directly to main or dev on HuggingFace. Always work through GitHub PRs. GitHub is the source of truth; HuggingFace is for deployment/demo only.
Package Manager¶
This project uses uv as the package manager. All commands should be prefixed with uv run to ensure they run in the correct environment.
Installation¶
# Install uv if you haven't already (recommended: standalone installer)
# Unix/macOS/Linux:
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows (PowerShell):
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
# Alternative: pipx install uv
# Or: pip install uv
# Sync all dependencies including dev extras
uv sync --all-extras
# Install pre-commit hooks
uv run pre-commit install
Development Commands¶
# Installation
uv sync --all-extras # Install all dependencies including dev
uv run pre-commit install # Install pre-commit hooks
# Code Quality Checks (run all before committing)
uv run ruff check src tests # Lint with ruff
uv run ruff format src tests # Format with ruff
uv run mypy src # Type checking
uv run pytest --cov=src --cov-report=term-missing tests/unit/ -v -m "not openai" -p no:logfire # Tests with coverage
# Testing Commands
uv run pytest tests/unit/ -v -m "not openai" -p no:logfire # Run unit tests (excludes OpenAI tests)
uv run pytest tests/ -v -m "huggingface" -p no:logfire # Run HuggingFace tests
uv run pytest tests/ -v -p no:logfire # Run all tests
uv run pytest --cov=src --cov-report=term-missing tests/unit/ -v -m "not openai" -p no:logfire # Tests with terminal coverage
uv run pytest --cov=src --cov-report=html -p no:logfire # Generate HTML coverage report (opens htmlcov/index.html)
# Documentation Commands
uv run mkdocs build # Build documentation
uv run mkdocs serve # Serve documentation locally (http://127.0.0.1:8000)
Test Markers¶
The project uses pytest markers to categorize tests. See Testing Guidelines for details:
unit: Unit tests (mocked, fast)integration: Integration tests (real APIs)slow: Slow testsopenai: Tests requiring OpenAI API keyhuggingface: Tests requiring HuggingFace API keyembedding_provider: Tests requiring API-based embedding providerslocal_embeddings: Tests using local embeddings
Note: The -p no:logfire flag disables the logfire plugin to avoid conflicts during testing.
Getting Started¶
-
Fork the repository on GitHub:
DeepCritical/GradioDemo -
Clone your fork:
- Install dependencies:
- Create a feature branch:
-
Make your changes following the guidelines below
-
Run checks:
uv run ruff check src tests
uv run mypy src
uv run pytest --cov=src --cov-report=term-missing tests/unit/ -v -m "not openai" -p no:logfire
- Commit and push:
- Create a pull request on GitHub
Development Guidelines¶
Code Style¶
- Follow Code Style Guidelines
- All code must pass
mypy --strict - Use
rufffor linting and formatting - Line length: 100 characters
Error Handling¶
- Follow Error Handling Guidelines
- Always chain exceptions:
raise SearchError(...) from e - Use structured logging with
structlog - Never silently swallow exceptions
Testing¶
- Follow Testing Guidelines
- Write tests before implementation (TDD)
- Aim for >80% coverage on critical paths
- Use markers:
unit,integration,slow
Implementation Patterns¶
- Follow Implementation Patterns
- Use factory functions for agent/tool creation
- Implement protocols for extensibility
- Use singleton pattern with
@lru_cache(maxsize=1)
Prompt Engineering¶
- Follow Prompt Engineering Guidelines
- Always validate citations
- Use diverse evidence selection
- Never trust LLM-generated citations without validation
Code Quality¶
- Follow Code Quality Guidelines
- Google-style docstrings for all public functions
- Explain WHY, not WHAT in comments
- Mark critical sections:
# CRITICAL: ...
MCP Integration¶
MCP Tools¶
- Functions in
src/mcp_tools.pyfor Claude Desktop - Full type hints required
- Google-style docstrings with Args/Returns sections
- Formatted string returns (markdown)
Gradio MCP Server¶
- Enable with
mcp_server=Trueindemo.launch() - Endpoint:
/gradio_api/mcp/ - Use
ssr_mode=Falseto fix hydration issues in HF Spaces
Common Pitfalls¶
- Blocking the event loop: Never use sync I/O in async functions
- Missing type hints: All functions must have complete type annotations
- Hallucinated citations: Always validate references
- Global mutable state: Use ContextVar or pass via parameters
- Import errors: Lazy-load optional dependencies (magentic, modal, embeddings)
- Rate limiting: Always implement for external APIs
- Error chaining: Always use
from ewhen raising exceptions
Key Principles¶
- Type Safety First: All code must pass
mypy --strict - Async Everything: All I/O must be async
- Test-Driven: Write tests before implementation
- No Hallucinations: Validate all citations
- Graceful Degradation: Support free tier (HF Inference) when no API keys
- Lazy Loading: Don't require optional dependencies at import time
- Structured Logging: Use structlog, never print()
- Error Chaining: Always preserve exception context
Pull Request Process¶
- Ensure all checks pass:
uv run ruff check src tests && uv run mypy src && uv run pytest --cov=src --cov-report=term-missing tests/unit/ -v -m "not openai" -p no:logfire - Update documentation if needed
- Add tests for new features
- Update CHANGELOG if applicable
- Request review from maintainers
- Address review feedback
- Wait for approval before merging
Project Structure¶
src/: Main source codetests/: Test files (unit/andintegration/)docs/: Documentation source files (MkDocs)examples/: Example usage scriptspyproject.toml: Project configuration and dependencies.pre-commit-config.yaml: Pre-commit hook configuration
Questions?¶
- Open an issue on GitHub
- Check existing documentation
- Review code examples in the codebase
Thank you for contributing to The DETERMINATOR!