import { containsPlaintextSecret } from '../secret-redaction.js';
import { COMPLETION_PROOF_SCHEMA, COMPLETION_PROOF_STATUSES } from './proof-schema.js';
function asRecord(value) {
    return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
}
export function validateCompletionProof(proof = {}) {
    const issues = [];
    const record = asRecord(proof);
    if (record.schema !== COMPLETION_PROOF_SCHEMA)
        issues.push('schema');
    if (!COMPLETION_PROOF_STATUSES.includes(String(record.status)))
        issues.push('status');
    if (!record.summary || typeof record.summary !== 'object')
        issues.push('summary');
    if (!record.evidence || typeof record.evidence !== 'object')
        issues.push('evidence');
    if (!Array.isArray(record.claims))
        issues.push('claims');
    if (!Array.isArray(record.unverified))
        issues.push('unverified');
    if (!Array.isArray(record.blockers))
        issues.push('blockers');
    if (containsPlaintextSecret(proof))
        issues.push('plaintext_secret');
    if (record.status === 'failed')
        issues.push('proof_failed');
    return {
        ok: issues.length === 0,
        status: issues.length ? 'failed' : String(record.status || 'not_verified'),
        issues
    };
}
//# sourceMappingURL=validation.js.map