/** * Recovery Manager * * Handles startup recovery by reconciling persisted state with physical worktrees. * Detects orphans, unlocks stuck worktrees, and cleans up abandoned resources. */ import type { Worktree } from '../types.js'; import type { PersistedState, PersistedWorktreeState, PersistedTaskState } from '../persistence/state-schema.js'; export type { PersistedState, PersistedWorktreeState, PersistedTaskState }; export interface OrphanedWorktree { id: string; path: string; branch: string; reason: 'no_task' | 'task_completed' | 'task_failed' | 'unknown_state'; physicalExists: boolean; branchExists: boolean; hasUncommittedChanges: boolean; lastActivityAt?: number; } export interface OrphanedTask { taskId: string; role: string; status: string; reason: 'no_worktree' | 'worktree_missing'; worktreeId?: string; } export interface OrphanedBranch { name: string; reason: 'no_worktree' | 'no_task'; lastCommitDate?: Date; } export interface ReconciliationResult { orphanedWorktrees: OrphanedWorktree[]; orphanedTasks: OrphanedTask[]; orphanedBranches: OrphanedBranch[]; recoveredWorktrees: string[]; recoveredTasks: string[]; stuckWorktrees: string[]; cleanedUp: string[]; errors: Array<{ resource: string; error: string; }>; } export interface RecoveryOptions { autoCleanOrphans: boolean; maxStaleAgeMs: number; preserveUncommittedChanges: boolean; dryRun: boolean; } export declare class RecoveryManager { private repoPath; private worktreeBaseDir; private branchPattern; private git; private logger; constructor(repoPath: string, worktreeBaseDir?: string, branchPattern?: string); /** * Main recovery entry point - call on server startup */ recoverOnStartup(persistedState: PersistedState | null, options?: Partial): Promise; /** * Discover all physical worktrees in the worktree directory */ private discoverPhysicalWorktrees; private getPhysicalWorktreeInfo; /** * Discover all task branches in the repository */ private discoverTaskBranches; /** * Reconcile persisted state with physical reality */ private reconcileWithPersistedState; /** * Handle case where we have no persisted state */ private handleNoPersistedState; private isStuckState; /** * Clean up orphaned resources */ private cleanupOrphans; private removeWorktree; /** * Unlock worktrees stuck in transitional states */ unlockStuckWorktrees(stuckIds: string[], worktrees: Map): Promise; /** * Prune worktrees that have been stale too long */ pruneStaleWorktrees(worktrees: Map, maxAgeMs?: number): Promise; } //# sourceMappingURL=recovery.d.ts.map