/**
 * Whether an entity diagnostic prevents a completeness claim.
 *
 * This is deliberately total over `EntityDiagnosticCode`: adding a diagnostic
 * requires choosing its evidence semantics here, rather than silently treating
 * a new failure mode as proof of completeness.
 */
const ENTITY_DIAGNOSTIC_EVIDENCE_CLASSIFICATION = {
    'commit-window-truncated': 'truncation',
    'commit-files-truncated': 'truncation',
    'blob-missing': 'evidence-gap',
    'blob-too-large': 'evidence-gap',
    'blob-too-many-lines': 'evidence-gap',
    'blob-binary': 'evidence-gap',
    'blob-unsupported': 'evidence-gap',
    'parse-failed': 'evidence-gap',
    'blob-budget-exhausted': 'truncation',
    'entities-truncated': 'truncation',
    'entity-budget-exhausted': 'truncation',
    'event-budget-exhausted': 'truncation',
    'cross-file-skipped': 'truncation',
    'similarity-skipped': 'truncation',
    'ambiguity-refused': 'evidence-gap',
    // Telemetry only in parser contract v3: the matcher still follows its prior
    // fallback ladder after a decline, so this must not change completeness yet.
    'lineage-accept-declined': 'informational',
    'evidence-unavailable': 'evidence-gap',
    'inline-context-stale': 'evidence-gap',
    'grammar-verification-refused': 'evidence-gap',
    'shallow-history': 'evidence-gap',
    'unborn-repo': 'evidence-gap',
    'merge-side-changes-skipped': 'evidence-gap',
    'index-unmerged': 'evidence-gap',
    'index-visibility-hidden': 'evidence-gap',
    'cache-rebuilt': 'informational',
    'cache-rewound': 'informational',
    'history-rewritten': 'informational',
};
function codesInClass(...classes) {
    const wanted = new Set(classes);
    return Object.entries(ENTITY_DIAGNOSTIC_EVIDENCE_CLASSIFICATION)
        .filter(([, classification]) => wanted.has(classification))
        .map(([code]) => code);
}
/** Bound exhaustion and deliberately skipped bounded work. */
export const TRUNCATION_CODES = new Set(codesInClass('truncation'));
/** Every diagnostic that prevents OCC from claiming complete semantic evidence. */
export const ENTITY_EVIDENCE_GAP_CODES = new Set(codesInClass('truncation', 'evidence-gap'));
export const ENTITY_EVIDENCE_GAP_REASON_LIMIT = 5;
/** Project the wide evidence-gap set into a bounded, renderable honesty block. */
export function summarizeEntityEvidenceGaps(diagnostics, limit = ENTITY_EVIDENCE_GAP_REASON_LIMIT) {
    const matching = diagnostics.filter(isEntityEvidenceGapDiagnostic);
    return {
        count: matching.length,
        reasons: matching.slice(0, Math.max(0, limit)),
    };
}
/**
 * Ambiguity has two observations: declined match pairs and emitted refusal
 * diagnostics. They are intentionally additive because neither subsumes the
 * other (one refusal can orphan records on both sides of a transition).
 */
export function countEntityAmbiguityEvidence(ambiguitiesRefused, diagnostics) {
    return ambiguitiesRefused + diagnostics.filter(diagnostic => diagnostic.code === 'ambiguity-refused').length;
}
export function isEntityEvidenceGapDiagnostic(diagnostic) {
    const code = typeof diagnostic === 'string' ? diagnostic : diagnostic.code;
    return ENTITY_EVIDENCE_GAP_CODES.has(code);
}
//# sourceMappingURL=evidence.js.map