import { hashText } from '../cache.js';
import { redactGraphText } from '../query.js';
function specIdFromPath(path) {
    return path.split('/').find((part) => /^SPEC-\d+$/i.test(part));
}
function basename(path) {
    return path.split('/').slice(-1)[0] ?? path;
}
export function extractValidationGraph(source, policy) {
    const specId = specIdFromPath(source.path);
    if (specId === undefined || !source.path.includes('validation')) {
        return { nodes: [], edges: [] };
    }
    const validationId = `validation:${specId}:${hashText(source.path).slice(0, 10)}`;
    const node = {
        id: validationId,
        type: 'validation',
        label: redactGraphText(basename(source.path), policy),
        source: 'validation-extractor',
        evidence: [{ path: source.path, hash: source.hash }],
        updatedAt: new Date().toISOString(),
    };
    const edge = {
        id: `edge:${hashText(`spec:${specId}:validated_by:${validationId}`)}`,
        from: `spec:${specId}`,
        to: validationId,
        type: 'validated_by',
        source: 'validation-extractor',
        confidence: 'medium',
        classification: 'extracted',
        evidence: { path: source.path, hash: source.hash },
        updatedAt: new Date().toISOString(),
    };
    return { nodes: [node], edges: [edge] };
}
//# sourceMappingURL=validation-extractor.js.map