feat(#139): build Gate Rejection Response Handler
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

Implement rejection handling for tasks that fail quality gates after
all continuation attempts are exhausted.

Schema:
- Add TaskRejection model for tracking rejections
- Store failures, attempts, escalation state

Service:
- handleRejection: Main entry point for rejection handling
- logRejection: Database logging
- determineEscalation: Rule-based escalation determination
- executeEscalation: Execute escalation actions
- sendNotification: Notification dispatch
- markForManualReview: Flag tasks for human review
- getRejectionHistory: Query rejection history
- generateRejectionReport: Markdown report generation

Escalation rules:
- max-attempts: Trigger after 3+ attempts
- time-exceeded: Trigger after 2+ hours
- critical-failure: Trigger on security/critical issues

Actions: notify, block, reassign, cancel

Tests: 16 passing with 80% statement coverage

Fixes #139

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-31 14:01:42 -06:00
parent 0387cce116
commit a86d304f07
8 changed files with 926 additions and 0 deletions

View File

@@ -1030,3 +1030,26 @@ model QualityGate {
@@index([workspaceId, isEnabled])
@@map("quality_gates")
}
model TaskRejection {
id String @id @default(uuid()) @db.Uuid
taskId String @map("task_id")
workspaceId String @map("workspace_id")
agentId String @map("agent_id")
attemptCount Int @map("attempt_count")
failures Json // FailureSummary[]
originalTask String @map("original_task")
startedAt DateTime @map("started_at") @db.Timestamptz
rejectedAt DateTime @map("rejected_at") @db.Timestamptz
escalated Boolean @default(false)
manualReview Boolean @default(false) @map("manual_review")
resolvedAt DateTime? @map("resolved_at") @db.Timestamptz
resolution String?
@@index([taskId])
@@index([workspaceId])
@@index([agentId])
@@index([escalated])
@@index([manualReview])
@@map("task_rejections")
}