@usine/engine/engine
Classes
Section titled “Classes”AttemptCancellationError
Section titled “AttemptCancellationError”The Run is canceled, but interrupting its active Attempt failed.
Extends
Section titled “Extends”Schema.Class
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AttemptCancellationError(…
args):AttemptCancellationError
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
[props: object, options?: MakeOptions] |
Returns
Section titled “Returns”Properties
Section titled “Properties”attemptId
Section titled “attemptId”
readonlyattemptId:string&Brand<"AttemptId">
readonlycause:unknown
Claimed
Section titled “Claimed”The Event now owns a Run; submitting it again returns the same run id.
Extends
Section titled “Extends”Schema.Class
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Claimed(…
args):Claimed
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
[props: object, options?: MakeOptions] |
Returns
Section titled “Returns”Properties
Section titled “Properties”eventId
Section titled “eventId”
readonlyeventId:string&Brand<"EventId">
readonlyrunId:string&Brand<"RunId">
CycleBlocked
Section titled “CycleBlocked”No Run opened because this Item requires an explicit cycle-budget reset.
Extends
Section titled “Extends”Schema.Class
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new CycleBlocked(…
args):CycleBlocked
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
[props: object, options?: MakeOptions] |
Returns
Section titled “Returns”Properties
Section titled “Properties”
readonlyask:CycleBudgetAsk
eventId
Section titled “eventId”
readonlyeventId:string&Brand<"EventId">
EnginePersistenceError
Section titled “EnginePersistenceError”An operation could not read or update the instance’s durable records.
Extends
Section titled “Extends”Schema.Class
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new EnginePersistenceError(…
args):EnginePersistenceError
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
[props: object, options?: MakeOptions] |
Returns
Section titled “Returns”Properties
Section titled “Properties”
readonlycause:unknown
operation
Section titled “operation”
readonlyoperation:string
Ignored
Section titled “Ignored”The Event stays in the ledger but can no longer open a Run.
Extends
Section titled “Extends”Schema.Class
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Ignored(…
args):Ignored
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
[props: object, options?: MakeOptions] |
Returns
Section titled “Returns”Properties
Section titled “Properties”eventId
Section titled “eventId”
readonlyeventId:string&Brand<"EventId">
reason
Section titled “reason”
readonlyreason:"superseded"|"revoked"
Queued
Section titled “Queued”A running Attempt on the same Item must finish before this Event is reconsidered.
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”Properties
Section titled “Properties”eventId
Section titled “eventId”
readonlyeventId:string&Brand<"EventId">
RunEngine
Section titled “RunEngine”Records Events and manages their Runs through approval, execution, retry, and cancellation.
Extends
Section titled “Extends”Context.ServiceClass
Properties
Section titled “Properties”Service
Section titled “Service”
readonlyService:object
The service’s operations: what yield* RunEngine returns.
approve
Section titled “approve”
readonlyapprove: (runId,approval) =>Effect.Effect<void,RunEngineError>
Records the operator’s approval Event and opens the Run’s gate; execution still waits for a Worker slot.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
runId |
RunId |
approval |
Event |
Returns
Section titled “Returns”Effect.Effect<void, RunEngineError>
cancel
Section titled “cancel”
readonlycancel: (runId) =>Effect.Effect<void,RunEngineError>
Cancels an open Run and interrupts its active Attempt. An already closed Run is unchanged.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
runId |
RunId |
Returns
Section titled “Returns”Effect.Effect<void, RunEngineError>
readonlydrain: () =>Effect.Effect<void>
Stops admitting Attempts, including retries, and waits for admitted work to settle. Interrupting this wait keeps admission closed until restart.
Returns
Section titled “Returns”Effect.Effect<void>
inspect
Section titled “inspect”
readonlyinspect: (runId) =>Effect.Effect<RunSnapshot,RunEngineError>
Reads the Run’s current state, effective task and Agent, Step result, and Attempt history.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
runId |
RunId |
Returns
Section titled “Returns”Effect.Effect<RunSnapshot, RunEngineError>
intervene
Section titled “intervene”
readonlyintervene: (runId,attemptId,intervention) =>Effect.Effect<void,RunEngineError>
Addresses one current Attempt explicitly so an old drawer cannot steer its replacement.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
runId |
RunId |
attemptId |
AttemptId |
intervention |
Intervention |
Returns
Section titled “Returns”Effect.Effect<void, RunEngineError>
reconcile
Section titled “reconcile”
readonlyreconcile: () =>Effect.Effect<void,RunEngineError>
Starts a fiber for every open Run without one in this process, except Runs waiting for their
approval, and opens the queued Events no closed Run continued. Also runs when the engine starts,
then every ReconcileInterval.
Returns
Section titled “Returns”Effect.Effect<void, RunEngineError>
resolveFailure
Section titled “resolveFailure”
readonlyresolveFailure: (runId,attemptId) =>Effect.Effect<void,RunEngineError>
Resolves the current failed Attempt’s attention without changing its outcome or starting work.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
runId |
RunId |
attemptId |
AttemptId |
Returns
Section titled “Returns”Effect.Effect<void, RunEngineError>
readonlyretry: (runId,amendment?) =>Effect.Effect<void,RunEngineError>
Requests another Attempt for a failed Run using its existing Event and effective task and Agent.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
runId |
RunId |
amendment? |
Option.Option<AttemptContext> |
Returns
Section titled “Returns”Effect.Effect<void, RunEngineError>
revoke
Section titled “revoke”
readonlyrevoke: (loop,itemKey) =>Effect.Effect<ReadonlyArray<RunId>,RunEngineError>
Cancels unstarted Runs and discards queued Events for a Loop’s Item when it stops matching; running Attempts continue.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
loop |
LoopName |
itemKey |
ItemKey |
Returns
Section titled “Returns”Effect.Effect<ReadonlyArray<RunId>, RunEngineError>
submit
Section titled “submit”
readonlysubmit: (submission) =>Effect.Effect<SubmissionResult,RunEngineError>
Records a matching Event and claims its Run, or queues it behind the Item’s running Attempt. Repeated Events are deduplicated; execution continues separately.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
submission |
Submission |
Returns
Section titled “Returns”Effect.Effect<SubmissionResult, RunEngineError>
transcript
Section titled “transcript”
readonlytranscript: (query) =>Effect.Effect<ReadonlyArray<TranscriptEntry>,RunEngineError>
Reads the requested portion of an Attempt’s persisted transcript in append order.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
query |
TranscriptQuery |
Returns
Section titled “Returns”Effect.Effect<ReadonlyArray<TranscriptEntry>, RunEngineError>
RunEngineShutdown
Section titled “RunEngineShutdown”Optional host-owned shutdown latch, provided before building an engine runtime. Completing it closes Attempt admission even while startup recovery is running. After startup, RunEngine.drain waits for admitted Attempts to persist their outcomes. Allocate a fresh latch for each runtime; it cannot be reopened (ADR 0023).
Extends
Section titled “Extends”Context.ServiceClass
Properties
Section titled “Properties”Service
Section titled “Service”
readonlyService:Deferred.Deferred<void,never>
The service’s operations: what yield* RunEngineShutdown returns.
RunInterventionRejectedError
Section titled “RunInterventionRejectedError”The requested Attempt is no longer live, or its channel could not accept operator input.
Extends
Section titled “Extends”Schema.Class
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new RunInterventionRejectedError(…
args):RunInterventionRejectedError
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
[props: object, options?: MakeOptions] |
Returns
Section titled “Returns”Properties
Section titled “Properties”attemptId
Section titled “attemptId”
readonlyattemptId:string&Brand<"AttemptId">
message
Section titled “message”
readonlymessage:string
readonlyrunId:string&Brand<"RunId">
RunNotFoundError
Section titled “RunNotFoundError”No Run with the requested identity exists in this instance’s records.
Extends
Section titled “Extends”Schema.Class
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new RunNotFoundError(…
args):RunNotFoundError
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
[props: object, options?: MakeOptions] |
Returns
Section titled “Returns”Properties
Section titled “Properties”
readonlyrunId:string&Brand<"RunId">
RunOperationRejectedError
Section titled “RunOperationRejectedError”The Run’s current state does not allow the requested operator action.
Extends
Section titled “Extends”Schema.Class
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new RunOperationRejectedError(…
args):RunOperationRejectedError
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
[props: object, options?: MakeOptions] |
Returns
Section titled “Returns”Properties
Section titled “Properties”operation
Section titled “operation”
readonlyoperation:"approve"|"retry"|"resolveFailure"
readonlyrunId:string&Brand<"RunId">
readonlystate:string
Submission
Section titled “Submission”A matched Event with the Loop, Item, and execution choices that determine the work owed.
Extends
Section titled “Extends”Schema.Class
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Submission(…
args):Submission
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…args |
[props: object, options?: MakeOptions] |
Returns
Section titled “Returns”Properties
Section titled “Properties”
readonlyagent:Agent
approval
Section titled “approval”
readonlyapproval:"required"|"none"
cycleGeneration
Section titled “cycleGeneration”
readonlycycleGeneration:number&Brand<"CycleGeneration">
Capture before fetching trigger input. A reset supersedes older observations.
cycleLimit
Section titled “cycleLimit”
readonlycycleLimit:Option<number&Brand<"CycleLimit">>
Item Runs default to three rounds; schedule adapters explicitly supply None.
readonlyevent:Event
itemKey
Section titled “itemKey”
readonlyitemKey:string&Brand<"ItemKey">
readonlyloop:string&Brand<"LoopName">
parentModel
Section titled “parentModel”
readonlyparentModel:Option<string&Brand<"ModelId">>
repository
Section titled “repository”
readonlyrepository:string&Brand<"RepositoryName">
revision
Section titled “revision”
readonlyrevision:string&Brand<"RepositoryRevision">
readonlystep:string&Brand<"StepName">
readonlytask:string&Brand<"AttemptTask">
Type Aliases
Section titled “Type Aliases”IgnoreReason
Section titled “IgnoreReason”IgnoreReason = typeof
IgnoreReason.Type
RunEngineError
Section titled “RunEngineError”RunEngineError = typeof
RunEngineError.Type
The store’s failures plus the cancellation handshake failure only the engine raises.
RunStoreError
Section titled “RunStoreError”RunStoreError = typeof
RunStoreError.Type
Everything the store itself can fail with.
SubmissionResult
Section titled “SubmissionResult”SubmissionResult = typeof
SubmissionResult.Type
Whether a recorded Event owns a Run, waits behind running work, or can no longer open a Run.
Variables
Section titled “Variables”IgnoreReason
Section titled “IgnoreReason”
constIgnoreReason:Schema.Literals<readonly ["superseded","revoked"]>
layerWithDatabase
Section titled “layerWithDatabase”
constlayerWithDatabase: <DatabaseError,DatabaseRequirements>(database) =>Layer.Layer<CursorStore|CycleBudgets|ItemProjectionReader|ItemProjectionWriter|LoopControl|RepositoryLabelProjectionReader|RepositoryLabelProjectionWriter|RunEngine|RunReader,RunEngineError|DatabaseError,Crypto.Crypto|StepExecutor|TriggerCondition|DatabaseRequirements>
Provides Run execution and recovery on the supplied database, whose run
tables are the only durable state of the Run lifecycle. The deployment
supplies Crypto, which hashes dedup keys into Run ids, the Worker
implementation through StepExecutor, and the trigger re-check for queued
Events through TriggerCondition.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
DatabaseError |
DatabaseRequirements |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
database |
Layer.Layer<RunDatabase, DatabaseError, DatabaseRequirements> |
Returns
Section titled “Returns”Layer.Layer<CursorStore | CycleBudgets | ItemProjectionReader | ItemProjectionWriter | LoopControl | RepositoryLabelProjectionReader | RepositoryLabelProjectionWriter | RunEngine | RunReader, RunEngineError | DatabaseError, Crypto.Crypto | StepExecutor | TriggerCondition | DatabaseRequirements>
ReconcileInterval
Section titled “ReconcileInterval”
constReconcileInterval:Context.Reference<Duration.Input>
How long the engine waits between reconciles after the one at startup, so an open Run whose fiber stopped, as on a store failure that outlasted its retries, is driven again without a restart. Provide another value to change it.
RunEngineError
Section titled “RunEngineError”
constRunEngineError:Schema.Union<readonly [typeofRunNotFoundError, typeofRunOperationRejectedError, typeofEnginePersistenceError, typeofAttemptCancellationError, typeofRunInterventionRejectedError]>
The store’s failures plus the cancellation handshake failure only the engine raises.
RunStoreError
Section titled “RunStoreError”
constRunStoreError:Schema.Union<readonly [typeofRunNotFoundError, typeofRunOperationRejectedError, typeofEnginePersistenceError]>
Everything the store itself can fail with.
SubmissionResult
Section titled “SubmissionResult”
constSubmissionResult:Schema.Union<readonly [typeofClaimed, typeofQueued, typeofIgnored, typeofCycleBlocked]>
Whether a recorded Event owns a Run, waits behind running work, or can no longer open a Run.