Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -9,61 +9,61 @@
# ============================================================================
# Default Owners (catch-all for any file not matching specific rules)
# ============================================================================
* @alex
* @anchapin

# ============================================================================
# Frontend Team - React/TypeScript UI Components
# ============================================================================
# All frontend-related files require review from frontend maintainers
/frontend/ @alex
/frontend/ @anchapin

# ============================================================================
# Backend Team - Python API and Server
# ============================================================================
# All backend-related files require review from backend maintainers
/backend/ @alex
/backend/ @anchapin

# ============================================================================
# AI-Engine Team - ML/AI Components
# ============================================================================
# All AI engine-related files require review from AI engine maintainers
/ai-engine/ @alex
/ai-engine/ @anchapin

# ============================================================================
# Infrastructure & DevOps
# ============================================================================
# Docker and infrastructure configurations
/docker/ @alex
docker-compose*.yml @alex
Dockerfile* @alex
/docker/ @anchapin
docker-compose*.yml @anchapin
Dockerfile* @anchapin

# ============================================================================
# Security & Compliance
# ============================================================================
# Security-related files require review from security team
/.github/security-check.sh @alex
/.github/security-config-guide.md @alex
/.github/security-check.sh @anchapin
/.github/security-config-guide.md @anchapin

# ============================================================================
# Documentation
# ============================================================================
# Documentation changes can be reviewed by any maintainer
/docs/ @alex
*.md @alex
/docs/ @anchapin
*.md @anchapin
!/.github/*.md

# ============================================================================
# Configuration Files
# ============================================================================
# Project-wide configuration files
/.github/ @alex
/database/ @alex
/monitoring/ @alex
/scripts/ @alex
/modporter/ @alex
/tests/ @alex
/.github/ @anchapin
/database/ @anchapin
/monitoring/ @anchapin
/scripts/ @anchapin
/modporter/ @anchapin
/tests/ @anchapin

# ============================================================================
# CI/CD Workflows
# ============================================================================
/.github/workflows/ @alex
/.github/workflows/ @anchapin
9 changes: 5 additions & 4 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ assignees: ''
---

**Priority**
- [ ] P1 - Critical: System completely broken, data loss
- [ ] P2 - High: Major functionality broken
- [ ] P3 - Medium: Minor functionality affected
- [ ] P4 - Low: Minor issue, cosmetic
- [ ] P1 - Critical (System down, data loss)
- [ ] P2 - High (Major functionality broken)
- [ ] P3 - Medium (Minor functionality affected)
- [ ] P4 - Low (Cosmetic or minor issue)

**Component**
- [ ] Backend
- [ ] Frontend
- [ ] AI Engine
- [ ] Database
- [ ] CLI
- [ ] Documentation
- [ ] CI/CD
- [ ] Other
Expand Down
27 changes: 14 additions & 13 deletions .github/ISSUE_TEMPLATE/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,29 @@ assignees: ''
---

**Priority**
- [ ] P1 - Critical: System cannot start or deploy
- [ ] P2 - High: Major configuration issue
- [ ] P3 - Medium: Minor configuration issue
- [ ] P4 - Low: Cosmetic or improvement

**Type of configuration issue**
- [ ] Environment variable
- [ ] Docker configuration
- [ ] API configuration
- [ ] Build configuration
- [ ] Runtime configuration
- [ ] Other
- [ ] P1 - Critical (System down, data loss)
- [ ] P2 - High (Major functionality broken)
- [ ] P3 - Medium (Minor functionality affected)
- [ ] P4 - Low (Cosmetic or minor issue)

**Component**
Which component is this issue related to?
- [ ] Backend
- [ ] Frontend
- [ ] AI Engine
- [ ] Database
- [ ] CLI
- [ ] Documentation
- [ ] CI/CD
- [ ] Other

**Type of configuration issue**
- [ ] Environment variable
- [ ] Docker configuration
- [ ] API configuration
- [ ] Build configuration
- [ ] Runtime configuration
- [ ] Other

**Describe the issue**
A clear and concise description of the configuration issue.

Expand Down
9 changes: 5 additions & 4 deletions .github/ISSUE_TEMPLATE/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ assignees: ''
---

**Priority**
- [ ] P1 - Critical: Documentation missing for critical feature
- [ ] P2 - High: Major documentation issue
- [ ] P3 - Medium: Minor documentation issue
- [ ] P4 - Low: Cosmetic or low priority
- [ ] P1 - Critical (System down, data loss)
- [ ] P2 - High (Major functionality broken)
- [ ] P3 - Medium (Minor functionality affected)
- [ ] P4 - Low (Cosmetic or minor issue)

**Component**
- [ ] Backend
- [ ] Frontend
- [ ] AI Engine
- [ ] Database
- [ ] CLI
- [ ] Documentation
- [ ] CI/CD
- [ ] Other
Expand Down
9 changes: 5 additions & 4 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ assignees: ''
---

**Priority**
- [ ] P1 - Critical: Must have for project success
- [ ] P2 - High: Important feature
- [ ] P3 - Medium: Nice to have
- [ ] P4 - Low: Future consideration
- [ ] P1 - Critical (System down, data loss)
- [ ] P2 - High (Major functionality broken)
- [ ] P3 - Medium (Minor functionality affected)
- [ ] P4 - Low (Cosmetic or minor issue)

**Component**
- [ ] Backend
- [ ] Frontend
- [ ] AI Engine
- [ ] Database
- [ ] CLI
- [ ] Documentation
- [ ] CI/CD
- [ ] Other
Expand Down
9 changes: 5 additions & 4 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ assignees: ''
---

**Priority**
- [ ] P1 - Critical: Urgent question blocking progress
- [ ] P2 - High: Important question
- [ ] P3 - Medium: General question
- [ ] P4 - Low: Curiosity
- [ ] P1 - Critical (System down, data loss)
- [ ] P2 - High (Major functionality broken)
- [ ] P3 - Medium (Minor functionality affected)
- [ ] P4 - Low (Cosmetic or minor issue)

**Component**
- [ ] Backend
- [ ] Frontend
- [ ] AI Engine
- [ ] Database
- [ ] CLI
- [ ] Documentation
- [ ] CI/CD
- [ ] Other
Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,20 +190,36 @@ curl http://localhost:8080/health/liveness
# Check AI engine health
curl http://localhost:8001/api/v1/health

# Check AI engine readiness (Redis dependency check)
curl http://localhost:8001/health/readiness

# Check AI engine liveness (process running)
curl http://localhost:8001/health/liveness

# Check all service status
docker compose ps
```

### Health Check Endpoints

The backend provides three health check endpoints for Kubernetes probes:
The backend and AI engine provide health check endpoints for Kubernetes probes:

#### Backend (port 8080)

| Endpoint | Purpose | Dependencies Checked |
|----------|---------|---------------------|
| `/health` | Basic health check | None |
| `/health/liveness` | Process is running | None |
| `/health/readiness` | Can serve traffic | Database, Redis |

#### AI Engine (port 8001)

| Endpoint | Purpose | Dependencies Checked |
|----------|---------|---------------------|
| `/api/v1/health` | Basic health check | Assumption engine |
| `/health/liveness` | Process running | None |
| `/health/readiness` | Can serve traffic | Redis |

**Response Format:**
```json
{
Expand Down
104 changes: 104 additions & 0 deletions ai-engine/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pydantic import BaseModel, Field
from typing import Dict, List, Any, Optional
from datetime import datetime
import time
from enum import Enum
import uvicorn
import os
Expand Down Expand Up @@ -165,6 +166,22 @@ class HealthResponse(BaseModel):
timestamp: str
services: Dict[str, str]


class DependencyHealth(BaseModel):
"""Individual dependency health status"""
name: str
status: str
latency_ms: float = 0.0
message: str = ""


class HealthStatus(BaseModel):
"""Health check response model for readiness/liveness"""
status: str = Field(..., description="Overall health status: healthy, degraded, or unhealthy")
timestamp: str = Field(..., description="ISO timestamp of the health check")
checks: Dict[str, Any] = Field(..., description="Individual check results")


class ConversionRequest(BaseModel):
"""Conversion request model"""
job_id: str = Field(..., description="Unique job identifier")
Expand Down Expand Up @@ -240,6 +257,93 @@ async def health_check():
services=services
)


async def check_redis_health() -> DependencyHealth:
"""
Check Redis connectivity and return health status.
"""
start_time = time.time()

try:
if not redis_client:
return DependencyHealth(
name="redis",
status="unhealthy",
latency_ms=0.0,
message="Redis client not initialized"
)

# Try a simple Redis operation
await redis_client.ping()

latency_ms = (time.time() - start_time) * 1000

return DependencyHealth(
name="redis",
status="healthy",
latency_ms=latency_ms,
message="Redis connection successful"
)
except Exception as e:
latency_ms = (time.time() - start_time) * 1000
logger.error(f"Redis health check failed: {e}")

Comment on lines +287 to +290
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error logging here drops stack trace context (exc_info=True), while other error logs in this file include it. Log the exception with stack trace to make health-check failures diagnosable in production.

Copilot uses AI. Check for mistakes.
return DependencyHealth(
name="redis",
status="unhealthy",
latency_ms=latency_ms,
message=f"Redis connection failed: {str(e)}"
)


@app.get("/health/readiness", response_model=HealthStatus, tags=["health"])
async def readiness_check():
"""
Readiness probe - checks if the application can serve traffic.

This endpoint verifies that all required dependencies (Redis) are available.
The application should only receive traffic when this endpoint returns healthy.
"""
checks = []

# Check Redis
redis_health = await check_redis_health()
checks.append(redis_health)

# Determine overall status
unhealthy_checks = [c for c in checks if c.status == "unhealthy"]

if unhealthy_checks:
status = "unhealthy"
else:
status = "healthy"

return HealthStatus(
status=status,
timestamp=datetime.utcnow().isoformat(),
checks={
"dependencies": {
c.name: {"status": c.status, "latency_ms": c.latency_ms, "message": c.message}
for c in checks
}
}
)


@app.get("/health/liveness", response_model=HealthStatus, tags=["health"])
async def liveness_check():
"""
Liveness probe - checks if the application is running and doesn't need restart.

This endpoint verifies that the application process is running and can handle requests.
"""
return HealthStatus(
status="healthy",
timestamp=datetime.utcnow().isoformat(),
checks={"application": {"status": "running", "message": "Application process is running"}}
)
Comment on lines +299 to +344
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New readiness/liveness endpoints are added here, but there are no tests asserting their status codes and response schema (including when Redis is unavailable). Add focused tests in ai-engine/tests/ for /health/liveness and /health/readiness so regressions are caught in CI.

Copilot generated this review using guidance from repository custom instructions.


@app.post("/api/v1/convert", response_model=ConversionResponse, tags=["conversion"])
async def start_conversion(
request: ConversionRequest,
Expand Down
12 changes: 11 additions & 1 deletion ai-engine/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,14 @@ pydantic-settings
# Monitoring
prometheus-client
psutil
structlog>=24.0.0
structlog>=24.0.0

# Distributed Tracing (OpenTelemetry)
opentelemetry-api>=1.24.0
opentelemetry-sdk>=1.24.0
opentelemetry-exporter-otlp>=1.24.0
# Note: opentelemetry-exporter-jaeger 1.21.0 is the latest version compatible with Python 3.11
opentelemetry-exporter-jaeger==1.21.0
opentelemetry-instrumentation-fastapi>=0.45b0
opentelemetry-instrumentation-httpx>=0.45b0
opentelemetry-instrumentation-redis>=0.45b0
Comment on lines +54 to +62
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenTelemetry dependencies are added here, but there’s no AI engine instrumentation/configuration in the codebase. Either include the wiring (FastAPI/httpx/redis instrumentation + exporter configuration) or drop these requirements to keep the runtime lean.

Copilot uses AI. Check for mistakes.
Loading
Loading