claude-flow-novice
Version:
Claude Flow Novice - Advanced orchestration platform for multi-agent AI workflows with CFN Loop architecture Includes Local RuVector Accelerator and all CFN skills for complete functionality.
94 lines (93 loc) • 3.4 kB
JavaScript
/**
* Gate Checker Type Definitions
*
* Core types and interfaces for the CFN Loop gate checking system including:
* - Test result tracking
* - Pass rate calculations
* - Gate validation and thresholds
* - Execution modes and strategies
* - Error handling
*
* @module gate-checker/types
*/ // ===== EXECUTION MODE TYPES =====
// ===== VALIDATION ERROR TYPES =====
export class GateCheckError extends Error {
code;
metadata;
constructor(message, code, metadata){
super(message), this.code = code, this.metadata = metadata;
this.name = 'GateCheckError';
}
}
export class ValidationError extends GateCheckError {
constructor(message, metadata){
super(message, 'VALIDATION_ERROR', metadata);
this.name = 'ValidationError';
}
}
export class SecurityError extends GateCheckError {
constructor(message, metadata){
super(message, 'SECURITY_ERROR', metadata);
this.name = 'SecurityError';
}
}
export class TimeoutError extends GateCheckError {
constructor(message, metadata){
super(message, 'TIMEOUT_ERROR', metadata);
this.name = 'TimeoutError';
}
}
// ===== TYPE GUARDS =====
/**
* Type guard to check if a value is a valid TestResult
*/ export function isValidTestResult(value) {
if (typeof value !== 'object' || value === null) {
return false;
}
const result = value;
const validStatuses = [
'success',
'timeout',
'parse_error',
'failure',
'parsed'
];
return typeof result.pass_rate === 'number' && typeof result.passed === 'number' && typeof result.failed === 'number' && typeof result.total === 'number' && typeof result.status === 'string' && result.pass_rate >= 0 && result.pass_rate <= 1 && result.passed >= 0 && result.failed >= 0 && result.total >= 0 && validStatuses.indexOf(result.status) !== -1;
}
/**
* Type guard to check if a value is a valid SuccessCriteria
*/ export function isValidSuccessCriteria(value) {
if (typeof value !== 'object' || value === null) {
return false;
}
const criteria = value;
return Array.isArray(criteria.test_suites) && criteria.test_suites.length > 0 && criteria.test_suites.every((suite)=>isValidTestSuite(suite));
}
/**
* Type guard to check if a value is a valid TestSuite
*/ export function isValidTestSuite(value) {
if (typeof value !== 'object' || value === null) {
return false;
}
const suite = value;
return typeof suite.name === 'string' && typeof suite.command === 'string' && (suite.timeout === undefined || typeof suite.timeout === 'number') && (suite.framework === undefined || typeof suite.framework === 'string') && (suite.required === undefined || typeof suite.required === 'boolean');
}
/**
* Type guard to check if a value is a valid ExecutionMode
*/ export function isValidExecutionMode(value) {
return value === 'mvp' || value === 'standard' || value === 'enterprise';
}
/**
* Type guard to check if a value is a valid GateCheckStrategy
*/ export function isValidGateCheckStrategy(value) {
return value === 'test-driven' || value === 'confidence' || value === 'auto';
}
// ===== EXPORTS =====
export default {
isValidTestResult,
isValidSuccessCriteria,
isValidTestSuite,
isValidExecutionMode,
isValidGateCheckStrategy
};
//# sourceMappingURL=types.js.map