@usine/core/run/state
Classes
Section titled “Classes”Canceled
Section titled “Canceled”Canceled, with the reason recorded.
Extends
Section titled “Extends”Schema.Class
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Canceled(…
args):Canceled
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
[props: object, options?: MakeOptions] |
Returns
Section titled “Returns”Properties
Section titled “Properties”reason
Section titled “reason”
readonlyreason:OperatorCanceled|Superseded|Revoked
Failed
Section titled “Failed”The last attempt failed and no auto-retry applies. The failure is on the Attempt, and retry reopens the run.
Extends
Section titled “Extends”Schema.Class
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Failed(…
args):Failed
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
[props?: object, options?: MakeOptions] |
Returns
Section titled “Returns”OperatorCanceled
Section titled “OperatorCanceled”The operator closed the run by hand.
Extends
Section titled “Extends”Schema.Class
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new OperatorCanceled(…
args):OperatorCanceled
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
[props?: object, options?: MakeOptions] |
Returns
Section titled “Returns”Pending
Section titled “Pending”Just created: no attempt started and no approval gate passed.
Extends
Section titled “Extends”Schema.Class
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Pending(…
args):Pending
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
[props?: object, options?: MakeOptions] |
Returns
Section titled “Returns”Queued
Section titled “Queued”Approved and waiting for a worker slot.
Extends
Section titled “Extends”Schema.Class
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Queued(…
args):Queued
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
[props?: object, options?: MakeOptions] |
Returns
Section titled “Returns”Revoked
Section titled “Revoked”The run’s Item stopped matching its loop’s trigger before any attempt started.
Extends
Section titled “Extends”Schema.Class
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Revoked(…
args):Revoked
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
[props?: object, options?: MakeOptions] |
Returns
Section titled “Returns”Running
Section titled “Running”An attempt is executing on a worker.
Extends
Section titled “Extends”Schema.Class
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Running(…
args):Running
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
[props?: object, options?: MakeOptions] |
Returns
Section titled “Returns”Succeeded
Section titled “Succeeded”The step finished and its result is stored.
Extends
Section titled “Extends”Schema.Class
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Succeeded(…
args):Succeeded
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
[props?: object, options?: MakeOptions] |
Returns
Section titled “Returns”Superseded
Section titled “Superseded”A newer Event for the same Item took the run’s place before any attempt started.
Extends
Section titled “Extends”Schema.Class
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Superseded(…
args):Superseded
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
[props: object, options?: MakeOptions] |
Returns
Section titled “Returns”Properties
Section titled “Properties”
readonlyby:string&Brand<"EventId">
Waiting
Section titled “Waiting”Parked on the loop’s approval gate. The approval it waits for is an Event like any other fact.
Extends
Section titled “Extends”Schema.Class
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Waiting(…
args):Waiting
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
[props?: object, options?: MakeOptions] |
Returns
Section titled “Returns”Type Aliases
Section titled “Type Aliases”CancelReason
Section titled “CancelReason”CancelReason = typeof
CancelReason.Type
Open = typeof
Open.Type
Runs that still owe work, including those waiting for approval or a Worker.
RunState
Section titled “RunState”RunState = typeof
RunState.Type
A Run’s progress from creation through approval and execution to a recorded outcome.
Startable
Section titled “Startable”Startable = typeof
Startable.Type
The states an attempt can start from: the gate is passed or absent.
Unstarted
Section titled “Unstarted”Unstarted = typeof
Unstarted.Type
The states with no attempt started: what supersede and revoke accept.
Variables
Section titled “Variables”approve
Section titled “approve”
constapprove: (_state) =>Queued
Returns the approved state; the Run still waits for a Worker slot before execution.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
_state |
Waiting |
Returns
Section titled “Returns”awaitApproval
Section titled “awaitApproval”
constawaitApproval: (_state) =>Waiting
Parks a pending run on its loop’s approval gate.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
_state |
Pending |
Returns
Section titled “Returns”cancelByOperator
Section titled “cancelByOperator”
constcancelByOperator: (_state) =>Canceled
Cancels from any open state.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
_state |
Open |
Returns
Section titled “Returns”CancelReason
Section titled “CancelReason”
constCancelReason:Schema.Union<readonly [typeofOperatorCanceled, typeofSuperseded, typeofRevoked]>
constfail: (_state) =>Failed
Closes the run after a failed attempt when no auto-retry applies; shouldAutoRetry decides that.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
_state |
Running |
Returns
Section titled “Returns”isOpen
Section titled “isOpen”
constisOpen: <I>(input) => input is I & (Pending | Queued | Running | Waiting)
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
I |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
I |
Returns
Section titled “Returns”input is I & (Pending | Queued | Running | Waiting)
isStartable
Section titled “isStartable”
constisStartable: <I>(input) => input is I & (Pending | Queued)
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
I |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
I |
Returns
Section titled “Returns”input is I & (Pending | Queued)
isUnstarted
Section titled “isUnstarted”
constisUnstarted: <I>(input) => input is I & (Pending | Queued | Waiting)
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
I |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
input |
I |
Returns
Section titled “Returns”input is I & (Pending | Queued | Waiting)
constOpen:Schema.Union<readonly [typeofPending, typeofWaiting, typeofQueued, typeofRunning]>
Runs that still owe work, including those waiting for approval or a Worker.
OPEN_STATE_TAGS
Section titled “OPEN_STATE_TAGS”
constOPEN_STATE_TAGS: readonly ["Pending","Waiting","Queued","Running"]
The open states as _tag literals, for queries that filter stored rows.
operatorActions
Section titled “operatorActions”
constoperatorActions: (state) =>object
The operator actions permitted by a Run’s lifecycle state. Command handlers still apply the typed transitions.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
state |
RunState |
Returns
Section titled “Returns”object
canApprove
Section titled “canApprove”canApprove:
boolean
canCancel
Section titled “canCancel”canCancel:
boolean
canResolveFailure
Section titled “canResolveFailure”canResolveFailure:
boolean
canRetry
Section titled “canRetry”canRetry:
boolean
constretry: (_state) =>Running
Returns the reopened state for operator retry; attempt N+1 belongs to the same Run and Step.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
_state |
Failed |
Returns
Section titled “Returns”revoke
Section titled “revoke”
constrevoke: (_state) =>Canceled
Cancels an unstarted run because its Item stopped matching the loop’s trigger.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
_state |
Unstarted |
Returns
Section titled “Returns”RunState
Section titled “RunState”
constRunState:Schema.Union<readonly [typeofPending, typeofWaiting, typeofQueued, typeofRunning, typeofSucceeded, typeofFailed, typeofCanceled]>
A Run’s progress from creation through approval and execution to a recorded outcome.
conststart: (_state) =>Running
Returns the running state for a first Attempt after any required approval has been granted.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
_state |
Startable |
Returns
Section titled “Returns”Startable
Section titled “Startable”
constStartable:Schema.Union<readonly [typeofPending, typeofQueued]>
The states an attempt can start from: the gate is passed or absent.
STATE_TAGS
Section titled “STATE_TAGS”
constSTATE_TAGS: readonly ["Pending","Waiting","Queued","Running","Succeeded","Failed","Canceled"]
Every state as a _tag literal, for read models that project stored rows.
succeed
Section titled “succeed”
constsucceed: (_state) =>Succeeded
Closes the run after a successful attempt.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
_state |
Running |
Returns
Section titled “Returns”supersede
Section titled “supersede”
constsupersede: (_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).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
_state |
Unstarted |
by |
EventId |
Returns
Section titled “Returns”Unstarted
Section titled “Unstarted”
constUnstarted:Schema.Union<readonly [typeofPending, typeofWaiting, typeofQueued]>
The states with no attempt started: what supersede and revoke accept.
UNSTARTED_STATE_TAGS
Section titled “UNSTARTED_STATE_TAGS”
constUNSTARTED_STATE_TAGS: readonly ["Pending","Waiting","Queued"]
The unstarted states as _tag literals, for queries that filter stored rows.