--- task_id: sprint_2_story_1_task_5 story: sprint_2_story_1 status: not_started estimated_hours: 3 created_date: 2025-11-05 assignee: Backend Team --- # Task 5: Integrate with ProjectManagement Module **Story**: Story 1 - Audit Log Foundation (Phase 1) **Estimated**: 3 hours ## Description Integrate the audit logging infrastructure with the existing ProjectManagement Module to ensure all Epic/Story/Task operations are automatically audited. ## Acceptance Criteria - [ ] Audit logging works for Project CRUD operations - [ ] Audit logging works for Epic CRUD operations - [ ] Audit logging works for Story CRUD operations - [ ] Audit logging works for Task CRUD operations - [ ] Integration tests verify audit logs are created - [ ] No performance degradation (< 5ms overhead) ## Implementation Details **No Code Changes Required** - The EF Core Interceptor automatically captures all changes! **Verification Steps**: 1. **Run Integration Tests**: ```bash cd colaflow-api dotnet test --filter "FullyQualifiedName~ProjectManagement.IntegrationTests" ``` 2. **Verify Audit Logs Created**: - Create a Project → Check AuditLog table for "Create" entry - Update an Epic → Check AuditLog table for "Update" entry - Delete a Story → Check AuditLog table for "Delete" entry 3. **Performance Benchmark**: ```csharp // Add to integration tests [Fact] public async Task CreateProject_ShouldHaveMinimalPerformanceOverhead() { // Measure time with audit logging enabled var stopwatch = Stopwatch.StartNew(); await Mediator.Send(new CreateProjectCommand { /* ... */ }); stopwatch.Stop(); Assert.True(stopwatch.ElapsedMilliseconds < 100, "Project creation took too long"); } ``` **Files to Update**: 1. **Integration Test Verification**: `colaflow-api/tests/ColaFlow.Application.IntegrationTests/ProjectManagement/AuditLogIntegrationTests.cs` ```csharp public class AuditLogIntegrationTests : IntegrationTestBase { [Fact] public async Task CreateProject_ShouldCreateAuditLog() { // Arrange var command = new CreateProjectCommand { Name = "Test Project", Key = "TEST", Description = "Test Description" }; // Act var projectId = await Mediator.Send(command); // Assert var auditLogs = await Context.AuditLogs .Where(a => a.EntityType == "Project" && a.EntityId == projectId) .ToListAsync(); Assert.Single(auditLogs); Assert.Equal(AuditAction.Create, auditLogs[0].Action); Assert.Equal(TenantId, auditLogs[0].TenantId); } [Fact] public async Task UpdateEpic_ShouldCreateAuditLog_WithOldAndNewValues() { // Create Epic first var epicId = await CreateTestEpic(); // Update Epic await Mediator.Send(new UpdateEpicCommand { EpicId = epicId, Title = "Updated Title" }); // Assert audit log created var auditLogs = await Context.AuditLogs .Where(a => a.EntityType == "Epic" && a.EntityId == epicId && a.Action == AuditAction.Update) .ToListAsync(); Assert.Single(auditLogs); Assert.NotNull(auditLogs[0].OldValues); Assert.NotNull(auditLogs[0].NewValues); } [Fact] public async Task DeleteTask_ShouldCreateAuditLog() { // Test delete operation audit logging // ... } } ``` ## Technical Notes - The SaveChangesInterceptor automatically captures all EF Core operations - No changes to Command Handlers required - Verify multi-tenant isolation works correctly - Check audit logs in database after each operation ## Testing **Integration Tests to Create**: 1. Project Create/Update/Delete audit logging 2. Epic Create/Update/Delete audit logging 3. Story Create/Update/Delete audit logging 4. Task Create/Update/Delete audit logging 5. Multi-tenant isolation verification 6. Performance overhead verification (< 5ms) **Run Tests**: ```bash dotnet test --filter "FullyQualifiedName~AuditLogIntegration" ``` ## Definition of Done - All 4 entity types (Project/Epic/Story/Task) are audited - Integration tests verify audit logs are created - Multi-tenant isolation verified - Performance benchmark met (< 5ms overhead) - Git commit created --- **Created**: 2025-11-05 by Backend Agent