Docket.Runtime.RunMutation (docket v0.1.1)

Copy Markdown View Source

Pure, named mutations of an already-committed Docket.Run.

Each successful state change returns exactly one uncommitted Docket.Runtime.Moment. Callers supply the proposal timestamp explicitly, so calculation is deterministic and performs no storage, process, checkpoint-handler, telemetry, or scheduling work.

An already-cancelled run is an idempotent success and is returned unchanged; there is no new moment to commit.

Summary

Functions

Cancels a durable active run and proposes a terminal park.

Resolves an open interrupt and proposes the run's next wake.

Types

cancellation_result()

@type cancellation_result() :: mutation_result() | {:unchanged, Docket.Run.t()}

mutation_result()

@type mutation_result() ::
  {:ok, Docket.Runtime.Moment.t()} | {:error, Docket.Error.t()}

Functions

cancel_run(run, now)

@spec cancel_run(Docket.Run.t(), DateTime.t()) :: cancellation_result()

Cancels a durable active run and proposes a terminal park.

Cancellation absorbs any parked superstep. Calling this again for the resulting run returns that exact run without consuming sequences.

resolve_interrupt(rtg, run, interrupt_id, value, now)

@spec resolve_interrupt(
  Docket.Runtime.Graph.t(),
  Docket.Run.t(),
  String.t(),
  term(),
  DateTime.t()
) ::
  mutation_result()

Resolves an open interrupt and proposes the run's next wake.

Terminal status is checked before interrupt lookup. A resolved interrupt is distinguished from an unknown interrupt, and the stored schema plus graph field contract both validate the resolution value.

Resolution proposes an immediate wake unless every active attempt is parked behind a future retry deadline; then it parks at the earliest deadline, so the committed wake never precedes the first dispatchable attempt.