Felipe Cardoso
2edfbe7158
fix(backend): critical bug fixes for agent termination and sprint validation
...
Bug Fixes:
- bulk_terminate_by_project now unassigns issues before terminating agents
to prevent orphaned issue assignments
- PATCH /issues/{id} now validates sprint status - cannot assign issues
to COMPLETED or CANCELLED sprints
- archive_project now performs cascading cleanup:
- Terminates all active agent instances
- Cancels all planned/active sprints
- Unassigns issues from terminated agents
Added edge case tests for all fixed bugs (19 new tests total):
- TestBulkTerminateEdgeCases
- TestSprintStatusValidation
- TestArchiveProjectCleanup
- TestDataIntegrityEdgeCases (IDOR protection)
Coverage: 93% (1836 tests passing)
2025-12-31 15:23:21 +01:00
Felipe Cardoso
54f3a13ec7
fix(agents): prevent issue assignment to terminated agents and cleanup on termination
...
This commit fixes 4 production bugs found via edge case testing:
1. BUG: System allowed assigning issues to terminated agents
- Added validation in issue creation endpoint
- Added validation in issue update endpoint
- Added validation in issue assign endpoint
2. BUG: Issues remained orphaned when agent was terminated
- Agent termination now auto-unassigns all issues from that agent
These bugs could lead to issues being assigned to non-functional agents
that would never work on them, causing work to stall silently.
Tests added in tests/api/routes/syndarix/test_edge_cases.py to verify:
- Cannot assign issue to terminated agent (3 variations)
- Issues are auto-unassigned when agent is terminated
- Various other edge cases (sprints, projects, IDOR protection)
Coverage: 88% → 93% (1830 tests passing)
2025-12-31 14:43:08 +01:00
Felipe Cardoso
5920bc5599
test(sprints): add sprint issues and IDOR prevention tests
...
- Add TestSprintIssues class (5 tests)
- List sprint issues (empty/with data)
- Add issue to sprint
- Add nonexistent issue to sprint
- Add TestSprintCrossProjectValidation class (3 tests)
- IDOR prevention for get/update/start through wrong project
Coverage: sprints.py 72% → 76%
2025-12-31 14:04:05 +01:00
Felipe Cardoso
e4fb1d22e5
test(syndarix): add agent_types and enhance issues API tests
...
- Add comprehensive test_agent_types.py (36 tests)
- CRUD operations (create, read, update, deactivate)
- Authorization (superuser vs regular user)
- Pagination and filtering
- Slug lookup functionality
- Model configuration validation
- Enhance test_issues.py (15 new tests, total 39)
- Issue assignment/unassignment endpoints
- Issue sync endpoint
- Cross-project validation (IDOR prevention)
- Validation error handling
- Sprint/agent reference validation
Coverage improvements:
- agent_types.py: 41% → 83%
- issues.py: 55% → 75%
- Overall: 88% → 89%
2025-12-31 14:00:11 +01:00
Felipe Cardoso
841028c8c0
test(agents): add comprehensive API route tests
...
Add 22 tests for agents API covering:
- CRUD operations (spawn, list, get, update, delete)
- Lifecycle management (pause, resume)
- Agent metrics (single and project-level)
- Authorization and access control
- Status filtering
2025-12-31 13:20:25 +01:00
Felipe Cardoso
62c33d4565
test(issues): add comprehensive API route tests
...
Add 24 tests for issues API covering:
- CRUD operations (create, list, get, update, delete)
- Status and priority filtering
- Search functionality
- Issue statistics
- Authorization and access control
2025-12-31 13:20:17 +01:00
Felipe Cardoso
3a72d4e2f7
test(sprints): add comprehensive API route tests
...
Add 28 tests for sprints API covering:
- CRUD operations (create, list, get, update)
- Lifecycle management (start, complete, cancel)
- Sprint velocity endpoint
- Authorization and access control
- Pagination and filtering
2025-12-31 13:20:09 +01:00
Felipe Cardoso
7640ad2b48
test(projects): add comprehensive API route tests
...
Add 46 tests for projects API covering:
- CRUD operations (create, list, get, update, archive)
- Lifecycle management (pause, resume)
- Authorization and access control
- Pagination and filtering
- All autonomy levels
2025-12-31 13:20:01 +01:00