// engine/config-health/index.ts — SPEC-042
// Orchestrator: runs requested config health checkers in parallel.
import { checkTsCoverage, checkVitestSchema, checkJestSchema, checkPackageScripts, checkHuskyScripts, } from './ts-checker.js';
import { checkPyprojectSchema, checkMypyConfig, checkPythonScripts, checkRequirementsConflicts, } from './python-checker.js';
import { checkGoModVersion, checkGoImports, checkGolangciConfig } from './go-checker.js';
import { checkCargoFeatures, checkClippyConfig, checkRustToolchain } from './rust-checker.js';
import { checkCiCommands, checkBuildArtifacts, checkVersionConsistency } from './ci-checker.js';
import { checkOtelVersionCompatibility } from './otel-checker.js';
import { checkBuildToolHealth } from './build-tool-checker.js';
// Re-export individual checkers for direct use
export { checkTsCoverage, checkVitestSchema, checkJestSchema, checkPackageScripts, checkHuskyScripts, } from './ts-checker.js';
export { checkPyprojectSchema, checkMypyConfig, checkPythonScripts, checkRequirementsConflicts, } from './python-checker.js';
export { checkGoModVersion, checkGoImports, checkGolangciConfig } from './go-checker.js';
export { checkCargoFeatures, checkClippyConfig, checkRustToolchain } from './rust-checker.js';
export { checkCiCommands, checkBuildArtifacts, checkVersionConsistency } from './ci-checker.js';
export { checkOtelVersionCompatibility } from './otel-checker.js';
export { checkBuildToolHealth } from './build-tool-checker.js';
const SEVERITY_ORDER = {
    error: 0,
    warning: 1,
    info: 2,
};
// ---------------------------------------------------------------------------
// Orchestrator
// ---------------------------------------------------------------------------
/**
 * Run all requested config health checkers in parallel and return a
 * consolidated ConfigHealthReport.
 *
 * @param projectPath - Absolute path to the project root.
 * @param checks - Optional subset of check groups to run (default: all).
 * @param minSeverity - Minimum severity level to include in findings (default: info).
 */
export async function runConfigHealthChecks(projectPath, checks, minSeverity = 'info') {
    const activeChecks = checks ?? ['ts', 'python', 'go', 'rust', 'ci', 'build-tool'];
    const minOrder = SEVERITY_ORDER[minSeverity];
    const checkPromises = [];
    if (activeChecks.includes('ts')) {
        checkPromises.push(checkTsCoverage(projectPath), checkVitestSchema(projectPath), checkJestSchema(projectPath), checkPackageScripts(projectPath), checkHuskyScripts(projectPath), 
        // SPEC-044 TD-P14-01: OTel version compatibility check
        checkOtelVersionCompatibility(projectPath));
    }
    if (activeChecks.includes('python')) {
        checkPromises.push(checkPyprojectSchema(projectPath), checkMypyConfig(projectPath), checkPythonScripts(projectPath), checkRequirementsConflicts(projectPath));
    }
    if (activeChecks.includes('go')) {
        checkPromises.push(checkGoModVersion(projectPath), checkGoImports(projectPath), checkGolangciConfig(projectPath));
    }
    if (activeChecks.includes('rust')) {
        checkPromises.push(checkCargoFeatures(projectPath), checkClippyConfig(projectPath), checkRustToolchain(projectPath));
    }
    if (activeChecks.includes('ci')) {
        checkPromises.push(checkCiCommands(projectPath), checkBuildArtifacts(projectPath), checkVersionConsistency(projectPath));
    }
    // SPEC-050 S3: Build tool health checks (C7/C8/C9)
    if (activeChecks.includes('build-tool')) {
        checkPromises.push(checkBuildToolHealth(projectPath));
    }
    const results = await Promise.all(checkPromises);
    const allFindings = results.flat();
    // Filter by minimum severity
    const filteredFindings = allFindings.filter((f) => SEVERITY_ORDER[f.severity] <= minOrder);
    // Build summary
    const summary = { errors: 0, warnings: 0, info: 0 };
    for (const finding of filteredFindings) {
        if (finding.severity === 'error') {
            summary.errors++;
        }
        else if (finding.severity === 'warning') {
            summary.warnings++;
        }
        else {
            summary.info++;
        }
    }
    return {
        summary,
        findings: filteredFindings,
        blocksDoR: summary.errors > 0,
    };
}
//# sourceMappingURL=index.js.map