// engine/auto-promoter.ts — Auto-Promotion Confidence Scoring logic (SPEC-391)
/**
 * Calculate a confidence score for auto-promoting a spec.
 * High-risk specs always get riskPenalty=100 (never eligible).
 * Medium-risk specs get penalty=20. Low-risk gets 0.
 * A dependency bonus of +10 is added when all dependencies are satisfied.
 */
export function calculateConfidence(spec, readinessScore, config) {
    const riskPenalty = spec.risk === 'high' ? 100 : spec.risk === 'medium' ? 20 : 0;
    // Dependency bonus: +10 when spec has no pending dependencies
    const noDeps = spec.dependencies.length === 0;
    const dependencyBonus = noDeps ? 10 : 0;
    const overall = Math.max(0, Math.min(100, readinessScore - riskPenalty + dependencyBonus));
    const riskAllowed = spec.risk !== 'high' && (config.maxRisk === 'medium' ? true : spec.risk === 'low');
    const eligible = overall >= config.readinessThreshold && riskAllowed;
    const reason = eligible
        ? `Score ${overall} >= threshold ${config.readinessThreshold}. Ready to auto-promote.`
        : `Score ${overall} < threshold ${config.readinessThreshold} or risk too high.`;
    return {
        overall,
        readiness: readinessScore,
        riskPenalty,
        dependencyBonus,
        eligible,
        reason,
    };
}
/**
 * Return the default AutoPromoterConfig for a project.
 */
export function getDefaultConfig(projectPath) {
    return {
        projectPath,
        enabled: false,
        readinessThreshold: 85,
        maxRisk: 'medium',
        requireDependenciesDone: true,
    };
}
//# sourceMappingURL=auto-promoter.js.map