Files
mcpctl/.taskmaster/tasks/task_129.md

25 lines
945 B
Markdown
Raw Permalink Normal View History

# Task ID: 129
**Title:** Task repository with compare-and-swap transitions
**Status:** pending
**Dependencies:** 118
**Priority:** medium
**Description:** Create TaskRepository with optimistic locking state transitions using updateMany with where clause
**Details:**
Create src/mcpd/src/repositories/task.repository.ts:
1. Standard CRUD methods following existing patterns
2. transition(id, fromState, toState): use prisma.task.updateMany({ where: { id, state: fromState }, data: { state: toState, version: { increment: 1 } } }), return affected count
3. If affected count is 0, the transition failed (race or wrong state)
4. findByFilters(): support epicTaskId, state, assigneeId filters
5. Include verdict and event relations where appropriate
**Test Strategy:**
Unit tests: test transition succeeds when state matches, test transition returns 0 when state doesn't match (simulating race), test concurrent transitions only one wins.