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:
2026-02-01 21:16:23 -06:00
parent 7102b4a1d2
commit efe624e2c1
54 changed files with 2597 additions and 17 deletions

View File

@@ -0,0 +1,20 @@
import { IsString, IsOptional, IsObject, IsUUID, IsEnum } from "class-validator";
import { EventType, ALL_EVENT_TYPES } from "../event-types";
/**
* DTO for creating a job event
*/
export class CreateEventDto {
@IsEnum(ALL_EVENT_TYPES)
type!: EventType;
@IsString()
actor!: string;
@IsObject()
payload!: Record<string, unknown>;
@IsOptional()
@IsUUID()
stepId?: string;
}

View File

@@ -0,0 +1,2 @@
export * from "./create-event.dto";
export * from "./query-events.dto";

View File

@@ -0,0 +1,29 @@
import { IsOptional, IsString, IsInt, Min, Max, IsEnum } from "class-validator";
import { Type } from "class-transformer";
import { EventType, ALL_EVENT_TYPES } from "../event-types";
/**
* DTO for querying job events
*/
export class QueryEventsDto {
@IsOptional()
@IsEnum(ALL_EVENT_TYPES)
type?: EventType;
@IsOptional()
@IsString()
stepId?: string;
@IsOptional()
@Type(() => Number)
@IsInt()
@Min(1)
page?: number;
@IsOptional()
@Type(() => Number)
@IsInt()
@Min(1)
@Max(100)
limit?: number;
}