sema_workflow/lib.rs
1//! Sema dynamic-workflow runtime: an in-process runtime that journals a frozen JSONL
2//! run-directory and returns a discriminated-union `{:status …}` envelope.
3//!
4//! The body runs sequentially; leaves fan out with bounded concurrency (`parallel` /
5//! `pipeline`). `--resume` short-circuits any agent/checkpoint leaf already recorded in
6//! the run's `memo/` sidecar dir. The run directory is the stable public contract (treat
7//! like the `.semac` bytecode format) — its layout and event vocabulary are FROZEN
8//! (append-only Option/skippable fields only).
9//!
10//! This crate is a leaf: it depends only on `sema-core` + serde.
11//! The builtins that invoke Sema thunks (`workflow/run`, `workflow/phase`,
12//! `checkpoint`, `workflow/agent`) live in `sema-stdlib`, which depends on this crate.
13
14pub mod approval;
15pub mod context;
16pub mod event;
17mod journal;
18pub mod writer;
19
20pub use context::{
21 cur_agent_for, current_for, resolve_run_id, set_cur_agent_for, set_workflow_scope, WorkflowCtx,
22 WorkflowGuard, WorkflowTaskState,
23};
24pub use event::WorkflowEvent;
25pub use journal::Journal;
26
27/// Project-local run-directory root (cwd-relative, git-ignorable). NOT
28/// `sema_home()` (`~/.sema`) — a run dir belongs to the project being worked on.
29/// The CLI overrides the base via the `SEMA_WORKFLOW_RUN_DIR` seam (see
30/// [`context::resolve_runs_root`]).
31pub const RUNS_ROOT: &str = ".sema/runs";
32
33/// Filename of the cross-run SQLite projection index, under the run-dir base
34/// (`<run-dir>/index.db`). One DB indexes every run for the dashboard's cross-run views.
35pub const INDEX_DB: &str = "index.db";