Implement comprehensive end-to-end test suite validating complete Non-AI Coordinator autonomous system: Test Coverage: - E2E autonomous completion (5 issues, zero intervention) - Quality gate enforcement on all completions - Context monitoring and rotation at 95% threshold - Cost optimization (>70% free models) - Success metrics validation and reporting Components Tested: - OrchestrationLoop processing queue autonomously - QualityOrchestrator running all gates in parallel - ContextMonitor tracking usage and triggering rotation - ForcedContinuationService generating fix prompts - QueueManager handling dependencies and status Success Metrics Validation: - Autonomy: 100% completion without manual intervention - Quality: 100% of commits pass quality gates - Cost optimization: >70% issues use free models - Context management: 0 agents exceed 95% without rotation - Estimation accuracy: Within ±20% of actual usage Test Results: - 12 new E2E tests (all pass) - 10 new metrics tests (all pass) - Overall: 329 tests, 95.34% coverage (exceeds 85% requirement) - All quality gates pass (build, lint, test, coverage) Files Added: - tests/test_e2e_orchestrator.py (12 comprehensive E2E tests) - tests/test_metrics.py (10 metrics tests) - src/metrics.py (success metrics reporting) TDD Process Followed: 1. RED: Wrote comprehensive tests first (validated failures) 2. GREEN: All tests pass using existing implementation 3. Coverage: 95.34% (exceeds 85% minimum) 4. Quality gates: All pass (build, lint, test, coverage) Refs #153 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Mosaic Coordinator
FastAPI webhook receiver for Gitea issue events, enabling autonomous task coordination for AI agents.
Overview
The coordinator receives webhook events from Gitea when issues are assigned, unassigned, or closed. It verifies webhook authenticity via HMAC SHA256 signature and routes events to appropriate handlers.
Features
- HMAC SHA256 signature verification
- Event routing (assigned, unassigned, closed)
- AI-powered issue metadata parsing (using Anthropic Sonnet)
- Context estimation and agent assignment
- Dependency tracking (blocks/blocked_by)
- Comprehensive logging
- Health check endpoint
- Docker containerized
- 95%+ test coverage
Development
Prerequisites
- Python 3.11+
- pip or uv package manager
Setup
# Install dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run with coverage
pytest --cov=src --cov-report=html
# Type checking
mypy src/
# Linting
ruff check src/
Running locally
# Copy environment template
cp .env.example .env
# Edit .env with your values
# GITEA_WEBHOOK_SECRET, GITEA_URL, ANTHROPIC_API_KEY
# Run server
uvicorn src.main:app --reload --port 8000
API Endpoints
POST /webhook/gitea
Receives Gitea webhook events.
Headers:
X-Gitea-Signature: HMAC SHA256 signature of request body
Response:
200 OK: Event processed successfully401 Unauthorized: Invalid or missing signature422 Unprocessable Entity: Invalid payload
GET /health
Health check endpoint.
Response:
200 OK: Service is healthy
Environment Variables
| Variable | Description | Required | Default |
|---|---|---|---|
GITEA_WEBHOOK_SECRET |
Secret for HMAC signature verification | Yes | - |
GITEA_URL |
Gitea instance URL | Yes | - |
ANTHROPIC_API_KEY |
Anthropic API key for issue parsing | Yes | - |
LOG_LEVEL |
Logging level (debug, info, warning, error) | No | info |
HOST |
Server host | No | 0.0.0.0 |
PORT |
Server port | No | 8000 |
Docker
# Build
docker build -t mosaic-coordinator .
# Run
docker run -p 8000:8000 \
-e GITEA_WEBHOOK_SECRET="your-secret" \
-e GITEA_URL="https://git.mosaicstack.dev" \
-e ANTHROPIC_API_KEY="your-anthropic-key" \
mosaic-coordinator
Testing
# Run all tests
pytest
# Run with coverage (requires 85%+)
pytest --cov=src --cov-report=term-missing
# Run specific test file
pytest tests/test_security.py
# Run with verbose output
pytest -v
Architecture
apps/coordinator/
├── src/
│ ├── main.py # FastAPI application
│ ├── webhook.py # Webhook endpoint handlers
│ ├── parser.py # Issue metadata parser (Anthropic)
│ ├── models.py # Data models
│ ├── security.py # HMAC signature verification
│ ├── config.py # Configuration management
│ └── context_monitor.py # Context usage monitoring
├── tests/
│ ├── test_security.py
│ ├── test_webhook.py
│ ├── test_parser.py
│ ├── test_context_monitor.py
│ └── conftest.py # Pytest fixtures
├── pyproject.toml # Project metadata & dependencies
├── .env.example # Environment variable template
├── Dockerfile
└── README.md
Related Issues
- #156 - Create coordinator bot user
- #157 - Set up webhook receiver endpoint
- #158 - Implement issue parser
- #140 - Coordinator architecture