/*
 * Copyright 2026, Jaime Terrats.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
const MIN_SUMMARY_LENGTH = 10;
const PASSING_SCORE = 50;
const GENERIC_SUMMARIES = new Set([
    'done',
    'completed',
    'finished',
    'ok',
    'pass',
    'passed',
    'n/a',
    'none',
    'ready',
]);
/**
 * Assess the quality of an evidence entry.
 * Returns a score 0-100 and a list of issues found.
 */
export function assessEvidenceQuality(evidence) {
    const issues = [];
    let deductions = 0;
    // Check: has role
    if (!evidence.role || evidence.role.trim().length === 0) {
        issues.push({ field: 'role', message: 'Missing role' });
        deductions += 25;
    }
    // Check: has type
    if (!evidence.type || evidence.type.trim().length === 0) {
        issues.push({ field: 'type', message: 'Missing type classification' });
        deductions += 25;
    }
    // Check: has summary with minimum length
    if (!evidence.summary || evidence.summary.trim().length === 0) {
        issues.push({ field: 'summary', message: 'Missing summary' });
        deductions += 50;
    }
    else if (GENERIC_SUMMARIES.has(evidence.summary.trim().toLowerCase())) {
        issues.push({ field: 'summary', message: 'Summary is too generic' });
        deductions += 20;
    }
    else if (evidence.summary.trim().length < MIN_SUMMARY_LENGTH) {
        issues.push({ field: 'summary', message: `Summary too short (min ${MIN_SUMMARY_LENGTH} chars)` });
        deductions += 30;
    }
    const score = Math.max(0, 100 - deductions);
    return {
        score,
        issues,
        pass: score >= PASSING_SCORE,
    };
}
//# sourceMappingURL=evidence-quality.js.map