/**
 * Git error classification and retry configuration for persistence adapters.
 *
 * Pure functions that classify raw Git plumbing errors into typed
 * PersistenceError categories. Extracted from GitGraphAdapter to keep
 * the adapter under the 500 LOC limit.
 */
import PersistenceError from '../../domain/errors/PersistenceError.ts';
import type { OperationPolicyExecuteOptions } from '../../ports/OperationPolicyPort.ts';
export interface GitErrorDetails {
    readonly stderr?: string;
    readonly stdout?: string;
    readonly code?: number;
}
/** Shape of errors produced by @git-stunts/plumbing commands. */
export interface GitError extends Error {
    readonly details?: GitErrorDetails;
    readonly exitCode?: number;
    /**
     * Upstream plumbing commands use `code` for a numeric exit/errno
     * value. When a non-Error throwable is wrapped into a PersistenceError
     * by `toGitError`, the WarpError inheritance surfaces `code` as a
     * string — accept both at the boundary so the union narrows cleanly.
     */
    readonly code?: number | string;
}
/** Shape of a stream with a collect() method from plumbing. */
export interface CollectableStream extends AsyncIterable<Uint8Array> {
    collect(opts?: {
        asString?: boolean;
        maxBytes?: number;
    }): Promise<Buffer | string>;
}
/** Minimal contract for the plumbing dependency injected into adapters. */
export interface GitPlumbing {
    readonly emptyTree: string;
    execute(options: {
        args: string[];
        input?: string | Buffer;
    }): Promise<string>;
    executeStream(options: {
        args: string[];
    }): Promise<CollectableStream>;
}
/** Extracts the exit code from a Git command error. */
export declare function getExitCode(err: GitError): number | undefined;
/**
 * Returns stderr+stdout diagnostic text, ignoring wrapper messages
 * like "Git command failed with code 1" that carry no object-lookup semantics.
 */
export declare function gitDiagnosticText(err: GitError): string;
/** Does the error indicate a dangling or missing Git object at exit code 128? */
export declare function isDanglingObjectError(err: GitError): boolean;
interface GitErrorHint {
    readonly ref?: string;
    readonly oid?: string;
}
/**
 * Wraps a raw Git error in a typed PersistenceError when the failure
 * matches a known pattern. Returns the original error unchanged otherwise.
 */
export declare function wrapGitError(err: GitError, hint?: GitErrorHint): GitError | PersistenceError;
/** Default retry options for git operations. Exponential backoff with jitter. */
export declare const DEFAULT_RETRY_OPTIONS: OperationPolicyExecuteOptions;
/**
 * Narrows a caught unknown to GitError for classification functions.
 * This is the single boundary parser for Git plumbing errors.
 *
 * Non-`Error` throwables are wrapped in a `PersistenceError` with
 * `E_MISSING_OBJECT` — the adapter-boundary representation of an
 * opaque git failure. The return type is `GitError | PersistenceError`
 * so downstream classifiers can read `details` / `exitCode` / `code`
 * defensively on the git-surface branch and `instanceof
 * PersistenceError` on the wrapped branch.
 */
export declare function toGitError(err: unknown): GitError | PersistenceError;
export {};
