Skip to main content

Class: ExecutionContext

Defined in: packages/core/src/core/execution.ts:213

A context is scoped; its shared barrier belongs to one invocation only.

Constructors​

Constructor​

new ExecutionContext(address?, state?, lanes?): ExecutionContext

Defined in: packages/core/src/core/execution.ts:214

Parameters​

address?​

ExecutionAddress = []

state?​

InvocationState = ...

lanes?​

Readonly<Record<string, ExecutionLane>> = {}

Returns​

ExecutionContext

Properties​

address​

readonly address: ExecutionAddress = []

Defined in: packages/core/src/core/execution.ts:215

Accessors​

capabilities​

Get Signature​

get capabilities(): ExecutionCapabilities | undefined

Defined in: packages/core/src/core/execution.ts:266

What the place guarantees for this run, when it declared it.

Returns​

ExecutionCapabilities | undefined


checkpointSteps​

Get Signature​

get checkpointSteps(): boolean

Defined in: packages/core/src/core/execution.ts:259

The run's default for checkpointSteps. False outside a durable run.

Returns​

boolean


durable​

Get Signature​

get durable(): boolean

Defined in: packages/core/src/core/execution.ts:233

Returns​

boolean


failure​

Get Signature​

get failure(): { error: unknown; } | undefined

Defined in: packages/core/src/core/execution.ts:588

Returns​

{ error: unknown; } | undefined


interruptions​

Get Signature​

get interruptions(): readonly Interruption[]

Defined in: packages/core/src/core/execution.ts:592

Returns​

readonly Interruption[]


localInterruptions​

Get Signature​

get localInterruptions(): readonly Interruption[]

Defined in: packages/core/src/core/execution.ts:589

Returns​

readonly Interruption[]


policy​

Get Signature​

get policy(): ResolvedRunPolicy

Defined in: packages/core/src/core/execution.ts:264

DEFAULT_RUN_POLICY with the run's overrides. Outside a durable run this is the default policy; places apply it, and a run without a place does not.

Returns​

ResolvedRunPolicy


runId​

Get Signature​

get runId(): string

Defined in: packages/core/src/core/execution.ts:220

Returns​

string

Methods​

approval()​

approval(payload, options?): Promise<unknown>

Defined in: packages/core/src/core/execution.ts:308

Pause at this address until the host supplies a persisted answer.

The answer is bound to the payload it approved. The record stores the payload's digest, a revision and schemaVersion (the answer's shape); a call whose payload or schema version differs opens a new revision and pauses again, so an old answer never applies to a changed action.

Parameters​

payload​

unknown

options?​
schemaVersion?​

string

Returns​

Promise<unknown>


assertNotCancelled()​

assertNotCancelled(): Promise<void>

Defined in: packages/core/src/core/execution.ts:243

Throws ExecutionCancelledError when the run was cancelled.

Returns​

Promise<void>


cancellation()​

cancellation(): Promise<JournalCancelRecord | undefined>

Defined in: packages/core/src/core/execution.ts:237

The run's cancel record, when the place wrote one. Undefined outside a durable run.

Returns​

Promise<JournalCancelRecord | undefined>


check()​

check(signal?): void

Defined in: packages/core/src/core/execution.ts:582

Parameters​

signal?​

AbortSignal

Returns​

void


checkpoint()​

checkpoint<T>(input, invoke, signal?, owner?): Promise<T>

Defined in: packages/core/src/core/execution.ts:372

Checkpoint one boundary. Completed descendants survive interrupted parents.

Each address is checkpointed at most once per invocation. Only runChild and runStep open a frame, so a custom Processable that hands its own options to two children gives both the same inner addresses; with equal inputs the second would replay the first's answer. The claim is taken before the first await, so siblings started together collide on the run that causes it rather than on a later resume. owner (the node's label) names both sides in the error and is recorded on the entry. It is a diagnostic, not a replay key: labels are display names, and an unnamed bot's changes on every restart.

Type Parameters​

T​

T

Parameters​

input​

unknown

invoke​

() => Promise<T>

signal?​

AbortSignal

owner?​

string

Returns​

Promise<T>


child()​

child(frame): ExecutionContext

Defined in: packages/core/src/core/execution.ts:567

Parameters​

frame​

AddressFrame

Returns​

ExecutionContext


decision()​

decision<T>(name, decide): Promise<T>

Defined in: packages/core/src/core/execution.ts:288

Cache decisions separately from outputs, before a selected branch starts.

Type Parameters​

T​

T

Parameters​

name​

string

decide​

() => Promise<T>

Returns​

Promise<T>


effect()​

effect<T>(name, adapter, options?): Promise<T>

Defined in: packages/core/src/core/execution.ts:488

Run an external write at most once per run and address.

The intent is written before execute runs, with the input digest, the adapter version and the run's owner. The write is a compare-and-set that refuses an intent already there, so a second delivery cannot dispatch the same key, and a cancelled or fenced run cannot dispatch at all.

After a crash, an intent with no completion is reconciled. Only definitelyAbsent executes again. pending and unknown suspend the run as interrupted (unresolved-effect); an intent without a reconciler, or whose reconciler throws, suspends as ambiguous-effect. Either way the interruption payload is an EffectSuspension, and the host answers it through resolve(). A completion recorded under another adapter version is reconciled the same way instead of replayed.

The deprecated { found } adapter is accepted for one release.

Type Parameters​

T​

T

Parameters​

name​

string

adapter​

EffectAdapter<T> | LegacyEffectAdapter<T>

options?​
input?​

unknown

Returns​

Promise<T>


fail()​

fail(error): void

Defined in: packages/core/src/core/execution.ts:587

Parameters​

error​

unknown

Returns​

void


interrupt()​

interrupt(payload): never

Defined in: packages/core/src/core/execution.ts:599

Parameters​

payload​

unknown

Returns​

never


lane()​

lane<K>(kind): ExecutionLanes[K] | undefined

Defined in: packages/core/src/core/execution.ts:577

The kind lane for work in this scope, when a run installed one.

Type Parameters​

K​

K extends "providerBatch"

Parameters​

kind​

K

Returns​

ExecutionLanes[K] | undefined


listRecords()​

listRecords<T>(kind): Promise<[string, T][]>

Defined in: packages/core/src/core/execution.ts:248

Every run-scoped record of kind, by id (see writeRecords).

Type Parameters​

T​

T

Parameters​

kind​

string

Returns​

Promise<[string, T][]>


readRecord()​

readRecord<T>(kind, id): Promise<T | undefined>

Defined in: packages/core/src/core/execution.ts:445

Read one run-scoped record written by writeRecords.

Type Parameters​

T​

T

Parameters​

kind​

string

id​

string

Returns​

Promise<T | undefined>


readState()​

readState<T>(name, initial): Promise<T>

Defined in: packages/core/src/core/execution.ts:423

Read shared run state without creating a write receipt.

Type Parameters​

T​

T

Parameters​

name​

string

initial​

T

Returns​

Promise<T>


release()​

release(): void

Defined in: packages/core/src/core/execution.ts:581

The scope's work has settled. Whoever called child() releases what it returned.

Returns​

void


resolve()​

resolve(address, answer, options?): Promise<void>

Defined in: packages/core/src/core/execution.ts:337

Hosts resolve the exact pending address, not a mutable node label.

An approval takes any answer. A suspended effect takes an EffectReconciliation: completed settles it with that output, definitelyAbsent lets it execute, and pending or unknown keeps it suspended. revision, when given, must name the pending approval's revision. A cancelled run refuses every answer.

Parameters​

address​

ExecutionAddress

answer​

unknown

options?​
revision?​

number

Returns​

Promise<void>


updateState()​

updateState<T>(name, initial, update): Promise<T>

Defined in: packages/core/src/core/execution.ts:431

State updates and their receipts commit atomically; replay does not update twice.

Type Parameters​

T​

T

Parameters​

name​

string

initial​

T

update​

(current) => T

Returns​

Promise<T>


withLane()​

withLane<K>(kind, lane): ExecutionContext

Defined in: packages/core/src/core/execution.ts:573

This scope, with lane installed for it and every descendant.

Type Parameters​

K​

K extends "providerBatch"

Parameters​

kind​

K

lane​

ExecutionLanes[K]

Returns​

ExecutionContext


writeRecords()​

writeRecords(kind, records): Promise<void>

Defined in: packages/core/src/core/execution.ts:459

Commit run-scoped records together, keyed by id rather than address.

For facts no one address owns: one provider batch holds calls from many items, and a replay has to find it from any of them. Unlike state, a write carries no receipt — the writer decides what writing again means.

Parameters​

kind​

string

records​

Readonly<Record<string, unknown>>

Returns​

Promise<void>


yieldRun()​

yieldRun(completedSteps): never

Defined in: packages/core/src/core/execution.ts:594

Stop this run at a safe boundary with its progress saved (see ExecutionYieldedError).

Parameters​

completedSteps​

number

Returns​

never


durable()​

static durable(journal, identity, options?): Promise<ExecutionContext>

Defined in: packages/core/src/core/execution.ts:226

Open a durable run. A durable place passes options: its step-checkpoint default, policy and capabilities. Without them the run keeps today's defaults (checkpointSteps false).

Parameters​

journal​

ExecutionJournal

identity​

ExecutionIdentity

options?​

DurableScopeOptions

Returns​

Promise<ExecutionContext>