/**
 * Graph type contracts for CLEO code intelligence.
 *
 * Defines the node types, relationship types, and structures that form the
 * foundation of the code intelligence graph. Ported from GitNexus graph
 * primitives and adapted for CLEO's lightweight, in-process use case.
 *
 * @task T512
 * @module contracts/graph
 */
/**
 * Map a numeric confidence value to a {@link GraphEdgeConfidenceLabel}.
 *
 * Thresholds align with the pipeline resolution tiers defined in
 * `resolution-context.ts`:
 * - ≥ 0.90 → `EXTRACTED`  (same-file 0.95, import-scoped 0.90, defines 1.0)
 * - 0.80 – 0.89 → `INFERRED`   (accesses 0.80, heritage import-scoped 0.85)
 * - < 0.80 → `AMBIGUOUS`  (global 0.50, speculative)
 *
 * @param confidence - Numeric confidence in range [0.0, 1.0]
 * @returns The corresponding three-state label
 */
export function confidenceLabelFromNumeric(confidence) {
    if (confidence >= 0.9)
        return 'EXTRACTED';
    if (confidence >= 0.8)
        return 'INFERRED';
    return 'AMBIGUOUS';
}
/**
 * Backfill a {@link ConfidenceProvenance} from a legacy numeric confidence value.
 *
 * @param confidence - Numeric confidence in range [0.0, 1.0]
 * @returns A structured provenance record consistent with the numeric value
 * @since T9145
 */
export function provenanceFromNumeric(confidence) {
    if (confidence === 1.0)
        return { kind: 'extracted', source: 'ast' };
    if (confidence >= 0.9)
        return { kind: 'extracted', source: 'legacy' };
    if (confidence >= 0.8)
        return { kind: 'inferred', heuristic: 'legacy' };
    return { kind: 'ambiguous', candidates: [] };
}
/**
 * Recover a numeric confidence value from a {@link ConfidenceProvenance} record.
 *
 * Inverse of {@link provenanceFromNumeric} for backward-compat bridging.
 *
 * @param provenance - Structured provenance record
 * @returns Best-effort numeric confidence in range [0.0, 1.0]
 * @since T9145
 */
export function confidenceFromProvenance(provenance) {
    switch (provenance.kind) {
        case 'extracted':
            return provenance.source === 'ast' ? 1.0 : 0.95;
        case 'inferred':
            return 0.85;
        case 'ambiguous':
            return 0.5;
    }
}
//# sourceMappingURL=graph.js.map