// engine/autopilot/trigger-rules.ts — SPEC-413: Catalog of default trigger rules
export const DEFAULT_TRIGGER_RULES = [
    // ── post spec:created ──────────────────────────────────────────────────────
    {
        id: 'post-create:validate_criteria_quality',
        event: 'spec:created',
        action: 'validate_criteria_quality',
        enabled: true,
        description: 'Scores EARS quality of acceptance criteria after spec creation',
    },
    {
        id: 'post-create:suggest_criteria',
        event: 'spec:created',
        action: 'suggest_criteria',
        enabled: true,
        description: 'Suggests missing domain criteria (security, compliance, edge cases)',
    },
    {
        id: 'post-create:detect_contradictions',
        event: 'spec:created',
        action: 'detect_contradictions',
        enabled: true,
        description: 'Runs full contradiction detection on new spec criteria',
    },
    {
        id: 'post-create:similar_problems_finder',
        event: 'spec:created',
        action: 'similar_problems_finder',
        enabled: true,
        description: 'Finds similar past specs to surface reusable patterns and avoid duplication',
    },
    {
        id: 'post-create:analyze_spec_size',
        event: 'spec:created',
        action: 'analyze_spec_size',
        enabled: true,
        description: 'Analyzes spec complexity and flags specs exceeding the split threshold',
    },
    {
        id: 'post-create:run_spec_lint',
        event: 'spec:created',
        action: 'run_spec_lint',
        enabled: true,
        description: 'Runs custom lint rules against the new spec for project-specific conventions',
    },
    {
        id: 'post-create:ears_lint',
        event: 'spec:created',
        action: 'ears_lint',
        enabled: true,
        description: 'Runs EARS compliance lint across all specs to track project-wide criteria quality',
    },
    {
        id: 'post-create:heal_spec_docs',
        event: 'spec:created',
        action: 'heal_spec_docs',
        enabled: true,
        description: 'Repairs placeholder technical.md and non-English titles after spec creation',
    },
    // ── post spec:status:approved ──────────────────────────────────────────────
    {
        id: 'post-approved:challenge_spec',
        event: 'spec:status:approved',
        action: 'challenge_spec',
        enabled: true,
        condition: { minEstimatedHours: 20, riskLevel: ['high', 'critical'] },
        description: 'Stress-tests approved specs with >20h estimate or high risk',
    },
    {
        id: 'post-approved:spec_quality_score',
        event: 'spec:status:approved',
        action: 'spec_quality_score',
        enabled: true,
        description: 'Generates A-F quality score at approval time',
    },
    {
        id: 'post-approved:generate_orchestration_plan',
        event: 'spec:status:approved',
        action: 'generate_orchestration_plan',
        enabled: true,
        condition: { minEstimatedHours: 20 },
        description: 'Suggests multi-agent plan for large specs (>20h)',
    },
    {
        id: 'post-approved:spec_health_check',
        event: 'spec:status:approved',
        action: 'spec_health_check',
        enabled: true,
        description: 'Runs health check on approved spec to detect structural issues before implementation',
    },
    {
        id: 'post-approved:check_parallel_safety',
        event: 'spec:status:approved',
        action: 'check_parallel_safety',
        enabled: true,
        description: 'Analyzes file-level conflicts to determine if spec can be implemented in parallel',
    },
    // ── post spec:status:implementing ─────────────────────────────────────────
    {
        id: 'post-implementing:tdd_scaffold',
        event: 'spec:status:implementing',
        action: 'tdd_scaffold',
        enabled: true,
        description: 'Generates test scaffold from acceptance criteria when implementation starts',
    },
    {
        id: 'post-implementing:generate_edge_tests',
        event: 'spec:status:implementing',
        action: 'generate_edge_tests',
        enabled: true,
        description: 'Generates edge-case test stubs from spec criteria in parallel with TDD scaffold',
    },
    {
        id: 'post-implementing:watch_spec_drift_start',
        event: 'spec:status:implementing',
        action: 'watch_spec_drift',
        enabled: true,
        description: 'Starts file watcher for real-time drift detection',
    },
    // ── post spec:status:done ──────────────────────────────────────────────────
    {
        id: 'post-done:watch_spec_drift_stop',
        event: 'spec:status:done',
        action: 'watch_spec_drift',
        enabled: true,
        description: 'Stops drift watcher when spec is marked done',
    },
    // SPEC-649: post-done cascade reduced to 2 actions (session.json + pending.json).
    // The rules below are kept in the registry for manual invocation but disabled from auto-cascade.
    {
        id: 'post-done:scan_crash_risks',
        event: 'spec:status:done',
        action: 'scan_crash_risks',
        enabled: false,
        condition: { field: 'score', operator: 'lt', value: 80 },
        description: 'Scans for crash risks — disabled from auto-cascade (SPEC-649), run manually.',
    },
    {
        id: 'post-done:auto_fix_health',
        event: 'spec:status:done',
        action: 'auto_fix_health',
        enabled: false,
        description: 'Auto-repairs health issues — disabled from auto-cascade (SPEC-649), run manually.',
    },
    {
        id: 'post-done:generate_changelog',
        event: 'spec:status:done',
        action: 'generate_changelog',
        enabled: false,
        description: 'Changelog written at release time only — disabled from auto-cascade (SPEC-649).',
    },
    {
        id: 'post-done:auto_fix_validation',
        event: 'spec:status:done',
        action: 'auto_fix_validation',
        enabled: false,
        condition: { field: 'validateScore', operator: 'lt', value: 80 },
        description: 'Validation healing — disabled from auto-cascade (SPEC-649), run manually.',
    },
    {
        id: 'post-done:calibrate_estimates',
        event: 'spec:status:done',
        action: 'calibrate_estimates',
        enabled: false,
        description: 'Estimate calibration — disabled from auto-cascade (SPEC-649), run manually.',
    },
    {
        id: 'post-done:coverage_gap_analyzer',
        event: 'spec:status:done',
        action: 'coverage_gap_analyzer',
        enabled: false,
        description: 'Coverage gap analysis — disabled from auto-cascade (SPEC-649), run manually.',
    },
    // ── drift:detected ────────────────────────────────────────────────────────
    {
        id: 'drift-detected:resolve_drift_violations',
        event: 'drift:detected',
        action: 'resolve_drift_violations',
        enabled: true,
        condition: { minDriftScore: 0.3 },
        description: 'Auto-resolves drift violations when score exceeds threshold',
    },
    {
        id: 'drift-detected:log_lesson',
        event: 'drift:detected',
        action: 'log_lesson',
        enabled: true,
        description: 'Logs lesson learned when drift is detected',
    },
    // ── cron:daily ────────────────────────────────────────────────────────────
    {
        id: 'cron:health_check_all',
        event: 'cron:daily',
        action: 'health_check_all',
        enabled: false,
        description: 'Daily health check across all specs (opt-in)',
    },
    {
        id: 'cron:velocity_report',
        event: 'cron:daily',
        action: 'velocity_report',
        enabled: false,
        description: 'Daily velocity metrics (opt-in)',
    },
    {
        id: 'cron:estimation_accuracy_report',
        event: 'cron:daily',
        action: 'estimation_accuracy_report',
        enabled: false,
        description: 'Daily estimation calibration (opt-in)',
    },
];
//# sourceMappingURL=trigger-rules.js.map