/**
 * @fileoverview RalphPlanTracker - Enhanced plan task management
 *
 * Manages plan tasks with verification criteria, dependencies,
 * execution tracking, TDD workflow support, and plan versioning.
 *
 * Extracted from ralph-tracker.ts as part of domain splitting.
 *
 * @module ralph-plan-tracker
 */
import { EventEmitter } from 'node:events';
import type { PlanTaskStatus, TddPhase } from './types.js';
/**
 * Enhanced plan task with verification criteria, dependencies, and execution tracking.
 * Supports TDD workflow, failure tracking, and plan versioning.
 */
export interface EnhancedPlanTask {
    /** Unique identifier (e.g., "P0-001") */
    id: string;
    /** Task description */
    content: string;
    /** Criticality level */
    priority: 'P0' | 'P1' | 'P2' | null;
    /** How to verify completion */
    verificationCriteria?: string;
    /** Command to run for verification */
    testCommand?: string;
    /** IDs of tasks that must complete first */
    dependencies: string[];
    /** Current execution status */
    status: PlanTaskStatus;
    /** How many times attempted */
    attempts: number;
    /** Most recent failure reason */
    lastError?: string;
    /** Timestamp of completion */
    completedAt?: number;
    /** Plan version this belongs to */
    version: number;
    /** TDD phase category */
    tddPhase?: TddPhase;
    /** ID of paired test/impl task */
    pairedWith?: string;
    /** Estimated complexity */
    complexity?: 'low' | 'medium' | 'high';
    /** Checklist items for review tasks (tddPhase: 'review') */
    reviewChecklist?: string[];
}
/** Checkpoint review data */
export interface CheckpointReview {
    iteration: number;
    timestamp: number;
    summary: {
        total: number;
        completed: number;
        failed: number;
        blocked: number;
        pending: number;
        inProgress: number;
    };
    stuckTasks: Array<{
        id: string;
        content: string;
        attempts: number;
        lastError?: string;
    }>;
    recommendations: string[];
}
/**
 * RalphPlanTracker - Manages enhanced plan tasks with versioning and checkpoints.
 *
 * Events emitted:
 * - `planInitialized` - When a new plan is initialized
 * - `planTaskUpdate` - When a plan task is updated
 * - `taskBlocked` - When a task becomes blocked after too many failures
 * - `taskUnblocked` - When a task's dependencies are all met
 * - `planCheckpoint` - When a checkpoint review is triggered
 * - `planTaskAdded` - When a new task is added to the plan
 * - `planRollback` - When the plan is rolled back to a previous version
 */
export declare class RalphPlanTracker extends EventEmitter {
    /** Current version of the plan (incremented on changes) */
    private _planVersion;
    /** History of plan versions for rollback support */
    private _planHistory;
    /** Enhanced plan tasks with execution tracking */
    private _planTasks;
    /** Checkpoint intervals (iterations at which to trigger review) */
    private _checkpointIterations;
    /** Last checkpoint iteration */
    private _lastCheckpointIteration;
    /** Current cycle count (fed by parent via notifyCycleCount) */
    private _cycleCount;
    constructor();
    /**
     * Notify the plan tracker of the current cycle count.
     * Called by parent when iteration changes (for checkpoint detection).
     */
    notifyCycleCount(cycleCount: number): void;
    /**
     * Initialize plan tasks from generated plan items.
     * Called when wizard generates a new plan.
     */
    initializePlanTasks(items: Array<{
        id?: string;
        content: string;
        priority?: 'P0' | 'P1' | 'P2' | null;
        verificationCriteria?: string;
        testCommand?: string;
        dependencies?: string[];
        tddPhase?: TddPhase;
        pairedWith?: string;
        complexity?: 'low' | 'medium' | 'high';
    }>): void;
    /**
     * Update a specific plan task's status, attempts, or error.
     */
    updatePlanTask(taskId: string, update: {
        status?: PlanTaskStatus;
        error?: string;
        incrementAttempts?: boolean;
    }): {
        success: boolean;
        task?: EnhancedPlanTask;
        error?: string;
    };
    /**
     * Add a new task to the plan (for runtime adaptation).
     */
    addPlanTask(task: {
        content: string;
        priority?: 'P0' | 'P1' | 'P2';
        verificationCriteria?: string;
        dependencies?: string[];
        insertAfter?: string;
    }): {
        task: EnhancedPlanTask;
    };
    /**
     * Get all plan tasks.
     */
    getPlanTasks(): EnhancedPlanTask[];
    /**
     * Generate a checkpoint review summarizing plan progress and stuck tasks.
     */
    generateCheckpointReview(): CheckpointReview;
    /**
     * Get plan version history.
     */
    getPlanHistory(): Array<{
        version: number;
        timestamp: number;
        summary: string;
        stats: {
            total: number;
            completed: number;
            failed: number;
        };
    }>;
    /**
     * Rollback to a previous plan version.
     */
    rollbackToVersion(version: number): {
        success: boolean;
        plan?: EnhancedPlanTask[];
        error?: string;
    };
    /**
     * Check if checkpoint review is due for current iteration.
     */
    isCheckpointDue(): boolean;
    /**
     * Get current plan version.
     */
    get planVersion(): number;
    /**
     * Reset plan state (soft reset - keeps version history).
     */
    reset(): void;
    /**
     * Full reset - clears all plan state.
     */
    fullReset(): void;
    /**
     * Clean up all resources.
     */
    destroy(): void;
    /**
     * Unblock tasks that were waiting on a completed dependency.
     */
    private _unblockDependentTasks;
    /**
     * Check if current iteration is a checkpoint and emit review if so.
     */
    private _checkForCheckpoint;
    /**
     * Save current plan state to history.
     */
    private _savePlanToHistory;
}
//# sourceMappingURL=ralph-plan-tracker.d.ts.map