/**
 * Closure Metrics - Telemetry for External Tool Sync Operations
 *
 * Tracks closure success/failure rates for GitHub, JIRA, and ADO.
 * Persists metrics to .specweave/state/closure-metrics.json
 *
 * Usage:
 *   const metrics = new ClosureMetrics(projectRoot);
 *   metrics.recordClosure('github', 100, true); // Success
 *   metrics.recordClosure('jira', 'TEST-123', false, 'Rate limited'); // Failure
 *   metrics.getSummary(); // Get aggregated stats
 */
import { Logger } from '../utils/logger.js';
export type ExternalTool = 'github' | 'jira' | 'ado';
export interface ClosureRecord {
    tool: ExternalTool;
    itemId: string | number;
    incrementId: string;
    success: boolean;
    error?: string;
    timestamp: string;
    durationMs?: number;
}
export interface ToolMetrics {
    totalAttempts: number;
    successful: number;
    failed: number;
    successRate: number;
    lastSuccess?: string;
    lastFailure?: string;
    avgDurationMs?: number;
    recentErrors: string[];
}
export interface ClosureMetricsSummary {
    github: ToolMetrics;
    jira: ToolMetrics;
    ado: ToolMetrics;
    overall: {
        totalAttempts: number;
        successful: number;
        failed: number;
        successRate: number;
    };
    lastUpdated: string;
}
export declare class ClosureMetrics {
    private projectRoot;
    private metricsFile;
    private logger;
    private currentIncrementId;
    private operationStartTime;
    constructor(options: {
        projectRoot: string;
        incrementId?: string;
        logger?: Logger;
    });
    /**
     * Start timing an operation
     */
    startOperation(): void;
    /**
     * Record a closure operation result
     */
    recordClosure(tool: ExternalTool, itemId: string | number, success: boolean, error?: string): void;
    /**
     * Record multiple closures in batch
     */
    recordBatch(tool: ExternalTool, results: Array<{
        itemId: string | number;
        success: boolean;
        error?: string;
    }>): void;
    /**
     * Get metrics summary
     */
    getSummary(): ClosureMetricsSummary;
    /**
     * Get recent failures for alerting
     */
    getRecentFailures(hours?: number): ClosureRecord[];
    /**
     * Check if failure rate exceeds threshold (for alerting)
     */
    isFailureRateHigh(tool: ExternalTool, threshold?: number): boolean;
    /**
     * Format summary for display
     */
    formatSummary(): string;
    /**
     * Reset metrics (for testing or fresh start)
     */
    reset(): void;
    private loadMetrics;
    private saveMetrics;
    private createEmptyMetrics;
    private updateSummary;
}
/**
 * Factory function for creating metrics instance
 */
export declare function createClosureMetrics(projectRoot: string, incrementId?: string, logger?: Logger): ClosureMetrics;
//# sourceMappingURL=closure-metrics.d.ts.map