/** * Agentic QE v3 - QE Pattern Types and Domains * ADR-021: QE ReasoningBank for Pattern Learning * * Defines QE-specific pattern types, domains, and validation. */ import type { DomainName } from '../shared/types/index.js'; /** * QE domain patterns for automatic classification * Each domain has regex patterns to match against task descriptions * Aligned with the 12 DDD bounded contexts from DomainName type */ export declare const QE_DOMAINS: { readonly 'test-generation': RegExp; readonly 'test-execution': RegExp; readonly 'coverage-analysis': RegExp; readonly 'quality-assessment': RegExp; readonly 'defect-intelligence': RegExp; readonly 'requirements-validation': RegExp; readonly 'code-intelligence': RegExp; readonly 'security-compliance': RegExp; readonly 'contract-testing': RegExp; readonly 'visual-accessibility': RegExp; readonly 'chaos-resilience': RegExp; readonly 'learning-optimization': RegExp; }; /** * QE Domain type - aligned with DomainName from shared types */ export type QEDomain = keyof typeof QE_DOMAINS; /** * QE pattern types - specific pattern categories */ export type QEPatternType = 'test-template' | 'assertion-pattern' | 'mock-pattern' | 'coverage-strategy' | 'mutation-strategy' | 'api-contract' | 'visual-baseline' | 'a11y-check' | 'perf-benchmark' | 'flaky-fix' | 'refactor-safe' | 'error-handling'; /** * Test framework identifiers */ export type TestFramework = 'jest' | 'vitest' | 'mocha' | 'pytest' | 'junit' | 'testng' | 'playwright' | 'cypress' | 'selenium'; /** * Programming language identifiers */ export type ProgrammingLanguage = 'typescript' | 'javascript' | 'python' | 'java' | 'go' | 'rust' | 'csharp' | 'kotlin'; /** * Pattern complexity levels */ export type ComplexityLevel = 'simple' | 'medium' | 'complex'; /** * QE-specific pattern for learning and reuse */ export interface QEPattern { /** Unique pattern identifier */ readonly id: string; /** Pattern type category */ readonly patternType: QEPatternType; /** QE domain this pattern belongs to */ readonly qeDomain: QEDomain; /** Mapped AQE domain name */ readonly domain: DomainName; /** Human-readable pattern name */ readonly name: string; /** Detailed description of what this pattern does */ readonly description: string; /** Pattern confidence score (0-1) */ readonly confidence: number; /** Number of times this pattern has been used */ readonly usageCount: number; /** Success rate when applied (0-1) */ readonly successRate: number; /** Quality score combining confidence, usage, and success */ readonly qualityScore: number; /** Pattern applicability context */ readonly context: QEPatternContext; /** The actual pattern template */ readonly template: QEPatternTemplate; /** Vector embedding for similarity search */ readonly embedding?: number[]; /** Short-term or long-term storage */ readonly tier: 'short-term' | 'long-term'; /** Creation timestamp */ readonly createdAt: Date; /** Last used timestamp */ readonly lastUsedAt: Date; /** Number of successful uses (for promotion) */ readonly successfulUses: number; } /** * Pattern applicability context */ export interface QEPatternContext { /** Programming language this pattern applies to */ readonly language?: ProgrammingLanguage; /** Test framework this pattern uses */ readonly framework?: TestFramework; /** Test type (unit, integration, e2e) */ readonly testType?: 'unit' | 'integration' | 'e2e' | 'contract' | 'smoke'; /** Code context pattern applies to */ readonly codeContext?: 'class' | 'function' | 'module' | 'api' | 'component'; /** Complexity level */ readonly complexity?: ComplexityLevel; /** Related domains */ readonly relatedDomains?: QEDomain[]; /** Searchable tags */ readonly tags: string[]; } /** * Pattern template with variables */ export interface QEPatternTemplate { /** Template type */ readonly type: 'code' | 'prompt' | 'workflow' | 'config'; /** Template content with {{variable}} placeholders */ readonly content: string; /** Variables that need to be filled in */ readonly variables: QETemplateVariable[]; /** Example of filled template */ readonly example?: string; } /** * Template variable definition */ export interface QETemplateVariable { /** Variable name (matches {{name}} in template) */ readonly name: string; /** Variable type */ readonly type: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'code'; /** Whether this variable is required */ readonly required: boolean; /** Default value if not provided */ readonly defaultValue?: unknown; /** Description for users/agents */ readonly description?: string; /** Validation pattern (regex for strings) */ readonly validation?: string; } /** * Options for creating a new QE pattern */ export interface CreateQEPatternOptions { patternType: QEPatternType; name: string; description: string; template: Omit; context?: Partial; embedding?: number[]; } /** * Detect QE domain from task description */ export declare function detectQEDomain(taskDescription: string): QEDomain | null; /** * Detect multiple QE domains from task description */ export declare function detectQEDomains(taskDescription: string): QEDomain[]; /** * Map QE domain to AQE bounded context domain * Since QEDomain is now aligned with DomainName, this is an identity mapping */ export declare function mapQEDomainToAQE(qeDomain: QEDomain): DomainName; /** * Calculate pattern quality score */ export declare function calculateQualityScore(pattern: { confidence: number; usageCount: number; successRate: number; }): number; /** * Check if pattern should be promoted to long-term storage * Requires 3+ successful uses as per ADR-021 */ export declare function shouldPromotePattern(pattern: QEPattern): boolean; /** * Validate QE pattern structure */ export declare function validateQEPattern(pattern: Partial): { valid: boolean; errors: string[]; }; /** * Apply template variables to pattern content */ export declare function applyPatternTemplate(template: QEPatternTemplate, variables: Record): string; /** * Pattern match result */ export interface PatternMatchResult { pattern: QEPattern; score: number; matchedContext: { language: boolean; framework: boolean; testType: boolean; codeContext: boolean; domain: boolean; }; } /** * Match patterns against a context */ export declare function matchPatternContext(pattern: QEPattern, context: Partial): PatternMatchResult; export declare const QE_PATTERN_TYPES: QEPatternType[]; export declare const QE_DOMAIN_LIST: QEDomain[]; //# sourceMappingURL=qe-patterns.d.ts.map