fix: Comprehensive validation and bug fixes

Infrastructure:
- Add Redis and Celery workers to all docker-compose files
- Fix celery migration race condition in entrypoint.sh
- Add healthchecks and resource limits to dev compose
- Update .env.template with Redis/Celery variables

Backend Models & Schemas:
- Rename Sprint.completed_points to velocity (per requirements)
- Add AgentInstance.name as required field
- Rename Issue external tracker fields for consistency
- Add IssueSource and TrackerType enums
- Add Project.default_tracker_type field

Backend Fixes:
- Add Celery retry configuration with exponential backoff
- Remove unused sequence counter from EventBus
- Add mypy overrides for test dependencies
- Fix test file using wrong schema (UserUpdate -> dict)

Frontend Fixes:
- Fix memory leak in useProjectEvents (proper cleanup)
- Fix race condition with stale closure in reconnection
- Sync TokenWithUser type with regenerated API client
- Fix expires_in null handling in useAuth
- Clean up unused imports in prototype pages
- Add ESLint relaxed rules for prototype files

CI/CD:
- Add E2E testing stage with Testcontainers
- Add security scanning with Trivy and pip-audit
- Add dependency caching for faster builds

Tests:
- Update all tests to use renamed fields (velocity, name, etc.)
- Fix 14 schema test failures
- All 1500 tests pass with 91% coverage

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-30 10:35:30 +01:00
parent 6ea9edf3d1
commit 742ce4c9c8
57 changed files with 1062 additions and 332 deletions

View File

@@ -65,4 +65,5 @@ def valid_agent_instance_data(valid_uuid):
return {
"agent_type_id": valid_uuid,
"project_id": valid_uuid,
"name": "TestAgent",
}

View File

@@ -3,7 +3,6 @@
Tests for AgentInstance schema validation.
"""
import uuid
from decimal import Decimal
import pytest
@@ -41,6 +40,7 @@ class TestAgentInstanceCreateValidation:
instance = AgentInstanceCreate(
agent_type_id=valid_uuid,
project_id=valid_uuid,
name="WorkingAgent",
status=AgentStatus.WORKING,
current_task="Processing feature request",
short_term_memory={"context": "working"},
@@ -59,6 +59,7 @@ class TestAgentInstanceCreateValidation:
with pytest.raises(ValidationError) as exc_info:
AgentInstanceCreate(
project_id=valid_uuid,
name="TestAgent",
)
errors = exc_info.value.errors()
@@ -69,11 +70,23 @@ class TestAgentInstanceCreateValidation:
with pytest.raises(ValidationError) as exc_info:
AgentInstanceCreate(
agent_type_id=valid_uuid,
name="TestAgent",
)
errors = exc_info.value.errors()
assert any("project_id" in str(e).lower() for e in errors)
def test_agent_instance_create_name_required(self, valid_uuid):
"""Test that name is required."""
with pytest.raises(ValidationError) as exc_info:
AgentInstanceCreate(
agent_type_id=valid_uuid,
project_id=valid_uuid,
)
errors = exc_info.value.errors()
assert any("name" in str(e).lower() for e in errors)
class TestAgentInstanceUpdateValidation:
"""Tests for AgentInstanceUpdate schema validation."""
@@ -145,6 +158,7 @@ class TestAgentStatusEnum:
instance = AgentInstanceCreate(
agent_type_id=valid_uuid,
project_id=valid_uuid,
name=f"Agent{status.value}",
status=status,
)
assert instance.status == status
@@ -155,6 +169,7 @@ class TestAgentStatusEnum:
AgentInstanceCreate(
agent_type_id=valid_uuid,
project_id=valid_uuid,
name="TestAgent",
status="invalid", # type: ignore
)
@@ -167,6 +182,7 @@ class TestAgentInstanceShortTermMemory:
instance = AgentInstanceCreate(
agent_type_id=valid_uuid,
project_id=valid_uuid,
name="TestAgent",
short_term_memory={},
)
assert instance.short_term_memory == {}
@@ -185,6 +201,7 @@ class TestAgentInstanceShortTermMemory:
instance = AgentInstanceCreate(
agent_type_id=valid_uuid,
project_id=valid_uuid,
name="MemoryAgent",
short_term_memory=memory,
)
assert instance.short_term_memory == memory
@@ -200,6 +217,7 @@ class TestAgentInstanceStringFields:
instance = AgentInstanceCreate(
agent_type_id=valid_uuid,
project_id=valid_uuid,
name="TestAgent",
long_term_memory_ref=long_ref,
)
assert instance.long_term_memory_ref == long_ref
@@ -212,6 +230,7 @@ class TestAgentInstanceStringFields:
AgentInstanceCreate(
agent_type_id=valid_uuid,
project_id=valid_uuid,
name="TestAgent",
long_term_memory_ref=too_long,
)
@@ -225,6 +244,7 @@ class TestAgentInstanceStringFields:
instance = AgentInstanceCreate(
agent_type_id=valid_uuid,
project_id=valid_uuid,
name="TestAgent",
session_id=long_session,
)
assert instance.session_id == long_session
@@ -237,6 +257,7 @@ class TestAgentInstanceStringFields:
AgentInstanceCreate(
agent_type_id=valid_uuid,
project_id=valid_uuid,
name="TestAgent",
session_id=too_long,
)

View File

@@ -55,17 +55,17 @@ class TestIssueCreateValidation:
story_points=5,
assigned_agent_id=agent_id,
sprint_id=sprint_id,
external_tracker="gitea",
external_id="gitea-123",
external_url="https://gitea.example.com/issues/123",
external_number=123,
external_tracker_type="gitea",
external_issue_id="gitea-123",
remote_url="https://gitea.example.com/issues/123",
external_issue_number=123,
)
assert issue.status == IssueStatus.IN_PROGRESS
assert issue.priority == IssuePriority.HIGH
assert issue.labels == ["bug", "security"]
assert issue.story_points == 5
assert issue.external_tracker == "gitea"
assert issue.external_tracker_type == "gitea"
def test_issue_create_title_empty_fails(self, valid_uuid):
"""Test that empty title raises ValidationError."""
@@ -188,10 +188,10 @@ class TestIssueExternalTrackerValidation:
issue = IssueCreate(
project_id=valid_uuid,
title="Test Issue",
external_tracker=tracker,
external_id="ext-123",
external_tracker_type=tracker,
external_issue_id="ext-123",
)
assert issue.external_tracker == tracker
assert issue.external_tracker_type == tracker
def test_invalid_external_tracker(self, valid_uuid):
"""Test that invalid external tracker raises ValidationError."""
@@ -199,8 +199,8 @@ class TestIssueExternalTrackerValidation:
IssueCreate(
project_id=valid_uuid,
title="Test Issue",
external_tracker="invalid", # type: ignore
external_id="ext-123",
external_tracker_type="invalid", # type: ignore
external_issue_id="ext-123",
)

View File

@@ -34,7 +34,7 @@ class TestSprintCreateValidation:
assert sprint.status == SprintStatus.PLANNED
assert sprint.goal is None
assert sprint.planned_points is None
assert sprint.completed_points is None
assert sprint.velocity is None
def test_sprint_create_with_all_fields(self, valid_uuid):
"""Test creating sprint with all optional fields."""
@@ -49,7 +49,7 @@ class TestSprintCreateValidation:
end_date=today + timedelta(days=14),
status=SprintStatus.PLANNED,
planned_points=21,
completed_points=0,
velocity=0,
)
assert sprint.name == "Full Sprint"
@@ -252,8 +252,8 @@ class TestSprintPointsValidation:
errors = exc_info.value.errors()
assert any("planned_points" in str(e).lower() for e in errors)
def test_valid_completed_points(self, valid_uuid):
"""Test valid completed_points values."""
def test_valid_velocity(self, valid_uuid):
"""Test valid velocity values."""
today = date.today()
for points in [0, 5, 21]:
@@ -263,26 +263,26 @@ class TestSprintPointsValidation:
number=1,
start_date=today,
end_date=today + timedelta(days=14),
completed_points=points,
velocity=points,
)
assert sprint.completed_points == points
assert sprint.velocity == points
def test_completed_points_negative_fails(self, valid_uuid):
"""Test that negative completed_points raises ValidationError."""
def test_velocity_negative_fails(self, valid_uuid):
"""Test that negative velocity raises ValidationError."""
today = date.today()
with pytest.raises(ValidationError) as exc_info:
SprintCreate(
project_id=valid_uuid,
name="Negative Completed Sprint",
name="Negative Velocity Sprint",
number=1,
start_date=today,
end_date=today + timedelta(days=14),
completed_points=-1,
velocity=-1,
)
errors = exc_info.value.errors()
assert any("completed_points" in str(e).lower() for e in errors)
assert any("velocity" in str(e).lower() for e in errors)
class TestSprintUpdateValidation:
@@ -310,7 +310,7 @@ class TestSprintUpdateValidation:
end_date=today + timedelta(days=21),
status=SprintStatus.ACTIVE,
planned_points=34,
completed_points=20,
velocity=20,
)
assert update.name == "Updated Name"