import { addLesson, getLessons } from '../../../storage/lessons-store.js';
async function handler(ctx) {
    const { spec, projectId, projectPath, validateScore } = ctx;
    // Guard: original inline guard is validateScore !== null && validateScore < 70 && projectPath
    if (validateScore === null || validateScore >= 70 || !projectPath) {
        return;
    }
    try {
        const existing = await getLessons(projectPath, {
            specId: spec.id,
            category: 'architecture',
            tags: ['auto-captured'],
        });
        if (existing.length > 0) {
            return;
        }
        await addLesson(projectPath, {
            projectId,
            specId: spec.id,
            category: 'architecture',
            severity: 'medium',
            title: `Spec drift detected on ${spec.title}`,
            description: 'Implementation drifted from spec definition',
            prevention: 'Run validate earlier in the implementation cycle',
            tags: ['auto-captured', 'drift'],
        });
    }
    catch {
        /* best-effort — never throw */
    }
}
export const lessonDriftHook = {
    id: 'lesson-drift',
    triggers: ['done'],
    requiresProjectPath: true,
    label: 'Auto-capture lesson drift when validateScore < 70 on done (SPEC-248)',
    handler,
};
//# sourceMappingURL=lesson-drift.hook.js.map