For AI agents: the complete documentation index is available at https://a3s-lab.github.io/Flow/v0.12.0/en/llms.txt, the full documentation bundle is available at https://a3s-lab.github.io/Flow/v0.12.0/en/llms-full.txt, and this page is available as Markdown at https://a3s-lab.github.io/Flow/v0.12.0/en/reference/api.md.

0.12.0 API reference

This page corresponds to Git tag v0.12.0. See docs.rs 0.12.0 for complete signatures.

Feature flags

FeatureDefaultEntry points
native-tsYesNativeTsRuntime and v1 JSON protocol
sqliteNoSqliteEventStore and retention
postgresNoPostgresEventStore, task queue, and retention
bootNoBootFlowTaskManager and task policy
a3s-eventNoPost-commit event sink

FlowEngine

Construction uses in_memory(), new(store, runtime), or builder(runtime). The builder configures store, observer, RuntimeBuildCompatibility, and maximum replay iterations.

Method groupMethods
Createstart(), start_with_id()
Drivedrive(), resume_wait(), resume_scheduled_run()
Due worklist_due_waits(), list_due_retries(), list_due_wakeups(), resume_due_waits(), resume_due_retries()
Inspectsnapshot(), history(), list_run_ids(), list_snapshots(), run_summary()
Suspendlist_open_suspensions(), next_wakeup(), list_active_hooks()
Hooksresume_hook(), resume_hook_by_token(), dispose_hook(), dispose_hook_by_token()
Stoprequest_cancellation(), force_cancel(), cancel(), terminate_for_timeout(), terminate_for_host_shutdown()
Control planerecord_progress(), link_child_operation()

start_with_id() is idempotent when run ID, definition, and input match. Changed authority returns RunConflict.

FlowRuntime

#[async_trait::async_trait]
pub trait FlowRuntime: Send + Sync {
    async fn run_workflow(
        &self,
        invocation: WorkflowInvocation,
    ) -> Result<RuntimeCommand>;

    async fn run_step(
        &self,
        invocation: StepInvocation,
    ) -> Result<JsonValue>;
}

WorkflowInvocation carries run ID, definition, input, and history and creates a helper through context(). StepInvocation carries run ID, step ID, handler name, input, and history.

Context reads

MethodReads
run_id(), input(), input_as()Run and input
history()Complete event envelopes
step_output(), step_output_as()Successful step output
step_completed(), step_failed()Step result
wait_completed()Wait completion
hook_payload(), hook_payload_as()Hook payload
hook_disposed()Hook disposal
cancellation_request()Cancellation request
progress()Durable progress
child_operation()External child-operation link

There are no signal, first-class child, continuation, or patch query methods.

Runtime commands

The 0.12.0 RuntimeCommand variants form the complete closed set.

VariantContext builder
Completecomplete()
Failfail()
Cancelcancel()
Timeouttimeout()
RecordProgressrecord_progress()
LinkChildOperationlink_child_operation()
ScheduleStepschedule_step(), schedule_step_with_retry()
ScheduleStepsstep(), step_with_retry(), schedule_steps()
WaitUntilwait_until()
CreateHookcreate_hook(), create_hook_with_metadata()

Retry

RetryPolicy::none() runs once. RetryPolicy::fixed(max_attempts, delay) uses fixed delay. continue_workflow_on_failure() leaves exhaustion for workflow handling.

StepCommand::new() and with_retry() construct batch members. This release has no exponential backoff type.

Definitions and snapshots

WorkflowSpec contains name, definition version, and RuntimeSpec and may pin RuntimeBuildId through with_runtime_build(). RuntimeBuildCompatibility describes builds admitted by a worker.

WorkflowRunSnapshot aggregates WorkflowRunStatus, steps, waits, hooks, cancellation, progress, external child operations, and WorkflowTerminalOutcome. Child projections include StepSnapshot, WaitSnapshot, HookSnapshot, and ScheduledWakeup.

HookMetadata and HookCallbackRoute provide callback audit and host routing metadata. They do not create an HTTP server.

Stores

FlowEventStore requires append, expected-sequence append, ordered complete list, and run enumeration. Active-hook and scheduled-wakeup lookups are public contracts.

TypeFeature
InMemoryEventStoreNone
LocalFileEventStoreNone
SqliteEventStoresqlite
PostgresEventStorepostgres
FlowHistoryRetentionPolicysqlite or postgres
FlowHistoryHold, FlowHistoryTombstonesqlite or postgres

SQL backends migrate in connect(). 0.12.0 has no separate PostgreSQL migration or verify-only constructors.

Scheduling and tasks

FlowScheduler provides next_wakeup(), next_wakeup_delay(), and enqueue_due_work(). FlowSchedulerTick returns due waits, due retries, and dispatch count.

The task layer exposes FlowTask, FlowTaskDispatcher, FlowTaskQueue, FlowTaskLease, FlowTaskOutcome, and FlowWorker.

Built-in queues are InMemoryFlowTaskQueue, LocalFileFlowTaskQueue, and optional PostgresFlowTaskQueue. RuntimeBuildTaskRouter selects a dispatcher by pinned build. BootFlowTaskManager requires the boot feature.

Observation

FlowEventObserver receives events after commit. Public implementations and adapters include NoopFlowEventObserver, InMemoryFlowEventObserver, FanoutFlowEventObserver, LocalFileA3sFlowEventSink, A3sFlowEventBridge, and the in-memory sink.

Observation output cannot decide workflow state. Run IDs and hook tokens do not belong in metric dimensions.

Native TypeScript

TypePurpose
NativeTsRuntimeConfigCompiler, cache, and working directories
NativeTsRuntimeCompile and invoke native artifacts
NativeTsRuntimePreflightEntrypoint, artifact, source hash, and cache hit
NativeRuntimeRequest, NativeRuntimeResponsea3s.flow.native_ts.v1 protocol
NativeRuntimeKindWorkflow or step invocation kind

NativeTsRuntime supports output limits, compilation timeout, invocation timeout, and preflight(). 0.12.0 has no NativeTsDependencyMode, compiler-capability protocol, or dependency-manifest type.

The host-supplied compiler accepts compile <entrypoint> -o <artifact>. The artifact accepts --a3s-flow-runtime and exchanges JSON over standard input and output.

Error categories

ErrorResponse
EventConflictAnother append won, so reread history
RunConflictCaller reused a different run authority
NonDeterministicWorkflow code drifted from durable decisions
HookConflictCallback payload or resolution conflicts
RuntimeBuildUnavailableCurrent worker does not admit the run build
RuntimeBuildRouteNotFoundTask routing lacks the target build
ReplayLimitExceededOne drive exceeded its safety bound

Identity, replay, and build errors require corrected configuration or code. Do not retry them indefinitely as transient failures.