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:
66
docs/scratchpads/168-job-steps-tracking.md
Normal file
66
docs/scratchpads/168-job-steps-tracking.md
Normal file
@@ -0,0 +1,66 @@
|
||||
# Issue #168: Job steps tracking
|
||||
|
||||
## Objective
|
||||
|
||||
Implement job-steps module for granular step tracking within jobs. This module will track individual steps (SETUP, EXECUTION, VALIDATION, CLEANUP) within a runner job, recording status transitions, token usage, and duration.
|
||||
|
||||
## Approach
|
||||
|
||||
1. Analyze existing RunnerJobsModule and JobStep model
|
||||
2. Create JobStepsModule with TDD approach
|
||||
3. Implement service layer for step CRUD and status tracking
|
||||
4. Implement controller with GET endpoints
|
||||
5. Ensure proper integration with RunnerJobsModule
|
||||
|
||||
## Progress
|
||||
|
||||
- [x] Analyze existing code structure
|
||||
- [x] Create directory structure and DTOs
|
||||
- [x] RED: Write tests for JobStepsService
|
||||
- [x] GREEN: Implement JobStepsService
|
||||
- [x] RED: Write tests for JobStepsController
|
||||
- [x] GREEN: Implement JobStepsController
|
||||
- [x] Create JobStepsModule
|
||||
- [x] REFACTOR: Clean up and optimize
|
||||
- [x] Quality gates: typecheck, lint, test, coverage
|
||||
- [x] Commit changes
|
||||
|
||||
## Testing
|
||||
|
||||
- Unit tests for service methods (13 tests)
|
||||
- Unit tests for controller endpoints (3 tests)
|
||||
- Mock Prisma service
|
||||
- Verify token usage tracking
|
||||
- Verify duration calculation
|
||||
- Coverage: 100% statements, 100% functions, 100% lines, 83.33% branches
|
||||
|
||||
## Notes
|
||||
|
||||
- Step types: COMMAND, AI_ACTION, GATE, ARTIFACT
|
||||
- Step phases: SETUP, EXECUTION, VALIDATION, CLEANUP
|
||||
- Status transitions: pending → running → completed/failed
|
||||
- Track token usage per step (for AI_ACTION steps)
|
||||
- Calculate duration on completion
|
||||
|
||||
## Implementation Summary
|
||||
|
||||
Created the following files:
|
||||
|
||||
- `/home/jwoltje/src/mosaic-stack/apps/api/src/job-steps/job-steps.module.ts` - Module definition
|
||||
- `/home/jwoltje/src/mosaic-stack/apps/api/src/job-steps/job-steps.service.ts` - Service with CRUD operations
|
||||
- `/home/jwoltje/src/mosaic-stack/apps/api/src/job-steps/job-steps.controller.ts` - Controller with GET endpoints
|
||||
- `/home/jwoltje/src/mosaic-stack/apps/api/src/job-steps/dto/create-step.dto.ts` - DTO for creating steps
|
||||
- `/home/jwoltje/src/mosaic-stack/apps/api/src/job-steps/dto/update-step.dto.ts` - DTO for updating steps
|
||||
- `/home/jwoltje/src/mosaic-stack/apps/api/src/job-steps/dto/index.ts` - DTO exports
|
||||
- `/home/jwoltje/src/mosaic-stack/apps/api/src/job-steps/job-steps.service.spec.ts` - Service tests (13 tests)
|
||||
- `/home/jwoltje/src/mosaic-stack/apps/api/src/job-steps/job-steps.controller.spec.ts` - Controller tests (3 tests)
|
||||
- `/home/jwoltje/src/mosaic-stack/apps/api/src/job-steps/index.ts` - Module exports
|
||||
|
||||
Also fixed pre-existing issue in job-events DTO (added `!` to required properties).
|
||||
|
||||
## Quality Gates
|
||||
|
||||
- ✅ Build: Passed
|
||||
- ✅ Lint: Passed (auto-fixed formatting)
|
||||
- ✅ Tests: 16/16 passed
|
||||
- ✅ Coverage: 100% statements, 100% functions, 100% lines, 83.33% branches
|
||||
Reference in New Issue
Block a user