/** * Pattern Inheritance Resolver * * Resolves the complete pattern inheritance chain for tickets: * Specification → Epic → Ticket * * Later values override earlier ones. Arrays are concatenated. * * @see MCI-030-05-pattern-inheritance-resolver */ import type { SpecificationCodeStandards, ReturnTypes, NamingConventions, EpicSharedPatterns, EpicCommonFiles } from '../types/index.js'; /** * Fully resolved patterns for a ticket * * Combines patterns from specification, epic, and ticket levels * with proper override semantics. */ export interface ResolvedPatterns { /** All imports (spec.commonImports + epic.additionalImports) */ imports: string[]; /** Merged patterns (spec → epic → ticket, later wins) */ patterns: Record; /** Return types from specification */ returnTypes: ReturnTypes; /** Common files from epic */ commonFiles: EpicCommonFiles; /** Naming conventions from specification */ naming: NamingConventions; /** Source information for debugging */ sources: { specificationId: string; epicId: string; ticketId: string; }; } /** * Override information for a single pattern key */ export interface PatternOverride { /** Pattern key */ key: string; /** Value from specification (if defined) */ specValue?: string; /** Value from epic (if defined) */ epicValue?: string; /** Value from ticket (if defined) */ ticketValue?: string; /** Which level the final value came from */ resolvedFrom: 'specification' | 'epic' | 'ticket'; } /** * Detailed override report for debugging */ export interface PatternOverrideReport { /** Final merged patterns */ final: Record; /** Details about each override */ overrides: PatternOverride[]; } /** * Input data for pattern resolution */ export interface PatternResolutionInput { /** Ticket ID */ ticketId: string; /** Specification data */ specification: { id: string; codeStandards?: SpecificationCodeStandards | null; commonImports?: string[] | null; returnTypes?: ReturnTypes | null; }; /** Epic data */ epic: { id: string; sharedPatterns?: EpicSharedPatterns | null; additionalImports?: string[] | null; commonFiles?: EpicCommonFiles | null; }; /** Ticket data (optional, for override information) */ ticket?: { id: string; technicalDetails?: { patterns?: Record; } | null; }; } /** * Flatten SpecificationCodeStandards to a flat Record * * Extracts all pattern-related fields from code standards into a * flat key-value structure for easy merging. * * @param standards - Specification code standards object * @returns Flat record of pattern key-value pairs */ export declare function flattenCodeStandards(standards: SpecificationCodeStandards | null | undefined): Record; /** * Flatten EpicSharedPatterns to a flat Record * * Extracts all pattern fields from epic shared patterns into a * flat key-value structure for merging. * * @param patterns - Epic shared patterns object * @returns Flat record of pattern key-value pairs */ export declare function flattenSharedPatterns(patterns: EpicSharedPatterns | null | undefined): Record; /** * Resolve inherited patterns for a ticket * * Merges patterns from the specification → epic → ticket chain. * Later values override earlier ones. Arrays are concatenated. * * @param input - Pattern resolution input with spec, epic, and ticket data * @returns Fully resolved patterns * * @example * ```typescript * const resolved = resolvePatterns({ * ticketId: 'ticket-123', * specification: { * id: 'spec-1', * codeStandards: { errorHandling: 'Result' }, * commonImports: ['import { z } from "zod"'] * }, * epic: { * id: 'epic-1', * sharedPatterns: { errorHandling: 'AppError' }, * additionalImports: ['import { api } from "@/lib/api"'] * } * }); * * // resolved.patterns.errorHandling === 'AppError' (epic overrides spec) * // resolved.imports contains both spec and epic imports * ``` */ export declare function resolvePatterns(input: PatternResolutionInput): ResolvedPatterns; /** * Get detailed override information for debugging * * Shows where each pattern value came from in the inheritance chain. * Useful for debugging and understanding pattern resolution. * * @param input - Pattern resolution input * @returns Override report with final values and source information * * @example * ```typescript * const report = getPatternOverrides(input); * * for (const override of report.overrides) { * if (override.resolvedFrom === 'epic') { * console.log(`${override.key}: Epic overrides spec`); * } * } * ``` */ export declare function getPatternOverrides(input: PatternResolutionInput): PatternOverrideReport; /** * Resolve patterns with caching for performance * * Uses an in-memory cache to avoid repeated resolution for the same ticket. * Cache entries expire after TTL (default 1 minute). * * @param input - Pattern resolution input * @param ttl - Cache TTL in milliseconds (default: 60000) * @returns Resolved patterns (may be cached) */ export declare function resolvePatternsWithCache(input: PatternResolutionInput, ttl?: number): ResolvedPatterns; /** * Clear cache for a specific ticket * * Call this after updating a ticket's patterns. * * @param ticketId - Ticket ID to invalidate */ export declare function invalidatePatternCache(ticketId: string): void; /** * Clear all pattern caches * * Call this after updating specification or epic patterns, * as these changes affect multiple tickets. */ export declare function invalidateAllPatternCaches(): void; /** * Get current cache size * * Useful for monitoring and debugging. * * @returns Number of cached entries */ export declare function getPatternCacheSize(): number; //# sourceMappingURL=inheritance.d.ts.map