/**
 * Improvement Marker Service
 *
 * Manages a persistent marker file that tracks self-improvement
 * state across process restarts (including hot-reload).
 *
 * @module services/orchestrator/improvement-marker
 */
/**
 * Improvement phases
 */
export type ImprovementPhase = 'planning' | 'backing_up' | 'changes_applied' | 'validating' | 'rolling_back' | 'rolled_back' | 'complete';
/**
 * File backup record
 */
export interface FileBackupRecord {
    originalPath: string;
    backupPath: string;
    checksum: string;
    existed: boolean;
}
/**
 * Validation result
 */
export interface ValidationResult {
    check: string;
    passed: boolean;
    output?: string;
    duration?: number;
}
/**
 * Improvement marker data
 */
export interface ImprovementMarker {
    /** Unique improvement ID */
    id: string;
    /** Human-readable description */
    description: string;
    /** When improvement started */
    startedAt: string;
    /** Current phase */
    phase: ImprovementPhase;
    /** Number of times process has restarted during this improvement */
    restartCount: number;
    /** Last phase transition timestamp */
    lastUpdatedAt: string;
    /** Target files being modified */
    targetFiles: string[];
    /** Backup information */
    backup: {
        gitCommit?: string;
        gitBranch?: string;
        files: FileBackupRecord[];
        createdAt: string;
    };
    /** Planned changes */
    changes: Array<{
        file: string;
        type: 'create' | 'modify' | 'delete';
        description: string;
        applied: boolean;
    }>;
    /** Validation configuration and results */
    validation: {
        required: string[];
        results: ValidationResult[];
        startedAt?: string;
        completedAt?: string;
    };
    /** Rollback information */
    rollback?: {
        reason: string;
        startedAt: string;
        completedAt?: string;
        filesRestored: string[];
        gitReset?: boolean;
    };
    /** Slack notification context */
    slack?: {
        channelId: string;
        threadTs: string;
        userId: string;
    };
    /** Error information if failed */
    error?: {
        message: string;
        phase: ImprovementPhase;
        timestamp: string;
        stack?: string;
    };
}
/**
 * ImprovementMarkerService class
 *
 * Manages persistent markers for tracking self-improvement state across restarts.
 */
export declare class ImprovementMarkerService {
    private markerPath;
    private historyPath;
    /**
     * Creates an instance of ImprovementMarkerService.
     *
     * @param baseDir - Optional base directory for marker files
     */
    constructor(baseDir?: string);
    /**
     * Initialize the marker service by creating necessary directories.
     */
    initialize(): Promise<void>;
    /**
     * Check if there's a pending improvement.
     *
     * @returns True if a pending improvement marker exists
     */
    hasPendingImprovement(): Promise<boolean>;
    /**
     * Get the pending improvement marker.
     *
     * @returns The improvement marker or null if none exists
     */
    getPendingImprovement(): Promise<ImprovementMarker | null>;
    /**
     * Create a new improvement marker.
     *
     * @param id - Unique improvement ID
     * @param description - Human-readable description
     * @param targetFiles - Files to be modified
     * @param slackContext - Optional Slack notification context
     * @returns The created improvement marker
     */
    createMarker(id: string, description: string, targetFiles: string[], slackContext?: {
        channelId: string;
        threadTs: string;
        userId: string;
    }): Promise<ImprovementMarker>;
    /**
     * Update marker phase.
     *
     * @param phase - New phase to set
     * @returns Updated marker or null if no pending marker
     */
    updatePhase(phase: ImprovementPhase): Promise<ImprovementMarker | null>;
    /**
     * Increment restart count (called on each startup).
     *
     * @returns New restart count
     */
    incrementRestartCount(): Promise<number>;
    /**
     * Record backup information.
     *
     * @param gitCommit - Git commit hash for checkpoint
     * @param gitBranch - Git branch name
     * @param files - File backup records
     */
    recordBackup(gitCommit: string | undefined, gitBranch: string | undefined, files: FileBackupRecord[]): Promise<void>;
    /**
     * Record that changes have been applied.
     *
     * @param changes - Array of applied changes
     */
    recordChangesApplied(changes: Array<{
        file: string;
        type: 'create' | 'modify' | 'delete';
        description: string;
    }>): Promise<void>;
    /**
     * Record validation result.
     *
     * @param result - Validation result to record
     */
    recordValidationResult(result: ValidationResult): Promise<void>;
    /**
     * Record rollback started.
     *
     * @param reason - Reason for rollback
     */
    recordRollbackStarted(reason: string): Promise<void>;
    /**
     * Record rollback completed.
     *
     * @param filesRestored - List of restored file paths
     * @param gitReset - Whether git reset was used
     */
    recordRollbackCompleted(filesRestored: string[], gitReset: boolean): Promise<void>;
    /**
     * Record error information.
     *
     * @param message - Error message
     * @param stack - Optional stack trace
     */
    recordError(message: string, stack?: string): Promise<void>;
    /**
     * Complete the improvement (move to history).
     *
     * @param success - Whether the improvement was successful
     */
    completeImprovement(success: boolean): Promise<void>;
    /**
     * Delete marker without saving to history (for cancelled improvements).
     */
    deleteMarker(): Promise<void>;
    /**
     * Save marker to disk atomically.
     *
     * @param marker - Marker to save
     */
    private saveMarker;
    /**
     * Cleanup old history files to maintain max limit.
     */
    private cleanupHistory;
    /**
     * Get improvement history.
     *
     * @param limit - Maximum number of history items to return
     * @returns Array of historical improvement markers
     */
    getHistory(limit?: number): Promise<ImprovementMarker[]>;
}
/**
 * Get singleton instance of ImprovementMarkerService.
 *
 * @returns The singleton ImprovementMarkerService instance
 */
export declare function getImprovementMarkerService(): ImprovementMarkerService;
/**
 * Reset singleton instance (for testing).
 */
export declare function resetImprovementMarkerService(): void;
//# sourceMappingURL=improvement-marker.service.d.ts.map