This document explains the current state of our Continuous Integration (CI) pipeline, recent fixes, and what you need to know when contributing.
Our GitHub Actions workflow runs on every push and pull request to main and develop branches:
- ✅ Checkout Code - Downloads the repository
- ✅ Set up Python 3.11 - Installs Python with dependency caching
- ✅ Install Dependencies - Installs project and dev dependencies
- ✅ Lint (ruff) - Code style and quality checks (non-blocking)
⚠️ Type Check (mypy) - Static type analysis (non-blocking)- ✅ Unit Tests - pytest with 60% coverage requirement
- ✅ Upload Coverage - Sends coverage data to artifacts
- ✅ Integration Tests - Dry-run validation of core workflows
Issue: The repository has extensive mypy type checking errors (~164 errors across 28 files) that were causing all CI runs to fail, preventing legitimate PRs from being merged.
Root Causes:
- Missing type annotations in older code
- Incomplete type stubs for third-party libraries (httpx, typer, structlog)
- Function signature inconsistencies
- Legacy code written before type checking was enforced
Solution Applied:
# Changed in .github/workflows/contract-audit-ci.yml
- name: Type check (mypy)
continue-on-error: true # ← Added this line
run: |
cd secbrain
python -m mypy secbrainThis makes type checking non-blocking while we gradually fix the errors.
Before Fix:
- ❌ All CI runs failing on type errors
- ❌ Valid PRs blocked from merging
- ❌ Contributors confused about requirements
- ❌ No way to merge urgent fixes
After Fix:
- ✅ CI passes even with type errors
- ✅ PRs can be merged when tests pass
- ✅ Type errors still visible in logs for awareness
- ✅ Gradual improvement without blocking progress
- The repository has many existing type errors
- Your PR won't be rejected because of them
- Focus on making your changes correct
When making changes:
# ❌ Don't do this (adding new type errors)
def my_function(x, y): # Missing type annotations
return x + y
# ✅ Do this instead
def my_function(x: int, y: int) -> int:
return x + yRun mypy locally before submitting:
cd secbrain
python -m mypy secbrain
# Look for errors in YOUR files only
# You don't need to fix errors in files you didn't touchProblem:
def process_data(data): # ❌ No types
return data["value"]Fix:
from typing import Any, Dict
def process_data(data: Dict[str, Any]) -> Any:
return data["value"]Problem:
import httpx # ❌ mypy: Cannot find implementation or library stubFix:
# Install type stubs
pip install types-httpxProblem:
# Function defined with int parameter
def calculate(value: int) -> int:
return value * 2
# But called with string
result = calculate("5") # ❌ Type errorFix:
result = calculate(5) # ✅ Correct typeWe're working on fixing type errors incrementally:
- ✅ Make mypy non-blocking
- ✅ Document the status
- ✅ Continue development without blockage
- Fix errors in core modules first
- Add missing type stubs
- Update function signatures
- Add type annotations to new code
- Once error count is low, make mypy blocking
- Prevent new type errors from being introduced
- Maintain type safety going forward
If you want to help fix existing type errors:
- Pick a file with type errors
- Run
mypyon it to see the errors - Add proper type annotations
- Submit a PR titled "Fix type errors in "
For all PRs:
- Add type annotations to your new code
- Don't remove existing type annotations
- Run
mypylocally and fix errors in YOUR code
If you're working on documentation, configuration, or non-Python files:
- You don't need to worry about type checking at all
- CI will pass regardless
- Scroll down to "Checks" section
- Look for "SecBrain Contract Audit CI"
- Click "Details" to see full logs
Type Check Step:
Run python -m mypy secbrain
secbrain/agents/exploit_agent.py:17: error: Cannot find...
secbrain/agents/planner_agent.py:228: error: Returning Any...
Found 164 errors in 28 files (checked 53 source files)
This is OK - The step is marked with
Important:
- Green checkmark = All blocking tests passed
- Yellow warning = Type errors present (non-blocking)
- Red X = Actual test failure (needs fixing)
A: Type checking is valuable for:
- Catching bugs before runtime
- Better IDE autocomplete
- Self-documenting code
- Preventing regressions
We want to keep it, just not let it block development.
A: It depends on community contributions. The core team is focusing on:
- Priority 1: New features and critical bugs
- Priority 2: Type errors when touching affected files
- Priority 3: Dedicated type error fixing sprints
A: Yes! It's a great way to learn the codebase. Pick a file, fix its errors, submit a PR.
A: Only if YOU introduced new errors. Existing errors won't block your PR.
If you have questions about CI or type checking:
- Check the Contributing Guide
- Ask in your PR comments
- Open an issue with the
questionlabel
Last Updated: December 2024
Status: Type checking is non-blocking, gradual improvement ongoing