feat(#166): Implement Stitcher module structure
Created the mosaic-stitcher module - the workflow orchestration layer that wraps OpenClaw. Responsibilities: - Receive webhooks from @mosaic bot - Apply Guard Rails (capability permissions) - Apply Quality Rails (mandatory gates) - Track all job steps and events - Dispatch work to OpenClaw with constraints Implementation: - StitcherModule: Module definition with PrismaModule and BullMqModule - StitcherService: Core orchestration logic - handleWebhook(): Process webhooks from @mosaic bot - dispatchJob(): Create RunnerJob and dispatch to BullMQ queue - applyGuardRails(): Check capability permissions for agent profiles - applyQualityRails(): Determine mandatory gates for job types - trackJobEvent(): Log events to database for audit trail - StitcherController: HTTP endpoints - POST /stitcher/webhook: Webhook receiver - POST /stitcher/dispatch: Manual job dispatch - DTOs and interfaces for type safety TDD Process: 1. RED: Created failing tests (12 tests) 2. GREEN: Implemented minimal code to pass tests 3. REFACTOR: Fixed TypeScript strict mode issues Quality Gates: ALL PASS - Typecheck: PASS - Lint: PASS - Build: PASS - Tests: PASS (12/12) Token estimate: ~56,000 tokens Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
1
apps/api/src/stitcher/dto/index.ts
Normal file
1
apps/api/src/stitcher/dto/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./webhook.dto";
|
||||
44
apps/api/src/stitcher/dto/webhook.dto.ts
Normal file
44
apps/api/src/stitcher/dto/webhook.dto.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { IsString, IsUUID, IsOptional, IsObject, ValidateNested } from "class-validator";
|
||||
import { Type } from "class-transformer";
|
||||
|
||||
/**
|
||||
* DTO for webhook payload from @mosaic bot
|
||||
*/
|
||||
export class WebhookPayloadDto {
|
||||
@IsString()
|
||||
issueNumber!: string;
|
||||
|
||||
@IsString()
|
||||
repository!: string;
|
||||
|
||||
@IsString()
|
||||
action!: string; // 'assigned', 'mentioned', 'commented'
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
comment?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsObject()
|
||||
metadata?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
/**
|
||||
* DTO for dispatching a job
|
||||
*/
|
||||
export class DispatchJobDto {
|
||||
@IsUUID("4")
|
||||
workspaceId!: string;
|
||||
|
||||
@IsString()
|
||||
type!: string; // 'git-status', 'code-task', 'priority-calc'
|
||||
|
||||
@IsOptional()
|
||||
@ValidateNested()
|
||||
@Type(() => WebhookPayloadDto)
|
||||
webhookPayload?: WebhookPayloadDto;
|
||||
|
||||
@IsOptional()
|
||||
@IsObject()
|
||||
context?: Record<string, unknown>;
|
||||
}
|
||||
Reference in New Issue
Block a user