/** * 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; /** * Check if there's a pending improvement. * * @returns True if a pending improvement marker exists */ hasPendingImprovement(): Promise; /** * Get the pending improvement marker. * * @returns The improvement marker or null if none exists */ getPendingImprovement(): Promise; /** * 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; /** * Update marker phase. * * @param phase - New phase to set * @returns Updated marker or null if no pending marker */ updatePhase(phase: ImprovementPhase): Promise; /** * Increment restart count (called on each startup). * * @returns New restart count */ incrementRestartCount(): Promise; /** * 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; /** * Record that changes have been applied. * * @param changes - Array of applied changes */ recordChangesApplied(changes: Array<{ file: string; type: 'create' | 'modify' | 'delete'; description: string; }>): Promise; /** * Record validation result. * * @param result - Validation result to record */ recordValidationResult(result: ValidationResult): Promise; /** * Record rollback started. * * @param reason - Reason for rollback */ recordRollbackStarted(reason: string): Promise; /** * Record rollback completed. * * @param filesRestored - List of restored file paths * @param gitReset - Whether git reset was used */ recordRollbackCompleted(filesRestored: string[], gitReset: boolean): Promise; /** * Record error information. * * @param message - Error message * @param stack - Optional stack trace */ recordError(message: string, stack?: string): Promise; /** * Complete the improvement (move to history). * * @param success - Whether the improvement was successful */ completeImprovement(success: boolean): Promise; /** * Delete marker without saving to history (for cancelled improvements). */ deleteMarker(): Promise; /** * 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; } /** * 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