import type { WorktreeParallelTask } from "./types.js"; export type WorktreeLifecyclePhase = "creating" | "setting-up" | "ready" | "removing" | "orphaned"; export interface WorktreeLifecycleOptions { readonly repositoryRoot: string; readonly worktreeRoot?: string; readonly gitPath?: string; } export interface WorktreeBasePin { readonly repositoryRoot: string; readonly sha: string; } export interface WorktreeSetupHook { readonly executable: string; readonly args?: readonly string[]; readonly timeoutMs?: number; } export interface WorktreeCreateRequest { readonly pin: WorktreeBasePin; readonly tasks: readonly WorktreeParallelTask[]; readonly setupHooks?: readonly WorktreeSetupHook[]; } export interface WorktreeCreateAtBaseRequest { readonly authority: WorktreeBasePin; readonly baseSha: string; readonly tasks: readonly WorktreeParallelTask[]; readonly setupHooks?: readonly WorktreeSetupHook[]; } export interface ManagedWorktree { readonly identity: string; readonly path: string; readonly branch: string; readonly baseSha: string; readonly phase: WorktreeLifecyclePhase; } export type WorktreeLifecycleErrorCode = "invalid-request" | "invalid-repository" | "dirty-tree" | "stale-base" | "git-failed" | "setup-failed" | "unsafe-cleanup" | "inventory-locked" | "corrupt-inventory"; export declare class WorktreeLifecycleError extends Error { readonly code: WorktreeLifecycleErrorCode; constructor(code: WorktreeLifecycleErrorCode, message: string); } export declare class WorktreeLifecycle { private readonly repositoryRoot; private readonly worktreeRoot; private readonly gitPath; private readonly commonGitDir; private readonly rootIdentity; private readonly inventoryRoot; private readonly inventoryPath; private readonly leaseRegistry; private readonly gitEnv; private inventory; private readonly inFlight; private writeQueue; private transactionQueue; private transactionLease; private readonly directParentAttestations; private constructor(); static open(options: WorktreeLifecycleOptions): Promise; pathPrefixFor(worktreeId: string): string; pinCleanBase(): Promise; createMany(request: WorktreeCreateRequest): Promise; createManyAtBase(request: WorktreeCreateAtBaseRequest): Promise; private createManyAtBaseInternal; cleanup(worktreeId: string): Promise; /** Discards only quiescent dirt inside one owned cancelled dispatch scope. */ discardOwnedChanges(worktreeId: string, managedPath: string, baseSha: string, branch: string, scopeWrite: readonly string[]): Promise; hasManagedWorktree(worktreeId: string): Promise; acceptCommit(worktreeId: string, managedPath: string, baseSha: string, commitSha: string, branch: string): Promise; reconcile(): Promise; private validateHook; private validateTask; private publicRecord; private git; private runSetupHook; private terminateProcessTree; private waitForClose; private runExecutable; private assertClean; private isClean; private assertAuthorityAndBase; private listWorktrees; private refSha; private branchExists; private attestDirectParent; private exactEntry; private createAndLock; private addWorktree; private requireOwnedRecord; private isDirectManagedPath; private isDirectManagedRecord; private targetInfo; private targetMatches; private assertCreationIdentity; private assertRootIdentity; private orphanOwnedRecords; private orphan; private withInventoryTransaction; private acquireInventoryLease; private loadInventory; private saveInventory; }