Scientific Workflow Rust crate
Scientific Workflow is an inference-first library for typed scientific state, configuration-driven model or program execution, and durable outputs.
Installation
[]
= "0.10.1"
= { = "1", = ["derive"] }
Rust 1.97 or newer is required. Executables should commit Cargo.lock.
Breaking 0.10 update: Version 0.10.1 is the current patch release of the 0.10 API generation that intentionally removed the pre-0.10 orchestration, configuration, storage/writer, and study surfaces. Applications using 0.9.x or earlier must adopt registered
ScientificModelimplementations, the canonical three project JSON files, and the crate-levelrun(&Path)facade. Removed Rust APIs and legacy JSON fields have no compatibility aliases.
Complete user procedure
1. Define a model
The model directly owns its canonical SystemState. Its associated constants
type is the complete typed form of one expanded section selected from
config/parameters.json by the model's registration key.
use Deserialize;
use *;
ScientificModel::observation_plan defaults to
ObservationPlan::all_fields(). Override it only
when selected fields, named streams, cadence, or units carry scientific
meaning. The observation-plan function may inspect constants but must be
deterministic and side-effect-free.
The model is an ordinary Rust owner: state() returns a direct borrow of its
SystemState, and coupled field access uses a typed tuple expansion. The
attribute does not define the model or generate field access. Its stable key is
only the automatic bridge from study.json to compiled Rust behavior, so there
is no separate registry list in main.
Standalone executable and Python tasks require no Rust trait or wrapper.
Declare them in study.json; they receive the same captured central project
configuration and dependency results at runtime. A Python task declares its
environment locally inside its nested python object—there is no global
environment registry.
2. Write project JSON
project/
├── study.json
├── scripts/
│ └── plot.py
└── config/
├── state.json
└── parameters.json
config/state.json:
config/parameters.json:
study.json:
Persistence is automatic. The omitted root persistence object infers the
local backend with a 64 MB decimal chunk target and queue capacity.
Projects that need explicit operational sizing may add:
"persistence":
All JSON persistence sizes are authored in decimal megabytes; one MB is exactly 1,000,000 bytes. Config converts both settings into exact internal byte counts.
Users never provide Rust recording paths, construct a backend, submit
observations, or finalize a recording. External programs may own a
project-relative domain output such as the Python plotter's output/plots.
UI is also automatic. No ui object or model display fields are required.
Interactive stdin and stderr select the Ratatui dashboard with inferred task
rows for only the current phase, progress, timing, lifecycle messages, and the
exit command. The task-panel title carries the replicate and phase once.
Redirected execution uses stable plain lifecycle lines.
Config alone reads study.json, config/state.json, and the complete arbitrary
config/parameters.json namespace once. $sweep creates independent Cartesian
choices; $cases creates correlated alternatives; ordinary arrays remain
literal. Program arguments are optional opaque strings and executables are
started directly without a shell. Python-specific script, environment, and
args stay nested beneath python; generic timeout policy remains on the
containing task. Supported managers are system, venv, mamba, conda,
uv, and poetry, with manager-specific paths/names validated during Study
loading.
3. Run
That call loads all declarations, discovers models, validates typed constants, binds observation plans to the state schema, resolves program paths and Python environments, creates immutable generic tasks and phases, compiles the effective persistence plan, infers identities/output paths, schedules work, and persists every task automatically while publishing inferred terminal progress.
Each program or Python script receives absolute WORKFLOW_CONFIG_PATH and
WORKFLOW_DEPENDENCIES_PATH snapshot files plus project, execution, replicate,
and task-output paths through WORKFLOW_* environment variables. It runs in an
isolated artifacts/ working directory; Workflow captures stdout, stderr, and
terminal status. A program may instead write domain outputs to a safe
project-relative destination it reads from parameters.json. Editing project
JSON after Study::load does not alter that execution.
Output is created beneath <project-root>/output only after Study preflight
succeeds.
Architecture at a glance
state: canonical typed scientific state and schema;observation: observation meaning and borrowed encoding;task: generic model/program tasks (including Python),ScientificModel, registration, and uniform invocation;config: sole all-JSON parser, immutable snapshot, executable/Python environment resolver, and typed constants supplier;study: effect-free binding and immutable declared intent;runtime: active execution and output creation;persistence: automatic durable lifecycle and verified reading;ui: automatic best-effort terminal presentation of Runtime facts;error: complete-workflow Study/Runtime error composition; andprelude: central aggregation of module-owned Basic/Advanced tiers.
The crate-level run(&Path) facade loads a Study and then invokes Runtime.
Study coordinates declared intent; runtime accepts that completed Study and
coordinates active execution.
Advanced consumers may use Study::load and runtime::advanced::execute, but
ordinary projects should not.
The repository's attractor_2d project combines
these pieces end to end: six swept Rust model tasks feed one directly declared
Python plotting phase that opens the verified recordings and emits an SVG in
the configured output/plots directory.
Each target subsystem publishes module::basic and module::advanced, with
the latter a strict superset. prelude::basic contains the small model-author
surface. Persistence writing is automatic and private; only verified reading
appears in the Advanced tier.
See src/state/api.md,
src/observation/api.md,
src/task/api.md,
src/config/api.md,
src/study/api.md,
src/persistence/api.md,
src/runtime/api.md,
src/ui/api.md,
src/error/api.md,
src/prelude/api.md, and the repository
architecture.md.
Validation
From the repository root:
RUSTDOCFLAGS="-D warnings"