feat(#134): design Non-AI Quality Orchestrator service

Implement quality orchestration service to enforce standards on AI
agent work and prevent premature completion claims.

Components:
- QualityOrchestratorService: Core validation and gate execution
- QualityGate interface: Extensible gate definitions
- CompletionClaim/Validation: Track claims and verdicts
- OrchestrationConfig: Per-workspace configuration

Features:
- Validate completions against quality gates (build/lint/test/coverage)
- Run gates with command execution and output validation
- Support string and RegExp output pattern matching
- Smart continuation logic with attempt tracking
- Generate actionable feedback for failed gates
- Strict/lenient mode for gate enforcement
- 5-minute timeout, 10MB output buffer per gate

Default gates:
- Build Check (required)
- Lint Check (required)
- Test Suite (required)
- Coverage Check (optional, 85% threshold)

Tests: 21 passing with 85.98% coverage

Fixes #134

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-31 13:24:46 -06:00
parent 0c78923138
commit a25e9048be
11 changed files with 992 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
import type { QualityGateResult } from "./quality-gate.interface";
/**
* Claim by an agent that a task is complete
*/
export interface CompletionClaim {
/** ID of the task being claimed as complete */
taskId: string;
/** ID of the agent making the claim */
agentId: string;
/** Workspace context */
workspaceId: string;
/** Timestamp of claim */
claimedAt: Date;
/** Agent's message about completion */
message: string;
/** List of files changed during task execution */
filesChanged: string[];
}
/**
* Result of validating a completion claim
*/
export interface CompletionValidation {
/** Original claim being validated */
claim: CompletionClaim;
/** Results from all quality gates */
gateResults: QualityGateResult[];
/** Whether all gates passed */
allGatesPassed: boolean;
/** List of required gates that failed */
requiredGatesFailed: string[];
/** Final verdict on the completion */
verdict: "accepted" | "rejected" | "needs-continuation";
/** Feedback message for the agent */
feedback?: string;
/** Specific actions to take to fix failures */
suggestedActions?: string[];
}

View File

@@ -0,0 +1,3 @@
export * from "./quality-gate.interface";
export * from "./completion-result.interface";
export * from "./orchestration-config.interface";

View File

@@ -0,0 +1,21 @@
import type { QualityGate } from "./quality-gate.interface";
/**
* Configuration for quality orchestration
*/
export interface OrchestrationConfig {
/** Workspace this config applies to */
workspaceId: string;
/** Quality gates to enforce */
gates: QualityGate[];
/** Maximum number of continuation attempts */
maxContinuations: number;
/** Token budget for continuations */
continuationBudget: number;
/** Whether to reject on ANY failure vs only required gates */
strictMode: boolean;
}

View File

@@ -0,0 +1,51 @@
/**
* Defines a quality gate that must be passed for task completion
*/
export interface QualityGate {
/** Unique identifier for the gate */
id: string;
/** Human-readable name */
name: string;
/** Description of what this gate checks */
description: string;
/** Type of quality check */
type: "test" | "lint" | "build" | "coverage" | "custom";
/** Command to execute for this gate (optional for custom gates) */
command?: string;
/** Expected output pattern (optional, for validation) */
expectedOutput?: string | RegExp;
/** Whether this gate must pass for completion */
required: boolean;
/** Execution order (lower numbers run first) */
order: number;
}
/**
* Result of running a quality gate
*/
export interface QualityGateResult {
/** ID of the gate that was run */
gateId: string;
/** Name of the gate */
gateName: string;
/** Whether the gate passed */
passed: boolean;
/** Output from running the gate */
output?: string;
/** Error message if gate failed */
error?: string;
/** Duration in milliseconds */
duration: number;
}