import type { BuildWorkspaceIdentity } from "../core/buildExecution.js"; import type { BuildWorkspaceInspection, BuildWorktreeOwnershipProof } from "../core/buildScheduler.js"; export interface GitCommandResult { code: number; stdout: string; stderr: string; } export interface GitRunner { run(args: readonly string[], options: { cwd: string; }): GitCommandResult; } export interface PrepareWorktreeOptions { repositoryRoot: string; candidateRoot: string; runId: string; nodeId: string; planVersion: number; planHash: string; } export interface WorktreeExecutionIntent { schemaVersion: 1; intentId: string; repositoryRoot: string; commonDir: string; candidateRoot: string; worktreePath: string; baseSha: string; branch: string; runId: string; nodeId: string; planVersion: number; planHash: string; } export interface WorktreeOwnershipRecord extends WorktreeExecutionIntent { reconciled: boolean; cleanupStatus: "active"; } export interface MaterializeWorktreeOptions { allowCreate: boolean; trustRepositoryCheckout: boolean; } export interface WorktreeChangeInspection { changedPaths: readonly string[]; stagedPaths: readonly string[]; } export interface WorktreeCleanupIntent { schemaVersion: 1; cleanupId: string; intentId: string; runId: string; nodeId: string; planVersion: number; planHash: string; repositoryRoot: string; worktreePath: string; branch: string; candidateHead: string; preparedAt: string; } export interface WorktreeCleanupReceipt { schemaVersion: 1; cleanupId: string; intentId: string; runId: string; nodeId: string; planVersion: number; planHash: string; worktreePath: string; branch: string; candidateHead: string; status: "released"; branchPreserved: true; reconciledAt: string; } /** Execute generated Git argv directly without a shell or string interpolation. */ export declare function createLocalGitRunner(options?: Readonly<{ timeoutMs?: number; }>): GitRunner; /** Reconstruct the full immutable intent from a durable planned authority. */ export declare function reconstructWorktreeIntent(options: Readonly<{ repositoryRoot: string; candidateRoot: string; }>, authorityValue: Exclude, { kind: "shared"; }>, git: GitRunner): WorktreeExecutionIntent; export declare function prepareWorktreeIntent(options: Readonly, git: GitRunner): WorktreeExecutionIntent; export declare function materializeWorktree(intentValue: Readonly, git: GitRunner, options: Readonly): WorktreeOwnershipRecord; export declare function reconcileWorktreeIntent(intentValue: Readonly, git: GitRunner): WorktreeOwnershipRecord | undefined; /** Convert an immutable worktree intent into the only planned authority accepted by BUILD dispatch. */ export declare function createPlannedBuildWorkspaceIdentity(intentValue: Readonly): Readonly; /** Reconcile Git before minting owned authority bound to the immutable effect receipt. */ export declare function createOwnedBuildWorkspaceIdentity(recordValue: Readonly, ownershipReceiptHash: string, git: GitRunner): Readonly; export declare function assertOwnedWorktree(recordValue: Readonly, git: GitRunner): void; /** Reconcile Git immediately before minting the bounded proof consumed by pure dispatch policy. */ export declare function createBuildWorktreeOwnershipProof(recordValue: Readonly, git: GitRunner): Readonly; export declare function inspectOwnedWorktreeChanges(recordValue: Readonly, declaredWriteSet: readonly string[], git: GitRunner): WorktreeChangeInspection; /** Inspect a shared BUILD workspace against the same bounded path policy. */ export declare function inspectSharedBuildWorkspace(repositoryRootValue: string, declaredWriteSet: readonly string[], git: GitRunner): WorktreeChangeInspection; /** Inspect candidate changes and reconcile Git again before returning trusted completion evidence. */ export declare function inspectOwnedBuildWorkspace(recordValue: Readonly, declaredWriteSet: readonly string[], git: GitRunner): Readonly; /** Prepare cleanup evidence without changing Git or the filesystem. */ export declare function prepareWorktreeCleanupIntent(recordValue: Readonly, git: GitRunner, now: string): WorktreeCleanupIntent; /** * Remove only the exact clean owned worktree, without force and without * deleting its branch. The caller must durably checkpoint the cleanup intent * before invoking this function. */ export declare function cleanupOwnedWorktree(cleanupValue: Readonly, recordValue: Readonly, git: GitRunner, options: Readonly<{ confirmed: boolean; now: string; }>): WorktreeCleanupReceipt; /** Reconcile a crash after non-force worktree removal without repeating it. */ export declare function reconcileWorktreeCleanup(cleanupValue: Readonly, recordValue: Readonly, git: GitRunner, now: string): WorktreeCleanupReceipt | undefined;