/**
 * A single step in a saga execution.
 *
 * @template Ctx - Shared context threaded through all steps.
 * @template Result - The return type of `run`, passed to `compensate` on rollback.
 */
export interface Step<Ctx, Result = unknown> {
    /** Human-readable step identifier (used in logs and error messages). */
    name: string;
    /**
     * When true, a failure in this step triggers reverse-execution of all
     * previously completed compensations and a full saga rollback.
     * When false, the failure is collected as a warning and execution continues.
     */
    critical: boolean;
    /** The forward action. Must not mutate compensations of earlier steps. */
    run: (ctx: Ctx) => Promise<Result>;
    /**
     * The compensating action, invoked in reverse order when a later critical
     * step fails. Must be idempotent — it may be called more than once safely.
     */
    compensate?: (ctx: Ctx, result: Result | undefined) => Promise<void>;
}
/** Result returned by `runSaga` after all steps have been executed or rolled back. */
export interface SagaResult<Ctx = unknown> {
    /** True when all critical steps succeeded and no rollback occurred. */
    ok: boolean;
    /** Name of the step that triggered a rollback (undefined when ok). */
    failedStep?: string;
    /** The error thrown by the failing step (undefined when ok). */
    error?: Error;
    /** True when compensating actions were invoked (rollback executed). */
    rolledBack: boolean;
    /** Warnings collected from non-critical failures. */
    warnings: {
        step: string;
        error: string;
    }[];
    _ctx?: Ctx;
}
/** Record of a completed step used internally during rollback. */
export interface CompletedStep<Ctx, Result = unknown> {
    step: Step<Ctx, Result>;
    result: Result | undefined;
}
import type { SpecStatus } from './index.js';
/** Context threaded through all cascade steps in the transition saga. */
export interface TransitionCascadeCtx {
    specId: string;
    specTitle: string;
    projectId: string;
    prevStatus: SpecStatus;
    newStatus: SpecStatus;
    actor: string;
    sessionId?: string;
    projectPath?: string;
}
/** Result returned by runTransitionCascadeSaga. */
export interface TransitionCascadeResult {
    ok: boolean;
    rolledBack: boolean;
    failedStep?: string;
    error?: string;
    code?: number;
    warnings: {
        step: string;
        error: string;
    }[];
}
//# sourceMappingURL=saga.d.ts.map