Expand description
Core types and traits for the Sayiir durable workflow engine.
This crate defines the foundational abstractions that every other sayiir-*
crate builds on. It is intentionally runtime-agnostic — no persistence,
no execution strategy, just pure workflow modelling.
§Key Abstractions
| Type / Trait | Purpose |
|---|---|
Workflow / SerializableWorkflow | The continuation tree that describes what to execute |
WorkflowBuilder | Fluent builder for assembling sequential, forked, and joined pipelines |
CoreTask | Trait implemented by every task (input → output, with metadata) |
Codec | Trait for pluggable serialization (JSON, rkyv, …) |
WorkflowContext | Per-execution context carrying the codec, workflow ID, and user metadata |
WorkflowSnapshot | Checkpoint of in-flight execution state (completed tasks + outputs) |
TaskRegistry | Name → factory map used for deserializing workflows across process boundaries |
§Architecture
sayiir-core (this crate — types & traits only)
↑
sayiir-persistence (SnapshotStore, SignalStore, TaskClaimStore)
↑
sayiir-runtime (CheckpointingRunner, PooledWorker, execution loop)
↑
sayiir-macros (#[task], workflow! — optional convenience)§Quick Example
ⓘ
use sayiir_core::prelude::*;
use std::sync::Arc;
// Create a context (codec + workflow ID)
// (Codec is generic — bring your own or use sayiir-runtime's JsonCodec / RkyvCodec)
let ctx = WorkflowContext::new("order-pipeline", Arc::new(my_codec), Arc::new(()));
// Build a workflow: validate → charge
let wf = WorkflowBuilder::new(ctx)
.then("validate", |order: String| async move { Ok(order) })
.then("charge", |order: String| async move { Ok(42u64) })
.build()?;For the proc-macro experience (#[task] + workflow!), see
sayiir-macros.
Modules§
- branch_
results - Named branch results — the outputs of parallel fork branches.
- builder
- codec
- context
- error
- Error types for sayiir-core.
- prelude
- Common imports for workflow authors.
- registry
- Task registry for serializable workflows.
- snapshot
- Workflow snapshot structures for checkpoint/restore functionality.
- task
- task_
claim - Task claiming mechanism for multi-node collaboration.
- workflow
Macros§
- sayiir_
ctx - Macro to access the workflow context from within a task.