/** * Worktree Pool * * Maintains a pool of pre-created worktrees for faster allocation. * Reduces latency by having worktrees ready before tasks need them. */ import type { WorktreeManager } from './manager.js'; import type { ResourceManager } from './resource-manager.js'; import type { Worktree } from '../types.js'; export interface PoolConfig { /** Whether the pool is enabled */ enabled: boolean; /** Minimum worktrees to keep ready */ minSize: number; /** Maximum pool size */ maxSize: number; /** Base branch for pre-warmed worktrees */ preWarmBranch?: string; } export interface PoolStats { /** Number of worktrees available in the pool */ available: number; /** Number of worktrees currently in use */ inUse: number; /** Total number of worktrees managed */ total: number; /** Number of pool hits (fast allocation from pool) */ hits: number; /** Number of pool misses (had to create new worktree) */ misses: number; /** Hit rate (hits / total acquisitions) */ hitRate: number; } export declare class WorktreePool { private readonly worktreeManager; private readonly resourceManager; private readonly config; private readonly logger; private availableWorktrees; private hits; private misses; private initialized; constructor(worktreeManager: WorktreeManager, resourceManager: ResourceManager, config?: Partial); /** * Initialize the pool with pre-warmed worktrees. */ initialize(): Promise; /** * Acquire a worktree from the pool or create a new one. * Returns null if allocation is not allowed (resource limits). */ acquire(taskId: string): Promise; /** * Release a worktree back to the pool or dispose it. * @param worktreeId - The worktree to release * @param returnToPool - Whether to return to pool (true) or remove entirely (false) */ release(worktreeId: string, returnToPool?: boolean): Promise; /** * Replenish the pool to minimum size. * Creates new worktrees in the background to maintain pool availability. */ replenish(): Promise; /** * Drain all worktrees from the pool. * Removes all pre-warmed worktrees (useful for shutdown or reconfiguration). */ drain(): Promise; /** * Resize the pool to new limits. * Drains excess worktrees or replenishes to meet new minimum. */ resize(newMinSize: number, newMaxSize: number): Promise; /** * Get pool statistics. */ getStats(): PoolStats; /** * Check if pool is enabled. */ isEnabled(): boolean; /** * Check if pool is initialized. */ isInitialized(): boolean; /** * Get pool configuration. */ getConfig(): PoolConfig; /** * Reset pool statistics. */ resetStats(): void; } //# sourceMappingURL=pool.d.ts.map