import type { RestartExecutionParams, StepResult, WorkflowRunState } from '../../types.js';
import type { LeafEntry } from './routing.js';
/**
 * What a worker does with a delivery of a step occurrence: run the step, drop
 * the delivery because the occurrence already finished and the run moved on,
 * or continue the run from the result the occurrence saved.
 */
export type FinishedOccurrence = 'run' | 'drop' | {
    continueFrom: StepResult<any, any, any, any>;
};
/**
 * Decides whether the leaf step occurrence a delivery names still has to run,
 * from the run's stored snapshot.
 *
 * A delivery can reach a worker after its occurrence finished: a broker
 * redelivery or a message that sat in a backlog while `restart()` ran the step,
 * or a restart that read the snapshot just before the step saved its result.
 * The stored record ends the occurrence when it is terminal and newer than the
 * record the delivery carried, so a step id used twice in one graph still runs
 * its second occurrence. For the steps a restart dispatches, any terminal
 * record ends them. For a loop body, a stored record from a later iteration
 * ends the iteration too. Foreach items are read from the foreach step's
 * per-item records.
 *
 * A finished occurrence continues the run from its saved result while the run
 * has not started a later step, which recovers a run whose worker stopped
 * after the step saved its result and before the next step was published.
 * A top-level step shows that through the run's active path. A branch
 * continues only when a restart dispatched it, since the restart is then what
 * recovers the run, and only while the run's active path is still inside the
 * branch's parallel or conditional entry. Any other finished delivery is
 * dropped.
 *
 * `stepGuards` tells whether the store has workflow step guards. Records they
 * stamped are left to the guards on the deliveries the guards arbitrate
 * (`guarded`), so a delivery never continues the run through both paths.
 */
export declare function finishedOccurrence({ step, executionPath, stepResults, restart, snapshot, stepGuards, guarded, }: {
    step: LeafEntry;
    executionPath: number[];
    stepResults: Record<string, StepResult<any, any, any, any>> | undefined;
    restart: RestartExecutionParams | undefined;
    snapshot: WorkflowRunState | null | undefined;
    stepGuards: boolean;
    guarded: boolean;
}): FinishedOccurrence;
//# sourceMappingURL=finished-occurrence.d.ts.map