anchor.diff:      CurrentRunNum;
   resolve_run_selector(RunNum, _) ->
       RunNum.
  +
  +
  +%% @private
  +-spec resolve_task_id(atm_task_execution:id() | task_selector(), ctx()) ->
  +    atm_task_execution:id().
  +resolve_task_id(AtmTaskExecutionId, _ExpStateCtx) when is_binary(AtmTaskExecutionId) ->
  +    AtmTaskExecutionId;
  +resolve_task_id(AtmTaskExecutionSelector, ExpStateCtx) ->
  +    get_task_id(AtmTaskExecutionSelector, ExpStateCtx).
   
   
   %% @private
  
positive.code: -type task_registry() :: #{AtmTaskSchemaId :: automation:id() => atm_task_execution:id()}.
  -type task_selector() :: {atm_lane_execution:lane_run_selector(), automation:id(), automation:id()}.
  
  -type log_fun() :: fun((binary(), [term()]) -> ok).
  
  -export_type([ctx/0, task_selector/0]).
  
  
  -define(JSON_PATH(__QUERY_BIN), binary:split(__QUERY_BIN, <<".">>, [global])).
  
negative.code: 
              <<"status">> => <<"scheduled">>,
  
              <<"scheduleTime">> => build_timestamp_field_validator(?NOW()),
              <<"startTime">> => 0,
              <<"suspendTime">> => 0,
              <<"finishTime">> => 0
          },
          exp_task_execution_state_ctx_registry = #{}
      }.
  
  
  -spec expect(ctx(), expectation() | [expectation()]) -> ctx().
  expect(ExpStateCtx, {current_lane_run_selector, {AtmLaneIndex, AtmRunNum}}) ->
      set_current_lane_run(AtmLaneIndex, AtmRunNum, ExpStateCtx);
  
  expect(ExpStateCtx, {task, AtmTaskExecutionIdOrSelector, ExpStatus}) when
      ExpStatus =:= resuming;
      ExpStatus =:= pending;
      ExpStatus =:= active;
      ExpStatus =:= stopping;
      ExpStatus =:= skipped;
      ExpStatus =:= finished;
      ExpStatus =:= failed;
      ExpStatus =:= cancelled;
      ExpStatus =:= paused;
      ExpStatus =:= interrupted
  ->
      AtmTaskExecutionId = resolve_task_id(AtmTaskExecutionIdOrSelector, ExpStateCtx),
      expect_task_transitioned_to(AtmTaskExecutionId, str_utils:to_binary(ExpStatus), ExpStateCtx);
  
  expect(ExpStateCtx, {all_tasks, AtmLaneRunSelector, ExpStatus}) when
      ExpStatus =:= resuming;
      ExpStatus =:= pending;
      ExpStatus =:= active;
      ExpStatus =:= stopping;
      ExpStatus =:= skipped;
      ExpStatus =:= finished;
      ExpStatus =:= failed;
      ExpStatus =:= cancelled;
      ExpStatus =:= paused;
      ExpStatus =:= interrupted
  ->
      expect_all_tasks_transitioned_to(AtmLaneRunSelector, str_utils:to_binary(ExpStatus), ExpStateCtx);
  
  expect(ExpStateCtx, {all_tasks, AtmLaneRunSelector, abruptly, ExpStoppedStatus}) when
      ExpStoppedStatus =:= failed;
      ExpStoppedStatus =:= cancelled;
      ExpStoppedStatus =:= interrupted
  ->
      expect_all_tasks_abruptly_stopped(AtmLaneRunSelector, str_utils:to_binary(ExpStoppedStatus), ExpStateCtx);
  
  expect(ExpStateCtx, {all_tasks, AtmLaneRunSelector, stopping_due_to, Reason}) when
      Reason =:= pause;
      Reason =:= interrupt;
      Reason =:= cancel
  ->
      expect_all_tasks_stopping_due_to(AtmLaneRunSelector, Reason, ExpStateCtx);
  
  expect(ExpStateCtx, {lane_run, AtmLaneRunSelector, automatic_retry_scheduled}) ->
      expect_lane_run_automatic_retry_scheduled(AtmLaneRunSelector, ExpStateCtx);
  
  expect(ExpStateCtx, {lane_run, AtmLaneRunSelector, manual_retry_scheduled, NewRunNum}) ->
      expect_lane_run_manual_repeat_scheduled(retry, AtmLaneRunSelector, NewRunNum, ExpStateCtx);
  
  expect(ExpStateCtx, {lane_run, AtmLaneRunSelector, manual_rerun_scheduled, NewRunNum}) ->
      expect_lane_run_manual_repeat_scheduled(rerun, AtmLaneRunSelector, NewRunNum, ExpStateCtx);
  
  expect(ExpStateCtx, {lane_run, AtmLaneRunSelector, manual_repeat_scheduled, RepeatType, NewRunNum}) ->
      expect_lane_run_manual_repeat_scheduled(RepeatType, AtmLaneRunSelector, NewRunNum, ExpStateCtx);
  
  expect(ExpStateCtx, {lane_run, AtmLaneRunSelector, started_preparing}) ->
      expect_lane_run_started_preparing(AtmLaneRunSelector, ExpStateCtx);
  
  expect(ExpStateCtx, {lane_run, AtmLaneRunSelector, started_preparing_as_current_lane_run}) ->
      expect_current_lane_run_started_preparing(AtmLaneRunSelector, ExpStateCtx);
  
  expect(ExpStateCtx, {lane_run, AtmLaneRunSelector, started_preparing_in_advance}) ->
      expect_lane_run_started_preparing_in_advance(AtmLaneRunSelector, ExpStateCtx);
  
  expect(ExpStateCtx, {lane_run, AtmLaneRunSelector, created}) ->
      expect_lane_run_created(AtmLaneRunSelector, ExpStateCtx);
  
  expect(ExpStateCtx, {lane_run, AtmLaneRunSelector, ExpStatus}) when
      ExpStatus =:= resuming;
      ExpStatus =:= enqueued;
      ExpStatus =:= active;
      ExpStatus =:= stopping;
      ExpStatus =:= interrupted;
      ExpStatus =:= paused;
      ExpStatus =:= finished;
      ExpStatus =:= crashed;
      ExpStatus =:= cancelled;
      ExpStatus =:= failed
  ->
      ExpAtmLaneRunStateDiff = #{<<"status">> => str_utils:to_binary(ExpStatus)},
      update_exp_lane_run_state(AtmLaneRunSelector, ExpAtmLaneRunStateDiff, ExpStateCtx);
  
  expect(ExpStateCtx, {lane_run, AtmLaneRunSelector, run_num_set, RunNum}) ->
      expect_lane_run_num_set(AtmLaneRunSelector, RunNum, ExpStateCtx);
  
  expect(ExpStateCtx, {lane_run, AtmLaneRunSelector, removed}) ->
      expect_lane_run_removed(AtmLaneRunSelector, ExpStateCtx);
  
  expect(ExpStateCtx, {lane_runs, AtmLaneRunSelectors, rerunable}) ->
      expect_lane_run_rerunable(AtmLaneRunSelectors, ExpStateCtx);
  
  expect(ExpStateCtx, {lane_runs, AtmLaneRunSelectors, retriable}) ->
      expect_lane_run_retriable(AtmLaneRunSelectors, ExpStateCtx);
  
  expect(ExpStateCtx, workflow_scheduled) ->
      expect_workflow_execution_scheduled(ExpStateCtx);
  
  expect(ExpStateCtx, workflow_resuming) ->
      expect_workflow_execution_resuming(ExpStateCtx);
  
  expect(ExpStateCtx, workflow_active) ->
      expect_workflow_execution_active(ExpStateCtx);
  
  expect(ExpStateCtx, workflow_stopping) ->
      expect_workflow_execution_stopping(ExpStateCtx);
  
  expect(ExpStateCtx, workflow_finished) ->
      expect_workflow_execution_finished(ExpStateCtx);
  
  expect(ExpStateCtx, workflow_failed) ->
      expect_workflow_execution_failed(ExpStateCtx);
  
  expect(ExpStateCtx, workflow_cancelled) ->
      expect_workflow_execution_cancelled(ExpStateCtx);
  
  expect(ExpStateCtx, workflow_paused) ->
      expect_workflow_execution_paused(ExpStateCtx);
  
  expect(ExpStateCtx, workflow_interrupted) ->
      expect_workflow_execution_interrupted(ExpStateCtx);
  
  expect(ExpStateCtx, workflow_crashed) ->
      expect_workflow_execution_crashed(ExpStateCtx);
  
  expect(ExpStateCtx, Expectations) when is_list(Expectations) ->
      lists:foldl(fun(Expectation, ExpStateCtxAcc) ->
          expect(Expectation, ExpStateCtxAcc)
      end, ExpStateCtx, Expectations).
  
  
  -spec set_current_lane_run(non_neg_integer(), non_neg_integer(), ctx()) -> ctx().
  