// engine/criteria-quality-checker.ts — SPEC-486: Zero-ambiguity criteria quality scoring
/** Phrases that are always score=0 — too generic to generate any expect() from. */
const PROHIBITED_PHRASES = new Set([
    'Implementation complete and tested',
    'Coverage meets project threshold',
    'Database migration created and tested',
    'tested',
    'complete',
]);
const GWT_PATTERN = /\bGIVEN\b.+\bWHEN\b.+\bTHEN\b/s;
/** Concrete value: number, quoted string, TS type, HTTP status code, array literal. */
const CONCRETE_VALUE_PATTERN = /\d+|"[^"]+"|'[^']+'|\{[^}]+\}|\[[^\]]+\]|\b(string|number|boolean|null|undefined|TypeError|Error|void)\b|\b[A-Z][a-zA-Z]+Error\b/;
/** Explicit function/method reference: fn(), method(), ClassName.method */
const FUNCTION_PATTERN = /\w+\s*\(|[A-Z][a-zA-Z]+\.\w+/;
/**
 * Score a single acceptance criterion for LLM parseability.
 * Returns score 0-100 and the reason for any deduction.
 */
export function checkCriteriaQuality(criterion) {
    // Exact prohibited phrase → immediate score=0
    if (PROHIBITED_PHRASES.has(criterion.trim())) {
        return {
            score: 0,
            reason: `Prohibited generic phrase — replace with GIVEN/WHEN/THEN and a concrete value`,
            hasGWT: false,
            hasConcreteValue: false,
        };
    }
    let score = 0;
    const reasons = [];
    const hasGWT = GWT_PATTERN.test(criterion);
    const hasConcreteValue = CONCRETE_VALUE_PATTERN.test(criterion);
    const hasFunction = FUNCTION_PATTERN.test(criterion);
    if (hasGWT) {
        score += 50;
    }
    else {
        reasons.push('no GIVEN/WHEN/THEN structure');
    }
    if (hasConcreteValue) {
        score += 30;
    }
    else {
        reasons.push('no concrete value (number, type, quoted string, or status code)');
    }
    if (hasFunction) {
        score += 20;
    }
    else {
        reasons.push('no explicit function/method reference');
    }
    const reason = reasons.length === 0 ? 'criterion is testable and concrete' : reasons.join('; ');
    return { score, reason, hasGWT, hasConcreteValue };
}
//# sourceMappingURL=criteria-quality-checker.js.map