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`] combines task configuration with either a project-owned
17//! `config/state.json` schema or a canonical schema supplied by a fixed-model
18//! crate as one immutable [`project::ScientificProject`]. [`execution`] creates
19//! collision-resistant or caller-named execution scopes and deterministic task
20//! recording paths without taking ownership away from storage writers.
21//! [`artifact`] atomically publishes and verifies content-addressed immutable
22//! bytes while leaving their scientific representation to downstream crates.
23//! [`reporting`] provides parameter-identified parallel progress tracking and
24//! one process-wide human-facing terminal owner. [`rng_record`] provides only
25//! validated, persisted RNG provenance records; random generation remains an
26//! application responsibility.
27//!
28//! [`system_state`] provides:
29//!
30//! - JSON-defined, immutable field layouts;
31//! - optional natural-language field descriptions without persisted Rust types;
32//! - heterogeneous concrete Rust payloads behind a typed API;
33//! - clone-free payload insertion, mutation, and extraction;
34//! - explicit per-payload cloning of complete states;
35//! - mutable, checked time-point progression.
36//!
37//! Type erasure and boxing remain internal to that module. Downstream crates
38//! work with their original concrete payload types.
39//!
40//! [`time_series`] provides the in-memory analysis collection for complete,
41//! ordered states. It enforces shared-layout identity and increasing simulation
42//! indices, offers a lightweight borrowed view, and permits field-level
43//! mutation without exposing mutable state time. It deliberately performs no
44//! serialization, chunking, or filesystem IO.
45//!
46//! [`storage`] provides named partial-state streams with writer-owned sampling
47//! intervals, borrowed JSON encoding only when due, bounded asynchronous
48//! persistence through one worker per recording, byte-targeted chunking, atomic recording
49//! metadata, automatic operational timing, terminal summaries, per-key payload
50//! decoders, and verified full-series or latest-state reconstruction.
51//! Import [`prelude`] when an application wants the complete supported API in
52//! scope without listing each module separately.
53//!
54//! # Basic use
55//!
56//! ```no_run
57//! use scientific_workflow::prelude::*;
58//!
59//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
60//! let spec = SystemStateSchema::load_json_template("state.json")?;
61//! let mut state = spec.create_empty_state(SimulationTime::from_iteration(0));
62//!
63//! assert!(
64//! state
65//! .insert_payload("population", vec![10_u64, 20, 30])?
66//! .is_none()
67//! );
68//! state
69//! .payload_mut::<Vec<u64>>("population")?
70//! .push(40);
71//! let time = state.advance_simulation_time(None)?;
72//! assert_eq!(time.iteration(), 1);
73//! let population = state.take_payload::<Vec<u64>>("population")?;
74//!
75//! assert_eq!(population, vec![10, 20, 30, 40]);
76//! # Ok(())
77//! # }
78//! ```
79//!
80//! Future dispatcher functionality will organize scoped workflow execution
81//! without changing the public state-value ownership or storage contracts.
82
83mod clock;
84
85pub mod artifact;
86pub mod configuration;
87pub mod execution;
88pub mod prelude;
89pub mod project;
90pub mod reporting;
91pub mod rng_record;
92pub mod storage;
93pub mod system_state;
94pub mod time_series;