Skip to main content

Interface: StepLedger

Defined in: packages/workflow-engine/src/kernel/ports.ts:154

Methods​

claim()​

claim(record): Promise<{ created: boolean; record: StepRecord; }>

Defined in: packages/workflow-engine/src/kernel/ports.ts:156

Insert-if-absent. Existing records win conflicts without throwing.

Parameters​

record​

Omit<StepRecord, "createdAt" | "updatedAt">

Returns​

Promise<{ created: boolean; record: StepRecord; }>


clear()​

clear(stageRecordId): Promise<void>

Defined in: packages/workflow-engine/src/kernel/ports.ts:179

Parameters​

stageRecordId​

string

Returns​

Promise<void>


clearExcept()?​

optional clearExcept(stageRecordId, keepStepIds): Promise<void>

Defined in: packages/workflow-engine/src/kernel/ports.ts:193

Delete every row of a stage record except the named steps.

Optional so an existing implementation keeps compiling. Re-running a terminally failed stage needs it, and so does a run.redrive that resumes a stage and keeps its completed steps: the rows must go so nothing stale replays, but a row naming an external effect that may still be live — an AI map's batch submit, holding the handle and external key of a batch a provider is still processing and still billing — must survive, or the effect is orphaned with no record anywhere. A ledger that does not implement this falls back to clear, and the kernel logs the external keys it is about to drop so they remain findable.

Parameters​

stageRecordId​

string

keepStepIds​

string[]

Returns​

Promise<void>


compareAndSet()​

compareAndSet(stageRecordId, stepId, expected, patch): Promise<{ applied: boolean; record: StepRecord | null; }>

Defined in: packages/workflow-engine/src/kernel/ports.ts:172

Atomically apply patch only when the record's current status and attempt equal expected. Returns whether the write applied and the record as it stands afterwards (null when the step does not exist). Used to re-claim expired leases, retry failed attempts, time out waits and complete signals without two workers both winning.

Parameters​

stageRecordId​

string

stepId​

string

expected​

StepRecordExpectation

patch​

StepRecordPatch

Returns​

Promise<{ applied: boolean; record: StepRecord | null; }>


get()​

get(stageRecordId, stepId): Promise<StepRecord | null>

Defined in: packages/workflow-engine/src/kernel/ports.ts:159

Parameters​

stageRecordId​

string

stepId​

string

Returns​

Promise<StepRecord | null>


list()​

list(stageRecordId): Promise<StepRecord[]>

Defined in: packages/workflow-engine/src/kernel/ports.ts:178

Parameters​

stageRecordId​

string

Returns​

Promise<StepRecord[]>


update()​

update(stageRecordId, stepId, patch): Promise<StepRecord>

Defined in: packages/workflow-engine/src/kernel/ports.ts:160

Parameters​

stageRecordId​

string

stepId​

string

patch​

StepRecordPatch

Returns​

Promise<StepRecord>