/** * Enterprise Certification System - Consensus Algorithm * * This module implements the weighted multi-agent consensus algorithm for * calculating certification scores and levels. It handles: * - Individual agent score calculation with severity penalties * - Cross-verification multipliers (confirmed findings penalized more, disputed less) * - Weighted aggregation across all agents * - Certification level determination based on thresholds and critical findings * * @module certification/consensus */ import { Certification, ConsensusResult, Severity, Finding } from "./types.js"; /** * The severity to USE for scoring + level determination. Deterministic and * cross-verified findings keep their real severity. An un-cross-verified * heuristic finding is demoted: to `info` when its confidence is below the floor * (it stays visible but stops inflating critical/high counts), otherwise one * notch (so a heuristic "critical" can't alone force BLOCKED). This is the * precision guard for the noisy heuristic layer — the deterministic scanners and * confirmed findings are unaffected. */ export declare function effectiveSeverity(finding: Finding): Severity; /** * Calculate the consensus result for a certification across all agents. * * This is the main scoring function that: * 1. Calculates individual scores for each completed agent * 2. Applies agent weights (Security 30%, Reliability 25%, TypeSafety 15%, * Performance 15%, Quality 10%, RedTeam 5%) * 3. Computes weighted overall score * 4. Counts findings by severity * 5. Calculates cross-verification rate * 6. Determines certification level based on score and critical findings * * @param certification - The full certification data including all agent findings * @returns ConsensusResult with overall score, level, and detailed metrics * * @example * ```typescript * const certification = await getCertification(projectPath, certId); * const consensus = calculateConsensus(certification); * console.log(`Score: ${consensus.overall_score}/100`); * console.log(`Level: ${consensus.certification_level}`); * ``` */ export declare function calculateConsensus(certification: Certification): ConsensusResult; /** * Check if a certification is ready to be finalized. * * A certification can be finalized when: * - All requested agents have completed their audits * - All critical findings have been cross-verified by at least one other agent * * Additionally, this function returns warnings for suspicious conditions: * - Agents reporting zero findings (may indicate incomplete audit) * - Total findings across all agents is zero (certification may not be trustworthy) * * @param certification - The certification to check * @returns Object containing: * - ready: boolean indicating if certification can be finalized * - missing: array of blocking issues that prevent finalization * - warnings: array of non-blocking concerns to review * * @example * ```typescript * const { ready, missing, warnings } = canFinalize(certification); * if (!ready) { * console.log('Cannot finalize:', missing); * } * if (warnings.length > 0) { * console.log('Warnings:', warnings); * } * ``` */ export declare function canFinalize(certification: Certification): { ready: boolean; missing: string[]; warnings: string[]; }; /** * Generate a human-readable summary of a certification consensus result. * * The summary includes: * - Certification level with color-coded emoji indicator * - Overall score out of 100 * - Breakdown of findings by severity * - Cross-verification rate as percentage * - Red team challenge statistics * * Level indicators: * - 🟢 CERTIFIED (90-100) * - 🟡 APPROVED (70-89) * - 🟠 REVIEW_REQUIRED (40-69) * - 🔴 BLOCKED (0-39) * * @param consensus - The consensus result to summarize * @returns Multi-line string formatted for display * * @example * ```typescript * const consensus = calculateConsensus(certification); * console.log(getCertificationSummary(consensus)); * // Output: * // 🟡 APPROVED * // Score: 85/100 * // * // Findings: 15 * // Critical: 0 * // High: 2 * // ... * ``` */ export declare function getCertificationSummary(consensus: ConsensusResult): string; //# sourceMappingURL=consensus.d.ts.map