Skip to main content

scientific_workflow/
lib.rs

1//! Rust primitives for reproducible scientific workflows.
2//!
3//! `scientific-workflow` provides the data and execution foundations needed to
4//! describe scientific systems, record their evolution, and organize scoped
5//! computational work. The crate is intentionally divided by responsibility:
6//! state representation, in-memory state time series, storage, dispatch, and
7//! language bridges remain separate modules rather than accumulating behind
8//! one monolithic interface.
9//!
10//! # Current modules
11//!
12//! [`configuration`] provides the standard `config/{fixed,sweep,paths}.json`
13//! project layout, deterministic Cartesian or explicit-case task expansion,
14//! complete cheap task-configuration handles, exact sweep-value selection,
15//! named path resolution, and byte-exact source export.
16//! [`project`] adds the mandatory conventional `config/state.json` schema as
17//! one immutable [`project::ScientificProject`]. [`execution`] creates
18//! collision-resistant or caller-named execution scopes and deterministic task
19//! recording paths without taking ownership away from storage writers.
20//! [`reporting`] provides parameter-identified parallel progress tracking and
21//! one process-wide human-facing terminal owner.
22//!
23//! [`system_state`] provides:
24//!
25//! - JSON-defined, immutable field layouts;
26//! - optional natural-language field descriptions without persisted Rust types;
27//! - heterogeneous concrete Rust payloads behind a typed API;
28//! - clone-free payload insertion, mutation, and extraction;
29//! - explicit per-payload cloning of complete states;
30//! - mutable, checked time-point progression.
31//!
32//! Type erasure and boxing remain internal to that module. Downstream crates
33//! work with their original concrete payload types.
34//!
35//! [`time_series`] provides the in-memory analysis collection for complete,
36//! ordered states. It enforces shared-layout identity and increasing simulation
37//! indices, offers a lightweight borrowed view, and permits field-level
38//! mutation without exposing mutable state time. It deliberately performs no
39//! serialization, chunking, or filesystem IO.
40//!
41//! [`storage`] provides named partial-state streams with writer-owned sampling
42//! intervals, borrowed JSON encoding only when due, bounded asynchronous
43//! persistence through one worker per recording, byte-targeted chunking, atomic recording
44//! metadata, automatic operational timing, terminal summaries, per-key payload
45//! decoders, and verified full-series or latest-state reconstruction.
46//! Import [`prelude`] when an application wants the complete supported API in
47//! scope without listing each module separately.
48//!
49//! # Basic use
50//!
51//! ```no_run
52//! use scientific_workflow::prelude::*;
53//!
54//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
55//! let spec = SystemStateSchema::load_json_template("state.json")?;
56//! let mut state = spec.create_empty_state(SimulationTime::from_iteration(0));
57//!
58//! assert!(
59//!     state
60//!         .insert_payload("population", vec![10_u64, 20, 30])?
61//!         .is_none()
62//! );
63//! state
64//!     .payload_mut::<Vec<u64>>("population")?
65//!     .push(40);
66//! let time = state.advance_simulation_time(None)?;
67//! assert_eq!(time.iteration(), 1);
68//! let population = state.take_payload::<Vec<u64>>("population")?;
69//!
70//! assert_eq!(population, vec![10, 20, 30, 40]);
71//! # Ok(())
72//! # }
73//! ```
74//!
75//! Future dispatcher functionality will organize scoped workflow execution
76//! without changing the public state-value ownership or storage contracts.
77
78mod clock;
79
80pub mod configuration;
81pub mod execution;
82pub mod prelude;
83pub mod project;
84pub mod reporting;
85pub mod storage;
86pub mod system_state;
87pub mod time_series;