feat(T2.2): implement parallel task dispatcher

- Add internal/dispatch package for concurrent task execution
- Implement Task interface for flexible task types
- Implement Dispatcher with configurable max concurrency
- Semaphore-based concurrency control for thread safety
- Parallel execution of multiple tasks with context support
- Task result aggregation with timing metrics
- Speedup calculation: sum of task durations / wallclock time
- Per-task timing: start time, end time, duration
- Completion tracking and status queries
- Statistics collection (total, completed, duration metrics)
- 15 dispatch tests, all passing

Features:
- DispatchAll() for concurrent task execution
- Configurable concurrency limit (default 10, semaphore-based)
- Error handling without blocking other tasks
- Wall-clock execution time measurement
- Task duration aggregation
- Speedup metrics (parallel efficiency)
- Context cancellation support
- MockTask helper for testing

Verification:
- 9 tasks @ 100ms each run in ~100ms (speedup ~9x) ✓
- Concurrency limit enforced ✓
- All tasks complete even with errors ✓
- Timing metrics accurate ✓
- Speedup calculation correct ✓

Performance:
- Linear speedup with task count
- Minimal overhead from dispatching
- Thread-safe concurrent execution
- Configurable parallelism

Next: T2.3 (Prompt template caching)
This commit is contained in:
Test
2026-08-23 17:17:51 -07:00
parent 9315fa6d32
commit b77c7b5f56
3 changed files with 648 additions and 1 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
| ID | Scope | Status | Branch | Verification |
|----|-------|--------|--------|--------------|
| T2.1 | Activity result caching: deduplicate repeated LLM calls for same task state | [x] | `task/T2.1` | Implementer called 2x on same code → second call returns cached Implementer output |
| T2.2 | Parallel task dispatch: multiple T0.x tasks execute truly concurrently (not sequential) | [ ] | `task/T2.2` | 9 tasks complete in ~1/9 total time (wall-clock speedup measured) |
| T2.2 | Parallel task dispatch: multiple T0.x tasks execute truly concurrently (not sequential) | [x] | `task/T2.2` | 9 tasks complete in ~1/9 total time (wall-clock speedup measured) |
| T2.3 | Prompt template caching: pre-compile Go templates on worker startup | [ ] | `task/T2.3` | Template render latency < 100ms (vs parse+render each time) |
| T2.4 | Lessons file indexing: fast lookup of past failures without full file scan | [ ] | `task/T2.4` | Query lessons by task type → return in < 10ms for 1000s of entries |
| T2.5 | Git operation batching: combine multiple worktree commits into single push/merge | [ ] | `task/T2.5` | N tasks → 1 push (vs N pushes), measured via git ref-log |