import * as pb from "../proto/orchestrator_service_pb"; import type { OrchestrationExecutionResult } from "./orchestration-executor"; /** * Build an {@link OrchestrationExecutionResult} containing a {@link pb.RewindOrchestrationAction}. * * When the worker detects an `executionRewound` event in the new events (that does not yet * appear in the committed history) it rewrites the history by removing failed task results * (`taskFailed`) and failed sub-orchestration results (`subOrchestrationInstanceFailed`). The * `executionRewound` event is kept so the backend knows why the rewind happened and so it * remains in the history for audit purposes. * * For failed activities, the corresponding `taskScheduled` event is also removed so that the * SDK will re-generate a `scheduleTask` action during the next replay, causing the backend to * re-dispatch the activity. * * For failed sub-orchestrations, the `subOrchestrationInstanceCreated` event is kept so the * backend can identify which sub-orchestration instances to recursively rewind. * * Known limitation (shared with the Core/.NET/Python rewind): timer events * (`timerCreated` / `timerFired`) emitted between retry attempts of an activity scheduled * with a `RetryPolicy` are not removed. On the next replay the regenerated `scheduleTask` * action may not line up with those retained timer events, which can surface as a * non-determinism mismatch. Rewinding an activity that used a retry policy is therefore not * currently supported. * * WARNING!!!: * If any changes are made to how this function modifies the orchestration's history, then * corresponding changes *must* be made in the backend implementations that rely on this * function for executing a rewind (e.g. the in-memory backend and the DTS backend). * * @param oldEvents - the committed history events for the instance * @param newEvents - the newly received events, which must be exactly * `[orchestratorStarted, executionRewound]` * @returns an execution result whose single action is a `rewindOrchestration` action carrying * the cleaned-up history */ export declare function buildRewindResult(oldEvents: pb.HistoryEvent[], newEvents: pb.HistoryEvent[]): OrchestrationExecutionResult;