feat(#168): Implement job steps tracking
Implement JobStepsModule for granular step tracking within runner jobs. Features: - Create and track job steps (SETUP, EXECUTION, VALIDATION, CLEANUP) - Track step status transitions (PENDING → RUNNING → COMPLETED/FAILED) - Record token usage for AI_ACTION steps - Calculate step duration automatically - GET endpoints for listing and retrieving steps Implementation: - JobStepsService: CRUD operations, status tracking, duration calculation - JobStepsController: GET /runner-jobs/:jobId/steps endpoints - DTOs: CreateStepDto, UpdateStepDto with validation - Full unit test coverage (16 tests) Quality gates: - Build: ✅ Passed - Lint: ✅ Passed - Tests: ✅ 16/16 passed - Coverage: ✅ 100% statements, 100% functions, 100% lines, 83.33% branches Also fixed pre-existing TypeScript strict mode issue in job-events DTO. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -54,10 +54,40 @@ Implement runner-jobs module for job lifecycle management and queue submission,
|
||||
- Mock Prisma for database operations
|
||||
- Target: ≥85% coverage
|
||||
|
||||
## Implementation Summary
|
||||
|
||||
**Files Created:**
|
||||
|
||||
- apps/api/src/runner-jobs/dto/create-job.dto.ts - Job creation DTO
|
||||
- apps/api/src/runner-jobs/dto/query-jobs.dto.ts - Job query DTO
|
||||
- apps/api/src/runner-jobs/dto/index.ts - DTO barrel export
|
||||
- apps/api/src/runner-jobs/runner-jobs.service.ts - Service implementation
|
||||
- apps/api/src/runner-jobs/runner-jobs.service.spec.ts - Service tests (18 tests)
|
||||
- apps/api/src/runner-jobs/runner-jobs.controller.ts - Controller implementation
|
||||
- apps/api/src/runner-jobs/runner-jobs.controller.spec.ts - Controller tests (6 tests)
|
||||
- apps/api/src/runner-jobs/runner-jobs.module.ts - Module configuration
|
||||
- apps/api/src/runner-jobs/index.ts - Module barrel export
|
||||
|
||||
**Key Implementation Details:**
|
||||
|
||||
1. Used Prisma relations (workspace.connect, agentTask.connect) for foreign keys
|
||||
2. Optional fields only included when present (result, agentTaskId)
|
||||
3. BullMQ integration for async job processing via QUEUE_NAMES.RUNNER
|
||||
4. Comprehensive error handling (NotFoundException, BadRequestException)
|
||||
5. Following existing patterns from tasks/events modules
|
||||
|
||||
**Test Coverage:**
|
||||
|
||||
- Service: 18 tests covering create, findAll, findOne, cancel, retry
|
||||
- Controller: 6 tests covering all endpoints
|
||||
- Total: 24 tests, all passing
|
||||
|
||||
**Token Usage Estimate:** ~76,000 tokens
|
||||
|
||||
## Notes
|
||||
|
||||
- Follow existing CRUD patterns from tasks/events modules
|
||||
- Use DTOs for validation
|
||||
- Integrate with BullMqService for queue submission
|
||||
- Use Prisma for all database operations
|
||||
- Follow PDA-friendly language principles in responses
|
||||
- Followed existing CRUD patterns from tasks/events modules
|
||||
- Used DTOs for validation
|
||||
- Integrated with BullMqService for queue submission
|
||||
- Used Prisma for all database operations
|
||||
- Followed PDA-friendly language principles in responses
|
||||
|
||||
Reference in New Issue
Block a user