Skip to content

@usine/core/run/state

Canceled, with the reason recorded.

  • Schema.Class

new Canceled(…args): Canceled

Parameter Type
…args [props: object, options?: MakeOptions]

Canceled

readonly reason: OperatorCanceled | Superseded | Revoked


The last attempt failed and no auto-retry applies. The failure is on the Attempt, and retry reopens the run.

  • Schema.Class

new Failed(…args): Failed

Parameter Type
…args [props?: object, options?: MakeOptions]

Failed


The operator closed the run by hand.

  • Schema.Class

new OperatorCanceled(…args): OperatorCanceled

Parameter Type
…args [props?: object, options?: MakeOptions]

OperatorCanceled


Just created: no attempt started and no approval gate passed.

  • Schema.Class

new Pending(…args): Pending

Parameter Type
…args [props?: object, options?: MakeOptions]

Pending


Approved and waiting for a worker slot.

  • Schema.Class

new Queued(…args): Queued

Parameter Type
…args [props?: object, options?: MakeOptions]

Queued


The run’s Item stopped matching its loop’s trigger before any attempt started.

  • Schema.Class

new Revoked(…args): Revoked

Parameter Type
…args [props?: object, options?: MakeOptions]

Revoked


An attempt is executing on a worker.

  • Schema.Class

new Running(…args): Running

Parameter Type
…args [props?: object, options?: MakeOptions]

Running


The step finished and its result is stored.

  • Schema.Class

new Succeeded(…args): Succeeded

Parameter Type
…args [props?: object, options?: MakeOptions]

Succeeded


A newer Event for the same Item took the run’s place before any attempt started.

  • Schema.Class

new Superseded(…args): Superseded

Parameter Type
…args [props: object, options?: MakeOptions]

Superseded

readonly by: string & Brand<"EventId">


Parked on the loop’s approval gate. The approval it waits for is an Event like any other fact.

  • Schema.Class

new Waiting(…args): Waiting

Parameter Type
…args [props?: object, options?: MakeOptions]

Waiting

CancelReason = typeof CancelReason.Type


Open = typeof Open.Type

Runs that still owe work, including those waiting for approval or a Worker.


RunState = typeof RunState.Type

A Run’s progress from creation through approval and execution to a recorded outcome.


Startable = typeof Startable.Type

The states an attempt can start from: the gate is passed or absent.


Unstarted = typeof Unstarted.Type

The states with no attempt started: what supersede and revoke accept.

const approve: (_state) => Queued

Returns the approved state; the Run still waits for a Worker slot before execution.

Parameter Type
_state Waiting

Queued


const awaitApproval: (_state) => Waiting

Parks a pending run on its loop’s approval gate.

Parameter Type
_state Pending

Waiting


const cancelByOperator: (_state) => Canceled

Cancels from any open state.

Parameter Type
_state Open

Canceled


const CancelReason: Schema.Union<readonly [typeof OperatorCanceled, typeof Superseded, typeof Revoked]>


const fail: (_state) => Failed

Closes the run after a failed attempt when no auto-retry applies; shouldAutoRetry decides that.

Parameter Type
_state Running

Failed


const isOpen: <I>(input) => input is I & (Pending | Queued | Running | Waiting)

Type Parameter
I
Parameter Type
input I

input is I & (Pending | Queued | Running | Waiting)


const isStartable: <I>(input) => input is I & (Pending | Queued)

Type Parameter
I
Parameter Type
input I

input is I & (Pending | Queued)


const isUnstarted: <I>(input) => input is I & (Pending | Queued | Waiting)

Type Parameter
I
Parameter Type
input I

input is I & (Pending | Queued | Waiting)


const Open: Schema.Union<readonly [typeof Pending, typeof Waiting, typeof Queued, typeof Running]>

Runs that still owe work, including those waiting for approval or a Worker.


const OPEN_STATE_TAGS: readonly ["Pending", "Waiting", "Queued", "Running"]

The open states as _tag literals, for queries that filter stored rows.


const operatorActions: (state) => object

The operator actions permitted by a Run’s lifecycle state. Command handlers still apply the typed transitions.

Parameter Type
state RunState

object

canApprove: boolean

canCancel: boolean

canResolveFailure: boolean

canRetry: boolean


const retry: (_state) => Running

Returns the reopened state for operator retry; attempt N+1 belongs to the same Run and Step.

Parameter Type
_state Failed

Running


const revoke: (_state) => Canceled

Cancels an unstarted run because its Item stopped matching the loop’s trigger.

Parameter Type
_state Unstarted

Canceled


const RunState: Schema.Union<readonly [typeof Pending, typeof Waiting, typeof Queued, typeof Running, typeof Succeeded, typeof Failed, typeof Canceled]>

A Run’s progress from creation through approval and execution to a recorded outcome.


const start: (_state) => Running

Returns the running state for a first Attempt after any required approval has been granted.

Parameter Type
_state Startable

Running


const Startable: Schema.Union<readonly [typeof Pending, typeof Queued]>

The states an attempt can start from: the gate is passed or absent.


const STATE_TAGS: readonly ["Pending", "Waiting", "Queued", "Running", "Succeeded", "Failed", "Canceled"]

Every state as a _tag literal, for read models that project stored rows.


const succeed: (_state) => Succeeded

Closes the run after a successful attempt.

Parameter Type
_state Running

Succeeded


const supersede: (_state, by) => Canceled

Cancels an unstarted run because a newer Event for the same Item replaced it. A running attempt always finishes and the newer state is judged when it ends (ADR 0007).

Parameter Type
_state Unstarted
by EventId

Canceled


const Unstarted: Schema.Union<readonly [typeof Pending, typeof Waiting, typeof Queued]>

The states with no attempt started: what supersede and revoke accept.


const UNSTARTED_STATE_TAGS: readonly ["Pending", "Waiting", "Queued"]

The unstarted states as _tag literals, for queries that filter stored rows.